2 Copyright (C) 2001-2007, 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(interp) 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(interp) 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"
64 /* HEADERIZER HFILE: include/parrot/extend.h */
68 =item C<int Parrot_vfprintf>
70 Writes a C string format with a varargs list to a PIO.
72 =item C<int Parrot_fprintf>
74 Writes a C string format with varargs to a PIO.
76 =item C<int Parrot_printf>
78 Writes a C string format with varargs to C<stdout>.
80 =item C<int Parrot_eprintf>
82 Writes a C string format with varargs to C<stderr>.
88 Parrot_vfprintf(PARROT_INTERP
, ARGIN(Parrot_PMC pio
),
89 ARGIN(const char *s
), va_list args
)
94 PARROT_CALLIN_START(interp
);
95 str
= Parrot_vsprintf_c(interp
, s
, args
);
96 retval
= PIO_putps(interp
, pio
, str
);
97 PARROT_CALLIN_END(interp
);
104 Parrot_fprintf(PARROT_INTERP
, ARGIN(Parrot_PMC pio
),
105 ARGIN(const char *s
), ...)
111 retval
= Parrot_vfprintf(interp
, pio
, s
, args
);
119 Parrot_printf(NULLOK_INTERP
, ARGIN(const char *s
), ...)
126 retval
= Parrot_vfprintf(interp
, PIO_STDOUT(interp
), s
, args
);
129 /* Be nice about this...
130 ** XXX BD Should this use the default PIO_STDOUT or something?
132 retval
= vfprintf(stdout
, s
, args
);
141 Parrot_eprintf(NULLOK_INTERP
, ARGIN(const char *s
), ...)
149 retval
= Parrot_vfprintf(interp
, PIO_STDERR(interp
), s
, args
);
152 /* Be nice about this...
153 ** XXX BD Should this use the default PIO_STDOUT or something?
155 retval
=vfprintf(stderr
, s
, args
);
165 =item C<Parrot_String Parrot_PMC_get_string_intkey>
167 Return the integer keyed string value of the passed-in PMC
175 Parrot_PMC_get_string_intkey(PARROT_INTERP
,
176 Parrot_PMC pmc
, Parrot_Int key
)
178 Parrot_String retval
;
179 PARROT_CALLIN_START(interp
);
180 retval
= VTABLE_get_string_keyed_int(interp
, pmc
, key
);
181 PARROT_CALLIN_END(interp
);
188 =item C<void * Parrot_PMC_get_pointer_intkey>
190 Return a pointer to the PMC indicated by an integer key.
197 PARROT_WARN_UNUSED_RESULT
198 PARROT_CAN_RETURN_NULL
200 Parrot_PMC_get_pointer_intkey(PARROT_INTERP
,
201 Parrot_PMC pmc
, Parrot_Int key
)
204 PARROT_CALLIN_START(interp
);
205 retval
= VTABLE_get_pointer_keyed_int(interp
, pmc
, key
);
206 PARROT_CALLIN_END(interp
);
212 =item C<Parrot_PMC Parrot_PMC_get_pmc_intkey>
214 Return the integer keyed PMC value of the passed-in PMC
222 Parrot_PMC_get_pmc_intkey(PARROT_INTERP
,
223 Parrot_PMC pmc
, Parrot_Int key
)
226 PARROT_CALLIN_START(interp
);
227 retval
= VTABLE_get_pmc_keyed_int(interp
, pmc
, key
);
228 PARROT_CALLIN_END(interp
);
234 =item C<Parrot_Int Parrot_PMC_get_intval>
236 Return the signed integer value of the value in the PMC.
244 Parrot_PMC_get_intval(PARROT_INTERP
, Parrot_PMC pmc
)
247 PARROT_CALLIN_START(interp
);
248 retval
= VTABLE_get_integer(interp
, pmc
);
249 PARROT_CALLIN_END(interp
);
255 =item C<Parrot_Int Parrot_PMC_get_intval_intkey>
257 Return the keyed, signed integer value of the value in the PMC.
265 Parrot_PMC_get_intval_intkey(PARROT_INTERP
,
266 Parrot_PMC pmc
, Parrot_Int key
)
269 PARROT_CALLIN_START(interp
);
270 retval
= VTABLE_get_integer_keyed_int(interp
, pmc
, key
);
271 PARROT_CALLIN_END(interp
);
277 =item C<Parrot_Int Parrot_PMC_get_intval_pmckey>
279 Return the keyed, signed integer value of the value in the PMC.
287 Parrot_PMC_get_intval_pmckey(PARROT_INTERP
,
288 Parrot_PMC pmc
, Parrot_PMC key
)
291 PARROT_CALLIN_START(interp
);
292 retval
= VTABLE_get_integer_keyed(interp
, pmc
, key
);
293 PARROT_CALLIN_END(interp
);
299 =item C<Parrot_Float Parrot_PMC_get_numval>
301 Return the floating-point value of the PMC.
309 Parrot_PMC_get_numval(PARROT_INTERP
, Parrot_PMC pmc
)
312 PARROT_CALLIN_START(interp
);
313 retval
= VTABLE_get_number(interp
, pmc
);
314 PARROT_CALLIN_END(interp
);
320 =item C<Parrot_Float Parrot_PMC_get_numval_intkey>
322 Return the keyed, signed integer value of the value in the PMC.
330 Parrot_PMC_get_numval_intkey(PARROT_INTERP
,
331 Parrot_PMC pmc
, Parrot_Int key
)
334 PARROT_CALLIN_START(interp
);
335 retval
= VTABLE_get_number_keyed_int(interp
, pmc
, key
);
336 PARROT_CALLIN_END(interp
);
342 =item C<char * Parrot_PMC_get_cstring_intkey>
344 Return a null-terminated string that represents the string value of the PMC.
346 Note that you must free this string with C<string_cstring_free()>!
354 PARROT_CAN_RETURN_NULL
356 Parrot_PMC_get_cstring_intkey(PARROT_INTERP
,
357 Parrot_PMC pmc
, Parrot_Int key
)
359 STRING
*intermediate
;
362 PARROT_CALLIN_START(interp
);
363 intermediate
= VTABLE_get_string_keyed_int(interp
, pmc
, key
);
364 retval
= string_to_cstring(interp
, intermediate
);
365 PARROT_CALLIN_END(interp
);
372 =item C<char * Parrot_PMC_get_cstring>
374 Return a null-terminated string that represents the string value of the PMC.
376 Note that you must free this string with C<string_cstring_free()>!
384 PARROT_CAN_RETURN_NULL
386 Parrot_PMC_get_cstring(PARROT_INTERP
, Parrot_PMC pmc
)
388 STRING
*intermediate
;
391 PARROT_CALLIN_START(interp
);
392 intermediate
= VTABLE_get_string(interp
, pmc
);
393 retval
= string_to_cstring(interp
, intermediate
);
394 PARROT_CALLIN_END(interp
);
401 =item C<char * Parrot_PMC_get_cstringn>
403 Return a null-terminated string for the PMC, along with the length.
405 Yes, right now this is a bit of a cheat. It needs fixing, but without
406 disturbing the interface.
408 Note that you must free the string with C<string_cstring_free()>.
416 PARROT_CAN_RETURN_NULL
418 Parrot_PMC_get_cstringn(PARROT_INTERP
, ARGIN(Parrot_PMC pmc
),
419 ARGOUT(Parrot_Int
*length
))
423 PARROT_CALLIN_START(interp
);
424 retval
= string_to_cstring(interp
, VTABLE_get_string(interp
, pmc
));
425 *length
= strlen(retval
);
426 PARROT_CALLIN_END(interp
);
433 =item C<char * Parrot_PMC_get_cstringn_intkey>
435 Return a null-terminated string for the PMC, along with the length.
437 Yes, right now this is a bit of a cheat. It needs fixing, but without
438 disturbing the interface.
440 Note that you must free this string with C<string_cstring_free()>.
448 PARROT_CAN_RETURN_NULL
450 Parrot_PMC_get_cstringn_intkey(PARROT_INTERP
, ARGIN(Parrot_PMC pmc
),
451 ARGOUT(Parrot_Int
*length
), Parrot_Int key
)
455 PARROT_CALLIN_START(interp
);
456 retval
= string_to_cstring(interp
,
457 VTABLE_get_string_keyed_int(interp
, pmc
, key
));
458 *length
= strlen(retval
);
459 PARROT_CALLIN_END(interp
);
466 =item C<void Parrot_PMC_set_string>
468 Assign the passed-in Parrot string to the passed-in PMC.
476 Parrot_PMC_set_string(PARROT_INTERP
,
477 Parrot_PMC pmc
, Parrot_String value
)
479 PARROT_CALLIN_START(interp
);
480 VTABLE_set_string_native(interp
, pmc
, value
);
481 PARROT_CALLIN_END(interp
);
486 =item C<void Parrot_PMC_set_string_intkey>
488 Assign the passed-in Parrot string to the passed-in PMC.
496 Parrot_PMC_set_string_intkey(PARROT_INTERP
,
497 Parrot_PMC pmc
, Parrot_Int key
, Parrot_String value
)
499 PARROT_CALLIN_START(interp
);
500 VTABLE_set_string_keyed_int(interp
, pmc
, key
, value
);
501 PARROT_CALLIN_END(interp
);
506 =item C<void Parrot_PMC_set_pmc_intkey>
508 Assign the passed-in pmc to the passed-in slot of the passed-in PMC.
516 Parrot_PMC_set_pmc_intkey(PARROT_INTERP
,
517 Parrot_PMC pmc
, Parrot_Int key
, Parrot_PMC value
)
519 PARROT_CALLIN_START(interp
);
520 VTABLE_set_pmc_keyed_int(interp
, pmc
, key
, value
);
521 PARROT_CALLIN_END(interp
);
526 =item C<void Parrot_PMC_set_pmc_pmckey>
528 Assign the passed-in pmc to the passed-in slot of the passed-in PMC.
536 Parrot_PMC_set_pmc_pmckey(PARROT_INTERP
,
537 Parrot_PMC pmc
, Parrot_PMC key
, Parrot_PMC value
)
539 PARROT_CALLIN_START(interp
);
540 VTABLE_set_pmc_keyed(interp
, pmc
, key
, value
);
541 PARROT_CALLIN_END(interp
);
546 =item C<void Parrot_PMC_set_pointer_intkey>
548 Assign the passed-in pointer to the passed-in PMC.
556 Parrot_PMC_set_pointer_intkey(PARROT_INTERP
,
557 ARGIN(Parrot_PMC pmc
), Parrot_Int key
, ARGIN_NULLOK(void *value
))
559 PARROT_CALLIN_START(interp
);
560 VTABLE_set_pointer_keyed_int(interp
, pmc
, key
, value
);
561 PARROT_CALLIN_END(interp
);
566 =item C<void Parrot_PMC_set_intval>
568 Assign the passed-in Parrot integer to the passed-in PMC.
576 Parrot_PMC_set_intval(PARROT_INTERP
, Parrot_PMC pmc
, Parrot_Int value
)
578 PARROT_CALLIN_START(interp
);
579 VTABLE_set_integer_native(interp
, pmc
, value
);
580 PARROT_CALLIN_END(interp
);
585 =item C<void Parrot_PMC_set_intval_intkey>
587 Assign the passed-in Parrot integer to the passed-in PMC.
595 Parrot_PMC_set_intval_intkey(PARROT_INTERP
,
596 Parrot_PMC pmc
, Parrot_Int key
, Parrot_Int value
)
598 PARROT_CALLIN_START(interp
);
599 VTABLE_set_integer_keyed_int(interp
, pmc
, key
, value
);
600 PARROT_CALLIN_END(interp
);
605 =item C<void Parrot_PMC_set_numval>
607 Assign the passed-in Parrot number to the passed-in PMC.
615 Parrot_PMC_set_numval(PARROT_INTERP
, Parrot_PMC pmc
, Parrot_Float value
)
617 PARROT_CALLIN_START(interp
);
618 VTABLE_set_number_native(interp
, pmc
, value
);
619 PARROT_CALLIN_END(interp
);
624 =item C<void Parrot_PMC_set_numval_intkey>
626 Assign the passed-in Parrot number to the passed-in PMC.
634 Parrot_PMC_set_numval_intkey(PARROT_INTERP
,
635 Parrot_PMC pmc
, Parrot_Int key
, Parrot_Float value
)
637 PARROT_CALLIN_START(interp
);
638 VTABLE_set_number_keyed_int(interp
, pmc
, key
, value
);
639 PARROT_CALLIN_END(interp
);
644 =item C<void Parrot_PMC_set_cstring>
646 Assign the passed-in null-terminated C string to the passed-in PMC.
654 Parrot_PMC_set_cstring(PARROT_INTERP
, Parrot_PMC pmc
, ARGIN_NULLOK(const char *value
))
656 PARROT_CALLIN_START(interp
);
657 VTABLE_set_string_native(interp
, pmc
,
658 string_from_cstring(interp
, value
, 0));
659 PARROT_CALLIN_END(interp
);
664 =item C<void Parrot_PMC_set_cstring_intkey>
666 Assign the passed-in null-terminated C string to the passed-in PMC.
674 Parrot_PMC_set_cstring_intkey(PARROT_INTERP
,
675 Parrot_PMC pmc
, Parrot_Int key
, ARGIN_NULLOK(const char *value
))
677 PARROT_CALLIN_START(interp
);
678 VTABLE_set_string_keyed_int(interp
, pmc
, key
,
679 string_from_cstring(interp
, value
, 0));
680 PARROT_CALLIN_END(interp
);
685 =item C<void Parrot_PMC_set_cstringn>
687 Assign the passed-in length-noted string to the passed-in PMC.
695 Parrot_PMC_set_cstringn(PARROT_INTERP
,
696 Parrot_PMC pmc
, ARGIN_NULLOK(const char *value
), Parrot_Int length
)
698 PARROT_CALLIN_START(interp
);
699 VTABLE_set_string_native(interp
, pmc
,
700 string_from_cstring(interp
, value
, length
));
701 PARROT_CALLIN_END(interp
);
706 =item C<void Parrot_PMC_push_intval>
708 Push the passed-in Parrot integer onto the passed in PMC
716 Parrot_PMC_push_intval(PARROT_INTERP
,
717 Parrot_PMC pmc
, Parrot_Int value
)
719 PARROT_CALLIN_START(interp
);
720 VTABLE_push_integer(interp
, pmc
, value
);
721 PARROT_CALLIN_END(interp
);
726 =item C<void Parrot_PMC_push_numval>
728 Push the passed-in Parrot number onto the passed in PMC
736 Parrot_PMC_push_numval(PARROT_INTERP
, Parrot_PMC pmc
, Parrot_Float value
)
738 PARROT_CALLIN_START(interp
);
739 VTABLE_push_float(interp
, pmc
, value
);
740 PARROT_CALLIN_END(interp
);
745 =item C<void Parrot_PMC_delete_pmckey>
747 Deletes the value associated with the passed-in PMC from the PMC.
755 Parrot_PMC_delete_pmckey(PARROT_INTERP
, Parrot_PMC pmc
, Parrot_PMC key
)
757 PARROT_CALLIN_START(interp
);
758 VTABLE_delete_keyed(interp
, pmc
, key
);
759 PARROT_CALLIN_END(interp
);
764 =item C<void Parrot_PMC_set_cstringn_intkey>
766 Assign the passed-in length-noted string to the passed-in PMC.
774 Parrot_PMC_set_cstringn_intkey(PARROT_INTERP
,
775 Parrot_PMC pmc
, Parrot_Int key
, ARGIN_NULLOK(const char *value
), Parrot_Int length
)
777 PARROT_CALLIN_START(interp
);
778 VTABLE_set_string_keyed_int(interp
, pmc
, key
,
779 string_from_cstring(interp
, value
, length
));
780 PARROT_CALLIN_END(interp
);
785 =item C<Parrot_PMC Parrot_PMC_new>
787 Create and return a new PMC.
795 Parrot_PMC_new(PARROT_INTERP
, Parrot_Int type
)
798 PARROT_CALLIN_START(interp
);
799 newpmc
= pmc_new_noinit(interp
, type
);
800 VTABLE_init(interp
, newpmc
);
801 PARROT_CALLIN_END(interp
);
807 =item C<Parrot_Int Parrot_PMC_typenum>
809 Returns the internal identifier that represents the named class.
817 Parrot_PMC_typenum(PARROT_INTERP
, ARGIN_NULLOK(const char *_class
))
820 PARROT_CALLIN_START(interp
);
821 retval
= pmc_type(interp
, string_from_cstring(interp
, _class
, 0));
822 PARROT_CALLIN_END(interp
);
828 =item C<Parrot_PMC Parrot_PMC_null>
830 Returns the special C<NULL> PMC.
838 Parrot_PMC_null(void)
845 =item C<void Parrot_free_cstring>
847 Deallocate a C string that the interpreter has handed to you.
855 Parrot_free_cstring(ARGIN_NULLOK(char *string
))
857 string_cstring_free(string
);
862 =item C<void* Parrot_call_sub>
864 Call a parrot subroutine with the given function signature. The first char in
865 C<signature> denotes the return value. Next chars are arguments.
867 The return value of this function can be void or a pointer type.
882 PARROT_WARN_UNUSED_RESULT
883 PARROT_CAN_RETURN_NULL
885 Parrot_call_sub(PARROT_INTERP
, Parrot_PMC sub
,
886 ARGIN(const char *signature
), ...)
891 PARROT_CALLIN_START(interp
);
893 va_start(ap
, signature
);
894 CONTEXT(interp
)->constants
=
895 PMC_sub(sub
)->seg
->const_table
->constants
;
896 result
= Parrot_runops_fromc_arglist(interp
, sub
, signature
, ap
);
899 PARROT_CALLIN_END(interp
);
905 =item C<Parrot_Int Parrot_call_sub_ret_int>
907 Like C<Parrot_call_sub>, with Parrot_Int return result.
915 Parrot_call_sub_ret_int(PARROT_INTERP
, Parrot_PMC sub
,
916 ARGIN(const char *signature
), ...)
921 PARROT_CALLIN_START(interp
);
923 va_start(ap
, signature
);
924 CONTEXT(interp
)->constants
=
925 PMC_sub(sub
)->seg
->const_table
->constants
;
926 result
= Parrot_runops_fromc_arglist_reti(interp
, sub
, signature
, ap
);
929 PARROT_CALLIN_END(interp
);
935 =item C<Parrot_Float Parrot_call_sub_ret_float>
937 Like C<Parrot_call_sub>, with Parrot_Float return result.
945 Parrot_call_sub_ret_float(PARROT_INTERP
, Parrot_PMC sub
,
946 ARGIN(const char *signature
), ...)
951 PARROT_CALLIN_START(interp
);
953 va_start(ap
, signature
);
954 CONTEXT(interp
)->constants
=
955 PMC_sub(sub
)->seg
->const_table
->constants
;
956 result
= Parrot_runops_fromc_arglist_retf(interp
, sub
, signature
, ap
);
959 PARROT_CALLIN_END(interp
);
965 =item C<void * Parrot_call_method>
967 Call a parrot method for the given object.
974 PARROT_WARN_UNUSED_RESULT
975 PARROT_CAN_RETURN_NULL
977 Parrot_call_method(PARROT_INTERP
, Parrot_PMC sub
, Parrot_PMC obj
,
978 Parrot_String method
, ARGIN(const char *signature
), ...)
983 PARROT_CALLIN_START(interp
);
984 va_start(ap
, signature
);
985 result
= Parrot_run_meth_fromc_arglist(interp
, sub
,
986 obj
, method
, signature
, ap
);
988 PARROT_CALLIN_END(interp
);
994 =item C<Parrot_Int Parrot_call_method_ret_int>
996 Call a parrot method for the given object.
1004 Parrot_call_method_ret_int(PARROT_INTERP
, Parrot_PMC sub
,
1005 Parrot_PMC obj
, Parrot_String method
, ARGIN(const char *signature
), ...)
1010 PARROT_CALLIN_START(interp
);
1011 va_start(ap
, signature
);
1012 result
= Parrot_run_meth_fromc_arglist_reti(interp
, sub
,
1013 obj
, method
, signature
, ap
);
1015 PARROT_CALLIN_END(interp
);
1021 =item C<Parrot_Float Parrot_call_method_ret_float>
1023 Call a parrot method for the given object.
1031 Parrot_call_method_ret_float(PARROT_INTERP
, Parrot_PMC sub
,
1032 Parrot_PMC obj
, Parrot_String method
, ARGIN(const char *signature
), ...)
1034 Parrot_Float result
;
1037 PARROT_CALLIN_START(interp
);
1038 va_start(ap
, signature
);
1039 result
= Parrot_run_meth_fromc_arglist_retf(interp
, sub
,
1040 obj
, method
, signature
, ap
);
1042 PARROT_CALLIN_END(interp
);
1048 =item C<Parrot_Int Parrot_get_intreg>
1050 Return the value of an integer register.
1058 Parrot_get_intreg(PARROT_INTERP
, Parrot_Int regnum
)
1060 return REG_INT(interp
, regnum
);
1065 =item C<Parrot_Float Parrot_get_numreg>
1067 Return the value of a numeric register.
1075 Parrot_get_numreg(PARROT_INTERP
, Parrot_Int regnum
)
1077 return REG_NUM(interp
, regnum
);
1082 =item C<Parrot_String Parrot_get_strreg>
1084 Return the value of a string register.
1092 Parrot_get_strreg(PARROT_INTERP
, Parrot_Int regnum
)
1094 return REG_STR(interp
, regnum
);
1099 =item C<Parrot_PMC Parrot_get_pmcreg>
1101 Return the value of a PMC register.
1109 Parrot_get_pmcreg(PARROT_INTERP
, Parrot_Int regnum
)
1111 return REG_PMC(interp
, regnum
);
1116 =item C<void Parrot_set_intreg>
1118 Set the value of an I register.
1126 Parrot_set_intreg(PARROT_INTERP
, Parrot_Int regnum
,
1129 REG_INT(interp
, regnum
) = value
;
1134 =item C<void Parrot_set_numreg>
1136 Set the value of an N register.
1144 Parrot_set_numreg(PARROT_INTERP
, Parrot_Int regnum
,
1147 REG_NUM(interp
, regnum
) = value
;
1152 =item C<void Parrot_set_strreg>
1154 Set the value of an S register.
1160 Parrot_set_strreg(PARROT_INTERP
, Parrot_Int regnum
,
1161 Parrot_String value
)
1163 REG_STR(interp
, regnum
) = value
;
1168 =item C<void Parrot_set_pmcreg>
1170 Set the value of a P register.
1178 Parrot_set_pmcreg(PARROT_INTERP
, Parrot_Int regnum
,
1181 REG_PMC(interp
, regnum
) = value
;
1184 /*=for api extend Parrot_new_string
1189 =item C<Parrot_String Parrot_new_string>
1191 Create a new Parrot string from a passed-in buffer. Pass in a 0 for
1192 flags for right now.
1194 A copy of the buffer is made.
1201 PARROT_WARN_UNUSED_RESULT
1202 PARROT_CANNOT_RETURN_NULL
1204 Parrot_new_string(PARROT_INTERP
, ARGIN_NULLOK(const char *buffer
), int length
,
1205 ARGIN_NULLOK(const char * const encoding_name
), Parrot_Int flags
)
1207 Parrot_String retval
;
1208 PARROT_CALLIN_START(interp
);
1209 retval
= string_make(interp
, buffer
, length
, encoding_name
, flags
);
1210 PARROT_CALLIN_END(interp
);
1216 =item C<Parrot_Language Parrot_find_language>
1218 Find the magic language token for a language, by language name.
1225 PARROT_WARN_UNUSED_RESULT
1227 Parrot_find_language(SHIM_INTERP
, SHIM(char *language
))
1234 =item C<void Parrot_register_pmc>
1236 Add a reference of the PMC to the interpreters DOD registry. This
1237 prevents PMCs only known to extension from getting destroyed during DOD
1246 Parrot_register_pmc(PARROT_INTERP
, Parrot_PMC pmc
)
1248 PARROT_CALLIN_START(interp
);
1249 dod_register_pmc(interp
, pmc
);
1250 PARROT_CALLIN_END(interp
);
1255 =item C<void Parrot_unregister_pmc>
1257 Remove a reference of the PMC from the interpreters DOD registry. If the
1258 reference count reaches zero, the PMC will be destroyed during the next
1267 Parrot_unregister_pmc(PARROT_INTERP
, Parrot_PMC pmc
)
1269 PARROT_CALLIN_START(interp
);
1270 dod_unregister_pmc(interp
, pmc
);
1271 PARROT_CALLIN_END(interp
);
1276 =item C<void Parrot_PMC_set_vtable>
1278 Replaces the vtable of the PMC.
1286 Parrot_PMC_set_vtable(SHIM_INTERP
, Parrot_PMC pmc
, Parrot_VTABLE vtable
)
1288 pmc
->vtable
= vtable
;
1293 =item C<Parrot_VTABLE Parrot_get_vtable>
1295 Returns the vtable corresponding to the given PMC ID.
1302 PARROT_PURE_FUNCTION
1304 Parrot_get_vtable(PARROT_INTERP
, Parrot_Int id
)
1306 return interp
->vtables
[id
];
1315 See F<include/parrot/extend.h> and F<docs/pdds/pdd11_extending.pod>.
1319 Initial version by Dan Sugalski.
1328 * c-file-style: "parrot"
1330 * vim: expandtab shiftwidth=4: