Skip to content

HTTPS clone URL

Subversion checkout URL

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