[svn:parrot] r48851 - in trunk/src: . ops

cotto at svn.parrot.org cotto at svn.parrot.org
Wed Sep 8 07:10:31 UTC 2010


Author: cotto
Date: Wed Sep  8 07:10:30 2010
New Revision: 48851
URL: https://trac.parrot.org/parrot/changeset/48851

Log:
make Parrot_oo_get_class fail less surprisingly and improve docs
thanks to bluescreen10++ for finding and reporting this underdocumented behavior

Modified:
   trunk/src/oo.c
   trunk/src/ops/object.ops

Modified: trunk/src/oo.c
==============================================================================
--- trunk/src/oo.c	Wed Sep  8 02:27:04 2010	(r48850)
+++ trunk/src/oo.c	Wed Sep  8 07:10:30 2010	(r48851)
@@ -260,8 +260,12 @@
          || base_type == enum_class_ResizableStringArray
          || base_type == enum_class_String)
             type = Parrot_pmc_get_type(interp, key);
-        else
+        else if (VTABLE_does(interp, key, CONST_STRING(interp, "string")) ||
+                base_type == enum_class_NameSpace)
             type = Parrot_pmc_get_type_str(interp, VTABLE_get_string(interp, key));
+        else
+            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+                    "can't get class from an instance of class '%Ss'", VTABLE_name(interp, key));
 
         classobj = get_pmc_proxy(interp, type);
     }

Modified: trunk/src/ops/object.ops
==============================================================================
--- trunk/src/ops/object.ops	Wed Sep  8 02:27:04 2010	(r48850)
+++ trunk/src/ops/object.ops	Wed Sep  8 07:10:30 2010	(r48851)
@@ -399,7 +399,8 @@
 
 =item B<get_class>(out PMC, in PMC)
 
-Find the PMC for a class, by string name or by key.
+Find the PMC for a class, by string name, key or namespace.  This op does
+C<not> find the class of an instance of an object.  use C<typeof> for that.
 
 =cut
 


More information about the parrot-commits mailing list