summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/upb_def.c6
-rw-r--r--core/upb_def.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/core/upb_def.c b/core/upb_def.c
index c0d72db..fd00895 100644
--- a/core/upb_def.c
+++ b/core/upb_def.c
@@ -331,6 +331,12 @@ upb_enum_iter upb_enum_next(upb_enumdef *e, upb_enum_iter iter) {
return upb_inttable_next(&e->iton, &iter->e);
}
+upb_string *upb_enumdef_iton(upb_enumdef *def, upb_enumval_t num) {
+ upb_iton_ent *e =
+ (upb_iton_ent*)upb_inttable_fastlookup(&def->iton, num, sizeof(*e));
+ return e ? e->string : NULL;
+}
+
/* upb_fielddef ***************************************************************/
diff --git a/core/upb_def.h b/core/upb_def.h
index 82d8520..9cdc54d 100644
--- a/core/upb_def.h
+++ b/core/upb_def.h
@@ -202,6 +202,7 @@ typedef int32_t upb_enumval_t;
// Lookups from name to integer and vice-versa.
bool upb_enumdef_ntoi(upb_enumdef *e, upb_string *name, upb_enumval_t *num);
+// Caller does not own a ref on the returned string.
upb_string *upb_enumdef_iton(upb_enumdef *e, upb_enumval_t num);
// Iteration over name/value pairs. The order is undefined.
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback