Skip to content
Newer
Older
100644 816 lines (624 sloc) 23 KB
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
1 /*
2 Copyright (C) 2010, Parrot Foundation.
3
4 =head1 NAME
5
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
6 src/embed/api.c - The Parrot embedding interface
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
7
8 =head1 DESCRIPTION
9
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
10 This file implements functions of the Parrot embedding interface.
11
12 =head2 Functions
13
14 =over 4
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
15
16 =cut
17
18 */
19
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
20 #include "parrot/parrot.h"
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
21 #include "parrot/runcore_api.h"
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
22 #include "parrot/embed.h"
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
23 #include "parrot/api.h"
1b6d1ce @Whiteknight start breaking up the embedding stuff into multiple files. Add embed_…
Whiteknight authored
24 #include "embed_private.h"
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
25
3f8ed92 @Whiteknight fix some file references and run headerizer to see my work so far
Whiteknight authored
26 /* HEADERIZER HFILE: include/parrot/api.h */
27
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
28
29 /*
30
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
31 =item C<Parrot_Int Parrot_api_get_result(Parrot_PMC interp_pmc, Parrot_Int
32 *is_error, Parrot_PMC * exception, Parrot_Int *exit_code, Parrot_String *
33 errmsg)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
34
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
35 Gets the results of the last API function call and stores the results in
36 C<is_error>, C<exception>, C<exit_code> and C<errmsg>. This function returns
37 a true value if this call is successful and false value otherwise. The stored
38 information is as follow:
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
39
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
40 C<is_error> a true value if an unhandled exception was thrown or the program
41 terminated with an error condition and a false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
42
43 C<exception> the last exception thrown.
44
45 C<exit_code> the exit code of the running program.
46
47 C<errmsg> contains an string with the last error message.
48
49 =cut
50
51 */
52
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
53 PARROT_API
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
54 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
55 Parrot_api_get_result(Parrot_PMC interp_pmc, ARGOUT(Parrot_Int *is_error),
56 ARGOUT(Parrot_PMC * exception), ARGOUT(Parrot_Int *exit_code),
57 ARGOUT(Parrot_String * errmsg))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
58 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
59 ASSERT_ARGS(Parrot_api_get_result)
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
60 EMBED_API_CALLIN(interp_pmc, interp)
be50d63 @bluescreen10 Implemented first version of Parrot_get_result, now a lot of failing …
bluescreen10 authored
61 *exit_code = interp->exit_code;
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
62 *exception = interp->final_exception;
73f662d @Whiteknight some fixes so libparrot builds with g++
Whiteknight authored
63 if (PMC_IS_NULL(*exception)) {
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
64 *is_error = 0;
65 *errmsg = STRINGNULL;
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
66 }
67 else {
b3af8c9 @Whiteknight fix main.c so that we check the is_error flag and only show an error …
Whiteknight authored
68 STRING * const severity_str = Parrot_str_new(interp, "severity", 0);
69 INTVAL severity = VTABLE_get_integer_keyed_str(interp, *exception, severity_str);
70 *is_error = (severity != EXCEPT_exit);
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
71 *errmsg = VTABLE_get_string(interp, *exception);
72 }
73 interp->final_exception = PMCNULL;
be50d63 @bluescreen10 Implemented first version of Parrot_get_result, now a lot of failing …
bluescreen10 authored
74 interp->exit_code = 0;
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
75 EMBED_API_CALLOUT(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
76 }
77
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
78 /*
79
80 =item C<Parrot_Int Parrot_api_get_exception_backtrace(Parrot_PMC interp_pmc,
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
81 Parrot_PMC exception, Parrot_String * bt)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
82
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
83 Gets the backtrace of the interpreter's call chain for the given exception
84 C<expcetion> and stores the results in string C<bt>. This function returns a
85 true value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
86
87 =cut
88
89 */
90
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
91 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
92 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
93 Parrot_api_get_exception_backtrace(Parrot_PMC interp_pmc,
94 Parrot_PMC exception, ARGOUT(Parrot_String * bt))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
95 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
96 ASSERT_ARGS(Parrot_api_get_exception_backtrace)
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
97 EMBED_API_CALLIN(interp_pmc, interp)
98 STRING * const bts = Parrot_dbg_get_exception_backtrace(interp, exception);
99 *bt = bts;
100 EMBED_API_CALLOUT(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
101 }
102
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
103
104 /*
105
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
106 =item C<Parrot_Int Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int
107 flags, Parrot_Init_Args *args, Parrot_PMC *interp)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
108
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
109 Creates a new interpreter and stores it in C<interp>. It takes three optional
110 parameters the new interpreter's C<flags>, the initialization paremeters C<args>
111 and the C<parent> interpreter. This function returns a true value if this call
112 is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
113
114 =cut
115
116 */
117
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
118 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
119 Parrot_Int
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
120 Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int flags,
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
121 ARGIN_NULLOK(Parrot_Init_Args *args), ARGOUT(Parrot_PMC *interp))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
122 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
123 ASSERT_ARGS(Parrot_api_make_interpreter)
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
124 int alt_stacktop;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
125 Parrot_Interp interp_raw;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an i…
Whiteknight authored
126 void *stacktop_ptr = &alt_stacktop;
82cbd84 @Whiteknight parrot executable compiles, but miniparrot does not link. I need to s…
Whiteknight authored
127 const Parrot_Interp parent_raw = PMC_IS_NULL(parent) ? NULL : GET_RAW_INTERP(parent);
128 interp_raw = allocate_interpreter(parent_raw, flags);
129 if (args) {
130 if (args->stacktop)
131 stacktop_ptr = args->stacktop;
132 if (args->gc_system)
133 Parrot_gc_set_system_type(interp_raw, args->gc_system);
134 if (args->gc_threshold)
135 interp_raw->gc_threshold = args->gc_threshold;
136 if (args->hash_seed)
137 interp_raw->hash_seed = args->hash_seed;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an i…
Whiteknight authored
138 }
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
139 initialize_interpreter(interp_raw, stacktop_ptr);
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
140 *interp = VTABLE_get_pmc_keyed_int(
141 interp_raw, interp_raw->iglobals, (Parrot_Int)IGLOBALS_INTERPRETER);
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an i…
Whiteknight authored
142 return !PMC_IS_NULL(*interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
143 }
144
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
145 /*
146
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
147 =item C<Parrot_Int Parrot_api_set_runcore(Parrot_PMC interp_pmc, const char *
148 corename, Parrot_UInt trace)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
149
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
150 Sets the C<interp_pmc>'s bytecode running core, the core is specified by the
151 C<corename>. This function returns a true value if this call is successful and
152 false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
153
154 =cut
155
156 */
157
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
158 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
159 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
160 Parrot_api_set_runcore(Parrot_PMC interp_pmc, ARGIN(const char * corename),
161 Parrot_UInt trace)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
162 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
163 ASSERT_ARGS(Parrot_api_set_runcore)
3ea891c First round of syntax error fixes
Mariano Wahlmann authored
164 EMBED_API_CALLIN(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
165 if (trace) {
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
166 Parrot_pcc_trace_flags_on(interp, interp->ctx, trace);
167 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
168 }
169 else {
372f8f7 @bluescreen10 Make bounds runcore available
bluescreen10 authored
170 if (!strcmp(corename, "slow") || !strcmp(corename, "bounds"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
171 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
172 else if (!strcmp(corename, "fast") ||
173 !strcmp(corename, "jit") || !strcmp(corename, "function"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
174 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "fast"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
175 else if (!strcmp(corename, "exec"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
176 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "exec"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
177 else if (!strcmp(corename, "trace"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
178 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
179 else if (!strcmp(corename, "profiling"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
180 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "profiling"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
181 else if (!strcmp(corename, "gcdebug"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
182 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "gcdebug"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
183 else
184 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Invalid runcore type %s", corename);
185 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
186 EMBED_API_CALLOUT(interp_pmc, interp)
187 }
188
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
189 /*
190
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
191 =item C<Parrot_Int Parrot_api_debug_flag(Parrot_PMC interp_pmc, Parrot_Int
192 flags, Parrot_Int set)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
193
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
194 Sets/Unsets the C<interp_pmc>'s debug flags. If C<set> is in a true value debug
195 flags are set otherwise debug flags are cleared. This function returns a true
196 value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
197
198 =cut
199
200 */
201
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
202 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
203 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
204 Parrot_api_debug_flag(Parrot_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 in…
Whiteknight authored
205 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
206 ASSERT_ARGS(Parrot_api_debug_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
207 EMBED_API_CALLIN(interp_pmc, interp)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
208 if (set)
209 interp->debug_flags |= flags;
210 else
211 interp->debug_flags &= ~flags;
212 EMBED_API_CALLOUT(interp_pmc, interp);
213 }
214
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
215 /*
216
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
217 =item C<Parrot_Int Parrot_api_flag(Parrot_PMC interp_pmc, Parrot_Int flags,
218 Parrot_Int set)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
219
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
220 Set/Unset the C<interp_pmc>'s general flags. If C<set> is in a true value general
221 flags are set otherwise passed flags are cleared. This function returns a true
222 value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
223
224 =cut
225
226 */
227
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
228 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
229 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
230 Parrot_api_flag(Parrot_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 in…
Whiteknight authored
231 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
232 ASSERT_ARGS(Parrot_api_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
233 EMBED_API_CALLIN(interp_pmc, interp)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
234 if (set) {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
235 Interp_flags_SET(interp, flags);
236 if (flags & (PARROT_BOUNDS_FLAG | PARROT_PROFILE_FLAG))
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
237 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
238 }
239 else
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
240 Interp_flags_CLEAR(interp, flags);
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
241 EMBED_API_CALLOUT(interp_pmc, interp);
242 }
243
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
244 /*
245
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
246 =item C<Parrot_Int Parrot_api_set_executable_name(Parrot_PMC interp_pmc, const
247 char * name)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
248
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
249 Sets the executable name for the C<interp_pmc> interpreter. This function returns
250 a true value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
251
252 =cut
253
254 */
255
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
256 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
257 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
258 Parrot_api_set_executable_name(Parrot_PMC interp_pmc, ARGIN(const char * name))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
259 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
260 ASSERT_ARGS(Parrot_api_set_executable_name)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
261 EMBED_API_CALLIN(interp_pmc, interp)
1a692e9 @Whiteknight _set_executable_name takes a C string instead of a Parrot string, for…
Whiteknight authored
262 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
263 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…
Whiteknight authored
264 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
265 VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_EXECUTABLE,
266 name_pmc);
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
267 EMBED_API_CALLOUT(interp_pmc, interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
268 }
269
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
270 /*
271
272 =item C<Parrot_Int Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)>
273
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
274 Destroys the C<interp_pmc> interpreter, freeing the memory structures allocated
275 for it. This function returns a true value if this call is successful and false
276 value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
277
278 =cut
279
280 */
281
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
282 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
283 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
284 Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
285 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
286 ASSERT_ARGS(Parrot_api_destroy_interpreter)
2dc5187 @nwellnhof [embed] Fix segfault with --leak-test option
nwellnhof authored
287 void * _oldtop;
288 Parrot_jump_buff env;
289 Interp * const interp = GET_INTERP(interp_pmc);
290 _oldtop = interp->lo_var_ptr;
291 if (_oldtop == NULL)
292 interp->lo_var_ptr = &_oldtop;
293 interp->api_jmp_buf = &env;
294 if (setjmp(env)) {
295 /* We can't check for potential errors because the interpreter
296 * might have been destroyed. */
297 return 1;
298 }
299 else {
300 Parrot_destroy(interp);
301 Parrot_x_exit(interp, 0);
302 /* Never reached, x_exit calls longjmp */
303 return 1;
304 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
305 }
306
307 /*
308
b9cdf9c @jkeenan After fixing C++ comments, I re-ran headerizer and modified these fil…
jkeenan authored
309 =item C<Parrot_Int Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc, const
310 char *filename, Parrot_PMC * pbc)>
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
311
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
312 Load a bytecode file and stores the resulting bytecode in C<pbc>. This function
313 returns a true value if this call is successful and false value otherwise.
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
314
315 =cut
316
317 */
318
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebu…
Whiteknight authored
319 /* TODO: This only works with the inital bytecode. After this we should use
320 Parrot_append_bytecode or something similar */
321
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
322 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
323 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
324 Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc,
325 ARGIN(const char *filename), ARGOUT(Parrot_PMC * pbc))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
326 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
327 ASSERT_ARGS(Parrot_api_load_bytecode_file)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
328 EMBED_API_CALLIN(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
329 PackFile * const pf = Parrot_pbc_read(interp, filename, 0);
330 if (!pf)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
331 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not load packfile");
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
332 do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL);
950d701 @Whiteknight Packfile PMCs don't do what I need them to do (yet). Use UnManagedStr…
Whiteknight authored
333 *pbc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
334 VTABLE_set_pointer(interp, *pbc, pf);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
335 EMBED_API_CALLOUT(interp_pmc, interp)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
336 }
337
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
338 /*
339
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
340 =item C<Parrot_Int Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc, const
341 unsigned char * const pbc, Parrot_Int bytecode_size, Parrot_PMC * pbcpmc)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
342
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
343 Unpacks a bytecode from a buffer C<pbc> of a C<bytecode_size> size, and stores
344 the resulting bytecode in C<pbcpmc>. This function returns a true value if this
345 call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
346
347 =cut
348
349 */
350
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
351 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
352 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
353 Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc,
354 ARGIN(const unsigned char * const pbc), Parrot_Int bytecode_size,
355 ARGOUT(Parrot_PMC * pbcpmc))
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
356 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
357 ASSERT_ARGS(Parrot_api_load_bytecode_bytes)
99428c2 Make src/embed/pmc.c & src/embed/api.c compile with gcc
Mariano Wahlmann authored
358 EMBED_API_CALLIN(interp_pmc, interp)
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
359 PackFile * const pf = PackFile_new(interp, 0);
360 if (!pf)
361 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not create packfile");
362
363 if (!PackFile_unpack(interp, pf, (const opcode_t *)pbc, bytecode_size))
364 Parrot_ex_throw_from_c_args(interp, NULL, 1, "could not unpack packfile");
365 do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL);
366 *pbcpmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
367 VTABLE_set_pointer(interp, *pbcpmc, pf);
368 EMBED_API_CALLOUT(interp_pmc, interp);
369 }
370
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebu…
Whiteknight authored
371 /* Load the bytecode into the interpreter, but don't execute it */
372 /* TODO: This only works with the inital bytecode. After this we should use
373 Parrot_append_bytecode or something similar */
374
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
375 /*
376
377 =item C<Parrot_Int Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
378 pbc, Parrot_PMC *main_sub)>
379
380 Prepares the bytecode C<pbc> to be run and stores the entry point subroutine in
381 C<main_sub>. This function returns a true value if this call is successful and
382 false value otherwise.
383
384 =cut
385
386 */
387
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
388 PARROT_API
389 Parrot_Int
390 Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
391 ARGOUT(Parrot_PMC *main_sub))
392 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
393 ASSERT_ARGS(Parrot_api_ready_bytecode)
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
394 EMBED_API_CALLIN(interp_pmc, interp)
395 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
396
397 /* Debugging mode nonsense. */
398 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
399 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
400 interp->run_core->name);
401 }
402
403 if (!pf)
404 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not get packfile");
405 if (pf->cur_cs != NULL)
406 Parrot_pbc_load(interp, pf);
407 PackFile_fixup_subs(interp, PBC_MAIN, NULL);
408 *main_sub = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
409 Parrot_pcc_set_constants(interp, interp->ctx, interp->code->const_table);
410 EMBED_API_CALLOUT(interp_pmc, interp)
411 }
412
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
413
414 /*
415
416 =item C<Parrot_Int Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
417 pbc, Parrot_PMC mainargs)>
418
419 Runs the bytecode C<pbc> passing optional C<mainargs> parameters. This function
420 returns a true value if this call is successful and false value otherwise.
421
422 =cut
423
424 */
425
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
426 PARROT_API
427 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
428 Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
429 Parrot_PMC mainargs)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
430 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
431 ASSERT_ARGS(Parrot_api_run_bytecode)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
432 EMBED_API_CALLIN(interp_pmc, interp)
65bf81a @Whiteknight actually run the code, don't just look at it. Miniparrot runs now. pa…
Whiteknight authored
433 PMC * main_sub = NULL;
434
98cd26c @Whiteknight don't call Parrot_pbc_load if the PBC comes straight out of IMCC. IMC…
Whiteknight authored
435 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
9f7a94c @Whiteknight make sure to set :main() args in the iglobals array. This makes ops2c…
Whiteknight authored
436
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
437 /* Debugging mode nonsense. */
438 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
439 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
440 interp->run_core->name);
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
441 }
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
442
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
443 if (!pf)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
444 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not get packfile");
98cd26c @Whiteknight don't call Parrot_pbc_load if the PBC comes straight out of IMCC. IMC…
Whiteknight authored
445 if (pf->cur_cs != NULL)
446 Parrot_pbc_load(interp, pf);
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
447 PackFile_fixup_subs(interp, PBC_MAIN, NULL);
65bf81a @Whiteknight actually run the code, don't just look at it. Miniparrot runs now. pa…
Whiteknight authored
448 main_sub = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
449
450 /* if no sub was marked being :main, we create a dummy sub with offset 0 */
451
452 if (!main_sub)
453 main_sub = set_current_sub(interp);
454
455 Parrot_pcc_set_sub(interp, CURRENT_CONTEXT(interp), NULL);
456 Parrot_pcc_set_constants(interp, interp->ctx, interp->code->const_table);
457
9f7a94c @Whiteknight make sure to set :main() args in the iglobals array. This makes ops2c…
Whiteknight authored
458 VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_ARGV_LIST, mainargs);
73f662d @Whiteknight some fixes so libparrot builds with g++
Whiteknight authored
459 Parrot_pcc_invoke_sub_from_c_args(interp, main_sub, "P->", mainargs);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
460 EMBED_API_CALLOUT(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
461 }
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
462
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
463 /*
464
465 =item C<Parrot_Int Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc,
466 Parrot_PMC pbc, const char * const outfile, Parrot_Int opts)>
467
468 Disassembles and prints out the C<pbc> bytecode. This function returns a true
469 value if this call is successful and false value otherwise.
470
471 =cut
472
473 */
474
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
475 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
476 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
477 Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
478 ARGIN_NULLOK(const char * const outfile), Parrot_Int opts)
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
479 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
480 ASSERT_ARGS(Parrot_api_disassemble_bytecode)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
481 EMBED_API_CALLIN(interp_pmc, interp)
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
482 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
483 if (!pf)
484 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not get packfile");
485 if (pf->cur_cs != NULL)
486 Parrot_pbc_load(interp, pf);
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
487 /* TODO: Break up the dependency with emebed.c */
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
488 Parrot_disassemble(interp, outfile, (Parrot_disassemble_options)opts);
489 EMBED_API_CALLOUT(interp_pmc, interp);
490 }
491
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
492 /*
493
494 =item C<Parrot_Int Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int
495 flags)>
496
497 Enables C<inter_pmc>'s warning messages the type of warning information to be
498 print out is specified by C<flags>. This function returns a true value if this
499 call is successful and false value otherwise.
500
501 =cut
502
503 */
504
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
505 PARROT_API
506 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
507 Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int flags)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
508 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
509 ASSERT_ARGS(Parrot_api_set_warnings)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
510 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
511 /* Activates the given warnings. (Macro from warnings.h.) */
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
512 PARROT_WARNINGS_on(interp, flags);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
513 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
514 }
515
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
516 /*
517
518 =item C<Parrot_Int Parrot_api_set_output_file(Parrot_PMC interp_pmc, const char
519 * filename)>
520
521 Sets the C<interp_pmc>'s output file name specified by C<filename>. This function
522 returns a true value if this call is successful and false value otherwise.
523
524 =cut
525
526 */
527
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
528 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
529 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
530 Parrot_api_set_output_file(Parrot_PMC interp_pmc,
531 ARGIN_NULLOK(const char * filename))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
532 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
533 ASSERT_ARGS(Parrot_api_set_output_file)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
534 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
535 if (!filename && !interp->output_file)
536 interp->output_file = "-";
537 else
538 interp->output_file = filename;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
539 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
540 }
541
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
542 /*
543
544 =item C<Parrot_Int Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
545 const char *path)>
546
547 Adds C<path> to the C<inter_pmc>'s library search path list. This function
548 returns a true value if this call is successful and false value otherwise.
549
550 =cut
551
552 */
553
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
554 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
555 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
556 Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
557 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
558 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
559 ASSERT_ARGS(Parrot_api_add_library_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
560 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
561 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_LIBRARY);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
562 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
563 }
564
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
565 /*
566
567 =item C<Parrot_Int Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
568 const char *path)>
569
570 Adds C<path> to the C<inter_pmc>'s include search path list. This function
571 returns a true value if this call is successful and false value otherwise.
572
573 =cut
574
575 */
576
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
577 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
578 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
579 Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
580 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
581 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
582 ASSERT_ARGS(Parrot_api_add_include_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
583 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
584 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_INCLUDE);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
585 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
586 }
587
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
588 /*
589
590 =item C<Parrot_Int Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
591 const char *path)>
592
593 Adds C<path> to the C<inter_pmc>'s dynext search path list. This function
594 returns a true value if this call is successful and false value otherwise.
595
596 =cut
597
598 */
599
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
600 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
601 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
602 Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
603 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
604 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
605 ASSERT_ARGS(Parrot_api_add_dynext_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
606 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
607 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_DYNEXT);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
608 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
609 }
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
610
611 /*
612
c7def2f @jkeenan Run 'perl tools/dev/headerizer.pl src/embed/api.o'.
jkeenan authored
613 =item C<Parrot_Int Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int
614 in, Parrot_Int out, Parrot_Int err)>
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
615
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
616 Set the C<interp_pmc>'s standard file descriptors STDIN, STDOUT, STDERR. Any
617 file descriptor set to C<PIO_INVALID_HANDLE> is ignored. This function returns
618 a true value if this call is successful and false value otherwise.
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
619
620 =cut
621
622 */
623
624 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
625 Parrot_Int
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
626 Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int in,
627 Parrot_Int out, Parrot_Int err)
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
628 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
629 ASSERT_ARGS(Parrot_api_set_stdhandles)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
630 EMBED_API_CALLIN(interp_pmc, interp)
631 void *dummy;
632
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
633 if (PIO_INVALID_HANDLE != (PIOHANDLE)in) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
634 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
635 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)in);
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
636 dummy = (void *)Parrot_io_stdhandle(interp, PIO_STDIN_FILENO, pmc);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
637 }
638
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
639 if (PIO_INVALID_HANDLE != (PIOHANDLE)out) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
640 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
641 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)out);
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
642 dummy = (void *)Parrot_io_stdhandle(interp, PIO_STDOUT_FILENO, pmc);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
643 }
644
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
645 if (PIO_INVALID_HANDLE != (PIOHANDLE)err) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
646 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
647 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)err);
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
648 dummy = (void *)Parrot_io_stdhandle(interp, PIO_STDERR_FILENO, pmc);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
649 }
16e368d @Whiteknight fix several build warnings in src/embed/* in gcc, g++, and icc
Whiteknight authored
650 UNUSED(dummy);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
651
652 EMBED_API_CALLOUT(interp_pmc, interp)
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
653 }
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
654
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
655 /*
656
657 =item C<Parrot_Int Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
658 Parrot_String *runtime)>
659
660 Stores in C<runtime> the C<interp_pmc>'s running path. This function returns a
661 true value if this call is successful and false value otherwise.
662
663 =cut
664
665 */
666
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
667 PARROT_API
668 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
669 Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
670 ARGOUT(Parrot_String *runtime))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
671 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
672 ASSERT_ARGS(Parrot_api_get_runtime_path)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
673 EMBED_API_CALLIN(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
674 *runtime = Parrot_get_runtime_path(interp);
675 EMBED_API_CALLOUT(interp_pmc, interp);
676 }
677
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
678 /*
679
680 =item C<Parrot_Int Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc,
681 Parrot_PMC confighash)>
682
683 Sets the C<interp_pmc>'s configuration hash passed in C<confighash>. This
684 function returns a true value if this call is successful and false value
685 otherwise.
686
687 =cut
688
689 */
690
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
691 PARROT_API
692 Parrot_Int
693 Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc, Parrot_PMC confighash)
694 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
695 ASSERT_ARGS(Parrot_api_set_configuration_hash)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
696 EMBED_API_CALLIN(interp_pmc, interp)
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
697 Parrot_set_config_hash_pmc(interp, confighash);
5c2c3d4 @Whiteknight fix library paths. The build now progresses through all the parts tha…
Whiteknight authored
698 Parrot_lib_update_paths_from_config_hash(interp);
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
699 EMBED_API_CALLOUT(interp_pmc, interp);
700 }
701
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
702 /*
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
703
704 =item C<Parrot_Int Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc, const char *
705 sourcefile, int argc, const char **argv, Parrot_PMC* bytecodepmc, int *result,
706 imcc_hack_func_t func)>
707
708 WARNING: This is an evil hack to provide a wrapper around IMCC to catch unhandled
709 exceptions without having to assume IMCC is linked in with libparrot. Delete this
710 as soon as we don't need it anymore.
711
712 This function returns a true value if this call is successful and false value
713 otherwise.
714
715 =cut
716
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
717 */
718
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch er…
Whiteknight authored
719 PARROT_API
720 Parrot_Int
eaf402c @nwellnhof Fix headerizer warnings
nwellnhof authored
721 Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc, ARGIN(const char * sourcefile),
722 int argc, ARGIN(const char **argv), ARGMOD(Parrot_PMC* bytecodepmc),
723 ARGOUT(int *result), imcc_hack_func_t func)
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch er…
Whiteknight authored
724 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
725 ASSERT_ARGS(Parrot_api_wrap_imcc_hack)
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch er…
Whiteknight authored
726 EMBED_API_CALLIN(interp_pmc, interp)
727 *result = func(interp_pmc, sourcefile, argc, argv, bytecodepmc);
728 EMBED_API_CALLOUT(interp_pmc, interp)
729 }
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
730
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
731 /*
732
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
733 =item C<Parrot_Int Parrot_api_load_language(Parrot_PMC interp_pmc, Parrot_String
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
734 lang)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
735
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
736 Loads the HLL compiler libraries for C<lang> into the C<interp_pmc>. This
737 function returns a true value if this call is successful and false value
738 otherwise.
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
739
740 =cut
741
742 */
743
744 PARROT_API
745 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
746 Parrot_api_load_language(Parrot_PMC interp_pmc, Parrot_String lang)
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
747 {
748 ASSERT_ARGS(Parrot_api_load_language)
749 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
750 Parrot_load_language(interp, lang);
751 EMBED_API_CALLOUT(interp_pmc, interp);
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
752 }
753
754 /*
755
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
756 =item C<Parrot_Int Parrot_api_get_compiler(Parrot_PMC interp_pmc, Parrot_String
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
757 type, Parrot_PMC *compiler)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
758
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
759 Gets the compiler PMC and stores it in C<compiler>. This function returns a true
760 value if this call is successful and false value otherwise.
761
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
762 =cut
763
764 */
765
766 PARROT_API
767 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
768 Parrot_api_get_compiler(Parrot_PMC interp_pmc, Parrot_String type,
769 ARGOUT(Parrot_PMC *compiler))
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
770 {
771 ASSERT_ARGS(Parrot_api_get_compiler)
772 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
773 *compiler = Parrot_get_compiler(interp, type);
774 EMBED_API_CALLOUT(interp_pmc, interp);
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
775 }
776
777 /*
778
779 =item C<Parrot_Int Parrot_api_set_compiler(Parrot_PMC interp_pmc, Parrot_String
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
780 type, Parrot_PMC compiler)>
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
781
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
782 Sets the C<compiler> object for the C<type> files. This function returns a true
783 value if this call is successful and false value otherwise.
784
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
785 =cut
786
787 */
788
789 PARROT_API
790 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
791 Parrot_api_set_compiler(Parrot_PMC interp_pmc, Parrot_String type,
792 Parrot_PMC compiler)
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
793 {
794 ASSERT_ARGS(Parrot_api_set_compiler)
795 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
796 Parrot_set_compiler(interp, type, compiler);
797 EMBED_API_CALLOUT(interp_pmc, interp);
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
798 }
0814f94 Merged changes with branch
Mariano Wahlmann authored
799
6f90f7d @nol888 Add API functions to get a class from an array, and to instantiate a …
nol888 authored
800
0814f94 Merged changes with branch
Mariano Wahlmann authored
801 /*
802
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
803 =back
804
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
805 =cut
0814f94 Merged changes with branch
Mariano Wahlmann authored
806
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
807 */
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
808
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
809 /*
810 * Local variables:
811 * c-file-style: "parrot"
812 * End:
813 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
814 */
0814f94 Merged changes with branch
Mariano Wahlmann authored
815
Something went wrong with that request. Please try again.