Skip to content

Commit 23841b2

Browse files
committed
Implement serialize/deserialize REPR functions for KnowHOWREPR.
1 parent d82072a commit 23841b2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/6model/reprs/KnowHOWREPR.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
8080
return spec;
8181
}
8282

83+
/* Serializes the data. */
84+
static void serialize(PARROT_INTERP, STable *st, void *data, SerializationWriter *writer) {
85+
KnowHOWREPRBody *body = (KnowHOWREPRBody *)data;
86+
writer->write_str(interp, writer, body->name);
87+
writer->write_ref(interp, writer, body->attributes);
88+
writer->write_ref(interp, writer, body->methods);
89+
}
90+
91+
/* Deserializes the data. */
92+
static void deserialize(PARROT_INTERP, STable *st, void *data, SerializationReader *reader) {
93+
KnowHOWREPRBody *body = (KnowHOWREPRBody *)data;
94+
body->name = reader->read_str(interp, reader);
95+
body->attributes = reader->read_ref(interp, reader);
96+
body->methods = reader->read_ref(interp, reader);
97+
}
98+
8399
/* Initializes the KnowHOWREPR representation. */
84100
REPROps * KnowHOWREPR_initialize(PARROT_INTERP) {
85101
/* Allocate and populate the representation function table. */
@@ -91,5 +107,7 @@ REPROps * KnowHOWREPR_initialize(PARROT_INTERP) {
91107
this_repr->gc_mark = gc_mark;
92108
this_repr->gc_free = gc_free;
93109
this_repr->get_storage_spec = get_storage_spec;
110+
this_repr->serialize = serialize;
111+
this_repr->deserialize = deserialize;
94112
return this_repr;
95113
}

0 commit comments

Comments
 (0)