develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34025 - trunk/src/pmc

From:
jonathan
Date:
December 17, 2008 06:36
Subject:
[svn:parrot] r34025 - trunk/src/pmc
Message ID:
20081217143606.836E5CBA12@x12.develooper.com
Author: jonathan
Date: Wed Dec 17 06:36:05 2008
New Revision: 34025

Modified:
   trunk/src/pmc/object.pmc

Log:
[core] I intended that the Object PMC's clone method would clone the attributes. Turns out, ResizablePMCArray doesn't clone its elements, so that wasn't happening. So, this does the cloning in Object's clone vtable method. Tested with various things and nothing breaks.

Modified: trunk/src/pmc/object.pmc
==============================================================================
--- trunk/src/pmc/object.pmc	(original)
+++ trunk/src/pmc/object.pmc	Wed Dec 17 06:36:05 2008
@@ -654,7 +654,7 @@
 
         /* See if we have a custom override of the method first. */
         const int num_classes = VTABLE_elements(interp, _class->all_parents);
-        int i;
+        int i, num_attrs;
         for (i = 0; i < num_classes; i++) {
             /* Get the class. */
             PMC * const cur_class = VTABLE_get_pmc_keyed_int(interp, _class->all_parents, i);
@@ -681,6 +681,14 @@
         cloned_guts->_class       = obj->_class;
         cloned_guts->attrib_store = VTABLE_clone(INTERP, obj->attrib_store);
         PMC_data(cloned)          = cloned_guts;
+        num_attrs                 = VTABLE_elements(INTERP, cloned_guts->attrib_store);
+        for (i = 0; i < num_attrs; i++) {
+            PMC *to_clone = VTABLE_get_pmc_keyed_int(INTERP, cloned_guts->attrib_store, i);
+            if (!PMC_IS_NULL(to_clone)) {
+                VTABLE_set_pmc_keyed_int(INTERP, cloned_guts->attrib_store, i,
+                        VTABLE_clone(INTERP, to_clone));
+            }
+        }
 
         /* Some of the attributes may have been the PMCs providing storage for any
          * PMCs we inherited from; also need to clone those. */



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About