Skip to content
Newer
Older
100644 860 lines (666 sloc) 24.3 KB
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
1 /*
ced54a5 @NotFound Fix remaining 'might be clobbered' warning
NotFound authored
2 Copyright (C) 2010-2011, Parrot Foundation.
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
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)
3c6f7d0 @Whiteknight rethrow caches the old backtrace.
Whiteknight authored
98 if (PMC_IS_NULL(exception))
99 *bt = STRINGNULL;
100 else
0a4f093 @Whiteknight build fixes
Whiteknight authored
101 *bt = Parrot_ex_build_complete_backtrace_string(interp, exception);
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
Whiteknight authored
102 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
103 }
104
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
105
106 /*
107
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
108 =item C<Parrot_Int Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int
109 flags, Parrot_Init_Args *args, Parrot_PMC *interp)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
110
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
111 Creates a new interpreter and stores it in C<interp>. It takes three optional
112 parameters the new interpreter's C<flags>, the initialization paremeters C<args>
113 and the C<parent> interpreter. This function returns a true value if this call
114 is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
115
116 =cut
117
118 */
119
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
120 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
121 Parrot_Int
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
122 Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int flags,
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
123 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
124 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
125 ASSERT_ARGS(Parrot_api_make_interpreter)
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
126 int alt_stacktop;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
127 Parrot_Interp interp_raw;
9b2b656 @nwellnhof Add minimum GC threshold option
nwellnhof authored
128 Parrot_GC_Init_Args gc_args;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an i…
Whiteknight authored
129 void *stacktop_ptr = &alt_stacktop;
82cbd84 @Whiteknight parrot executable compiles, but miniparrot does not link. I need to s…
Whiteknight authored
130 const Parrot_Interp parent_raw = PMC_IS_NULL(parent) ? NULL : GET_RAW_INTERP(parent);
131 interp_raw = allocate_interpreter(parent_raw, flags);
132 if (args) {
400feae @nwellnhof Merge branch 'master' into nwellnhof/gc_dynamic_threshold
nwellnhof authored
133 gc_args.stacktop = args->stacktop
134 ? args->stacktop : &alt_stacktop;
135 gc_args.system = args->gc_system;
136 gc_args.dynamic_threshold = args->gc_dynamic_threshold;
137 gc_args.min_threshold = args->gc_min_threshold;
138
82cbd84 @Whiteknight parrot executable compiles, but miniparrot does not link. I need to s…
Whiteknight authored
139 if (args->hash_seed)
140 interp_raw->hash_seed = args->hash_seed;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an i…
Whiteknight authored
141 }
400feae @nwellnhof Merge branch 'master' into nwellnhof/gc_dynamic_threshold
nwellnhof authored
142 else {
143 memset(&gc_args, 0, sizeof (Parrot_GC_Init_Args));
144 gc_args.stacktop = &alt_stacktop;
145 }
9b2b656 @nwellnhof Add minimum GC threshold option
nwellnhof authored
146 initialize_interpreter(interp_raw, &gc_args);
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
147 *interp = VTABLE_get_pmc_keyed_int(
148 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
149 return !PMC_IS_NULL(*interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
150 }
151
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
152 /*
153
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
154 =item C<Parrot_Int Parrot_api_set_runcore(Parrot_PMC interp_pmc, const char *
155 corename, Parrot_UInt trace)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
156
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
157 Sets the C<interp_pmc>'s bytecode running core, the core is specified by the
158 C<corename>. This function returns a true value if this call is successful and
159 false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
160
161 =cut
162
163 */
164
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
165 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
166 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
167 Parrot_api_set_runcore(Parrot_PMC interp_pmc, ARGIN(const char * corename),
168 Parrot_UInt trace)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
169 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
170 ASSERT_ARGS(Parrot_api_set_runcore)
3ea891c First round of syntax error fixes
Mariano Wahlmann authored
171 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
172 if (trace) {
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
173 Parrot_pcc_trace_flags_on(interp, interp->ctx, trace);
174 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
175 }
176 else {
372f8f7 @bluescreen10 Make bounds runcore available
bluescreen10 authored
177 if (!strcmp(corename, "slow") || !strcmp(corename, "bounds"))
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"));
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
179 else if (!strcmp(corename, "fast") ||
180 !strcmp(corename, "jit") || !strcmp(corename, "function"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
181 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
182 else if (!strcmp(corename, "exec"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
183 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
184 else if (!strcmp(corename, "trace"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
185 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
186 else if (!strcmp(corename, "profiling"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
187 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
188 else if (!strcmp(corename, "gcdebug"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
189 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
190 else
191 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Invalid runcore type %s", corename);
192 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
193 EMBED_API_CALLOUT(interp_pmc, interp)
194 }
195
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
196 /*
197
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
198 =item C<Parrot_Int Parrot_api_debug_flag(Parrot_PMC interp_pmc, Parrot_Int
199 flags, Parrot_Int set)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
200
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
201 Sets/Unsets the C<interp_pmc>'s debug flags. If C<set> is in a true value debug
202 flags are set otherwise debug flags are cleared. This function returns a true
203 value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
204
205 =cut
206
207 */
208
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
209 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
210 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
211 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
212 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
213 ASSERT_ARGS(Parrot_api_debug_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
214 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
215 if (set)
216 interp->debug_flags |= flags;
217 else
218 interp->debug_flags &= ~flags;
219 EMBED_API_CALLOUT(interp_pmc, interp);
220 }
221
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
222 /*
223
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
224 =item C<Parrot_Int Parrot_api_flag(Parrot_PMC interp_pmc, Parrot_Int flags,
225 Parrot_Int set)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
226
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
227 Set/Unset the C<interp_pmc>'s general flags. If C<set> is in a true value general
228 flags are set otherwise passed flags are cleared. This function returns a true
229 value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
230
231 =cut
232
233 */
234
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
235 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
236 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
237 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
238 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
239 ASSERT_ARGS(Parrot_api_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
240 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
241 if (set) {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
242 Interp_flags_SET(interp, flags);
243 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
244 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
245 }
246 else
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
247 Interp_flags_CLEAR(interp, flags);
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
248 EMBED_API_CALLOUT(interp_pmc, interp);
249 }
250
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
251 /*
252
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
253 =item C<Parrot_Int Parrot_api_set_executable_name(Parrot_PMC interp_pmc, const
254 char * name)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
255
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
256 Sets the executable name for the C<interp_pmc> interpreter. This function returns
257 a true value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
258
259 =cut
260
261 */
262
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
Whiteknight authored
263 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
264 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
265 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
266 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
267 ASSERT_ARGS(Parrot_api_set_executable_name)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
268 EMBED_API_CALLIN(interp_pmc, interp)
9cc3ace @plobsing allow for unicode names of fakecutables
plobsing authored
269 STRING * const name_str = Parrot_str_from_platform_cstring(interp, name);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
270 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
271 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
272 VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_EXECUTABLE,
273 name_pmc);
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
274 EMBED_API_CALLOUT(interp_pmc, interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
275 }
276
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
277 /*
278
279 =item C<Parrot_Int Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)>
280
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
281 Destroys the C<interp_pmc> interpreter, freeing the memory structures allocated
282 for it. This function returns a true value if this call is successful and false
283 value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
284
285 =cut
286
287 */
288
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
289 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
290 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
291 Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
292 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
293 ASSERT_ARGS(Parrot_api_destroy_interpreter)
2dc5187 @nwellnhof [embed] Fix segfault with --leak-test option
nwellnhof authored
294 Parrot_jump_buff env;
295 if (setjmp(env)) {
296 /* We can't check for potential errors because the interpreter
297 * might have been destroyed. */
298 return 1;
299 }
300 else {
ced54a5 @NotFound Fix remaining 'might be clobbered' warning
NotFound authored
301 Interp * const interp = GET_INTERP(interp_pmc);
302 void * _oldtop = interp->lo_var_ptr;
303 if (_oldtop == NULL)
304 interp->lo_var_ptr = &_oldtop;
305 interp->api_jmp_buf = &env;
2dc5187 @nwellnhof [embed] Fix segfault with --leak-test option
nwellnhof authored
306 Parrot_destroy(interp);
307 Parrot_x_exit(interp, 0);
308 /* Never reached, x_exit calls longjmp */
309 return 1;
310 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
311 }
312
313 /*
314
adc07e5 @nwellnhof Merge branch 'master' into nwellnhof/unicode_filenames
nwellnhof authored
315 =item C<Parrot_Int Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc,
316 Parrot_String filename, Parrot_PMC * pbc)>
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
317
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
318 Load a bytecode file and stores the resulting bytecode in C<pbc>. This function
319 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
320
321 =cut
322
323 */
324
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebu…
Whiteknight authored
325 /* TODO: This only works with the inital bytecode. After this we should use
d4cdba7 @Whiteknight remove .pbc loading logic from imcc_run, and move it into the parrot.…
Whiteknight authored
326 Parrot_append_bytecode or something similar */
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebu…
Whiteknight authored
327
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
328 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
329 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
330 Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc,
adc07e5 @nwellnhof Merge branch 'master' into nwellnhof/unicode_filenames
nwellnhof authored
331 ARGIN(Parrot_String filename), ARGOUT(Parrot_PMC * pbc))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
332 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
333 ASSERT_ARGS(Parrot_api_load_bytecode_file)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
334 EMBED_API_CALLIN(interp_pmc, interp)
adc07e5 @nwellnhof Merge branch 'master' into nwellnhof/unicode_filenames
nwellnhof authored
335 PackFile * const pf = PackFile_read_pbc(interp, filename, 0);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
336 if (!pf)
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the pac…
Whiteknight authored
337 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_MALFORMED_PACKFILE,
338 "Could not load packfile");
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
339 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
340 *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
341 VTABLE_set_pointer(interp, *pbc, pf);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
342 EMBED_API_CALLOUT(interp_pmc, interp)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
343 }
344
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
345 /*
346
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
347 =item C<Parrot_Int Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc, const
348 unsigned char * const pbc, Parrot_Int bytecode_size, Parrot_PMC * pbcpmc)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
349
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
350 Unpacks a bytecode from a buffer C<pbc> of a C<bytecode_size> size, and stores
351 the resulting bytecode in C<pbcpmc>. This function returns a true value if this
352 call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
353
354 =cut
355
356 */
357
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
358 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
359 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
360 Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc,
361 ARGIN(const unsigned char * const pbc), Parrot_Int bytecode_size,
362 ARGOUT(Parrot_PMC * pbcpmc))
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
363 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
364 ASSERT_ARGS(Parrot_api_load_bytecode_bytes)
99428c2 Make src/embed/pmc.c & src/embed/api.c compile with gcc
Mariano Wahlmann authored
365 EMBED_API_CALLIN(interp_pmc, interp)
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
366 PackFile * const pf = PackFile_new(interp, 0);
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the pac…
Whiteknight authored
367 PARROT_ASSERT(pf);
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
368
369 if (!PackFile_unpack(interp, pf, (const opcode_t *)pbc, bytecode_size))
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the pac…
Whiteknight authored
370 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_MALFORMED_PACKFILE,
f0c28dc @Whiteknight Add in an API function so that we can reset and reuse an existing Cal…
Whiteknight authored
371 "Could not unpack packfile");
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
372 do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL);
373 *pbcpmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
374 VTABLE_set_pointer(interp, *pbcpmc, pf);
375 EMBED_API_CALLOUT(interp_pmc, interp);
376 }
377
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebu…
Whiteknight authored
378 /* Load the bytecode into the interpreter, but don't execute it */
379 /* TODO: This only works with the inital bytecode. After this we should use
380 Parrot_append_bytecode or something similar */
381
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
382 /*
383
384 =item C<Parrot_Int Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
385 pbc, Parrot_PMC *main_sub)>
386
387 Prepares the bytecode C<pbc> to be run and stores the entry point subroutine in
388 C<main_sub>. This function returns a true value if this call is successful and
389 false value otherwise.
390
391 =cut
392
393 */
394
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
395 PARROT_API
396 Parrot_Int
397 Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
398 ARGOUT(Parrot_PMC *main_sub))
399 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
400 ASSERT_ARGS(Parrot_api_ready_bytecode)
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
401 EMBED_API_CALLIN(interp_pmc, interp)
402 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
403
404 /* Debugging mode nonsense. */
405 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
406 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
407 interp->run_core->name);
408 }
409
410 if (!pf)
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the pac…
Whiteknight authored
411 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
412 "Could not get packfile.");
413 if (pf->cur_cs)
414 Parrot_pf_set_current_packfile(interp, pf);
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
415 PackFile_fixup_subs(interp, PBC_MAIN, NULL);
416 *main_sub = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
417 Parrot_pcc_set_constants(interp, interp->ctx, interp->code->const_table);
418 EMBED_API_CALLOUT(interp_pmc, interp)
419 }
420
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
421
422 /*
423
424 =item C<Parrot_Int Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
425 pbc, Parrot_PMC mainargs)>
426
427 Runs the bytecode C<pbc> passing optional C<mainargs> parameters. This function
428 returns a true value if this call is successful and false value otherwise.
429
430 =cut
431
432 */
433
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
434 PARROT_API
435 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
436 Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
437 Parrot_PMC mainargs)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
438 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
439 ASSERT_ARGS(Parrot_api_run_bytecode)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
440 EMBED_API_CALLIN(interp_pmc, interp)
98cd26c @Whiteknight don't call Parrot_pbc_load if the PBC comes straight out of IMCC. IMC…
Whiteknight authored
441 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
442
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
443 /* Debugging mode nonsense. */
444 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
445 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
446 interp->run_core->name);
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
447 }
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
448
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
449 if (!pf)
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the pac…
Whiteknight authored
450 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
451 "Could not get packfile.");
2310551 @nwellnhof Fix assertion failure
nwellnhof authored
452 if (!mainargs)
453 mainargs = PMCNULL;
240d5b7 @Whiteknight Add a new function to execute a PackFile* as a program
Whiteknight authored
454 Parrot_pf_execute_bytecode_program(interp, pf, mainargs);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
455 EMBED_API_CALLOUT(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
456 }
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
457
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
458 /*
459
460 =item C<Parrot_Int Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc,
461 Parrot_PMC pbc, const char * const outfile, Parrot_Int opts)>
462
463 Disassembles and prints out the C<pbc> bytecode. This function returns a true
464 value if this call is successful and false value otherwise.
465
466 =cut
467
468 */
469
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
470 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
471 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
472 Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
473 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
474 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
475 ASSERT_ARGS(Parrot_api_disassemble_bytecode)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
476 EMBED_API_CALLIN(interp_pmc, interp)
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
477 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
478 if (!pf)
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the pac…
Whiteknight authored
479 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
480 "Could not get packfile.");
481 if (pf->cur_cs)
482 Parrot_pf_set_current_packfile(interp, pf);
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
483 /* 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
484 Parrot_disassemble(interp, outfile, (Parrot_disassemble_options)opts);
485 EMBED_API_CALLOUT(interp_pmc, interp);
486 }
487
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
488 /*
489
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suit…
Whiteknight authored
490 =item C<Parrot_Int Parrot_api_serialize_bytecode_pmc(Parrot_PMC interp_pmc,
491 Parrot_PMC pbc, Parrot_String * bc)>
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
492
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suit…
Whiteknight authored
493 Serialize a packfile PMC into a sequence of bytes suitable for writing out
494 to a .pbc file
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
495
496 =cut
497
498 */
499
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
500 PARROT_API
501 Parrot_Int
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suit…
Whiteknight authored
502 Parrot_api_serialize_bytecode_pmc(Parrot_PMC interp_pmc, Parrot_PMC pbc,
503 ARGOUT(Parrot_String * bc))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
504 {
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suit…
Whiteknight authored
505 ASSERT_ARGS(Parrot_api_serialize_bytecode_pmc)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
506 EMBED_API_CALLIN(interp_pmc, interp)
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suit…
Whiteknight authored
507 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
508 if (!pf)
509 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
510 "Could not get packfile.");
511 else {
512 const Parrot_Int size = PackFile_pack_size(interp, pf) * sizeof (opcode_t);
513 opcode_t * const packed = (opcode_t*) mem_sys_allocate(size);
514 PackFile_pack(interp, pf, packed);
515 *bc = Parrot_str_new_init(interp, (const char *)packed, size,
516 Parrot_binary_encoding_ptr, 0);
517 }
c1ab56e More fixes, almost there
Mariano Wahlmann authored
518 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
519 }
520
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
521 /*
522
523 =item C<Parrot_Int Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int
524 flags)>
525
526 Enables C<inter_pmc>'s warning messages the type of warning information to be
527 print out is specified by C<flags>. This function returns a true value if this
528 call is successful and false value otherwise.
529
530 =cut
531
532 */
533
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
534 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
535 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
536 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
537 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
538 ASSERT_ARGS(Parrot_api_set_warnings)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
539 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
540 /* 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
541 PARROT_WARNINGS_on(interp, flags);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
542 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
543 }
544
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
545 /*
546
547 =item C<Parrot_Int Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
548 const char *path)>
549
550 Adds C<path> to the C<inter_pmc>'s library search path list. This function
551 returns a true value if this call is successful and false value otherwise.
552
553 =cut
554
555 */
556
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
557 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
558 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
559 Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
560 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
561 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
562 ASSERT_ARGS(Parrot_api_add_library_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
563 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
564 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_LIBRARY);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
565 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
566 }
567
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
568 /*
569
570 =item C<Parrot_Int Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
571 const char *path)>
572
573 Adds C<path> to the C<inter_pmc>'s include search path list. This function
574 returns a true value if this call is successful and false value otherwise.
575
576 =cut
577
578 */
579
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
580 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
581 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
582 Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
583 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
584 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
585 ASSERT_ARGS(Parrot_api_add_include_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
586 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
587 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_INCLUDE);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
588 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
589 }
590
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
591 /*
592
593 =item C<Parrot_Int Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
594 const char *path)>
595
596 Adds C<path> to the C<inter_pmc>'s dynext search path list. This function
597 returns a true value if this call is successful and false value otherwise.
598
599 =cut
600
601 */
602
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
603 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
604 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
605 Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
606 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
607 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
608 ASSERT_ARGS(Parrot_api_add_dynext_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
609 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
610 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_DYNEXT);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
611 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
612 }
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
613
614 /*
615
c7def2f @jkeenan Run 'perl tools/dev/headerizer.pl src/embed/api.o'.
jkeenan authored
616 =item C<Parrot_Int Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int
617 in, Parrot_Int out, Parrot_Int err)>
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
618
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
619 Set the C<interp_pmc>'s standard file descriptors STDIN, STDOUT, STDERR. Any
620 file descriptor set to C<PIO_INVALID_HANDLE> is ignored. This function returns
621 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
622
623 =cut
624
625 */
f30aa2f @kapace Added some tests for embed api, get/set compiler and commented set_st…
kapace authored
626 /* Whiteknight told me that theres no way to test this for now, so it should be
627 commented out, for now.
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
628
629 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
630 Parrot_Int
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
631 Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int in,
632 Parrot_Int out, Parrot_Int err)
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
633 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
634 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
635 EMBED_API_CALLIN(interp_pmc, interp)
636 void *dummy;
637
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
638 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
639 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
640 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
641 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
642 }
643
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
644 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
645 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
646 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
647 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
648 }
649
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
650 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
651 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
652 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
653 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
654 }
16e368d @Whiteknight fix several build warnings in src/embed/* in gcc, g++, and icc
Whiteknight authored
655 UNUSED(dummy);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
656
657 EMBED_API_CALLOUT(interp_pmc, interp)
f30aa2f @kapace Added some tests for embed api, get/set compiler and commented set_st…
kapace authored
658 }*/
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
659
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
660 /*
661
662 =item C<Parrot_Int Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
663 Parrot_String *runtime)>
664
665 Stores in C<runtime> the C<interp_pmc>'s running path. This function returns a
666 true value if this call is successful and false value otherwise.
667
668 =cut
669
670 */
671
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
672 PARROT_API
673 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
674 Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
675 ARGOUT(Parrot_String *runtime))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
676 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
677 ASSERT_ARGS(Parrot_api_get_runtime_path)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
678 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
679 *runtime = Parrot_get_runtime_path(interp);
680 EMBED_API_CALLOUT(interp_pmc, interp);
681 }
682
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
683 /*
684
685 =item C<Parrot_Int Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc,
686 Parrot_PMC confighash)>
687
688 Sets the C<interp_pmc>'s configuration hash passed in C<confighash>. This
689 function returns a true value if this call is successful and false value
690 otherwise.
691
692 =cut
693
694 */
695
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
696 PARROT_API
697 Parrot_Int
698 Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc, Parrot_PMC confighash)
699 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
700 ASSERT_ARGS(Parrot_api_set_configuration_hash)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
701 EMBED_API_CALLIN(interp_pmc, interp)
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
702 Parrot_set_config_hash_pmc(interp, confighash);
5c2c3d4 @Whiteknight fix library paths. The build now progresses through all the parts tha…
Whiteknight authored
703 Parrot_lib_update_paths_from_config_hash(interp);
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
704 EMBED_API_CALLOUT(interp_pmc, interp);
705 }
706
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
707 /*
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
708
903db1c @nwellnhof [imcc] Switch to PIO and STRING filenames for all input files
nwellnhof authored
709 =item C<Parrot_Int Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc,
710 Parrot_String sourcefile, int argc, const char **argv, Parrot_PMC* bytecodepmc,
711 int *result, imcc_hack_func_t func)>
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
712
713 WARNING: This is an evil hack to provide a wrapper around IMCC to catch unhandled
714 exceptions without having to assume IMCC is linked in with libparrot. Delete this
715 as soon as we don't need it anymore.
716
717 This function returns a true value if this call is successful and false value
718 otherwise.
719
720 =cut
721
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
722 */
723
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch er…
Whiteknight authored
724 PARROT_API
725 Parrot_Int
903db1c @nwellnhof [imcc] Switch to PIO and STRING filenames for all input files
nwellnhof authored
726 Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc, ARGIN(Parrot_String sourcefile),
ca855f2 @Whiteknight implement the test for Parrot_api_serialize_bytecode_pmc. Fix some AR…
Whiteknight authored
727 int argc, ARGIN_NULLOK(const char **argv), ARGMOD(Parrot_PMC* bytecodepmc),
eaf402c @nwellnhof Fix headerizer warnings
nwellnhof authored
728 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
729 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
730 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
731 EMBED_API_CALLIN(interp_pmc, interp)
732 *result = func(interp_pmc, sourcefile, argc, argv, bytecodepmc);
733 EMBED_API_CALLOUT(interp_pmc, interp)
734 }
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
735
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
736 /*
737
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
738 =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
739 lang)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
740
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
741 Loads the HLL compiler libraries for C<lang> into the C<interp_pmc>. This
742 function returns a true value if this call is successful and false value
743 otherwise.
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
744
745 =cut
746
747 */
748
749 PARROT_API
750 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
751 Parrot_api_load_language(Parrot_PMC interp_pmc, Parrot_String lang)
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
752 {
753 ASSERT_ARGS(Parrot_api_load_language)
754 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
755 Parrot_load_language(interp, lang);
756 EMBED_API_CALLOUT(interp_pmc, interp);
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
757 }
758
759 /*
760
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
761 =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
762 type, Parrot_PMC *compiler)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
763
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
764 Gets the compiler PMC and stores it in C<compiler>. This function returns a true
765 value if this call is successful and false value otherwise.
766
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
767 =cut
768
769 */
770
771 PARROT_API
772 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
773 Parrot_api_get_compiler(Parrot_PMC interp_pmc, Parrot_String type,
774 ARGOUT(Parrot_PMC *compiler))
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
775 {
776 ASSERT_ARGS(Parrot_api_get_compiler)
777 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
778 *compiler = Parrot_get_compiler(interp, type);
779 EMBED_API_CALLOUT(interp_pmc, interp);
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
780 }
781
782 /*
783
784 =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
785 type, Parrot_PMC compiler)>
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
786
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
787 Sets the C<compiler> object for the C<type> files. This function returns a true
788 value if this call is successful and false value otherwise.
789
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
790 =cut
791
792 */
793
794 PARROT_API
795 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
796 Parrot_api_set_compiler(Parrot_PMC interp_pmc, Parrot_String type,
797 Parrot_PMC compiler)
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
798 {
799 ASSERT_ARGS(Parrot_api_set_compiler)
800 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
801 Parrot_set_compiler(interp, type, compiler);
255a8d8 @Whiteknight move -G commandline argument parsing from IMCC into the frontend
Whiteknight authored
802 EMBED_API_CALLOUT(interp_pmc, interp)
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
803 }
0814f94 Merged changes with branch
Mariano Wahlmann authored
804
255a8d8 @Whiteknight move -G commandline argument parsing from IMCC into the frontend
Whiteknight authored
805 /*
806
807 =item C<Parrot_Int Parrot_api_toggle_gc(Parrot_PMC interp_pmc, Parrot_Int on)>
808
809 Turn Parrot's GC on or off.
810
811 =cut
812
813 */
814
815 PARROT_API
816 Parrot_Int
817 Parrot_api_toggle_gc(Parrot_PMC interp_pmc, Parrot_Int on)
818 {
819 ASSERT_ARGS(Parrot_api_toggle_gc)
820 EMBED_API_CALLIN(interp_pmc, interp)
821 if (on) {
822 Parrot_unblock_GC_mark(interp);
823 Parrot_unblock_GC_sweep(interp);
824 }
825 else {
826 Parrot_block_GC_mark(interp);
827 Parrot_block_GC_sweep(interp);
828 }
829 EMBED_API_CALLOUT(interp_pmc, interp)
830 }
6f90f7d @nol888 Add API functions to get a class from an array, and to instantiate a …
nol888 authored
831
f0c28dc @Whiteknight Add in an API function so that we can reset and reuse an existing Cal…
Whiteknight authored
832 PARROT_API
833 Parrot_Int
834 Parrot_api_reset_call_signature(Parrot_PMC interp_pmc, Parrot_PMC ctx)
835 {
836 EMBED_API_CALLIN(interp_pmc, interp)
837 STRING * const callcontext = Parrot_str_new(interp, "CallContext", 0);
838 if (!VTABLE_isa(interp, ctx, callcontext))
839 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
840 "Not a valid CallContext");
841 VTABLE_morph(interp, ctx, PMCNULL);
842 EMBED_API_CALLOUT(interp_pmc, interp)
843 }
844
0814f94 Merged changes with branch
Mariano Wahlmann authored
845 /*
846
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
847 =back
848
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
849 =cut
0814f94 Merged changes with branch
Mariano Wahlmann authored
850
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
851 */
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
852
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
853 /*
854 * Local variables:
855 * c-file-style: "parrot"
856 * End:
857 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
858 */
0814f94 Merged changes with branch
Mariano Wahlmann authored
859
Something went wrong with that request. Please try again.