Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 293 lines (258 sloc) 9.561 kb
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
1 #include "parrot/parrot.h"
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
2 #include "parrot/embed.h"
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
3 #include "parrot/api.h"
1b6d1ce @Whiteknight start breaking up the embedding stuff into multiple files. Add embed_pri...
Whiteknight authored
4 #include "embed_private.h"
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
5
3f8ed92 @Whiteknight fix some file references and run headerizer to see my work so far
Whiteknight authored
6 /* HEADERIZER HFILE: include/parrot/api.h */
7
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
8 PARROT_API
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
9 Parrot_Int
82cbd84 @Whiteknight parrot executable compiles, but miniparrot does not link. I need to sort...
Whiteknight authored
10 Parrot_api_get_last_error(ARGMOD(PMC * interp_pmc), ARGOUT(Parrot_String * errmsg))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
11 {
12 EMBED_API_CALLIN(interp_pmc, interp);
13 *errmsg = Parrot_str_new(interp, "Generic Error Message", 0);
14 EMBED_API_CALLOUT(interp_pmc, interp);
15 }
16
17 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
18 Parrot_Int
19 Parrot_api_make_interpreter(ARGIN_NULLOK(PMC *parent), Parrot_Int flags, ARGIN_NULLOK(Parrot_Init_Args *args), ARGOUT(PMC **interp))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
20 {
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an inte...
Whiteknight authored
21 ASSERT_ARGS(Parrot_api_make_interpreter)
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
22 int alt_stacktop;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
23 Parrot_Interp interp_raw;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an inte...
Whiteknight authored
24 void *stacktop_ptr = &alt_stacktop;
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
25 PMC * iglobals;
82cbd84 @Whiteknight parrot executable compiles, but miniparrot does not link. I need to sort...
Whiteknight authored
26 const Parrot_Interp parent_raw = PMC_IS_NULL(parent) ? NULL : GET_RAW_INTERP(parent);
27 interp_raw = allocate_interpreter(parent_raw, flags);
28 if (args) {
29 if (args->stacktop)
30 stacktop_ptr = args->stacktop;
31 if (args->gc_system)
32 Parrot_gc_set_system_type(interp_raw, args->gc_system);
33 if (args->gc_threshold)
34 interp_raw->gc_threshold = args->gc_threshold;
35 if (args->hash_seed)
36 interp_raw->hash_seed = args->hash_seed;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an inte...
Whiteknight authored
37 }
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
38 initialize_interpreter(interp_raw, stacktop_ptr);
39 iglobals = interp_raw->iglobals;
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
40 *interp = VTABLE_get_pmc_keyed_int(interp_raw, interp_raw->iglobals, (Parrot_Int)IGLOBALS_INTERPRETER);
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an inte...
Whiteknight authored
41 return !PMC_IS_NULL(*interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
42 }
43
44 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
45 Parrot_Int
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
46 Parrot_api_set_runcore(ARGIN(PMC *interp_pmc), const char * corename, Parrot_UInt trace)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
47 {
48 ASSERT_ARGS(Parrot_api_set_runcore)
3ea891c First round of syntax error fixes
Mariano Wahlmann authored
49 EMBED_API_CALLIN(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
50 if (trace) {
51 Parrot_set_trace(interp, (Parrot_trace_flags)trace);
52 Parrot_set_run_cure(interp, PARROT_SLOW_CORE);
53 } else {
54 Parrot_Run_core_t core = PARROT_SLOW_CORE;
55 if (!strcmp(corename, "slow"))
56 core = PARROT_SLOW_CORE;
57 else if (!strcmp(corename, "fast") || !strcmp(corename, "jit") || !strcmp(corename, "function"))
58 core = PARROT_FAST_CORE;
59 else if (!strcmp(corename, "exec"))
60 core = PARROT_EXEC_CORE;
61 else if (!strcmp(corename, "trace"))
62 core = PARROT_SLOW_CORE; // !!!
63 else if (!strcmp(corename, "profiling"))
64 core = PARROT_PROFILING_CORE;
65 else if (!strcmp(corename, "gcdebug"))
66 core = PARROT_GC_DEBUG_CORE;
67 else
68 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Invalid runcore type %s", corename);
69 Parrot_set_trace(interp, (Parrot_trace_flags)trace);
70 Parrot_set_run_core(interp, core);
71 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
72 EMBED_API_CALLOUT(interp_pmc, interp)
73 }
74
75 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
76 Parrot_Int
77 Parrot_api_debug_flag(ARGMOD(PMC *interp_pmc), Parrot_Int flags, Parrot_Int set)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
78 {
79 ASSERT_ARGS(Parrot_api_debug_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
80 EMBED_API_CALLIN(interp_pmc, interp)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
81 if (set)
82 interp->debug_flags |= flags;
83 else
84 interp->debug_flags &= ~flags;
85 EMBED_API_CALLOUT(interp_pmc, interp);
86 }
87
88 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
89 Parrot_Int
90 Parrot_api_flag(ARGMOD(PMC *interp_pmc), Parrot_Int flags, Parrot_Int set)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
91 {
92 ASSERT_ARGS(Parrot_api_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
93 EMBED_API_CALLIN(interp_pmc, interp)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
94 if (set) {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
95 Interp_flags_SET(interp, flags);
96 if (flags & (PARROT_BOUNDS_FLAG | PARROT_PROFILE_FLAG))
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
97 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
98 }
99 else
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
100 Interp_flags_CLEAR(interp, flags);
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
101 EMBED_API_CALLOUT(interp_pmc, interp);
102 }
103
104 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
105 Parrot_Int
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
106 Parrot_api_set_executable_name(ARGMOD(PMC *interp_pmc), ARGIN(const char * name))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
107 {
108 ASSERT_ARGS(Parrot_api_set_executable_name)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
109 EMBED_API_CALLIN(interp_pmc, interp)
1a692e9 @Whiteknight _set_executable_name takes a C string instead of a Parrot string, for co...
Whiteknight authored
110 STRING * const name_str = Parrot_str_new(interp, name, 0);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
111 PMC * const name_pmc = Parrot_pmc_new(interp, enum_class_String);
1a692e9 @Whiteknight _set_executable_name takes a C string instead of a Parrot string, for co...
Whiteknight authored
112 VTABLE_set_string_native(interp, name_pmc, name_str);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
113 VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_EXECUTABLE,
114 name_pmc);
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
115 EMBED_API_CALLOUT(interp_pmc, interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
116 }
117
118 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
119 Parrot_Int
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
120 Parrot_api_destroy_interpreter(ARGIN(PMC *interp_pmc))
121 {
122 ASSERT_ARGS(Parrot_api_destroy_interpreter)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
123 EMBED_API_CALLIN(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
124 Parrot_destroy(interp);
1a692e9 @Whiteknight _set_executable_name takes a C string instead of a Parrot string, for co...
Whiteknight authored
125 Parrot_exit(interp, 0);
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
126 EMBED_API_CALLOUT(interp_pmc, interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
127 }
128
129 /*
130
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
131 =item C<PARROT_API Parrot_Int Parrot_api_load_bytecode_file(PMC *interp_pmc,
132 const char *filename, PMC **pbc)>
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
133
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
134 Load a bytecode file and return a bytecode PMC.
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
135
136 =cut
137
138 */
139
140 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
141 Parrot_Int
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
142 Parrot_api_load_bytecode_file(ARGMOD(PMC *interp_pmc), ARGIN(const char *filename), ARGOUT(PMC **pbc))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
143 {
144 ASSERT_ARGS(Parrot_api_load_bytecode_file)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
145 EMBED_API_CALLIN(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
146 PackFile * const pf = Parrot_pbc_read(interp, filename, 0);
147 if (!pf)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
148 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not load packfile");
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
149 *pbc = Parrot_pmc_new(interp, enum_class_Packfile);
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
150 VTABLE_set_pointer(interp, *pbc, pf);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
151 EMBED_API_CALLOUT(interp_pmc, interp)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
152 }
153
154 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
155 Parrot_Int
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
156 Parrot_api_run_bytecode(ARGMOD(PMC *interp_pmc), ARGIN(PMC *pbc), ARGIN(PMC *mainargs))
157 {
158 ASSERT_ARGS(Parrot_api_run_bytecode)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
159 EMBED_API_CALLIN(interp_pmc, interp)
160 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
161 if (!pf)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
162 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not get packfile");
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
163 Parrot_pbc_load(interp, pf);
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
164 PackFile_fixup_subs(interp, PBC_IMMEDIATE, NULL);
165 PackFile_fixup_subs(interp, PBC_POSTCOMP, NULL);
166 PackFile_fixup_subs(interp, PBC_MAIN, NULL);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
167 EMBED_API_CALLOUT(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
168 }
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
169
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
170 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
171 Parrot_Int
172 Parrot_api_build_argv_array(ARGMOD(PMC *interp_pmc), Parrot_Int argc, ARGIN(char **argv), ARGOUT(PMC **args))
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
173 {
174 ASSERT_ARGS(Parrot_api_build_argv_array)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
175 EMBED_API_CALLIN(interp_pmc, interp)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
176 PMC * const userargv = Parrot_pmc_new(interp, enum_class_ResizableStringArray);
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
177 Parrot_Int i;
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
178
179 for (i = 0; i < argc; ++i) {
180 /* Run through argv, adding everything to the array */
181 STRING * const arg = Parrot_str_new_init(interp, argv[i], strlen(argv[i]),
182 Parrot_utf8_encoding_ptr, PObj_external_FLAG);
183 VTABLE_push_string(interp, userargv, arg);
184 }
185 *args = userargv;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
186 EMBED_API_CALLOUT(interp_pmc, interp)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
187 }
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
188
189 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
190 Parrot_Int
191 Parrot_api_set_warnings(ARGMOD(PMC *interp_pmc), Parrot_Int flags)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
192 {
193 ASSERT_ARGS(Parrot_api_set_warnings)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
194 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
195 /* Activates the given warnings. (Macro from warnings.h.) */
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
196 PARROT_WARNINGS_on(interp, flags);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
197 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
198 }
199
200 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
201 Parrot_Int
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
202 Parrot_api_set_output_file(ARGMOD(PMC *interp_pmc), ARGIN_NULLOK(const char * filename))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
203 {
204 ASSERT_ARGS(Parrot_api_set_output_file)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
205 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
206 if (!filename && !interp->output_file)
207 interp->output_file = "-";
208 else
209 interp->output_file = filename;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
210 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
211 }
212
213 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
214 Parrot_Int
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
215 Parrot_api_add_library_search_path(ARGMOD(PMC *interp_pmc), ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
216 {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
217 //ASSERT_ARGS(Parrot_api_add_library_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
218 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
219 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_LIBRARY);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
220 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
221 }
222
223 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
224 Parrot_Int
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
225 Parrot_api_add_include_search_path(ARGMOD(PMC *interp_pmc), ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
226 {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
227 //ASSERT_ARGS(Parrot_api_add_include_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
228 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
229 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_INCLUDE);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
230 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
231 }
232
233 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
234 Parrot_Int
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
235 Parrot_api_add_dynext_search_path(ARGMOD(PMC *interp_pmc), ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
236 {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
237 //ASSERT_ARGS(Parrot_api_add_dynext_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
238 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
239 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_DYNEXT);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
240 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
241 }
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
242
243 /*
244
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
245 =item C<PARROT_API Parrot_Int Parrot_api_set_stdhandles(PMC *interp_pmc,
246 Parrot_Int stdin, Parrot_Int stdout, Parrot_Int stderr)>
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
247
248 Set the std file descriptors for the embedded interpreter. Any file descriptor
249 passed as argument and set to C<PIO_INVALID_HANDLE> is ignored.
250
251 =cut
252
253 */
254
255 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
256 Parrot_Int
257 Parrot_api_set_stdhandles(ARGIN(PMC *interp_pmc), Parrot_Int stdin, Parrot_Int stdout, Parrot_Int stderr)
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
258 {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
259 ASSERT_ARGS(Parrot_api_set_stdhandles)
260 EMBED_API_CALLIN(interp_pmc, interp)
261 void *dummy;
262
263 if(PIO_INVALID_HANDLE != (PIOHANDLE)stdin) {
264 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
265 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)stdin);
266 dummy = (void *)Parrot_io_stdhandle(interp,PIO_STDIN_FILENO,pmc);
267 }
268
269 if(PIO_INVALID_HANDLE != (PIOHANDLE)stdout) {
270 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
271 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)stdout);
272 dummy = (void *)Parrot_io_stdhandle(interp,PIO_STDOUT_FILENO,pmc);
273 }
274
275 if(PIO_INVALID_HANDLE != (PIOHANDLE)stderr) {
276 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
277 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)stderr);
278 dummy = (void *)Parrot_io_stdhandle(interp,PIO_STDERR_FILENO,pmc);
279 }
280
281 EMBED_API_CALLOUT(interp_pmc, interp)
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
282 }
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
283
284 PARROT_API
285 Parrot_Int
286 Parrot_api_get_runtime_path(Parrot_PMC interp_pmc, ARGOUT(Parrot_String *runtime))
287 {
288 EMBED_API_CALLIN(interp_pmc, interp);
289 *runtime = Parrot_get_runtime_path(interp);
290 EMBED_API_CALLOUT(interp_pmc, interp);
291 }
292
Something went wrong with that request. Please try again.