Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 954 lines (741 sloc) 27.727 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 remove…
bluescreen10 authored
21 #include "parrot/runcore_api.h"
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
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_…
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 alternat…
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 alternat…
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 p…
Whiteknight authored
60 EMBED_API_CALLIN(interp_pmc, interp)
be50d63 @bluescreen10 Implemented first version of Parrot_get_result, now a lot of failing …
bluescreen10 authored
61 *exit_code = interp->exit_code;
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
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 p…
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 …
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 p…
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 …
bluescreen10 authored
74 interp->exit_code = 0;
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we p…
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 alternat…
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 alternat…
Whiteknight authored
91 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
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 p…
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 p…
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 alternat…
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 alternat…
Whiteknight authored
120 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
121 Parrot_Int
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
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 s…
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 s…
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 i…
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 i…
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 close…
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 alternat…
Whiteknight authored
171 if (trace) {
c510c5c @Whiteknight fix the trace core, so when we use the -t, --trace, or -Rtrace flags,…
Whiteknight authored
172 Interp_trace_SET(interp, PARROT_TRACE_OPS_FLAG);
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
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 strc…
petdance authored
176 if (STREQ(corename, "slow") || STREQ(corename, "bounds"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
177 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
38e5177 @petdance Use STREQ() for string comparisons, instead of incorrectly using strc…
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 remove…
bluescreen10 authored
179 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "fast"));
38e5177 @petdance Use STREQ() for string comparisons, instead of incorrectly using strc…
petdance authored
180 else if (STREQ(corename, "exec"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
181 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "exec"));
114d897 @petdance Use STREQ() for string comparisons, instead of incorrectly using strc…
petdance authored
182 else if (STREQ(corename, "trace"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
183 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
38e5177 @petdance Use STREQ() for string comparisons, instead of incorrectly using strc…
petdance authored
184 else if (STREQ(corename, "profiling"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
185 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "profiling"));
38e5177 @petdance Use STREQ() for string comparisons, instead of incorrectly using strc…
petdance authored
186 else if (STREQ(corename, "gcdebug"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
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 alternat…
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 close…
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 in…
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 in…
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 in…
Whiteknight authored
233 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
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 in…
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 in…
Whiteknight authored
239 if (set) {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
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 in…
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 close…
Whiteknight authored
245 Interp_flags_CLEAR(interp, flags);
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…
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 in…
Whiteknight authored
261 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
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…
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 close…
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
adc07e5 @nwellnhof Merge branch 'master' into nwellnhof/unicode_filenames
nwellnhof authored
313 =item C<Parrot_Int Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc,
314 Parrot_String filename, Parrot_PMC * pbc)>
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
315
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
316 Load a bytecode file and stores the resulting bytecode in C<pbc>. This function
317 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
318
319 =cut
320
321 */
322
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebu…
Whiteknight authored
323 /* 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.…
Whiteknight authored
324 Parrot_append_bytecode or something similar */
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebu…
Whiteknight authored
325
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
326 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
327 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
328 Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc,
adc07e5 @nwellnhof Merge branch 'master' into nwellnhof/unicode_filenames
nwellnhof authored
329 ARGIN(Parrot_String filename), ARGOUT(Parrot_PMC * pbc))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
330 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
331 ASSERT_ARGS(Parrot_api_load_bytecode_file)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
332 EMBED_API_CALLIN(interp_pmc, interp)
369b59b @cotto make gcc happy
cotto authored
333 *pbc = PackFile_read_pbc(interp, filename, 0);
f65e92a @bacek Update code to new Parrot_PackFile typedef.
bacek authored
334 if (PMC_IS_NULL(*pbc))
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the pac…
Whiteknight authored
335 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_MALFORMED_PACKFILE,
336 "Could not load packfile");
d234bcc @bacek Change do_sub_pragmas to accept PMC instead of raw PackFile_ByteCode …
bacek authored
337 do_sub_pragmas(interp, *pbc, PBC_PBC, NULL);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
338 EMBED_API_CALLOUT(interp_pmc, interp)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
339 }
340
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
341 /*
342
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
343 =item C<Parrot_Int Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc, const
344 unsigned char * const pbc, Parrot_Int bytecode_size, Parrot_PMC * pbcpmc)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
345
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
346 Unpacks a bytecode from a buffer C<pbc> of a C<bytecode_size> size, and stores
347 the resulting bytecode in C<pbcpmc>. This function returns a true value if this
348 call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
349
350 =cut
351
352 */
353
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
354 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
355 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
356 Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc,
357 ARGIN(const unsigned char * const pbc), Parrot_Int bytecode_size,
358 ARGOUT(Parrot_PMC * pbcpmc))
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
359 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
360 ASSERT_ARGS(Parrot_api_load_bytecode_bytes)
99428c2 Make src/embed/pmc.c & src/embed/api.c compile with gcc
Mariano Wahlmann authored
361 EMBED_API_CALLIN(interp_pmc, interp)
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
362 PackFile * const pf = PackFile_new(interp, 0);
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the pac…
Whiteknight authored
363 PARROT_ASSERT(pf);
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
364
d9497e3 @bacek Apply patch from nwellnhof++ to disable GC during Packfile loading. W…
bacek authored
365 Parrot_block_GC_mark(interp);
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
366 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 pac…
Whiteknight authored
367 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 Cal…
Whiteknight authored
368 "Could not unpack packfile");
47d6211 @Whiteknight remove TT #1990 hack from Parrot_load_bytecode. This should prevent P…
Whiteknight authored
369 *pbcpmc = Parrot_pf_get_packfile_pmc(interp, pf);
d234bcc @bacek Change do_sub_pragmas to accept PMC instead of raw PackFile_ByteCode …
bacek authored
370 do_sub_pragmas(interp, *pbcpmc, PBC_PBC, NULL);
d9497e3 @bacek Apply patch from nwellnhof++ to disable GC during Packfile loading. W…
bacek authored
371 Parrot_unblock_GC_mark(interp);
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
372 EMBED_API_CALLOUT(interp_pmc, interp);
373 }
374
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebu…
Whiteknight authored
375 /* Load the bytecode into the interpreter, but don't execute it */
376 /* TODO: This only works with the inital bytecode. After this we should use
377 Parrot_append_bytecode or something similar */
378
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
379 /*
380
381 =item C<Parrot_Int Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
382 pbc, Parrot_PMC *main_sub)>
383
384 Prepares the bytecode C<pbc> to be run and stores the entry point subroutine in
385 C<main_sub>. This function returns a true value if this call is successful and
386 false value otherwise.
387
388 =cut
389
390 */
391
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
392 PARROT_API
393 Parrot_Int
394 Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
395 ARGOUT(Parrot_PMC *main_sub))
396 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
397 ASSERT_ARGS(Parrot_api_ready_bytecode)
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
398 EMBED_API_CALLIN(interp_pmc, interp)
399 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
400
401 /* Debugging mode nonsense. */
402 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
403 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
404 interp->run_core->name);
405 }
406
407 if (!pf)
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the pac…
Whiteknight authored
408 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
409 "Could not get packfile.");
410 if (pf->cur_cs)
62b5f53 @bacek Mass replace of interp_pf with current_pf.
bacek authored
411 Parrot_pf_set_current_packfile(interp, pbc);
412
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
413 PackFile_fixup_subs(interp, PBC_MAIN, NULL);
414 *main_sub = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
415 Parrot_pcc_set_constants(interp, interp->ctx, interp->code->const_table);
416 EMBED_API_CALLOUT(interp_pmc, interp)
417 }
418
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
419
420 /*
421
422 =item C<Parrot_Int Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
423 pbc, Parrot_PMC mainargs)>
424
425 Runs the bytecode C<pbc> passing optional C<mainargs> parameters. This function
426 returns a true value if this call is successful and false value otherwise.
427
428 =cut
429
430 */
431
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults bui…
Whiteknight authored
432 PARROT_API
433 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
434 Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
435 Parrot_PMC mainargs)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
436 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
437 ASSERT_ARGS(Parrot_api_run_bytecode)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
438 EMBED_API_CALLIN(interp_pmc, interp)
98cd26c @Whiteknight don't call Parrot_pbc_load if the PBC comes straight out of IMCC. IMC…
Whiteknight authored
439 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
9f7a94c @Whiteknight make sure to set :main() args in the iglobals array. This makes ops2c…
Whiteknight authored
440
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
441 /* Debugging mode nonsense. */
442 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
443 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
444 interp->run_core->name);
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't bein…
Whiteknight authored
445 }
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also remove…
bluescreen10 authored
446
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
447 if (!pf)
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the pac…
Whiteknight authored
448 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
449 "Could not get packfile.");
2310551 @nwellnhof Fix assertion failure
nwellnhof authored
450 if (!mainargs)
451 mainargs = PMCNULL;
62b5f53 @bacek Mass replace of interp_pf with current_pf.
bacek authored
452 Parrot_pf_execute_bytecode_program(interp, pbc, mainargs);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
453 EMBED_API_CALLOUT(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
454 }
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
455
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
456 /*
457
458 =item C<Parrot_Int Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc,
459 Parrot_PMC pbc, const char * const outfile, Parrot_Int opts)>
460
461 Disassembles and prints out the C<pbc> bytecode. This function returns a true
462 value if this call is successful and false value otherwise.
463
464 =cut
465
466 */
467
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more …
Whiteknight authored
468 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
469 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
470 Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
471 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 …
Whiteknight authored
472 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
473 ASSERT_ARGS(Parrot_api_disassemble_bytecode)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
474 EMBED_API_CALLIN(interp_pmc, interp)
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
475 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
476 if (!pf)
fc0f759 @Whiteknight Add some accessors for interp->initial_pf and interp->code to the pac…
Whiteknight authored
477 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
478 "Could not get packfile.");
479 if (pf->cur_cs)
62b5f53 @bacek Mass replace of interp_pf with current_pf.
bacek authored
480 Parrot_pf_set_current_packfile(interp, pbc);
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
481 /* TODO: Break up the dependency with emebed.c */
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
482 Parrot_disassemble(interp, outfile, (Parrot_disassemble_options)opts);
483 EMBED_API_CALLOUT(interp_pmc, interp);
484 }
485
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
486 /*
487
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suit…
Whiteknight authored
488 =item C<Parrot_Int Parrot_api_serialize_bytecode_pmc(Parrot_PMC interp_pmc,
489 Parrot_PMC pbc, Parrot_String * bc)>
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
490
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suit…
Whiteknight authored
491 Serialize a packfile PMC into a sequence of bytes suitable for writing out
492 to a .pbc file
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
493
494 =cut
495
496 */
497
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function …
Whiteknight authored
498 PARROT_API
499 Parrot_Int
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suit…
Whiteknight authored
500 Parrot_api_serialize_bytecode_pmc(Parrot_PMC interp_pmc, Parrot_PMC pbc,
501 ARGOUT(Parrot_String * bc))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
502 {
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suit…
Whiteknight authored
503 ASSERT_ARGS(Parrot_api_serialize_bytecode_pmc)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
504 EMBED_API_CALLIN(interp_pmc, interp)
31792fa @Whiteknight Add a new API function to serialize a packfile PMC into a format suit…
Whiteknight authored
505 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
506 if (!pf)
507 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
508 "Could not get packfile.");
509 else {
510 const Parrot_Int size = PackFile_pack_size(interp, pf) * sizeof (opcode_t);
511 opcode_t * const packed = (opcode_t*) mem_sys_allocate(size);
512 PackFile_pack(interp, pf, packed);
513 *bc = Parrot_str_new_init(interp, (const char *)packed, size,
514 Parrot_binary_encoding_ptr, 0);
515 }
c1ab56e More fixes, almost there
Mariano Wahlmann authored
516 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
517 }
518
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
519 /*
520
2690e47 @Whiteknight small doc fix
Whiteknight authored
521 =item C<Parrot_Int Parrot_api_write_bytecode_to_file(Parrot_PMC interp_pmc,
2f0411b @Whiteknight Add a new prototype API function to write a PackFile PMC out to a .pb…
Whiteknight authored
522 Parrot_PMC pbc, Parrot_String filename)>
523
524 Write out a PackFile PMC to a .pbc file
525
526 =cut
527
528 */
529
530 PARROT_API
531 Parrot_Int
532 Parrot_api_write_bytecode_to_file(Parrot_PMC interp_pmc, Parrot_PMC pbc,
533 Parrot_String filename)
534 {
535 ASSERT_ARGS(Parrot_api_write_bytecode_to_file)
536 EMBED_API_CALLIN(interp_pmc, interp)
537 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
538 if (!pf)
539 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
540 "Could not get packfile.");
541 else {
985e82a @fperrad [build] fix C
fperrad authored
542 PIOHANDLE fp;
364ad6b @Whiteknight block GC during packfile serialization and write to file. This gets r…
Whiteknight authored
543 Parrot_block_GC_mark(interp);
985e82a @fperrad [build] fix C
fperrad authored
544 fp = PIO_OPEN(interp, filename, PIO_F_WRITE);
364ad6b @Whiteknight block GC during packfile serialization and write to file. This gets r…
Whiteknight authored
545 if (fp == PIO_INVALID_HANDLE) {
546 Parrot_unblock_GC_mark(interp);
2f0411b @Whiteknight Add a new prototype API function to write a PackFile PMC out to a .pb…
Whiteknight authored
547 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
548 "Cannot open output file %Ss", filename);
364ad6b @Whiteknight block GC during packfile serialization and write to file. This gets r…
Whiteknight authored
549 }
2f0411b @Whiteknight Add a new prototype API function to write a PackFile PMC out to a .pb…
Whiteknight authored
550 else {
551 const Parrot_Int size = PackFile_pack_size(interp, pf) * sizeof (opcode_t);
552 opcode_t * const packed = (opcode_t*)mem_sys_allocate(size);
553 PackFile_pack(interp, pf, packed);
554 PIO_WRITE(interp, fp, (char *)packed, size);
555 }
fa228c7 @Whiteknight handle -o and -r options from the frontend. delete some code in IMCC …
Whiteknight authored
556 PIO_CLOSE(interp, fp);
364ad6b @Whiteknight block GC during packfile serialization and write to file. This gets r…
Whiteknight authored
557 Parrot_unblock_GC_mark(interp);
2f0411b @Whiteknight Add a new prototype API function to write a PackFile PMC out to a .pb…
Whiteknight authored
558 }
559
560 EMBED_API_CALLOUT(interp_pmc, interp)
561 }
562
563 /*
564
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
565 =item C<Parrot_Int Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int
566 flags)>
567
568 Enables C<inter_pmc>'s warning messages the type of warning information to be
569 print out is specified by C<flags>. This function returns a true value if this
570 call is successful and false value otherwise.
571
572 =cut
573
574 */
575
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
576 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
577 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
578 Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int flags)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
579 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
580 ASSERT_ARGS(Parrot_api_set_warnings)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
581 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
582 /* Activates the given warnings. (Macro from warnings.h.) */
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
583 PARROT_WARNINGS_on(interp, flags);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
584 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
585 }
586
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
587 /*
588
589 =item C<Parrot_Int Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
590 const char *path)>
591
592 Adds C<path> to the C<inter_pmc>'s library search path list. This function
593 returns a true value if this call is successful and false value otherwise.
594
595 =cut
596
597 */
598
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
599 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
600 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
601 Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
602 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
603 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
604 ASSERT_ARGS(Parrot_api_add_library_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
605 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
606 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_LIBRARY);
229a781 @Whiteknight Add experimental ability to modify PARROT_LIB_PATH_LANG with the -L c…
Whiteknight authored
607
608 /* EXPERIMENTAL. This line has been added experimentally because it is a
609 missing feature, and it may go away at any time without warning. */
610 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_LANG);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
611 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
612 }
613
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
614 /*
615
616 =item C<Parrot_Int Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
617 const char *path)>
618
619 Adds C<path> to the C<inter_pmc>'s include search path list. This function
620 returns a true value if this call is successful and false value otherwise.
621
622 =cut
623
624 */
625
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
626 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
627 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
628 Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
629 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
630 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
631 ASSERT_ARGS(Parrot_api_add_include_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
632 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
633 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_INCLUDE);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
634 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
635 }
636
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
637 /*
638
639 =item C<Parrot_Int Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
640 const char *path)>
641
642 Adds C<path> to the C<inter_pmc>'s dynext search path list. This function
643 returns a true value if this call is successful and false value otherwise.
644
645 =cut
646
647 */
648
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
649 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
650 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
651 Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
652 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
653 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
654 ASSERT_ARGS(Parrot_api_add_dynext_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
655 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
656 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_DYNEXT);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
657 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use i…
Whiteknight authored
658 }
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
659
660 /*
661
c7def2f @jkeenan Run 'perl tools/dev/headerizer.pl src/embed/api.o'.
jkeenan authored
662 =item C<Parrot_Int Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int
663 in, Parrot_Int out, Parrot_Int err)>
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
664
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
665 Set the C<interp_pmc>'s standard file descriptors STDIN, STDOUT, STDERR. Any
666 file descriptor set to C<PIO_INVALID_HANDLE> is ignored. This function returns
667 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
668
669 =cut
670
671 */
f30aa2f @kapace Added some tests for embed api, get/set compiler and commented set_st…
kapace authored
672 /* Whiteknight told me that theres no way to test this for now, so it should be
673 commented out, for now.
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
674
675 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much close…
Whiteknight authored
676 Parrot_Int
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
677 Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int in,
678 Parrot_Int out, Parrot_Int err)
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
679 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
680 ASSERT_ARGS(Parrot_api_set_stdhandles)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
681 EMBED_API_CALLIN(interp_pmc, interp)
682 void *dummy;
683
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
684 if (PIO_INVALID_HANDLE != (PIOHANDLE)in) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
685 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
686 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
687 dummy = (void *)Parrot_io_stdhandle(interp, PIO_STDIN_FILENO, pmc);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
688 }
689
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
690 if (PIO_INVALID_HANDLE != (PIOHANDLE)out) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
691 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
692 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
693 dummy = (void *)Parrot_io_stdhandle(interp, PIO_STDOUT_FILENO, pmc);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
694 }
695
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
696 if (PIO_INVALID_HANDLE != (PIOHANDLE)err) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
697 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
698 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
699 dummy = (void *)Parrot_io_stdhandle(interp, PIO_STDERR_FILENO, pmc);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
700 }
16e368d @Whiteknight fix several build warnings in src/embed/* in gcc, g++, and icc
Whiteknight authored
701 UNUSED(dummy);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
702
703 EMBED_API_CALLOUT(interp_pmc, interp)
f30aa2f @kapace Added some tests for embed api, get/set compiler and commented set_st…
kapace authored
704 }*/
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
705
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
706 /*
707
708 =item C<Parrot_Int Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
709 Parrot_String *runtime)>
710
711 Stores in C<runtime> the C<interp_pmc>'s running path. This function returns a
712 true value if this call is successful and false value otherwise.
713
714 =cut
715
716 */
717
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
718 PARROT_API
719 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
720 Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
721 ARGOUT(Parrot_String *runtime))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
722 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
723 ASSERT_ARGS(Parrot_api_get_runtime_path)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
724 EMBED_API_CALLIN(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternat…
Whiteknight authored
725 *runtime = Parrot_get_runtime_path(interp);
726 EMBED_API_CALLOUT(interp_pmc, interp);
727 }
728
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
729 /*
730
731 =item C<Parrot_Int Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc,
732 Parrot_PMC confighash)>
733
734 Sets the C<interp_pmc>'s configuration hash passed in C<confighash>. This
735 function returns a true value if this call is successful and false value
736 otherwise.
737
738 =cut
739
740 */
741
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
742 PARROT_API
743 Parrot_Int
744 Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc, Parrot_PMC confighash)
745 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
746 ASSERT_ARGS(Parrot_api_set_configuration_hash)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
747 EMBED_API_CALLIN(interp_pmc, interp)
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
748 Parrot_set_config_hash_pmc(interp, confighash);
5c2c3d4 @Whiteknight fix library paths. The build now progresses through all the parts tha…
Whiteknight authored
749 Parrot_lib_update_paths_from_config_hash(interp);
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash…
Whiteknight authored
750 EMBED_API_CALLOUT(interp_pmc, interp);
751 }
752
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
753 /*
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
754
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
755 =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
756 lang)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
757
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
758 Loads the HLL compiler libraries for C<lang> into the C<interp_pmc>. This
759 function returns a true value if this call is successful and false value
760 otherwise.
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
761
762 =cut
763
764 */
765
766 PARROT_API
767 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
768 Parrot_api_load_language(Parrot_PMC interp_pmc, Parrot_String lang)
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
769 {
770 ASSERT_ARGS(Parrot_api_load_language)
771 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
772 Parrot_load_language(interp, lang);
773 EMBED_API_CALLOUT(interp_pmc, interp);
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
774 }
775
776 /*
777
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
778 =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
779 type, Parrot_PMC *compiler)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
780
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
781 Gets the compiler PMC and stores it in C<compiler>. This function returns a true
782 value if this call is successful and false value otherwise.
783
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
784 =cut
785
786 */
787
788 PARROT_API
789 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
790 Parrot_api_get_compiler(Parrot_PMC interp_pmc, Parrot_String type,
791 ARGOUT(Parrot_PMC *compiler))
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
792 {
793 ASSERT_ARGS(Parrot_api_get_compiler)
794 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
795 *compiler = Parrot_get_compiler(interp, type);
796 EMBED_API_CALLOUT(interp_pmc, interp);
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
797 }
798
799 /*
800
801 =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
802 type, Parrot_PMC compiler)>
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
803
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
804 Sets the C<compiler> object for the C<type> files. This function returns a true
805 value if this call is successful and false value otherwise.
806
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
807 =cut
808
809 */
810
811 PARROT_API
812 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
813 Parrot_api_set_compiler(Parrot_PMC interp_pmc, Parrot_String type,
814 Parrot_PMC compiler)
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
815 {
816 ASSERT_ARGS(Parrot_api_set_compiler)
817 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
818 Parrot_set_compiler(interp, type, compiler);
255a8d8 @Whiteknight move -G commandline argument parsing from IMCC into the frontend
Whiteknight authored
819 EMBED_API_CALLOUT(interp_pmc, interp)
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
820 }
0814f94 Merged changes with branch
Mariano Wahlmann authored
821
255a8d8 @Whiteknight move -G commandline argument parsing from IMCC into the frontend
Whiteknight authored
822 /*
823
824 =item C<Parrot_Int Parrot_api_toggle_gc(Parrot_PMC interp_pmc, Parrot_Int on)>
825
826 Turn Parrot's GC on or off.
827
828 =cut
829
830 */
831
832 PARROT_API
833 Parrot_Int
834 Parrot_api_toggle_gc(Parrot_PMC interp_pmc, Parrot_Int on)
835 {
836 ASSERT_ARGS(Parrot_api_toggle_gc)
837 EMBED_API_CALLIN(interp_pmc, interp)
838 if (on) {
839 Parrot_unblock_GC_mark(interp);
840 Parrot_unblock_GC_sweep(interp);
841 }
842 else {
843 Parrot_block_GC_mark(interp);
844 Parrot_block_GC_sweep(interp);
845 }
846 EMBED_API_CALLOUT(interp_pmc, interp)
847 }
6f90f7d @nol888 Add API functions to get a class from an array, and to instantiate a …
nol888 authored
848
c6fa8b7 @mikehh fix codetest failures - add c function docs and ASSERT_ARGS
mikehh authored
849 /*
850
851 =item C<Parrot_Int Parrot_api_reset_call_signature(Parrot_PMC interp_pmc,
852 Parrot_PMC ctx)>
853
854 Reset the call signature
855
856 =cut
857
858 */
859
f0c28dc @Whiteknight Add in an API function so that we can reset and reuse an existing Cal…
Whiteknight authored
860 PARROT_API
861 Parrot_Int
862 Parrot_api_reset_call_signature(Parrot_PMC interp_pmc, Parrot_PMC ctx)
863 {
c6fa8b7 @mikehh fix codetest failures - add c function docs and ASSERT_ARGS
mikehh authored
864 ASSERT_ARGS(Parrot_api_reset_call_signature)
f0c28dc @Whiteknight Add in an API function so that we can reset and reuse an existing Cal…
Whiteknight authored
865 EMBED_API_CALLIN(interp_pmc, interp)
866 STRING * const callcontext = Parrot_str_new(interp, "CallContext", 0);
867 if (!VTABLE_isa(interp, ctx, callcontext))
868 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
869 "Not a valid CallContext");
870 VTABLE_morph(interp, ctx, PMCNULL);
871 EMBED_API_CALLOUT(interp_pmc, interp)
872 }
873
0814f94 Merged changes with branch
Mariano Wahlmann authored
874 /*
875
027abfa @Whiteknight add two new API functions for dealing with opaque user data pointers
Whiteknight authored
876 =item C<Parrot_Int Parrot_api_wrap_pointer(Parrot_PMC interp_pmc, void *ptr,
877 Parrot_Int size, Parrot_PMC *pmc)>
878
879 Wrap a user data pointer into a Ptr PMC for passing into Parrot. This PMC
880 is designed such that Parrot will treat the pointer as being opaque and will
881 not attempt to dereference, examine, or manipulate it at all.
882
883 Optionally a C<size> parameter can be passed. If C<size> is greater than zero,
884 the size information will be included with the pointer for later use. If
885 C<size> is less than or equal to zero, it will be ignored and will not be
886 included in the PMC object.
887
54d5026 @plobsing [codetest] correct format of C function doc =item
plobsing authored
888 =item C<Parrot_Int Parrot_api_unwrap_pointer(Parrot_PMC interp_pmc, Parrot_PMC
889 pmc, void ** ptr, Parrot_Int * size)>
027abfa @Whiteknight add two new API functions for dealing with opaque user data pointers
Whiteknight authored
890
891 Return a pointer from a PMC. This is typically used in conjunction with
892 C<Parrot_api_wrap_pointer> to return the original wrapped pointer value from
893 the PMC. Used with other PMC types besides C<Ptr> or C<PtrBuf> will have
894 undefined results, and should not be used or relied upon.
895
896 If the pointer was stored with size information, C<size> will contain that
897 size value. Otherwise, C<size> will be -1.
898
899 Notice that this function does not destroy or alter the data PMC.
900
901 =cut
902
903 */
904
905 PARROT_API
906 Parrot_Int
907 Parrot_api_wrap_pointer(Parrot_PMC interp_pmc, ARGIN_NULLOK(void *ptr),
908 Parrot_Int size, ARGOUT(Parrot_PMC *pmc))
909 {
910 ASSERT_ARGS(Parrot_api_wrap_pointer)
911 EMBED_API_CALLIN(interp_pmc, interp)
912 PMC * ptr_pmc = NULL;
913 if (size > 0) {
914 ptr_pmc = Parrot_pmc_new(interp, enum_class_PtrBuf);
b65a8ba @bacek Fix braino in api_wrap/unwrap_pointer.
bacek authored
915 VTABLE_set_integer_native(interp, ptr_pmc, size);
edc686b @plobsing cuddled else
plobsing authored
916 }
917 else
027abfa @Whiteknight add two new API functions for dealing with opaque user data pointers
Whiteknight authored
918 ptr_pmc = Parrot_pmc_new(interp, enum_class_Ptr);
b65a8ba @bacek Fix braino in api_wrap/unwrap_pointer.
bacek authored
919 VTABLE_set_pointer(interp, ptr_pmc, ptr);
027abfa @Whiteknight add two new API functions for dealing with opaque user data pointers
Whiteknight authored
920 *pmc = ptr_pmc;
921 EMBED_API_CALLOUT(interp_pmc, interp)
922 }
923
924 PARROT_API
925 Parrot_Int
926 Parrot_api_unwrap_pointer(Parrot_PMC interp_pmc, Parrot_PMC pmc,
927 ARGOUT(void ** ptr), ARGOUT(Parrot_Int * size))
928 {
929 ASSERT_ARGS(Parrot_api_unwrap_pointer)
930 EMBED_API_CALLIN(interp_pmc, interp)
931 *ptr = VTABLE_get_pointer(interp, pmc);
932 if (pmc->vtable->base_type == enum_class_PtrBuf)
933 *size = VTABLE_get_integer(interp, pmc);
934 else
935 *size = -1;
936 EMBED_API_CALLOUT(interp_pmc, interp);
937 }
938
939 /*
940
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
941 =back
942
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
943 =cut
0814f94 Merged changes with branch
Mariano Wahlmann authored
944
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
945 */
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
946
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
947 /*
948 * Local variables:
949 * c-file-style: "parrot"
950 * End:
951 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
952 */
0814f94 Merged changes with branch
Mariano Wahlmann authored
953
Something went wrong with that request. Please try again.