Skip to content

HTTPS clone URL

Subversion checkout URL

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