[svn:parrot] r43398 - branches/tt389_fix/src/pmc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Wed Jan 6 21:44:27 UTC 2010


Author: chromatic
Date: Wed Jan  6 21:44:26 2010
New Revision: 43398
URL: https://trac.parrot.org/parrot/changeset/43398

Log:
[PMC] Made NameSpace PMC skip adding subs marked with :method to the namespace
in two cases:

    * where there's an existing class into which the methods go, or
    * where the NameSpace's name does not match a built-in PMC type

This resolves TT #389.  Some tests fail.  They need fixing; they're wrong.

Modified:
   branches/tt389_fix/src/pmc/namespace.pmc

Modified: branches/tt389_fix/src/pmc/namespace.pmc
==============================================================================
--- branches/tt389_fix/src/pmc/namespace.pmc	Wed Jan  6 21:38:05 2010	(r43397)
+++ branches/tt389_fix/src/pmc/namespace.pmc	Wed Jan  6 21:44:26 2010	(r43398)
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2005-2009, Parrot Foundation.
+Copyright (C) 2005-2010, Parrot Foundation.
 $Id$
 
 =head1 NAME
@@ -20,7 +20,7 @@
 
 #include "pmc/pmc_sub.h"
 
-static void add_to_class(
+static int add_to_class(
         Interp *interp,
         Parrot_NameSpace_attributes * const nsinfo,
         PMC * const classobj,
@@ -28,18 +28,24 @@
         PMC *value)
 {
     /* Insert it in class, if there is a class */
-    if (!PMC_IS_NULL(classobj) && PObj_is_class_TEST(classobj))
+    if (!PMC_IS_NULL(classobj) && PObj_is_class_TEST(classobj)) {
         VTABLE_add_method(interp, classobj, key, value);
+        return 1;
+    }
 
     /* Otherwise, store it in the namespace for the class to
      * retrieve later */
     else {
         /* If we don't have a place to hang methods, make one. */
+        int core_type = pmc_type(interp, nsinfo->name);
+
         if (PMC_IS_NULL(nsinfo->methods))
             nsinfo->methods = pmc_new(interp, enum_class_Hash);
 
         /* Insert it. */
         VTABLE_set_pmc_keyed_str(interp, nsinfo->methods, key, value);
+
+        return core_type == 0;
     }
 }
 
@@ -81,14 +87,13 @@
         STRING *method_name = key;
 
         if (Parrot_str_equal(interp, sub->method_name, CONST_STRING(interp, ""))) {
-            if (sub->vtable_index != -1 && vtable_key != NULL) {
+            if (sub->vtable_index != -1 && vtable_key)
                 method_name = Parrot_str_copy(interp, vtable_key);
-            }
         }
-        else {
+        else
             method_name = sub->method_name;
-        }
-        add_to_class(interp, nsinfo, classobj, method_name, value);
+
+        return add_to_class(interp, nsinfo, classobj, method_name, value);
     }
 
     return 0;
@@ -118,7 +123,8 @@
         PMC * const classobj = VTABLE_get_class(interp, SELF);
 
         /* Insert it in class, if there is a class */
-        add_to_class(interp, nsinfo, classobj, key, value);
+        int dummy = add_to_class(interp, nsinfo, classobj, key, value);
+        UNUSED(dummy);
     }
 }
 
@@ -145,11 +151,13 @@
                 STRING *empty_str   = CONST_STRING(interp, "");
                 STRING *method_name = key;
                 Hash   *hash;
+                int     dummy;
 
                 if (Parrot_str_not_equal(interp, sub->method_name, empty_str))
                     method_name = sub->method_name;
 
-                add_to_class(interp, nsinfo, classobj, method_name, value);
+                dummy = add_to_class(interp, nsinfo, classobj, method_name, value);
+                UNUSED(dummy);
 
                 GETATTR_NameSpace_hash(interp, SELF, hash);
 


More information about the parrot-commits mailing list