From 3d0c7c45da5b72a88bfb03dc5ce3384b7f01cef6 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Tue, 18 Nov 2014 15:21:50 -0800 Subject: Sync to Google-internal development. --- upb/def.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'upb/def.c') diff --git a/upb/def.c b/upb/def.c index b1598d8..fde2ee8 100644 --- a/upb/def.c +++ b/upb/def.c @@ -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); } -- cgit v1.2.3