I want to get rid of this flag, and move the special case of DOD marking into 
the mark() vtable entry.  Here's a patch which accomplishes most of this 
(except for getting rid of the special case) and breaks Tcl's PMCs 
spectacularly.

A little patch review here would be swell.

-- c

=== src/pmc/capture.pmc
==================================================================
--- src/pmc/capture.pmc	(revision 5058)
+++ src/pmc/capture.pmc	(local)
@@ -55,8 +55,7 @@
         CAPTURE_array(SELF) = NULL;
         CAPTURE_hash(SELF)  = NULL;
         PMC_int_val(SELF)   = CAPTURE_DATA_SIZE;
-        PObj_active_destroy_SET(SELF);
-        PObj_data_is_PMC_array_SET(SELF);
+        PObj_custom_mark_destroy_SETALL(SELF);
     }
 
     void destroy() {
@@ -67,6 +66,17 @@
         PMC_int_val(SELF) = 0;
     }
 
+    void mark() {
+        PMC *array = CAPTURE_array(SELF);
+        PMC *hash  = CAPTURE_hash(SELF);
+
+        if (!PMC_IS_NULL(array))
+            pobject_lives(interp, (PObj *)array);
+
+        if (!PMC_IS_NULL(hash))
+            pobject_lives(interp, (PObj *)hash);
+    }
+
 /*
 
 =item C<void set_number_keyed_int(INTVAL key, FLOATVAL value)>
=== src/pmc/fixedpmcarray.pmc
==================================================================
--- src/pmc/fixedpmcarray.pmc	(revision 5058)
+++ src/pmc/fixedpmcarray.pmc	(local)
@@ -122,9 +122,8 @@
 
     void init() {
         PMC_int_val(SELF) = 0;
-        PMC_data(SELF) = NULL;
-        PObj_active_destroy_SET(SELF);
-        PObj_data_is_PMC_array_SET(SELF);
+        PMC_data(SELF)    = NULL;
+        PObj_custom_mark_destroy_SETALL(SELF);
     }
 
 /*
@@ -141,7 +140,21 @@
         SUPER(type);
     }
 
+/*
+*/
 
+    void mark() {
+        INTVAL e = DYNSELF.elements();
+        INTVAL i;
+
+        for (i = 0; i < e; ++i) {
+            PMC *elem = DYNSELF.get_pmc_keyed_int(i);
+            if (!PMC_IS_NULL(elem))
+                pobject_lives(interp, (PObj *)elem);
+        }
+    }
+
+
 /*
 
 =item C<void destroy()>
@@ -177,7 +190,7 @@
             PMC_int_val(dest) = size;
             PMC_data(dest) = mem_sys_allocate(size * sizeof (PMC*));
             mem_sys_memcopy(PMC_data(dest), PMC_data(SELF), size*sizeof (PMC*));
-            PObj_data_is_PMC_array_SET(dest);
+            PObj_custom_mark_destroy_SETALL(dest);
         }
         return dest;
     }
@@ -450,7 +463,7 @@
         PMC_data(SELF) = mem_sys_allocate(size * sizeof (PMC*));
         mem_sys_memcopy(PMC_data(SELF), PMC_data(value), size*sizeof (PMC*));
         PMC_int_val2(SELF) = size;
-        PObj_data_is_PMC_array_SET(SELF);
+        PObj_custom_mark_destroy_SETALL(SELF);
     }
 /*
 
=== src/pmc/parrotclass.pmc
==================================================================
--- src/pmc/parrotclass.pmc	(revision 5058)
+++ src/pmc/parrotclass.pmc	(local)
@@ -195,10 +195,13 @@
     void init() {
         /* No attributes to start with */
         PMC_int_val(SELF) = CLASS_ATTRIB_COUNT(SELF) = 0;
+
         /* But we are a class, really */
         PObj_is_class_SET(SELF);
+
         /* turn on marking of the class_data array */
-        PObj_data_is_PMC_array_SET(SELF);
+        PObj_custom_mark_destroy_SETALL(SELF);
+
         /* turn on custom destruction since our PMC* array is
            dynamically allocated */
         PObj_active_destroy_SET(SELF);
@@ -218,6 +221,21 @@
 =cut
 
 */
+
+    void mark() {
+        SLOTTYPE **attribs = PMC_data_typed(SELF, SLOTTYPE *);
+        UINTVAL  i;
+
+        if (!attribs)
+            return;
+
+        for (i = 0; i < PCD_MAX; ++i) {
+            PMC *attrib = get_attrib_num(attribs, i);
+            if (!PMC_IS_NULL(attrib))
+                pobject_lives(interp, (PObj *)attrib);
+        }
+    }
+
     void destroy() {
         if (PMC_int_val(SELF)) {
             mem_sys_free(PMC_data(SELF));

Reply via email to