[svn:parrot] r40926 - in trunk: src/pmc t/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Wed Sep 2 13:08:11 UTC 2009


Author: bacek
Date: Wed Sep  2 13:08:09 2009
New Revision: 40926
URL: https://trac.parrot.org/parrot/changeset/40926

Log:
[pmc] Revert previous commit. Actually preserve type of unpacked segment. Add setter/getter to PackfileRawSegment.type

Modified:
   trunk/src/pmc/packfiledirectory.pmc
   trunk/src/pmc/packfilerawsegment.pmc
   trunk/t/pmc/packfiledirectory.t

Modified: trunk/src/pmc/packfiledirectory.pmc
==============================================================================
--- trunk/src/pmc/packfiledirectory.pmc	Wed Sep  2 12:30:01 2009	(r40925)
+++ trunk/src/pmc/packfiledirectory.pmc	Wed Sep  2 13:08:09 2009	(r40926)
@@ -42,7 +42,7 @@
         Parrot_PackfileDirectory_attributes * attrs =
                 mem_allocate_zeroed_typed(Parrot_PackfileDirectory_attributes);
 
-        attrs->hash = pmc_new(interp, enum_class_OrderedHash);
+        attrs->hash = pmc_new(interp, enum_class_Hash);
 
         PObj_custom_mark_destroy_SETALL(SELF);
         PMC_data(SELF) = attrs;

Modified: trunk/src/pmc/packfilerawsegment.pmc
==============================================================================
--- trunk/src/pmc/packfilerawsegment.pmc	Wed Sep  2 12:30:01 2009	(r40925)
+++ trunk/src/pmc/packfilerawsegment.pmc	Wed Sep  2 13:08:09 2009	(r40926)
@@ -25,6 +25,8 @@
 */
 
 pmclass PackfileRawSegment extends PackfileSegment {
+    /* Type of segment */
+    ATTR INTVAL  type;
     /* ResizableIntegerArray of opcodes */
     ATTR PMC    *opcodes;
 
@@ -43,6 +45,7 @@
                 mem_allocate_zeroed_typed(Parrot_PackfileRawSegment_attributes);
 
         attrs->opcodes = pmc_new(interp, enum_class_ResizableIntegerArray);
+        attrs->type    = PF_BYTEC_SEG; 
 
         PObj_custom_mark_destroy_SETALL(SELF);
         PMC_data(SELF) = attrs;
@@ -103,9 +106,14 @@
     VTABLE void set_pointer(void * pointer) {
         const PackFile_Segment * const pfseg =
                 (const PackFile_Segment *)pointer;
-        PMC * opcodes = PARROT_PACKFILERAWSEGMENT(SELF)->opcodes;
+        Parrot_PackfileRawSegment_attributes * attrs =
+                PARROT_PACKFILERAWSEGMENT(SELF);
+        PMC * opcodes = attrs->opcodes;
         size_t i;
 
+        /* Preserve type of unpacked segment */
+        attrs->type = pfseg->type;
+
         if (pfseg->size) {
             /* copy data to own array */
             VTABLE_set_integer_native(interp, opcodes, pfseg->size);
@@ -132,7 +140,7 @@
         PMC * opcodes = attrs->opcodes;
         size_t i;
 
-        pfseg->type     = PF_BYTEC_SEG;
+        pfseg->type     = attrs->type;
         pfseg->size     = VTABLE_get_integer(interp, opcodes);
         pfseg->data     = mem_allocate_n_typed(pfseg->size, opcode_t);
 
@@ -187,6 +195,28 @@
             PARROT_PACKFILERAWSEGMENT(SELF)->opcodes, key, value);
     }
 
+/*
+
+=item C<>
+
+Set of get segment type.
+
+=cut
+
+TODO: Don't allow create Directory, Annotations, etc segments.
+
+*/
+
+    METHOD type(INTVAL type :optional, INTVAL got_type :opt_flag) {
+        Parrot_PackfileRawSegment_attributes * attrs =
+                PARROT_PACKFILERAWSEGMENT(SELF);
+
+        if (got_type) {
+            attrs->type = type;
+        }
+            
+        RETURN(INTVAL attrs->type);
+    }
 
 }
 /*

Modified: trunk/t/pmc/packfiledirectory.t
==============================================================================
--- trunk/t/pmc/packfiledirectory.t	Wed Sep  2 12:30:01 2009	(r40925)
+++ trunk/t/pmc/packfiledirectory.t	Wed Sep  2 13:08:09 2009	(r40926)
@@ -137,8 +137,7 @@
     delete pfdir[$S0]
     dec $I0
     $I1 = elements pfdir
-    $I3 = $I0 == $I1
-    todo($I3, "segment deleted", "OrderedHash delete is borked")
+    is($I0, $I1, "segment deleted")
 
   done:
     .return()


More information about the parrot-commits mailing list