Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 774 lines (568 sloc) 18.389 kb
3e1f322 Inline docs update
Michael Scott authored
1 /*
10610ab @mikehh remove another compiler warning ["/*" within comment]
mikehh authored
2 Copyright (C) 2001-2011, Parrot Foundation.
3e1f322 Inline docs update
Michael Scott authored
3
4 =head1 NAME
5
6 src/extend.c - Parrot extension interface
7
8 =head1 DESCRIPTION
99b337c start of actual extension routines and docs
Dan Sugalski authored
9
37fe0b3 @Whiteknight update some docs in src/extend.c
Whiteknight authored
10 These are utility functions which extension code may use, but which are
11 typically not used by Parrot internally. These functions are for EXTENDING
12 use only, not for EMBEDDING. Embedding should be handed through the embedding
10610ab @mikehh remove another compiler warning ["/*" within comment]
mikehh authored
13 API with c files in directory src/embed/.
3e1f322 Inline docs update
Michael Scott authored
14
37fe0b3 @Whiteknight update some docs in src/extend.c
Whiteknight authored
15 Extending situations are things like NCI function libraries, dyn-pmc and
16 dyn-op libraries which are loaded into Parrot and called from Parrot (as
17 opposed to embedding, where an external program calls into Parrot). These
18 functions assume the existance of an interpreter, memory management through
19 GC and stackwalking, and the presence of an exception-handling infrastructure.
3e1f322 Inline docs update
Michael Scott authored
20
21 =head2 Functions
22
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
23 =over 4
24
25 =cut
26
3e1f322 Inline docs update
Michael Scott authored
27 */
99b337c start of actual extension routines and docs
Dan Sugalski authored
28
37fe0b3 @Whiteknight update some docs in src/extend.c
Whiteknight authored
29 /* DO NOT CALL THESE FUNCTIONS WITHOUT LIBPARROT, OR FROM OUTSIDE LIBPARROT!!
30
31 These functions presume that GC is available and is properly configured
32 (setting the stacktop for stack walking, etc) and that there is an active
33 exception-handling infrastructure. Calling these functions when there is
34 no exception handlers available, including a default top-level handler, or
35 when the GC is not properly initialized can lead to big problems. Be sure
36 to understand the difference between an embedding and an extending
37 situation. Using the wrong kind of function in the wrong situation, or
38 combining some functions from the Embedding API with functions from the
39 extending API is a recipe for disaster. We (Parrot developers) will not be
40 held responsible if you insist on making these kinds of mistakes.
41
42 If there are utility functions that *YOU* as a user of parrot need from
43 either the extending or the embedding API, please request them or attempt
44 to write them yourself. Blindly mixing things from the wrong API, or
45 calling a function in the wrong context will cause you problems.
46
47 You have been warned.
48
49 Notice that the "Extending API" is a loosely-defined concept which is
50 currently understood to mean the sum of public APIs for various subsystems.
51 This definition may change in the future, but this is what we mean by the
52 phrase right now.
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
53
54 The problem comes in if these routines are called from *outside*
55 an interpreter. This happens when an embedding application calls
56 them to do stuff with PMCs, STRINGS, interpreter contents, and
57 suchlike things. This is perfectly legal -- in fact it's what
58 we've documented should be done -- but the problem is that the
59 stack base pointer will be NULL. This is Very Bad.
60
61 To deal with this there are two macros that are defined to handle
62 the problem.
63
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
64 PARROT_CALLIN_START(interp) will figure out if the stack
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
65 anchor needs setting and, if so, will set it. It must *always*
66 come immediately after the last variable declared in the block
67 making the calls into the interpreter, as it declares a variable
68 and has some code.
69
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
70 PARROT_CALLIN_END(interp) will put the stack anchor back to
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
71 the way it was, and should always be the last statement before a
72 return. (If you have multiple returns have it in multiple times)
73
74 Not doing this is a good way to introduce bizarre heisenbugs, so
75 just do it. This is the only place they ought to have to be put
76 in, and most of the functions are already written, so it's not
77 like it's an onerous requirement.
78
79 */
80
99b337c start of actual extension routines and docs
Dan Sugalski authored
81 #include "parrot/parrot.h"
82 #include "parrot/extend.h"
63889c2 @cotto [PMC] replace PMC_struct_val and derivatives with ATTR accessors for …
cotto authored
83 #include "pmc/pmc_sub.h"
68bf472 @bacek Merge context_unify3_simple branch back to trunk.
bacek authored
84 #include "pmc/pmc_callcontext.h"
99b337c start of actual extension routines and docs
Dan Sugalski authored
85
490c1c6 @petdance Changed HEADERIZER TARGET to HEADERIZER HFILE
petdance authored
86 /* HEADERIZER HFILE: include/parrot/extend.h */
df5e1a1 @petdance lie to the headerizer
petdance authored
87
3e1f322 Inline docs update
Michael Scott authored
88 /*
89
4dc854f @coke [cage] run 'make headerizer'
coke authored
90 =item C<int Parrot_vfprintf(PARROT_INTERP, Parrot_PMC pio, const char *s,
91 va_list args)>
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
92
93 Writes a C string format with a varargs list to a PIO.
94
4dc854f @coke [cage] run 'make headerizer'
coke authored
95 =item C<int Parrot_fprintf(PARROT_INTERP, Parrot_PMC pio, const char *s, ...)>
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
96
97 Writes a C string format with varargs to a PIO.
98
4dc854f @coke [cage] run 'make headerizer'
coke authored
99 =item C<int Parrot_printf(NULLOK_INTERP, const char *s, ...)>
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
100
101 Writes a C string format with varargs to C<stdout>.
102
4dc854f @coke [cage] run 'make headerizer'
coke authored
103 =item C<int Parrot_eprintf(NULLOK_INTERP, const char *s, ...)>
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
104
105 Writes a C string format with varargs to C<stderr>.
106
fb2ca1e @NotFound fix lack of cut in a pod comment
NotFound authored
107 =cut
108
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
109 */
110
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
111 PARROT_EXPORT
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
112 int
113 Parrot_vfprintf(PARROT_INTERP, ARGIN(Parrot_PMC pio),
114 ARGIN(const char *s), va_list args)
115 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
116 ASSERT_ARGS(Parrot_vfprintf)
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
117 STRING * str;
118 INTVAL retval;
119
120 PARROT_CALLIN_START(interp);
121 str = Parrot_vsprintf_c(interp, s, args);
9f9cea2 @allisonrandal [pdd22io] Merging the pdd22io_part2 branch into trunk for r32922 to r…
allisonrandal authored
122 retval = Parrot_io_putps(interp, pio, str);
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
123 PARROT_CALLIN_END(interp);
124
125 return retval;
126 }
127
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
128 PARROT_EXPORT
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
129 int
130 Parrot_fprintf(PARROT_INTERP, ARGIN(Parrot_PMC pio),
131 ARGIN(const char *s), ...)
132 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
133 ASSERT_ARGS(Parrot_fprintf)
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
134 va_list args;
135 INTVAL retval;
136
137 va_start(args, s);
138 retval = Parrot_vfprintf(interp, pio, s, args);
139 va_end(args);
140
141 return retval;
142 }
143
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
144 PARROT_EXPORT
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
145 int
146 Parrot_printf(NULLOK_INTERP, ARGIN(const char *s), ...)
147 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
148 ASSERT_ARGS(Parrot_printf)
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
149 va_list args;
150 INTVAL retval;
151 va_start(args, s);
152
153 if (interp) {
9f9cea2 @allisonrandal [pdd22io] Merging the pdd22io_part2 branch into trunk for r32922 to r…
allisonrandal authored
154 retval = Parrot_vfprintf(interp, Parrot_io_STDOUT(interp), s, args);
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
155 }
156 else {
157 /* Be nice about this...
9f9cea2 @allisonrandal [pdd22io] Merging the pdd22io_part2 branch into trunk for r32922 to r…
allisonrandal authored
158 ** XXX BD Should this use the default Parrot_io_STDOUT or something?
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
159 */
160 retval = vfprintf(stdout, s, args);
161 }
162 va_end(args);
163
164 return retval;
165 }
166
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
167 PARROT_EXPORT
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
168 int
169 Parrot_eprintf(NULLOK_INTERP, ARGIN(const char *s), ...)
170 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
171 ASSERT_ARGS(Parrot_eprintf)
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
172 va_list args;
173 INTVAL retval;
174
175 va_start(args, s);
176
177 if (interp) {
9f9cea2 @allisonrandal [pdd22io] Merging the pdd22io_part2 branch into trunk for r32922 to r…
allisonrandal authored
178 retval = Parrot_vfprintf(interp, Parrot_io_STDERR(interp), s, args);
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
179 }
180 else {
181 /* Be nice about this...
9f9cea2 @allisonrandal [pdd22io] Merging the pdd22io_part2 branch into trunk for r32922 to r…
allisonrandal authored
182 ** XXX BD Should this use the default Parrot_io_STDOUT or something?
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
183 */
184 retval=vfprintf(stderr, s, args);
185 }
186
187 va_end(args);
188
189 return retval;
190 }
191
192 /*
193
4dc854f @coke [cage] run 'make headerizer'
coke authored
194 =item C<Parrot_PMC Parrot_get_root_namespace(PARROT_INTERP)>
4429375 @NotFound [core] add functions Parrot_get_root_namespace and Parrot_PMC_get_pmc…
NotFound authored
195
196 Return the root namespace
197
198 =cut
199
200 */
201
202 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
203 PARROT_PURE_FUNCTION
4429375 @NotFound [core] add functions Parrot_get_root_namespace and Parrot_PMC_get_pmc…
NotFound authored
204 Parrot_PMC
205 Parrot_get_root_namespace(PARROT_INTERP)
206 {
207 ASSERT_ARGS(Parrot_get_root_namespace)
208 return interp->root_namespace;
209 }
210
211 /*
212
4dc854f @coke [cage] run 'make headerizer'
coke authored
213 =item C<Parrot_PMC Parrot_PMC_new(PARROT_INTERP, Parrot_Int type)>
3e1f322 Inline docs update
Michael Scott authored
214
215 Create and return a new PMC.
216
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
217 =cut
218
3e1f322 Inline docs update
Michael Scott authored
219 */
220
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
221 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
222 Parrot_PMC
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
223 Parrot_PMC_new(PARROT_INTERP, Parrot_Int type)
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
224 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
225 ASSERT_ARGS(Parrot_PMC_new)
fa999b0 First chunk of extension code done
Dan Sugalski authored
226 Parrot_PMC newpmc;
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
227 PARROT_CALLIN_START(interp);
083213a @Whiteknight start rename of pmc_new to Parrot_pmc_new
Whiteknight authored
228 newpmc = Parrot_pmc_new_noinit(interp, type);
fa999b0 First chunk of extension code done
Dan Sugalski authored
229 VTABLE_init(interp, newpmc);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
230 PARROT_CALLIN_END(interp);
fa999b0 First chunk of extension code done
Dan Sugalski authored
231 return newpmc;
232 }
233
3e1f322 Inline docs update
Michael Scott authored
234 /*
235
4dc854f @coke [cage] run 'make headerizer'
coke authored
236 =item C<Parrot_Int Parrot_PMC_typenum(PARROT_INTERP, const char *_class)>
3e1f322 Inline docs update
Michael Scott authored
237
238 Returns the internal identifier that represents the named class.
239
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
240 =cut
241
3e1f322 Inline docs update
Michael Scott authored
242 */
243
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
244 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
245 Parrot_Int
802efc1 @petdance If something is NULLOK(const...) it is by definition ARGIN_NULLOK(con…
petdance authored
246 Parrot_PMC_typenum(PARROT_INTERP, ARGIN_NULLOK(const char *_class))
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
247 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
248 ASSERT_ARGS(Parrot_PMC_typenum)
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
249 Parrot_Int retval;
250 PARROT_CALLIN_START(interp);
847522f @Whiteknight rename the rest of the functions in pmc.c, start updating the rest of…
Whiteknight authored
251 retval = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, _class, 0));
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
252 PARROT_CALLIN_END(interp);
253 return retval;
fa999b0 First chunk of extension code done
Dan Sugalski authored
254 }
255
3e1f322 Inline docs update
Michael Scott authored
256 /*
257
4dc854f @coke [cage] run 'make headerizer'
coke authored
258 =item C<Parrot_PMC Parrot_PMC_null(void)>
3e1f322 Inline docs update
Michael Scott authored
259
260 Returns the special C<NULL> PMC.
261
06fb631 @paultcochrane [core] Added function documentation.
paultcochrane authored
262 =cut
263
3e1f322 Inline docs update
Michael Scott authored
264 */
265
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
266 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
267 PARROT_PURE_FUNCTION
11323f5 @petdance fixing null/not-null annotations
petdance authored
268 PARROT_CAN_RETURN_NULL
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
269 Parrot_PMC
270 Parrot_PMC_null(void)
271 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
272 ASSERT_ARGS(Parrot_PMC_null)
8deb08e Expose PMCNULL to extension API.
Melvin Smith authored
273 return PMCNULL;
274 }
275
3e1f322 Inline docs update
Michael Scott authored
276 /*
277
4dc854f @coke [cage] run 'make headerizer'
coke authored
278 =item C<void Parrot_free_cstring(char *string)>
3e1f322 Inline docs update
Michael Scott authored
279
280 Deallocate a C string that the interpreter has handed to you.
281
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
282 =cut
283
3e1f322 Inline docs update
Michael Scott authored
284 */
8deb08e Expose PMCNULL to extension API.
Melvin Smith authored
285
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
286 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
287 void
172bc90 @petdance updating annotations
petdance authored
288 Parrot_free_cstring(ARGFREE(char *string))
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
289 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
290 ASSERT_ARGS(Parrot_free_cstring)
b6bc0c3 @allisonrandal [pdd28str] Merging the pdd27mmd branch into trunk for r36123 to r36318.
allisonrandal authored
291 Parrot_str_free_cstring(string);
99b337c start of actual extension routines and docs
Dan Sugalski authored
292 }
293
3e1f322 Inline docs update
Michael Scott authored
294 /*
295
6c743be @allisonrandal [pcc] Add a generic extend/embed interface function for invoking Parrot
allisonrandal authored
296 =item C<void Parrot_ext_call(PARROT_INTERP, Parrot_PMC sub_pmc, const char
297 *signature, ...)>
298
299 Call a Parrot subroutine or method with the given function signature. The
300 function signature holds one type character for each argument or return, these
301 are:
302
303 I ... Parrot_Int
304 N ... Parrot_Float
305 S ... Parrot_String
306 P ... Parrot_PMC
307
308 Returns come after the arguments, separated by an arrow, so "PN->S" takes a PMC
309 and a float as arguments and returns a string.
310
311 Pass the variables for the arguments and returns in the same order as the
312 signature, with returns as reference to the variable (so it can be modified).
313
314 Parrot_ext_call(interp, sub, "P->S", pmc_arg, &string_result);
315
316 To call a method, pass the object for the method as the first argument, and
317 mark it in the signature as "Pi" ("i" stands for "invocant").
318
319 Parrot_ext_call(interp, sub, "PiP->S", object_arg, pmc_arg, &string_result);
320
321 =cut
322
323 */
324
325 PARROT_EXPORT
326 void
327 Parrot_ext_call(PARROT_INTERP, ARGIN(Parrot_PMC sub_pmc),
328 ARGIN(const char *signature), ...)
329 {
330 ASSERT_ARGS(Parrot_ext_call)
331 va_list args;
363ca41 @chromatic Merged pcc_hackathon_6Mar10 into trunk. Because this changed op numb…
chromatic authored
332 PMC *call_obj;
f3faadb @bacek Fix build with g++
bacek authored
333 const char *arg_sig, *ret_sig;
c9f655c @chromatic [src] Fixed yet another Parrot_pcc_split_signature_string() memory le…
chromatic authored
334
f084166 @petdance Removed an unused argument. Fixed consting.
petdance authored
335 PMC * const old_call_obj = Parrot_pcc_get_signature(interp,
c9f655c @chromatic [src] Fixed yet another Parrot_pcc_split_signature_string() memory le…
chromatic authored
336 CURRENT_CONTEXT(interp));
f084166 @petdance Removed an unused argument. Fixed consting.
petdance authored
337 Parrot_pcc_split_signature_string(signature, &arg_sig, &ret_sig);
6c743be @allisonrandal [pcc] Add a generic extend/embed interface function for invoking Parrot
allisonrandal authored
338
339 va_start(args, signature);
c9f655c @chromatic [src] Fixed yet another Parrot_pcc_split_signature_string() memory le…
chromatic authored
340 call_obj = Parrot_pcc_build_call_from_varargs(interp, PMCNULL,
341 arg_sig, &args);
6c743be @allisonrandal [pcc] Add a generic extend/embed interface function for invoking Parrot
allisonrandal authored
342
363ca41 @chromatic Merged pcc_hackathon_6Mar10 into trunk. Because this changed op numb…
chromatic authored
343 Parrot_pcc_invoke_from_sig_object(interp, sub_pmc, call_obj);
344 call_obj = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
345 Parrot_pcc_fill_params_from_varargs(interp, call_obj, ret_sig, &args,
346 PARROT_ERRORS_RESULT_COUNT_FLAG);
347 va_end(args);
112c28e @bacek Restore old CallContext in Parrot_ext_call. Spotted by fperrad++
bacek authored
348 Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_call_obj);
6c743be @allisonrandal [pcc] Add a generic extend/embed interface function for invoking Parrot
allisonrandal authored
349 }
350
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
351 /*
352
353 =item C<void Parrot_ext_try(PARROT_INTERP, void (*cfunction(Parrot_Interp, void
354 *)), void (*chandler(Parrot_Interp, PMC *, void *)), void *data)>
355
356 Executes the cfunction argument wrapped in a exception handler.
357 If the function throws, the provided handler function is invoked
358
359 =cut
360
361 */
362
363 PARROT_EXPORT
364 void
365 Parrot_ext_try(PARROT_INTERP,
366 ARGIN_NULLOK(void (*cfunction)(Parrot_Interp, void *)),
367 ARGIN_NULLOK(void (*chandler)(Parrot_Interp, PMC *, void *)),
368 ARGIN_NULLOK(void *data))
369 {
370 ASSERT_ARGS(Parrot_ext_try)
371 if (cfunction) {
372 Parrot_runloop jmp;
8bf9b75 @NotFound restore initial context in Parrot_ext_try
NotFound authored
373 Parrot_Context *initialctx, *curctx;
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
374 PARROT_CALLIN_START(interp);
8bf9b75 @NotFound restore initial context in Parrot_ext_try
NotFound authored
375 initialctx = CONTEXT(interp);
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
376 switch (setjmp(jmp.resume)) {
377 case 0: /* try */
378 Parrot_ex_add_c_handler(interp, &jmp);
379 (*cfunction)(interp, data);
8bf9b75 @NotFound restore initial context in Parrot_ext_try
NotFound authored
380 curctx = CONTEXT(interp);
381 if (curctx != initialctx) {
382 Parrot_warn(interp, PARROT_WARNINGS_NONE_FLAG,
383 "popping context in Parrot_ext_try");
384 do {
385 if (curctx == NULL)
386 do_panic(interp,
387 "cannot restore context", __FILE__, __LINE__);
388 } while ((curctx = CONTEXT(interp)) != initialctx);
389 }
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
390 Parrot_cx_delete_handler_local(interp, STRINGNULL);
391 break;
392 default: /* catch */
393 {
394 PMC *exception = jmp.exception;
b03561f @NotFound initialize curctx in the catch part of Parrot_ext_try
NotFound authored
395 curctx = CONTEXT(interp);
8bf9b75 @NotFound restore initial context in Parrot_ext_try
NotFound authored
396 if (curctx != initialctx) {
397 Parrot_warn(interp, PARROT_WARNINGS_NONE_FLAG,
398 "popping context in Parrot_ext_try");
399 do {
400 if (curctx == NULL)
401 do_panic(interp,
402 "cannot restore context", __FILE__, __LINE__);
403 } while ((curctx = CONTEXT(interp)) != initialctx);
404 }
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
405 Parrot_cx_delete_handler_local(interp, STRINGNULL);
406 if (chandler)
407 (*chandler)(interp, exception, data);
408 }
409 }
410 PARROT_CALLIN_END(interp);
411 }
412 }
c9f655c @chromatic [src] Fixed yet another Parrot_pcc_split_signature_string() memory le…
chromatic authored
413
6c743be @allisonrandal [pcc] Add a generic extend/embed interface function for invoking Parrot
allisonrandal authored
414 /*
415
4dc854f @coke [cage] run 'make headerizer'
coke authored
416 =item C<Parrot_Int Parrot_get_intreg(PARROT_INTERP, Parrot_Int regnum)>
3e1f322 Inline docs update
Michael Scott authored
417
418 Return the value of an integer register.
419
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
420 =cut
421
3e1f322 Inline docs update
Michael Scott authored
422 */
3b31e02 More extension stuff at least partially stubbed out
Dan Sugalski authored
423
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
424 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
425 PARROT_PURE_FUNCTION
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
426 Parrot_Int
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
427 Parrot_get_intreg(PARROT_INTERP, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
428 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
429 ASSERT_ARGS(Parrot_get_intreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
430 return REG_INT(interp, regnum);
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
431 }
432
3e1f322 Inline docs update
Michael Scott authored
433 /*
434
4dc854f @coke [cage] run 'make headerizer'
coke authored
435 =item C<Parrot_Float Parrot_get_numreg(PARROT_INTERP, Parrot_Int regnum)>
3e1f322 Inline docs update
Michael Scott authored
436
437 Return the value of a numeric register.
438
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
439 =cut
440
3e1f322 Inline docs update
Michael Scott authored
441 */
442
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
443 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
444 PARROT_PURE_FUNCTION
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
445 Parrot_Float
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
446 Parrot_get_numreg(PARROT_INTERP, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
447 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
448 ASSERT_ARGS(Parrot_get_numreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
449 return REG_NUM(interp, regnum);
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
450 }
451
3e1f322 Inline docs update
Michael Scott authored
452 /*
453
4dc854f @coke [cage] run 'make headerizer'
coke authored
454 =item C<Parrot_String Parrot_get_strreg(PARROT_INTERP, Parrot_Int regnum)>
3e1f322 Inline docs update
Michael Scott authored
455
456 Return the value of a string register.
457
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
458 =cut
459
3e1f322 Inline docs update
Michael Scott authored
460 */
461
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
462 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
463 PARROT_PURE_FUNCTION
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
464 Parrot_String
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
465 Parrot_get_strreg(PARROT_INTERP, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
466 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
467 ASSERT_ARGS(Parrot_get_strreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
468 return REG_STR(interp, regnum);
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
469 }
470
3e1f322 Inline docs update
Michael Scott authored
471 /*
472
4dc854f @coke [cage] run 'make headerizer'
coke authored
473 =item C<Parrot_PMC Parrot_get_pmcreg(PARROT_INTERP, Parrot_Int regnum)>
3e1f322 Inline docs update
Michael Scott authored
474
475 Return the value of a PMC register.
476
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
477 =cut
478
3e1f322 Inline docs update
Michael Scott authored
479 */
480
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
481 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
482 PARROT_PURE_FUNCTION
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
483 Parrot_PMC
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
484 Parrot_get_pmcreg(PARROT_INTERP, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
485 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
486 ASSERT_ARGS(Parrot_get_pmcreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
487 return REG_PMC(interp, regnum);
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
488 }
489
3e1f322 Inline docs update
Michael Scott authored
490 /*
491
4dc854f @coke [cage] run 'make headerizer'
coke authored
492 =item C<void Parrot_set_intreg(PARROT_INTERP, Parrot_Int regnum, Parrot_Int
493 value)>
3e1f322 Inline docs update
Michael Scott authored
494
495 Set the value of an I register.
496
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
497 =cut
498
3e1f322 Inline docs update
Michael Scott authored
499 */
500
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
501 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
502 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
503 Parrot_set_intreg(PARROT_INTERP, Parrot_Int regnum,
d067bc6 @ambs 80's cuts.
ambs authored
504 Parrot_Int value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
505 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
506 ASSERT_ARGS(Parrot_set_intreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
507 REG_INT(interp, regnum) = value;
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
508 }
509
3e1f322 Inline docs update
Michael Scott authored
510 /*
511
4dc854f @coke [cage] run 'make headerizer'
coke authored
512 =item C<void Parrot_set_numreg(PARROT_INTERP, Parrot_Int regnum, Parrot_Float
513 value)>
3e1f322 Inline docs update
Michael Scott authored
514
515 Set the value of an N register.
516
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
517 =cut
518
3e1f322 Inline docs update
Michael Scott authored
519 */
520
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
521 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
522 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
523 Parrot_set_numreg(PARROT_INTERP, Parrot_Int regnum,
d067bc6 @ambs 80's cuts.
ambs authored
524 Parrot_Float value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
525 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
526 ASSERT_ARGS(Parrot_set_numreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
527 REG_NUM(interp, regnum) = value;
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
528 }
529
3e1f322 Inline docs update
Michael Scott authored
530 /*
531
4dc854f @coke [cage] run 'make headerizer'
coke authored
532 =item C<void Parrot_set_strreg(PARROT_INTERP, Parrot_Int regnum, Parrot_String
533 value)>
3e1f322 Inline docs update
Michael Scott authored
534
535 Set the value of an S register.
536
bc4de54 @moritz add '=cut' lines to some POD documents. Closes trac #19, jimmy++
moritz authored
537 =cut
538
3e1f322 Inline docs update
Michael Scott authored
539 */
540
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
541 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
542 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
543 Parrot_set_strreg(PARROT_INTERP, Parrot_Int regnum,
ef4c70a @chromatic Sanitize external interface, mostly by changing Parrot_STRING to Parr…
chromatic authored
544 Parrot_String value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
545 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
546 ASSERT_ARGS(Parrot_set_strreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
547 REG_STR(interp, regnum) = value;
5f1d8d9 @bacek Add write barrier to Parrot_set_strreg
bacek authored
548 PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp));
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
549 }
550
3e1f322 Inline docs update
Michael Scott authored
551 /*
552
4dc854f @coke [cage] run 'make headerizer'
coke authored
553 =item C<void Parrot_set_pmcreg(PARROT_INTERP, Parrot_Int regnum, Parrot_PMC
554 value)>
3e1f322 Inline docs update
Michael Scott authored
555
556 Set the value of a P register.
557
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
558 =cut
559
3e1f322 Inline docs update
Michael Scott authored
560 */
561
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
562 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
563 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
564 Parrot_set_pmcreg(PARROT_INTERP, Parrot_Int regnum,
d067bc6 @ambs 80's cuts.
ambs authored
565 Parrot_PMC value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
566 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
567 ASSERT_ARGS(Parrot_set_pmcreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
568 REG_PMC(interp, regnum) = value;
2f168ec @bacek Add write barrier to Parrot_set_pmcreg.
bacek authored
569 PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp));
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
570 }
571
000d780 Add in some string construction functions
Dan Sugalski authored
572 /*=for api extend Parrot_new_string
573 *
574 */
3e1f322 Inline docs update
Michael Scott authored
575 /*
576
4dc854f @coke [cage] run 'make headerizer'
coke authored
577 =item C<Parrot_String Parrot_new_string(PARROT_INTERP, const char *buffer,
578 Parrot_UInt length, const char * const encoding_name, Parrot_UInt flags)>
3e1f322 Inline docs update
Michael Scott authored
579
3a348a0 anchor overflow array immediately
Leopold Toetsch authored
580 Create a new Parrot string from a passed-in buffer. Pass in a 0 for
e89e713 Here is my (large-ish) patch which integrates ICU into the core of
Dan Sugalski authored
581 flags for right now.
3e1f322 Inline docs update
Michael Scott authored
582
583 A copy of the buffer is made.
584
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
585 =cut
586
3e1f322 Inline docs update
Michael Scott authored
587 */
588
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
589 PARROT_EXPORT
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
590 PARROT_WARN_UNUSED_RESULT
591 PARROT_CANNOT_RETURN_NULL
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
592 Parrot_String
258de48 @chromatic [src] Cleaned up some conversion and signedness warnings.
chromatic authored
593 Parrot_new_string(PARROT_INTERP, ARGIN_NULLOK(const char *buffer),
594 Parrot_UInt length, ARGIN_NULLOK(const char * const encoding_name),
595 Parrot_UInt flags)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
596 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
597 ASSERT_ARGS(Parrot_new_string)
ef4c70a @chromatic Sanitize external interface, mostly by changing Parrot_STRING to Parr…
chromatic authored
598 Parrot_String retval;
456db43 @nwellnhof [str] Prepare deprecation of string_* functions
nwellnhof authored
599 const STR_VTABLE *encoding;
600
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
601 PARROT_CALLIN_START(interp);
456db43 @nwellnhof [str] Prepare deprecation of string_* functions
nwellnhof authored
602
603 if (encoding_name) {
604 encoding = Parrot_find_encoding(interp, encoding_name);
605 if (!encoding)
606 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
607 "Can't make '%s' encoding strings", encoding_name);
608 }
609 else
610 encoding = Parrot_default_encoding_ptr;
611
612 retval = Parrot_str_new_init(interp, buffer, length, encoding, flags);
613
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
614 PARROT_CALLIN_END(interp);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
615 return retval;
000d780 Add in some string construction functions
Dan Sugalski authored
616 }
617
3e1f322 Inline docs update
Michael Scott authored
618 /*
619
4dc854f @coke [cage] run 'make headerizer'
coke authored
620 =item C<void Parrot_register_pmc(PARROT_INTERP, Parrot_PMC pmc)>
3e1f322 Inline docs update
Michael Scott authored
621
e1f3d50 @cotto [gc] replace/remove "DOD" in comments in most files in src/
cotto authored
622 Add a reference of the PMC to the interpreter's GC registry. This prevents PMCs
623 only known to extension from getting destroyed during GC runs.
3e1f322 Inline docs update
Michael Scott authored
624
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
625 =cut
626
3e1f322 Inline docs update
Michael Scott authored
627 */
9b7b3de register ops
Leopold Toetsch authored
628
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
629 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
630 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
631 Parrot_register_pmc(PARROT_INTERP, Parrot_PMC pmc)
9b7b3de register ops
Leopold Toetsch authored
632 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
633 ASSERT_ARGS(Parrot_register_pmc)
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
634 PARROT_CALLIN_START(interp);
847522f @Whiteknight rename the rest of the functions in pmc.c, start updating the rest of…
Whiteknight authored
635 Parrot_pmc_gc_register(interp, pmc);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
636 PARROT_CALLIN_END(interp);
9b7b3de register ops
Leopold Toetsch authored
637 }
638
3e1f322 Inline docs update
Michael Scott authored
639 /*
640
4dc854f @coke [cage] run 'make headerizer'
coke authored
641 =item C<void Parrot_unregister_pmc(PARROT_INTERP, Parrot_PMC pmc)>
3e1f322 Inline docs update
Michael Scott authored
642
e1f3d50 @cotto [gc] replace/remove "DOD" in comments in most files in src/
cotto authored
643 Remove a reference of the PMC from the interpreter's GC registry. If the
644 reference count reaches zero, the PMC will be destroyed during the next GC run.
3e1f322 Inline docs update
Michael Scott authored
645
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
646 =cut
647
3e1f322 Inline docs update
Michael Scott authored
648 */
9b7b3de register ops
Leopold Toetsch authored
649
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
650 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
651 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
652 Parrot_unregister_pmc(PARROT_INTERP, Parrot_PMC pmc)
9b7b3de register ops
Leopold Toetsch authored
653 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
654 ASSERT_ARGS(Parrot_unregister_pmc)
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
655 PARROT_CALLIN_START(interp);
847522f @Whiteknight rename the rest of the functions in pmc.c, start updating the rest of…
Whiteknight authored
656 Parrot_pmc_gc_unregister(interp, pmc);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
657 PARROT_CALLIN_END(interp);
9b7b3de register ops
Leopold Toetsch authored
658 }
659
06fb631 @paultcochrane [core] Added function documentation.
paultcochrane authored
660 /*
661
859b8a9 @cotto [extend] add functions for string registering and unregistering for e…
cotto authored
662 =item C<void Parrot_register_string(PARROT_INTERP, Parrot_String s)>
663
664 Add a reference of the string to the interpreter's GC registry. This prevents
665 strings only known to extension from getting destroyed during GC runs.
666
667 =cut
668
669 */
670
671 PARROT_EXPORT
672 void
673 Parrot_register_string(PARROT_INTERP, Parrot_String s)
674 {
675 ASSERT_ARGS(Parrot_register_string)
676 PARROT_CALLIN_START(interp);
677 Parrot_str_gc_register(interp, s);
678 PARROT_CALLIN_END(interp);
679 }
680
681 /*
682
683 =item C<void Parrot_unregister_string(PARROT_INTERP, Parrot_String s)>
684
685 Remove a reference of the string from the interpreter's GC registry. If the
686 reference count reaches zero, the string will be destroyed during the next GC
687 run.
688
689 =cut
690
691 */
692
693 PARROT_EXPORT
694 void
695 Parrot_unregister_string(PARROT_INTERP, Parrot_String s)
696 {
697 ASSERT_ARGS(Parrot_unregister_string)
698 PARROT_CALLIN_START(interp);
699 Parrot_str_gc_unregister(interp, s);
700 PARROT_CALLIN_END(interp);
701 }
702
703 /*
704
4dc854f @coke [cage] run 'make headerizer'
coke authored
705 =item C<Parrot_PMC Parrot_sub_new_from_c_func(PARROT_INTERP, void (*func(void)),
706 const char * signature)>
50f5936 @NotFound [core] add Parrot_sub_new_from_c_func to extend.h
NotFound authored
707
6d4f4cf @NotFound [core] add Parrot_PMC_push_pmcval and Parrot_PMC_newclass to the exte…
NotFound authored
708 Returns a PMC sub wrapper for a c function.
50f5936 @NotFound [core] add Parrot_sub_new_from_c_func to extend.h
NotFound authored
709
710 =cut
711
712 */
713
714 PARROT_EXPORT
715 Parrot_PMC
716 Parrot_sub_new_from_c_func(PARROT_INTERP,
969837b @Infinoid [cage] Add ARGIN() to some new function arguments.
Infinoid authored
717 ARGIN(void (*func)(void)), ARGIN(const char * signature))
50f5936 @NotFound [core] add Parrot_sub_new_from_c_func to extend.h
NotFound authored
718 {
6b45a4c @NotFound [cage] add missed ASSERT_ARGS
NotFound authored
719 ASSERT_ARGS(Parrot_sub_new_from_c_func)
50f5936 @NotFound [core] add Parrot_sub_new_from_c_func to extend.h
NotFound authored
720 Parrot_String sig = Parrot_new_string(interp, signature, strlen(signature),
721 (char *) NULL, 0);
083213a @Whiteknight start rename of pmc_new to Parrot_pmc_new
Whiteknight authored
722 Parrot_PMC sub = Parrot_pmc_new(interp, enum_class_NCI);
50f5936 @NotFound [core] add Parrot_sub_new_from_c_func to extend.h
NotFound authored
723 VTABLE_set_pointer_keyed_str(interp, sub, sig, F2DPTR(func));
724 return sub;
725 }
726
727 /*
728
4dc854f @coke [cage] run 'make headerizer'
coke authored
729 =item C<Parrot_PMC Parrot_PMC_newclass(PARROT_INTERP, Parrot_PMC classtype)>
6d4f4cf @NotFound [core] add Parrot_PMC_push_pmcval and Parrot_PMC_newclass to the exte…
NotFound authored
730
731 Create a class with the type given
732
733 =cut
734
735 */
736
737 PARROT_EXPORT
738 Parrot_PMC
739 Parrot_PMC_newclass(PARROT_INTERP, Parrot_PMC classtype)
740 {
741 ASSERT_ARGS(Parrot_PMC_newclass)
742 Parrot_PMC result;
743 PARROT_CALLIN_START(interp);
744
083213a @Whiteknight start rename of pmc_new to Parrot_pmc_new
Whiteknight authored
745 result = Parrot_pmc_new_init(interp, enum_class_Class, classtype);
6d4f4cf @NotFound [core] add Parrot_PMC_push_pmcval and Parrot_PMC_newclass to the exte…
NotFound authored
746
747 PARROT_CALLIN_END(interp);
748 return result;
749 }
750
751 /*
752
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
753 =back
754
3e1f322 Inline docs update
Michael Scott authored
755 =head1 SEE ALSO
756
0ba0e8a Remove extend.pod; superseded by PDD11
Simon Glover authored
757 See F<include/parrot/extend.h> and F<docs/pdds/pdd11_extending.pod>.
3e1f322 Inline docs update
Michael Scott authored
758
759 =head1 HISTORY
760
761 Initial version by Dan Sugalski.
762
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
763 =cut
764
3e1f322 Inline docs update
Michael Scott authored
765 */
766
2a130ef @particle [PDD07]:
particle authored
767
3e1f322 Inline docs update
Michael Scott authored
768 /*
99b337c start of actual extension routines and docs
Dan Sugalski authored
769 * Local variables:
2a130ef @particle [PDD07]:
particle authored
770 * c-file-style: "parrot"
99b337c start of actual extension routines and docs
Dan Sugalski authored
771 * End:
1d7dded @plobsing update C file vim modelines
plobsing authored
772 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
99b337c start of actual extension routines and docs
Dan Sugalski authored
773 */
Something went wrong with that request. Please try again.