[svn:parrot] r43751 - branches/gc_encapsulate/src/interp

bacek at svn.parrot.org bacek at svn.parrot.org
Sun Feb 7 07:54:35 UTC 2010


Author: bacek
Date: Sun Feb  7 07:54:35 2010
New Revision: 43751
URL: https://trac.parrot.org/parrot/changeset/43751

Log:
Fix fetching interpeter in NCI callback.

Modified:
   branches/gc_encapsulate/src/interp/inter_cb.c

Modified: branches/gc_encapsulate/src/interp/inter_cb.c
==============================================================================
--- branches/gc_encapsulate/src/interp/inter_cb.c	Sun Feb  7 07:54:18 2010	(r43750)
+++ branches/gc_encapsulate/src/interp/inter_cb.c	Sun Feb  7 07:54:35 2010	(r43751)
@@ -25,6 +25,7 @@
 */
 
 #include "parrot/parrot.h"
+#include "pmc/pmc_parrotinterpreter.h"
 #include "inter_cb.str"
 
 
@@ -159,6 +160,8 @@
     ASSERT_ARGS(verify_CD)
     PARROT_INTERP = NULL;
     size_t i;
+    PMC    *interp_pmc;
+    STRING *sc;
 
     /*
      * 1.) user_data is from external code so:
@@ -175,21 +178,15 @@
         PANIC(interp, "user_data doesn't look like a pointer");
 
     /*
-     * We don't yet know which interpreter this PMC is from, so run
-     * through all of the existing interpreters and check their PMC
-     * pools
+     * Fetch original interpeter from prop
      */
     LOCK(interpreter_array_mutex);
-#if 0
-    XXX FIXME It is really strange idea to use this approach.
-    for (i = 0; i < n_interpreters; ++i) {
-        Parrot_Interp checkinterp = interpreter_array [i];
-        if (checkinterp && Parrot_gc_ptr_is_pmc(checkinterp, user_data)) {
-            interp = checkinterp;
-            break;
-        }
-    }
-#endif
+
+    interp      = interpreter_array[0];
+    sc          = CONST_STRING(interp, "_interpreter");
+    interp_pmc  = VTABLE_getprop(interp, user_data, sc);
+    GETATTR_ParrotInterpreter_interp(interp, interp_pmc, interp);
+
     UNLOCK(interpreter_array_mutex);
     if (!interp)
         PANIC(interp, "interpreter not found for callback");


More information about the parrot-commits mailing list