summaryrefslogtreecommitdiff
path: root/upb/symtab.c
diff options
context:
space:
mode:
authorChris Fallin <cfallin@c1f.net>2015-01-14 11:18:20 -0800
committerChris Fallin <cfallin@c1f.net>2015-01-14 11:18:20 -0800
commit87a18f37743efde6f66f77209c98400cdec67cbe (patch)
treefcbab052ead901543a135a15e25fee36189b15bd /upb/symtab.c
parentbebdc009b484295f06185b5bab884a3754bbbacd (diff)
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.
Diffstat (limited to 'upb/symtab.c')
-rw-r--r--upb/symtab.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/upb/symtab.c b/upb/symtab.c
index f172aaa..817a581 100644
--- a/upb/symtab.c
+++ b/upb/symtab.c
@@ -139,8 +139,10 @@ static bool upb_resolve_dfs(const upb_def *def, upb_strtable *addtab,
// For messages, continue the recursion by visiting all subdefs.
const upb_msgdef *m = upb_dyncast_msgdef(def);
if (m) {
- 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)) {
upb_fielddef *f = upb_msg_iter_field(&i);
if (!upb_fielddef_hassubdef(f)) continue;
// |= to avoid short-circuit; we need its side-effects.
@@ -293,8 +295,10 @@ bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, int n, void *ref_donor,
// Type names are resolved relative to the message in which they appear.
const char *base = upb_msgdef_fullname(m);
- upb_msg_iter j;
- for(upb_msg_begin(&j, m); !upb_msg_done(&j); upb_msg_next(&j)) {
+ upb_msg_field_iter j;
+ for(upb_msg_field_begin(&j, m);
+ !upb_msg_field_done(&j);
+ upb_msg_field_next(&j)) {
upb_fielddef *f = upb_msg_iter_field(&j);
const char *name = upb_fielddef_subdefname(f);
if (name && !upb_fielddef_subdef(f)) {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback