Author: jonathan
Date: Mon Apr 16 16:26:34 2007
New Revision: 18244
Added:
trunk/src/pmc/classobject.h
Modified:
trunk/MANIFEST
trunk/src/pmc/class.pmc
trunk/src/pmc/object.pmc
Log:
[PDD15]: Add classobject.h, and move Class and Object PMC's structures,
typedefs and macros into it. Include it from Class and Object. Now these two
can know about each other's guts (but nothing outside of them will).
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Mon Apr 16 16:26:34 2007
@@ -2584,6 +2584,7 @@
src/pmc/bound_nci.pmc []
src/pmc/capture.pmc []
src/pmc/class.pmc []
+src/pmc/classobject.h []
src/pmc/closure.pmc []
src/pmc/compiler.pmc []
src/pmc/complex.pmc []
Modified: trunk/src/pmc/class.pmc
==============================================================================
--- trunk/src/pmc/class.pmc (original)
+++ trunk/src/pmc/class.pmc Mon Apr 16 16:26:34 2007
@@ -86,26 +86,7 @@
#include "parrot/parrot.h"
#include "pmc_namespace.h"
-#define PARROT_CLASS(o) ((Parrot_Class *) PMC_data(o))
-
-
-/* This is the underlying structure of this PMC. */
-typedef struct Parrot_Class {
- STRING *name; /* The name of the class. */
- PMC *namespace; /* The namespace it's linked to, if any. */
- int instantiated; /* Any instantiations since last modification? */
- PMC *parents; /* Immediate parent classes. */
- PMC *all_parents; /* Cached list of ourself and all parents, in MRO
order. */
- PMC *roles; /* An array of roles. */
- PMC *methods; /* Hash of method names to methods in this class. */
- PMC *vtable_methods; /* Hash of Parrot v-table methods we override. */
- PMC *attrib_metadata; /* Hash of attributes in this class to hashes of
metadata. */
- PMC *attrib_index; /* Lookup table for attributes in this and parents.
*/
- PMC *attrib_cache; /* Cache of visible attrib names to indexes. */
- PMC *resolve_method; /* List of method names the class provides to resolve
- * conflicts with methods from roles. */
-} Parrot_Class;
-
+#include "classobject.h"
/* Build a string representing the fully qualified class name. */
static STRING* get_fq_classname(Parrot_Interp interp, Parrot_Class
*class_info) {
@@ -750,7 +731,7 @@
=item C<void name(STRING *name :optional, int got_name :opt_flag)>
-Sets the name of the class.
+Sets the name of the class, and updates the namespace accoringly.
=cut
Added: trunk/src/pmc/classobject.h
==============================================================================
--- (empty file)
+++ trunk/src/pmc/classobject.h Mon Apr 16 16:26:34 2007
@@ -0,0 +1,51 @@
+/*
+** classobject.h
+**
+** structs, typedefs and macros for the Class and Object PMCs. This header
+** file is only included by the two PMCs, since they are allowed to know
+** about each other's internals, but all other usage should be through the
+** documented interface.
+*/
+
+#if !defined(PARROT_CLASSOBJECT_H_GUARD)
+# define PARROT_CLASSOBJECT_GUARD
+
+/* Class PMC's underlying struct. */
+typedef struct Parrot_Class {
+ STRING *name; /* The name of the class. */
+ PMC *namespace; /* The namespace it's linked to, if any. */
+ int instantiated; /* Any instantiations since last modification? */
+ PMC *parents; /* Immediate parent classes. */
+ PMC *all_parents; /* Cached list of ourself and all parents, in MRO
order. */
+ PMC *roles; /* An array of roles. */
+ PMC *methods; /* Hash of method names to methods in this class. */
+ PMC *vtable_methods; /* Hash of Parrot v-table methods we override. */
+ PMC *attrib_metadata; /* Hash of attributes in this class to hashes of
metadata. */
+ PMC *attrib_index; /* Lookup table for attributes in this and parents.
*/
+ PMC *attrib_cache; /* Cache of visible attrib names to indexes. */
+ PMC *resolve_method; /* List of method names the class provides to resolve
+ * conflicts with methods from roles. */
+} Parrot_Class;
+
+/* Macro to access underlying structure of a Class PMC. */
+#define PARROT_CLASS(o) ((Parrot_Class *) PMC_data(o))
+
+/* Object PMC's underlying struct. */
+typedef struct Parrot_Object {
+ PMC *class; /* The class this is an instance of. */
+ PMC *attrib_store; /* The attributes store - a resizable PMC array. */
+} Parrot_Object;
+
+/* Macro to access underlying structure of an Object PMC. */
+#define PARROT_OBJECT(o) ((Parrot_Object *) PMC_data(o))
+
+
+#endif /* PARROT_CLASSOBJECT_GUARD */
+
+
+/*
+ * Local variables:
+ * c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */
Modified: trunk/src/pmc/object.pmc
==============================================================================
--- trunk/src/pmc/object.pmc (original)
+++ trunk/src/pmc/object.pmc Mon Apr 16 16:26:34 2007
@@ -19,13 +19,7 @@
*/
#include "parrot/parrot.h"
-#define PARROT_OBJECT(o) ((Parrot_Object *) PMC_data(o))
-
-typedef struct Parrot_Object {
- PMC *class; /* The class this is an instance of. */
- PMC *attrib_store; /* The attributes store - a resizable PMC array. */
-} Parrot_Object;
-
+#include "classobject.h"
pmclass Object need_ext {