From 87a18f37743efde6f66f77209c98400cdec67cbe Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Wed, 14 Jan 2015 11:18:20 -0800 Subject: Support oneof defs in upb. This change adds support for a OneofDef (upb_oneofdef), which represents a 'oneof' as introduced by Protocol Buffers. This is semantically a union type that contains fields and in turn may be added to a MessageDef. This change does not alter parsing or the handler abstraction in any way, because a oneof has impact only at a higher semantic level (i.e., any sort of storage of the fields in a message object), which is user-specific with respect to upb. --- upb/pb/encoder.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'upb/pb/encoder.c') diff --git a/upb/pb/encoder.c b/upb/pb/encoder.c index d2c22e9..d5685dc 100644 --- a/upb/pb/encoder.c +++ b/upb/pb/encoder.c @@ -378,8 +378,10 @@ static void newhandlers_callback(const void *closure, upb_handlers *h) { upb_handlers_setendmsg(h, endmsg, NULL); const upb_msgdef *m = upb_handlers_msgdef(h); - upb_msg_iter i; - for(upb_msg_begin(&i, m); !upb_msg_done(&i); upb_msg_next(&i)) { + upb_msg_field_iter i; + for(upb_msg_field_begin(&i, m); + !upb_msg_field_done(&i); + upb_msg_field_next(&i)) { const upb_fielddef *f = upb_msg_iter_field(&i); bool packed = upb_fielddef_isseq(f) && upb_fielddef_isprimitive(f) && upb_fielddef_packed(f); -- cgit v1.2.3