Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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