From 7d565f1e7a0f107506d3cf31ef2e33e22a504d2b Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Tue, 4 Feb 2014 15:43:52 -0800 Subject: Sync from Google development. --- upb/def.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'upb/def.c') diff --git a/upb/def.c b/upb/def.c index 805f143..14715c8 100644 --- a/upb/def.c +++ b/upb/def.c @@ -145,6 +145,12 @@ static bool upb_validate_field(upb_fielddef *f, upb_status *s) { upb_status_seterrmsg(s, "fielddef type was not initialized"); return false; } + if (upb_fielddef_lazy(f) && + upb_fielddef_descriptortype(f) != UPB_DESCRIPTOR_TYPE_MESSAGE) { + upb_status_seterrmsg(s, + "only length-delimited submessage fields may be lazy"); + return false; + } if (upb_fielddef_hassubdef(f)) { if (f->subdef_is_symbolic) { upb_status_seterrf(s, @@ -463,6 +469,7 @@ upb_fielddef *upb_fielddef_new(const void *owner) { f->type_is_set_ = false; f->tagdelim = false; f->is_extension_ = false; + f->lazy_ = false; // 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 @@ -565,6 +572,10 @@ bool upb_fielddef_isextension(const upb_fielddef *f) { return f->is_extension_; } +bool upb_fielddef_lazy(const upb_fielddef *f) { + return f->lazy_; +} + const char *upb_fielddef_name(const upb_fielddef *f) { return upb_def_fullname(UPB_UPCAST(f)); } @@ -824,10 +835,14 @@ upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f) { return 0; } -bool upb_fielddef_setisextension(upb_fielddef *f, bool is_extension) { +void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension) { assert(!upb_fielddef_isfrozen(f)); f->is_extension_ = is_extension; - return true; +} + +void upb_fielddef_setlazy(upb_fielddef *f, bool lazy) { + assert(!upb_fielddef_isfrozen(f)); + f->lazy_ = lazy; } void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label) { @@ -836,17 +851,16 @@ void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label) { f->label_ = label; } -bool upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt) { +void upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt) { assert(!upb_fielddef_isfrozen(f)); assert(upb_fielddef_checkintfmt(fmt)); f->intfmt = fmt; - return true; } -bool upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim) { +void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim) { assert(!upb_fielddef_isfrozen(f)); f->tagdelim = tag_delim; - return true; + f->tagdelim = tag_delim; } static bool checksetdefault(upb_fielddef *f, upb_fieldtype_t type) { -- cgit v1.2.3