cvsuser 03/11/02 22:52:59
Modified: src objects.c
Log:
Flush a couple of minor tweaks.
Revision Changes Path
1.14 +37 -2 parrot/src/objects.c
Index: objects.c
===================================================================
RCS file: /cvs/public/parrot/src/objects.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -w -r1.13 -r1.14
--- objects.c 23 Oct 2003 17:48:59 -0000 1.13
+++ objects.c 3 Nov 2003 06:52:59 -0000 1.14
@@ -1,7 +1,7 @@
/* objects.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: objects.c,v 1.13 2003/10/23 17:48:59 robert Exp $
+ * $Id: objects.c,v 1.14 2003/11/03 06:52:59 mrjoltcola Exp $
* Overview:
* Handles class and object manipulation
* Data Structure and Algorithms:
@@ -121,10 +121,30 @@
VTABLE_set_pmc_keyed_int(interpreter, new_class_array, 1, classname_pmc);
/* Add ourselves to the interpreter's class hash */
+ if(Parrot_class_lookup(interpreter, class_name)) {
+ internal_exception(1, "Class %s already registered!\n",
+ string_to_cstring(interpreter, class_name));
+ }
+
+ Parrot_class_register(interpreter, class_name, new_class);
+
+ return new_class;
+}
+
+
+PMC *
+Parrot_class_lookup(Parrot_Interp interpreter, STRING *class_name)
+{
+ return VTABLE_get_pmc_keyed(interpreter, interpreter->class_hash,
+ key_new_string(interpreter, class_name));
+}
+
+void
+Parrot_class_register(Parrot_Interp interpreter, STRING *class_name, PMC *new_class)
+{
VTABLE_set_pmc_keyed(interpreter, interpreter->class_hash,
key_new_string(interpreter,class_name), new_class);
- return new_class;
}
@@ -184,6 +204,21 @@
Parrot_multi_subclass(Parrot_Interp interpreter, PMC *base_class_array,
STRING *child_class_name) {
return NULL;
+}
+
+/*=for api objects Parrot_object_is
+ *
+ * Is the object an instance of class.
+ * XXX: This should check parent classes as well, but it currently doesn't.
+ */
+INTVAL
+Parrot_object_isa(Parrot_Interp interpreter, PMC *obj, PMC *cl) {
+ PMC * t;
+ PMC * object_array = PMC_data(obj);
+ t = VTABLE_get_pmc_keyed_int(interpreter, object_array, 0);
+ if(t == cl)
+ return 1;
+ return 0;
}
/*=for api objects Parrot_new_method_cache