diff options
author | Joshua Haberman <joshua@reverberate.org> | 2010-07-17 19:00:40 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2010-07-17 19:00:40 -0700 |
commit | 4b6c8b6b2317436ab77b38e17b49a7c7b03bf3f4 (patch) | |
tree | 78d29aa3e9a1409c9487d9ebf9b0e52d36b03d60 /core | |
parent | 0fcfeab521b01160875e863575dd5b63952b1593 (diff) |
Fixed bugs in textoutput.
Text output from descriptor.proto is now
identical to protoc!
Diffstat (limited to 'core')
-rw-r--r-- | core/upb_def.c | 6 | ||||
-rw-r--r-- | core/upb_def.h | 1 |
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. |