summaryrefslogtreecommitdiff
path: root/upb/def.c
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2016-09-09 14:03:25 -0700
committerJosh Haberman <jhaberman@gmail.com>2016-11-29 17:56:13 +0000
commit4b0c4ca7fb0aa9207af3398e04534b23fbb88f27 (patch)
tree045750c6262e74f366ae2ec29797d3816005c21a /upb/def.c
parent77c97fd3f29caa5c243294b5f4e6763b3ed3c36f (diff)
New upb_msg code and Lua bindings around it.
There are still some things that are unfinished, but we are at parity with what Lua had before.
Diffstat (limited to 'upb/def.c')
-rw-r--r--upb/def.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/upb/def.c b/upb/def.c
index 92e89e0..bd8c129 100644
--- a/upb/def.c
+++ b/upb/def.c
@@ -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) {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback