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>.
90 Parrot_vfprintf(PARROT_INTERP
, ARGIN(Parrot_PMC pio
),
91 ARGIN(const char *s
), va_list args
)
96 PARROT_CALLIN_START(interp
);
97 str
= Parrot_vsprintf_c(interp
, s
, args
);
98 retval
= PIO_putps(interp
, pio
, str
);
99 PARROT_CALLIN_END(interp
);
106 Parrot_fprintf(PARROT_INTERP
, ARGIN(Parrot_PMC pio
),
107 ARGIN(const char *s
), ...)
113 retval
= Parrot_vfprintf(interp
, pio
, s
, args
);
121 Parrot_printf(NULLOK_INTERP
, ARGIN(const char *s
), ...)
128 retval
= Parrot_vfprintf(interp
, PIO_STDOUT(interp
), s
, args
);
131 /* Be nice about this...
132 ** XXX BD Should this use the default PIO_STDOUT or something?
134 retval
= vfprintf(stdout
, s
, args
);
143 Parrot_eprintf(NULLOK_INTERP
, ARGIN(const char *s
), ...)
151 retval
= Parrot_vfprintf(interp
, PIO_STDERR(interp
), s
, args
);
154 /* Be nice about this...
155 ** XXX BD Should this use the default PIO_STDOUT or something?
157 retval
=vfprintf(stderr
, s
, args
);
167 =item C<Parrot_String Parrot_PMC_get_string_intkey>
169 Return the integer keyed string value of the passed-in PMC
177 Parrot_PMC_get_string_intkey(PARROT_INTERP
,
178 Parrot_PMC pmc
, Parrot_Int key
)
180 Parrot_String retval
;
181 PARROT_CALLIN_START(interp
);
182 retval
= VTABLE_get_string_keyed_int(interp
, pmc
, key
);
183 PARROT_CALLIN_END(interp
);
190 =item C<void * Parrot_PMC_get_pointer_intkey>
192 Return a pointer to the PMC indicated by an integer key.
199 PARROT_WARN_UNUSED_RESULT
200 PARROT_CAN_RETURN_NULL
202 Parrot_PMC_get_pointer_intkey(PARROT_INTERP
,
203 Parrot_PMC pmc
, Parrot_Int key
)
206 PARROT_CALLIN_START(interp
);
207 retval
= VTABLE_get_pointer_keyed_int(interp
, pmc
, key
);
208 PARROT_CALLIN_END(interp
);
214 =item C<Parrot_PMC Parrot_PMC_get_pmc_intkey>
216 Return the integer keyed PMC value of the passed-in PMC
224 Parrot_PMC_get_pmc_intkey(PARROT_INTERP
,
225 Parrot_PMC pmc
, Parrot_Int key
)
228 PARROT_CALLIN_START(interp
);
229 retval
= VTABLE_get_pmc_keyed_int(interp
, pmc
, key
);
230 PARROT_CALLIN_END(interp
);
236 =item C<Parrot_Int Parrot_PMC_get_intval>
238 Return the signed integer value of the value in the PMC.
246 Parrot_PMC_get_intval(PARROT_INTERP
, Parrot_PMC pmc
)
249 PARROT_CALLIN_START(interp
);
250 retval
= VTABLE_get_integer(interp
, pmc
);
251 PARROT_CALLIN_END(interp
);
257 =item C<Parrot_Int Parrot_PMC_get_intval_intkey>
259 Return the keyed, signed integer value of the value in the PMC.
267 Parrot_PMC_get_intval_intkey(PARROT_INTERP
,
268 Parrot_PMC pmc
, Parrot_Int key
)
271 PARROT_CALLIN_START(interp
);
272 retval
= VTABLE_get_integer_keyed_int(interp
, pmc
, key
);
273 PARROT_CALLIN_END(interp
);
279 =item C<Parrot_Int Parrot_PMC_get_intval_pmckey>
281 Return the keyed, signed integer value of the value in the PMC.
289 Parrot_PMC_get_intval_pmckey(PARROT_INTERP
,
290 Parrot_PMC pmc
, Parrot_PMC key
)
293 PARROT_CALLIN_START(interp
);
294 retval
= VTABLE_get_integer_keyed(interp
, pmc
, key
);
295 PARROT_CALLIN_END(interp
);
301 =item C<Parrot_Float Parrot_PMC_get_numval>
303 Return the floating-point value of the PMC.
311 Parrot_PMC_get_numval(PARROT_INTERP
, Parrot_PMC pmc
)
314 PARROT_CALLIN_START(interp
);
315 retval
= VTABLE_get_number(interp
, pmc
);
316 PARROT_CALLIN_END(interp
);
322 =item C<Parrot_Float Parrot_PMC_get_numval_intkey>
324 Return the keyed, signed integer value of the value in the PMC.
332 Parrot_PMC_get_numval_intkey(PARROT_INTERP
,
333 Parrot_PMC pmc
, Parrot_Int key
)
336 PARROT_CALLIN_START(interp
);
337 retval
= VTABLE_get_number_keyed_int(interp
, pmc
, key
);
338 PARROT_CALLIN_END(interp
);
344 =item C<char * Parrot_PMC_get_cstring_intkey>
346 Return a null-terminated string that represents the string value of the PMC.
348 Note that you must free this string with C<string_cstring_free()>!
356 PARROT_CAN_RETURN_NULL
358 Parrot_PMC_get_cstring_intkey(PARROT_INTERP
,
359 Parrot_PMC pmc
, Parrot_Int key
)
361 STRING
*intermediate
;
364 PARROT_CALLIN_START(interp
);
365 intermediate
= VTABLE_get_string_keyed_int(interp
, pmc
, key
);
366 retval
= string_to_cstring(interp
, intermediate
);
367 PARROT_CALLIN_END(interp
);
374 =item C<char * Parrot_PMC_get_cstring>
376 Return a null-terminated string that represents the string value of the PMC.
378 Note that you must free this string with C<string_cstring_free()>!
386 PARROT_CAN_RETURN_NULL
388 Parrot_PMC_get_cstring(PARROT_INTERP
, Parrot_PMC pmc
)
390 STRING
*intermediate
;
393 PARROT_CALLIN_START(interp
);
394 intermediate
= VTABLE_get_string(interp
, pmc
);
395 retval
= string_to_cstring(interp
, intermediate
);
396 PARROT_CALLIN_END(interp
);
403 =item C<char * Parrot_PMC_get_cstringn>
405 Return a null-terminated string for the PMC, along with the length.
407 Yes, right now this is a bit of a cheat. It needs fixing, but without
408 disturbing the interface.
410 Note that you must free the string with C<string_cstring_free()>.
418 PARROT_CAN_RETURN_NULL
420 Parrot_PMC_get_cstringn(PARROT_INTERP
, ARGIN(Parrot_PMC pmc
),
421 ARGOUT(Parrot_Int
*length
))
425 PARROT_CALLIN_START(interp
);
426 retval
= string_to_cstring(interp
, VTABLE_get_string(interp
, pmc
));
427 *length
= strlen(retval
);
428 PARROT_CALLIN_END(interp
);
435 =item C<char * Parrot_PMC_get_cstringn_intkey>
437 Return a null-terminated string for the PMC, along with the length.
439 Yes, right now this is a bit of a cheat. It needs fixing, but without
440 disturbing the interface.
442 Note that you must free this string with C<string_cstring_free()>.
450 PARROT_CAN_RETURN_NULL
452 Parrot_PMC_get_cstringn_intkey(PARROT_INTERP
, ARGIN(Parrot_PMC pmc
),
453 ARGOUT(Parrot_Int
*length
), Parrot_Int key
)
457 PARROT_CALLIN_START(interp
);
458 retval
= string_to_cstring(interp
,
459 VTABLE_get_string_keyed_int(interp
, pmc
, key
));
460 *length
= strlen(retval
);
461 PARROT_CALLIN_END(interp
);
468 =item C<void Parrot_PMC_set_string>
470 Assign the passed-in Parrot string to the passed-in PMC.
478 Parrot_PMC_set_string(PARROT_INTERP
,
479 Parrot_PMC pmc
, Parrot_String value
)
481 PARROT_CALLIN_START(interp
);
482 VTABLE_set_string_native(interp
, pmc
, value
);
483 PARROT_CALLIN_END(interp
);
488 =item C<void Parrot_PMC_set_string_intkey>
490 Assign the passed-in Parrot string to the passed-in PMC.
498 Parrot_PMC_set_string_intkey(PARROT_INTERP
,
499 Parrot_PMC pmc
, Parrot_Int key
, Parrot_String value
)
501 PARROT_CALLIN_START(interp
);
502 VTABLE_set_string_keyed_int(interp
, pmc
, key
, value
);
503 PARROT_CALLIN_END(interp
);
508 =item C<void Parrot_PMC_set_pmc_intkey>
510 Assign the passed-in pmc to the passed-in slot of the passed-in PMC.
518 Parrot_PMC_set_pmc_intkey(PARROT_INTERP
,
519 Parrot_PMC pmc
, Parrot_Int key
, Parrot_PMC value
)
521 PARROT_CALLIN_START(interp
);
522 VTABLE_set_pmc_keyed_int(interp
, pmc
, key
, value
);
523 PARROT_CALLIN_END(interp
);
528 =item C<void Parrot_PMC_set_pmc_pmckey>
530 Assign the passed-in pmc to the passed-in slot of the passed-in PMC.
538 Parrot_PMC_set_pmc_pmckey(PARROT_INTERP
,
539 Parrot_PMC pmc
, Parrot_PMC key
, Parrot_PMC value
)
541 PARROT_CALLIN_START(interp
);
542 VTABLE_set_pmc_keyed(interp
, pmc
, key
, value
);
543 PARROT_CALLIN_END(interp
);
548 =item C<void Parrot_PMC_set_pointer_intkey>
550 Assign the passed-in pointer to the passed-in PMC.
558 Parrot_PMC_set_pointer_intkey(PARROT_INTERP
,
559 ARGIN(Parrot_PMC pmc
), Parrot_Int key
, ARGIN_NULLOK(void *value
))
561 PARROT_CALLIN_START(interp
);
562 VTABLE_set_pointer_keyed_int(interp
, pmc
, key
, value
);
563 PARROT_CALLIN_END(interp
);
568 =item C<void Parrot_PMC_set_intval>
570 Assign the passed-in Parrot integer to the passed-in PMC.
578 Parrot_PMC_set_intval(PARROT_INTERP
, Parrot_PMC pmc
, Parrot_Int value
)
580 PARROT_CALLIN_START(interp
);
581 VTABLE_set_integer_native(interp
, pmc
, value
);
582 PARROT_CALLIN_END(interp
);
587 =item C<void Parrot_PMC_set_intval_intkey>
589 Assign the passed-in Parrot integer to the passed-in PMC.
597 Parrot_PMC_set_intval_intkey(PARROT_INTERP
,
598 Parrot_PMC pmc
, Parrot_Int key
, Parrot_Int value
)
600 PARROT_CALLIN_START(interp
);
601 VTABLE_set_integer_keyed_int(interp
, pmc
, key
, value
);
602 PARROT_CALLIN_END(interp
);
607 =item C<void Parrot_PMC_set_numval>
609 Assign the passed-in Parrot number to the passed-in PMC.
617 Parrot_PMC_set_numval(PARROT_INTERP
, Parrot_PMC pmc
, Parrot_Float value
)
619 PARROT_CALLIN_START(interp
);
620 VTABLE_set_number_native(interp
, pmc
, value
);
621 PARROT_CALLIN_END(interp
);
626 =item C<void Parrot_PMC_set_numval_intkey>
628 Assign the passed-in Parrot number to the passed-in PMC.
636 Parrot_PMC_set_numval_intkey(PARROT_INTERP
,
637 Parrot_PMC pmc
, Parrot_Int key
, Parrot_Float value
)
639 PARROT_CALLIN_START(interp
);
640 VTABLE_set_number_keyed_int(interp
, pmc
, key
, value
);
641 PARROT_CALLIN_END(interp
);
646 =item C<void Parrot_PMC_set_cstring>
648 Assign the passed-in null-terminated C string to the passed-in PMC.
656 Parrot_PMC_set_cstring(PARROT_INTERP
, Parrot_PMC pmc
, ARGIN_NULLOK(const char *value
))
658 PARROT_CALLIN_START(interp
);
659 VTABLE_set_string_native(interp
, pmc
,
660 string_from_cstring(interp
, value
, 0));
661 PARROT_CALLIN_END(interp
);
666 =item C<void Parrot_PMC_set_cstring_intkey>
668 Assign the passed-in null-terminated C string to the passed-in PMC.
676 Parrot_PMC_set_cstring_intkey(PARROT_INTERP
,
677 Parrot_PMC pmc
, Parrot_Int key
, ARGIN_NULLOK(const char *value
))
679 PARROT_CALLIN_START(interp
);
680 VTABLE_set_string_keyed_int(interp
, pmc
, key
,
681 string_from_cstring(interp
, value
, 0));
682 PARROT_CALLIN_END(interp
);
687 =item C<void Parrot_PMC_set_cstringn>
689 Assign the passed-in length-noted string to the passed-in PMC.
697 Parrot_PMC_set_cstringn(PARROT_INTERP
,
698 Parrot_PMC pmc
, ARGIN_NULLOK(const char *value
), Parrot_Int length
)
700 PARROT_CALLIN_START(interp
);
701 VTABLE_set_string_native(interp
, pmc
,
702 string_from_cstring(interp
, value
, length
));
703 PARROT_CALLIN_END(interp
);
708 =item C<void Parrot_PMC_push_intval>
710 Push the passed-in Parrot integer onto the passed in PMC
718 Parrot_PMC_push_intval(PARROT_INTERP
,
719 Parrot_PMC pmc
, Parrot_Int value
)
721 PARROT_CALLIN_START(interp
);
722 VTABLE_push_integer(interp
, pmc
, value
);
723 PARROT_CALLIN_END(interp
);
728 =item C<void Parrot_PMC_push_numval>
730 Push the passed-in Parrot number onto the passed in PMC
738 Parrot_PMC_push_numval(PARROT_INTERP
, Parrot_PMC pmc
, Parrot_Float value
)
740 PARROT_CALLIN_START(interp
);
741 VTABLE_push_float(interp
, pmc
, value
);
742 PARROT_CALLIN_END(interp
);
747 =item C<void Parrot_PMC_delete_pmckey>
749 Deletes the value associated with the passed-in PMC from the PMC.
757 Parrot_PMC_delete_pmckey(PARROT_INTERP
, Parrot_PMC pmc
, Parrot_PMC key
)
759 PARROT_CALLIN_START(interp
);
760 VTABLE_delete_keyed(interp
, pmc
, key
);
761 PARROT_CALLIN_END(interp
);
766 =item C<void Parrot_PMC_set_cstringn_intkey>
768 Assign the passed-in length-noted string to the passed-in PMC.
776 Parrot_PMC_set_cstringn_intkey(PARROT_INTERP
,
777 Parrot_PMC pmc
, Parrot_Int key
, ARGIN_NULLOK(const char *value
), Parrot_Int length
)
779 PARROT_CALLIN_START(interp
);
780 VTABLE_set_string_keyed_int(interp
, pmc
, key
,
781 string_from_cstring(interp
, value
, length
));
782 PARROT_CALLIN_END(interp
);
787 =item C<Parrot_PMC Parrot_PMC_new>
789 Create and return a new PMC.
797 Parrot_PMC_new(PARROT_INTERP
, Parrot_Int type
)
800 PARROT_CALLIN_START(interp
);
801 newpmc
= pmc_new_noinit(interp
, type
);
802 VTABLE_init(interp
, newpmc
);
803 PARROT_CALLIN_END(interp
);
809 =item C<Parrot_Int Parrot_PMC_typenum>
811 Returns the internal identifier that represents the named class.
819 Parrot_PMC_typenum(PARROT_INTERP
, ARGIN_NULLOK(const char *_class
))
822 PARROT_CALLIN_START(interp
);
823 retval
= pmc_type(interp
, string_from_cstring(interp
, _class
, 0));
824 PARROT_CALLIN_END(interp
);
830 =item C<Parrot_PMC Parrot_PMC_null>
832 Returns the special C<NULL> PMC.
840 Parrot_PMC_null(void)
847 =item C<void Parrot_free_cstring>
849 Deallocate a C string that the interpreter has handed to you.
857 Parrot_free_cstring(ARGIN_NULLOK(char *string
))
859 string_cstring_free(string
);
864 =item C<void* Parrot_call_sub>
866 Call a parrot subroutine with the given function signature. The first char in
867 C<signature> denotes the return value. Next chars are arguments.
869 The return value of this function can be void or a pointer type.
884 PARROT_WARN_UNUSED_RESULT
885 PARROT_CAN_RETURN_NULL
887 Parrot_call_sub(PARROT_INTERP
, Parrot_PMC sub
,
888 ARGIN(const char *signature
), ...)
893 PARROT_CALLIN_START(interp
);
895 va_start(ap
, signature
);
896 CONTEXT(interp
)->constants
=
897 PMC_sub(sub
)->seg
->const_table
->constants
;
898 result
= Parrot_runops_fromc_arglist(interp
, sub
, signature
, ap
);
901 PARROT_CALLIN_END(interp
);
907 =item C<Parrot_Int Parrot_call_sub_ret_int>
909 Like C<Parrot_call_sub>, with Parrot_Int return result.
917 Parrot_call_sub_ret_int(PARROT_INTERP
, Parrot_PMC sub
,
918 ARGIN(const char *signature
), ...)
923 PARROT_CALLIN_START(interp
);
925 va_start(ap
, signature
);
926 CONTEXT(interp
)->constants
=
927 PMC_sub(sub
)->seg
->const_table
->constants
;
928 result
= Parrot_runops_fromc_arglist_reti(interp
, sub
, signature
, ap
);
931 PARROT_CALLIN_END(interp
);
937 =item C<Parrot_Float Parrot_call_sub_ret_float>
939 Like C<Parrot_call_sub>, with Parrot_Float return result.
947 Parrot_call_sub_ret_float(PARROT_INTERP
, Parrot_PMC sub
,
948 ARGIN(const char *signature
), ...)
953 PARROT_CALLIN_START(interp
);
955 va_start(ap
, signature
);
956 CONTEXT(interp
)->constants
=
957 PMC_sub(sub
)->seg
->const_table
->constants
;
958 result
= Parrot_runops_fromc_arglist_retf(interp
, sub
, signature
, ap
);
961 PARROT_CALLIN_END(interp
);
967 =item C<void * Parrot_call_method>
969 Call the parrot subroutine C<sub> as a method on PMC object C<obj>. The method
970 should have the name C<method> as a Parrot_string, and should have a function
971 signature C<signature>. Any arguments to the method can be passed at the end
972 as a variadic argument list.
979 PARROT_WARN_UNUSED_RESULT
980 PARROT_CAN_RETURN_NULL
982 Parrot_call_method(PARROT_INTERP
, Parrot_PMC sub
, Parrot_PMC obj
,
983 Parrot_String method
, ARGIN(const char *signature
), ...)
988 PARROT_CALLIN_START(interp
);
989 va_start(ap
, signature
);
990 result
= Parrot_run_meth_fromc_arglist(interp
, sub
,
991 obj
, method
, signature
, ap
);
993 PARROT_CALLIN_END(interp
);
999 =item C<Parrot_Int Parrot_call_method_ret_int>
1001 Call a parrot method for the given object.
1009 Parrot_call_method_ret_int(PARROT_INTERP
, Parrot_PMC sub
,
1010 Parrot_PMC obj
, Parrot_String method
, ARGIN(const char *signature
), ...)
1015 PARROT_CALLIN_START(interp
);
1016 va_start(ap
, signature
);
1017 result
= Parrot_run_meth_fromc_arglist_reti(interp
, sub
,
1018 obj
, method
, signature
, ap
);
1020 PARROT_CALLIN_END(interp
);
1026 =item C<Parrot_Float Parrot_call_method_ret_float>
1028 Call a parrot method for the given object.
1036 Parrot_call_method_ret_float(PARROT_INTERP
, Parrot_PMC sub
,
1037 Parrot_PMC obj
, Parrot_String method
, ARGIN(const char *signature
), ...)
1039 Parrot_Float result
;
1042 PARROT_CALLIN_START(interp
);
1043 va_start(ap
, signature
);
1044 result
= Parrot_run_meth_fromc_arglist_retf(interp
, sub
,
1045 obj
, method
, signature
, ap
);
1047 PARROT_CALLIN_END(interp
);
1053 =item C<Parrot_Int Parrot_get_intreg>
1055 Return the value of an integer register.
1063 Parrot_get_intreg(PARROT_INTERP
, Parrot_Int regnum
)
1065 return REG_INT(interp
, regnum
);
1070 =item C<Parrot_Float Parrot_get_numreg>
1072 Return the value of a numeric register.
1080 Parrot_get_numreg(PARROT_INTERP
, Parrot_Int regnum
)
1082 return REG_NUM(interp
, regnum
);
1087 =item C<Parrot_String Parrot_get_strreg>
1089 Return the value of a string register.
1097 Parrot_get_strreg(PARROT_INTERP
, Parrot_Int regnum
)
1099 return REG_STR(interp
, regnum
);
1104 =item C<Parrot_PMC Parrot_get_pmcreg>
1106 Return the value of a PMC register.
1114 Parrot_get_pmcreg(PARROT_INTERP
, Parrot_Int regnum
)
1116 return REG_PMC(interp
, regnum
);
1121 =item C<void Parrot_set_intreg>
1123 Set the value of an I register.
1131 Parrot_set_intreg(PARROT_INTERP
, Parrot_Int regnum
,
1134 REG_INT(interp
, regnum
) = value
;
1139 =item C<void Parrot_set_numreg>
1141 Set the value of an N register.
1149 Parrot_set_numreg(PARROT_INTERP
, Parrot_Int regnum
,
1152 REG_NUM(interp
, regnum
) = value
;
1157 =item C<void Parrot_set_strreg>
1159 Set the value of an S register.
1165 Parrot_set_strreg(PARROT_INTERP
, Parrot_Int regnum
,
1166 Parrot_String value
)
1168 REG_STR(interp
, regnum
) = value
;
1173 =item C<void Parrot_set_pmcreg>
1175 Set the value of a P register.
1183 Parrot_set_pmcreg(PARROT_INTERP
, Parrot_Int regnum
,
1186 REG_PMC(interp
, regnum
) = value
;
1189 /*=for api extend Parrot_new_string
1194 =item C<Parrot_String Parrot_new_string>
1196 Create a new Parrot string from a passed-in buffer. Pass in a 0 for
1197 flags for right now.
1199 A copy of the buffer is made.
1206 PARROT_WARN_UNUSED_RESULT
1207 PARROT_CANNOT_RETURN_NULL
1209 Parrot_new_string(PARROT_INTERP
, ARGIN_NULLOK(const char *buffer
), int length
,
1210 ARGIN_NULLOK(const char * const encoding_name
), Parrot_Int flags
)
1212 Parrot_String retval
;
1213 PARROT_CALLIN_START(interp
);
1214 retval
= string_make(interp
, buffer
, length
, encoding_name
, flags
);
1215 PARROT_CALLIN_END(interp
);
1221 =item C<Parrot_Language Parrot_find_language>
1223 Find the magic language token for a language, by language name.
1230 PARROT_WARN_UNUSED_RESULT
1232 Parrot_find_language(SHIM_INTERP
, SHIM(char *language
))
1239 =item C<void Parrot_register_pmc>
1241 Add a reference of the PMC to the interpreters DOD registry. This
1242 prevents PMCs only known to extension from getting destroyed during DOD
1251 Parrot_register_pmc(PARROT_INTERP
, Parrot_PMC pmc
)
1253 PARROT_CALLIN_START(interp
);
1254 dod_register_pmc(interp
, pmc
);
1255 PARROT_CALLIN_END(interp
);
1260 =item C<void Parrot_unregister_pmc>
1262 Remove a reference of the PMC from the interpreters DOD registry. If the
1263 reference count reaches zero, the PMC will be destroyed during the next
1272 Parrot_unregister_pmc(PARROT_INTERP
, Parrot_PMC pmc
)
1274 PARROT_CALLIN_START(interp
);
1275 dod_unregister_pmc(interp
, pmc
);
1276 PARROT_CALLIN_END(interp
);
1281 =item C<void Parrot_PMC_set_vtable>
1283 Replaces the vtable of the PMC.
1291 Parrot_PMC_set_vtable(SHIM_INTERP
, Parrot_PMC pmc
, Parrot_VTABLE vtable
)
1293 pmc
->vtable
= vtable
;
1298 =item C<Parrot_VTABLE Parrot_get_vtable>
1300 Returns the vtable corresponding to the given PMC ID.
1307 PARROT_PURE_FUNCTION
1309 Parrot_get_vtable(PARROT_INTERP
, Parrot_Int id
)
1311 return interp
->vtables
[id
];
1320 See F<include/parrot/extend.h> and F<docs/pdds/pdd11_extending.pod>.
1324 Initial version by Dan Sugalski.
1333 * c-file-style: "parrot"
1335 * vim: expandtab shiftwidth=4: