Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 774 lines (566 sloc) 17.376 kB
3e1f322 Inline docs update
Michael Scott authored
1 /*
c9f655c @chromatic [src] Fixed yet another Parrot_pcc_split_signature_string() memory le…
chromatic authored
2 Copyright (C) 2001-2010, 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
3e1f322 Inline docs update
Michael Scott authored
10 These are the functions that parrot extensions (i.e. parrot subroutines
11 written in C, or some other compiled language, rather than in parrot
12 bytecode) may access.
13
14 There is a deliberate distancing from the internals here. Don't go
15 peeking inside -- you've as much access as bytecode does, but no more,
16 so we can provide backwards compatibility for as long as we possibly
17 can.
18
19 =head2 Functions
20
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
21 =over 4
22
23 =cut
24
3e1f322 Inline docs update
Michael Scott authored
25 */
99b337c start of actual extension routines and docs
Dan Sugalski authored
26
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
27 /* Some internal notes. Parrot will die a horrible and bizarre death
e1f3d50 @cotto [gc] replace/remove "DOD" in comments in most files in src/
cotto authored
28 if the stack start pointer's not set and a GC run is
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
29 triggered. The pointer *will* be set by the interpreter if the
30 interpreter calls code which calls these functions, so most
31 extension code is safe, no problem.
32
33 The problem comes in if these routines are called from *outside*
34 an interpreter. This happens when an embedding application calls
35 them to do stuff with PMCs, STRINGS, interpreter contents, and
36 suchlike things. This is perfectly legal -- in fact it's what
37 we've documented should be done -- but the problem is that the
38 stack base pointer will be NULL. This is Very Bad.
39
40 To deal with this there are two macros that are defined to handle
41 the problem.
42
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
43 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
44 anchor needs setting and, if so, will set it. It must *always*
45 come immediately after the last variable declared in the block
46 making the calls into the interpreter, as it declares a variable
47 and has some code.
48
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
49 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
50 the way it was, and should always be the last statement before a
51 return. (If you have multiple returns have it in multiple times)
52
53 Not doing this is a good way to introduce bizarre heisenbugs, so
54 just do it. This is the only place they ought to have to be put
55 in, and most of the functions are already written, so it's not
56 like it's an onerous requirement.
57
58 */
59
99b337c start of actual extension routines and docs
Dan Sugalski authored
60 #include "parrot/parrot.h"
61 #include "parrot/extend.h"
63889c2 @cotto [PMC] replace PMC_struct_val and derivatives with ATTR accessors for …
cotto authored
62 #include "pmc/pmc_sub.h"
68bf472 @bacek Merge context_unify3_simple branch back to trunk.
bacek authored
63 #include "pmc/pmc_callcontext.h"
99b337c start of actual extension routines and docs
Dan Sugalski authored
64
490c1c6 @petdance Changed HEADERIZER TARGET to HEADERIZER HFILE
petdance authored
65 /* HEADERIZER HFILE: include/parrot/extend.h */
df5e1a1 @petdance lie to the headerizer
petdance authored
66
3e1f322 Inline docs update
Michael Scott authored
67 /*
68
4dc854f @coke [cage] run 'make headerizer'
coke authored
69 =item C<int Parrot_vfprintf(PARROT_INTERP, Parrot_PMC pio, const char *s,
70 va_list args)>
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
71
72 Writes a C string format with a varargs list to a PIO.
73
4dc854f @coke [cage] run 'make headerizer'
coke authored
74 =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
75
76 Writes a C string format with varargs to a PIO.
77
4dc854f @coke [cage] run 'make headerizer'
coke authored
78 =item C<int Parrot_printf(NULLOK_INTERP, const char *s, ...)>
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
79
80 Writes a C string format with varargs to C<stdout>.
81
4dc854f @coke [cage] run 'make headerizer'
coke authored
82 =item C<int Parrot_eprintf(NULLOK_INTERP, const char *s, ...)>
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
83
84 Writes a C string format with varargs to C<stderr>.
85
fb2ca1e @NotFound fix lack of cut in a pod comment
NotFound authored
86 =cut
87
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
88 */
89
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
90 PARROT_EXPORT
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
91 int
92 Parrot_vfprintf(PARROT_INTERP, ARGIN(Parrot_PMC pio),
93 ARGIN(const char *s), va_list args)
94 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
95 ASSERT_ARGS(Parrot_vfprintf)
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
96 STRING * str;
97 INTVAL retval;
98
99 PARROT_CALLIN_START(interp);
100 str = Parrot_vsprintf_c(interp, s, args);
9f9cea2 @allisonrandal [pdd22io] Merging the pdd22io_part2 branch into trunk for r32922 to r…
allisonrandal authored
101 retval = Parrot_io_putps(interp, pio, str);
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
102 PARROT_CALLIN_END(interp);
103
104 return retval;
105 }
106
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
107 PARROT_EXPORT
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
108 int
109 Parrot_fprintf(PARROT_INTERP, ARGIN(Parrot_PMC pio),
110 ARGIN(const char *s), ...)
111 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
112 ASSERT_ARGS(Parrot_fprintf)
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
113 va_list args;
114 INTVAL retval;
115
116 va_start(args, s);
117 retval = Parrot_vfprintf(interp, pio, s, args);
118 va_end(args);
119
120 return retval;
121 }
122
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
123 PARROT_EXPORT
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
124 int
125 Parrot_printf(NULLOK_INTERP, ARGIN(const char *s), ...)
126 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
127 ASSERT_ARGS(Parrot_printf)
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
128 va_list args;
129 INTVAL retval;
130 va_start(args, s);
131
132 if (interp) {
9f9cea2 @allisonrandal [pdd22io] Merging the pdd22io_part2 branch into trunk for r32922 to r…
allisonrandal authored
133 retval = Parrot_vfprintf(interp, Parrot_io_STDOUT(interp), s, args);
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
134 }
135 else {
136 /* Be nice about this...
9f9cea2 @allisonrandal [pdd22io] Merging the pdd22io_part2 branch into trunk for r32922 to r…
allisonrandal authored
137 ** 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
138 */
139 retval = vfprintf(stdout, s, args);
140 }
141 va_end(args);
142
143 return retval;
144 }
145
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
146 PARROT_EXPORT
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
147 int
148 Parrot_eprintf(NULLOK_INTERP, ARGIN(const char *s), ...)
149 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
150 ASSERT_ARGS(Parrot_eprintf)
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
151 va_list args;
152 INTVAL retval;
153
154 va_start(args, s);
155
156 if (interp) {
9f9cea2 @allisonrandal [pdd22io] Merging the pdd22io_part2 branch into trunk for r32922 to r…
allisonrandal authored
157 retval = Parrot_vfprintf(interp, Parrot_io_STDERR(interp), s, args);
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
158 }
159 else {
160 /* Be nice about this...
9f9cea2 @allisonrandal [pdd22io] Merging the pdd22io_part2 branch into trunk for r32922 to r…
allisonrandal authored
161 ** 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
162 */
163 retval=vfprintf(stderr, s, args);
164 }
165
166 va_end(args);
167
168 return retval;
169 }
170
171 /*
172
4dc854f @coke [cage] run 'make headerizer'
coke authored
173 =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
174
175 Return the root namespace
176
177 =cut
178
179 */
180
181 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
182 PARROT_PURE_FUNCTION
4429375 @NotFound [core] add functions Parrot_get_root_namespace and Parrot_PMC_get_pmc…
NotFound authored
183 Parrot_PMC
184 Parrot_get_root_namespace(PARROT_INTERP)
185 {
186 ASSERT_ARGS(Parrot_get_root_namespace)
187 return interp->root_namespace;
188 }
189
190 /*
191
4dc854f @coke [cage] run 'make headerizer'
coke authored
192 =item C<Parrot_PMC Parrot_PMC_new(PARROT_INTERP, Parrot_Int type)>
3e1f322 Inline docs update
Michael Scott authored
193
194 Create and return a new PMC.
195
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
196 =cut
197
3e1f322 Inline docs update
Michael Scott authored
198 */
199
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
200 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
201 Parrot_PMC
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
202 Parrot_PMC_new(PARROT_INTERP, Parrot_Int type)
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
203 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
204 ASSERT_ARGS(Parrot_PMC_new)
fa999b0 First chunk of extension code done
Dan Sugalski authored
205 Parrot_PMC newpmc;
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
206 PARROT_CALLIN_START(interp);
083213a @Whiteknight start rename of pmc_new to Parrot_pmc_new
Whiteknight authored
207 newpmc = Parrot_pmc_new_noinit(interp, type);
fa999b0 First chunk of extension code done
Dan Sugalski authored
208 VTABLE_init(interp, newpmc);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
209 PARROT_CALLIN_END(interp);
fa999b0 First chunk of extension code done
Dan Sugalski authored
210 return newpmc;
211 }
212
3e1f322 Inline docs update
Michael Scott authored
213 /*
214
4dc854f @coke [cage] run 'make headerizer'
coke authored
215 =item C<Parrot_Int Parrot_PMC_typenum(PARROT_INTERP, const char *_class)>
3e1f322 Inline docs update
Michael Scott authored
216
217 Returns the internal identifier that represents the named class.
218
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
219 =cut
220
3e1f322 Inline docs update
Michael Scott authored
221 */
222
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
223 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
224 Parrot_Int
802efc1 @petdance If something is NULLOK(const...) it is by definition ARGIN_NULLOK(con…
petdance authored
225 Parrot_PMC_typenum(PARROT_INTERP, ARGIN_NULLOK(const char *_class))
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
226 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
227 ASSERT_ARGS(Parrot_PMC_typenum)
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
228 Parrot_Int retval;
229 PARROT_CALLIN_START(interp);
847522f @Whiteknight rename the rest of the functions in pmc.c, start updating the rest of…
Whiteknight authored
230 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
231 PARROT_CALLIN_END(interp);
232 return retval;
fa999b0 First chunk of extension code done
Dan Sugalski authored
233 }
234
3e1f322 Inline docs update
Michael Scott authored
235 /*
236
4dc854f @coke [cage] run 'make headerizer'
coke authored
237 =item C<Parrot_PMC Parrot_PMC_null(void)>
3e1f322 Inline docs update
Michael Scott authored
238
239 Returns the special C<NULL> PMC.
240
06fb631 @paultcochrane [core] Added function documentation.
paultcochrane authored
241 =cut
242
3e1f322 Inline docs update
Michael Scott authored
243 */
244
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
245 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
246 PARROT_PURE_FUNCTION
11323f5 @petdance fixing null/not-null annotations
petdance authored
247 PARROT_CAN_RETURN_NULL
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
248 Parrot_PMC
249 Parrot_PMC_null(void)
250 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
251 ASSERT_ARGS(Parrot_PMC_null)
8deb08e Expose PMCNULL to extension API.
Melvin Smith authored
252 return PMCNULL;
253 }
254
3e1f322 Inline docs update
Michael Scott authored
255 /*
256
4dc854f @coke [cage] run 'make headerizer'
coke authored
257 =item C<void Parrot_free_cstring(char *string)>
3e1f322 Inline docs update
Michael Scott authored
258
259 Deallocate a C string that the interpreter has handed to you.
260
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
261 =cut
262
3e1f322 Inline docs update
Michael Scott authored
263 */
8deb08e Expose PMCNULL to extension API.
Melvin Smith authored
264
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
265 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
266 void
172bc90 @petdance updating annotations
petdance authored
267 Parrot_free_cstring(ARGFREE(char *string))
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
268 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
269 ASSERT_ARGS(Parrot_free_cstring)
b6bc0c3 @allisonrandal [pdd28str] Merging the pdd27mmd branch into trunk for r36123 to r36318.
allisonrandal authored
270 Parrot_str_free_cstring(string);
99b337c start of actual extension routines and docs
Dan Sugalski authored
271 }
272
3e1f322 Inline docs update
Michael Scott authored
273 /*
274
6c743be @allisonrandal [pcc] Add a generic extend/embed interface function for invoking Parrot
allisonrandal authored
275 =item C<void Parrot_ext_call(PARROT_INTERP, Parrot_PMC sub_pmc, const char
276 *signature, ...)>
277
278 Call a Parrot subroutine or method with the given function signature. The
279 function signature holds one type character for each argument or return, these
280 are:
281
282 I ... Parrot_Int
283 N ... Parrot_Float
284 S ... Parrot_String
285 P ... Parrot_PMC
286
287 Returns come after the arguments, separated by an arrow, so "PN->S" takes a PMC
288 and a float as arguments and returns a string.
289
290 Pass the variables for the arguments and returns in the same order as the
291 signature, with returns as reference to the variable (so it can be modified).
292
293 Parrot_ext_call(interp, sub, "P->S", pmc_arg, &string_result);
294
295 To call a method, pass the object for the method as the first argument, and
296 mark it in the signature as "Pi" ("i" stands for "invocant").
297
298 Parrot_ext_call(interp, sub, "PiP->S", object_arg, pmc_arg, &string_result);
299
300 =cut
301
302 */
303
304 PARROT_EXPORT
305 void
306 Parrot_ext_call(PARROT_INTERP, ARGIN(Parrot_PMC sub_pmc),
307 ARGIN(const char *signature), ...)
308 {
309 ASSERT_ARGS(Parrot_ext_call)
310 va_list args;
363ca41 @chromatic Merged pcc_hackathon_6Mar10 into trunk. Because this changed op numb…
chromatic authored
311 PMC *call_obj;
f3faadb @bacek Fix build with g++
bacek authored
312 const char *arg_sig, *ret_sig;
c9f655c @chromatic [src] Fixed yet another Parrot_pcc_split_signature_string() memory le…
chromatic authored
313
f084166 @petdance Removed an unused argument. Fixed consting.
petdance authored
314 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
315 CURRENT_CONTEXT(interp));
f084166 @petdance Removed an unused argument. Fixed consting.
petdance authored
316 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
317
318 va_start(args, signature);
c9f655c @chromatic [src] Fixed yet another Parrot_pcc_split_signature_string() memory le…
chromatic authored
319 call_obj = Parrot_pcc_build_call_from_varargs(interp, PMCNULL,
320 arg_sig, &args);
6c743be @allisonrandal [pcc] Add a generic extend/embed interface function for invoking Parrot
allisonrandal authored
321
363ca41 @chromatic Merged pcc_hackathon_6Mar10 into trunk. Because this changed op numb…
chromatic authored
322 Parrot_pcc_invoke_from_sig_object(interp, sub_pmc, call_obj);
323 call_obj = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
324 Parrot_pcc_fill_params_from_varargs(interp, call_obj, ret_sig, &args,
325 PARROT_ERRORS_RESULT_COUNT_FLAG);
326 va_end(args);
112c28e @bacek Restore old CallContext in Parrot_ext_call. Spotted by fperrad++
bacek authored
327 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
328 }
329
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
330 /*
331
332 =item C<void Parrot_ext_try(PARROT_INTERP, void (*cfunction(Parrot_Interp, void
333 *)), void (*chandler(Parrot_Interp, PMC *, void *)), void *data)>
334
335 Executes the cfunction argument wrapped in a exception handler.
336 If the function throws, the provided handler function is invoked
337
338 =cut
339
340 */
341
342 PARROT_EXPORT
343 void
344 Parrot_ext_try(PARROT_INTERP,
345 ARGIN_NULLOK(void (*cfunction)(Parrot_Interp, void *)),
346 ARGIN_NULLOK(void (*chandler)(Parrot_Interp, PMC *, void *)),
347 ARGIN_NULLOK(void *data))
348 {
349 ASSERT_ARGS(Parrot_ext_try)
350 if (cfunction) {
351 Parrot_runloop jmp;
8bf9b75 @NotFound restore initial context in Parrot_ext_try
NotFound authored
352 Parrot_Context *initialctx, *curctx;
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
353 PARROT_CALLIN_START(interp);
8bf9b75 @NotFound restore initial context in Parrot_ext_try
NotFound authored
354 initialctx = CONTEXT(interp);
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
355 switch (setjmp(jmp.resume)) {
356 case 0: /* try */
357 Parrot_ex_add_c_handler(interp, &jmp);
358 (*cfunction)(interp, data);
8bf9b75 @NotFound restore initial context in Parrot_ext_try
NotFound authored
359 curctx = CONTEXT(interp);
360 if (curctx != initialctx) {
361 Parrot_warn(interp, PARROT_WARNINGS_NONE_FLAG,
362 "popping context in Parrot_ext_try");
363 do {
364 if (curctx == NULL)
365 do_panic(interp,
366 "cannot restore context", __FILE__, __LINE__);
367 } while ((curctx = CONTEXT(interp)) != initialctx);
368 }
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
369 Parrot_cx_delete_handler_local(interp, STRINGNULL);
370 break;
371 default: /* catch */
372 {
373 PMC *exception = jmp.exception;
b03561f @NotFound initialize curctx in the catch part of Parrot_ext_try
NotFound authored
374 curctx = CONTEXT(interp);
8bf9b75 @NotFound restore initial context in Parrot_ext_try
NotFound authored
375 if (curctx != initialctx) {
376 Parrot_warn(interp, PARROT_WARNINGS_NONE_FLAG,
377 "popping context in Parrot_ext_try");
378 do {
379 if (curctx == NULL)
380 do_panic(interp,
381 "cannot restore context", __FILE__, __LINE__);
382 } while ((curctx = CONTEXT(interp)) != initialctx);
383 }
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
384 Parrot_cx_delete_handler_local(interp, STRINGNULL);
385 if (chandler)
386 (*chandler)(interp, exception, data);
387 }
388 }
389 PARROT_CALLIN_END(interp);
390 }
391 }
c9f655c @chromatic [src] Fixed yet another Parrot_pcc_split_signature_string() memory le…
chromatic authored
392
6c743be @allisonrandal [pcc] Add a generic extend/embed interface function for invoking Parrot
allisonrandal authored
393 /*
394
4dc854f @coke [cage] run 'make headerizer'
coke authored
395 =item C<Parrot_Int Parrot_get_intreg(PARROT_INTERP, Parrot_Int regnum)>
3e1f322 Inline docs update
Michael Scott authored
396
397 Return the value of an integer register.
398
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
399 =cut
400
3e1f322 Inline docs update
Michael Scott authored
401 */
3b31e02 More extension stuff at least partially stubbed out
Dan Sugalski authored
402
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
403 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
404 PARROT_PURE_FUNCTION
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
405 Parrot_Int
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
406 Parrot_get_intreg(PARROT_INTERP, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
407 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
408 ASSERT_ARGS(Parrot_get_intreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
409 return REG_INT(interp, regnum);
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
410 }
411
3e1f322 Inline docs update
Michael Scott authored
412 /*
413
4dc854f @coke [cage] run 'make headerizer'
coke authored
414 =item C<Parrot_Float Parrot_get_numreg(PARROT_INTERP, Parrot_Int regnum)>
3e1f322 Inline docs update
Michael Scott authored
415
416 Return the value of a numeric register.
417
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
418 =cut
419
3e1f322 Inline docs update
Michael Scott authored
420 */
421
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
422 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
423 PARROT_PURE_FUNCTION
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
424 Parrot_Float
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
425 Parrot_get_numreg(PARROT_INTERP, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
426 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
427 ASSERT_ARGS(Parrot_get_numreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
428 return REG_NUM(interp, regnum);
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
429 }
430
3e1f322 Inline docs update
Michael Scott authored
431 /*
432
4dc854f @coke [cage] run 'make headerizer'
coke authored
433 =item C<Parrot_String Parrot_get_strreg(PARROT_INTERP, Parrot_Int regnum)>
3e1f322 Inline docs update
Michael Scott authored
434
435 Return the value of a string register.
436
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
437 =cut
438
3e1f322 Inline docs update
Michael Scott authored
439 */
440
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
441 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
442 PARROT_PURE_FUNCTION
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
443 Parrot_String
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
444 Parrot_get_strreg(PARROT_INTERP, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
445 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
446 ASSERT_ARGS(Parrot_get_strreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
447 return REG_STR(interp, regnum);
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
448 }
449
3e1f322 Inline docs update
Michael Scott authored
450 /*
451
4dc854f @coke [cage] run 'make headerizer'
coke authored
452 =item C<Parrot_PMC Parrot_get_pmcreg(PARROT_INTERP, Parrot_Int regnum)>
3e1f322 Inline docs update
Michael Scott authored
453
454 Return the value of a PMC register.
455
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
456 =cut
457
3e1f322 Inline docs update
Michael Scott authored
458 */
459
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
460 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
461 PARROT_PURE_FUNCTION
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
462 Parrot_PMC
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
463 Parrot_get_pmcreg(PARROT_INTERP, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
464 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
465 ASSERT_ARGS(Parrot_get_pmcreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
466 return REG_PMC(interp, regnum);
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
467 }
468
3e1f322 Inline docs update
Michael Scott authored
469 /*
470
4dc854f @coke [cage] run 'make headerizer'
coke authored
471 =item C<void Parrot_set_intreg(PARROT_INTERP, Parrot_Int regnum, Parrot_Int
472 value)>
3e1f322 Inline docs update
Michael Scott authored
473
474 Set the value of an I register.
475
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
476 =cut
477
3e1f322 Inline docs update
Michael Scott authored
478 */
479
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
480 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
481 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
482 Parrot_set_intreg(PARROT_INTERP, Parrot_Int regnum,
d067bc6 @ambs 80's cuts.
ambs authored
483 Parrot_Int value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
484 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
485 ASSERT_ARGS(Parrot_set_intreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
486 REG_INT(interp, regnum) = value;
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
487 }
488
3e1f322 Inline docs update
Michael Scott authored
489 /*
490
4dc854f @coke [cage] run 'make headerizer'
coke authored
491 =item C<void Parrot_set_numreg(PARROT_INTERP, Parrot_Int regnum, Parrot_Float
492 value)>
3e1f322 Inline docs update
Michael Scott authored
493
494 Set the value of an N register.
495
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
496 =cut
497
3e1f322 Inline docs update
Michael Scott authored
498 */
499
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
500 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
501 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
502 Parrot_set_numreg(PARROT_INTERP, Parrot_Int regnum,
d067bc6 @ambs 80's cuts.
ambs authored
503 Parrot_Float value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
504 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
505 ASSERT_ARGS(Parrot_set_numreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
506 REG_NUM(interp, regnum) = value;
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
507 }
508
3e1f322 Inline docs update
Michael Scott authored
509 /*
510
4dc854f @coke [cage] run 'make headerizer'
coke authored
511 =item C<void Parrot_set_strreg(PARROT_INTERP, Parrot_Int regnum, Parrot_String
512 value)>
3e1f322 Inline docs update
Michael Scott authored
513
514 Set the value of an S register.
515
bc4de54 @moritz add '=cut' lines to some POD documents. Closes trac #19, jimmy++
moritz authored
516 =cut
517
3e1f322 Inline docs update
Michael Scott authored
518 */
519
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
520 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
521 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
522 Parrot_set_strreg(PARROT_INTERP, Parrot_Int regnum,
ef4c70a @chromatic Sanitize external interface, mostly by changing Parrot_STRING to Parr…
chromatic authored
523 Parrot_String value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
524 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
525 ASSERT_ARGS(Parrot_set_strreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
526 REG_STR(interp, regnum) = value;
5f1d8d9 @bacek Add write barrier to Parrot_set_strreg
bacek authored
527 PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp));
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_pmcreg(PARROT_INTERP, Parrot_Int regnum, Parrot_PMC
533 value)>
3e1f322 Inline docs update
Michael Scott authored
534
535 Set the value of a P register.
536
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane 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_pmcreg(PARROT_INTERP, Parrot_Int regnum,
d067bc6 @ambs 80's cuts.
ambs authored
544 Parrot_PMC 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_pmcreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variab…
petdance authored
547 REG_PMC(interp, regnum) = value;
2f168ec @bacek Add write barrier to Parrot_set_pmcreg.
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
000d780 Add in some string construction functions
Dan Sugalski authored
551 /*=for api extend Parrot_new_string
552 *
553 */
3e1f322 Inline docs update
Michael Scott authored
554 /*
555
4dc854f @coke [cage] run 'make headerizer'
coke authored
556 =item C<Parrot_String Parrot_new_string(PARROT_INTERP, const char *buffer,
557 Parrot_UInt length, const char * const encoding_name, Parrot_UInt flags)>
3e1f322 Inline docs update
Michael Scott authored
558
3a348a0 anchor overflow array immediately
Leopold Toetsch authored
559 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
560 flags for right now.
3e1f322 Inline docs update
Michael Scott authored
561
562 A copy of the buffer is made.
563
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
564 =cut
565
3e1f322 Inline docs update
Michael Scott authored
566 */
567
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
568 PARROT_EXPORT
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
569 PARROT_WARN_UNUSED_RESULT
570 PARROT_CANNOT_RETURN_NULL
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
571 Parrot_String
258de48 @chromatic [src] Cleaned up some conversion and signedness warnings.
chromatic authored
572 Parrot_new_string(PARROT_INTERP, ARGIN_NULLOK(const char *buffer),
573 Parrot_UInt length, ARGIN_NULLOK(const char * const encoding_name),
574 Parrot_UInt flags)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
575 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
576 ASSERT_ARGS(Parrot_new_string)
ef4c70a @chromatic Sanitize external interface, mostly by changing Parrot_STRING to Parr…
chromatic authored
577 Parrot_String retval;
456db43 @nwellnhof [str] Prepare deprecation of string_* functions
nwellnhof authored
578 const STR_VTABLE *encoding;
579
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
580 PARROT_CALLIN_START(interp);
456db43 @nwellnhof [str] Prepare deprecation of string_* functions
nwellnhof authored
581
582 if (encoding_name) {
583 encoding = Parrot_find_encoding(interp, encoding_name);
584 if (!encoding)
585 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
586 "Can't make '%s' encoding strings", encoding_name);
587 }
588 else
589 encoding = Parrot_default_encoding_ptr;
590
591 retval = Parrot_str_new_init(interp, buffer, length, encoding, flags);
592
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
593 PARROT_CALLIN_END(interp);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
594 return retval;
000d780 Add in some string construction functions
Dan Sugalski authored
595 }
596
3e1f322 Inline docs update
Michael Scott authored
597 /*
598
b12ac0b @petdance function annotations
petdance authored
599 =item C<Parrot_Language Parrot_find_language(PARROT_INTERP, const char
600 *language)>
3e1f322 Inline docs update
Michael Scott authored
601
602 Find the magic language token for a language, by language name.
603
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
604 =cut
605
3e1f322 Inline docs update
Michael Scott authored
606 */
607
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
608 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
609 PARROT_PURE_FUNCTION
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so tha…
petdance authored
610 PARROT_WARN_UNUSED_RESULT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
611 Parrot_Language
b12ac0b @petdance function annotations
petdance authored
612 Parrot_find_language(SHIM_INTERP, SHIM(const char *language))
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c head…
petdance authored
613 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
614 ASSERT_ARGS(Parrot_find_language)
000d780 Add in some string construction functions
Dan Sugalski authored
615 return 0;
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.