From a952e42e996fcab8f13e48d0078c0e95a4d507d9 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sat, 1 Aug 2009 18:34:24 -0700 Subject: Fixed a bug in set_flags order in the compiler. --- tools/upbc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'tools/upbc.c') diff --git a/tools/upbc.c b/tools/upbc.c index 3234a34..8eec85c 100644 --- a/tools/upbc.c +++ b/tools/upbc.c @@ -467,12 +467,18 @@ static void write_message_c(void *data, struct upb_msg *m, struct upb_msg *m = e->field->ref.msg; void *msgdata = val.msg; /* Print set flags. */ - fputs(" {.set_flags = {.bytes = {", stream); - for(unsigned int j = 0; j < m->set_flags_bytes; j++) { - fprintf(stream, "0x%02hhx", *(uint8_t*)(val.msg + j)); - if(j < m->set_flags_bytes - 1) fputs(", ", stream); + fputs(" {.set_flags = {.has = {\n", stream); + for(unsigned int j = 0; j < m->num_fields; j++) { + struct upb_msg_field *f = &m->fields[j]; + google_protobuf_FieldDescriptorProto *fd = m->field_descriptors[j]; + fprintf(stream, " ." UPB_STRFMT " = ", UPB_STRARG(*fd->name)); + if(upb_msg_isset(msgdata, f)) + fprintf(stream, "true"); + else + fprintf(stream, "false"); + fputs(",\n", stream); } - fputs("}},\n", stream); + fputs(" }},\n", stream); /* Print msg data. */ for(unsigned int j = 0; j < m->num_fields; j++) { struct upb_msg_field *f = &m->fields[j]; -- cgit v1.2.3