Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 939 lines (728 sloc) 27.349 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) {
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
172 Parrot_pcc_trace_flags_on(interp, interp->ctx, trace);
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 {
372f8f7 @bluescreen10 Make bounds runcore available
bluescreen10 authored
176 if (!strcmp(corename, "slow") || !strcmp(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"));
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
178 else if (!strcmp(corename, "fast") ||
179 !strcmp(corename, "jit") || !strcmp(corename, "function"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
180 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "fast"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
181 else if (!strcmp(corename, "exec"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
182 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "exec"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
183 else if (!strcmp(corename, "trace"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
184 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
185 else if (!strcmp(corename, "profiling"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
186 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "profiling"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
187 else if (!strcmp(corename, "gcdebug"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
188 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "gcdebug"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
189 else
190 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Invalid runcore type %s", corename);
191 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
192 EMBED_API_CALLOUT(interp_pmc, interp)
193 }
194
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
195 /*
196
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
197 =item C<Parrot_Int Parrot_api_debug_flag(Parrot_PMC interp_pmc, Parrot_Int
198 flags, Parrot_Int set)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
199
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
200 Sets/Unsets the C<interp_pmc>'s debug flags. If C<set> is in a true value debug
201 flags are set otherwise debug flags are cleared. This function returns a true
202 value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
203
204 =cut
205
206 */
207
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
208 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
209 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
210 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
211 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
212 ASSERT_ARGS(Parrot_api_debug_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
213 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
214 if (set)
215 interp->debug_flags |= flags;
216 else
217 interp->debug_flags &= ~flags;
218 EMBED_API_CALLOUT(interp_pmc, interp);
219 }
220
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
221 /*
222
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
223 =item C<Parrot_Int Parrot_api_flag(Parrot_PMC interp_pmc, Parrot_Int flags,
224 Parrot_Int set)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
225
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
226 Set/Unset the C<interp_pmc>'s general flags. If C<set> is in a true value general
227 flags are set otherwise passed flags are cleared. This function returns a true
228 value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
229
230 =cut
231
232 */
233
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
234 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
235 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
236 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
237 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
238 ASSERT_ARGS(Parrot_api_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
239 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
240 if (set) {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
241 Interp_flags_SET(interp, flags);
242 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
243 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
244 }
245 else
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
246 Interp_flags_CLEAR(interp, flags);
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
247 EMBED_API_CALLOUT(interp_pmc, interp);
248 }
249
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
250 /*
251
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
252 =item C<Parrot_Int Parrot_api_set_executable_name(Parrot_PMC interp_pmc, const
253 char * name)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
254
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
255 Sets the executable name for the C<interp_pmc> interpreter. This function returns
256 a true value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
257
258 =cut
259
260 */
261
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
262 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
263 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
264 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
265 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
266 ASSERT_ARGS(Parrot_api_set_executable_name)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
267 EMBED_API_CALLIN(interp_pmc, interp)
9cc3ace @plobsing allow for unicode names of fakecutables
plobsing authored
268 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
269 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
270 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
271 VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_EXECUTABLE,
272 name_pmc);
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
273 EMBED_API_CALLOUT(interp_pmc, interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
274 }
275
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
276 /*
277
278 =item C<Parrot_Int Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)>
279
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
280 Destroys the C<interp_pmc> interpreter, freeing the memory structures allocated
281 for it. This function returns a true value if this call is successful and false
282 value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
283
284 =cut
285
286 */
287
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
288 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
289 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
290 Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
291 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
292 ASSERT_ARGS(Parrot_api_destroy_interpreter)
2dc5187 @nwellnhof [embed] Fix segfault with --leak-test option
nwellnhof authored
293 Parrot_jump_buff env;
294 if (setjmp(env)) {
295 /* We can't check for potential errors because the interpreter
296 * might have been destroyed. */
297 return 1;
298 }
299 else {
ced54a5 @NotFound Fix remaining 'might be clobbered' warning
NotFound authored
300 Interp * const interp = GET_INTERP(interp_pmc);
301 void * _oldtop = interp->lo_var_ptr;
302 if (_oldtop == NULL)
303 interp->lo_var_ptr = &_oldtop;
304 interp->api_jmp_buf = &env;
2dc5187 @nwellnhof [embed] Fix segfault with --leak-test option
nwellnhof authored
305 Parrot_destroy(interp);
306 Parrot_x_exit(interp, 0);
307 /* Never reached, x_exit calls longjmp */
308 return 1;
309 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
310 }
311
312 /*
313
adc07e5 @nwellnhof Merge branch 'master' into nwellnhof/unicode_filenames
nwellnhof authored
314 =item C<Parrot_Int Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc,
315 Parrot_String filename, Parrot_PMC * pbc)>
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
316
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
317 Load a bytecode file and stores the resulting bytecode in C<pbc>. This function
318 returns a true value if this call is successful and false value otherwise.
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
319
320 =cut
321
322 */
323
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebuild...
Whiteknight authored
324 /* TODO: This only works with the inital bytecode. After this we should use
d4cdba7 @Whiteknight remove .pbc loading logic from imcc_run, and move it into the parrot.exe...
Whiteknight authored
325 Parrot_append_bytecode or something similar */
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebuild...
Whiteknight authored
326
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
327 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
328 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
329 Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc,
adc07e5 @nwellnhof Merge branch 'master' into nwellnhof/unicode_filenames
nwellnhof authored
330 ARGIN(Parrot_String filename), ARGOUT(Parrot_PMC * pbc))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
331 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
332 ASSERT_ARGS(Parrot_api_load_bytecode_file)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
333 EMBED_API_CALLIN(interp_pmc, interp)
adc07e5 @nwellnhof Merge branch 'master' into nwellnhof/unicode_filenames
nwellnhof authored
334 PackFile * const pf = PackFile_read_pbc(interp, filename, 0);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
335 if (!pf)
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the packfi...
Whiteknight authored
336 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_MALFORMED_PACKFILE,
337 "Could not load packfile");
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults buildi...
Whiteknight authored
338 do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL);
d9497e3 @bacek Apply patch from nwellnhof++ to disable GC during Packfile loading. Wall...
bacek authored
339 Parrot_block_GC_mark(interp);
950d701 @Whiteknight Packfile PMCs don't do what I need them to do (yet). Use UnManagedStruct...
Whiteknight authored
340 *pbc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
d9497e3 @bacek Apply patch from nwellnhof++ to disable GC during Packfile loading. Wall...
bacek authored
341 Parrot_unblock_GC_mark(interp);
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
342 VTABLE_set_pointer(interp, *pbc, pf);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
343 EMBED_API_CALLOUT(interp_pmc, interp)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
344 }
345
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
346 /*
347
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
348 =item C<Parrot_Int Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc, const
349 unsigned char * const pbc, Parrot_Int bytecode_size, Parrot_PMC * pbcpmc)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
350
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
351 Unpacks a bytecode from a buffer C<pbc> of a C<bytecode_size> size, and stores
352 the resulting bytecode in C<pbcpmc>. This function returns a true value if this
353 call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
354
355 =cut
356
357 */
358
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
359 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
360 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
361 Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc,
362 ARGIN(const unsigned char * const pbc), Parrot_Int bytecode_size,
363 ARGOUT(Parrot_PMC * pbcpmc))
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults buildi...
Whiteknight authored
364 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
365 ASSERT_ARGS(Parrot_api_load_bytecode_bytes)
99428c2 Make src/embed/pmc.c & src/embed/api.c compile with gcc
Mariano Wahlmann authored
366 EMBED_API_CALLIN(interp_pmc, interp)
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults buildi...
Whiteknight authored
367 PackFile * const pf = PackFile_new(interp, 0);
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the packfi...
Whiteknight authored
368 PARROT_ASSERT(pf);
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults buildi...
Whiteknight authored
369
d9497e3 @bacek Apply patch from nwellnhof++ to disable GC during Packfile loading. Wall...
bacek authored
370 Parrot_block_GC_mark(interp);
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults buildi...
Whiteknight authored
371 if (!PackFile_unpack(interp, pf, (const opcode_t *)pbc, bytecode_size))
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the packfi...
Whiteknight authored
372 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_MALFORMED_PACKFILE,
f0c28dc @Whiteknight Add in an API function so that we can reset and reuse an existing CallCo...
Whiteknight authored
373 "Could not unpack packfile");
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults buildi...
Whiteknight authored
374 do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL);
375 *pbcpmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
376 VTABLE_set_pointer(interp, *pbcpmc, pf);
d9497e3 @bacek Apply patch from nwellnhof++ to disable GC during Packfile loading. Wall...
bacek authored
377 Parrot_unblock_GC_mark(interp);
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults buildi...
Whiteknight authored
378 EMBED_API_CALLOUT(interp_pmc, interp);
379 }
380
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebuild...
Whiteknight authored
381 /* Load the bytecode into the interpreter, but don't execute it */
382 /* TODO: This only works with the inital bytecode. After this we should use
383 Parrot_append_bytecode or something similar */
384
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
385 /*
386
387 =item C<Parrot_Int Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
388 pbc, Parrot_PMC *main_sub)>
389
390 Prepares the bytecode C<pbc> to be run and stores the entry point subroutine in
391 C<main_sub>. This function returns a true value if this call is successful and
392 false value otherwise.
393
394 =cut
395
396 */
397
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't being u...
Whiteknight authored
398 PARROT_API
399 Parrot_Int
400 Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
401 ARGOUT(Parrot_PMC *main_sub))
402 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
403 ASSERT_ARGS(Parrot_api_ready_bytecode)
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't being u...
Whiteknight authored
404 EMBED_API_CALLIN(interp_pmc, interp)
405 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
406
407 /* Debugging mode nonsense. */
408 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
409 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
410 interp->run_core->name);
411 }
412
413 if (!pf)
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the packfi...
Whiteknight authored
414 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
415 "Could not get packfile.");
416 if (pf->cur_cs)
417 Parrot_pf_set_current_packfile(interp, pf);
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't being u...
Whiteknight authored
418 PackFile_fixup_subs(interp, PBC_MAIN, NULL);
419 *main_sub = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
420 Parrot_pcc_set_constants(interp, interp->ctx, interp->code->const_table);
421 EMBED_API_CALLOUT(interp_pmc, interp)
422 }
423
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
424
425 /*
426
427 =item C<Parrot_Int Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
428 pbc, Parrot_PMC mainargs)>
429
430 Runs the bytecode C<pbc> passing optional C<mainargs> parameters. This function
431 returns a true value if this call is successful and false value otherwise.
432
433 =cut
434
435 */
436
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults buildi...
Whiteknight authored
437 PARROT_API
438 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
439 Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
440 Parrot_PMC mainargs)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
441 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
442 ASSERT_ARGS(Parrot_api_run_bytecode)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
443 EMBED_API_CALLIN(interp_pmc, interp)
98cd26c @Whiteknight don't call Parrot_pbc_load if the PBC comes straight out of IMCC. IMCC d...
Whiteknight authored
444 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
9f7a94c @Whiteknight make sure to set :main() args in the iglobals array. This makes ops2c ru...
Whiteknight authored
445
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
446 /* Debugging mode nonsense. */
447 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
448 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
449 interp->run_core->name);
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't being u...
Whiteknight authored
450 }
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
451
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
452 if (!pf)
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the packfi...
Whiteknight authored
453 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
454 "Could not get packfile.");
2310551 @nwellnhof Fix assertion failure
nwellnhof authored
455 if (!mainargs)
456 mainargs = PMCNULL;
240d5b7 @Whiteknight Add a new function to execute a PackFile* as a program
Whiteknight authored
457 Parrot_pf_execute_bytecode_program(interp, pf, mainargs);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
458 EMBED_API_CALLOUT(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
459 }
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
460
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
461 /*
462
463 =item C<Parrot_Int Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc,
464 Parrot_PMC pbc, const char * const outfile, Parrot_Int opts)>
465
466 Disassembles and prints out the C<pbc> bytecode. This function returns a true
467 value if this call is successful and false value otherwise.
468
469 =cut
470
471 */
472
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
473 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
474 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
475 Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
476 ARGIN_NULLOK(const char * const outfile), Parrot_Int opts)
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function to ...
Whiteknight authored
477 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
478 ASSERT_ARGS(Parrot_api_disassemble_bytecode)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
479 EMBED_API_CALLIN(interp_pmc, interp)
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function to ...
Whiteknight authored
480 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
481 if (!pf)
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the packfi...
Whiteknight authored
482 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
483 "Could not get packfile.");
484 if (pf->cur_cs)
485 Parrot_pf_set_current_packfile(interp, pf);
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
486 /* TODO: Break up the dependency with emebed.c */
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function to ...
Whiteknight authored
487 Parrot_disassemble(interp, outfile, (Parrot_disassemble_options)opts);
488 EMBED_API_CALLOUT(interp_pmc, interp);
489 }
490
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
491 /*
492
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suitabl...
Whiteknight authored
493 =item C<Parrot_Int Parrot_api_serialize_bytecode_pmc(Parrot_PMC interp_pmc,
494 Parrot_PMC pbc, Parrot_String * bc)>
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
495
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suitabl...
Whiteknight authored
496 Serialize a packfile PMC into a sequence of bytes suitable for writing out
497 to a .pbc file
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
498
499 =cut
500
501 */
502
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function to ...
Whiteknight authored
503 PARROT_API
504 Parrot_Int
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suitabl...
Whiteknight authored
505 Parrot_api_serialize_bytecode_pmc(Parrot_PMC interp_pmc, Parrot_PMC pbc,
506 ARGOUT(Parrot_String * bc))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
507 {
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suitabl...
Whiteknight authored
508 ASSERT_ARGS(Parrot_api_serialize_bytecode_pmc)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
509 EMBED_API_CALLIN(interp_pmc, interp)
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suitabl...
Whiteknight authored
510 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
511 if (!pf)
512 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
513 "Could not get packfile.");
514 else {
515 const Parrot_Int size = PackFile_pack_size(interp, pf) * sizeof (opcode_t);
516 opcode_t * const packed = (opcode_t*) mem_sys_allocate(size);
517 PackFile_pack(interp, pf, packed);
518 *bc = Parrot_str_new_init(interp, (const char *)packed, size,
519 Parrot_binary_encoding_ptr, 0);
520 }
c1ab56e More fixes, almost there
Mariano Wahlmann authored
521 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
522 }
523
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
524 /*
525
526 =item C<Parrot_Int Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int
527 flags)>
528
529 Enables C<inter_pmc>'s warning messages the type of warning information to be
530 print out is specified by C<flags>. This function returns a true value if this
531 call is successful and false value otherwise.
532
533 =cut
534
535 */
536
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
537 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
538 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
539 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
540 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
541 ASSERT_ARGS(Parrot_api_set_warnings)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
542 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
543 /* 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
544 PARROT_WARNINGS_on(interp, flags);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
545 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
546 }
547
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
548 /*
549
550 =item C<Parrot_Int Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
551 const char *path)>
552
553 Adds C<path> to the C<inter_pmc>'s library search path list. This function
554 returns a true value if this call is successful and false value otherwise.
555
556 =cut
557
558 */
559
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
560 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
561 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
562 Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
563 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
564 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
565 ASSERT_ARGS(Parrot_api_add_library_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
566 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
567 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_LIBRARY);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
568 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
569 }
570
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
571 /*
572
573 =item C<Parrot_Int Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
574 const char *path)>
575
576 Adds C<path> to the C<inter_pmc>'s include search path list. This function
577 returns a true value if this call is successful and false value otherwise.
578
579 =cut
580
581 */
582
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
583 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
584 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
585 Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
586 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
587 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
588 ASSERT_ARGS(Parrot_api_add_include_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
589 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
590 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_INCLUDE);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
591 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
592 }
593
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
594 /*
595
596 =item C<Parrot_Int Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
597 const char *path)>
598
599 Adds C<path> to the C<inter_pmc>'s dynext search path list. This function
600 returns a true value if this call is successful and false value otherwise.
601
602 =cut
603
604 */
605
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
606 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
607 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
608 Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
609 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
610 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
611 ASSERT_ARGS(Parrot_api_add_dynext_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
612 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
613 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_DYNEXT);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
614 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
615 }
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
616
617 /*
618
c7def2f @jkeenan Run 'perl tools/dev/headerizer.pl src/embed/api.o'.
jkeenan authored
619 =item C<Parrot_Int Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int
620 in, Parrot_Int out, Parrot_Int err)>
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
621
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
622 Set the C<interp_pmc>'s standard file descriptors STDIN, STDOUT, STDERR. Any
623 file descriptor set to C<PIO_INVALID_HANDLE> is ignored. This function returns
624 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
625
626 =cut
627
628 */
f30aa2f @kapace Added some tests for embed api, get/set compiler and commented set_std_h...
kapace authored
629 /* Whiteknight told me that theres no way to test this for now, so it should be
630 commented out, for now.
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
631
632 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
633 Parrot_Int
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
634 Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int in,
635 Parrot_Int out, Parrot_Int err)
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
636 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
637 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
638 EMBED_API_CALLIN(interp_pmc, interp)
639 void *dummy;
640
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
641 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
642 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
643 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
644 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
645 }
646
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
647 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
648 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
649 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
650 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
651 }
652
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
653 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
654 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
655 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
656 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
657 }
16e368d @Whiteknight fix several build warnings in src/embed/* in gcc, g++, and icc
Whiteknight authored
658 UNUSED(dummy);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
659
660 EMBED_API_CALLOUT(interp_pmc, interp)
f30aa2f @kapace Added some tests for embed api, get/set compiler and commented set_std_h...
kapace authored
661 }*/
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
662
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
663 /*
664
665 =item C<Parrot_Int Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
666 Parrot_String *runtime)>
667
668 Stores in C<runtime> the C<interp_pmc>'s running path. This function returns a
669 true value if this call is successful and false value otherwise.
670
671 =cut
672
673 */
674
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
675 PARROT_API
676 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
677 Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
678 ARGOUT(Parrot_String *runtime))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
679 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
680 ASSERT_ARGS(Parrot_api_get_runtime_path)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
681 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
682 *runtime = Parrot_get_runtime_path(interp);
683 EMBED_API_CALLOUT(interp_pmc, interp);
684 }
685
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
686 /*
687
688 =item C<Parrot_Int Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc,
689 Parrot_PMC confighash)>
690
691 Sets the C<interp_pmc>'s configuration hash passed in C<confighash>. This
692 function returns a true value if this call is successful and false value
693 otherwise.
694
695 =cut
696
697 */
698
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash as...
Whiteknight authored
699 PARROT_API
700 Parrot_Int
701 Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc, Parrot_PMC confighash)
702 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
703 ASSERT_ARGS(Parrot_api_set_configuration_hash)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
704 EMBED_API_CALLIN(interp_pmc, interp)
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash as...
Whiteknight authored
705 Parrot_set_config_hash_pmc(interp, confighash);
5c2c3d4 @Whiteknight fix library paths. The build now progresses through all the parts that r...
Whiteknight authored
706 Parrot_lib_update_paths_from_config_hash(interp);
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash as...
Whiteknight authored
707 EMBED_API_CALLOUT(interp_pmc, interp);
708 }
709
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
710 /*
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
711
903db1c @nwellnhof [imcc] Switch to PIO and STRING filenames for all input files
nwellnhof authored
712 =item C<Parrot_Int Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc,
713 Parrot_String sourcefile, int argc, const char **argv, Parrot_PMC* bytecodepmc,
714 int *result, imcc_hack_func_t func)>
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
715
716 WARNING: This is an evil hack to provide a wrapper around IMCC to catch unhandled
717 exceptions without having to assume IMCC is linked in with libparrot. Delete this
718 as soon as we don't need it anymore.
719
720 This function returns a true value if this call is successful and false value
721 otherwise.
722
723 =cut
724
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
725 */
726
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch error...
Whiteknight authored
727 PARROT_API
728 Parrot_Int
903db1c @nwellnhof [imcc] Switch to PIO and STRING filenames for all input files
nwellnhof authored
729 Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc, ARGIN(Parrot_String sourcefile),
ca855f2 @Whiteknight implement the test for Parrot_api_serialize_bytecode_pmc. Fix some ARG m...
Whiteknight authored
730 int argc, ARGIN_NULLOK(const char **argv), ARGMOD(Parrot_PMC* bytecodepmc),
eaf402c @nwellnhof Fix headerizer warnings
nwellnhof authored
731 ARGOUT(int *result), imcc_hack_func_t func)
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch error...
Whiteknight authored
732 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
733 ASSERT_ARGS(Parrot_api_wrap_imcc_hack)
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch error...
Whiteknight authored
734 EMBED_API_CALLIN(interp_pmc, interp)
735 *result = func(interp_pmc, sourcefile, argc, argv, bytecodepmc);
736 EMBED_API_CALLOUT(interp_pmc, interp)
737 }
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash as...
Whiteknight authored
738
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
739 /*
740
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
741 =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
742 lang)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
743
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
744 Loads the HLL compiler libraries for C<lang> into the C<interp_pmc>. This
745 function returns a true value if this call is successful and false value
746 otherwise.
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
747
748 =cut
749
750 */
751
752 PARROT_API
753 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
754 Parrot_api_load_language(Parrot_PMC interp_pmc, Parrot_String lang)
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
755 {
756 ASSERT_ARGS(Parrot_api_load_language)
757 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
758 Parrot_load_language(interp, lang);
759 EMBED_API_CALLOUT(interp_pmc, interp);
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
760 }
761
762 /*
763
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
764 =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
765 type, Parrot_PMC *compiler)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
766
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
767 Gets the compiler PMC and stores it in C<compiler>. This function returns a true
768 value if this call is successful and false value otherwise.
769
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
770 =cut
771
772 */
773
774 PARROT_API
775 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
776 Parrot_api_get_compiler(Parrot_PMC interp_pmc, Parrot_String type,
777 ARGOUT(Parrot_PMC *compiler))
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
778 {
779 ASSERT_ARGS(Parrot_api_get_compiler)
780 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
781 *compiler = Parrot_get_compiler(interp, type);
782 EMBED_API_CALLOUT(interp_pmc, interp);
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
783 }
784
785 /*
786
787 =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
788 type, Parrot_PMC compiler)>
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
789
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
790 Sets the C<compiler> object for the C<type> files. This function returns a true
791 value if this call is successful and false value otherwise.
792
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
793 =cut
794
795 */
796
797 PARROT_API
798 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
799 Parrot_api_set_compiler(Parrot_PMC interp_pmc, Parrot_String type,
800 Parrot_PMC compiler)
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
801 {
802 ASSERT_ARGS(Parrot_api_set_compiler)
803 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
804 Parrot_set_compiler(interp, type, compiler);
255a8d8 @Whiteknight move -G commandline argument parsing from IMCC into the frontend
Whiteknight authored
805 EMBED_API_CALLOUT(interp_pmc, interp)
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
806 }
0814f94 Merged changes with branch
Mariano Wahlmann authored
807
255a8d8 @Whiteknight move -G commandline argument parsing from IMCC into the frontend
Whiteknight authored
808 /*
809
810 =item C<Parrot_Int Parrot_api_toggle_gc(Parrot_PMC interp_pmc, Parrot_Int on)>
811
812 Turn Parrot's GC on or off.
813
814 =cut
815
816 */
817
818 PARROT_API
819 Parrot_Int
820 Parrot_api_toggle_gc(Parrot_PMC interp_pmc, Parrot_Int on)
821 {
822 ASSERT_ARGS(Parrot_api_toggle_gc)
823 EMBED_API_CALLIN(interp_pmc, interp)
824 if (on) {
825 Parrot_unblock_GC_mark(interp);
826 Parrot_unblock_GC_sweep(interp);
827 }
828 else {
829 Parrot_block_GC_mark(interp);
830 Parrot_block_GC_sweep(interp);
831 }
832 EMBED_API_CALLOUT(interp_pmc, interp)
833 }
6f90f7d @nol888 Add API functions to get a class from an array, and to instantiate a PMC...
nol888 authored
834
c6fa8b7 @mikehh fix codetest failures - add c function docs and ASSERT_ARGS
mikehh authored
835 /*
836
837 =item C<Parrot_Int Parrot_api_reset_call_signature(Parrot_PMC interp_pmc,
838 Parrot_PMC ctx)>
839
840 Reset the call signature
841
842 =cut
843
844 */
845
f0c28dc @Whiteknight Add in an API function so that we can reset and reuse an existing CallCo...
Whiteknight authored
846 PARROT_API
847 Parrot_Int
848 Parrot_api_reset_call_signature(Parrot_PMC interp_pmc, Parrot_PMC ctx)
849 {
c6fa8b7 @mikehh fix codetest failures - add c function docs and ASSERT_ARGS
mikehh authored
850 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
851 EMBED_API_CALLIN(interp_pmc, interp)
852 STRING * const callcontext = Parrot_str_new(interp, "CallContext", 0);
853 if (!VTABLE_isa(interp, ctx, callcontext))
854 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
855 "Not a valid CallContext");
856 VTABLE_morph(interp, ctx, PMCNULL);
857 EMBED_API_CALLOUT(interp_pmc, interp)
858 }
859
0814f94 Merged changes with branch
Mariano Wahlmann authored
860 /*
861
027abfa @Whiteknight add two new API functions for dealing with opaque user data pointers
Whiteknight authored
862 =item C<Parrot_Int Parrot_api_wrap_pointer(Parrot_PMC interp_pmc, void *ptr,
863 Parrot_Int size, Parrot_PMC *pmc)>
864
865 Wrap a user data pointer into a Ptr PMC for passing into Parrot. This PMC
866 is designed such that Parrot will treat the pointer as being opaque and will
867 not attempt to dereference, examine, or manipulate it at all.
868
869 Optionally a C<size> parameter can be passed. If C<size> is greater than zero,
870 the size information will be included with the pointer for later use. If
871 C<size> is less than or equal to zero, it will be ignored and will not be
872 included in the PMC object.
873
874 item C<Parrot_Int Parrot_api_unwrap_pointer(Parrot_PMC interp_pmc,
875 Parrot_PMC pmc, ARGOUT(void ** ptr), ARGOUT(Parrot_Int * size))>
876
877 Return a pointer from a PMC. This is typically used in conjunction with
878 C<Parrot_api_wrap_pointer> to return the original wrapped pointer value from
879 the PMC. Used with other PMC types besides C<Ptr> or C<PtrBuf> will have
880 undefined results, and should not be used or relied upon.
881
882 If the pointer was stored with size information, C<size> will contain that
883 size value. Otherwise, C<size> will be -1.
884
885 Notice that this function does not destroy or alter the data PMC.
886
887 =cut
888
889 */
890
891 PARROT_API
892 Parrot_Int
893 Parrot_api_wrap_pointer(Parrot_PMC interp_pmc, ARGIN_NULLOK(void *ptr),
894 Parrot_Int size, ARGOUT(Parrot_PMC *pmc))
895 {
896 ASSERT_ARGS(Parrot_api_wrap_pointer)
897 EMBED_API_CALLIN(interp_pmc, interp)
898 PMC * ptr_pmc = NULL;
899 if (size > 0) {
900 ptr_pmc = Parrot_pmc_new(interp, enum_class_PtrBuf);
b65a8ba @bacek Fix braino in api_wrap/unwrap_pointer.
bacek authored
901 VTABLE_set_integer_native(interp, ptr_pmc, size);
027abfa @Whiteknight add two new API functions for dealing with opaque user data pointers
Whiteknight authored
902 } else
903 ptr_pmc = Parrot_pmc_new(interp, enum_class_Ptr);
b65a8ba @bacek Fix braino in api_wrap/unwrap_pointer.
bacek authored
904 VTABLE_set_pointer(interp, ptr_pmc, ptr);
027abfa @Whiteknight add two new API functions for dealing with opaque user data pointers
Whiteknight authored
905 *pmc = ptr_pmc;
906 EMBED_API_CALLOUT(interp_pmc, interp)
907 }
908
909 PARROT_API
910 Parrot_Int
911 Parrot_api_unwrap_pointer(Parrot_PMC interp_pmc, Parrot_PMC pmc,
912 ARGOUT(void ** ptr), ARGOUT(Parrot_Int * size))
913 {
914 ASSERT_ARGS(Parrot_api_unwrap_pointer)
915 EMBED_API_CALLIN(interp_pmc, interp)
916 *ptr = VTABLE_get_pointer(interp, pmc);
917 if (pmc->vtable->base_type == enum_class_PtrBuf)
918 *size = VTABLE_get_integer(interp, pmc);
919 else
920 *size = -1;
921 EMBED_API_CALLOUT(interp_pmc, interp);
922 }
923
924 /*
925
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
926 =back
927
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
928 =cut
0814f94 Merged changes with branch
Mariano Wahlmann authored
929
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
930 */
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
931
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
932 /*
933 * Local variables:
934 * c-file-style: "parrot"
935 * End:
936 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
937 */
0814f94 Merged changes with branch
Mariano Wahlmann authored
938
Something went wrong with that request. Please try again.