Skip to content
This repository
Browse code

Serialize/deserialize CArray representation's REPR data. Should fix p…

…re-compilation of things that use CArray based types.
  • Loading branch information...
commit a88d0b88701fbb1e82021899dd301d1f084fb467 1 parent 232518c
Jonathan Worthington authored April 21, 2012

Showing 1 changed file with 20 additions and 0 deletions. Show diff stats Hide diff stats

  1. 20  src/6model/reprs/CArray.c
20  src/6model/reprs/CArray.c
@@ -274,6 +274,24 @@ static STable * get_elem_stable(PARROT_INTERP, STable *st) {
274 274
     return STABLE(repr_data->elem_type);
275 275
 }
276 276
 
  277
+/* Serializes the REPR data. */
  278
+static void serialize_repr_data(PARROT_INTERP, STable *st, SerializationWriter *writer) {
  279
+    CArrayREPRData *repr_data = (CArrayREPRData *)st->REPR_data;
  280
+    if (!repr_data->elem_size)
  281
+        fill_repr_data(interp, st);
  282
+    writer->write_int(interp, writer, repr_data->elem_size);
  283
+    writer->write_ref(interp, writer, repr_data->elem_type);
  284
+    writer->write_int(interp, writer, repr_data->elem_kind);
  285
+}
  286
+
  287
+/* Deserializes the REPR data. */
  288
+static void deserialize_repr_data(PARROT_INTERP, STable *st, SerializationReader *reader) {
  289
+    CArrayREPRData *repr_data = st->REPR_data = mem_sys_allocate_zeroed(sizeof(CArrayREPRData));
  290
+    repr_data->elem_size = reader->read_int(interp, reader);
  291
+    repr_data->elem_type = reader->read_ref(interp, reader);
  292
+    repr_data->elem_kind = reader->read_int(interp, reader);
  293
+}
  294
+
277 295
 /* Initializes the CArray representation. */
278 296
 REPROps * CArray_initialize(PARROT_INTERP,
279 297
         PMC * (* wrap_object_func_ptr) (PARROT_INTERP, void *obj),
@@ -302,6 +320,8 @@ REPROps * CArray_initialize(PARROT_INTERP,
302 320
     this_repr->idx_funcs->make_hole = make_hole;
303 321
     this_repr->idx_funcs->delete_elems = delete_elems;
304 322
     this_repr->idx_funcs->get_elem_stable = get_elem_stable;
  323
+    this_repr->serialize_repr_data = serialize_repr_data;
  324
+    this_repr->deserialize_repr_data = deserialize_repr_data;
305 325
     
306 326
     return this_repr;
307 327
 }

0 notes on commit a88d0b8

Please sign in to comment.
Something went wrong with that request. Please try again.