2 Copyright (C) 2001-2003, The Perl Foundation.
7 src/extend.c - Parrot extension interface
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
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
28 /* Some internal notes. Parrot will die a horrible and bizarre death
29 if the stack start pointer's not set and a DOD run is
30 triggered. The pointer *will* be set by the interpreter if the
31 interpreter calls code which calls these functions, so most
32 extension code is safe, no problem.
34 The problem comes in if these routines are called from *outside*
35 an interpreter. This happens when an embedding application calls
36 them to do stuff with PMCs, STRINGS, interpreter contents, and
37 suchlike things. This is perfectly legal -- in fact it's what
38 we've documented should be done -- but the problem is that the
39 stack base pointer will be NULL. This is Very Bad.
41 To deal with this there are two macros that are defined to handle
44 PARROT_CALLIN_START(interpreter) will figure out if the stack
45 anchor needs setting and, if so, will set it. It must *always*
46 come immediately after the last variable declared in the block
47 making the calls into the interpreter, as it declares a variable
50 PARROT_CALLIN_END(interpreter) will put the stack anchor back to
51 the way it was, and should always be the last statement before a
52 return. (If you have multiple returns have it in multiple times)
54 Not doing this is a good way to introduce bizarre heisenbugs, so
55 just do it. This is the only place they ought to have to be put
56 in, and most of the functions are already written, so it's not
57 like it's an onerous requirement.
61 #include "parrot/parrot.h"
62 #include "parrot/extend.h"
67 Parrot_PMC_get_string_intkey(Parrot_INTERP interp, Parrot_PMC pmc,
70 Return the integer keyed string value of the passed-in PMC
76 Parrot_STRING
Parrot_PMC_get_string_intkey(Parrot_INTERP interp
,
77 Parrot_PMC pmc
, Parrot_Int key
) {
79 PARROT_CALLIN_START(interp
);
80 retval
= VTABLE_get_string_keyed_int(interp
, pmc
, key
);
81 PARROT_CALLIN_END(interp
);
89 Parrot_PMC_get_pointer_intkey(Parrot_INTERP interp, Parrot_PMC pmc,
92 Return the keyed, signed integer value of the value in the PMC.
98 void *Parrot_PMC_get_pointer_intkey(Parrot_INTERP interp
, Parrot_PMC pmc
,
101 PARROT_CALLIN_START(interp
);
102 retval
= VTABLE_get_pointer_keyed_int(interp
, pmc
, key
);
103 PARROT_CALLIN_END(interp
);
110 Parrot_PMC_get_pmc_intkey(Parrot_INTERP interp, Parrot_PMC pmc, Parrot_Int key)>
112 Return the integer keyed PMC value of the passed-in PMC
118 Parrot_PMC
Parrot_PMC_get_pmc_intkey(Parrot_INTERP interp
, Parrot_PMC pmc
,
121 PARROT_CALLIN_START(interp
);
122 retval
= VTABLE_get_pmc_keyed_int(interp
, pmc
, key
);
123 PARROT_CALLIN_END(interp
);
130 Parrot_PMC_get_intval(Parrot_INTERP interp, Parrot_PMC pmc)>
132 Return the signed integer value of the value in the PMC.
138 Parrot_Int
Parrot_PMC_get_intval(Parrot_INTERP interp
, Parrot_PMC pmc
) {
140 PARROT_CALLIN_START(interp
);
141 retval
= VTABLE_get_integer(interp
, pmc
);
142 PARROT_CALLIN_END(interp
);
149 Parrot_PMC_get_intval_intkey(Parrot_INTERP interp, Parrot_PMC pmc,
152 Return the keyed, signed integer value of the value in the PMC.
158 Parrot_Int
Parrot_PMC_get_intval_intkey(Parrot_INTERP interp
, Parrot_PMC pmc
,
161 PARROT_CALLIN_START(interp
);
162 retval
= VTABLE_get_integer_keyed_int(interp
, pmc
, key
);
163 PARROT_CALLIN_END(interp
);
170 Parrot_PMC_get_intval_pmckey(Parrot_INTERP interp, Parrot_PMC pmc,
173 Return the keyed, signed integer value of the value in the PMC.
179 Parrot_Int
Parrot_PMC_get_intval_pmckey(Parrot_INTERP interp
, Parrot_PMC pmc
,
182 PARROT_CALLIN_START(interp
);
183 retval
= VTABLE_get_integer_keyed(interp
, pmc
, key
);
184 PARROT_CALLIN_END(interp
);
191 Parrot_PMC_get_numval(Parrot_INTERP interp, Parrot_PMC pmc)>
193 Return the floating-point value of the PMC.
199 Parrot_Float
Parrot_PMC_get_numval(Parrot_INTERP interp
, Parrot_PMC pmc
) {
201 PARROT_CALLIN_START(interp
);
202 retval
= VTABLE_get_number(interp
, pmc
);
203 PARROT_CALLIN_END(interp
);
210 Parrot_PMC_get_numval_intkey(Parrot_INTERP interp, Parrot_PMC pmc,
213 Return the keyed, signed integer value of the value in the PMC.
219 Parrot_Float
Parrot_PMC_get_numval_intkey(Parrot_INTERP interp
, Parrot_PMC pmc
,
222 PARROT_CALLIN_START(interp
);
223 retval
= VTABLE_get_number_keyed_int(interp
, pmc
, key
);
224 PARROT_CALLIN_END(interp
);
231 Parrot_PMC_get_cstring_intkey(Parrot_INTERP interp, Parrot_PMC pmc,
234 Return a null-terminated string that represents the string value of the PMC.
240 char *Parrot_PMC_get_cstring_intkey(Parrot_INTERP interp
, Parrot_PMC pmc
,
242 STRING
*intermediate
;
244 PARROT_CALLIN_START(interp
);
245 intermediate
= VTABLE_get_string_keyed_int(interp
, pmc
, key
);
246 retval
= string_to_cstring(interp
, intermediate
);
247 PARROT_CALLIN_END(interp
);
253 =item C<char *Parrot_PMC_get_cstring(Parrot_INTERP interp, Parrot_PMC pmc)>
255 Return a null-terminated string that represents the string value of the PMC.
261 char *Parrot_PMC_get_cstring(Parrot_INTERP interp
, Parrot_PMC pmc
) {
262 STRING
*intermediate
;
264 PARROT_CALLIN_START(interp
);
265 intermediate
= VTABLE_get_string(interp
, pmc
);
266 retval
= string_to_cstring(interp
, intermediate
);
267 PARROT_CALLIN_END(interp
);
274 Parrot_PMC_get_cstringn(Parrot_INTERP interp, Parrot_PMC pmc,
277 Return a null-terminated string for the PMC, along with the length.
279 Yes, right now this is a bit of a cheat. It needs fixing, but without
280 disturbing the interface.
286 char *Parrot_PMC_get_cstringn(Parrot_INTERP interp
, Parrot_PMC pmc
,
287 Parrot_Int
*length
) {
289 PARROT_CALLIN_START(interp
);
290 retval
= string_to_cstring(interp
, VTABLE_get_string(interp
, pmc
));
291 *length
= strlen(retval
);
292 PARROT_CALLIN_END(interp
);
299 Parrot_PMC_get_cstringn_intkey(Parrot_INTERP interp, Parrot_PMC pmc,
300 Parrot_Int *length, Parrot_Int key)>
302 Return a null-terminated string for the PMC, along with the length.
304 Yes, right now this is a bit of a cheat. It needs fixing, but without
305 disturbing the interface.
311 char *Parrot_PMC_get_cstringn_intkey(Parrot_INTERP interp
, Parrot_PMC pmc
,
312 Parrot_Int
*length
, Parrot_Int key
) {
314 PARROT_CALLIN_START(interp
);
315 retval
= string_to_cstring(interp
,
316 VTABLE_get_string_keyed_int(interp
, pmc
, key
));
317 *length
= strlen(retval
);
318 PARROT_CALLIN_END(interp
);
325 Parrot_PMC_set_string(Parrot_INTERP interp, Parrot_PMC pmc,
326 Parrot_STRING value)>
328 Assign the passed-in Parrot string to the passed-in PMC.
335 Parrot_PMC_set_string(Parrot_INTERP interp
, Parrot_PMC pmc
,
336 Parrot_STRING value
) {
337 PARROT_CALLIN_START(interp
);
338 VTABLE_set_string_native(interp
, pmc
, value
);
339 PARROT_CALLIN_END(interp
);
345 Parrot_PMC_set_string_intkey(Parrot_INTERP interp, Parrot_PMC pmc,
346 Parrot_Int key, Parrot_STRING value)>
348 Assign the passed-in Parrot string to the passed-in PMC.
355 Parrot_PMC_set_string_intkey(Parrot_INTERP interp
, Parrot_PMC pmc
,
356 Parrot_Int key
, Parrot_STRING value
)
358 PARROT_CALLIN_START(interp
);
359 VTABLE_set_string_keyed_int(interp
, pmc
, key
, value
);
360 PARROT_CALLIN_END(interp
);
366 Parrot_PMC_set_pmc_intkey(Parrot_INTERP interp, Parrot_PMC pmc,
367 Parrot_Int key, Parrot_PMC value)>
369 Assign the passed-in pmc to the passed-in slot of the passed-in PMC.
376 Parrot_PMC_set_pmc_intkey(Parrot_INTERP interp
, Parrot_PMC pmc
,
377 Parrot_Int key
, Parrot_PMC value
) {
378 PARROT_CALLIN_START(interp
);
379 VTABLE_set_pmc_keyed_int(interp
, pmc
, key
, value
);
380 PARROT_CALLIN_END(interp
);
386 Parrot_PMC_set_pmc_pmckey(Parrot_INTERP interp, Parrot_PMC pmc,
387 Parrot_PMC key, Parrot_PMC value)>
389 Assign the passed-in pmc to the passed-in slot of the passed-in PMC.
396 Parrot_PMC_set_pmc_pmckey(Parrot_INTERP interp
, Parrot_PMC pmc
,
397 Parrot_PMC key
, Parrot_PMC value
) {
398 PARROT_CALLIN_START(interp
);
399 VTABLE_set_pmc_keyed(interp
, pmc
, key
, value
);
400 PARROT_CALLIN_END(interp
);
406 Parrot_PMC_set_pointer_intkey(Parrot_INTERP interp, Parrot_PMC pmc,
407 Parrot_Int key, void *value)>
409 Assign the passed-in pointer to the passed-in PMC.
416 Parrot_PMC_set_pointer_intkey(Parrot_INTERP interp
, Parrot_PMC pmc
,
417 Parrot_Int key
, void *value
) {
418 PARROT_CALLIN_START(interp
);
419 VTABLE_set_pointer_keyed_int(interp
, pmc
, key
, value
);
420 PARROT_CALLIN_END(interp
);
426 Parrot_PMC_set_intval(Parrot_INTERP interp, Parrot_PMC pmc, Parrot_Int value)>
428 Assign the passed-in Parrot integer to the passed-in PMC.
435 Parrot_PMC_set_intval(Parrot_INTERP interp
, Parrot_PMC pmc
, Parrot_Int value
) {
436 PARROT_CALLIN_START(interp
);
437 VTABLE_set_integer_native(interp
, pmc
, value
);
438 PARROT_CALLIN_END(interp
);
444 Parrot_PMC_set_intval_intkey(Parrot_INTERP interp, Parrot_PMC pmc,
445 Parrot_Int key, Parrot_Int value)>
447 Assign the passed-in Parrot integer to the passed-in PMC.
454 Parrot_PMC_set_intval_intkey(Parrot_INTERP interp
, Parrot_PMC pmc
,
455 Parrot_Int key
, Parrot_Int value
) {
456 PARROT_CALLIN_START(interp
);
457 VTABLE_set_integer_keyed_int(interp
, pmc
, key
, value
);
458 PARROT_CALLIN_END(interp
);
464 Parrot_PMC_set_numval(Parrot_INTERP interp, Parrot_PMC pmc, Parrot_Float value)>
466 Assign the passed-in Parrot number to the passed-in PMC.
473 Parrot_PMC_set_numval(Parrot_INTERP interp
, Parrot_PMC pmc
, Parrot_Float value
){
474 PARROT_CALLIN_START(interp
);
475 VTABLE_set_number_native(interp
, pmc
, value
);
476 PARROT_CALLIN_END(interp
);
482 Parrot_PMC_set_numval_intkey(Parrot_INTERP interp, Parrot_PMC pmc,
483 Parrot_Int key, Parrot_Float value)>
485 Assign the passed-in Parrot number to the passed-in PMC.
492 Parrot_PMC_set_numval_intkey(Parrot_INTERP interp
, Parrot_PMC pmc
,
493 Parrot_Int key
, Parrot_Float value
) {
494 PARROT_CALLIN_START(interp
);
495 VTABLE_set_number_keyed_int(interp
, pmc
, key
, value
);
496 PARROT_CALLIN_END(interp
);
502 Parrot_PMC_set_cstring(Parrot_INTERP interp, Parrot_PMC pmc, const char *value)>
504 Assign the passed-in null-terminated C string to the passed-in PMC.
511 Parrot_PMC_set_cstring(Parrot_INTERP interp
, Parrot_PMC pmc
, const char *value
){
512 PARROT_CALLIN_START(interp
);
513 VTABLE_set_string_native(interp
, pmc
,
514 string_from_cstring(interp
, value
, 0));
515 PARROT_CALLIN_END(interp
);
521 Parrot_PMC_set_cstring_intkey(Parrot_INTERP interp, Parrot_PMC pmc,
522 Parrot_Int key, const char *value)>
524 Assign the passed-in null-terminated C string to the passed-in PMC.
531 Parrot_PMC_set_cstring_intkey(Parrot_INTERP interp
, Parrot_PMC pmc
,
532 Parrot_Int key
, const char *value
) {
533 PARROT_CALLIN_START(interp
);
534 VTABLE_set_string_keyed_int(interp
, pmc
, key
,
535 string_from_cstring(interp
, value
, 0));
536 PARROT_CALLIN_END(interp
);
542 Parrot_PMC_set_cstringn(Parrot_INTERP interp, Parrot_PMC pmc,
543 const char *value, Parrot_Int length)>
545 Assign the passed-in length-noted string to the passed-in PMC.
552 Parrot_PMC_set_cstringn(Parrot_INTERP interp
, Parrot_PMC pmc
,
553 const char *value
, Parrot_Int length
) {
554 PARROT_CALLIN_START(interp
);
555 VTABLE_set_string_native(interp
, pmc
,
556 string_from_cstring(interp
, value
, length
));
557 PARROT_CALLIN_END(interp
);
563 Parrot_PMC_push_intval(Parrot_INTERP interp, Parrot_PMC pmc,
566 Push the passed-in Parrot integer onto the passed in PMC
573 Parrot_PMC_push_intval(Parrot_INTERP interp
, Parrot_PMC pmc
,
575 PARROT_CALLIN_START(interp
);
576 VTABLE_push_integer(interp
, pmc
, value
);
577 PARROT_CALLIN_END(interp
);
583 Parrot_PMC_push_numval(Parrot_INTERP interp, Parrot_PMC pmc,
586 Push the passed-in Parrot number onto the passed in PMC
593 Parrot_PMC_push_numval(Parrot_INTERP interp
, Parrot_PMC pmc
,
594 Parrot_Float value
) {
595 PARROT_CALLIN_START(interp
);
596 VTABLE_push_float(interp
, pmc
, value
);
597 PARROT_CALLIN_END(interp
);
603 Parrot_PMC_delete_pmckey(Parrot_INTERP interp, Parrot_PMC pmc,
606 Deletes the value associated with the passed-in PMC from the PMC.
613 Parrot_PMC_delete_pmckey(Parrot_INTERP interp
, Parrot_PMC pmc
,
615 PARROT_CALLIN_START(interp
);
616 VTABLE_delete_keyed(interp
, pmc
, key
);
617 PARROT_CALLIN_END(interp
);
623 Parrot_PMC_set_cstringn_intkey(Parrot_INTERP interp, Parrot_PMC pmc,
625 const char *value, Parrot_Int length)>
627 Assign the passed-in length-noted string to the passed-in PMC.
634 Parrot_PMC_set_cstringn_intkey(Parrot_INTERP interp
, Parrot_PMC pmc
,
636 const char *value
, Parrot_Int length
) {
637 PARROT_CALLIN_START(interp
);
638 VTABLE_set_string_keyed_int(interp
, pmc
, key
,
639 string_from_cstring(interp
, value
, length
));
640 PARROT_CALLIN_END(interp
);
645 =item C<Parrot_PMC Parrot_PMC_new(Parrot_INTERP interp, Parrot_Int type)>
647 Create and return a new PMC.
653 Parrot_PMC
Parrot_PMC_new(Parrot_INTERP interp
, Parrot_Int type
) {
655 PARROT_CALLIN_START(interp
);
656 newpmc
= pmc_new_noinit(interp
, type
);
657 VTABLE_init(interp
, newpmc
);
658 PARROT_CALLIN_END(interp
);
664 =item C<Parrot_Int Parrot_PMC_typenum(Parrot_INTERP interp, const char *class)>
666 Returns the internal identifier that represents the named class.
672 Parrot_Int
Parrot_PMC_typenum(Parrot_INTERP interp
, const char *class) {
674 PARROT_CALLIN_START(interp
);
675 retval
= pmc_type(interp
, string_from_cstring(interp
, class, 0));
676 PARROT_CALLIN_END(interp
);
682 =item C<Parrot_PMC Parrot_PMC_null()>
684 Returns the special C<NULL> PMC.
691 Parrot_PMC_null(void) {
697 =item C<void Parrot_free_cstring(char *string)>
699 Deallocate a C string that the interpreter has handed to you.
706 Parrot_free_cstring(char *string
) {
707 string_cstring_free(string
);
713 Parrot_call_sub(Parrot_INTERP interpreter, Parrot_PMC sub,
714 const char *signature, ...)>
716 Call a parrot subroutine with the given function signature. The first char in
717 C<signature> denotes the return value. Next chars are arguments.
719 The return value of this function can be void or a pointer type.
730 Parrot_call_sub_ret_int(Parrot_INTERP interpreter, Parrot_PMC sub,
731 const char *signature, ...)>
733 =item C<Parrot_Float>
734 Parrot_call_sub_ret_float(Parrot_INTERP interpreter, Parrot_PMC sub,
735 const char *signature, ...)>
737 Like above, with Parrot_Int or Parrot_Float return result.
744 Parrot_call_sub(Parrot_INTERP interpreter
, Parrot_PMC sub
,
745 const char *signature
, ...)
750 PARROT_CALLIN_START(interpreter
);
752 va_start(ap
, signature
);
753 CONTEXT(interpreter
->ctx
)->constants
=
754 PMC_sub(sub
)->seg
->const_table
->constants
;
755 result
= Parrot_runops_fromc_arglist(interpreter
, sub
, signature
, ap
);
758 PARROT_CALLIN_END(interpreter
);
763 Parrot_call_sub_ret_int(Parrot_INTERP interpreter
, Parrot_PMC sub
,
764 const char *signature
, ...)
769 PARROT_CALLIN_START(interpreter
);
771 va_start(ap
, signature
);
772 result
= Parrot_runops_fromc_arglist_reti(interpreter
, sub
, signature
, ap
);
775 PARROT_CALLIN_END(interpreter
);
780 Parrot_call_sub_ret_float(Parrot_INTERP interpreter
, Parrot_PMC sub
,
781 const char *signature
, ...)
786 PARROT_CALLIN_START(interpreter
);
788 va_start(ap
, signature
);
789 result
= Parrot_runops_fromc_arglist_retf(interpreter
, sub
, signature
, ap
);
792 PARROT_CALLIN_END(interpreter
);
798 =item C<void* Parrot_call_method(Parrot_INTERP interp, Parrot_PMC sub,
799 Parrot_PMC object, Parrot_STRING method, const char *signature, ...)>
801 =item C<Parrot_Int Parrot_call_method_ret_int(Parrot_INTERP interp,
802 Parrot_PMC sub, Parrot_PMC object, Parrot_STRING method,
803 const char *signature, ...)>
805 =item C<Parrot_Float Parrot_call_method_ret_float(Parrot_INTERP interp,
806 Parrot_PMC sub, Parrot_PMC object, Parrot_STRING method,
807 const char *signature, ...)>
809 Call a parrot method for the given object.
816 Parrot_call_method(Parrot_INTERP interpreter
, Parrot_PMC sub
, Parrot_PMC obj
,
817 Parrot_STRING method
, const char *signature
, ...)
822 PARROT_CALLIN_START(interpreter
);
823 va_start(ap
, signature
);
824 result
= Parrot_run_meth_fromc_arglist(interpreter
, sub
,
825 obj
, method
, signature
, ap
);
827 PARROT_CALLIN_END(interpreter
);
832 Parrot_call_method_ret_int(Parrot_INTERP interpreter
, Parrot_PMC sub
,
833 Parrot_PMC obj
, Parrot_STRING method
, const char *signature
, ...)
838 PARROT_CALLIN_START(interpreter
);
839 va_start(ap
, signature
);
840 result
= Parrot_run_meth_fromc_arglist_reti(interpreter
, sub
,
841 obj
, method
, signature
, ap
);
843 PARROT_CALLIN_END(interpreter
);
848 Parrot_call_method_ret_float(Parrot_INTERP interpreter
, Parrot_PMC sub
,
849 Parrot_PMC obj
, Parrot_STRING method
, const char *signature
, ...)
854 PARROT_CALLIN_START(interpreter
);
855 va_start(ap
, signature
);
856 result
= Parrot_run_meth_fromc_arglist_retf(interpreter
, sub
,
857 obj
, method
, signature
, ap
);
859 PARROT_CALLIN_END(interpreter
);
866 Parrot_get_intreg(Parrot_INTERP interpreter, Parrot_Int regnum)>
868 Return the value of an integer register.
875 Parrot_get_intreg(Parrot_INTERP interpreter
, Parrot_Int regnum
)
877 return REG_INT(regnum
);
883 Parrot_get_numreg(Parrot_INTERP interpreter, Parrot_Int regnum)>
885 Return the value of a numeric register.
892 Parrot_get_numreg(Parrot_INTERP interpreter
, Parrot_Int regnum
)
894 return REG_NUM(regnum
);
899 =item C<Parrot_STRING
900 Parrot_get_strreg(Parrot_INTERP interpreter, Parrot_Int regnum)>
902 Return the value of a string register.
909 Parrot_get_strreg(Parrot_INTERP interpreter
, Parrot_Int regnum
)
911 return REG_STR(regnum
);
917 Parrot_get_pmcreg(Parrot_INTERP interpreter, Parrot_Int regnum)>
919 Return the value of a PMC register.
926 Parrot_get_pmcreg(Parrot_INTERP interpreter
, Parrot_Int regnum
)
928 return REG_PMC(regnum
);
934 Parrot_set_intreg(Parrot_INTERP interpreter, Parrot_Int regnum,
937 Set the value of an I register.
944 Parrot_set_intreg(Parrot_INTERP interpreter
, Parrot_Int regnum
,
947 REG_INT(regnum
) = value
;
953 Parrot_set_numreg(Parrot_INTERP interpreter, Parrot_Int regnum,
956 Set the value of an N register.
963 Parrot_set_numreg(Parrot_INTERP interpreter
, Parrot_Int regnum
,
966 REG_NUM(regnum
) = value
;
972 Parrot_set_strreg(Parrot_INTERP interpreter, Parrot_Int regnum,
973 Parrot_STRING value)>
975 Set the value of an S register.
982 Parrot_set_strreg(Parrot_INTERP interpreter
, Parrot_Int regnum
,
985 REG_STR(regnum
) = value
;
991 Parrot_set_pmcreg(Parrot_INTERP interpreter, Parrot_Int regnum,
994 Set the value of a P register.
1001 Parrot_set_pmcreg(Parrot_INTERP interpreter
, Parrot_Int regnum
,
1004 REG_PMC(regnum
) = value
;
1007 /*=for api extend Parrot_new_string
1012 =item C<Parrot_STRING Parrot_new_string(Parrot_INTERP interpreter,
1013 char *buffer, int length,
1014 const char * const encoding_name,
1017 Create a new Parrot string from a passed-in buffer. Pass in a 0 for
1018 flags for right now.
1020 A copy of the buffer is made.
1027 Parrot_new_string(Parrot_INTERP interpreter
,
1028 char *buffer
, int length
,
1029 const char * const encoding_name
,
1032 Parrot_STRING retval
;
1033 PARROT_CALLIN_START(interpreter
);
1034 retval
= string_make(interpreter
, buffer
, length
, encoding_name
, flags
);
1035 PARROT_CALLIN_END(interpreter
);
1041 =item C<Parrot_Const_Encoding
1042 Parrot_find_encoding(Parrot_INTERP interpreter, char *encoding_name)>
1044 Find the magic token for an encoding, by name.
1050 Parrot_Const_Encoding Parrot_find_encoding(Parrot_INTERP interpreter,
1051 char *encoding_name) {
1052 return Parrot_encoding_lookup(encoding_name);
1057 =item C<Parrot_Language
1058 Parrot_find_language(Parrot_INTERP interpreter, char *language)>
1060 Find the magic language token for a language, by language name.
1067 Parrot_find_language(Parrot_INTERP interpreter
, char *language
)
1075 Parrot_register_pmc(Parrot_INTERP interpreter, Parrot_PMC pmc)>
1077 Add a reference of the PMC to the interpreters DOD registry. This
1078 prevents PMCs only known to extension from getting destroyed during DOD
1086 Parrot_register_pmc(Parrot_INTERP interp
, Parrot_PMC pmc
)
1088 PARROT_CALLIN_START(interp
);
1089 dod_register_pmc(interp
, pmc
);
1090 PARROT_CALLIN_END(interp
);
1096 Parrot_unregister_pmc(Parrot_INTERP interpreter, Parrot_PMC pmc)>
1098 Remove a reference of the PMC from the interpreters DOD registry. If the
1099 reference count reaches zero, the PMC will be destroyed during the next
1102 =item C<Parrot_PMC Parrot_get_dod_registry(Parrot_INTERP)>
1104 Return Parrot's internal DOD registry PMC.
1105 See also: F<src/pmc/addrregistry.pmc>.
1112 Parrot_unregister_pmc(Parrot_INTERP interp
, Parrot_PMC pmc
)
1114 PARROT_CALLIN_START(interp
);
1115 dod_unregister_pmc(interp
, pmc
);
1116 PARROT_CALLIN_END(interp
);
1120 Parrot_get_dod_registry(Parrot_INTERP interp
)
1122 PMC
*registry
= interp
->DOD_registry
;
1123 PARROT_CALLIN_START(interp
);
1125 registry
= interp
->DOD_registry
=
1126 pmc_new(interp
, enum_class_AddrRegistry
);
1128 PARROT_CALLIN_END(interp
);
1135 Parrot_pmc_set_vtable(Parrot_INTERP interpreter, Parrot_PMC pmc,
1136 Parrot_VTABLE vtable)>
1138 Replaces the vtable of the PMC.
1145 Parrot_PMC_set_vtable(Parrot_INTERP interpreter
, Parrot_PMC pmc
,
1146 Parrot_VTABLE vtable
)
1148 pmc
->vtable
= vtable
;
1153 =item C<Parrot_VTABLE
1154 Parrot_get_vtable(Parrot_INTERP interpreter, Parrot_Int id)>
1156 Returns the vtable corresponding to the given PMC ID.
1163 Parrot_get_vtable(Parrot_INTERP interpreter
, Parrot_Int id
)
1165 return interpreter
->vtables
[id
];
1174 See F<include/parrot/extend.h> and F<docs/pdds/pdd11_extending.pod>.
1178 Initial version by Dan Sugalski.
1187 * c-file-style: "parrot"
1189 * vim: expandtab shiftwidth=4: