[svn:parrot] r45475 - in trunk: include/parrot src/nci

plobsing at svn.parrot.org plobsing at svn.parrot.org
Fri Apr 9 01:33:48 UTC 2010


Author: plobsing
Date: Fri Apr  9 01:33:48 2010
New Revision: 45475
URL: https://trac.parrot.org/parrot/changeset/45475

Log:
first cut at hooks for runtime-loadable frame builder

Modified:
   trunk/include/parrot/interpreter.h
   trunk/include/parrot/nci.h
   trunk/src/nci/api.c

Modified: trunk/include/parrot/interpreter.h
==============================================================================
--- trunk/include/parrot/interpreter.h	Fri Apr  9 00:54:11 2010	(r45474)
+++ trunk/include/parrot/interpreter.h	Fri Apr  9 01:33:48 2010	(r45475)
@@ -315,6 +315,8 @@
     IGLOBALS_COMPREG_HASH,
     IGLOBALS_ARGV_LIST,
     IGLOBALS_NCI_FUNCS,
+    IGLOBALS_NCI_FB_CB,
+    IGLOBALS_NCI_FB_UD,
     IGLOBALS_INTERPRETER,       /* this interpreter as ParrotInterpreter PMC */
     IGLOBALS_DYN_LIBS,          /* Hash of ParrotLibrary loaded dynamic ext */
     IGLOBALS_CONFIG_HASH,

Modified: trunk/include/parrot/nci.h
==============================================================================
--- trunk/include/parrot/nci.h	Fri Apr  9 00:54:11 2010	(r45474)
+++ trunk/include/parrot/nci.h	Fri Apr  9 01:33:48 2010	(r45475)
@@ -15,6 +15,7 @@
 
 #include "parrot/parrot.h"
 
+typedef PMC *(*nci_fb_func_t)(PMC *user_data, STRING *signature);
 typedef void (*nci_thunk_t)(PARROT_INTERP, PMC *, PMC *);
 
 void Parrot_nci_load_core_thunks(PARROT_INTERP);

Modified: trunk/src/nci/api.c
==============================================================================
--- trunk/src/nci/api.c	Fri Apr  9 00:54:11 2010	(r45474)
+++ trunk/src/nci/api.c	Fri Apr  9 01:33:48 2010	(r45475)
@@ -60,6 +60,19 @@
 
     thunk = VTABLE_get_pmc_keyed_str(interp, nci_funcs, signature);
 
+    if (PMC_IS_NULL(thunk)) {
+        /* try to dynamically build a thunk */
+        PMC *nci_fb_cb = VTABLE_get_pmc_keyed_int(interp, iglobals, IGLOBALS_NCI_FB_CB);
+        if (!PMC_IS_NULL(nci_fb_cb)) {
+            void *cb_ptr = VTABLE_get_pointer(interp, nci_fb_cb);
+            nci_fb_func_t cb = (nci_fb_func_t)D2FPTR(cb_ptr);
+            if (cb_ptr) {
+                PMC *nci_fb_ud = VTABLE_get_pmc_keyed_int(interp, iglobals, IGLOBALS_NCI_FB_UD);
+                thunk = cb(signature, nci_fb_ud);
+            }
+        }
+    }
+
     if (!PMC_IS_NULL(thunk)) {
         PARROT_ASSERT(thunk->vtable);
         PARROT_ASSERT(thunk->vtable->base_type == enum_class_UnManagedStruct);


More information about the parrot-commits mailing list