Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 759 lines (537 sloc) 17.562 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
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
33 exception-handling infrastructure. Calling these functions when there are
37fe0b3 @Whiteknight update some docs in src/extend.c
Whiteknight authored
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
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
39 Extending API is a recipe for disaster. We (Parrot developers) will not be
37fe0b3 @Whiteknight update some docs in src/extend.c
Whiteknight authored
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
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
52 phrase right now. The functions in this file do not belong to any
53 particular subsystem, and are always part of the extending API. Functions
54 named "Parrot_xxx_..." where "xxx" is a 2- or 3-letter subsystem
55 abbreviation and which are marked with "PARROT_EXPORT" can generally be
56 considered to be part of the public API. Subsystems which are properly
57 arranged will typically have a folder src/xxx/, and an "api.c" file
58 therein for holding API functions from that subsystem. Many of the bigger
59 systems are arranged in this way (and the rest of the systems will be
60 eventually). If so, that is the canonical source of information regarding
61 API functions for that subsystem.
62
63 Other documentation sources, such as the PDDs or other files in the
64 docs/ directory may include other information about the extending API.
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
65
66 */
67
99b337c start of actual extension routines and docs
Dan Sugalski authored
68 #include "parrot/parrot.h"
69 #include "parrot/extend.h"
63889c2 @cotto [PMC] replace PMC_struct_val and derivatives with ATTR accessors for the...
cotto authored
70 #include "pmc/pmc_sub.h"
68bf472 @bacek Merge context_unify3_simple branch back to trunk.
bacek authored
71 #include "pmc/pmc_callcontext.h"
99b337c start of actual extension routines and docs
Dan Sugalski authored
72
490c1c6 @petdance Changed HEADERIZER TARGET to HEADERIZER HFILE
petdance authored
73 /* HEADERIZER HFILE: include/parrot/extend.h */
df5e1a1 @petdance lie to the headerizer
petdance authored
74
3e1f322 Inline docs update
Michael Scott authored
75 /*
76
4dc854f @coke [cage] run 'make headerizer'
coke authored
77 =item C<int Parrot_vfprintf(PARROT_INTERP, Parrot_PMC pio, const char *s,
78 va_list args)>
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
79
80 Writes a C string format with a varargs list to a PIO.
81
4dc854f @coke [cage] run 'make headerizer'
coke authored
82 =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
83
84 Writes a C string format with varargs to a PIO.
85
4dc854f @coke [cage] run 'make headerizer'
coke authored
86 =item C<int Parrot_printf(NULLOK_INTERP, const char *s, ...)>
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
87
88 Writes a C string format with varargs to C<stdout>.
89
4dc854f @coke [cage] run 'make headerizer'
coke authored
90 =item C<int Parrot_eprintf(NULLOK_INTERP, const char *s, ...)>
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
91
92 Writes a C string format with varargs to C<stderr>.
93
fb2ca1e @NotFound fix lack of cut in a pod comment
NotFound authored
94 =cut
95
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
96 */
97
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
98 PARROT_EXPORT
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
99 int
100 Parrot_vfprintf(PARROT_INTERP, ARGIN(Parrot_PMC pio),
101 ARGIN(const char *s), va_list args)
102 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
103 ASSERT_ARGS(Parrot_vfprintf)
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
104 STRING * str;
105 INTVAL retval;
106
107 str = Parrot_vsprintf_c(interp, s, args);
9f9cea2 @allisonrandal [pdd22io] Merging the pdd22io_part2 branch into trunk for r32922 to r336...
allisonrandal authored
108 retval = Parrot_io_putps(interp, pio, str);
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
109
110 return retval;
111 }
112
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
113 PARROT_EXPORT
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
114 int
115 Parrot_fprintf(PARROT_INTERP, ARGIN(Parrot_PMC pio),
116 ARGIN(const char *s), ...)
117 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
118 ASSERT_ARGS(Parrot_fprintf)
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
119 va_list args;
120 INTVAL retval;
121
122 va_start(args, s);
123 retval = Parrot_vfprintf(interp, pio, s, args);
124 va_end(args);
125
126 return retval;
127 }
128
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
129 PARROT_EXPORT
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
130 int
131 Parrot_printf(NULLOK_INTERP, ARGIN(const char *s), ...)
132 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
133 ASSERT_ARGS(Parrot_printf)
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
134 va_list args;
135 INTVAL retval;
136 va_start(args, s);
137
942bad2 @Whiteknight Several misc cleanups to src/extend.c. Add some TODO and DEPRECATED note...
Whiteknight authored
138 if (interp)
9f9cea2 @allisonrandal [pdd22io] Merging the pdd22io_part2 branch into trunk for r32922 to r336...
allisonrandal authored
139 retval = Parrot_vfprintf(interp, Parrot_io_STDOUT(interp), s, args);
942bad2 @Whiteknight Several misc cleanups to src/extend.c. Add some TODO and DEPRECATED note...
Whiteknight authored
140 else
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
141 retval = vfprintf(stdout, s, args);
142 va_end(args);
143
144 return retval;
145 }
146
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
147 PARROT_EXPORT
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
148 int
149 Parrot_eprintf(NULLOK_INTERP, ARGIN(const char *s), ...)
150 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
151 ASSERT_ARGS(Parrot_eprintf)
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
152 va_list args;
153 INTVAL retval;
154
155 va_start(args, s);
156
942bad2 @Whiteknight Several misc cleanups to src/extend.c. Add some TODO and DEPRECATED note...
Whiteknight authored
157 if (interp)
9f9cea2 @allisonrandal [pdd22io] Merging the pdd22io_part2 branch into trunk for r32922 to r336...
allisonrandal authored
158 retval = Parrot_vfprintf(interp, Parrot_io_STDERR(interp), s, args);
942bad2 @Whiteknight Several misc cleanups to src/extend.c. Add some TODO and DEPRECATED note...
Whiteknight authored
159 else
160 retval = vfprintf(stderr, s, args);
87909b3 @NotFound Add Parrot_printf and Parrot_eprintf to the extend API
NotFound authored
161
162 va_end(args);
163
164 return retval;
165 }
166
167 /*
168
4dc854f @coke [cage] run 'make headerizer'
coke authored
169 =item C<Parrot_PMC Parrot_get_root_namespace(PARROT_INTERP)>
4429375 @NotFound [core] add functions Parrot_get_root_namespace and Parrot_PMC_get_pmc_st...
NotFound authored
170
171 Return the root namespace
172
173 =cut
174
175 */
176
177 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
178 PARROT_PURE_FUNCTION
4429375 @NotFound [core] add functions Parrot_get_root_namespace and Parrot_PMC_get_pmc_st...
NotFound authored
179 Parrot_PMC
180 Parrot_get_root_namespace(PARROT_INTERP)
181 {
182 ASSERT_ARGS(Parrot_get_root_namespace)
3693897 @leto Add many missing PARROT_CALLIN_(START|END) macros to src/extend.c
leto authored
183
4429375 @NotFound [core] add functions Parrot_get_root_namespace and Parrot_PMC_get_pmc_st...
NotFound authored
184 return interp->root_namespace;
185 }
186
187 /*
188
4dc854f @coke [cage] run 'make headerizer'
coke authored
189 =item C<Parrot_PMC Parrot_PMC_new(PARROT_INTERP, Parrot_Int type)>
3e1f322 Inline docs update
Michael Scott authored
190
191 Create and return a new PMC.
192
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
193 =cut
194
3e1f322 Inline docs update
Michael Scott authored
195 */
196
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
197 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
198 Parrot_PMC
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so that s...
petdance authored
199 Parrot_PMC_new(PARROT_INTERP, Parrot_Int type)
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
200 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
201 ASSERT_ARGS(Parrot_PMC_new)
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
202 Parrot_PMC newpmc = Parrot_pmc_new_noinit(interp, type);
fa999b0 First chunk of extension code done
Dan Sugalski authored
203 VTABLE_init(interp, newpmc);
204 return newpmc;
205 }
206
3e1f322 Inline docs update
Michael Scott authored
207 /*
208
4dc854f @coke [cage] run 'make headerizer'
coke authored
209 =item C<Parrot_Int Parrot_PMC_typenum(PARROT_INTERP, const char *_class)>
3e1f322 Inline docs update
Michael Scott authored
210
211 Returns the internal identifier that represents the named class.
212
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
213 =cut
214
3e1f322 Inline docs update
Michael Scott authored
215 */
216
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
217 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
218 Parrot_Int
802efc1 @petdance If something is NULLOK(const...) it is by definition ARGIN_NULLOK(const....
petdance authored
219 Parrot_PMC_typenum(PARROT_INTERP, ARGIN_NULLOK(const char *_class))
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
220 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
221 ASSERT_ARGS(Parrot_PMC_typenum)
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
222 Parrot_Int 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
223 return retval;
fa999b0 First chunk of extension code done
Dan Sugalski authored
224 }
225
3e1f322 Inline docs update
Michael Scott authored
226 /*
227
4dc854f @coke [cage] run 'make headerizer'
coke authored
228 =item C<Parrot_PMC Parrot_PMC_null(void)>
3e1f322 Inline docs update
Michael Scott authored
229
230 Returns the special C<NULL> PMC.
231
06fb631 @paultcochrane [core] Added function documentation.
paultcochrane authored
232 =cut
233
3e1f322 Inline docs update
Michael Scott authored
234 */
235
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
236 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
237 PARROT_PURE_FUNCTION
11323f5 @petdance fixing null/not-null annotations
petdance authored
238 PARROT_CAN_RETURN_NULL
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
239 Parrot_PMC
240 Parrot_PMC_null(void)
241 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
242 ASSERT_ARGS(Parrot_PMC_null)
8deb08e Expose PMCNULL to extension API.
Melvin Smith authored
243 return PMCNULL;
244 }
245
3e1f322 Inline docs update
Michael Scott authored
246 /*
247
4dc854f @coke [cage] run 'make headerizer'
coke authored
248 =item C<void Parrot_free_cstring(char *string)>
3e1f322 Inline docs update
Michael Scott authored
249
250 Deallocate a C string that the interpreter has handed to you.
251
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
252 =cut
253
3e1f322 Inline docs update
Michael Scott authored
254 */
8deb08e Expose PMCNULL to extension API.
Melvin Smith authored
255
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
256 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
257 void
172bc90 @petdance updating annotations
petdance authored
258 Parrot_free_cstring(ARGFREE(char *string))
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
259 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
260 ASSERT_ARGS(Parrot_free_cstring)
b6bc0c3 @allisonrandal [pdd28str] Merging the pdd27mmd branch into trunk for r36123 to r36318.
allisonrandal authored
261 Parrot_str_free_cstring(string);
99b337c start of actual extension routines and docs
Dan Sugalski authored
262 }
263
3e1f322 Inline docs update
Michael Scott authored
264 /*
265
6c743be @allisonrandal [pcc] Add a generic extend/embed interface function for invoking Parrot
allisonrandal authored
266 =item C<void Parrot_ext_call(PARROT_INTERP, Parrot_PMC sub_pmc, const char
267 *signature, ...)>
268
269 Call a Parrot subroutine or method with the given function signature. The
270 function signature holds one type character for each argument or return, these
271 are:
272
273 I ... Parrot_Int
274 N ... Parrot_Float
275 S ... Parrot_String
276 P ... Parrot_PMC
277
278 Returns come after the arguments, separated by an arrow, so "PN->S" takes a PMC
279 and a float as arguments and returns a string.
280
281 Pass the variables for the arguments and returns in the same order as the
282 signature, with returns as reference to the variable (so it can be modified).
283
284 Parrot_ext_call(interp, sub, "P->S", pmc_arg, &string_result);
285
286 To call a method, pass the object for the method as the first argument, and
287 mark it in the signature as "Pi" ("i" stands for "invocant").
288
289 Parrot_ext_call(interp, sub, "PiP->S", object_arg, pmc_arg, &string_result);
290
291 =cut
292
293 */
294
295 PARROT_EXPORT
296 void
297 Parrot_ext_call(PARROT_INTERP, ARGIN(Parrot_PMC sub_pmc),
298 ARGIN(const char *signature), ...)
299 {
300 ASSERT_ARGS(Parrot_ext_call)
301 va_list args;
363ca41 @chromatic Merged pcc_hackathon_6Mar10 into trunk. Because this changed op numberi...
chromatic authored
302 PMC *call_obj;
f3faadb @bacek Fix build with g++
bacek authored
303 const char *arg_sig, *ret_sig;
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
304 PMC * old_call_obj = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
f084166 @petdance Removed an unused argument. Fixed consting.
petdance authored
305 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
306
307 va_start(args, signature);
c9f655c @chromatic [src] Fixed yet another Parrot_pcc_split_signature_string() memory leak....
chromatic authored
308 call_obj = Parrot_pcc_build_call_from_varargs(interp, PMCNULL,
309 arg_sig, &args);
6c743be @allisonrandal [pcc] Add a generic extend/embed interface function for invoking Parrot
allisonrandal authored
310
363ca41 @chromatic Merged pcc_hackathon_6Mar10 into trunk. Because this changed op numberi...
chromatic authored
311 Parrot_pcc_invoke_from_sig_object(interp, sub_pmc, call_obj);
312 call_obj = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
313 Parrot_pcc_fill_params_from_varargs(interp, call_obj, ret_sig, &args,
314 PARROT_ERRORS_RESULT_COUNT_FLAG);
315 va_end(args);
112c28e @bacek Restore old CallContext in Parrot_ext_call. Spotted by fperrad++
bacek authored
316 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
317 }
318
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
319 /*
320
321 =item C<void Parrot_ext_try(PARROT_INTERP, void (*cfunction(Parrot_Interp, void
322 *)), void (*chandler(Parrot_Interp, PMC *, void *)), void *data)>
323
324 Executes the cfunction argument wrapped in a exception handler.
325 If the function throws, the provided handler function is invoked
326
327 =cut
328
329 */
330
037628f @mikehh wrap macro arguments
mikehh authored
331 #define POP_CONTEXT(interp, curctx, intialctx) \
332 Parrot_warn((interp), PARROT_WARNINGS_NONE_FLAG, \
333 "popping context in Parrot_ext_try"); \
334 do { \
335 if ((curctx) == NULL) \
336 do_panic((interp), "cannot restore context", \
337 __FILE__, __LINE__); \
338 } while (((curctx) = CONTEXT(interp)) != initialctx); \
3f7b5d3 @leto Refactor duplicated context popping code into a macro
leto authored
339
340
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
341 PARROT_EXPORT
342 void
343 Parrot_ext_try(PARROT_INTERP,
344 ARGIN_NULLOK(void (*cfunction)(Parrot_Interp, void *)),
345 ARGIN_NULLOK(void (*chandler)(Parrot_Interp, PMC *, void *)),
346 ARGIN_NULLOK(void *data))
347 {
348 ASSERT_ARGS(Parrot_ext_try)
349 if (cfunction) {
350 Parrot_runloop jmp;
8bf9b75 @NotFound restore initial context in Parrot_ext_try
NotFound authored
351 Parrot_Context *initialctx, *curctx;
352 initialctx = CONTEXT(interp);
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
353 switch (setjmp(jmp.resume)) {
354 case 0: /* try */
355 Parrot_ex_add_c_handler(interp, &jmp);
356 (*cfunction)(interp, data);
8bf9b75 @NotFound restore initial context in Parrot_ext_try
NotFound authored
357 curctx = CONTEXT(interp);
358 if (curctx != initialctx) {
3f7b5d3 @leto Refactor duplicated context popping code into a macro
leto authored
359 POP_CONTEXT(interp, curctx, initialctx);
8bf9b75 @NotFound restore initial context in Parrot_ext_try
NotFound authored
360 }
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
361 Parrot_cx_delete_handler_local(interp, STRINGNULL);
362 break;
363 default: /* catch */
364 {
365 PMC *exception = jmp.exception;
b03561f @NotFound initialize curctx in the catch part of Parrot_ext_try
NotFound authored
366 curctx = CONTEXT(interp);
8bf9b75 @NotFound restore initial context in Parrot_ext_try
NotFound authored
367 if (curctx != initialctx) {
3f7b5d3 @leto Refactor duplicated context popping code into a macro
leto authored
368 POP_CONTEXT(interp, curctx, initialctx);
8bf9b75 @NotFound restore initial context in Parrot_ext_try
NotFound authored
369 }
668635f @NotFound add function Parrot_ext_try and use it in extend_vtable tests
NotFound authored
370 Parrot_cx_delete_handler_local(interp, STRINGNULL);
371 if (chandler)
372 (*chandler)(interp, exception, data);
373 }
374 }
375 }
376 }
c9f655c @chromatic [src] Fixed yet another Parrot_pcc_split_signature_string() memory leak....
chromatic authored
377
6c743be @allisonrandal [pcc] Add a generic extend/embed interface function for invoking Parrot
allisonrandal authored
378 /*
379
4dc854f @coke [cage] run 'make headerizer'
coke authored
380 =item C<Parrot_Int Parrot_get_intreg(PARROT_INTERP, Parrot_Int regnum)>
3e1f322 Inline docs update
Michael Scott authored
381
382 Return the value of an integer register.
383
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
384 DEPRECATED: Do not use. See TT #2133
385
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
386 =cut
387
3e1f322 Inline docs update
Michael Scott authored
388 */
3b31e02 More extension stuff at least partially stubbed out
Dan Sugalski authored
389
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
390 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
391 PARROT_PURE_FUNCTION
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
392 Parrot_Int
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so that s...
petdance authored
393 Parrot_get_intreg(PARROT_INTERP, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c headers...
petdance authored
394 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
395 ASSERT_ARGS(Parrot_get_intreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variable,...
petdance authored
396 return REG_INT(interp, regnum);
b4bdfa8 Stub in some new object manipulation methods, and some extension routine...
Dan Sugalski authored
397 }
398
3e1f322 Inline docs update
Michael Scott authored
399 /*
400
4dc854f @coke [cage] run 'make headerizer'
coke authored
401 =item C<Parrot_Float Parrot_get_numreg(PARROT_INTERP, Parrot_Int regnum)>
3e1f322 Inline docs update
Michael Scott authored
402
403 Return the value of a numeric register.
404
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
405 DEPRECATED: Do not use. See TT #2133
406
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
407 =cut
408
3e1f322 Inline docs update
Michael Scott authored
409 */
410
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
411 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
412 PARROT_PURE_FUNCTION
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
413 Parrot_Float
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so that s...
petdance authored
414 Parrot_get_numreg(PARROT_INTERP, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c headers...
petdance authored
415 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
416 ASSERT_ARGS(Parrot_get_numreg)
3693897 @leto Add many missing PARROT_CALLIN_(START|END) macros to src/extend.c
leto authored
417
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variable,...
petdance authored
418 return REG_NUM(interp, regnum);
b4bdfa8 Stub in some new object manipulation methods, and some extension routine...
Dan Sugalski authored
419 }
420
3e1f322 Inline docs update
Michael Scott authored
421 /*
422
4dc854f @coke [cage] run 'make headerizer'
coke authored
423 =item C<Parrot_String Parrot_get_strreg(PARROT_INTERP, Parrot_Int regnum)>
3e1f322 Inline docs update
Michael Scott authored
424
425 Return the value of a string register.
426
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
427 DEPRECATED: Do not use. See TT #2133
428
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
429 =cut
430
3e1f322 Inline docs update
Michael Scott authored
431 */
432
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
433 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
434 PARROT_PURE_FUNCTION
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
435 Parrot_String
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so that s...
petdance authored
436 Parrot_get_strreg(PARROT_INTERP, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c headers...
petdance authored
437 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
438 ASSERT_ARGS(Parrot_get_strreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variable,...
petdance authored
439 return REG_STR(interp, regnum);
b4bdfa8 Stub in some new object manipulation methods, and some extension routine...
Dan Sugalski authored
440 }
441
3e1f322 Inline docs update
Michael Scott authored
442 /*
443
4dc854f @coke [cage] run 'make headerizer'
coke authored
444 =item C<Parrot_PMC Parrot_get_pmcreg(PARROT_INTERP, Parrot_Int regnum)>
3e1f322 Inline docs update
Michael Scott authored
445
446 Return the value of a PMC register.
447
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
448 DEPRECATED: Do not use. See TT #2133
449
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
450 =cut
451
3e1f322 Inline docs update
Michael Scott authored
452 */
453
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
454 PARROT_EXPORT
b12ac0b @petdance function annotations
petdance authored
455 PARROT_PURE_FUNCTION
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
456 Parrot_PMC
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so that s...
petdance authored
457 Parrot_get_pmcreg(PARROT_INTERP, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c headers...
petdance authored
458 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
459 ASSERT_ARGS(Parrot_get_pmcreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variable,...
petdance authored
460 return REG_PMC(interp, regnum);
b4bdfa8 Stub in some new object manipulation methods, and some extension routine...
Dan Sugalski authored
461 }
462
3e1f322 Inline docs update
Michael Scott authored
463 /*
464
4dc854f @coke [cage] run 'make headerizer'
coke authored
465 =item C<void Parrot_set_intreg(PARROT_INTERP, Parrot_Int regnum, Parrot_Int
466 value)>
3e1f322 Inline docs update
Michael Scott authored
467
468 Set the value of an I register.
469
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
470 DEPRECATED: Do not use. See TT #2133
471
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
472 =cut
473
3e1f322 Inline docs update
Michael Scott authored
474 */
475
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
476 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
477 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so that s...
petdance authored
478 Parrot_set_intreg(PARROT_INTERP, Parrot_Int regnum,
d067bc6 @ambs 80's cuts.
ambs authored
479 Parrot_Int value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c headers...
petdance authored
480 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
481 ASSERT_ARGS(Parrot_set_intreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variable,...
petdance authored
482 REG_INT(interp, regnum) = value;
b4bdfa8 Stub in some new object manipulation methods, and some extension routine...
Dan Sugalski authored
483 }
484
3e1f322 Inline docs update
Michael Scott authored
485 /*
486
4dc854f @coke [cage] run 'make headerizer'
coke authored
487 =item C<void Parrot_set_numreg(PARROT_INTERP, Parrot_Int regnum, Parrot_Float
488 value)>
3e1f322 Inline docs update
Michael Scott authored
489
490 Set the value of an N register.
491
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
492 DEPRECATED: Do not use. See TT #2133
493
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
494 =cut
495
3e1f322 Inline docs update
Michael Scott authored
496 */
497
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
498 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
499 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so that s...
petdance authored
500 Parrot_set_numreg(PARROT_INTERP, Parrot_Int regnum,
d067bc6 @ambs 80's cuts.
ambs authored
501 Parrot_Float value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c headers...
petdance authored
502 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
503 ASSERT_ARGS(Parrot_set_numreg)
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variable,...
petdance authored
504 REG_NUM(interp, regnum) = value;
b4bdfa8 Stub in some new object manipulation methods, and some extension routine...
Dan Sugalski authored
505 }
506
3e1f322 Inline docs update
Michael Scott authored
507 /*
508
4dc854f @coke [cage] run 'make headerizer'
coke authored
509 =item C<void Parrot_set_strreg(PARROT_INTERP, Parrot_Int regnum, Parrot_String
510 value)>
3e1f322 Inline docs update
Michael Scott authored
511
512 Set the value of an S register.
513
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
514 DEPRECATED: Do not use. See TT #2133
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 that s...
petdance authored
522 Parrot_set_strreg(PARROT_INTERP, Parrot_Int regnum,
ef4c70a @chromatic Sanitize external interface, mostly by changing Parrot_STRING to Parrot_...
chromatic authored
523 Parrot_String value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c headers...
petdance authored
524 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
525 ASSERT_ARGS(Parrot_set_strreg)
3693897 @leto Add many missing PARROT_CALLIN_(START|END) macros to src/extend.c
leto authored
526
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variable,...
petdance authored
527 REG_STR(interp, regnum) = value;
5f1d8d9 @bacek Add write barrier to Parrot_set_strreg
bacek authored
528 PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp));
b4bdfa8 Stub in some new object manipulation methods, and some extension routine...
Dan Sugalski authored
529 }
530
3e1f322 Inline docs update
Michael Scott authored
531 /*
532
4dc854f @coke [cage] run 'make headerizer'
coke authored
533 =item C<void Parrot_set_pmcreg(PARROT_INTERP, Parrot_Int regnum, Parrot_PMC
534 value)>
3e1f322 Inline docs update
Michael Scott authored
535
536 Set the value of a P register.
537
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
538 DEPRECATED: Do not use. See TT #2133
539
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
540 =cut
541
3e1f322 Inline docs update
Michael Scott authored
542 */
543
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
544 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
545 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so that s...
petdance authored
546 Parrot_set_pmcreg(PARROT_INTERP, Parrot_Int regnum,
d067bc6 @ambs 80's cuts.
ambs authored
547 Parrot_PMC value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c headers...
petdance authored
548 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
549 ASSERT_ARGS(Parrot_set_pmcreg)
3693897 @leto Add many missing PARROT_CALLIN_(START|END) macros to src/extend.c
leto authored
550
db561ab @petdance Changed REG_(INT|NUM|PMC|STR) to explicitly pass in the interp variable,...
petdance authored
551 REG_PMC(interp, regnum) = value;
2f168ec @bacek Add write barrier to Parrot_set_pmcreg.
bacek authored
552 PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp));
b4bdfa8 Stub in some new object manipulation methods, and some extension routine...
Dan Sugalski authored
553 }
554
000d780 Add in some string construction functions
Dan Sugalski authored
555 /*=for api extend Parrot_new_string
556 *
557 */
3e1f322 Inline docs update
Michael Scott authored
558 /*
559
4dc854f @coke [cage] run 'make headerizer'
coke authored
560 =item C<Parrot_String Parrot_new_string(PARROT_INTERP, const char *buffer,
561 Parrot_UInt length, const char * const encoding_name, Parrot_UInt flags)>
3e1f322 Inline docs update
Michael Scott authored
562
3a348a0 anchor overflow array immediately
Leopold Toetsch authored
563 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
564 flags for right now.
3e1f322 Inline docs update
Michael Scott authored
565
566 A copy of the buffer is made.
567
942bad2 @Whiteknight Several misc cleanups to src/extend.c. Add some TODO and DEPRECATED note...
Whiteknight authored
568 DEPRECATED: Use Parrot_str_new or Parrot_str_new_init instead. See TT #2133
569
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
570 =cut
571
3e1f322 Inline docs update
Michael Scott authored
572 */
573
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
574 PARROT_EXPORT
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so that s...
petdance authored
575 PARROT_WARN_UNUSED_RESULT
576 PARROT_CANNOT_RETURN_NULL
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
577 Parrot_String
258de48 @chromatic [src] Cleaned up some conversion and signedness warnings.
chromatic authored
578 Parrot_new_string(PARROT_INTERP, ARGIN_NULLOK(const char *buffer),
579 Parrot_UInt length, ARGIN_NULLOK(const char * const encoding_name),
580 Parrot_UInt flags)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c headers...
petdance authored
581 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
582 ASSERT_ARGS(Parrot_new_string)
ef4c70a @chromatic Sanitize external interface, mostly by changing Parrot_STRING to Parrot_...
chromatic authored
583 Parrot_String retval;
456db43 @nwellnhof [str] Prepare deprecation of string_* functions
nwellnhof authored
584 const STR_VTABLE *encoding;
585
586 if (encoding_name) {
587 encoding = Parrot_find_encoding(interp, encoding_name);
588 if (!encoding)
589 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
590 "Can't make '%s' encoding strings", encoding_name);
591 }
592 else
593 encoding = Parrot_default_encoding_ptr;
594
595 retval = Parrot_str_new_init(interp, buffer, length, encoding, flags);
596
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
597 return retval;
000d780 Add in some string construction functions
Dan Sugalski authored
598 }
599
3e1f322 Inline docs update
Michael Scott authored
600 /*
601
4dc854f @coke [cage] run 'make headerizer'
coke authored
602 =item C<void Parrot_register_pmc(PARROT_INTERP, Parrot_PMC pmc)>
3e1f322 Inline docs update
Michael Scott authored
603
e1f3d50 @cotto [gc] replace/remove "DOD" in comments in most files in src/
cotto authored
604 Add a reference of the PMC to the interpreter's GC registry. This prevents PMCs
605 only known to extension from getting destroyed during GC runs.
3e1f322 Inline docs update
Michael Scott authored
606
942bad2 @Whiteknight Several misc cleanups to src/extend.c. Add some TODO and DEPRECATED note...
Whiteknight authored
607 DEPRECATED: Use Parrot_pmc_gc_register instead
608
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
609 =cut
610
3e1f322 Inline docs update
Michael Scott authored
611 */
9b7b3de register ops
Leopold Toetsch authored
612
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
613 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
614 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so that s...
petdance authored
615 Parrot_register_pmc(PARROT_INTERP, Parrot_PMC pmc)
9b7b3de register ops
Leopold Toetsch authored
616 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
617 ASSERT_ARGS(Parrot_register_pmc)
847522f @Whiteknight rename the rest of the functions in pmc.c, start updating the rest of th...
Whiteknight authored
618 Parrot_pmc_gc_register(interp, pmc);
9b7b3de register ops
Leopold Toetsch authored
619 }
620
3e1f322 Inline docs update
Michael Scott authored
621 /*
622
4dc854f @coke [cage] run 'make headerizer'
coke authored
623 =item C<void Parrot_unregister_pmc(PARROT_INTERP, Parrot_PMC pmc)>
3e1f322 Inline docs update
Michael Scott authored
624
e1f3d50 @cotto [gc] replace/remove "DOD" in comments in most files in src/
cotto authored
625 Remove a reference of the PMC from the interpreter's GC registry. If the
626 reference count reaches zero, the PMC will be destroyed during the next GC run.
3e1f322 Inline docs update
Michael Scott authored
627
942bad2 @Whiteknight Several misc cleanups to src/extend.c. Add some TODO and DEPRECATED note...
Whiteknight authored
628 DEPRECATED: Use Parrot_pmc_gc_unregister instead
629
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
630 =cut
631
3e1f322 Inline docs update
Michael Scott authored
632 */
9b7b3de register ops
Leopold Toetsch authored
633
42d0af3 @particle #60624: [DEPRECATED] PARROT_API changes to PARROT_EXPORT
particle authored
634 PARROT_EXPORT
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
635 void
c4b44b0 @petdance Putting PARROT_INTERP in all the typedefs instead of Interp *, so that s...
petdance authored
636 Parrot_unregister_pmc(PARROT_INTERP, Parrot_PMC pmc)
9b7b3de register ops
Leopold Toetsch authored
637 {
00f1c24 @Infinoid [cage] Attempt to work around MSVC warnings related to ASSERT_ARGS().
Infinoid authored
638 ASSERT_ARGS(Parrot_unregister_pmc)
847522f @Whiteknight rename the rest of the functions in pmc.c, start updating the rest of th...
Whiteknight authored
639 Parrot_pmc_gc_unregister(interp, pmc);
9b7b3de register ops
Leopold Toetsch authored
640 }
641
06fb631 @paultcochrane [core] Added function documentation.
paultcochrane authored
642 /*
643
859b8a9 @cotto [extend] add functions for string registering and unregistering for embe...
cotto authored
644 =item C<void Parrot_register_string(PARROT_INTERP, Parrot_String s)>
645
646 Add a reference of the string to the interpreter's GC registry. This prevents
647 strings only known to extension from getting destroyed during GC runs.
648
942bad2 @Whiteknight Several misc cleanups to src/extend.c. Add some TODO and DEPRECATED note...
Whiteknight authored
649 DEPRECATED: Use Parrot_str_gc_register instead
650
859b8a9 @cotto [extend] add functions for string registering and unregistering for embe...
cotto authored
651 =cut
652
653 */
654
655 PARROT_EXPORT
656 void
657 Parrot_register_string(PARROT_INTERP, Parrot_String s)
658 {
659 ASSERT_ARGS(Parrot_register_string)
660 Parrot_str_gc_register(interp, s);
661 }
662
663 /*
664
665 =item C<void Parrot_unregister_string(PARROT_INTERP, Parrot_String s)>
666
667 Remove a reference of the string from the interpreter's GC registry. If the
668 reference count reaches zero, the string will be destroyed during the next GC
669 run.
670
942bad2 @Whiteknight Several misc cleanups to src/extend.c. Add some TODO and DEPRECATED note...
Whiteknight authored
671 DEPRECATED: Use Parrot_str_gc_unregister instead
672
859b8a9 @cotto [extend] add functions for string registering and unregistering for embe...
cotto authored
673 =cut
674
675 */
676
677 PARROT_EXPORT
678 void
679 Parrot_unregister_string(PARROT_INTERP, Parrot_String s)
680 {
681 ASSERT_ARGS(Parrot_unregister_string)
682 Parrot_str_gc_unregister(interp, s);
683 }
684
685 /*
686
4dc854f @coke [cage] run 'make headerizer'
coke authored
687 =item C<Parrot_PMC Parrot_sub_new_from_c_func(PARROT_INTERP, void (*func(void)),
688 const char * signature)>
50f5936 @NotFound [core] add Parrot_sub_new_from_c_func to extend.h
NotFound authored
689
6d4f4cf @NotFound [core] add Parrot_PMC_push_pmcval and Parrot_PMC_newclass to the extend ...
NotFound authored
690 Returns a PMC sub wrapper for a c function.
50f5936 @NotFound [core] add Parrot_sub_new_from_c_func to extend.h
NotFound authored
691
942bad2 @Whiteknight Several misc cleanups to src/extend.c. Add some TODO and DEPRECATED note...
Whiteknight authored
692 TODO: Clean this up, move it some place more appropriate
693
50f5936 @NotFound [core] add Parrot_sub_new_from_c_func to extend.h
NotFound authored
694 =cut
695
696 */
697
698 PARROT_EXPORT
699 Parrot_PMC
700 Parrot_sub_new_from_c_func(PARROT_INTERP,
969837b @Infinoid [cage] Add ARGIN() to some new function arguments.
Infinoid authored
701 ARGIN(void (*func)(void)), ARGIN(const char * signature))
50f5936 @NotFound [core] add Parrot_sub_new_from_c_func to extend.h
NotFound authored
702 {
6b45a4c @NotFound [cage] add missed ASSERT_ARGS
NotFound authored
703 ASSERT_ARGS(Parrot_sub_new_from_c_func)
782bf96 @leto Attempt to make the MSWin32-x86-multi-thread ttbot happy by ANSI-89-ific...
leto authored
704
705 Parrot_String sig;
706 Parrot_PMC sub;
a0911db @leto Fix bug in Parrot_sub_new_from_c_func cause by not using PARROT_CALLIN_(...
leto authored
707
782bf96 @leto Attempt to make the MSWin32-x86-multi-thread ttbot happy by ANSI-89-ific...
leto authored
708 sig = Parrot_new_string(interp, signature, strlen(signature),
50f5936 @NotFound [core] add Parrot_sub_new_from_c_func to extend.h
NotFound authored
709 (char *) NULL, 0);
782bf96 @leto Attempt to make the MSWin32-x86-multi-thread ttbot happy by ANSI-89-ific...
leto authored
710
711 sub = Parrot_pmc_new(interp, enum_class_NCI);
50f5936 @NotFound [core] add Parrot_sub_new_from_c_func to extend.h
NotFound authored
712 VTABLE_set_pointer_keyed_str(interp, sub, sig, F2DPTR(func));
713 return sub;
714 }
715
716 /*
717
4dc854f @coke [cage] run 'make headerizer'
coke authored
718 =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 extend ...
NotFound authored
719
720 Create a class with the type given
721
942bad2 @Whiteknight Several misc cleanups to src/extend.c. Add some TODO and DEPRECATED note...
Whiteknight authored
722 TODO: Clean this up, move this to src/oo.c
723
6d4f4cf @NotFound [core] add Parrot_PMC_push_pmcval and Parrot_PMC_newclass to the extend ...
NotFound authored
724 =cut
725
726 */
727
728 PARROT_EXPORT
729 Parrot_PMC
730 Parrot_PMC_newclass(PARROT_INTERP, Parrot_PMC classtype)
731 {
732 ASSERT_ARGS(Parrot_PMC_newclass)
85781e9 @Whiteknight Remove PARROT_CALLIN_START and PARROT_CALLIN_END macros. The Extending A...
Whiteknight authored
733 return Parrot_pmc_new_init(interp, enum_class_Class, classtype);
6d4f4cf @NotFound [core] add Parrot_PMC_push_pmcval and Parrot_PMC_newclass to the extend ...
NotFound authored
734 }
735
736 /*
737
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
738 =back
739
3e1f322 Inline docs update
Michael Scott authored
740 =head1 SEE ALSO
741
0ba0e8a Remove extend.pod; superseded by PDD11
Simon Glover authored
742 See F<include/parrot/extend.h> and F<docs/pdds/pdd11_extending.pod>.
3e1f322 Inline docs update
Michael Scott authored
743
744 =head1 HISTORY
745
746 Initial version by Dan Sugalski.
747
bc15dd5 @paultcochrane [core] Converted FUNCDOCs to POD and tidied the POD up a bit.
paultcochrane authored
748 =cut
749
3e1f322 Inline docs update
Michael Scott authored
750 */
751
2a130ef @particle [PDD07]:
particle authored
752
3e1f322 Inline docs update
Michael Scott authored
753 /*
99b337c start of actual extension routines and docs
Dan Sugalski authored
754 * Local variables:
2a130ef @particle [PDD07]:
particle authored
755 * c-file-style: "parrot"
99b337c start of actual extension routines and docs
Dan Sugalski authored
756 * End:
1d7dded @plobsing update C file vim modelines
plobsing authored
757 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
99b337c start of actual extension routines and docs
Dan Sugalski authored
758 */
Something went wrong with that request. Please try again.