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"
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_API Parrot_String
77 Parrot_PMC_get_string_intkey(Parrot_Interp interp
,
78 Parrot_PMC pmc
, Parrot_Int key
) {
80 PARROT_CALLIN_START(interp
);
81 retval
= VTABLE_get_string_keyed_int(interp
, pmc
, key
);
82 PARROT_CALLIN_END(interp
);
90 Parrot_PMC_get_pointer_intkey(Parrot_Interp interp, Parrot_PMC pmc,
93 Return the keyed, signed integer value of the value in the PMC.
100 Parrot_PMC_get_pointer_intkey(Parrot_Interp interp
, Parrot_PMC pmc
,
103 PARROT_CALLIN_START(interp
);
104 retval
= VTABLE_get_pointer_keyed_int(interp
, pmc
, key
);
105 PARROT_CALLIN_END(interp
);
112 Parrot_PMC_get_pmc_intkey(Parrot_Interp interp, Parrot_PMC pmc, Parrot_Int key)>
114 Return the integer keyed PMC value of the passed-in PMC
120 PARROT_API Parrot_PMC
121 Parrot_PMC_get_pmc_intkey(Parrot_Interp interp
, Parrot_PMC pmc
,
124 PARROT_CALLIN_START(interp
);
125 retval
= VTABLE_get_pmc_keyed_int(interp
, pmc
, key
);
126 PARROT_CALLIN_END(interp
);
133 Parrot_PMC_get_intval(Parrot_Interp interp, Parrot_PMC pmc)>
135 Return the signed integer value of the value in the PMC.
141 PARROT_API Parrot_Int
142 Parrot_PMC_get_intval(Parrot_Interp interp
, Parrot_PMC pmc
) {
144 PARROT_CALLIN_START(interp
);
145 retval
= VTABLE_get_integer(interp
, pmc
);
146 PARROT_CALLIN_END(interp
);
153 Parrot_PMC_get_intval_intkey(Parrot_Interp interp, Parrot_PMC pmc,
156 Return the keyed, signed integer value of the value in the PMC.
162 PARROT_API Parrot_Int
163 Parrot_PMC_get_intval_intkey(Parrot_Interp interp
, Parrot_PMC pmc
,
166 PARROT_CALLIN_START(interp
);
167 retval
= VTABLE_get_integer_keyed_int(interp
, pmc
, key
);
168 PARROT_CALLIN_END(interp
);
175 Parrot_PMC_get_intval_pmckey(Parrot_Interp interp, Parrot_PMC pmc,
178 Return the keyed, signed integer value of the value in the PMC.
184 PARROT_API Parrot_Int
185 Parrot_PMC_get_intval_pmckey(Parrot_Interp interp
, Parrot_PMC pmc
,
188 PARROT_CALLIN_START(interp
);
189 retval
= VTABLE_get_integer_keyed(interp
, pmc
, key
);
190 PARROT_CALLIN_END(interp
);
197 Parrot_PMC_get_numval(Parrot_Interp interp, Parrot_PMC pmc)>
199 Return the floating-point value of the PMC.
205 PARROT_API Parrot_Float
206 Parrot_PMC_get_numval(Parrot_Interp interp
, Parrot_PMC pmc
) {
208 PARROT_CALLIN_START(interp
);
209 retval
= VTABLE_get_number(interp
, pmc
);
210 PARROT_CALLIN_END(interp
);
217 Parrot_PMC_get_numval_intkey(Parrot_Interp interp, Parrot_PMC pmc,
220 Return the keyed, signed integer value of the value in the PMC.
226 PARROT_API Parrot_Float
227 Parrot_PMC_get_numval_intkey(Parrot_Interp interp
, Parrot_PMC pmc
,
230 PARROT_CALLIN_START(interp
);
231 retval
= VTABLE_get_number_keyed_int(interp
, pmc
, key
);
232 PARROT_CALLIN_END(interp
);
239 Parrot_PMC_get_cstring_intkey(Parrot_Interp interp, Parrot_PMC pmc,
242 Return a null-terminated string that represents the string value of the PMC.
244 Note that you must free this string with C<string_cstring_free()>!
251 Parrot_PMC_get_cstring_intkey(Parrot_Interp interp
, Parrot_PMC pmc
,
253 STRING
*intermediate
;
256 PARROT_CALLIN_START(interp
);
257 intermediate
= VTABLE_get_string_keyed_int(interp
, pmc
, key
);
258 retval
= string_to_cstring(interp
, intermediate
);
259 PARROT_CALLIN_END(interp
);
266 =item C<char *Parrot_PMC_get_cstring(Parrot_Interp interp, Parrot_PMC pmc)>
268 Return a null-terminated string that represents the string value of the PMC.
270 Note that you must free this string with C<string_cstring_free()>!
277 Parrot_PMC_get_cstring(Parrot_Interp interp
, Parrot_PMC pmc
) {
278 STRING
*intermediate
;
281 PARROT_CALLIN_START(interp
);
282 intermediate
= VTABLE_get_string(interp
, pmc
);
283 retval
= string_to_cstring(interp
, intermediate
);
284 PARROT_CALLIN_END(interp
);
292 Parrot_PMC_get_cstringn(Parrot_Interp interp, Parrot_PMC pmc,
295 Return a null-terminated string for the PMC, along with the length.
297 Yes, right now this is a bit of a cheat. It needs fixing, but without
298 disturbing the interface.
300 Note that you must free the string with C<string_cstring_free()>.
307 Parrot_PMC_get_cstringn(Parrot_Interp interp
, Parrot_PMC pmc
,
308 Parrot_Int
*length
) {
311 PARROT_CALLIN_START(interp
);
312 retval
= string_to_cstring(interp
, VTABLE_get_string(interp
, pmc
));
313 *length
= strlen(retval
);
314 PARROT_CALLIN_END(interp
);
322 Parrot_PMC_get_cstringn_intkey(Parrot_Interp interp, Parrot_PMC pmc,
323 Parrot_Int *length, Parrot_Int key)>
325 Return a null-terminated string for the PMC, along with the length.
327 Yes, right now this is a bit of a cheat. It needs fixing, but without
328 disturbing the interface.
330 Note that you must free this string with C<string_cstring_free()>.
337 Parrot_PMC_get_cstringn_intkey(Parrot_Interp interp
, Parrot_PMC pmc
,
338 Parrot_Int
*length
, Parrot_Int key
) {
341 PARROT_CALLIN_START(interp
);
342 retval
= string_to_cstring(interp
,
343 VTABLE_get_string_keyed_int(interp
, pmc
, key
));
344 *length
= strlen(retval
);
345 PARROT_CALLIN_END(interp
);
353 Parrot_PMC_set_string(Parrot_Interp interp, Parrot_PMC pmc,
354 Parrot_String value)>
356 Assign the passed-in Parrot string to the passed-in PMC.
363 Parrot_PMC_set_string(Parrot_Interp interp
, Parrot_PMC pmc
,
364 Parrot_String value
) {
365 PARROT_CALLIN_START(interp
);
366 VTABLE_set_string_native(interp
, pmc
, value
);
367 PARROT_CALLIN_END(interp
);
373 Parrot_PMC_set_string_intkey(Parrot_Interp interp, Parrot_PMC pmc,
374 Parrot_Int key, Parrot_String value)>
376 Assign the passed-in Parrot string to the passed-in PMC.
383 Parrot_PMC_set_string_intkey(Parrot_Interp interp
, Parrot_PMC pmc
,
384 Parrot_Int key
, Parrot_String value
)
386 PARROT_CALLIN_START(interp
);
387 VTABLE_set_string_keyed_int(interp
, pmc
, key
, value
);
388 PARROT_CALLIN_END(interp
);
394 Parrot_PMC_set_pmc_intkey(Parrot_Interp interp, Parrot_PMC pmc,
395 Parrot_Int key, Parrot_PMC value)>
397 Assign the passed-in pmc to the passed-in slot of the passed-in PMC.
404 Parrot_PMC_set_pmc_intkey(Parrot_Interp interp
, Parrot_PMC pmc
,
405 Parrot_Int key
, Parrot_PMC value
) {
406 PARROT_CALLIN_START(interp
);
407 VTABLE_set_pmc_keyed_int(interp
, pmc
, key
, value
);
408 PARROT_CALLIN_END(interp
);
414 Parrot_PMC_set_pmc_pmckey(Parrot_Interp interp, Parrot_PMC pmc,
415 Parrot_PMC key, Parrot_PMC value)>
417 Assign the passed-in pmc to the passed-in slot of the passed-in PMC.
424 Parrot_PMC_set_pmc_pmckey(Parrot_Interp interp
, Parrot_PMC pmc
,
425 Parrot_PMC key
, Parrot_PMC value
) {
426 PARROT_CALLIN_START(interp
);
427 VTABLE_set_pmc_keyed(interp
, pmc
, key
, value
);
428 PARROT_CALLIN_END(interp
);
434 Parrot_PMC_set_pointer_intkey(Parrot_Interp interp, Parrot_PMC pmc,
435 Parrot_Int key, void *value)>
437 Assign the passed-in pointer to the passed-in PMC.
444 Parrot_PMC_set_pointer_intkey(Parrot_Interp interp
, Parrot_PMC pmc
,
445 Parrot_Int key
, void *value
) {
446 PARROT_CALLIN_START(interp
);
447 VTABLE_set_pointer_keyed_int(interp
, pmc
, key
, value
);
448 PARROT_CALLIN_END(interp
);
454 Parrot_PMC_set_intval(Parrot_Interp interp, Parrot_PMC pmc, Parrot_Int value)>
456 Assign the passed-in Parrot integer to the passed-in PMC.
463 Parrot_PMC_set_intval(Parrot_Interp interp
, Parrot_PMC pmc
, Parrot_Int value
) {
464 PARROT_CALLIN_START(interp
);
465 VTABLE_set_integer_native(interp
, pmc
, value
);
466 PARROT_CALLIN_END(interp
);
472 Parrot_PMC_set_intval_intkey(Parrot_Interp interp, Parrot_PMC pmc,
473 Parrot_Int key, Parrot_Int value)>
475 Assign the passed-in Parrot integer to the passed-in PMC.
482 Parrot_PMC_set_intval_intkey(Parrot_Interp interp
, Parrot_PMC pmc
,
483 Parrot_Int key
, Parrot_Int value
) {
484 PARROT_CALLIN_START(interp
);
485 VTABLE_set_integer_keyed_int(interp
, pmc
, key
, value
);
486 PARROT_CALLIN_END(interp
);
492 Parrot_PMC_set_numval(Parrot_Interp interp, Parrot_PMC pmc, Parrot_Float value)>
494 Assign the passed-in Parrot number to the passed-in PMC.
501 Parrot_PMC_set_numval(Parrot_Interp interp
, Parrot_PMC pmc
, Parrot_Float value
){
502 PARROT_CALLIN_START(interp
);
503 VTABLE_set_number_native(interp
, pmc
, value
);
504 PARROT_CALLIN_END(interp
);
510 Parrot_PMC_set_numval_intkey(Parrot_Interp interp, Parrot_PMC pmc,
511 Parrot_Int key, Parrot_Float value)>
513 Assign the passed-in Parrot number to the passed-in PMC.
520 Parrot_PMC_set_numval_intkey(Parrot_Interp interp
, Parrot_PMC pmc
,
521 Parrot_Int key
, Parrot_Float value
) {
522 PARROT_CALLIN_START(interp
);
523 VTABLE_set_number_keyed_int(interp
, pmc
, key
, value
);
524 PARROT_CALLIN_END(interp
);
530 Parrot_PMC_set_cstring(Parrot_Interp interp, Parrot_PMC pmc, const char *value)>
532 Assign the passed-in null-terminated C string to the passed-in PMC.
539 Parrot_PMC_set_cstring(Parrot_Interp interp
, Parrot_PMC pmc
, const char *value
){
540 PARROT_CALLIN_START(interp
);
541 VTABLE_set_string_native(interp
, pmc
,
542 string_from_cstring(interp
, value
, 0));
543 PARROT_CALLIN_END(interp
);
549 Parrot_PMC_set_cstring_intkey(Parrot_Interp interp, Parrot_PMC pmc,
550 Parrot_Int key, const char *value)>
552 Assign the passed-in null-terminated C string to the passed-in PMC.
559 Parrot_PMC_set_cstring_intkey(Parrot_Interp interp
, Parrot_PMC pmc
,
560 Parrot_Int key
, const char *value
) {
561 PARROT_CALLIN_START(interp
);
562 VTABLE_set_string_keyed_int(interp
, pmc
, key
,
563 string_from_cstring(interp
, value
, 0));
564 PARROT_CALLIN_END(interp
);
570 Parrot_PMC_set_cstringn(Parrot_Interp interp, Parrot_PMC pmc,
571 const char *value, Parrot_Int length)>
573 Assign the passed-in length-noted string to the passed-in PMC.
580 Parrot_PMC_set_cstringn(Parrot_Interp interp
, Parrot_PMC pmc
,
581 const char *value
, Parrot_Int length
) {
582 PARROT_CALLIN_START(interp
);
583 VTABLE_set_string_native(interp
, pmc
,
584 string_from_cstring(interp
, value
, length
));
585 PARROT_CALLIN_END(interp
);
591 Parrot_PMC_push_intval(Parrot_Interp interp, Parrot_PMC pmc,
594 Push the passed-in Parrot integer onto the passed in PMC
601 Parrot_PMC_push_intval(Parrot_Interp interp
, Parrot_PMC pmc
,
603 PARROT_CALLIN_START(interp
);
604 VTABLE_push_integer(interp
, pmc
, value
);
605 PARROT_CALLIN_END(interp
);
611 Parrot_PMC_push_numval(Parrot_Interp interp, Parrot_PMC pmc,
614 Push the passed-in Parrot number onto the passed in PMC
621 Parrot_PMC_push_numval(Parrot_Interp interp
, Parrot_PMC pmc
,
622 Parrot_Float value
) {
623 PARROT_CALLIN_START(interp
);
624 VTABLE_push_float(interp
, pmc
, value
);
625 PARROT_CALLIN_END(interp
);
631 Parrot_PMC_delete_pmckey(Parrot_Interp interp, Parrot_PMC pmc,
634 Deletes the value associated with the passed-in PMC from the PMC.
641 Parrot_PMC_delete_pmckey(Parrot_Interp interp
, Parrot_PMC pmc
,
643 PARROT_CALLIN_START(interp
);
644 VTABLE_delete_keyed(interp
, pmc
, key
);
645 PARROT_CALLIN_END(interp
);
651 Parrot_PMC_set_cstringn_intkey(Parrot_Interp interp, Parrot_PMC pmc,
653 const char *value, Parrot_Int length)>
655 Assign the passed-in length-noted string to the passed-in PMC.
662 Parrot_PMC_set_cstringn_intkey(Parrot_Interp interp
, Parrot_PMC pmc
,
664 const char *value
, Parrot_Int length
) {
665 PARROT_CALLIN_START(interp
);
666 VTABLE_set_string_keyed_int(interp
, pmc
, key
,
667 string_from_cstring(interp
, value
, length
));
668 PARROT_CALLIN_END(interp
);
673 =item C<Parrot_PMC Parrot_PMC_new(Parrot_Interp interp, Parrot_Int type)>
675 Create and return a new PMC.
681 PARROT_API Parrot_PMC
682 Parrot_PMC_new(Parrot_Interp interp
, Parrot_Int type
) {
684 PARROT_CALLIN_START(interp
);
685 newpmc
= pmc_new_noinit(interp
, type
);
686 VTABLE_init(interp
, newpmc
);
687 PARROT_CALLIN_END(interp
);
693 =item C<Parrot_Int Parrot_PMC_typenum(Parrot_Interp interp, const char *_class)>
695 Returns the internal identifier that represents the named class.
701 PARROT_API Parrot_Int
702 Parrot_PMC_typenum(Parrot_Interp interp
, const char *_class
) {
704 PARROT_CALLIN_START(interp
);
705 retval
= pmc_type(interp
, string_from_cstring(interp
, _class
, 0));
706 PARROT_CALLIN_END(interp
);
712 =item C<Parrot_PMC Parrot_PMC_null()>
714 Returns the special C<NULL> PMC.
720 PARROT_API Parrot_PMC
721 Parrot_PMC_null(void) {
727 =item C<void Parrot_free_cstring(char *string)>
729 Deallocate a C string that the interpreter has handed to you.
736 Parrot_free_cstring(char *string
) {
737 string_cstring_free(string
);
743 Parrot_call_sub(Parrot_Interp interp, Parrot_PMC sub,
744 const char *signature, ...)>
746 Call a parrot subroutine with the given function signature. The first char in
747 C<signature> denotes the return value. Next chars are arguments.
749 The return value of this function can be void or a pointer type.
760 Parrot_call_sub_ret_int(Parrot_Interp interp, Parrot_PMC sub,
761 const char *signature, ...)>
763 =item C<Parrot_Float>
764 Parrot_call_sub_ret_float(Parrot_Interp interp, Parrot_PMC sub,
765 const char *signature, ...)>
767 Like above, with Parrot_Int or Parrot_Float return result.
774 Parrot_call_sub(Parrot_Interp interp
, Parrot_PMC sub
,
775 const char *signature
, ...)
780 PARROT_CALLIN_START(interp
);
782 va_start(ap
, signature
);
783 CONTEXT(interp
->ctx
)->constants
=
784 PMC_sub(sub
)->seg
->const_table
->constants
;
785 result
= Parrot_runops_fromc_arglist(interp
, sub
, signature
, ap
);
788 PARROT_CALLIN_END(interp
);
792 PARROT_API Parrot_Int
793 Parrot_call_sub_ret_int(Parrot_Interp interp
, Parrot_PMC sub
,
794 const char *signature
, ...)
799 PARROT_CALLIN_START(interp
);
801 va_start(ap
, signature
);
802 CONTEXT(interp
->ctx
)->constants
=
803 PMC_sub(sub
)->seg
->const_table
->constants
;
804 result
= Parrot_runops_fromc_arglist_reti(interp
, sub
, signature
, ap
);
807 PARROT_CALLIN_END(interp
);
811 PARROT_API Parrot_Float
812 Parrot_call_sub_ret_float(Parrot_Interp interp
, Parrot_PMC sub
,
813 const char *signature
, ...)
818 PARROT_CALLIN_START(interp
);
820 va_start(ap
, signature
);
821 CONTEXT(interp
->ctx
)->constants
=
822 PMC_sub(sub
)->seg
->const_table
->constants
;
823 result
= Parrot_runops_fromc_arglist_retf(interp
, sub
, signature
, ap
);
826 PARROT_CALLIN_END(interp
);
832 =item C<void* Parrot_call_method(Parrot_Interp interp, Parrot_PMC sub,
833 Parrot_PMC object, Parrot_String method, const char *signature, ...)>
835 =item C<Parrot_Int Parrot_call_method_ret_int(Parrot_Interp interp,
836 Parrot_PMC sub, Parrot_PMC object, Parrot_String method,
837 const char *signature, ...)>
839 =item C<Parrot_Float Parrot_call_method_ret_float(Parrot_Interp interp,
840 Parrot_PMC sub, Parrot_PMC object, Parrot_String method,
841 const char *signature, ...)>
843 Call a parrot method for the given object.
850 Parrot_call_method(Parrot_Interp interp
, Parrot_PMC sub
, Parrot_PMC obj
,
851 Parrot_String method
, const char *signature
, ...)
856 PARROT_CALLIN_START(interp
);
857 va_start(ap
, signature
);
858 result
= Parrot_run_meth_fromc_arglist(interp
, sub
,
859 obj
, method
, signature
, ap
);
861 PARROT_CALLIN_END(interp
);
865 PARROT_API Parrot_Int
866 Parrot_call_method_ret_int(Parrot_Interp interp
, Parrot_PMC sub
,
867 Parrot_PMC obj
, Parrot_String method
, const char *signature
, ...)
872 PARROT_CALLIN_START(interp
);
873 va_start(ap
, signature
);
874 result
= Parrot_run_meth_fromc_arglist_reti(interp
, sub
,
875 obj
, method
, signature
, ap
);
877 PARROT_CALLIN_END(interp
);
881 PARROT_API Parrot_Float
882 Parrot_call_method_ret_float(Parrot_Interp interp
, Parrot_PMC sub
,
883 Parrot_PMC obj
, Parrot_String method
, const char *signature
, ...)
888 PARROT_CALLIN_START(interp
);
889 va_start(ap
, signature
);
890 result
= Parrot_run_meth_fromc_arglist_retf(interp
, sub
,
891 obj
, method
, signature
, ap
);
893 PARROT_CALLIN_END(interp
);
900 Parrot_get_intreg(Parrot_Interp interp, Parrot_Int regnum)>
902 Return the value of an integer register.
908 PARROT_API Parrot_Int
909 Parrot_get_intreg(Parrot_Interp interp
, Parrot_Int regnum
)
911 return REG_INT(regnum
);
917 Parrot_get_numreg(Parrot_Interp interp, Parrot_Int regnum)>
919 Return the value of a numeric register.
925 PARROT_API Parrot_Float
926 Parrot_get_numreg(Parrot_Interp interp
, Parrot_Int regnum
)
928 return REG_NUM(regnum
);
933 =item C<Parrot_String
934 Parrot_get_strreg(Parrot_Interp interp, Parrot_Int regnum)>
936 Return the value of a string register.
942 PARROT_API Parrot_String
943 Parrot_get_strreg(Parrot_Interp interp
, Parrot_Int regnum
)
945 return REG_STR(regnum
);
951 Parrot_get_pmcreg(Parrot_Interp interp, Parrot_Int regnum)>
953 Return the value of a PMC register.
959 PARROT_API Parrot_PMC
960 Parrot_get_pmcreg(Parrot_Interp interp
, Parrot_Int regnum
)
962 return REG_PMC(regnum
);
968 Parrot_set_intreg(Parrot_Interp interp, Parrot_Int regnum,
971 Set the value of an I register.
978 Parrot_set_intreg(Parrot_Interp interp
, Parrot_Int regnum
,
981 REG_INT(regnum
) = value
;
987 Parrot_set_numreg(Parrot_Interp interp, Parrot_Int regnum,
990 Set the value of an N register.
997 Parrot_set_numreg(Parrot_Interp interp
, Parrot_Int regnum
,
1000 REG_NUM(regnum
) = value
;
1006 Parrot_set_strreg(Parrot_Interp interp, Parrot_Int regnum,
1007 Parrot_String value)>
1009 Set the value of an S register.
1016 Parrot_set_strreg(Parrot_Interp interp
, Parrot_Int regnum
,
1017 Parrot_String value
)
1019 REG_STR(regnum
) = value
;
1025 Parrot_set_pmcreg(Parrot_Interp interp, Parrot_Int regnum,
1028 Set the value of a P register.
1035 Parrot_set_pmcreg(Parrot_Interp interp
, Parrot_Int regnum
,
1038 REG_PMC(regnum
) = value
;
1041 /*=for api extend Parrot_new_string
1046 =item C<Parrot_String Parrot_new_string(Parrot_Interp interp,
1047 char *buffer, int length,
1048 const char * const encoding_name,
1051 Create a new Parrot string from a passed-in buffer. Pass in a 0 for
1052 flags for right now.
1054 A copy of the buffer is made.
1060 PARROT_API Parrot_String
1061 Parrot_new_string(Parrot_Interp interp
,
1062 char *buffer
, int length
,
1063 const char * const encoding_name
,
1066 Parrot_String retval
;
1067 PARROT_CALLIN_START(interp
);
1068 retval
= string_make(interp
, buffer
, length
, encoding_name
, flags
);
1069 PARROT_CALLIN_END(interp
);
1075 =item C<Parrot_Const_Encoding
1076 Parrot_find_encoding(Parrot_Interp interp, char *encoding_name)>
1078 Find the magic token for an encoding, by name.
1084 PARROT_API Parrot_Const_Encoding
1085 Parrot_find_encoding(Parrot_Interp interp,
1086 char *encoding_name) {
1087 return Parrot_encoding_lookup(encoding_name);
1092 =item C<Parrot_Language
1093 Parrot_find_language(Parrot_Interp interp, char *language)>
1095 Find the magic language token for a language, by language name.
1101 PARROT_API Parrot_Language
1102 Parrot_find_language(Parrot_Interp interp
, char *language
)
1110 Parrot_register_pmc(Parrot_Interp interp, Parrot_PMC pmc)>
1112 Add a reference of the PMC to the interpreters DOD registry. This
1113 prevents PMCs only known to extension from getting destroyed during DOD
1121 Parrot_register_pmc(Parrot_Interp interp
, Parrot_PMC pmc
)
1123 PARROT_CALLIN_START(interp
);
1124 dod_register_pmc(interp
, pmc
);
1125 PARROT_CALLIN_END(interp
);
1131 Parrot_unregister_pmc(Parrot_Interp interp, Parrot_PMC pmc)>
1133 Remove a reference of the PMC from the interpreters DOD registry. If the
1134 reference count reaches zero, the PMC will be destroyed during the next
1137 =item C<Parrot_PMC Parrot_get_dod_registry(Parrot_Interp)>
1139 Return Parrot's internal DOD registry PMC.
1140 See also: F<src/pmc/addrregistry.pmc>.
1147 Parrot_unregister_pmc(Parrot_Interp interp
, Parrot_PMC pmc
)
1149 PARROT_CALLIN_START(interp
);
1150 dod_unregister_pmc(interp
, pmc
);
1151 PARROT_CALLIN_END(interp
);
1154 PARROT_API Parrot_PMC
1155 Parrot_get_dod_registry(Parrot_Interp interp
)
1157 PMC
*registry
= interp
->DOD_registry
;
1158 PARROT_CALLIN_START(interp
);
1160 registry
= interp
->DOD_registry
=
1161 pmc_new(interp
, enum_class_AddrRegistry
);
1163 PARROT_CALLIN_END(interp
);
1170 Parrot_pmc_set_vtable(Parrot_Interp interp, Parrot_PMC pmc,
1171 Parrot_VTABLE vtable)>
1173 Replaces the vtable of the PMC.
1180 Parrot_PMC_set_vtable(Parrot_Interp interp
, Parrot_PMC pmc
,
1181 Parrot_VTABLE vtable
)
1183 pmc
->vtable
= vtable
;
1188 =item C<Parrot_VTABLE
1189 Parrot_get_vtable(Parrot_Interp interp, Parrot_Int id)>
1191 Returns the vtable corresponding to the given PMC ID.
1197 PARROT_API Parrot_VTABLE
1198 Parrot_get_vtable(Parrot_Interp interp
, Parrot_Int id
)
1200 return interp
->vtables
[id
];
1209 See F<include/parrot/extend.h> and F<docs/pdds/pdd11_extending.pod>.
1213 Initial version by Dan Sugalski.
1222 * c-file-style: "parrot"
1224 * vim: expandtab shiftwidth=4: