From cada8df6c22a4f21398b3abd1f698de6c8af0cd9 Mon Sep 17 00:00:00 2001 From: James McKaskill Date: Thu, 12 Sep 2013 14:17:57 -0400 Subject: [PATCH] Decode field slot when we get around to declaring it rather than early as the names aren't resolved yet --- compiler/capnpc-c.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/capnpc-c.c b/compiler/capnpc-c.c index 8befcd8..db94dc9 100644 --- a/compiler/capnpc-c.c +++ b/compiler/capnpc-c.c @@ -375,13 +375,8 @@ static void decode_field(struct field *fields, Field_list l, int i) { exit(3); } - switch (f.f.which) { - case Field_slot: - decode_value(&f.v, f.f.slot.type, f.f.slot.defaultValue, NULL); - break; - case Field_group: + if (f.f.which == Field_group) { f.group = find_node(f.f.group.typeId); - break; } memcpy(&fields[f.f.codeOrder], &f, sizeof(f)); @@ -806,6 +801,10 @@ static void define_group(struct strings *s, struct node *n, const char *group_na str_addf(&s->var, "%s.", group_name); } + for (f = n->fields; f < n->fields + flen; f++) { + decode_value(&f->v, f->f.slot.type, f->f.slot.defaultValue, NULL); + } + /* fields before the union members */ for (f = n->fields; f < n->fields + flen && !in_union(f); f++) { define_field(s, f);