Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 718 lines (557 sloc) 20.617 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 removed s...
bluescreen10 authored
21 #include "parrot/runcore_api.h"
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
22 #include "parrot/api.h"
1b6d1ce @Whiteknight start breaking up the embedding stuff into multiple files. Add embed_pri...
Whiteknight authored
23 #include "embed_private.h"
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
24
3f8ed92 @Whiteknight fix some file references and run headerizer to see my work so far
Whiteknight authored
25 /* HEADERIZER HFILE: include/parrot/api.h */
26
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
27
28 /*
29
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
30 =item C<Parrot_Int Parrot_api_get_result(Parrot_PMC interp_pmc, Parrot_Int
31 *is_error, Parrot_PMC * exception, Parrot_Int *exit_code, Parrot_String *
32 errmsg)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
33
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
34 Gets the results of the last API function call and stores the results in
35 C<is_error>, C<exception>, C<exit_code> and C<errmsg>. This function returns
36 a true value if this call is successful and false value otherwise. The stored
37 information is as follow:
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
38
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
39 C<is_error> a true value if an unhandled exception was thrown or the program
40 terminated with an error condition and a false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
41
42 C<exception> the last exception thrown.
43
44 C<exit_code> the exit code of the running program.
45
46 C<errmsg> contains an string with the last error message.
47
48 =cut
49
50 */
51
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
52 PARROT_API
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
53 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
54 Parrot_api_get_result(Parrot_PMC interp_pmc, ARGOUT(Parrot_Int *is_error),
55 ARGOUT(Parrot_PMC * exception), ARGOUT(Parrot_Int *exit_code),
56 ARGOUT(Parrot_String * errmsg))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
57 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
58 ASSERT_ARGS(Parrot_api_get_result)
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
59 EMBED_API_CALLIN(interp_pmc, interp)
be50d63 @bluescreen10 Implemented first version of Parrot_get_result, now a lot of failing tes...
bluescreen10 authored
60 *exit_code = interp->exit_code;
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
61 *exception = interp->final_exception;
73f662d @Whiteknight some fixes so libparrot builds with g++
Whiteknight authored
62 if (PMC_IS_NULL(*exception)) {
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
63 *is_error = 0;
64 *errmsg = STRINGNULL;
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
65 }
66 else {
b3af8c9 @Whiteknight fix main.c so that we check the is_error flag and only show an error mes...
Whiteknight authored
67 STRING * const severity_str = Parrot_str_new(interp, "severity", 0);
68 INTVAL severity = VTABLE_get_integer_keyed_str(interp, *exception, severity_str);
69 *is_error = (severity != EXCEPT_exit);
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
70 *errmsg = VTABLE_get_string(interp, *exception);
71 }
72 interp->final_exception = PMCNULL;
be50d63 @bluescreen10 Implemented first version of Parrot_get_result, now a lot of failing tes...
bluescreen10 authored
73 interp->exit_code = 0;
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
74 EMBED_API_CALLOUT(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
75 }
76
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
77 /*
78
79 =item C<Parrot_Int Parrot_api_get_exception_backtrace(Parrot_PMC interp_pmc,
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
80 Parrot_PMC exception, Parrot_String * bt)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
81
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
82 Gets the backtrace of the interpreter's call chain for the given exception
83 C<expcetion> and stores the results in string C<bt>. This function returns a
84 true value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
85
86 =cut
87
88 */
89
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
90 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
91 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
92 Parrot_api_get_exception_backtrace(Parrot_PMC interp_pmc,
93 Parrot_PMC exception, ARGOUT(Parrot_String * bt))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
94 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
95 ASSERT_ARGS(Parrot_api_get_exception_backtrace)
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
96 EMBED_API_CALLIN(interp_pmc, interp)
3c6f7d0 @Whiteknight rethrow caches the old backtrace.
Whiteknight authored
97 if (PMC_IS_NULL(exception))
98 *bt = STRINGNULL;
99 else
0a4f093 @Whiteknight build fixes
Whiteknight authored
100 *bt = Parrot_ex_build_complete_backtrace_string(interp, exception);
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
101 EMBED_API_CALLOUT(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
102 }
103
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
104
105 /*
106
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
107 =item C<Parrot_Int Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int
108 flags, Parrot_Init_Args *args, Parrot_PMC *interp)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
109
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
110 Creates a new interpreter and stores it in C<interp>. It takes three optional
111 parameters the new interpreter's C<flags>, the initialization paremeters C<args>
112 and the C<parent> interpreter. This function returns a true value if this call
113 is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
114
115 =cut
116
117 */
118
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
119 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
120 Parrot_Int
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't being u...
Whiteknight authored
121 Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int flags,
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
122 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
123 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
124 ASSERT_ARGS(Parrot_api_make_interpreter)
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
125 int alt_stacktop;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
126 Parrot_Interp interp_raw;
9b2b656 @nwellnhof Add minimum GC threshold option
nwellnhof authored
127 Parrot_GC_Init_Args gc_args;
82cbd84 @Whiteknight parrot executable compiles, but miniparrot does not link. I need to sort...
Whiteknight authored
128 const Parrot_Interp parent_raw = PMC_IS_NULL(parent) ? NULL : GET_RAW_INTERP(parent);
7a315db @Whiteknight set an api jump buffer in Parrot_api_make_interpreter, so we can try to ...
Whiteknight authored
129 Parrot_jump_buff env;
0eef3cd @NotFound fix C90 compliance
NotFound authored
130 interp_raw = allocate_interpreter(parent_raw, flags);
7a315db @Whiteknight set an api jump buffer in Parrot_api_make_interpreter, so we can try to ...
Whiteknight authored
131 if (setjmp(env)) {
132 interp_raw->api_jmp_buf = NULL;
69ee128 @Whiteknight if we don't have an interp, print out an error message. If we do, try to...
Whiteknight authored
133 *interp = NULL;
7a315db @Whiteknight set an api jump buffer in Parrot_api_make_interpreter, so we can try to ...
Whiteknight authored
134 return !interp_raw->exit_code;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an inte...
Whiteknight authored
135 }
400feae @nwellnhof Merge branch 'master' into nwellnhof/gc_dynamic_threshold
nwellnhof authored
136 else {
7a315db @Whiteknight set an api jump buffer in Parrot_api_make_interpreter, so we can try to ...
Whiteknight authored
137 interp_raw->api_jmp_buf = &env;
138 if (args) {
139 gc_args.stacktop = args->stacktop
140 ? args->stacktop : &alt_stacktop;
141 gc_args.system = args->gc_system;
142 gc_args.nursery_size = args->gc_nursery_size;
143 gc_args.dynamic_threshold = args->gc_dynamic_threshold;
144 gc_args.min_threshold = args->gc_min_threshold;
145
146 if (args->hash_seed)
147 interp_raw->hash_seed = args->hash_seed;
148 }
149 else {
150 memset(&gc_args, 0, sizeof (Parrot_GC_Init_Args));
151 gc_args.stacktop = &alt_stacktop;
152 }
153 initialize_interpreter(interp_raw, &gc_args);
154 *interp = VTABLE_get_pmc_keyed_int(
155 interp_raw, interp_raw->iglobals, (Parrot_Int)IGLOBALS_INTERPRETER);
400feae @nwellnhof Merge branch 'master' into nwellnhof/gc_dynamic_threshold
nwellnhof authored
156 }
7a315db @Whiteknight set an api jump buffer in Parrot_api_make_interpreter, so we can try to ...
Whiteknight authored
157 interp_raw->api_jmp_buf = NULL;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an inte...
Whiteknight authored
158 return !PMC_IS_NULL(*interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
159 }
160
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
161 /*
162
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
163 =item C<Parrot_Int Parrot_api_set_runcore(Parrot_PMC interp_pmc, const char *
164 corename, Parrot_UInt trace)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
165
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
166 Sets the C<interp_pmc>'s bytecode running core, the core is specified by the
167 C<corename>. This function returns a true value if this call is successful and
168 false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
169
170 =cut
171
172 */
173
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
174 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
175 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
176 Parrot_api_set_runcore(Parrot_PMC interp_pmc, ARGIN(const char * corename),
177 Parrot_UInt trace)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
178 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
179 ASSERT_ARGS(Parrot_api_set_runcore)
3ea891c First round of syntax error fixes
Mariano Wahlmann authored
180 EMBED_API_CALLIN(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
181 if (trace) {
c510c5c @Whiteknight fix the trace core, so when we use the -t, --trace, or -Rtrace flags, it...
Whiteknight authored
182 Interp_trace_SET(interp, PARROT_TRACE_OPS_FLAG);
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
183 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
184 }
185 else {
38e5177 @petdance Use STREQ() for string comparisons, instead of incorrectly using strcmp ...
petdance authored
186 if (STREQ(corename, "slow") || STREQ(corename, "bounds"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
187 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
38e5177 @petdance Use STREQ() for string comparisons, instead of incorrectly using strcmp ...
petdance authored
188 else if (STREQ(corename, "fast") || STREQ(corename, "jit") || STREQ(corename, "function"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
189 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "fast"));
f5d74c4 @mlschroe subprof_fun -> subprof_sub, headerize
mlschroe authored
190 else if (STREQ(corename, "subprof_sub"))
191 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "subprof_sub"));
f5358a8 @mlschroe move global subprofdata into the runcore data for now. dump profile data...
mlschroe authored
192 else if (STREQ(corename, "subprof_hll") || STREQ(corename, "subprof"))
beef84c @mlschroe support subprof_fun, subprof_hll, subprof_ops
mlschroe authored
193 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "subprof_hll"));
194 else if (STREQ(corename, "subprof_ops"))
195 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "subprof_ops"));
38e5177 @petdance Use STREQ() for string comparisons, instead of incorrectly using strcmp ...
petdance authored
196 else if (STREQ(corename, "exec"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
197 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "exec"));
114d897 @petdance Use STREQ() for string comparisons, instead of incorrectly using strcmp ...
petdance authored
198 else if (STREQ(corename, "trace"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
199 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
38e5177 @petdance Use STREQ() for string comparisons, instead of incorrectly using strcmp ...
petdance authored
200 else if (STREQ(corename, "profiling"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
201 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "profiling"));
38e5177 @petdance Use STREQ() for string comparisons, instead of incorrectly using strcmp ...
petdance authored
202 else if (STREQ(corename, "gcdebug"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
203 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 alternate f...
Whiteknight authored
204 else
205 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Invalid runcore type %s", corename);
206 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
207 EMBED_API_CALLOUT(interp_pmc, interp)
208 }
209
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
210 /*
211
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
212 =item C<Parrot_Int Parrot_api_debug_flag(Parrot_PMC interp_pmc, Parrot_Int
213 flags, Parrot_Int set)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
214
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
215 Sets/Unsets the C<interp_pmc>'s debug flags. If C<set> is in a true value debug
216 flags are set otherwise debug flags are cleared. This function returns a true
217 value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
218
219 =cut
220
221 */
222
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
223 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
224 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
225 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 inste...
Whiteknight authored
226 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
227 ASSERT_ARGS(Parrot_api_debug_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
228 EMBED_API_CALLIN(interp_pmc, interp)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
229 if (set)
230 interp->debug_flags |= flags;
231 else
232 interp->debug_flags &= ~flags;
233 EMBED_API_CALLOUT(interp_pmc, interp);
234 }
235
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
236 /*
237
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
238 =item C<Parrot_Int Parrot_api_flag(Parrot_PMC interp_pmc, Parrot_Int flags,
239 Parrot_Int set)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
240
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
241 Set/Unset the C<interp_pmc>'s general flags. If C<set> is in a true value general
242 flags are set otherwise passed flags are cleared. This function returns a true
243 value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
244
245 =cut
246
247 */
248
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
249 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
250 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
251 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 inste...
Whiteknight authored
252 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
253 ASSERT_ARGS(Parrot_api_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
254 EMBED_API_CALLIN(interp_pmc, interp)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
255 if (set) {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
256 Interp_flags_SET(interp, flags);
257 if (flags & (PARROT_BOUNDS_FLAG | PARROT_PROFILE_FLAG))
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
258 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
259 }
260 else
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
261 Interp_flags_CLEAR(interp, flags);
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
262 EMBED_API_CALLOUT(interp_pmc, interp);
263 }
264
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
265 /*
266
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
267 =item C<Parrot_Int Parrot_api_set_executable_name(Parrot_PMC interp_pmc, const
268 char * name)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
269
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
270 Sets the executable name for the C<interp_pmc> interpreter. This function returns
271 a true value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
272
273 =cut
274
275 */
276
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
277 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
278 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
279 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
280 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
281 ASSERT_ARGS(Parrot_api_set_executable_name)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
282 EMBED_API_CALLIN(interp_pmc, interp)
9cc3ace @plobsing allow for unicode names of fakecutables
plobsing authored
283 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
284 PMC * const name_pmc = Parrot_pmc_new(interp, enum_class_String);
1a692e9 @Whiteknight _set_executable_name takes a C string instead of a Parrot string, for co...
Whiteknight authored
285 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
286 VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_EXECUTABLE,
287 name_pmc);
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
288 EMBED_API_CALLOUT(interp_pmc, interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
289 }
290
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
291 /*
292
293 =item C<Parrot_Int Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)>
294
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
295 Destroys the C<interp_pmc> interpreter, freeing the memory structures allocated
296 for it. This function returns a true value if this call is successful and false
297 value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
298
299 =cut
300
301 */
302
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
303 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
304 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
305 Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
306 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
307 ASSERT_ARGS(Parrot_api_destroy_interpreter)
2dc5187 @nwellnhof [embed] Fix segfault with --leak-test option
nwellnhof authored
308 Parrot_jump_buff env;
309 if (setjmp(env)) {
310 /* We can't check for potential errors because the interpreter
311 * might have been destroyed. */
312 return 1;
313 }
314 else {
ced54a5 @NotFound Fix remaining 'might be clobbered' warning
NotFound authored
315 Interp * const interp = GET_INTERP(interp_pmc);
316 void * _oldtop = interp->lo_var_ptr;
317 if (_oldtop == NULL)
318 interp->lo_var_ptr = &_oldtop;
319 interp->api_jmp_buf = &env;
2dc5187 @nwellnhof [embed] Fix segfault with --leak-test option
nwellnhof authored
320 Parrot_destroy(interp);
321 Parrot_x_exit(interp, 0);
322 /* Never reached, x_exit calls longjmp */
323 return 1;
324 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
325 }
326
327 /*
328
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
329 =item C<Parrot_Int Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int
330 flags)>
331
332 Enables C<inter_pmc>'s warning messages the type of warning information to be
333 print out is specified by C<flags>. This function returns a true value if this
334 call is successful and false value otherwise.
335
336 =cut
337
338 */
339
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
340 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
341 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
342 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 it w...
Whiteknight authored
343 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
344 ASSERT_ARGS(Parrot_api_set_warnings)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
345 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
346 /* Activates the given warnings. (Macro from warnings.h.) */
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
347 PARROT_WARNINGS_on(interp, flags);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
348 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
349 }
350
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
351 /*
352
353 =item C<Parrot_Int Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
354 const char *path)>
355
356 Adds C<path> to the C<inter_pmc>'s library search path list. This function
357 returns a true value if this call is successful and false value otherwise.
358
359 =cut
360
361 */
362
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
363 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
364 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
365 Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
366 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
367 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
368 ASSERT_ARGS(Parrot_api_add_library_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
369 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
370 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_LIBRARY);
229a781 @Whiteknight Add experimental ability to modify PARROT_LIB_PATH_LANG with the -L comm...
Whiteknight authored
371
372 /* EXPERIMENTAL. This line has been added experimentally because it is a
373 missing feature, and it may go away at any time without warning. */
374 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_LANG);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
375 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
376 }
377
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
378 /*
379
380 =item C<Parrot_Int Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
381 const char *path)>
382
383 Adds C<path> to the C<inter_pmc>'s include search path list. This function
384 returns a true value if this call is successful and false value otherwise.
385
386 =cut
387
388 */
389
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
390 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
391 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
392 Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
393 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
394 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
395 ASSERT_ARGS(Parrot_api_add_include_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
396 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
397 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_INCLUDE);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
398 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
399 }
400
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
401 /*
402
403 =item C<Parrot_Int Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
404 const char *path)>
405
406 Adds C<path> to the C<inter_pmc>'s dynext search path list. This function
407 returns a true value if this call is successful and false value otherwise.
408
409 =cut
410
411 */
412
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
413 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
414 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
415 Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
416 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
417 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
418 ASSERT_ARGS(Parrot_api_add_dynext_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
419 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
420 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_DYNEXT);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
421 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
422 }
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
423
424 /*
425
c7def2f @jkeenan Run 'perl tools/dev/headerizer.pl src/embed/api.o'.
jkeenan authored
426 =item C<Parrot_Int Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int
427 in, Parrot_Int out, Parrot_Int err)>
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
428
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
429 Set the C<interp_pmc>'s standard file descriptors STDIN, STDOUT, STDERR. Any
430 file descriptor set to C<PIO_INVALID_HANDLE> is ignored. This function returns
431 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
432
433 =cut
434
435 */
f30aa2f @kapace Added some tests for embed api, get/set compiler and commented set_std_h...
kapace authored
436 /* Whiteknight told me that theres no way to test this for now, so it should be
437 commented out, for now.
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
438
439 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
440 Parrot_Int
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
441 Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int in,
442 Parrot_Int out, Parrot_Int err)
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
443 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
444 ASSERT_ARGS(Parrot_api_set_stdhandles)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
445 EMBED_API_CALLIN(interp_pmc, interp)
446 void *dummy;
447
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
448 if (PIO_INVALID_HANDLE != (PIOHANDLE)in) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
449 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
450 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
451 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 alternate f...
Whiteknight authored
452 }
453
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
454 if (PIO_INVALID_HANDLE != (PIOHANDLE)out) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
455 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
456 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
457 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 alternate f...
Whiteknight authored
458 }
459
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
460 if (PIO_INVALID_HANDLE != (PIOHANDLE)err) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
461 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
462 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
463 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 alternate f...
Whiteknight authored
464 }
16e368d @Whiteknight fix several build warnings in src/embed/* in gcc, g++, and icc
Whiteknight authored
465 UNUSED(dummy);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
466
467 EMBED_API_CALLOUT(interp_pmc, interp)
f30aa2f @kapace Added some tests for embed api, get/set compiler and commented set_std_h...
kapace authored
468 }*/
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
469
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
470 /*
471
472 =item C<Parrot_Int Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
473 Parrot_String *runtime)>
474
475 Stores in C<runtime> the C<interp_pmc>'s running path. This function returns a
476 true value if this call is successful and false value otherwise.
477
478 =cut
479
480 */
481
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
482 PARROT_API
483 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
484 Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
485 ARGOUT(Parrot_String *runtime))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
486 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
487 ASSERT_ARGS(Parrot_api_get_runtime_path)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
488 EMBED_API_CALLIN(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
489 *runtime = Parrot_get_runtime_path(interp);
490 EMBED_API_CALLOUT(interp_pmc, interp);
491 }
492
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
493 /*
494
495 =item C<Parrot_Int Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc,
496 Parrot_PMC confighash)>
497
498 Sets the C<interp_pmc>'s configuration hash passed in C<confighash>. This
499 function returns a true value if this call is successful and false value
500 otherwise.
501
502 =cut
503
504 */
505
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash as...
Whiteknight authored
506 PARROT_API
507 Parrot_Int
508 Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc, Parrot_PMC confighash)
509 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
510 ASSERT_ARGS(Parrot_api_set_configuration_hash)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
511 EMBED_API_CALLIN(interp_pmc, interp)
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash as...
Whiteknight authored
512 Parrot_set_config_hash_pmc(interp, confighash);
5c2c3d4 @Whiteknight fix library paths. The build now progresses through all the parts that r...
Whiteknight authored
513 Parrot_lib_update_paths_from_config_hash(interp);
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash as...
Whiteknight authored
514 EMBED_API_CALLOUT(interp_pmc, interp);
515 }
516
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
517 /*
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
518
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
519 =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
520 lang)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
521
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
522 Loads the HLL compiler libraries for C<lang> into the C<interp_pmc>. This
523 function returns a true value if this call is successful and false value
524 otherwise.
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
525
526 =cut
527
528 */
529
530 PARROT_API
531 Parrot_Int
c9c5a00 @leto Decorate some embed api functions and rerun headerizer
leto authored
532 Parrot_api_load_language(Parrot_PMC interp_pmc, ARGIN(Parrot_String lang))
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
533 {
534 ASSERT_ARGS(Parrot_api_load_language)
535 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
536 Parrot_load_language(interp, lang);
537 EMBED_API_CALLOUT(interp_pmc, interp);
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
538 }
539
540 /*
541
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
542 =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
543 type, Parrot_PMC *compiler)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
544
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
545 Gets the compiler PMC and stores it in C<compiler>. This function returns a true
546 value if this call is successful and false value otherwise.
547
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
548 =cut
549
550 */
551
552 PARROT_API
553 Parrot_Int
c9c5a00 @leto Decorate some embed api functions and rerun headerizer
leto authored
554 Parrot_api_get_compiler(Parrot_PMC interp_pmc, ARGIN(Parrot_String type),
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
555 ARGOUT(Parrot_PMC *compiler))
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
556 {
557 ASSERT_ARGS(Parrot_api_get_compiler)
558 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
559 *compiler = Parrot_get_compiler(interp, type);
560 EMBED_API_CALLOUT(interp_pmc, interp);
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
561 }
562
563 /*
564
565 =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
566 type, Parrot_PMC compiler)>
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
567
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
568 Sets the C<compiler> object for the C<type> files. This function returns a true
569 value if this call is successful and false value otherwise.
570
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
571 =cut
572
573 */
574
575 PARROT_API
576 Parrot_Int
c9c5a00 @leto Decorate some embed api functions and rerun headerizer
leto authored
577 Parrot_api_set_compiler(Parrot_PMC interp_pmc, ARGIN(Parrot_String type),
578 ARGIN(Parrot_PMC compiler))
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
579 {
580 ASSERT_ARGS(Parrot_api_set_compiler)
581 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
582 Parrot_set_compiler(interp, type, compiler);
255a8d8 @Whiteknight move -G commandline argument parsing from IMCC into the frontend
Whiteknight authored
583 EMBED_API_CALLOUT(interp_pmc, interp)
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
584 }
0814f94 Merged changes with branch
Mariano Wahlmann authored
585
255a8d8 @Whiteknight move -G commandline argument parsing from IMCC into the frontend
Whiteknight authored
586 /*
587
588 =item C<Parrot_Int Parrot_api_toggle_gc(Parrot_PMC interp_pmc, Parrot_Int on)>
589
590 Turn Parrot's GC on or off.
591
592 =cut
593
594 */
595
596 PARROT_API
597 Parrot_Int
598 Parrot_api_toggle_gc(Parrot_PMC interp_pmc, Parrot_Int on)
599 {
600 ASSERT_ARGS(Parrot_api_toggle_gc)
601 EMBED_API_CALLIN(interp_pmc, interp)
602 if (on) {
603 Parrot_unblock_GC_mark(interp);
604 Parrot_unblock_GC_sweep(interp);
605 }
606 else {
607 Parrot_block_GC_mark(interp);
608 Parrot_block_GC_sweep(interp);
609 }
610 EMBED_API_CALLOUT(interp_pmc, interp)
611 }
6f90f7d @nol888 Add API functions to get a class from an array, and to instantiate a PMC...
nol888 authored
612
c6fa8b7 @mikehh fix codetest failures - add c function docs and ASSERT_ARGS
mikehh authored
613 /*
614
615 =item C<Parrot_Int Parrot_api_reset_call_signature(Parrot_PMC interp_pmc,
616 Parrot_PMC ctx)>
617
618 Reset the call signature
619
620 =cut
621
622 */
623
f0c28dc @Whiteknight Add in an API function so that we can reset and reuse an existing CallCo...
Whiteknight authored
624 PARROT_API
625 Parrot_Int
c9c5a00 @leto Decorate some embed api functions and rerun headerizer
leto authored
626 Parrot_api_reset_call_signature(Parrot_PMC interp_pmc, ARGMOD(Parrot_PMC ctx))
f0c28dc @Whiteknight Add in an API function so that we can reset and reuse an existing CallCo...
Whiteknight authored
627 {
c6fa8b7 @mikehh fix codetest failures - add c function docs and ASSERT_ARGS
mikehh authored
628 ASSERT_ARGS(Parrot_api_reset_call_signature)
f0c28dc @Whiteknight Add in an API function so that we can reset and reuse an existing CallCo...
Whiteknight authored
629 EMBED_API_CALLIN(interp_pmc, interp)
630 STRING * const callcontext = Parrot_str_new(interp, "CallContext", 0);
631 if (!VTABLE_isa(interp, ctx, callcontext))
632 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
633 "Not a valid CallContext");
634 VTABLE_morph(interp, ctx, PMCNULL);
635 EMBED_API_CALLOUT(interp_pmc, interp)
636 }
637
0814f94 Merged changes with branch
Mariano Wahlmann authored
638 /*
639
027abfa @Whiteknight add two new API functions for dealing with opaque user data pointers
Whiteknight authored
640 =item C<Parrot_Int Parrot_api_wrap_pointer(Parrot_PMC interp_pmc, void *ptr,
641 Parrot_Int size, Parrot_PMC *pmc)>
642
643 Wrap a user data pointer into a Ptr PMC for passing into Parrot. This PMC
644 is designed such that Parrot will treat the pointer as being opaque and will
645 not attempt to dereference, examine, or manipulate it at all.
646
647 Optionally a C<size> parameter can be passed. If C<size> is greater than zero,
648 the size information will be included with the pointer for later use. If
649 C<size> is less than or equal to zero, it will be ignored and will not be
650 included in the PMC object.
651
54d5026 @plobsing [codetest] correct format of C function doc =item
plobsing authored
652 =item C<Parrot_Int Parrot_api_unwrap_pointer(Parrot_PMC interp_pmc, Parrot_PMC
653 pmc, void ** ptr, Parrot_Int * size)>
027abfa @Whiteknight add two new API functions for dealing with opaque user data pointers
Whiteknight authored
654
655 Return a pointer from a PMC. This is typically used in conjunction with
656 C<Parrot_api_wrap_pointer> to return the original wrapped pointer value from
657 the PMC. Used with other PMC types besides C<Ptr> or C<PtrBuf> will have
658 undefined results, and should not be used or relied upon.
659
660 If the pointer was stored with size information, C<size> will contain that
661 size value. Otherwise, C<size> will be -1.
662
663 Notice that this function does not destroy or alter the data PMC.
664
665 =cut
666
667 */
668
669 PARROT_API
670 Parrot_Int
671 Parrot_api_wrap_pointer(Parrot_PMC interp_pmc, ARGIN_NULLOK(void *ptr),
672 Parrot_Int size, ARGOUT(Parrot_PMC *pmc))
673 {
674 ASSERT_ARGS(Parrot_api_wrap_pointer)
675 EMBED_API_CALLIN(interp_pmc, interp)
676 PMC * ptr_pmc = NULL;
677 if (size > 0) {
678 ptr_pmc = Parrot_pmc_new(interp, enum_class_PtrBuf);
b65a8ba @bacek Fix braino in api_wrap/unwrap_pointer.
bacek authored
679 VTABLE_set_integer_native(interp, ptr_pmc, size);
edc686b @plobsing cuddled else
plobsing authored
680 }
681 else
027abfa @Whiteknight add two new API functions for dealing with opaque user data pointers
Whiteknight authored
682 ptr_pmc = Parrot_pmc_new(interp, enum_class_Ptr);
b65a8ba @bacek Fix braino in api_wrap/unwrap_pointer.
bacek authored
683 VTABLE_set_pointer(interp, ptr_pmc, ptr);
027abfa @Whiteknight add two new API functions for dealing with opaque user data pointers
Whiteknight authored
684 *pmc = ptr_pmc;
685 EMBED_API_CALLOUT(interp_pmc, interp)
686 }
687
688 PARROT_API
689 Parrot_Int
690 Parrot_api_unwrap_pointer(Parrot_PMC interp_pmc, Parrot_PMC pmc,
691 ARGOUT(void ** ptr), ARGOUT(Parrot_Int * size))
692 {
693 ASSERT_ARGS(Parrot_api_unwrap_pointer)
694 EMBED_API_CALLIN(interp_pmc, interp)
695 *ptr = VTABLE_get_pointer(interp, pmc);
696 if (pmc->vtable->base_type == enum_class_PtrBuf)
697 *size = VTABLE_get_integer(interp, pmc);
698 else
699 *size = -1;
700 EMBED_API_CALLOUT(interp_pmc, interp);
701 }
702
703 /*
704
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
705 =back
706
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
707 =cut
0814f94 Merged changes with branch
Mariano Wahlmann authored
708
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
709 */
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
710
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
711 /*
712 * Local variables:
713 * c-file-style: "parrot"
714 * End:
715 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
716 */
0814f94 Merged changes with branch
Mariano Wahlmann authored
717
Something went wrong with that request. Please try again.