diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2016-12-07 17:07:05 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-07 17:07:05 -0800 |
commit | 076a82ee7edf35fb5f2a3430535e21a6dbd4cd6d (patch) | |
tree | 87969c375756dc4290478c9ecc5d0d87ae48f557 /upb/def.c | |
parent | 9a91f7bba8c89ed4d1cb0d56b8a394a9590df029 (diff) | |
parent | 2b77da3da8234484ebc099c560671ea21ab7181b (diff) |
Merge pull request #74 from haberman/msg
Added upb_msg and Lua bindings for using it.
Diffstat (limited to 'upb/def.c')
-rw-r--r-- | upb/def.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -133,7 +133,8 @@ upb_def *upb_def_dup(const upb_def *def, const void *o) { case UPB_DEF_ENUM: return upb_enumdef_upcast_mutable( upb_enumdef_dup(upb_downcast_enumdef(def), o)); - default: UPB_ASSERT(false); return NULL; + default: + UPB_UNREACHABLE(); } } @@ -283,6 +284,7 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) { /* Sort fields. upb internally relies on UPB_TYPE_MESSAGE fields having the * lowest indexes, but we do not publicly guarantee this. */ upb_msg_field_iter j; + upb_msg_oneof_iter k; int i; uint32_t selector; int n = upb_msgdef_numfields(m); @@ -367,6 +369,13 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) { #undef TRY #endif + for(upb_msg_oneof_begin(&k, m), i = 0; + !upb_msg_oneof_done(&k); + upb_msg_oneof_next(&k), i++) { + upb_oneofdef *o = upb_msg_iter_oneof(&k); + o->index = i; + } + upb_gfree(fields); return true; } @@ -1833,6 +1842,10 @@ int upb_oneofdef_numfields(const upb_oneofdef *o) { return upb_strtable_count(&o->ntof); } +uint32_t upb_oneofdef_index(const upb_oneofdef *o) { + return o->index; +} + bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f, const void *ref_donor, upb_status *s) { |