summaryrefslogtreecommitdiff
path: root/upb/handlers.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/handlers.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/handlers.c')
-rw-r--r--upb/handlers.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/upb/handlers.c b/upb/handlers.c
index c0fd271..fd19633 100644
--- a/upb/handlers.c
+++ b/upb/handlers.c
@@ -40,8 +40,10 @@ static void freehandlers(upb_refcounted *r) {
static void visithandlers(const upb_refcounted *r, upb_refcounted_visit *visit,
void *closure) {
const upb_handlers *h = (const upb_handlers*)r;
- upb_msg_iter i;
- for(upb_msg_begin(&i, h->msg); !upb_msg_done(&i); upb_msg_next(&i)) {
+ upb_msg_field_iter i;
+ for(upb_msg_field_begin(&i, h->msg);
+ !upb_msg_field_done(&i);
+ upb_msg_field_next(&i)) {
upb_fielddef *f = upb_msg_iter_field(&i);
if (!upb_fielddef_issubmsg(f)) continue;
const upb_handlers *sub = upb_handlers_getsubhandlers(h, f);
@@ -70,8 +72,10 @@ static upb_handlers *newformsg(const upb_msgdef *m, const void *owner,
// For each submessage field, get or create a handlers object and set it as
// the subhandlers.
- 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_issubmsg(f)) continue;
@@ -428,8 +432,10 @@ bool upb_handlers_freeze(upb_handlers *const*handlers, int n, upb_status *s) {
// Check that there are no closure mismatches due to missing Start* handlers
// or subhandlers with different type-level types.
- upb_msg_iter j;
- for(upb_msg_begin(&j, h->msg); !upb_msg_done(&j); upb_msg_next(&j)) {
+ upb_msg_field_iter j;
+ for(upb_msg_field_begin(&j, h->msg);
+ !upb_msg_field_done(&j);
+ upb_msg_field_next(&j)) {
const upb_fielddef *f = upb_msg_iter_field(&j);
if (upb_fielddef_isseq(f)) {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback