diff options
author | Josh Haberman <jhaberman@gmail.com> | 2014-11-18 15:21:50 -0800 |
---|---|---|
committer | Josh Haberman <jhaberman@gmail.com> | 2014-11-18 15:21:50 -0800 |
commit | 3d0c7c45da5b72a88bfb03dc5ce3384b7f01cef6 (patch) | |
tree | 1c9fd69700e1162c7ed78458160800b586600c9b /upb/def.c | |
parent | 648afe3da654b6e08fe6ea26ae520581eb892e23 (diff) |
Sync to Google-internal development.
Diffstat (limited to 'upb/def.c')
-rw-r--r-- | upb/def.c | 25 |
1 files changed, 14 insertions, 11 deletions
@@ -628,6 +628,7 @@ upb_fielddef *upb_fielddef_new(const void *owner) { f->tagdelim = false; f->is_extension_ = false; f->lazy_ = false; + f->packed_ = true; // For the moment we default this to UPB_INTFMT_VARIABLE, since it will work // with all integer types and is in some since more "default" since the most @@ -735,6 +736,10 @@ bool upb_fielddef_lazy(const upb_fielddef *f) { return f->lazy_; } +bool upb_fielddef_packed(const upb_fielddef *f) { + return f->packed_; +} + const char *upb_fielddef_name(const upb_fielddef *f) { return upb_def_fullname(UPB_UPCAST(f)); } @@ -1030,6 +1035,11 @@ void upb_fielddef_setlazy(upb_fielddef *f, bool lazy) { f->lazy_ = lazy; } +void upb_fielddef_setpacked(upb_fielddef *f, bool packed) { + assert(!upb_fielddef_isfrozen(f)); + f->packed_ = packed; +} + void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label) { assert(!upb_fielddef_isfrozen(f)); assert(upb_fielddef_checklabel(label)); @@ -1341,7 +1351,7 @@ bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor, upb_status_seterrmsg(s, "field name or number were not set"); return false; } else if(upb_msgdef_itof(m, upb_fielddef_number(f)) || - upb_msgdef_ntof(m, upb_fielddef_name(f))) { + upb_msgdef_ntofz(m, upb_fielddef_name(f))) { upb_status_seterrmsg(s, "duplicate field name or number"); return false; } @@ -1365,20 +1375,13 @@ const upb_fielddef *upb_msgdef_itof(const upb_msgdef *m, uint32_t i) { upb_value_getptr(val) : NULL; } -const upb_fielddef *upb_msgdef_ntof(const upb_msgdef *m, const char *name) { +const upb_fielddef *upb_msgdef_ntof(const upb_msgdef *m, const char *name, + size_t len) { upb_value val; - return upb_strtable_lookup(&m->ntof, name, &val) ? + return upb_strtable_lookup2(&m->ntof, name, len, &val) ? upb_value_getptr(val) : NULL; } -upb_fielddef *upb_msgdef_itof_mutable(upb_msgdef *m, uint32_t i) { - return (upb_fielddef*)upb_msgdef_itof(m, i); -} - -upb_fielddef *upb_msgdef_ntof_mutable(upb_msgdef *m, const char *name) { - return (upb_fielddef*)upb_msgdef_ntof(m, name); -} - int upb_msgdef_numfields(const upb_msgdef *m) { return upb_strtable_count(&m->ntof); } |