Skip to content
Newer
Older
100644 1113 lines (804 sloc) 21.8 KB
3e1f322 Inline docs update
Michael Scott authored
1 /*
76c4c09 @chromatic [External] Explicitly export external API symbols.
chromatic authored
2 Copyright (C) 2001-2007, The Perl Foundation.
3e1f322 Inline docs update
Michael Scott authored
3 $Id$
4
5 =head1 NAME
6
7 src/extend.c - Parrot extension interface
8
9 =head1 DESCRIPTION
99b337c start of actual extension routines and docs
Dan Sugalski authored
10
3e1f322 Inline docs update
Michael Scott authored
11 These are the functions that parrot extensions (i.e. parrot subroutines
12 written in C, or some other compiled language, rather than in parrot
13 bytecode) may access.
14
15 There is a deliberate distancing from the internals here. Don't go
16 peeking inside -- you've as much access as bytecode does, but no more,
17 so we can provide backwards compatibility for as long as we possibly
18 can.
19
20 =head2 Functions
21
22 */
99b337c start of actual extension routines and docs
Dan Sugalski authored
23
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
24 /* Some internal notes. Parrot will die a horrible and bizarre death
25 if the stack start pointer's not set and a DOD run is
26 triggered. The pointer *will* be set by the interpreter if the
27 interpreter calls code which calls these functions, so most
28 extension code is safe, no problem.
29
30 The problem comes in if these routines are called from *outside*
31 an interpreter. This happens when an embedding application calls
32 them to do stuff with PMCs, STRINGS, interpreter contents, and
33 suchlike things. This is perfectly legal -- in fact it's what
34 we've documented should be done -- but the problem is that the
35 stack base pointer will be NULL. This is Very Bad.
36
37 To deal with this there are two macros that are defined to handle
38 the problem.
39
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
40 PARROT_CALLIN_START(interp) will figure out if the stack
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
41 anchor needs setting and, if so, will set it. It must *always*
42 come immediately after the last variable declared in the block
43 making the calls into the interpreter, as it declares a variable
44 and has some code.
45
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
46 PARROT_CALLIN_END(interp) will put the stack anchor back to
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
47 the way it was, and should always be the last statement before a
48 return. (If you have multiple returns have it in multiple times)
49
50 Not doing this is a good way to introduce bizarre heisenbugs, so
51 just do it. This is the only place they ought to have to be put
52 in, and most of the functions are already written, so it's not
53 like it's an onerous requirement.
54
55 */
56
99b337c start of actual extension routines and docs
Dan Sugalski authored
57 #include "parrot/parrot.h"
58 #include "parrot/extend.h"
59
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
60 /* HEADER: include/parrot/extend.h */
df5e1a1 @petdance lie to the headerizer
petdance authored
61
3e1f322 Inline docs update
Michael Scott authored
62 /*
63
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
64 FUNCDOC: Parrot_PMC_get_string_intkey
9b7e2b7 Add missing Parrot_PMC_get_string_intkey function
Simon Glover authored
65
66 Return the integer keyed string value of the passed-in PMC
67
68 */
69
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
70 PARROT_API
71 Parrot_String
72 Parrot_PMC_get_string_intkey(Parrot_Interp interp /*NN*/,
73 Parrot_PMC pmc, Parrot_Int key)
74 {
ef4c70a @chromatic Sanitize external interface, mostly by changing Parrot_STRING to Parr…
chromatic authored
75 Parrot_String retval;
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
76 PARROT_CALLIN_START(interp);
77 retval = VTABLE_get_string_keyed_int(interp, pmc, key);
78 PARROT_CALLIN_END(interp);
79 return retval;
9b7e2b7 Add missing Parrot_PMC_get_string_intkey function
Simon Glover authored
80 }
81
82
83 /*
84
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
85 FUNCDOC: Parrot_PMC_get_pointer_intkey
3e1f322 Inline docs update
Michael Scott authored
86
87 Return the keyed, signed integer value of the value in the PMC.
88
89 */
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
90
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
91 PARROT_API
92 void *
93 Parrot_PMC_get_pointer_intkey(Parrot_Interp interp /*NN*/, Parrot_PMC pmc,
76c4c09 @chromatic [External] Explicitly export external API symbols.
chromatic authored
94 Parrot_Int key) {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
95 void *retval;
96 PARROT_CALLIN_START(interp);
97 retval = VTABLE_get_pointer_keyed_int(interp, pmc, key);
98 PARROT_CALLIN_END(interp);
99 return retval;
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
100 }
101
3e1f322 Inline docs update
Michael Scott authored
102 /*
103
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
104 FUNCDOC: Parrot_PMC_get_pmc_intkey
3e1f322 Inline docs update
Michael Scott authored
105
106 Return the integer keyed PMC value of the passed-in PMC
107
108 */
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
109
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
110 PARROT_API
111 Parrot_PMC
112 Parrot_PMC_get_pmc_intkey(Parrot_Interp interp /*NN*/,
113 Parrot_PMC pmc, Parrot_Int key)
114 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
115 Parrot_PMC retval;
116 PARROT_CALLIN_START(interp);
117 retval = VTABLE_get_pmc_keyed_int(interp, pmc, key);
118 PARROT_CALLIN_END(interp);
119 return retval;
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
120 }
121
3e1f322 Inline docs update
Michael Scott authored
122 /*
123
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
124 FUNCDOC: Parrot_PMC_get_intval
3e1f322 Inline docs update
Michael Scott authored
125
126 Return the signed integer value of the value in the PMC.
127
128 */
99b337c start of actual extension routines and docs
Dan Sugalski authored
129
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
130 PARROT_API
131 Parrot_Int
132 Parrot_PMC_get_intval(Parrot_Interp interp /*NN*/, Parrot_PMC pmc)
133 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
134 Parrot_Int retval;
135 PARROT_CALLIN_START(interp);
136 retval = VTABLE_get_integer(interp, pmc);
137 PARROT_CALLIN_END(interp);
138 return retval;
99b337c start of actual extension routines and docs
Dan Sugalski authored
139 }
140
3e1f322 Inline docs update
Michael Scott authored
141 /*
142
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
143 FUNCDOC: Parrot_PMC_get_intval_intkey
3e1f322 Inline docs update
Michael Scott authored
144
145 Return the keyed, signed integer value of the value in the PMC.
146
147 */
808faf0 Add integer keyed get/set for ints, for Ponie
Dan Sugalski authored
148
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
149 PARROT_API
150 Parrot_Int
151 Parrot_PMC_get_intval_intkey(Parrot_Interp interp /*NN*/,
152 Parrot_PMC pmc, Parrot_Int key)
153 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
154 Parrot_Int retval;
155 PARROT_CALLIN_START(interp);
156 retval = VTABLE_get_integer_keyed_int(interp, pmc, key);
157 PARROT_CALLIN_END(interp);
158 return retval;
808faf0 Add integer keyed get/set for ints, for Ponie
Dan Sugalski authored
159 }
160
3e1f322 Inline docs update
Michael Scott authored
161 /*
162
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
163 FUNCDOC: Parrot_PMC_get_intval_pmckey
5a3984a Expose VTABLE_get_integer_keyed, VTABLE_set_pmc_keyed and VTABLE_dele…
Nicholas Clark authored
164
165 Return the keyed, signed integer value of the value in the PMC.
166
167 */
168
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
169 PARROT_API
170 Parrot_Int
171 Parrot_PMC_get_intval_pmckey(Parrot_Interp interp /*NN*/,
172 Parrot_PMC pmc, Parrot_PMC key)
173 {
5a3984a Expose VTABLE_get_integer_keyed, VTABLE_set_pmc_keyed and VTABLE_dele…
Nicholas Clark authored
174 Parrot_Int retval;
175 PARROT_CALLIN_START(interp);
176 retval = VTABLE_get_integer_keyed(interp, pmc, key);
177 PARROT_CALLIN_END(interp);
178 return retval;
179 }
180
181 /*
182
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
183 FUNCDOC: Parrot_PMC_get_numval
3e1f322 Inline docs update
Michael Scott authored
184
185 Return the floating-point value of the PMC.
186
187 */
99b337c start of actual extension routines and docs
Dan Sugalski authored
188
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
189 PARROT_API
190 Parrot_Float
191 Parrot_PMC_get_numval(Parrot_Interp interp /*NN*/, Parrot_PMC pmc)
192 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
193 Parrot_Float retval;
194 PARROT_CALLIN_START(interp);
195 retval = VTABLE_get_number(interp, pmc);
196 PARROT_CALLIN_END(interp);
197 return retval;
fa999b0 First chunk of extension code done
Dan Sugalski authored
198 }
199
3e1f322 Inline docs update
Michael Scott authored
200 /*
201
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
202 FUNCDOC: Parrot_PMC_get_numval_intkey
3e1f322 Inline docs update
Michael Scott authored
203
204 Return the keyed, signed integer value of the value in the PMC.
205
206 */
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
207
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
208 PARROT_API
209 Parrot_Float
210 Parrot_PMC_get_numval_intkey(Parrot_Interp interp /*NN*/,
211 Parrot_PMC pmc, Parrot_Int key)
212 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
213 Parrot_Float retval;
214 PARROT_CALLIN_START(interp);
215 retval = VTABLE_get_number_keyed_int(interp, pmc, key);
216 PARROT_CALLIN_END(interp);
217 return retval;
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
218 }
219
3e1f322 Inline docs update
Michael Scott authored
220 /*
221
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
222 FUNCDOC: Parrot_PMC_get_cstring_intkey
3e1f322 Inline docs update
Michael Scott authored
223
224 Return a null-terminated string that represents the string value of the PMC.
225
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
226 Note that you must free this string with C<string_cstring_free()>!
227
3e1f322 Inline docs update
Michael Scott authored
228 */
229
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
230 PARROT_API
231 char *
232 Parrot_PMC_get_cstring_intkey(Parrot_Interp interp /*NN*/,
233 Parrot_PMC pmc, Parrot_Int key)
234 /* WARN_UNUSED, MALLOC */
235 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
236 STRING *intermediate;
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
237 char *retval;
238
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
239 PARROT_CALLIN_START(interp);
240 intermediate = VTABLE_get_string_keyed_int(interp, pmc, key);
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
241 retval = string_to_cstring(interp, intermediate);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
242 PARROT_CALLIN_END(interp);
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
243
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
244 return retval;
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
245 }
246
3e1f322 Inline docs update
Michael Scott authored
247 /*
248
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
249 FUNCDOC: Parrot_PMC_get_cstring
3e1f322 Inline docs update
Michael Scott authored
250
251 Return a null-terminated string that represents the string value of the PMC.
252
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
253 Note that you must free this string with C<string_cstring_free()>!
254
3e1f322 Inline docs update
Michael Scott authored
255 */
256
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
257 PARROT_API
258 char *
259 Parrot_PMC_get_cstring(Parrot_Interp interp /*NN*/, Parrot_PMC pmc)
260 /* MALLOC, WARN_UNUSED */
261 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
262 STRING *intermediate;
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
263 char *retval;
264
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
265 PARROT_CALLIN_START(interp);
266 intermediate = VTABLE_get_string(interp, pmc);
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
267 retval = string_to_cstring(interp, intermediate);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
268 PARROT_CALLIN_END(interp);
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
269
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
270 return retval;
fa999b0 First chunk of extension code done
Dan Sugalski authored
271 }
272
3e1f322 Inline docs update
Michael Scott authored
273 /*
274
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
275 FUNCDOC: Parrot_PMC_get_cstringn
3e1f322 Inline docs update
Michael Scott authored
276
277 Return a null-terminated string for the PMC, along with the length.
278
279 Yes, right now this is a bit of a cheat. It needs fixing, but without
280 disturbing the interface.
281
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
282 Note that you must free the string with C<string_cstring_free()>.
283
3e1f322 Inline docs update
Michael Scott authored
284 */
285
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
286 PARROT_API
287 char *
288 Parrot_PMC_get_cstringn(Parrot_Interp interp /*NN*/,
289 Parrot_PMC pmc, Parrot_Int *length /*NN*/)
290 /* WARN_UNUSED, MALLOC */
291 {
fa999b0 First chunk of extension code done
Dan Sugalski authored
292 char *retval;
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
293
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
294 PARROT_CALLIN_START(interp);
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
295 retval = string_to_cstring(interp, VTABLE_get_string(interp, pmc));
fa999b0 First chunk of extension code done
Dan Sugalski authored
296 *length = strlen(retval);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
297 PARROT_CALLIN_END(interp);
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
298
fa999b0 First chunk of extension code done
Dan Sugalski authored
299 return retval;
300 }
301
3e1f322 Inline docs update
Michael Scott authored
302 /*
303
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
304 FUNCDOC: Parrot_PMC_get_cstringn_intkey
3e1f322 Inline docs update
Michael Scott authored
305
306 Return a null-terminated string for the PMC, along with the length.
307
308 Yes, right now this is a bit of a cheat. It needs fixing, but without
309 disturbing the interface.
310
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
311 Note that you must free this string with C<string_cstring_free()>.
312
3e1f322 Inline docs update
Michael Scott authored
313 */
314
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
315 PARROT_API
316 char *
317 Parrot_PMC_get_cstringn_intkey(Parrot_Interp interp /*NN*/,
318 Parrot_PMC pmc, Parrot_Int *length /*NN*/, Parrot_Int key)
319 /* WARN_UNUSED, MALLOC */
320 {
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
321 char *retval;
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
322
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
323 PARROT_CALLIN_START(interp);
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
324 retval = string_to_cstring(interp,
d067bc6 @ambs 80's cuts.
ambs authored
325 VTABLE_get_string_keyed_int(interp, pmc, key));
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
326 *length = strlen(retval);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
327 PARROT_CALLIN_END(interp);
13ad730 @chromatic Free strings allocated with string_to_cstring().
chromatic authored
328
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
329 return retval;
330 }
331
3e1f322 Inline docs update
Michael Scott authored
332 /*
333
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
334 FUNCDOC: Parrot_PMC_set_string
3e1f322 Inline docs update
Michael Scott authored
335
336 Assign the passed-in Parrot string to the passed-in PMC.
337
338 */
339
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
340 PARROT_API
341 void
342 Parrot_PMC_set_string(Parrot_Interp interp /*NN*/,
343 Parrot_PMC pmc, Parrot_String value)
344 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
345 PARROT_CALLIN_START(interp);
fa999b0 First chunk of extension code done
Dan Sugalski authored
346 VTABLE_set_string_native(interp, pmc, value);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
347 PARROT_CALLIN_END(interp);
fa999b0 First chunk of extension code done
Dan Sugalski authored
348 }
349
3e1f322 Inline docs update
Michael Scott authored
350 /*
351
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
352 FUNCDOC: Parrot_PMC_set_string_intkey
3e1f322 Inline docs update
Michael Scott authored
353
354 Assign the passed-in Parrot string to the passed-in PMC.
355
356 */
357
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
358 PARROT_API
359 void
360 Parrot_PMC_set_string_intkey(Parrot_Interp interp /*NN*/,
361 Parrot_PMC pmc, Parrot_Int key, Parrot_String value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c heade…
petdance authored
362 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
363 PARROT_CALLIN_START(interp);
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
364 VTABLE_set_string_keyed_int(interp, pmc, key, value);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
365 PARROT_CALLIN_END(interp);
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
366 }
367
3e1f322 Inline docs update
Michael Scott authored
368 /*
369
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
370 FUNCDOC: Parrot_PMC_set_pmc_intkey
3e1f322 Inline docs update
Michael Scott authored
371
a2516e7 Transpose Parrot_PMC_set_pointer and Parrot_PMC_set_pmc_intkey to giv…
Nicholas Clark authored
372 Assign the passed-in pmc to the passed-in slot of the passed-in PMC.
3e1f322 Inline docs update
Michael Scott authored
373
374 */
375
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
376 PARROT_API
377 void
378 Parrot_PMC_set_pmc_intkey(Parrot_Interp interp /*NN*/,
379 Parrot_PMC pmc, Parrot_Int key, Parrot_PMC value)
380 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
381 PARROT_CALLIN_START(interp);
a2516e7 Transpose Parrot_PMC_set_pointer and Parrot_PMC_set_pmc_intkey to giv…
Nicholas Clark authored
382 VTABLE_set_pmc_keyed_int(interp, pmc, key, value);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
383 PARROT_CALLIN_END(interp);
cf4fa0b expose get/set pointer functions
Dan Sugalski authored
384 }
385
3e1f322 Inline docs update
Michael Scott authored
386 /*
387
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
388 FUNCDOC: Parrot_PMC_set_pmc_pmckey
5a3984a Expose VTABLE_get_integer_keyed, VTABLE_set_pmc_keyed and VTABLE_dele…
Nicholas Clark authored
389
390 Assign the passed-in pmc to the passed-in slot of the passed-in PMC.
391
392 */
393
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
394 PARROT_API
395 void
396 Parrot_PMC_set_pmc_pmckey(Parrot_Interp interp /*NN*/,
397 Parrot_PMC pmc, Parrot_PMC key, Parrot_PMC value)
398 {
5a3984a Expose VTABLE_get_integer_keyed, VTABLE_set_pmc_keyed and VTABLE_dele…
Nicholas Clark authored
399 PARROT_CALLIN_START(interp);
400 VTABLE_set_pmc_keyed(interp, pmc, key, value);
401 PARROT_CALLIN_END(interp);
402 }
403
404 /*
405
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
406 FUNCDOC: Parrot_PMC_set_pointer_intkey
3e1f322 Inline docs update
Michael Scott authored
407
408 Assign the passed-in pointer to the passed-in PMC.
409
410 */
411
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
412 PARROT_API
413 void
414 Parrot_PMC_set_pointer_intkey(Parrot_Interp interp /*NN*/,
415 Parrot_PMC pmc, Parrot_Int key, void *value)
416 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
417 PARROT_CALLIN_START(interp);
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
418 VTABLE_set_pointer_keyed_int(interp, pmc, key, value);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
419 PARROT_CALLIN_END(interp);
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
420 }
421
3e1f322 Inline docs update
Michael Scott authored
422 /*
423
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
424 FUNCDOC: Parrot_PMC_set_intval
3e1f322 Inline docs update
Michael Scott authored
425
426 Assign the passed-in Parrot integer to the passed-in PMC.
427
428 */
429
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
430 PARROT_API
431 void
432 Parrot_PMC_set_intval(Parrot_Interp interp /*NN*/, Parrot_PMC pmc, Parrot_Int value)
433 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
434 PARROT_CALLIN_START(interp);
fa999b0 First chunk of extension code done
Dan Sugalski authored
435 VTABLE_set_integer_native(interp, pmc, value);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
436 PARROT_CALLIN_END(interp);
fa999b0 First chunk of extension code done
Dan Sugalski authored
437 }
438
3e1f322 Inline docs update
Michael Scott authored
439 /*
440
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
441 FUNCDOC: Parrot_PMC_set_intval_intkey
3e1f322 Inline docs update
Michael Scott authored
442
443 Assign the passed-in Parrot integer to the passed-in PMC.
444
445 */
446
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
447 PARROT_API
448 void
449 Parrot_PMC_set_intval_intkey(Parrot_Interp interp /*NN*/,
450 Parrot_PMC pmc, Parrot_Int key, Parrot_Int value)
451 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
452 PARROT_CALLIN_START(interp);
808faf0 Add integer keyed get/set for ints, for Ponie
Dan Sugalski authored
453 VTABLE_set_integer_keyed_int(interp, pmc, key, value);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
454 PARROT_CALLIN_END(interp);
808faf0 Add integer keyed get/set for ints, for Ponie
Dan Sugalski authored
455 }
456
3e1f322 Inline docs update
Michael Scott authored
457 /*
458
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
459 FUNCDOC: Parrot_PMC_set_numval
3e1f322 Inline docs update
Michael Scott authored
460
461 Assign the passed-in Parrot number to the passed-in PMC.
462
463 */
464
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
465 PARROT_API
466 void
467 Parrot_PMC_set_numval(Parrot_Interp interp /*NN*/, Parrot_PMC pmc, Parrot_Float value)
468 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
469 PARROT_CALLIN_START(interp);
fa999b0 First chunk of extension code done
Dan Sugalski authored
470 VTABLE_set_number_native(interp, pmc, value);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
471 PARROT_CALLIN_END(interp);
fa999b0 First chunk of extension code done
Dan Sugalski authored
472 }
473
3e1f322 Inline docs update
Michael Scott authored
474 /*
475
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
476 FUNCDOC: Parrot_PMC_set_numval_intkey
3e1f322 Inline docs update
Michael Scott authored
477
478 Assign the passed-in Parrot number to the passed-in PMC.
479
480 */
481
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
482 PARROT_API
483 void
484 Parrot_PMC_set_numval_intkey(Parrot_Interp interp /*NN*/,
485 Parrot_PMC pmc, Parrot_Int key, Parrot_Float value)
486 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
487 PARROT_CALLIN_START(interp);
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
488 VTABLE_set_number_keyed_int(interp, pmc, key, value);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
489 PARROT_CALLIN_END(interp);
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
490 }
491
3e1f322 Inline docs update
Michael Scott authored
492 /*
493
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
494 Parrot_PMC_set_cstring
3e1f322 Inline docs update
Michael Scott authored
495
496 Assign the passed-in null-terminated C string to the passed-in PMC.
497
498 */
499
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
500 PARROT_API
501 void
502 Parrot_PMC_set_cstring(Parrot_Interp interp /*NN*/, Parrot_PMC pmc, const char *value)
503 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
504 PARROT_CALLIN_START(interp);
bf41b66 @particle [PDD07]: ws cleanup in src/, src/dynpmc/, and src/pmc/
particle authored
505 VTABLE_set_string_native(interp, pmc,
d067bc6 @ambs 80's cuts.
ambs authored
506 string_from_cstring(interp, value, 0));
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
507 PARROT_CALLIN_END(interp);
fa999b0 First chunk of extension code done
Dan Sugalski authored
508 }
509
3e1f322 Inline docs update
Michael Scott authored
510 /*
511
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
512 Parrot_PMC_set_cstring_intkey
3e1f322 Inline docs update
Michael Scott authored
513
514 Assign the passed-in null-terminated C string to the passed-in PMC.
515
516 */
517
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
518 PARROT_API
519 void
520 Parrot_PMC_set_cstring_intkey(Parrot_Interp interp /*NN*/,
521 Parrot_PMC pmc, Parrot_Int key, const char *value /*NN*/)
522 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
523 PARROT_CALLIN_START(interp);
bf41b66 @particle [PDD07]: ws cleanup in src/, src/dynpmc/, and src/pmc/
particle authored
524 VTABLE_set_string_keyed_int(interp, pmc, key,
d067bc6 @ambs 80's cuts.
ambs authored
525 string_from_cstring(interp, value, 0));
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
526 PARROT_CALLIN_END(interp);
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
527 }
528
3e1f322 Inline docs update
Michael Scott authored
529 /*
530
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
531 FUNCDOC: Parrot_PMC_set_cstringn
3e1f322 Inline docs update
Michael Scott authored
532
c03ee10 @chromatic r20350@windwheel: chromatic | 2006-08-19 13:49:15 -0700
chromatic authored
533 Assign the passed-in length-noted string to the passed-in PMC.
3e1f322 Inline docs update
Michael Scott authored
534
535 */
536
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
537 PARROT_API
538 void
539 Parrot_PMC_set_cstringn(Parrot_Interp interp /*NN*/,
540 Parrot_PMC pmc, const char *value, Parrot_Int length)
541 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
542 PARROT_CALLIN_START(interp);
bf41b66 @particle [PDD07]: ws cleanup in src/, src/dynpmc/, and src/pmc/
particle authored
543 VTABLE_set_string_native(interp, pmc,
d067bc6 @ambs 80's cuts.
ambs authored
544 string_from_cstring(interp, value, length));
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
545 PARROT_CALLIN_END(interp);
fa999b0 First chunk of extension code done
Dan Sugalski authored
546 }
547
3e1f322 Inline docs update
Michael Scott authored
548 /*
549
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
550 FUNCDOC: Parrot_PMC_push_intval
8bb4c95 Add 4 types of push to extend.h
Nicholas Clark authored
551
552 Push the passed-in Parrot integer onto the passed in PMC
553
554 */
555
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
556 PARROT_API
557 void
558 Parrot_PMC_push_intval(Parrot_Interp interp /*NN*/,
559 Parrot_PMC pmc, Parrot_Int value)
560 {
8bb4c95 Add 4 types of push to extend.h
Nicholas Clark authored
561 PARROT_CALLIN_START(interp);
562 VTABLE_push_integer(interp, pmc, value);
563 PARROT_CALLIN_END(interp);
564 }
565
566 /*
567
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
568 FUNCDOC: Parrot_PMC_push_numval
8bb4c95 Add 4 types of push to extend.h
Nicholas Clark authored
569
570 Push the passed-in Parrot number onto the passed in PMC
571
572 */
573
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
574 PARROT_API
575 void
576 Parrot_PMC_push_numval(Parrot_Interp interp /*NN*/,
577 Parrot_PMC pmc, Parrot_Float value)
578 {
8bb4c95 Add 4 types of push to extend.h
Nicholas Clark authored
579 PARROT_CALLIN_START(interp);
580 VTABLE_push_float(interp, pmc, value);
581 PARROT_CALLIN_END(interp);
582 }
583
584 /*
585
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
586 FUNCDOC: Parrot_PMC_delete_pmckey
5a3984a Expose VTABLE_get_integer_keyed, VTABLE_set_pmc_keyed and VTABLE_dele…
Nicholas Clark authored
587
588 Deletes the value associated with the passed-in PMC from the PMC.
589
590 */
591
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
592 PARROT_API
593 void
594 Parrot_PMC_delete_pmckey(Parrot_Interp interp /*NN*/,
595 Parrot_PMC pmc, Parrot_PMC key)
596 {
5a3984a Expose VTABLE_get_integer_keyed, VTABLE_set_pmc_keyed and VTABLE_dele…
Nicholas Clark authored
597 PARROT_CALLIN_START(interp);
598 VTABLE_delete_keyed(interp, pmc, key);
599 PARROT_CALLIN_END(interp);
600 }
601
602 /*
603
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
604 FUNCDOC: Parrot_PMC_set_cstringn_intkey
3e1f322 Inline docs update
Michael Scott authored
605
606 Assign the passed-in length-noted string to the passed-in PMC.
607
608 */
609
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
610 PARROT_API
611 void
612 Parrot_PMC_set_cstringn_intkey(Parrot_Interp interp /*NN*/,
613 Parrot_PMC pmc, Parrot_Int key, const char *value, Parrot_Int length)
614 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
615 PARROT_CALLIN_START(interp);
d067bc6 @ambs 80's cuts.
ambs authored
616 VTABLE_set_string_keyed_int(interp, pmc, key,
617 string_from_cstring(interp, value, length));
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
618 PARROT_CALLIN_END(interp);
6b2d2bf get/set intkey stuff for embedding
Dan Sugalski authored
619 }
620
3e1f322 Inline docs update
Michael Scott authored
621 /*
622
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
623 FUNCDOC: Parrot_PMC_new
3e1f322 Inline docs update
Michael Scott authored
624
625 Create and return a new PMC.
626
627 */
628
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
629 PARROT_API
630 Parrot_PMC
631 Parrot_PMC_new(Parrot_Interp interp /*NN*/, Parrot_Int type)
632 {
fa999b0 First chunk of extension code done
Dan Sugalski authored
633 Parrot_PMC newpmc;
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
634 PARROT_CALLIN_START(interp);
fa999b0 First chunk of extension code done
Dan Sugalski authored
635 newpmc = pmc_new_noinit(interp, type);
636 VTABLE_init(interp, newpmc);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
637 PARROT_CALLIN_END(interp);
fa999b0 First chunk of extension code done
Dan Sugalski authored
638 return newpmc;
639 }
640
3e1f322 Inline docs update
Michael Scott authored
641 /*
642
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
643 FUNCDOC: Parrot_PMC_typenum
3e1f322 Inline docs update
Michael Scott authored
644
645 Returns the internal identifier that represents the named class.
646
647 */
648
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
649 PARROT_API
650 Parrot_Int
651 Parrot_PMC_typenum(Parrot_Interp interp /*NN*/, const char *_class)
652 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
653 Parrot_Int retval;
654 PARROT_CALLIN_START(interp);
14ff6e9 @chromatic C++ cleanups; mostly variable name changes. (Steve Peters, RT #42584).
chromatic authored
655 retval = pmc_type(interp, string_from_cstring(interp, _class, 0));
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
656 PARROT_CALLIN_END(interp);
657 return retval;
fa999b0 First chunk of extension code done
Dan Sugalski authored
658 }
659
3e1f322 Inline docs update
Michael Scott authored
660 /*
661
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
662 Parrot_PMC_null
3e1f322 Inline docs update
Michael Scott authored
663
664 Returns the special C<NULL> PMC.
665
666 */
667
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
668 PARROT_API
669 Parrot_PMC
670 Parrot_PMC_null(void)
671 {
8deb08e Expose PMCNULL to extension API.
Melvin Smith authored
672 return PMCNULL;
673 }
674
3e1f322 Inline docs update
Michael Scott authored
675 /*
676
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
677 FUNCDOC: Parrot_free_cstring
3e1f322 Inline docs update
Michael Scott authored
678
679 Deallocate a C string that the interpreter has handed to you.
680
681 */
8deb08e Expose PMCNULL to extension API.
Melvin Smith authored
682
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
683 PARROT_API
684 void
685 Parrot_free_cstring(char *string)
686 {
fa999b0 First chunk of extension code done
Dan Sugalski authored
687 string_cstring_free(string);
99b337c start of actual extension routines and docs
Dan Sugalski authored
688 }
689
3e1f322 Inline docs update
Michael Scott authored
690 /*
691
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
692 FUNCDOC: Parrot_call_sub
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
693
c03ee10 @chromatic r20350@windwheel: chromatic | 2006-08-19 13:49:15 -0700
chromatic authored
694 Call a parrot subroutine with the given function signature. The first char in
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
695 C<signature> denotes the return value. Next chars are arguments.
696
697 The return value of this function can be void or a pointer type.
698
699 Signature chars are:
700
701 v ... void return
702 I ... Parrot_Int
703 N ... Parrot_Float
ef4c70a @chromatic Sanitize external interface, mostly by changing Parrot_STRING to Parr…
chromatic authored
704 S ... Parrot_String
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
705 P ... Parrot_PMC
706
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
707 FUNCDOC: Parrot_call_sub_ret_int
3e1f322 Inline docs update
Michael Scott authored
708
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
709 FUNCDOC: Parrot_call_sub_ret_float
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
710
711 Like above, with Parrot_Int or Parrot_Float return result.
3e1f322 Inline docs update
Michael Scott authored
712
713 */
714
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
715 PARROT_API
716 void*
717 Parrot_call_sub(Parrot_Interp interp /*NN*/, Parrot_PMC sub,
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
718 const char *signature, ...)
719 {
3b31e02 More extension stuff at least partially stubbed out
Dan Sugalski authored
720 va_list ap;
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
721 void *result;
722
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
723 PARROT_CALLIN_START(interp);
3b31e02 More extension stuff at least partially stubbed out
Dan Sugalski authored
724
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
725 va_start(ap, signature);
839e959 @chromatic [REVERT] Reverted accidentally-committed code from r18635.
chromatic authored
726 CONTEXT(interp->ctx)->constants =
727 PMC_sub(sub)->seg->const_table->constants;
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
728 result = Parrot_runops_fromc_arglist(interp, sub, signature, ap);
3b31e02 More extension stuff at least partially stubbed out
Dan Sugalski authored
729 va_end(ap);
730
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
731 PARROT_CALLIN_END(interp);
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
732 return result;
733 }
734
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
735 PARROT_API
736 Parrot_Int
737 Parrot_call_sub_ret_int(Parrot_Interp interp /*NN*/, Parrot_PMC sub,
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
738 const char *signature, ...)
739 {
740 va_list ap;
741 Parrot_Int result;
742
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
743 PARROT_CALLIN_START(interp);
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
744
745 va_start(ap, signature);
fd76940 @jnthn Make sure the constants table pointer in the context is set correctly…
jnthn authored
746 CONTEXT(interp->ctx)->constants =
747 PMC_sub(sub)->seg->const_table->constants;
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
748 result = Parrot_runops_fromc_arglist_reti(interp, sub, signature, ap);
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
749 va_end(ap);
abe6ef8 Run a subroutine in Parrot_call
Leopold Toetsch authored
750
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
751 PARROT_CALLIN_END(interp);
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
752 return result;
753 }
754
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
755 PARROT_API
756 Parrot_Float
757 Parrot_call_sub_ret_float(Parrot_Interp interp /*NN*/, Parrot_PMC sub,
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
758 const char *signature, ...)
759 {
760 va_list ap;
761 Parrot_Float result;
762
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
763 PARROT_CALLIN_START(interp);
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
764
765 va_start(ap, signature);
fd76940 @jnthn Make sure the constants table pointer in the context is set correctly…
jnthn authored
766 CONTEXT(interp->ctx)->constants =
767 PMC_sub(sub)->seg->const_table->constants;
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
768 result = Parrot_runops_fromc_arglist_retf(interp, sub, signature, ap);
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
769 va_end(ap);
770
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
771 PARROT_CALLIN_END(interp);
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
772 return result;
3b31e02 More extension stuff at least partially stubbed out
Dan Sugalski authored
773 }
774
3e1f322 Inline docs update
Michael Scott authored
775 /*
776
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
777 FUNCDOC: Parrot_call_method
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
778
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
779 FUNCDOC: Parrot_call_method_ret_int
3e1f322 Inline docs update
Michael Scott authored
780
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
781 FUNCDOC: Parrot_call_method_ret_float
3e1f322 Inline docs update
Michael Scott authored
782
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
783 Call a parrot method for the given object.
3e1f322 Inline docs update
Michael Scott authored
784
785 */
786
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
787 PARROT_API
788 void *
789 Parrot_call_method(Parrot_Interp interp /*NN*/, Parrot_PMC sub, Parrot_PMC obj,
ef4c70a @chromatic Sanitize external interface, mostly by changing Parrot_STRING to Parr…
chromatic authored
790 Parrot_String method, const char *signature, ...)
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
791 {
792 void *result;
793 va_list ap;
794
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
795 PARROT_CALLIN_START(interp);
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
796 va_start(ap, signature);
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
797 result = Parrot_run_meth_fromc_arglist(interp, sub,
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
798 obj, method, signature, ap);
799 va_end(ap);
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
800 PARROT_CALLIN_END(interp);
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
801 return result;
802 }
803
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
804 PARROT_API
805 Parrot_Int
806 Parrot_call_method_ret_int(Parrot_Interp interp /*NN*/, Parrot_PMC sub,
ef4c70a @chromatic Sanitize external interface, mostly by changing Parrot_STRING to Parr…
chromatic authored
807 Parrot_PMC obj, Parrot_String method, const char *signature, ...)
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
808 {
809 Parrot_Int result;
810 va_list ap;
811
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
812 PARROT_CALLIN_START(interp);
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
813 va_start(ap, signature);
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
814 result = Parrot_run_meth_fromc_arglist_reti(interp, sub,
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
815 obj, method, signature, ap);
816 va_end(ap);
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
817 PARROT_CALLIN_END(interp);
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
818 return result;
819 }
820
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
821 PARROT_API
822 Parrot_Float
823 Parrot_call_method_ret_float(Parrot_Interp interp /*NN*/, Parrot_PMC sub,
ef4c70a @chromatic Sanitize external interface, mostly by changing Parrot_STRING to Parr…
chromatic authored
824 Parrot_PMC obj, Parrot_String method, const char *signature, ...)
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
825 {
826 Parrot_Float result;
827 va_list ap;
828
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
829 PARROT_CALLIN_START(interp);
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
830 va_start(ap, signature);
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
831 result = Parrot_run_meth_fromc_arglist_retf(interp, sub,
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
832 obj, method, signature, ap);
833 va_end(ap);
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
834 PARROT_CALLIN_END(interp);
7decdbe changed extend.c:Parrot_call
Leopold Toetsch authored
835 return result;
3b31e02 More extension stuff at least partially stubbed out
Dan Sugalski authored
836 }
837
3e1f322 Inline docs update
Michael Scott authored
838 /*
839
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
840 FUNCDOC: Parrot_get_intreg
3e1f322 Inline docs update
Michael Scott authored
841
842 Return the value of an integer register.
843
844 */
3b31e02 More extension stuff at least partially stubbed out
Dan Sugalski authored
845
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
846 PARROT_API
847 Parrot_Int
848 Parrot_get_intreg(Parrot_Interp interp /*NN*/, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c heade…
petdance authored
849 {
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
850 return REG_INT(regnum);
851 }
852
3e1f322 Inline docs update
Michael Scott authored
853 /*
854
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
855 FUNCDOC: Parrot_get_numreg
3e1f322 Inline docs update
Michael Scott authored
856
857 Return the value of a numeric register.
858
859 */
860
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
861 PARROT_API
862 Parrot_Float
863 Parrot_get_numreg(Parrot_Interp interp /*NN*/, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c heade…
petdance authored
864 {
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
865 return REG_NUM(regnum);
866 }
867
3e1f322 Inline docs update
Michael Scott authored
868 /*
869
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
870 FUNCDOC: Parrot_get_strreg
3e1f322 Inline docs update
Michael Scott authored
871
872 Return the value of a string register.
873
874 */
875
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
876 PARROT_API
877 Parrot_String
878 Parrot_get_strreg(Parrot_Interp interp /*NN*/, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c heade…
petdance authored
879 {
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
880 return REG_STR(regnum);
881 }
882
3e1f322 Inline docs update
Michael Scott authored
883 /*
884
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
885 FUNCDOC: Parrot_get_pmcreg
3e1f322 Inline docs update
Michael Scott authored
886
887 Return the value of a PMC register.
888
889 */
890
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
891 PARROT_API
892 Parrot_PMC
893 Parrot_get_pmcreg(Parrot_Interp interp /*NN*/, Parrot_Int regnum)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c heade…
petdance authored
894 {
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
895 return REG_PMC(regnum);
896 }
897
3e1f322 Inline docs update
Michael Scott authored
898 /*
899
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
900 FUNCDOC: Parrot_set_intreg
3e1f322 Inline docs update
Michael Scott authored
901
902 Set the value of an I register.
903
904 */
905
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
906 PARROT_API
907 void
908 Parrot_set_intreg(Parrot_Interp interp /*NN*/, Parrot_Int regnum,
d067bc6 @ambs 80's cuts.
ambs authored
909 Parrot_Int value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c heade…
petdance authored
910 {
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
911 REG_INT(regnum) = value;
912 }
913
3e1f322 Inline docs update
Michael Scott authored
914 /*
915
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
916 FUNCDOC: Parrot_set_numreg
3e1f322 Inline docs update
Michael Scott authored
917
918 Set the value of an N register.
919
920 */
921
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
922 PARROT_API
923 void
924 Parrot_set_numreg(Parrot_Interp interp /*NN*/, Parrot_Int regnum,
d067bc6 @ambs 80's cuts.
ambs authored
925 Parrot_Float value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c heade…
petdance authored
926 {
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
927 REG_NUM(regnum) = value;
928 }
929
3e1f322 Inline docs update
Michael Scott authored
930 /*
931
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
932 Parrot_set_strreg
3e1f322 Inline docs update
Michael Scott authored
933
934 Set the value of an S register.
935
936 */
937
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
938 PARROT_API
939 void
940 Parrot_set_strreg(Parrot_Interp interp /*NN*/, Parrot_Int regnum,
ef4c70a @chromatic Sanitize external interface, mostly by changing Parrot_STRING to Parr…
chromatic authored
941 Parrot_String value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c heade…
petdance authored
942 {
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
943 REG_STR(regnum) = value;
944 }
945
3e1f322 Inline docs update
Michael Scott authored
946 /*
947
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
948 FUNCDOC: Parrot_set_pmcreg
3e1f322 Inline docs update
Michael Scott authored
949
950 Set the value of a P register.
951
952 */
953
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
954 PARROT_API
955 void
956 Parrot_set_pmcreg(Parrot_Interp interp /*NN*/, Parrot_Int regnum,
d067bc6 @ambs 80's cuts.
ambs authored
957 Parrot_PMC value)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c heade…
petdance authored
958 {
b4bdfa8 Stub in some new object manipulation methods, and some extension rout…
Dan Sugalski authored
959 REG_PMC(regnum) = value;
960 }
961
000d780 Add in some string construction functions
Dan Sugalski authored
962 /*=for api extend Parrot_new_string
963 *
964 */
3e1f322 Inline docs update
Michael Scott authored
965 /*
966
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
967 FUNCDOC: Parrot_new_string
3e1f322 Inline docs update
Michael Scott authored
968
3a348a0 anchor overflow array immediately
Leopold Toetsch authored
969 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
970 flags for right now.
3e1f322 Inline docs update
Michael Scott authored
971
972 A copy of the buffer is made.
973
974 */
975
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
976 PARROT_API
977 Parrot_String
978 Parrot_new_string(Parrot_Interp interp /*NN*/, char *buffer, int length,
979 const char * const encoding_name, Parrot_Int flags)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c heade…
petdance authored
980 {
ef4c70a @chromatic Sanitize external interface, mostly by changing Parrot_STRING to Parr…
chromatic authored
981 Parrot_String retval;
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
982 PARROT_CALLIN_START(interp);
983 retval = string_make(interp, buffer, length, encoding_name, flags);
984 PARROT_CALLIN_END(interp);
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
985 return retval;
000d780 Add in some string construction functions
Dan Sugalski authored
986 }
987
3e1f322 Inline docs update
Michael Scott authored
988 /*
989
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
990 FUNCDOC: Parrot_find_language
3e1f322 Inline docs update
Michael Scott authored
991
992 Find the magic language token for a language, by language name.
993
994 */
995
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
996 PARROT_API
997 Parrot_Language
998 Parrot_find_language(Parrot_Interp interp /*NN*/, char *language)
831ff97 @petdance Added check to headerizer to check sanity of parms. Tweaked *.c heade…
petdance authored
999 {
000d780 Add in some string construction functions
Dan Sugalski authored
1000 return 0;
1001 }
1002
3e1f322 Inline docs update
Michael Scott authored
1003 /*
1004
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
1005 FUNCDOC: Parrot_register_pmc
3e1f322 Inline docs update
Michael Scott authored
1006
1007 Add a reference of the PMC to the interpreters DOD registry. This
1008 prevents PMCs only known to extension from getting destroyed during DOD
1009 runs.
1010
1011 */
9b7b3de register ops
Leopold Toetsch authored
1012
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
1013 PARROT_API
1014 void
1015 Parrot_register_pmc(Parrot_Interp interp /*NN*/, Parrot_PMC pmc)
9b7b3de register ops
Leopold Toetsch authored
1016 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
1017 PARROT_CALLIN_START(interp);
1018 dod_register_pmc(interp, pmc);
1019 PARROT_CALLIN_END(interp);
9b7b3de register ops
Leopold Toetsch authored
1020 }
1021
3e1f322 Inline docs update
Michael Scott authored
1022 /*
1023
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
1024 FUNCDOC: Parrot_unregister_pmc
3e1f322 Inline docs update
Michael Scott authored
1025
80ba927 @bschmalhofer Fix a few spelling and punctuation errors.
bschmalhofer authored
1026 Remove a reference of the PMC from the interpreters DOD registry. If the
8fee6c9 Fix typos
Simon Glover authored
1027 reference count reaches zero, the PMC will be destroyed during the next
3e1f322 Inline docs update
Michael Scott authored
1028 DOD run.
1029
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
1030 FUNCDOC: Parrot_get_dod_registry
abc112d new AddrRegistry PMC class
Leopold Toetsch authored
1031
1032 Return Parrot's internal DOD registry PMC.
f474cd7 @bschmalhofer [perl #38235] Rename (dyn)?classes to (dyn)?pmc
bschmalhofer authored
1033 See also: F<src/pmc/addrregistry.pmc>.
abc112d new AddrRegistry PMC class
Leopold Toetsch authored
1034
3e1f322 Inline docs update
Michael Scott authored
1035 */
9b7b3de register ops
Leopold Toetsch authored
1036
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
1037 PARROT_API
1038 void
1039 Parrot_unregister_pmc(Parrot_Interp interp /*NN*/, Parrot_PMC pmc)
9b7b3de register ops
Leopold Toetsch authored
1040 {
ffd5c6d Make the extension interface set stacktop right when it needs to so
Dan Sugalski authored
1041 PARROT_CALLIN_START(interp);
1042 dod_unregister_pmc(interp, pmc);
1043 PARROT_CALLIN_END(interp);
9b7b3de register ops
Leopold Toetsch authored
1044 }
1045
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
1046 PARROT_API
1047 Parrot_PMC
1048 Parrot_get_dod_registry(Parrot_Interp interp /*NN*/)
abc112d new AddrRegistry PMC class
Leopold Toetsch authored
1049 {
1050 PMC *registry = interp->DOD_registry;
1051 PARROT_CALLIN_START(interp);
1052 if (!registry) {
1053 registry = interp->DOD_registry =
1054 pmc_new(interp, enum_class_AddrRegistry);
1055 }
1056 PARROT_CALLIN_END(interp);
1057 return registry;
1058 }
1059
99b337c start of actual extension routines and docs
Dan Sugalski authored
1060 /*
3e1f322 Inline docs update
Michael Scott authored
1061
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
1062 FUNCDOC: Parrot_pmc_set_vtable
379f65b [perl #31112] [PATCH] Add --include directive to pmc2c2.pl
Leopold Toetsch authored
1063
1064 Replaces the vtable of the PMC.
1065
1066 */
1067
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
1068 PARROT_API
1069 void
1070 Parrot_PMC_set_vtable(Parrot_Interp interp /*NN*/,
1071 Parrot_PMC pmc, Parrot_VTABLE vtable)
379f65b [perl #31112] [PATCH] Add --include directive to pmc2c2.pl
Leopold Toetsch authored
1072 {
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
1073 UNUSED(interp);
1074
379f65b [perl #31112] [PATCH] Add --include directive to pmc2c2.pl
Leopold Toetsch authored
1075 pmc->vtable = vtable;
1076 }
1077
1078 /*
1079
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
1080 FUNCDOC: Parrot_get_vtable
379f65b [perl #31112] [PATCH] Add --include directive to pmc2c2.pl
Leopold Toetsch authored
1081
1082 Returns the vtable corresponding to the given PMC ID.
1083
1084 */
1085
be68e0d @petdance Headerized extend.h and extend.c
petdance authored
1086 PARROT_API
1087 Parrot_VTABLE
1088 Parrot_get_vtable(const Parrot_Interp interp /*NN*/, Parrot_Int id)
1089 /* PURE, WARN_UNUSED */
379f65b [perl #31112] [PATCH] Add --include directive to pmc2c2.pl
Leopold Toetsch authored
1090 {
3240c6e @chipdude Consistently name interpreter "interp" instead of "interpreter".
chipdude authored
1091 return interp->vtables[id];
379f65b [perl #31112] [PATCH] Add --include directive to pmc2c2.pl
Leopold Toetsch authored
1092 }
1093
1094 /*
1095
3e1f322 Inline docs update
Michael Scott authored
1096 =head1 SEE ALSO
1097
0ba0e8a Remove extend.pod; superseded by PDD11
Simon Glover authored
1098 See F<include/parrot/extend.h> and F<docs/pdds/pdd11_extending.pod>.
3e1f322 Inline docs update
Michael Scott authored
1099
1100 =head1 HISTORY
1101
1102 Initial version by Dan Sugalski.
1103
1104 */
1105
2a130ef @particle [PDD07]:
particle authored
1106
3e1f322 Inline docs update
Michael Scott authored
1107 /*
99b337c start of actual extension routines and docs
Dan Sugalski authored
1108 * Local variables:
2a130ef @particle [PDD07]:
particle authored
1109 * c-file-style: "parrot"
99b337c start of actual extension routines and docs
Dan Sugalski authored
1110 * End:
1111 * vim: expandtab shiftwidth=4:
1112 */
Something went wrong with that request. Please try again.