Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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