[svn:parrot] r44761 - branches/tt1015/src/pmc

plobsing at svn.parrot.org plobsing at svn.parrot.org
Mon Mar 8 19:06:52 UTC 2010


Author: plobsing
Date: Mon Mar  8 19:06:51 2010
New Revision: 44761
URL: https://trac.parrot.org/parrot/changeset/44761

Log:
freeze/thaw for FixedFloatArray (propagates to RFA)

Modified:
   branches/tt1015/src/pmc/fixedfloatarray.pmc

Modified: branches/tt1015/src/pmc/fixedfloatarray.pmc
==============================================================================
--- branches/tt1015/src/pmc/fixedfloatarray.pmc	Mon Mar  8 18:41:45 2010	(r44760)
+++ branches/tt1015/src/pmc/fixedfloatarray.pmc	Mon Mar  8 19:06:51 2010	(r44761)
@@ -80,6 +80,52 @@
 
 /*
 
+=item C<void freeze(PMC *visit)>
+
+=item C<void thaw(PMC *visit)>
+
+Used in serialization/deserialization.
+
+=cut
+
+*/
+
+    VTABLE void freeze(PMC *visit) {
+        FLOATVAL *float_array;
+        INTVAL i, n;
+
+        SUPER(visit);
+
+        GET_ATTR_size(INTERP, SELF, n);
+        VTABLE_push_integer(INTERP, visit, n);
+        GET_ATTR_float_array(INTERP, SELF, float_array);
+
+        for (i = 0; i < n; ++i)
+            VTABLE_push_float(INTERP, visit, float_array[i]);
+    }
+
+    VTABLE void thaw(PMC *visit) {
+        INTVAL n;
+
+        SUPER(visit);
+
+        SET_ATTR_size(INTERP, SELF, 0);
+        SET_ATTR_float_array(INTERP, SELF, NULL);
+
+        if ((n = VTABLE_shift_integer(INTERP, visit))) {
+            INTVAL i;
+            FLOATVAL *float_array;
+
+            SELF.set_integer_native(n);
+            GET_ATTR_float_array(INTERP, SELF, float_array);
+
+            for (i = 0; i < n; ++i)
+                float_array[i] = VTABLE_shift_float(INTERP, visit);
+        }
+    }
+
+/*
+
 =item C<PMC *get_iter()>
 
 Return an Iterator for this PMC.


More information about the parrot-commits mailing list