[svn:parrot] r44532 - in branches/tt1477: include/parrot src

plobsing at svn.parrot.org plobsing at svn.parrot.org
Sat Feb 27 04:07:03 UTC 2010


Author: plobsing
Date: Sat Feb 27 04:06:47 2010
New Revision: 44532
URL: https://trac.parrot.org/parrot/changeset/44532

Log:
add Parrot_ext_call_cb function to provide feature requested in TT 1477

Modified:
   branches/tt1477/include/parrot/call.h
   branches/tt1477/include/parrot/extend.h
   branches/tt1477/src/extend.c

Modified: branches/tt1477/include/parrot/call.h
==============================================================================
--- branches/tt1477/include/parrot/call.h	Sat Feb 27 02:49:37 2010	(r44531)
+++ branches/tt1477/include/parrot/call.h	Sat Feb 27 04:06:47 2010	(r44532)
@@ -50,15 +50,15 @@
 #define CALLSIGNATURE_is_exception_CLEAR(o) CALLSIGNATURE_flag_CLEAR(is_exception, (o))
 
 typedef struct Parrot_pcc_sig_object_callback_funcs {
-    INTVAL (*intval_arg)(PARROT_INTERP, void *call_info, int idx);
-    FLOATVAL (*numval_arg)(PARROT_INTERP, void *call_info, int idx);
-    STRING *(*string_arg)(PARROT_INTERP, void *call_info, int idx);
-    PMC *(*pmc_arg)(PARROT_INTERP, void *call_info, int idx);
-
-    INTVAL *(*intval_ret)(PARROT_INTERP, void *call_info, int idx);
-    FLOATVAL *(*numval_ret)(PARROT_INTERP, void *call_info, int idx);
-    STRING *(*string_ret)(PARROT_INTERP, void *call_info, int idx);
-    PMC *(*pmc_ret)(PARROT_INTERP, void *call_info, int idx);
+    INTVAL       (*intval_arg)(PARROT_INTERP, void *call_info, int idx);
+    FLOATVAL     (*numval_arg)(PARROT_INTERP, void *call_info, int idx);
+    STRING      *(*string_arg)(PARROT_INTERP, void *call_info, int idx);
+    PMC         *(*pmc_arg)(PARROT_INTERP, void *call_info, int idx);
+
+    INTVAL      *(*intval_ret)(PARROT_INTERP, void *call_info, int idx);
+    FLOATVAL    *(*numval_ret)(PARROT_INTERP, void *call_info, int idx);
+    STRING     **(*string_ret)(PARROT_INTERP, void *call_info, int idx);
+    PMC        **(*pmc_ret)(PARROT_INTERP, void *call_info, int idx);
 } Parrot_pcc_sig_object_callback_funcs;
 
 

Modified: branches/tt1477/include/parrot/extend.h
==============================================================================
--- branches/tt1477/include/parrot/extend.h	Sat Feb 27 02:49:37 2010	(r44531)
+++ branches/tt1477/include/parrot/extend.h	Sat Feb 27 04:06:47 2010	(r44532)
@@ -56,6 +56,18 @@
 
 #endif
 
+typedef struct Parrot_ext_call_cbs {
+    Parrot_Int       (*intval_arg)(PARROT_INTERP, void *user_data, int idx);
+    Parrot_Float     (*numval_arg)(PARROT_INTERP, void *user_data, int idx);
+    Parrot_String    (*string_arg)(PARROT_INTERP, void *user_data, int idx);
+    Parrot_PMC       (*pmc_arg)(PARROT_INTERP, void *user_data, int idx);
+
+    Parrot_Int      *(*intval_ret)(PARROT_INTERP, void *user_data, int idx);
+    Parrot_Float    *(*numval_ret)(PARROT_INTERP, void *user_data, int idx);
+    Parrot_String   *(*string_ret)(PARROT_INTERP, void *user_data, int idx);
+    Parrot_PMC      *(*pmc_ret)(PARROT_INTERP, void *user_data, int idx);
+} Parrot_ext_call_cbs;
+
 #include "parrot/extend_vtable.h" /* the auto-generated prototypes    */
 
 /* HEADERIZER BEGIN: src/extend.c */

Modified: branches/tt1477/src/extend.c
==============================================================================
--- branches/tt1477/src/extend.c	Sat Feb 27 02:49:37 2010	(r44531)
+++ branches/tt1477/src/extend.c	Sat Feb 27 04:06:47 2010	(r44532)
@@ -1058,6 +1058,30 @@
 
 /*
 
+=item C<Parrot_ext_call_cb(PARROT_INTERP, Parrot_PMC sub_pmc,
+const char *signature, Parrot_ext_call_cbs *cbs, void *user_data)>
+
+Call a Parrot subroutine or method with the given function signature, similar
+to C<Parrot_ext_call>. However, instead of taking a C<va_list>, a set of
+callbacks will get called as the signature is parsed to get the arguments and
+pointers to the return storage locations.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_ext_call_cb(PARROT_INTERP, ARGIN(Parrot_PMC sub_pmc),
+                    ARGIN(const char *signature), ARGIN(Parrot_ext_call_cbs *cbs),
+                    ARGIN_NULLOK(void *user_data)) {
+    PMC *sig_object =
+        Parrot_pcc_build_sig_object_from_callbacks(interp, PMCNULL, signature, cbs, user_data);
+    Parrot_pcc_invoke_from_sig_object(interp, sub_pmc, sig_object);
+}
+
+/*
+
 =item C<Parrot_Int Parrot_get_intreg(PARROT_INTERP, Parrot_Int regnum)>
 
 Return the value of an integer register.


More information about the parrot-commits mailing list