cvsuser 03/10/15 12:58:30
Modified: . object.ops objects.c
Log:
Some fledgling object instantiation code
Revision Changes Path
1.12 +19 -1 parrot/object.ops
Index: object.ops
===================================================================
RCS file: /cvs/public/parrot/object.ops,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -r1.11 -r1.12
--- object.ops 9 Oct 2003 20:10:59 -0000 1.11
+++ object.ops 15 Oct 2003 19:58:26 -0000 1.12
@@ -237,9 +237,27 @@
goto NEXT();
}
-=back
=cut
+
+###############################################################################
+
+=item B<instantiate>(out PMC, in PMC)
+
+Instantiate an object of class $2. Creates a brand-new PMC and puts that
+PMC into register $1.
+
+=cut
+
+inline op instantiate(out PMC, in PMC) {
+
+ goto NEXT();
+}
+
+
+
+=back
+
###############################################################################
1.8 +32 -2 parrot/objects.c
Index: objects.c
===================================================================
RCS file: /cvs/public/parrot/objects.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -r1.7 -r1.8
--- objects.c 9 Oct 2003 13:18:54 -0000 1.7
+++ objects.c 15 Oct 2003 19:58:26 -0000 1.8
@@ -1,7 +1,7 @@
/* objects.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: objects.c,v 1.7 2003/10/09 13:18:54 dan Exp $
+ * $Id: objects.c,v 1.8 2003/10/15 19:58:26 dan Exp $
* Overview:
* Handles class and object manipulation
* Data Structure and Algorithms:
@@ -90,7 +90,9 @@
return child_class;
}
-/* Create a brand new class, named what we pass in.
+/*=for api objects Parrot_new_class
+ *
+ * Create a brand new class, named what we pass in.
*/
PMC *
Parrot_new_class(Parrot_Interp interpreter, STRING *class_name)
@@ -123,6 +125,34 @@
key_new_string(interpreter,class_name), new_class);
return new_class;
+}
+
+
+/*=for api objects Parrot_instantiate_object
+ *
+ * Create a new parrot object. Takes a passed-in class PMC that has
+ * sufficient information to describe the layout of the object and,
+ * well, makes the darned object.
+ *
+ */
+PMC *
+Parrot_instantiate_object(Parrot_Interp interpreter, PMC *class) {
+ PMC *new_object;
+ PMC *new_object_array;
+ INTVAL attrib_count;
+
+ /* Grab the attribute count from the parent */
+ attrib_count = class->cache.int_val;
+
+ /* */
+ new_object_array = pmc_new(interpreter, enum_class_Array);
+ VTABLE_set_integer_native(interpreter, new_object_array, attrib_count);
+ new_object = pmc_new(interpreter, enum_class_ParrotObject);
+ PMC_data(new_object) = new_object_array;
+ PObj_flag_SET(is_PMC_ptr, new_object);
+
+ return new_object;
+
}
PMC *