Skip to content

HTTPS clone URL

Subversion checkout URL

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