diff options
Diffstat (limited to 'upb')
-rw-r--r-- | upb/bytestream.upb.c | 4 | ||||
-rw-r--r-- | upb/bytestream.upb.h | 6 | ||||
-rw-r--r-- | upb/def.c | 180 | ||||
-rw-r--r-- | upb/def.h | 275 | ||||
-rwxr-xr-x | upb/descriptor/descriptor.upb.c | 186 | ||||
-rwxr-xr-x | upb/descriptor/descriptor.upb.h | 384 | ||||
-rw-r--r-- | upb/descriptor/reader.c | 101 | ||||
-rw-r--r-- | upb/google/bridge.cc | 36 | ||||
-rw-r--r-- | upb/handlers-inl.h | 183 | ||||
-rw-r--r-- | upb/handlers.c | 109 | ||||
-rw-r--r-- | upb/handlers.h | 218 | ||||
-rw-r--r-- | upb/pb/decoder_x64.dasc | 24 | ||||
-rw-r--r-- | upb/sink.c | 28 | ||||
-rw-r--r-- | upb/sink.h | 8 | ||||
-rw-r--r-- | upb/symtab.c | 9 | ||||
-rw-r--r-- | upb/upb.h | 7 |
16 files changed, 973 insertions, 785 deletions
diff --git a/upb/bytestream.upb.c b/upb/bytestream.upb.c index 03388ab..4d84ec2 100644 --- a/upb/bytestream.upb.c +++ b/upb/bytestream.upb.c @@ -12,11 +12,11 @@ const upb_tabent upb_bytestream_intentries[0]; const _upb_value upb_bytestream_arrays[3]; const upb_msgdef upb_bytestream_msgs[1] = { - UPB_MSGDEF_INIT("upb.ByteStream", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &upb_bytestream_arrays[0], 3, 1), UPB_STRTABLE_INIT(1, 3, 9, 2, &upb_bytestream_strentries[0]), 3), + UPB_MSGDEF_INIT("upb.ByteStream", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &upb_bytestream_arrays[0], 3, 1), UPB_STRTABLE_INIT(1, 3, 9, 2, &upb_bytestream_strentries[0]), 5), }; const upb_fielddef upb_bytestream_fields[1] = { - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, "bytes", 1, &upb_bytestream_msgs[0], NULL, 0, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, "bytes", 1, &upb_bytestream_msgs[0], NULL, 2, UPB_VALUE_INIT_NONE), }; const upb_enumdef upb_bytestream_enums[0] = { diff --git a/upb/bytestream.upb.h b/upb/bytestream.upb.h index 304c426..0c6969b 100644 --- a/upb/bytestream.upb.h +++ b/upb/bytestream.upb.h @@ -26,9 +26,9 @@ extern const upb_enumdef upb_bytestream_enums[0]; #define UPB_BYTESTREAM &upb_bytestream_msgs[0] // Selector definitions. -#define UPB_BYTESTREAM_BYTES_ENDSTR 2 -#define UPB_BYTESTREAM_BYTES_STRING 0 -#define UPB_BYTESTREAM_BYTES_STARTSTR 1 +#define UPB_BYTESTREAM_BYTES_ENDSTR 4 +#define UPB_BYTESTREAM_BYTES_STRING 2 +#define UPB_BYTESTREAM_BYTES_STARTSTR 3 #ifdef __cplusplus }; // extern "C" @@ -41,18 +41,30 @@ static bool upb_isalphanum(char c) { return upb_isletter(c) || upb_isbetween(c, '0', '9'); } -static bool upb_isident(const char *str, size_t len, bool full) { +static bool upb_isident(const char *str, size_t len, bool full, upb_status *s) { bool start = true; for (size_t i = 0; i < len; i++) { char c = str[i]; if (c == '.') { - if (start || !full) return false; + if (start || !full) { + upb_status_seterrf(s, "invalid name: unexpected '.' (%s)", str); + return false; + } start = true; } else if (start) { - if (!upb_isletter(c)) return false; + if (!upb_isletter(c)) { + upb_status_seterrf( + s, "invalid name: path components must start with a letter (%s)", + str); + return false; + } start = false; } else { - if (!upb_isalphanum(c)) return false; + if (!upb_isalphanum(c)) { + upb_status_seterrf(s, "invalid name: non-alphanumeric character (%s)", + str); + return false; + } } } return !start; @@ -65,9 +77,9 @@ upb_deftype_t upb_def_type(const upb_def *d) { return d->type; } const char *upb_def_fullname(const upb_def *d) { return d->fullname; } -bool upb_def_setfullname(upb_def *def, const char *fullname) { +bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s) { assert(!upb_def_isfrozen(def)); - if (!upb_isident(fullname, strlen(fullname), true)) return false; + if (!upb_isident(fullname, strlen(fullname), true, s)) return false; free((void*)def->fullname); def->fullname = upb_strdup(fullname); return true; @@ -185,7 +197,7 @@ bool upb_def_freeze(upb_def *const* defs, int n, upb_status *s) { if (m) { upb_inttable_compact(&m->itof); upb_msg_iter j; - uint32_t selector = 0; + uint32_t selector = UPB_STATIC_SELECTOR_COUNT; for(upb_msg_begin(&j, m); !upb_msg_done(&j); upb_msg_next(&j)) { upb_fielddef *f = upb_msg_iter_field(&j); assert(f->msgdef == m); @@ -283,14 +295,14 @@ const char *upb_enumdef_fullname(const upb_enumdef *e) { return upb_def_fullname(upb_upcast(e)); } -bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname) { - return upb_def_setfullname(upb_upcast(e), fullname); +bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname, + upb_status *s) { + return upb_def_setfullname(upb_upcast(e), fullname, s); } bool upb_enumdef_addval(upb_enumdef *e, const char *name, int32_t num, upb_status *status) { - if (!upb_isident(name, strlen(name), false)) { - upb_status_seterrf(status, "name '%s' is not a valid identifier", name); + if (!upb_isident(name, strlen(name), false, status)) { return false; } if (upb_enumdef_ntoi(e, name, NULL)) { @@ -416,11 +428,11 @@ upb_fielddef *upb_fielddef_dup(const upb_fielddef *f, const void *owner) { if (!newf) return NULL; upb_fielddef_settype(newf, upb_fielddef_type(f)); upb_fielddef_setlabel(newf, upb_fielddef_label(f)); - upb_fielddef_setnumber(newf, upb_fielddef_number(f)); - upb_fielddef_setname(newf, upb_fielddef_name(f)); + upb_fielddef_setnumber(newf, upb_fielddef_number(f), NULL); + upb_fielddef_setname(newf, upb_fielddef_name(f), NULL); if (f->default_is_string) { str_t *s = upb_value_getptr(upb_fielddef_default(f)); - upb_fielddef_setdefaultstr(newf, s->str, s->len); + upb_fielddef_setdefaultstr(newf, s->str, s->len, NULL); } else { upb_fielddef_setdefault(newf, upb_fielddef_default(f)); } @@ -439,7 +451,7 @@ upb_fielddef *upb_fielddef_dup(const upb_fielddef *f, const void *owner) { } strcpy(newname, "."); strcat(newname, f->sub.def->fullname); - upb_fielddef_setsubdefname(newf, newname); + upb_fielddef_setsubdefname(newf, newname, NULL); free(newname); } @@ -504,8 +516,8 @@ upb_msgdef *upb_fielddef_msgdef_mutable(upb_fielddef *f) { return (upb_msgdef*)f->msgdef; } -bool upb_fielddef_setname(upb_fielddef *f, const char *name) { - return upb_def_setfullname(upb_upcast(f), name); +bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s) { + return upb_def_setfullname(upb_upcast(f), name, s); } upb_value upb_fielddef_default(const upb_fielddef *f) { @@ -561,22 +573,30 @@ const char *upb_fielddef_subdefname(const upb_fielddef *f) { return f->subdef_is_symbolic ? f->sub.name : NULL; } -bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number) { - assert(f->msgdef == NULL); +bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s) { + if (f->msgdef) { + upb_status_seterrliteral( + s, "cannot change field number after adding to a message"); + return false; + } + if (number == 0 || number > UPB_MAX_FIELDNUMBER) { + upb_status_seterrf(s, "invalid field number (%u)", number); + return false; + } f->number_ = number; return true; } -bool upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type) { +void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type) { assert(!upb_fielddef_isfrozen(f)); + assert(upb_fielddef_checktype(type)); upb_fielddef_uninit_default(f); f->type_ = type; f->type_is_set_ = true; upb_fielddef_init_default(f); - return true; } -bool upb_fielddef_setdescriptortype(upb_fielddef *f, int type) { +void upb_fielddef_setdescriptortype(upb_fielddef *f, int type) { assert(!upb_fielddef_isfrozen(f)); switch (type) { case UPB_DESCRIPTOR_TYPE_DOUBLE: @@ -619,8 +639,7 @@ bool upb_fielddef_setdescriptortype(upb_fielddef *f, int type) { case UPB_DESCRIPTOR_TYPE_ENUM: upb_fielddef_settype(f, UPB_TYPE_ENUM); break; - default: - return false; + default: assert(false); } if (type == UPB_DESCRIPTOR_TYPE_FIXED64 || @@ -636,8 +655,6 @@ bool upb_fielddef_setdescriptortype(upb_fielddef *f, int type) { } upb_fielddef_settagdelim(f, type == UPB_DESCRIPTOR_TYPE_GROUP); - - return true; } upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f) { @@ -679,14 +696,15 @@ upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f) { return 0; } -bool upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label) { +void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label) { assert(!upb_fielddef_isfrozen(f)); + assert(upb_fielddef_checklabel(label)); f->label_ = label; - return true; } bool 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; } @@ -710,9 +728,10 @@ void upb_fielddef_setdefault(upb_fielddef *f, upb_value value) { f->default_is_string = false; } -bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len) { +bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len, + upb_status *s) { assert(upb_fielddef_isstring(f) || f->type_ == UPB_TYPE_ENUM); - if (f->type_ == UPB_TYPE_ENUM && !upb_isident(str, len, false)) + if (f->type_ == UPB_TYPE_ENUM && !upb_isident(str, len, false, s)) return false; if (f->default_is_string) { @@ -723,15 +742,16 @@ bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len) { assert(f->type_ == UPB_TYPE_ENUM); } - str_t *s = newstr(str, len); - upb_value_setptr(&f->defaultval, s); + str_t *str2 = newstr(str, len); + upb_value_setptr(&f->defaultval, str2); f->default_is_string = true; return true; } -void upb_fielddef_setdefaultcstr(upb_fielddef *f, const char *str) { +void upb_fielddef_setdefaultcstr(upb_fielddef *f, const char *str, + upb_status *s) { assert(f->type_is_set_); - upb_fielddef_setdefaultstr(f, str, str ? strlen(str) : 0); + upb_fielddef_setdefaultstr(f, str, str ? strlen(str) : 0, s); } bool upb_fielddef_default_is_symbolic(const upb_fielddef *f) { @@ -740,34 +760,43 @@ bool upb_fielddef_default_is_symbolic(const upb_fielddef *f) { f->type_ == UPB_TYPE_ENUM; } -bool upb_fielddef_resolvedefault(upb_fielddef *f) { +bool upb_fielddef_resolveenumdefault(upb_fielddef *f, upb_status *s) { if (!upb_fielddef_default_is_symbolic(f)) return true; - str_t *s = upb_value_getptr(f->defaultval); + str_t *str = upb_value_getptr(f->defaultval); const upb_enumdef *e = upb_downcast_enumdef(upb_fielddef_subdef(f)); - assert(s); // Points to either a real default or the empty string. + assert(str); // Points to either a real default or the empty string. assert(e); - if (s->len == 0) { + if (str->len == 0) { // The "default default" for an enum is the first defined value. upb_value_setint32(&f->defaultval, e->defaultval); } else { int32_t val = 0; - if (!upb_enumdef_ntoi(e, s->str, &val)) + if (!upb_enumdef_ntoi(e, str->str, &val)) { + upb_status_seterrf(s, "enum default not found in enum (%s)", str->str); return false; + } upb_value_setint32(&f->defaultval, val); } f->default_is_string = false; - freestr(s); + freestr(str); return true; } -static bool upb_subdef_typecheck(upb_fielddef *f, const upb_def *subdef) { - if (f->type_ == UPB_TYPE_MESSAGE) - return upb_dyncast_msgdef(subdef) != NULL; - else if (f->type_ == UPB_TYPE_ENUM) - return upb_dyncast_enumdef(subdef) != NULL; - else { - assert(false); +static bool upb_subdef_typecheck(upb_fielddef *f, const upb_def *subdef, + upb_status *s) { + if (f->type_ == UPB_TYPE_MESSAGE) { + if (upb_dyncast_msgdef(subdef)) return true; + upb_status_seterrliteral(s, + "invalid subdef type for this submessage field"); + return false; + } else if (f->type_ == UPB_TYPE_ENUM) { + if (upb_dyncast_enumdef(subdef)) return true; + upb_status_seterrliteral(s, "invalid subdef type for this enum field"); + return false; + } else { + upb_status_seterrliteral(s, + "only message and enum fields can have a subdef"); return false; } } @@ -780,10 +809,11 @@ static void release_subdef(upb_fielddef *f) { } } -bool upb_fielddef_setsubdef(upb_fielddef *f, const upb_def *subdef) { +bool upb_fielddef_setsubdef(upb_fielddef *f, const upb_def *subdef, + upb_status *s) { assert(!upb_fielddef_isfrozen(f)); assert(upb_fielddef_hassubdef(f)); - if (subdef && !upb_subdef_typecheck(f, subdef)) return false; + if (subdef && !upb_subdef_typecheck(f, subdef, s)) return false; release_subdef(f); f->sub.def = subdef; f->subdef_is_symbolic = false; @@ -791,9 +821,13 @@ bool upb_fielddef_setsubdef(upb_fielddef *f, const upb_def *subdef) { return true; } -bool upb_fielddef_setsubdefname(upb_fielddef *f, const char *name) { +bool upb_fielddef_setsubdefname(upb_fielddef *f, const char *name, + upb_status *s) { assert(!upb_fielddef_isfrozen(f)); - assert(upb_fielddef_hassubdef(f)); + if (!upb_fielddef_hassubdef(f)) { + upb_status_seterrliteral(s, "field type does not accept a subdef"); + return false; + } release_subdef(f); f->sub.name = upb_strdup(name); f->subdef_is_symbolic = true; @@ -821,6 +855,17 @@ bool upb_fielddef_hassubdef(const upb_fielddef *f) { return upb_fielddef_issubmsg(f) || upb_fielddef_type(f) == UPB_TYPE_ENUM; } +static bool between(int32_t x, int32_t low, int32_t high) { + return x >= low && x <= high; +} + +bool upb_fielddef_checklabel(int32_t label) { return between(label, 1, 3); } +bool upb_fielddef_checktype(int32_t type) { return between(type, 1, 11); } +bool upb_fielddef_checkintfmt(int32_t fmt) { return between(fmt, 1, 3); } + +bool upb_fielddef_checkdescriptortype(int32_t type) { + return between(type, 1, 18); +} /* upb_msgdef *****************************************************************/ @@ -861,11 +906,13 @@ err2: upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner) { upb_msgdef *newm = upb_msgdef_new(owner); if (!newm) return NULL; - upb_def_setfullname(upb_upcast(newm), upb_def_fullname(upb_upcast(m))); + bool ok = upb_def_setfullname(upb_upcast(newm), + upb_def_fullname(upb_upcast(m)), NULL); + UPB_ASSERT_VAR(ok, ok); upb_msg_iter i; for(upb_msg_begin(&i, m); !upb_msg_done(&i); upb_msg_next(&i)) { upb_fielddef *f = upb_fielddef_dup(upb_msg_iter_field(&i), &f); - if (!f || !upb_msgdef_addfield(newm, f, &f)) { + if (!f || !upb_msgdef_addfield(newm, f, &f, NULL)) { upb_msgdef_unref(newm, owner); return NULL; } @@ -898,22 +945,29 @@ const char *upb_msgdef_fullname(const upb_msgdef *m) { return upb_def_fullname(upb_upcast(m)); } -bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname) { - return upb_def_setfullname(upb_upcast(m), fullname); +bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname, + upb_status *s) { + return upb_def_setfullname(upb_upcast(m), fullname, s); } bool upb_msgdef_addfields(upb_msgdef *m, upb_fielddef *const *fields, int n, - const void *ref_donor) { + const void *ref_donor, upb_status *s) { // Check constraints for all fields before performing any action. for (int i = 0; i < n; i++) { upb_fielddef *f = fields[i]; // TODO(haberman): handle the case where two fields of the input duplicate // name or number. - if (f->msgdef != NULL || - upb_fielddef_name(f) == NULL || upb_fielddef_number(f) == 0 || - upb_msgdef_itof(m, upb_fielddef_number(f)) || - upb_msgdef_ntof(m, upb_fielddef_name(f))) + if (f->msgdef != NULL) { + upb_status_seterrliteral(s, "fielddef already belongs to a message"); return false; + } else if (upb_fielddef_name(f) == NULL || upb_fielddef_number(f) == 0) { + upb_status_seterrliteral(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_status_seterrliteral(s, "duplicate field name or number"); + return false; + } } // Constraint checks ok, perform the action. @@ -929,9 +983,9 @@ bool upb_msgdef_addfields(upb_msgdef *m, upb_fielddef *const *fields, int n, return true; } -bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, - const void *ref_donor) { - return upb_msgdef_addfields(m, &f, 1, ref_donor); +bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor, + upb_status *s) { + return upb_msgdef_addfields(m, &f, 1, ref_donor, s); } const upb_fielddef *upb_msgdef_itof(const upb_msgdef *m, uint32_t i) { @@ -93,9 +93,10 @@ class upb::Def { // The def must be mutable. Caller retains ownership of fullname. Defs are // not required to have a name; if a def has no name when it is frozen, it - // will remain an anonymous def. - bool set_full_name(const char *fullname); - bool set_full_name(const std::string& fullname); + // will remain an anonymous def. On failure, returns false and details in "s" + // if non-NULL. + bool set_full_name(const char *fullname, upb::Status* s); + bool set_full_name(const std::string& fullname, upb::Status* s); // Freezes the given defs; this validates all constraints and marks the defs // as frozen (read-only). "defs" may not contain any fielddefs, but fields @@ -144,8 +145,8 @@ void upb_def_checkref(const upb_def *def, const void *owner); upb_deftype_t upb_def_type(const upb_def *d); const char *upb_def_fullname(const upb_def *d); -bool upb_def_setfullname(upb_def *def, const char *fullname); -bool upb_def_freeze(upb_def *const*defs, int n, upb_status *status); +bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s); +bool upb_def_freeze(upb_def *const*defs, int n, upb_status *s); #ifdef __cplusplus } // extern "C" #endif @@ -219,6 +220,19 @@ class upb::FieldDef { typedef upb_intfmt_t IntegerFormat; typedef upb_descriptortype_t DescriptorType; + // These return true if the given value is a valid member of the enumeration. + static bool CheckType(int32_t val); + static bool CheckLabel(int32_t val); + static bool CheckDescriptorType(int32_t val); + static bool CheckIntegerFormat(int32_t val); + + // These convert to the given enumeration; they require that the value is + // valid. + static Type ConvertType(int32_t val); + static Label ConvertLabel(int32_t val); + static DescriptorType ConvertDescriptorType(int32_t val); + static IntegerFormat ConvertIntegerFormat(int32_t val); + // Returns NULL if memory allocation failed. static FieldDef* New(const void *owner); @@ -243,38 +257,42 @@ class upb::FieldDef { // Functionality from upb::Def. const char *full_name() const; - bool set_full_name(const char *fullname); - bool set_full_name(const std::string& fullname); + bool set_full_name(const char *fullname, upb::Status* s); + bool set_full_name(const std::string& fullname, upb::Status* s); - bool type_is_set() const; // Whether set_type() has been called. + bool type_is_set() const; // Whether set_[descriptor_]type() has been called. Type type() const; // Requires that type_is_set() == true. Label label() const; // Defaults to UPB_LABEL_OPTIONAL. + const char *name() const; // NULL if uninitialized. uint32_t number() const; // Returns 0 if uninitialized. const MessageDef* message_def() const; - // Gets/sets the field's type according to the enum in descriptor.proto. - // This is not the same as UPB_TYPE_*, because it distinguishes between - // (for example) INT32 and SINT32, whereas our "type" enum does not. - // This return of descriptor_type() is a function of type(), - // integer_format(), and is_tag_delimited(). Likewise set_descriptor_type() - // sets all three appropriately. + // The field's type according to the enum in descriptor.proto. This is not + // the same as UPB_TYPE_*, because it distinguishes between (for example) + // INT32 and SINT32, whereas our "type" enum does not. This return of + // descriptor_type() is a function of type(), integer_format(), and + // is_tag_delimited(). Likewise set_descriptor_type() sets all three + // appropriately. DescriptorType descriptor_type() const; - bool set_descriptor_type(DescriptorType type); - // "number" and "name" must be set before the FieldDef is added to a - // MessageDef, and may not be set after that. "type" must be set explicitly - // before the fielddef is finalized. - bool set_number(uint32_t number); - bool set_type(Type type); - bool set_label(Label label); + // "type" or "descriptor_type" MUST be set explicitly before the fielddef is + // finalized. These setters require that the enum value is valid; if the + // value did not come directly from an enum constant, the caller should + // validate it first with the functions above (CheckFieldType(), etc). + void set_type(Type type); + void set_label(Label label); + void set_descriptor_type(DescriptorType type); - // These are the same as full_name()/set_full_name(), but since fielddefs + // "number" and "name" must be set before the FieldDef is added to a + // MessageDef, and may not be set after that. + // + // "name" is the same as full_name()/set_full_name(), but since fielddefs // most often use simple, non-qualified names, we provide this accessor // also. Generally only extensions will want to think of this name as // fully-qualified. - bool set_name(const char *name); - bool set_name(const std::string& name); - const char *name() const; + bool set_number(uint32_t number, upb::Status* s); + bool set_name(const char *name, upb::Status* s); + bool set_name(const std::string& name, upb::Status* s); // Convenient field type tests. bool IsSubMessage() const; @@ -285,12 +303,12 @@ class upb::FieldDef { // How integers are encoded. Only meaningful for integer types. // Defaults to UPB_INTFMT_VARIABLE, and is reset when "type" changes. IntegerFormat integer_format() const; - bool set_integer_format(IntegerFormat format); + void set_integer_format(IntegerFormat format); // Whether a submessage field is tag-delimited or not (if false, then - // length-delimited). Only meaningful when type() == UPB_TYPE_MESSAGE. + // length-delimited). May only be set when type() == UPB_TYPE_MESSAGE. bool is_tag_delimited() const; - bool set_tag_delimited(bool tag_delimited); + bool set_tag_delimited(bool tag_delimited, upb::Status* s); // Returns the non-string default value for this fielddef, which may either // be something the client set explicitly or the "default default" (0 for @@ -320,9 +338,9 @@ class upb::FieldDef { // NOTE: May only be called for fields whose type has already been set. // Also, will be reset to default if the field's type is set again. void set_default_value(Value value); - bool set_default_string(const void *str, size_t len); - bool set_default_string(const std::string& str); - void set_default_cstr(const char *str); + bool set_default_string(const void *str, size_t len, Status* s); + bool set_default_string(const std::string& str, Status* s); + void set_default_cstr(const char *str, Status* s); // The results of this function are only meaningful for mutable enum fields, // which can have a default specified either as an integer or as a string. @@ -333,7 +351,7 @@ class upb::FieldDef { // If this is an enum field with a symbolic default, resolves the default and // returns true if resolution was successful or if this field didn't need to // be resolved (because it is not an enum with a symbolic default). - bool ResolveDefault(); + bool ResolveEnumDefault(Status* s); // Submessage and enum fields must reference a "subdef", which is the // upb_msgdef or upb_enumdef that defines their type. Note that when the @@ -364,9 +382,9 @@ class upb::FieldDef { // to calling these methods). Returns false if this is not the case, or if // the given subdef is not of the correct type. The subdef is reset if the // field's type is changed. The subdef can be set to NULL to clear it. - bool set_subdef(const Def* subdef); - bool set_subdef_name(const char* name); - bool set_subdef_name(const std::string& name); + bool set_subdef(const Def* subdef, Status* s); + bool set_subdef_name(const char* name, Status* s); + bool set_subdef_name(const std::string& name, Status* s); private: UPB_DISALLOW_POD_OPS(FieldDef); @@ -415,7 +433,8 @@ void upb_fielddef_checkref(const upb_fielddef *f, const void *owner); // From upb_def. const char *upb_fielddef_fullname(const upb_fielddef *f); -bool upb_fielddef_setfullname(upb_fielddef *f, const char *fullname); +bool upb_fielddef_setfullname(upb_fielddef *f, const char *fullname, + upb_status *s); bool upb_fielddef_typeisset(const upb_fielddef *f); upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f); @@ -438,19 +457,29 @@ bool upb_fielddef_hassubdef(const upb_fielddef *f); const upb_def *upb_fielddef_subdef(const upb_fielddef *f); const char *upb_fielddef_subdefname(const upb_fielddef *f); -bool upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type); -bool upb_fielddef_setdescriptortype(upb_fielddef *f, int type); -bool upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label); -bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number); -bool upb_fielddef_setname(upb_fielddef *f, const char *name); +void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type); +void upb_fielddef_setdescriptortype(upb_fielddef *f, int type); +void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label); +bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s); +bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s); bool upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt); bool upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim); void upb_fielddef_setdefault(upb_fielddef *f, upb_value value); -bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len); -void upb_fielddef_setdefaultcstr(upb_fielddef *f, const char *str); -bool upb_fielddef_resolvedefault(upb_fielddef *f); -bool upb_fielddef_setsubdef(upb_fielddef *f, const upb_def *subdef); -bool upb_fielddef_setsubdefname(upb_fielddef *f, const char *name); +bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len, + upb_status *s); +void upb_fielddef_setdefaultcstr(upb_fielddef *f, const char *str, + upb_status *s); +bool upb_fielddef_resolveenumdefault(upb_fielddef *f, upb_status *s); +bool upb_fielddef_setsubdef(upb_fielddef *f, const upb_def *subdef, + upb_status *s); +bool upb_fielddef_setsubdefname(upb_fielddef *f, const char *name, + upb_status *s); + +bool upb_fielddef_checklabel(int32_t label); +bool upb_fielddef_checktype(int32_t type); +bool upb_fielddef_checkdescriptortype(int32_t type); +bool upb_fielddef_checkintfmt(int32_t fmt); + #ifdef __cplusplus } // extern "C" #endif @@ -482,19 +511,19 @@ class upb::MessageDef { // Functionality from upb::Def. const char *full_name() const; - bool set_full_name(const char *fullname); - bool set_full_name(const std::string& fullname); + bool set_full_name(const char *fullname, Status* s); + bool set_full_name(const std::string& fullname, Status* s); // The number of fields that belong to the MessageDef. int field_count() const; - // Adds a set of fields (upb_fielddef objects) to a msgdef. Requires that - // the msgdef and all the fielddefs are mutable. The fielddef's name and - // number must be set, and the message may not already contain any field with - // this name or number, and this fielddef may not be part of another message. - // In error cases false is returned and the msgdef is unchanged. On success, - // the caller donates a ref from ref_donor (if non-NULL). - bool AddField(upb_fielddef *f, const void *ref_donor); + // Adds a field (upb_fielddef object) to a msgdef. Requires that the msgdef + // and the fielddefs are mutable. The fielddef's name and number must be + // set, and the message may not already contain any field with this name or + // number, and this fielddef may not be part of another message. In error + // cases false is returned and the msgdef is unchanged. On success, the + // caller donates a ref from ref_donor (if non-NULL). + bool AddField(upb_fielddef *f, const void *ref_donor, Status* s); // These return NULL if the field is not found. FieldDef* FindFieldByNumber(uint32_t number); @@ -573,12 +602,13 @@ void upb_msgdef_checkref(const upb_msgdef *m, const void *owner); // From upb_def. const char *upb_msgdef_fullname(const upb_msgdef *m); -bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname); +bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname, upb_status *s); upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner); -bool upb_msgdef_addfields( - upb_msgdef *m, upb_fielddef *const *f, int n, const void *ref_donor); -bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor); +bool upb_msgdef_addfields(upb_msgdef *m, upb_fielddef *const *f, int n, + const void *ref_donor, upb_status *s); +bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor, + upb_status *s); const upb_fielddef *upb_msgdef_itof(const upb_msgdef *m, uint32_t i); const upb_fielddef *upb_msgdef_ntof(const upb_msgdef *m, const char *name); upb_fielddef *upb_msgdef_itof_mutable(upb_msgdef *m, uint32_t i); @@ -624,8 +654,8 @@ class upb::EnumDef { // Functionality from upb::Def. const char *full_name() const; - bool set_full_name(const char *fullname); - bool set_full_name(const std::string& fullname); + bool set_full_name(const char *fullname, Status* s); + bool set_full_name(const std::string& fullname, Status* s); // The value that is used as the default when no field default is specified. int32_t default_value() const; @@ -700,7 +730,8 @@ void upb_enumdef_checkref(const upb_enumdef *e, const void *owner); // From upb_def. const char *upb_enumdef_fullname(const upb_enumdef *e); -bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname); +bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname, + upb_status *s); int32_t upb_enumdef_default(const upb_enumdef *e); void upb_enumdef_setdefault(upb_enumdef *e, int32_t val); @@ -789,11 +820,11 @@ inline Def::Type Def::def_type() const { inline const char *Def::full_name() const { return upb_def_fullname(this); } -inline bool Def::set_full_name(const char *fullname) { - return upb_def_setfullname(this, fullname); +inline bool Def::set_full_name(const char *fullname, Status* s) { + return upb_def_setfullname(this, fullname, s); } -inline bool Def::set_full_name(const std::string& fullname) { - return upb_def_setfullname(this, upb_safecstr(fullname)); +inline bool Def::set_full_name(const std::string& fullname, Status* s) { + return upb_def_setfullname(this, upb_safecstr(fullname), s); } inline bool Def::Freeze(Def *const*defs, int n, Status *status) { return upb_def_freeze(defs, n, status); @@ -802,6 +833,36 @@ inline bool Def::Freeze(const std::vector<Def*>& defs, Status *status) { return upb_def_freeze((Def*const*)&defs[0], defs.size(), status); } + +inline bool FieldDef::CheckType(int32_t val) { + return upb_fielddef_checktype(val); +} +inline bool FieldDef::CheckLabel(int32_t val) { + return upb_fielddef_checklabel(val); +} +inline bool FieldDef::CheckDescriptorType(int32_t val) { + return upb_fielddef_checkdescriptortype(val); +} +inline bool FieldDef::CheckIntegerFormat(int32_t val) { + return upb_fielddef_checkintfmt(val); +} +inline FieldDef::Type FieldDef::ConvertType(int32_t val) { + assert(CheckType(val)); + return static_cast<FieldDef::Type>(val); +} +inline FieldDef::Label FieldDef::ConvertLabel(int32_t val) { + assert(CheckLabel(val)); + return static_cast<FieldDef::Label>(val); +} +inline FieldDef::DescriptorType FieldDef::ConvertDescriptorType(int32_t val) { + assert(CheckDescriptorType(val)); + return static_cast<FieldDef::DescriptorType>(val); +} +inline FieldDef::IntegerFormat FieldDef::ConvertIntegerFormat(int32_t val) { + assert(CheckIntegerFormat(val)); + return static_cast<FieldDef::IntegerFormat>(val); +} + inline FieldDef* FieldDef::New(const void *owner) { return upb_fielddef_new(owner); } @@ -832,11 +893,11 @@ inline void FieldDef::CheckRef(const void *owner) const { inline const char *FieldDef::full_name() const { return upb_fielddef_fullname(this); } -inline bool FieldDef::set_full_name(const char *fullname) { - return upb_fielddef_setfullname(this, fullname); +inline bool FieldDef::set_full_name(const char *fullname, Status* s) { + return upb_fielddef_setfullname(this, fullname, s); } -inline bool FieldDef::set_full_name(const std::string& fullname) { - return upb_fielddef_setfullname(this, upb_safecstr(fullname)); +inline bool FieldDef::set_full_name(const std::string &fullname, Status *s) { + return upb_fielddef_setfullname(this, upb_safecstr(fullname), s); } inline bool FieldDef::type_is_set() const { return upb_fielddef_typeisset(this); @@ -859,23 +920,23 @@ inline const char *FieldDef::name() const { inline const MessageDef* FieldDef::message_def() const { return upb_fielddef_msgdef(this); } -inline bool FieldDef::set_number(uint32_t number) { - return upb_fielddef_setnumber(this, number); +inline bool FieldDef::set_number(uint32_t number, Status* s) { + return upb_fielddef_setnumber(this, number, s); } -inline bool FieldDef::set_name(const char *name) { - return upb_fielddef_setname(this, name); +inline bool FieldDef::set_name(const char *name, Status* s) { + return upb_fielddef_setname(this, name, s); } -inline bool FieldDef::set_name(const std::string& name) { - return upb_fielddef_setname(this, upb_safecstr(name)); +inline bool FieldDef::set_name(const std::string& name, Status* s) { + return upb_fielddef_setname(this, upb_safecstr(name), s); } -inline bool FieldDef::set_type(upb_fieldtype_t type) { - return upb_fielddef_settype(this, type); +inline void FieldDef::set_type(upb_fieldtype_t type) { + upb_fielddef_settype(this, type); } -inline bool FieldDef::set_descriptor_type(FieldDef::DescriptorType type) { - return upb_fielddef_setdescriptortype(this, type); +inline void FieldDef::set_descriptor_type(FieldDef::DescriptorType type) { + upb_fielddef_setdescriptortype(this, type); } -inline bool FieldDef::set_label(upb_label_t label) { - return upb_fielddef_setlabel(this, label); +inline void FieldDef::set_label(upb_label_t label) { + upb_fielddef_setlabel(this, label); } inline bool FieldDef::IsSubMessage() const { return upb_fielddef_issubmsg(this); @@ -895,20 +956,21 @@ inline const char *FieldDef::GetDefaultString(size_t* len) const { inline void FieldDef::set_default_value(Value value) { upb_fielddef_setdefault(this, value); } -inline bool FieldDef::set_default_string(const void *str, size_t len) { - return upb_fielddef_setdefaultstr(this, str, len); +inline bool FieldDef::set_default_string(const void *str, size_t len, + Status *s) { + return upb_fielddef_setdefaultstr(this, str, len, s); } -inline bool FieldDef::set_default_string(const std::string& str) { - return upb_fielddef_setdefaultstr(this, str.c_str(), str.size()); +inline bool FieldDef::set_default_string(const std::string& str, Status* s) { + return upb_fielddef_setdefaultstr(this, str.c_str(), str.size(), s); } -inline void FieldDef::set_default_cstr(const char *str) { - return upb_fielddef_setdefaultcstr(this, str); +inline void FieldDef::set_default_cstr(const char *str, Status* s) { + return upb_fielddef_setdefaultcstr(this, str, s); } inline bool FieldDef::IsDefaultSymbolic() const { return upb_fielddef_default_is_symbolic(this); } -inline bool FieldDef::ResolveDefault() { - return upb_fielddef_resolvedefault(this); +inline bool FieldDef::ResolveEnumDefault(Status* s) { + return upb_fielddef_resolveenumdefault(this, s); } inline bool FieldDef::HasSubDef() const { return upb_fielddef_hassubdef(this); @@ -919,14 +981,14 @@ inline const Def* FieldDef::subdef() const { inline const char* FieldDef::subdef_name() const { return upb_fielddef_subdefname(this); } -inline bool FieldDef::set_subdef(const Def* subdef) { - return upb_fielddef_setsubdef(this, subdef); +inline bool FieldDef::set_subdef(const Def* subdef, Status* s) { + return upb_fielddef_setsubdef(this, subdef, s); } -inline bool FieldDef::set_subdef_name(const char* name) { - return upb_fielddef_setsubdefname(this, name); +inline bool FieldDef::set_subdef_name(const char* name, Status* s) { + return upb_fielddef_setsubdefname(this, name, s); } -inline bool FieldDef::set_subdef_name(const std::string& name) { - return upb_fielddef_setsubdefname(this, upb_safecstr(name)); +inline bool FieldDef::set_subdef_name(const std::string& name, Status* s) { + return upb_fielddef_setsubdefname(this, upb_safecstr(name), s); } inline MessageDef* MessageDef::New(const void *owner) { @@ -956,17 +1018,18 @@ inline void MessageDef::CheckRef(const void *owner) const { inline const char *MessageDef::full_name() const { return upb_msgdef_fullname(this); } -inline bool MessageDef::set_full_name(const char *fullname) { - return upb_msgdef_setfullname(this, fullname); +inline bool MessageDef::set_full_name(const char *fullname, Status *s) { + return upb_msgdef_setfullname(this, fullname, s); } -inline bool MessageDef::set_full_name(const std::string& fullname) { - return upb_msgdef_setfullname(this, upb_safecstr(fullname)); +inline bool MessageDef::set_full_name(const std::string& fullname, Status* s) { + return upb_msgdef_setfullname(this, upb_safecstr(fullname), s); } inline int MessageDef::field_count() const { return upb_msgdef_numfields(this); } -inline bool MessageDef::AddField(upb_fielddef *f, const void *ref_donor) { - return upb_msgdef_addfield(this, f, ref_donor); +inline bool MessageDef::AddField(upb_fielddef *f, const void *ref_donor, + Status *s) { + return upb_msgdef_addfield(this, f, ref_donor, s); } inline FieldDef* MessageDef::FindFieldByNumber(uint32_t number) { return upb_msgdef_itof_mutable(this, number); @@ -1037,11 +1100,11 @@ inline void EnumDef::CheckRef(const void *owner) const { inline const char *EnumDef::full_name() const { return upb_enumdef_fullname(this); } -inline bool EnumDef::set_full_name(const char *fullname) { - return upb_enumdef_setfullname(this, fullname); +inline bool EnumDef::set_full_name(const char *fullname, Status* s) { + return upb_enumdef_setfullname(this, fullname, s); } -inline bool EnumDef::set_full_name(const std::string& fullname) { - return upb_enumdef_setfullname(this, upb_safecstr(fullname)); +inline bool EnumDef::set_full_name(const std::string& fullname, Status* s) { + return upb_enumdef_setfullname(this, upb_safecstr(fullname), s); } inline int32_t EnumDef::default_value() const { return upb_enumdef_default(this); diff --git a/upb/descriptor/descriptor.upb.c b/upb/descriptor/descriptor.upb.c index 61a5449..e910d3a 100755 --- a/upb/descriptor/descriptor.upb.c +++ b/upb/descriptor/descriptor.upb.c @@ -12,102 +12,102 @@ const upb_tabent google_protobuf_intentries[66]; const _upb_value google_protobuf_arrays[97]; const upb_msgdef google_protobuf_msgs[20] = { - UPB_MSGDEF_INIT("google.protobuf.DescriptorProto", UPB_INTTABLE_INIT(2, 3, 9, 2, &google_protobuf_intentries[0], &google_protobuf_arrays[0], 6, 5), UPB_STRTABLE_INIT(7, 15, 9, 4, &google_protobuf_strentries[0]), 31), - UPB_MSGDEF_INIT("google.protobuf.DescriptorProto.ExtensionRange", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[6], 4, 2), UPB_STRTABLE_INIT(2, 3, 9, 2, &google_protobuf_strentries[16]), 2), - UPB_MSGDEF_INIT("google.protobuf.EnumDescriptorProto", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[10], 4, 3), UPB_STRTABLE_INIT(3, 3, 9, 2, &google_protobuf_strentries[20]), 11), - UPB_MSGDEF_INIT("google.protobuf.EnumOptions", UPB_INTTABLE_INIT(1, 1, 9, 1, &google_protobuf_intentries[4], &google_protobuf_arrays[14], 1, 0), UPB_STRTABLE_INIT(1, 3, 9, 2, &google_protobuf_strentries[24]), 5), - UPB_MSGDEF_INIT("google.protobuf.EnumValueDescriptorProto", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[15], 4, 3), UPB_STRTABLE_INIT(3, 3, 9, 2, &google_protobuf_strentries[28]), 7), - UPB_MSGDEF_INIT("google.protobuf.EnumValueOptions", UPB_INTTABLE_INIT(1, 1, 9, 1, &google_protobuf_intentries[6], &google_protobuf_arrays[19], 1, 0), UPB_STRTABLE_INIT(1, 3, 9, 2, &google_protobuf_strentries[32]), 5), - UPB_MSGDEF_INIT("google.protobuf.FieldDescriptorProto", UPB_INTTABLE_INIT(3, 3, 9, 2, &google_protobuf_intentries[8], &google_protobuf_arrays[20], 6, 5), UPB_STRTABLE_INIT(8, 15, 9, 4, &google_protobuf_strentries[36]), 18), - UPB_MSGDEF_INIT("google.protobuf.FieldOptions", UPB_INTTABLE_INIT(2, 3, 9, 2, &google_protobuf_intentries[12], &google_protobuf_arrays[26], 5, 3), UPB_STRTABLE_INIT(5, 7, 9, 3, &google_protobuf_strentries[52]), 11), - UPB_MSGDEF_INIT("google.protobuf.FileDescriptorProto", UPB_INTTABLE_INIT(4, 7, 9, 3, &google_protobuf_intentries[16], &google_protobuf_arrays[31], 6, 5), UPB_STRTABLE_INIT(9, 15, 9, 4, &google_protobuf_strentries[60]), 37), - UPB_MSGDEF_INIT("google.protobuf.FileDescriptorSet", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[37], 3, 1), UPB_STRTABLE_INIT(1, 3, 9, 2, &google_protobuf_strentries[76]), 5), - UPB_MSGDEF_INIT("google.protobuf.FileOptions", UPB_INTTABLE_INIT(8, 15, 9, 4, &google_protobuf_intentries[24], &google_protobuf_arrays[40], 6, 1), UPB_STRTABLE_INIT(9, 15, 9, 4, &google_protobuf_strentries[80]), 17), - UPB_MSGDEF_INIT("google.protobuf.MessageOptions", UPB_INTTABLE_INIT(1, 1, 9, 1, &google_protobuf_intentries[40], &google_protobuf_arrays[46], 4, 2), UPB_STRTABLE_INIT(3, 3, 9, 2, &google_protobuf_strentries[96]), 7), - UPB_MSGDEF_INIT("google.protobuf.MethodDescriptorProto", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[50], 5, 4), UPB_STRTABLE_INIT(4, 7, 9, 3, &google_protobuf_strentries[100]), 12), - UPB_MSGDEF_INIT("google.protobuf.MethodOptions", UPB_INTTABLE_INIT(1, 1, 9, 1, &google_protobuf_intentries[42], &google_protobuf_arrays[55], 1, 0), UPB_STRTABLE_INIT(1, 3, 9, 2, &google_protobuf_strentries[108]), 5), - UPB_MSGDEF_INIT("google.protobuf.ServiceDescriptorProto", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[56], 4, 3), UPB_STRTABLE_INIT(3, 3, 9, 2, &google_protobuf_strentries[112]), 11), - UPB_MSGDEF_INIT("google.protobuf.ServiceOptions", UPB_INTTABLE_INIT(1, 1, 9, 1, &google_protobuf_intentries[44], &google_protobuf_arrays[60], 1, 0), UPB_STRTABLE_INIT(1, 3, 9, 2, &google_protobuf_strentries[116]), 5), - UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[61], 3, 1), UPB_STRTABLE_INIT(1, 3, 9, 2, &google_protobuf_strentries[120]), 5), - UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo.Location", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[64], 4, 2), UPB_STRTABLE_INIT(2, 3, 9, 2, &google_protobuf_strentries[124]), 6), - UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption", UPB_INTTABLE_INIT(3, 3, 9, 2, &google_protobuf_intentries[46], &google_protobuf_arrays[68], 6, 4), UPB_STRTABLE_INIT(7, 15, 9, 4, &google_protobuf_strentries[128]), 17), - UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption.NamePart", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[74], 4, 2), UPB_STRTABLE_INIT(2, 3, 9, 2, &google_protobuf_strentries[144]), 4), + UPB_MSGDEF_INIT("google.protobuf.DescriptorProto", UPB_INTTABLE_INIT(2, 3, 9, 2, &google_protobuf_intentries[0], &google_protobuf_arrays[0], 6, 5), UPB_STRTABLE_INIT(7, 15, 9, 4, &google_protobuf_strentries[0]), 33), + UPB_MSGDEF_INIT("google.protobuf.DescriptorProto.ExtensionRange", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[6], 4, 2), UPB_STRTABLE_INIT(2, 3, 9, 2, &google_protobuf_strentries[16]), 4), + UPB_MSGDEF_INIT("google.protobuf.EnumDescriptorProto", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[10], 4, 3), UPB_STRTABLE_INIT(3, 3, 9, 2, &google_protobuf_strentries[20]), 13), + UPB_MSGDEF_INIT("google.protobuf.EnumOptions", UPB_INTTABLE_INIT(1, 1, 9, 1, &google_protobuf_intentries[4], &google_protobuf_arrays[14], 1, 0), UPB_STRTABLE_INIT(1, 3, 9, 2, &google_protobuf_strentries[24]), 7), + UPB_MSGDEF_INIT("google.protobuf.EnumValueDescriptorProto", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[15], 4, 3), UPB_STRTABLE_INIT(3, 3, 9, 2, &google_protobuf_strentries[28]), 9), + UPB_MSGDEF_INIT("google.protobuf.EnumValueOptions", UPB_INTTABLE_INIT(1, 1, 9, 1, &google_protobuf_intentries[6], &google_protobuf_arrays[19], 1, 0), UPB_STRTABLE_INIT(1, 3, 9, 2, &google_protobuf_strentries[32]), 7), + UPB_MSGDEF_INIT("google.protobuf.FieldDescriptorProto", UPB_INTTABLE_INIT(3, 3, 9, 2, &google_protobuf_intentries[8], &google_protobuf_arrays[20], 6, 5), UPB_STRTABLE_INIT(8, 15, 9, 4, &google_protobuf_strentries[36]), 20), + UPB_MSGDEF_INIT("google.protobuf.FieldOptions", UPB_INTTABLE_INIT(2, 3, 9, 2, &google_protobuf_intentries[12], &google_protobuf_arrays[26], 5, 3), UPB_STRTABLE_INIT(5, 7, 9, 3, &google_protobuf_strentries[52]), 13), + UPB_MSGDEF_INIT("google.protobuf.FileDescriptorProto", UPB_INTTABLE_INIT(4, 7, 9, 3, &google_protobuf_intentries[16], &google_protobuf_arrays[31], 6, 5), UPB_STRTABLE_INIT(9, 15, 9, 4, &google_protobuf_strentries[60]), 39), + UPB_MSGDEF_INIT("google.protobuf.FileDescriptorSet", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[37], 3, 1), UPB_STRTABLE_INIT(1, 3, 9, 2, &google_protobuf_strentries[76]), 7), + UPB_MSGDEF_INIT("google.protobuf.FileOptions", UPB_INTTABLE_INIT(8, 15, 9, 4, &google_protobuf_intentries[24], &google_protobuf_arrays[40], 6, 1), UPB_STRTABLE_INIT(9, 15, 9, 4, &google_protobuf_strentries[80]), 19), + UPB_MSGDEF_INIT("google.protobuf.MessageOptions", UPB_INTTABLE_INIT(1, 1, 9, 1, &google_protobuf_intentries[40], &google_protobuf_arrays[46], 4, 2), UPB_STRTABLE_INIT(3, 3, 9, 2, &google_protobuf_strentries[96]), 9), + UPB_MSGDEF_INIT("google.protobuf.MethodDescriptorProto", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[50], 5, 4), UPB_STRTABLE_INIT(4, 7, 9, 3, &google_protobuf_strentries[100]), 14), + UPB_MSGDEF_INIT("google.protobuf.MethodOptions", UPB_INTTABLE_INIT(1, 1, 9, 1, &google_protobuf_intentries[42], &google_protobuf_arrays[55], 1, 0), UPB_STRTABLE_INIT(1, 3, 9, 2, &google_protobuf_strentries[108]), 7), + UPB_MSGDEF_INIT("google.protobuf.ServiceDescriptorProto", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[56], 4, 3), UPB_STRTABLE_INIT(3, 3, 9, 2, &google_protobuf_strentries[112]), 13), + UPB_MSGDEF_INIT("google.protobuf.ServiceOptions", UPB_INTTABLE_INIT(1, 1, 9, 1, &google_protobuf_intentries[44], &google_protobuf_arrays[60], 1, 0), UPB_STRTABLE_INIT(1, 3, 9, 2, &google_protobuf_strentries[116]), 7), + UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[61], 3, 1), UPB_STRTABLE_INIT(1, 3, 9, 2, &google_protobuf_strentries[120]), 7), + UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo.Location", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[64], 4, 2), UPB_STRTABLE_INIT(2, 3, 9, 2, &google_protobuf_strentries[124]), 8), + UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption", UPB_INTTABLE_INIT(3, 3, 9, 2, &google_protobuf_intentries[46], &google_protobuf_arrays[68], 6, 4), UPB_STRTABLE_INIT(7, 15, 9, 4, &google_protobuf_strentries[128]), 19), + UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption.NamePart", UPB_INTTABLE_INIT(0, 0, 9, 0, NULL, &google_protobuf_arrays[74], 4, 2), UPB_STRTABLE_INIT(2, 3, 9, 2, &google_protobuf_strentries[144]), 6), }; const upb_fielddef google_protobuf_fields[73] = { - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "aggregate_value", 8, &google_protobuf_msgs[18], NULL, 10, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "cc_generic_services", 16, &google_protobuf_msgs[10], NULL, 3, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, "ctype", 1, &google_protobuf_msgs[7], upb_upcast(&google_protobuf_enums[2]), 0, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "default_value", 7, &google_protobuf_msgs[6], NULL, 15, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, "dependency", 3, &google_protobuf_msgs[8], NULL, 8, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "deprecated", 3, &google_protobuf_msgs[7], NULL, 2, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_DOUBLE, 0, false, "double_value", 6, &google_protobuf_msgs[18], NULL, 13, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, "end", 2, &google_protobuf_msgs[1], NULL, 1, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "enum_type", 4, &google_protobuf_msgs[0], upb_upcast(&google_protobuf_msgs[2]), 15, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "enum_type", 5, &google_protobuf_msgs[8], upb_upcast(&google_protobuf_msgs[2]), 18, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "experimental_map_key", 9, &google_protobuf_msgs[7], NULL, 3, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "extendee", 2, &google_protobuf_msgs[6], NULL, 3, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "extension", 7, &google_protobuf_msgs[8], upb_upcast(&google_protobuf_msgs[6]), 34, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "extension", 6, &google_protobuf_msgs[0], upb_upcast(&google_protobuf_msgs[6]), 25, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "extension_range", 5, &google_protobuf_msgs[0], upb_upcast(&google_protobuf_msgs[1]), 20, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "field", 2, &google_protobuf_msgs[0], upb_upcast(&google_protobuf_msgs[6]), 5, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "file", 1, &google_protobuf_msgs[9], upb_upcast(&google_protobuf_msgs[8]), 2, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "identifier_value", 3, &google_protobuf_msgs[18], NULL, 5, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "input_type", 2, &google_protobuf_msgs[12], NULL, 3, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_BOOL, 0, false, "is_extension", 2, &google_protobuf_msgs[19], NULL, 3, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "java_generate_equals_and_hash", 20, &google_protobuf_msgs[10], NULL, 6, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "java_generic_services", 17, &google_protobuf_msgs[10], NULL, 4, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "java_multiple_files", 10, &google_protobuf_msgs[10], NULL, 16, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "java_outer_classname", 8, &google_protobuf_msgs[10], NULL, 12, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "java_package", 1, &google_protobuf_msgs[10], NULL, 0, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, "label", 4, &google_protobuf_msgs[6], upb_upcast(&google_protobuf_enums[0]), 7, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "location", 1, &google_protobuf_msgs[16], upb_upcast(&google_protobuf_msgs[17]), 2, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "message_set_wire_format", 1, &google_protobuf_msgs[11], NULL, 0, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "message_type", 4, &google_protobuf_msgs[8], upb_upcast(&google_protobuf_msgs[0]), 13, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "method", 2, &google_protobuf_msgs[14], upb_upcast(&google_protobuf_msgs[12]), 5, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[12], NULL, 0, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[4], NULL, 0, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[14], NULL, 0, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[2], NULL, 0, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[6], NULL, 0, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "name", 2, &google_protobuf_msgs[18], upb_upcast(&google_protobuf_msgs[19]), 2, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[0], NULL, 0, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[8], NULL, 0, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_STRING, 0, false, "name_part", 1, &google_protobuf_msgs[19], NULL, 0, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT64, UPB_INTFMT_VARIABLE, false, "negative_int_value", 5, &google_protobuf_msgs[18], NULL, 9, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "nested_type", 3, &google_protobuf_msgs[0], upb_upcast(&google_protobuf_msgs[0]), 10, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "no_standard_descriptor_accessor", 2, &google_protobuf_msgs[11], NULL, 1, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, "number", 2, &google_protobuf_msgs[4], NULL, 3, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, "number", 3, &google_protobuf_msgs[6], NULL, 6, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, "optimize_for", 9, &google_protobuf_msgs[10], upb_upcast(&google_protobuf_enums[3]), 15, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 4, &google_protobuf_msgs[12], upb_upcast(&google_protobuf_msgs[13]), 9, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 3, &google_protobuf_msgs[14], upb_upcast(&google_protobuf_msgs[15]), 8, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 8, &google_protobuf_msgs[8], upb_upcast(&google_protobuf_msgs[10]), 21, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 3, &google_protobuf_msgs[2], upb_upcast(&google_protobuf_msgs[3]), 8, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 7, &google_protobuf_msgs[0], upb_upcast(&google_protobuf_msgs[11]), 28, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 8, &google_protobuf_msgs[6], upb_upcast(&google_protobuf_msgs[7]), 9, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 3, &google_protobuf_msgs[4], upb_upcast(&google_protobuf_msgs[5]), 4, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "output_type", 3, &google_protobuf_msgs[12], NULL, 6, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "package", 2, &google_protobuf_msgs[8], NULL, 3, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "packed", 2, &google_protobuf_msgs[7], NULL, 1, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, "path", 1, &google_protobuf_msgs[17], NULL, 2, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_UINT64, UPB_INTFMT_VARIABLE, false, "positive_int_value", 4, &google_protobuf_msgs[18], NULL, 8, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "py_generic_services", 18, &google_protobuf_msgs[10], NULL, 5, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "service", 6, &google_protobuf_msgs[8], upb_upcast(&google_protobuf_msgs[14]), 29, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "source_code_info", 9, &google_protobuf_msgs[8], upb_upcast(&google_protobuf_msgs[16]), 24, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, "span", 2, &google_protobuf_msgs[17], NULL, 5, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, "start", 1, &google_protobuf_msgs[1], NULL, 0, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, "string_value", 7, &google_protobuf_msgs[18], NULL, 14, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, "type", 5, &google_protobuf_msgs[6], upb_upcast(&google_protobuf_enums[1]), 8, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "type_name", 6, &google_protobuf_msgs[6], NULL, 12, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[15], upb_upcast(&google_protobuf_msgs[18]), 2, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[11], upb_upcast(&google_protobuf_msgs[18]), 4, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[13], upb_upcast(&google_protobuf_msgs[18]), 2, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[10], upb_upcast(&google_protobuf_msgs[18]), 9, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[7], upb_upcast(&google_protobuf_msgs[18]), 8, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[3], upb_upcast(&google_protobuf_msgs[18]), 2, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[5], upb_upcast(&google_protobuf_msgs[18]), 2, UPB_VALUE_INIT_NONE), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "value", 2, &google_protobuf_msgs[2], upb_upcast(&google_protobuf_msgs[4]), 5, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "aggregate_value", 8, &google_protobuf_msgs[18], NULL, 12, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "cc_generic_services", 16, &google_protobuf_msgs[10], NULL, 5, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, "ctype", 1, &google_protobuf_msgs[7], upb_upcast(&google_protobuf_enums[2]), 2, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "default_value", 7, &google_protobuf_msgs[6], NULL, 17, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, "dependency", 3, &google_protobuf_msgs[8], NULL, 10, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "deprecated", 3, &google_protobuf_msgs[7], NULL, 4, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_DOUBLE, 0, false, "double_value", 6, &google_protobuf_msgs[18], NULL, 15, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, "end", 2, &google_protobuf_msgs[1], NULL, 3, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "enum_type", 4, &google_protobuf_msgs[0], upb_upcast(&google_protobuf_msgs[2]), 17, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "enum_type", 5, &google_protobuf_msgs[8], upb_upcast(&google_protobuf_msgs[2]), 20, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "experimental_map_key", 9, &google_protobuf_msgs[7], NULL, 5, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "extendee", 2, &google_protobuf_msgs[6], NULL, 5, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "extension", 7, &google_protobuf_msgs[8], upb_upcast(&google_protobuf_msgs[6]), 36, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "extension", 6, &google_protobuf_msgs[0], upb_upcast(&google_protobuf_msgs[6]), 27, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "extension_range", 5, &google_protobuf_msgs[0], upb_upcast(&google_protobuf_msgs[1]), 22, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "field", 2, &google_protobuf_msgs[0], upb_upcast(&google_protobuf_msgs[6]), 7, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "file", 1, &google_protobuf_msgs[9], upb_upcast(&google_protobuf_msgs[8]), 4, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "identifier_value", 3, &google_protobuf_msgs[18], NULL, 7, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "input_type", 2, &google_protobuf_msgs[12], NULL, 5, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_BOOL, 0, false, "is_extension", 2, &google_protobuf_msgs[19], NULL, 5, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "java_generate_equals_and_hash", 20, &google_protobuf_msgs[10], NULL, 8, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "java_generic_services", 17, &google_protobuf_msgs[10], NULL, 6, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "java_multiple_files", 10, &google_protobuf_msgs[10], NULL, 18, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "java_outer_classname", 8, &google_protobuf_msgs[10], NULL, 14, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "java_package", 1, &google_protobuf_msgs[10], NULL, 2, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, "label", 4, &google_protobuf_msgs[6], upb_upcast(&google_protobuf_enums[0]), 9, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "location", 1, &google_protobuf_msgs[16], upb_upcast(&google_protobuf_msgs[17]), 4, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "message_set_wire_format", 1, &google_protobuf_msgs[11], NULL, 2, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "message_type", 4, &google_protobuf_msgs[8], upb_upcast(&google_protobuf_msgs[0]), 15, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "method", 2, &google_protobuf_msgs[14], upb_upcast(&google_protobuf_msgs[12]), 7, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[12], NULL, 2, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[4], NULL, 2, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[14], NULL, 2, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[2], NULL, 2, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[6], NULL, 2, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "name", 2, &google_protobuf_msgs[18], upb_upcast(&google_protobuf_msgs[19]), 4, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[0], NULL, 2, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "name", 1, &google_protobuf_msgs[8], NULL, 2, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_STRING, 0, false, "name_part", 1, &google_protobuf_msgs[19], NULL, 2, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT64, UPB_INTFMT_VARIABLE, false, "negative_int_value", 5, &google_protobuf_msgs[18], NULL, 11, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "nested_type", 3, &google_protobuf_msgs[0], upb_upcast(&google_protobuf_msgs[0]), 12, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "no_standard_descriptor_accessor", 2, &google_protobuf_msgs[11], NULL, 3, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, "number", 2, &google_protobuf_msgs[4], NULL, 5, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, "number", 3, &google_protobuf_msgs[6], NULL, 8, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, "optimize_for", 9, &google_protobuf_msgs[10], upb_upcast(&google_protobuf_enums[3]), 17, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 4, &google_protobuf_msgs[12], upb_upcast(&google_protobuf_msgs[13]), 11, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 3, &google_protobuf_msgs[14], upb_upcast(&google_protobuf_msgs[15]), 10, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 8, &google_protobuf_msgs[8], upb_upcast(&google_protobuf_msgs[10]), 23, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 3, &google_protobuf_msgs[2], upb_upcast(&google_protobuf_msgs[3]), 10, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 7, &google_protobuf_msgs[0], upb_upcast(&google_protobuf_msgs[11]), 30, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 8, &google_protobuf_msgs[6], upb_upcast(&google_protobuf_msgs[7]), 11, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "options", 3, &google_protobuf_msgs[4], upb_upcast(&google_protobuf_msgs[5]), 6, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "output_type", 3, &google_protobuf_msgs[12], NULL, 8, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "package", 2, &google_protobuf_msgs[8], NULL, 5, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "packed", 2, &google_protobuf_msgs[7], NULL, 3, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, "path", 1, &google_protobuf_msgs[17], NULL, 4, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_UINT64, UPB_INTFMT_VARIABLE, false, "positive_int_value", 4, &google_protobuf_msgs[18], NULL, 10, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, "py_generic_services", 18, &google_protobuf_msgs[10], NULL, 7, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "service", 6, &google_protobuf_msgs[8], upb_upcast(&google_protobuf_msgs[14]), 31, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, "source_code_info", 9, &google_protobuf_msgs[8], upb_upcast(&google_protobuf_msgs[16]), 26, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, "span", 2, &google_protobuf_msgs[17], NULL, 7, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, "start", 1, &google_protobuf_msgs[1], NULL, 2, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, "string_value", 7, &google_protobuf_msgs[18], NULL, 16, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, "type", 5, &google_protobuf_msgs[6], upb_upcast(&google_protobuf_enums[1]), 10, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, "type_name", 6, &google_protobuf_msgs[6], NULL, 14, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[15], upb_upcast(&google_protobuf_msgs[18]), 4, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[11], upb_upcast(&google_protobuf_msgs[18]), 6, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[13], upb_upcast(&google_protobuf_msgs[18]), 4, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[10], upb_upcast(&google_protobuf_msgs[18]), 11, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[7], upb_upcast(&google_protobuf_msgs[18]), 10, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[3], upb_upcast(&google_protobuf_msgs[18]), 4, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "uninterpreted_option", 999, &google_protobuf_msgs[5], upb_upcast(&google_protobuf_msgs[18]), 4, UPB_VALUE_INIT_NONE), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, "value", 2, &google_protobuf_msgs[2], upb_upcast(&google_protobuf_msgs[4]), 7, UPB_VALUE_INIT_NONE), }; const upb_enumdef google_protobuf_enums[4] = { diff --git a/upb/descriptor/descriptor.upb.h b/upb/descriptor/descriptor.upb.h index e3291a3..e61178a 100755 --- a/upb/descriptor/descriptor.upb.h +++ b/upb/descriptor/descriptor.upb.h @@ -84,198 +84,198 @@ extern const upb_enumdef google_protobuf_enums[4]; #define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART &google_protobuf_msgs[19] // Selector definitions. -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_AGGREGATE_VALUE_ENDSTR 12 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_AGGREGATE_VALUE_STRING 10 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_AGGREGATE_VALUE_STARTSTR 11 -#define GOOGLE_PROTOBUF_FILEOPTIONS_CC_GENERIC_SERVICES_BOOL 3 -#define GOOGLE_PROTOBUF_FIELDOPTIONS_CTYPE_INT32 0 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_ENDSTR 17 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STRING 15 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STARTSTR 16 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_ENDSTR 10 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_ENDSEQ 7 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STRING 8 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STARTSTR 9 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STARTSEQ 6 -#define GOOGLE_PROTOBUF_FIELDOPTIONS_DEPRECATED_BOOL 2 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_DOUBLE_VALUE_DOUBLE 13 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_END_INT32 1 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSUBMSG 15 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 14 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 13 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 16 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_STARTSUBMSG 18 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 17 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 16 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 19 -#define GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_ENDSTR 5 -#define GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_STRING 3 -#define GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_STARTSTR 4 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_ENDSTR 5 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_STRING 3 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_STARTSTR 4 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_STARTSUBMSG 34 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_ENDSEQ 33 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_STARTSEQ 32 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_ENDSUBMSG 35 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSUBMSG 25 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSEQ 24 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSEQ 23 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSUBMSG 26 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSUBMSG 20 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSEQ 19 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSEQ 18 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSUBMSG 21 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSUBMSG 5 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSEQ 4 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSEQ 3 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSUBMSG 6 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSUBMSG 2 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_ENDSEQ 1 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSEQ 0 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_ENDSUBMSG 3 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_IDENTIFIER_VALUE_ENDSTR 7 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_IDENTIFIER_VALUE_STRING 5 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_IDENTIFIER_VALUE_STARTSTR 6 -#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_ENDSTR 5 -#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_STRING 3 -#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_STARTSTR 4 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_IS_EXTENSION_BOOL 3 -#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERATE_EQUALS_AND_HASH_BOOL 6 -#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERIC_SERVICES_BOOL 4 -#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_MULTIPLE_FILES_BOOL 16 -#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_ENDSTR 14 -#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_STRING 12 -#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_STARTSTR 13 -#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_ENDSTR 2 -#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_STRING 0 -#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_STARTSTR 1 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_INT32 7 -#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSUBMSG 2 -#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_ENDSEQ 1 -#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSEQ 0 -#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_ENDSUBMSG 3 -#define GOOGLE_PROTOBUF_MESSAGEOPTIONS_MESSAGE_SET_WIRE_FORMAT_BOOL 0 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSUBMSG 13 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_ENDSEQ 12 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSEQ 11 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_ENDSUBMSG 14 -#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSUBMSG 5 -#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_ENDSEQ 4 -#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSEQ 3 -#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_ENDSUBMSG 6 -#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_ENDSTR 2 -#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_STRING 0 -#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_STARTSTR 1 -#define GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_ENDSTR 2 -#define GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_STRING 0 -#define GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_STARTSTR 1 -#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_ENDSTR 2 -#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_STRING 0 -#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_STARTSTR 1 -#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_ENDSTR 2 -#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_STRING 0 -#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_STARTSTR 1 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_ENDSTR 2 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_STRING 0 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_STARTSTR 1 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_STARTSUBMSG 2 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_ENDSEQ 1 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_STARTSEQ 0 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_ENDSUBMSG 3 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_ENDSTR 2 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STRING 0 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STARTSTR 1 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_ENDSTR 2 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_STRING 0 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_STARTSTR 1 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_NAME_PART_ENDSTR 2 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_NAME_PART_STRING 0 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_NAME_PART_STARTSTR 1 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NEGATIVE_INT_VALUE_INT64 9 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSUBMSG 10 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSEQ 9 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSEQ 8 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSUBMSG 11 -#define GOOGLE_PROTOBUF_MESSAGEOPTIONS_NO_STANDARD_DESCRIPTOR_ACCESSOR_BOOL 1 -#define GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NUMBER_INT32 3 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NUMBER_INT32 6 -#define GOOGLE_PROTOBUF_FILEOPTIONS_OPTIMIZE_FOR_INT32 15 -#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 9 -#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 10 -#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 8 -#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 9 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 21 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 22 -#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 8 -#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 9 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_STARTSUBMSG 28 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_ENDSUBMSG 29 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 9 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 10 -#define GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 4 -#define GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 5 -#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_ENDSTR 8 -#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STRING 6 -#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STARTSTR 7 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_ENDSTR 5 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_STRING 3 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_STARTSTR 4 -#define GOOGLE_PROTOBUF_FIELDOPTIONS_PACKED_BOOL 1 -#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_ENDSEQ 1 -#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_INT32 2 -#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_STARTSEQ 0 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_POSITIVE_INT_VALUE_UINT64 8 -#define GOOGLE_PROTOBUF_FILEOPTIONS_PY_GENERIC_SERVICES_BOOL 5 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_STARTSUBMSG 29 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_ENDSEQ 28 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_STARTSEQ 27 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_ENDSUBMSG 30 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SOURCE_CODE_INFO_STARTSUBMSG 24 -#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SOURCE_CODE_INFO_ENDSUBMSG 25 -#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_ENDSEQ 4 -#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_INT32 5 -#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_STARTSEQ 3 -#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_START_INT32 0 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_STRING_VALUE_ENDSTR 16 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_STRING_VALUE_STRING 14 -#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_STRING_VALUE_STARTSTR 15 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT32 8 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_ENDSTR 14 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_STRING 12 -#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_STARTSTR 13 -#define GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2 -#define GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 1 -#define GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 0 -#define GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 3 -#define GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 4 -#define GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 3 -#define GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 2 -#define GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5 -#define GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2 -#define GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 1 -#define GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 0 -#define GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 3 -#define GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 9 -#define GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 8 -#define GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 7 -#define GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 10 -#define GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 8 -#define GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 7 -#define GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 6 -#define GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 9 -#define GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2 -#define GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 1 -#define GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 0 -#define GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 3 -#define GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2 -#define GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 1 -#define GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 0 -#define GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 3 -#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSUBMSG 5 -#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_ENDSEQ 4 -#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSEQ 3 -#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_ENDSUBMSG 6 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_AGGREGATE_VALUE_ENDSTR 14 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_AGGREGATE_VALUE_STRING 12 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_AGGREGATE_VALUE_STARTSTR 13 +#define GOOGLE_PROTOBUF_FILEOPTIONS_CC_GENERIC_SERVICES_BOOL 5 +#define GOOGLE_PROTOBUF_FIELDOPTIONS_CTYPE_INT32 2 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_ENDSTR 19 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STRING 17 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STARTSTR 18 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_ENDSTR 12 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_ENDSEQ 9 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STRING 10 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STARTSTR 11 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STARTSEQ 8 +#define GOOGLE_PROTOBUF_FIELDOPTIONS_DEPRECATED_BOOL 4 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_DOUBLE_VALUE_DOUBLE 15 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_END_INT32 3 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSUBMSG 17 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 16 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 15 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 18 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_STARTSUBMSG 20 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 19 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 18 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 21 +#define GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_ENDSTR 7 +#define GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_STRING 5 +#define GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_STARTSTR 6 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_ENDSTR 7 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_STRING 5 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_STARTSTR 6 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_STARTSUBMSG 36 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_ENDSEQ 35 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_STARTSEQ 34 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_ENDSUBMSG 37 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSUBMSG 27 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSEQ 26 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSEQ 25 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSUBMSG 28 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSUBMSG 22 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSEQ 21 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSEQ 20 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSUBMSG 23 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSUBMSG 7 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSEQ 6 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSEQ 5 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSUBMSG 8 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSUBMSG 4 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_ENDSEQ 3 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSEQ 2 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_ENDSUBMSG 5 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_IDENTIFIER_VALUE_ENDSTR 9 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_IDENTIFIER_VALUE_STRING 7 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_IDENTIFIER_VALUE_STARTSTR 8 +#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_ENDSTR 7 +#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_STRING 5 +#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_STARTSTR 6 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_IS_EXTENSION_BOOL 5 +#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERATE_EQUALS_AND_HASH_BOOL 8 +#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERIC_SERVICES_BOOL 6 +#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_MULTIPLE_FILES_BOOL 18 +#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_ENDSTR 16 +#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_STRING 14 +#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_STARTSTR 15 +#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_ENDSTR 4 +#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_STRING 2 +#define GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_STARTSTR 3 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_INT32 9 +#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSUBMSG 4 +#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_ENDSEQ 3 +#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSEQ 2 +#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_ENDSUBMSG 5 +#define GOOGLE_PROTOBUF_MESSAGEOPTIONS_MESSAGE_SET_WIRE_FORMAT_BOOL 2 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSUBMSG 15 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_ENDSEQ 14 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSEQ 13 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_ENDSUBMSG 16 +#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSUBMSG 7 +#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_ENDSEQ 6 +#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSEQ 5 +#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_ENDSUBMSG 8 +#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_ENDSTR 4 +#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_STRING 2 +#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_STARTSTR 3 +#define GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_ENDSTR 4 +#define GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_STRING 2 +#define GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_STARTSTR 3 +#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_ENDSTR 4 +#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_STRING 2 +#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_STARTSTR 3 +#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_ENDSTR 4 +#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_STRING 2 +#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_STARTSTR 3 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_ENDSTR 4 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_STRING 2 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_STARTSTR 3 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_STARTSUBMSG 4 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_ENDSEQ 3 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_STARTSEQ 2 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_ENDSUBMSG 5 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_ENDSTR 4 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STRING 2 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STARTSTR 3 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_ENDSTR 4 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_STRING 2 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_STARTSTR 3 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_NAME_PART_ENDSTR 4 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_NAME_PART_STRING 2 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_NAME_PART_STARTSTR 3 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NEGATIVE_INT_VALUE_INT64 11 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSUBMSG 12 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSEQ 11 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSEQ 10 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSUBMSG 13 +#define GOOGLE_PROTOBUF_MESSAGEOPTIONS_NO_STANDARD_DESCRIPTOR_ACCESSOR_BOOL 3 +#define GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NUMBER_INT32 5 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NUMBER_INT32 8 +#define GOOGLE_PROTOBUF_FILEOPTIONS_OPTIMIZE_FOR_INT32 17 +#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 11 +#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 12 +#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 10 +#define GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 11 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 23 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 24 +#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 10 +#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 11 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_STARTSUBMSG 30 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_ENDSUBMSG 31 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 11 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 12 +#define GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 6 +#define GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 7 +#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_ENDSTR 10 +#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STRING 8 +#define GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STARTSTR 9 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_ENDSTR 7 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_STRING 5 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_STARTSTR 6 +#define GOOGLE_PROTOBUF_FIELDOPTIONS_PACKED_BOOL 3 +#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_ENDSEQ 3 +#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_INT32 4 +#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_STARTSEQ 2 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_POSITIVE_INT_VALUE_UINT64 10 +#define GOOGLE_PROTOBUF_FILEOPTIONS_PY_GENERIC_SERVICES_BOOL 7 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_STARTSUBMSG 31 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_ENDSEQ 30 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_STARTSEQ 29 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_ENDSUBMSG 32 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SOURCE_CODE_INFO_STARTSUBMSG 26 +#define GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SOURCE_CODE_INFO_ENDSUBMSG 27 +#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_ENDSEQ 6 +#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_INT32 7 +#define GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_STARTSEQ 5 +#define GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_START_INT32 2 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_STRING_VALUE_ENDSTR 18 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_STRING_VALUE_STRING 16 +#define GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_STRING_VALUE_STARTSTR 17 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT32 10 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_ENDSTR 16 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_STRING 14 +#define GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_STARTSTR 15 +#define GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 4 +#define GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 3 +#define GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 2 +#define GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5 +#define GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 6 +#define GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 5 +#define GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 4 +#define GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 7 +#define GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 4 +#define GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 3 +#define GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 2 +#define GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5 +#define GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 11 +#define GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 10 +#define GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 9 +#define GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 12 +#define GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 10 +#define GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 9 +#define GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 8 +#define GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 11 +#define GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 4 +#define GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 3 +#define GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 2 +#define GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5 +#define GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 4 +#define GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 3 +#define GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 2 +#define GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5 +#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSUBMSG 7 +#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_ENDSEQ 6 +#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSEQ 5 +#define GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_ENDSUBMSG 8 #ifdef __cplusplus }; // extern "C" diff --git a/upb/descriptor/reader.c b/upb/descriptor/reader.c index 5fe334f..e1b0c92 100644 --- a/upb/descriptor/reader.c +++ b/upb/descriptor/reader.c @@ -103,7 +103,7 @@ static void upb_deflist_qualify(upb_deflist *l, char *str, int32_t start) { for(uint32_t i = start; i < l->len; i++) { upb_def *def = l->defs[i]; char *name = upb_join(str, upb_def_fullname(def)); - upb_def_setfullname(def, name); + upb_def_setfullname(def, name, NULL); free(name); } } @@ -216,12 +216,14 @@ void upb_descreader_setscopename(upb_descreader *r, char *str) { } // Handlers for google.protobuf.FileDescriptorProto. -static bool file_startmsg(void *r) { +static bool file_startmsg(void *r, const void *hd) { + UPB_UNUSED(hd); upb_descreader_startcontainer(r); return true; } -static bool file_endmsg(void *closure, upb_status *status) { +static bool file_endmsg(void *closure, const void *hd, upb_status *status) { + UPB_UNUSED(hd); UPB_UNUSED(status); upb_descreader *r = closure; upb_descreader_endcontainer(r); @@ -238,7 +240,8 @@ static size_t file_onpackage(void *closure, const void *hd, const char *buf, } // Handlers for google.protobuf.EnumValueDescriptorProto. -static bool enumval_startmsg(void *closure) { +static bool enumval_startmsg(void *closure, const void *hd) { + UPB_UNUSED(hd); upb_descreader *r = closure; r->saw_number = false; r->saw_name = false; @@ -264,7 +267,8 @@ static bool enumval_onnumber(void *closure, const void *hd, int32_t val) { return true; } -static bool enumval_endmsg(void *closure, upb_status *status) { +static bool enumval_endmsg(void *closure, const void *hd, upb_status *status) { + UPB_UNUSED(hd); upb_descreader *r = closure; if(!r->saw_number || !r->saw_name) { upb_status_seterrliteral(status, "Enum value missing name or number."); @@ -284,13 +288,14 @@ static bool enumval_endmsg(void *closure, upb_status *status) { // Handlers for google.protobuf.EnumDescriptorProto. -static bool enum_startmsg(void *closure) { +static bool enum_startmsg(void *closure, const void *hd) { + UPB_UNUSED(hd); upb_descreader *r = closure; upb_deflist_push(&r->defs, upb_upcast(upb_enumdef_new(&r->defs))); return true; } -static bool enum_endmsg(void *closure, upb_status *status) { +static bool enum_endmsg(void *closure, const void *hd, upb_status *status) { upb_descreader *r = closure; upb_enumdef *e = upb_downcast_enumdef_mutable(upb_descreader_last(r)); if (upb_def_fullname(upb_descreader_last(r)) == NULL) { @@ -310,13 +315,14 @@ static size_t enum_onname(void *closure, const void *hd, const char *buf, upb_descreader *r = closure; // XXX: see comment at the top of the file. char *fullname = upb_strndup(buf, n); - upb_def_setfullname(upb_descreader_last(r), fullname); + upb_def_setfullname(upb_descreader_last(r), fullname, NULL); free(fullname); return n; } // Handlers for google.protobuf.FieldDescriptorProto -static bool field_startmsg(void *closure) { +static bool field_startmsg(void *closure, const void *hd) { + UPB_UNUSED(hd); upb_descreader *r = closure; r->f = upb_fielddef_new(&r->defs); free(r->default_string); @@ -388,7 +394,8 @@ static bool parse_default(char *str, upb_value *d, int type) { return success; } -static bool field_endmsg(void *closure, upb_status *status) { +static bool field_endmsg(void *closure, const void *hd, upb_status *status) { + UPB_UNUSED(hd); upb_descreader *r = closure; upb_fielddef *f = r->f; // TODO: verify that all required fields were present. @@ -401,7 +408,7 @@ static bool field_endmsg(void *closure, upb_status *status) { return false; } if (upb_fielddef_isstring(f) || upb_fielddef_type(f) == UPB_TYPE_ENUM) { - upb_fielddef_setdefaultcstr(f, r->default_string); + upb_fielddef_setdefaultcstr(f, r->default_string, NULL); } else { upb_value val; upb_value_setptr(&val, NULL); // Silence inaccurate compiler warnings. @@ -434,7 +441,7 @@ static bool field_onlabel(void *closure, const void *hd, int32_t val) { static bool field_onnumber(void *closure, const void *hd, int32_t val) { UPB_UNUSED(hd); upb_descreader *r = closure; - upb_fielddef_setnumber(r->f, val); + upb_fielddef_setnumber(r->f, val, NULL); return true; } @@ -444,7 +451,7 @@ static size_t field_onname(void *closure, const void *hd, const char *buf, upb_descreader *r = closure; // XXX: see comment at the top of the file. char *name = upb_strndup(buf, n); - upb_fielddef_setname(r->f, name); + upb_fielddef_setname(r->f, name, NULL); free(name); return n; } @@ -455,7 +462,7 @@ static size_t field_ontypename(void *closure, const void *hd, const char *buf, upb_descreader *r = closure; // XXX: see comment at the top of the file. char *name = upb_strndup(buf, n); - upb_fielddef_setsubdefname(r->f, name); + upb_fielddef_setsubdefname(r->f, name, NULL); free(name); return n; } @@ -473,14 +480,16 @@ static size_t field_ondefaultval(void *closure, const void *hd, } // Handlers for google.protobuf.DescriptorProto (representing a message). -static bool msg_startmsg(void *closure) { +static bool msg_startmsg(void *closure, const void *hd) { + UPB_UNUSED(hd); upb_descreader *r = closure; upb_deflist_push(&r->defs, upb_upcast(upb_msgdef_new(&r->defs))); upb_descreader_startcontainer(r); return true; } -static bool msg_endmsg(void *closure, upb_status *status) { +static bool msg_endmsg(void *closure, const void *hd, upb_status *status) { + UPB_UNUSED(hd); upb_descreader *r = closure; upb_msgdef *m = upb_descreader_top(r); if(!upb_def_fullname(upb_upcast(m))) { @@ -498,7 +507,7 @@ static size_t msg_onname(void *closure, const void *hd, const char *buf, upb_msgdef *m = upb_descreader_top(r); // XXX: see comment at the top of the file. char *name = upb_strndup(buf, n); - upb_def_setfullname(upb_upcast(m), name); + upb_def_setfullname(upb_upcast(m), name, NULL); upb_descreader_setscopename(r, name); // Passes ownership of name. return n; } @@ -507,7 +516,7 @@ static bool msg_onendfield(void *closure, const void *hd) { UPB_UNUSED(hd); upb_descreader *r = closure; upb_msgdef *m = upb_descreader_top(r); - upb_msgdef_addfield(m, r->f, &r->defs); + upb_msgdef_addfield(m, r->f, &r->defs, NULL); r->f = NULL; return true; } @@ -521,42 +530,48 @@ static bool discardfield(void *closure, const void *hd) { return true; } +static const upb_fielddef *f(const upb_handlers *h, const char *name) { + const upb_fielddef *ret = upb_msgdef_ntof(upb_handlers_msgdef(h), name); + assert(ret); + return ret; +} + static void reghandlers(void *closure, upb_handlers *h) { UPB_UNUSED(closure); const upb_msgdef *m = upb_handlers_msgdef(h); if (m == GOOGLE_PROTOBUF_DESCRIPTORPROTO) { - upb_handlers_setstartmsg(h, &msg_startmsg); - upb_handlers_setendmsg(h, &msg_endmsg); - upb_handlers_setstring_n(h, "name", &msg_onname, NULL, NULL); - upb_handlers_setendsubmsg_n(h, "field", &msg_onendfield, NULL, NULL); + upb_handlers_setstartmsg(h, &msg_startmsg, NULL, NULL); + upb_handlers_setendmsg(h, &msg_endmsg, NULL, NULL); + upb_handlers_setstring(h, f(h, "name"), &msg_onname, NULL, NULL); + upb_handlers_setendsubmsg(h, f(h, "field"), &msg_onendfield, NULL, NULL); // TODO: support extensions - upb_handlers_setendsubmsg_n(h, "extension", &discardfield, NULL, NULL); + upb_handlers_setendsubmsg(h, f(h, "extension"), &discardfield, NULL, NULL); } else if (m == GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO) { - upb_handlers_setstartmsg(h, &file_startmsg); - upb_handlers_setendmsg(h, &file_endmsg); - upb_handlers_setstring_n(h, "package", &file_onpackage, NULL, NULL); + upb_handlers_setstartmsg(h, &file_startmsg, NULL, NULL); + upb_handlers_setendmsg(h, &file_endmsg, NULL, NULL); + upb_handlers_setstring(h, f(h, "package"), &file_onpackage, NULL, NULL); // TODO: support extensions - upb_handlers_setendsubmsg_n(h, "extension", &discardfield, NULL, NULL); + upb_handlers_setendsubmsg(h, f(h, "extension"), &discardfield, NULL, NULL); } else if (m == GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO) { - upb_handlers_setstartmsg(h, &enumval_startmsg); - upb_handlers_setendmsg(h, &enumval_endmsg); - upb_handlers_setstring_n(h, "name", &enumval_onname, NULL, NULL); - upb_handlers_setint32_n(h, "number", &enumval_onnumber, NULL, NULL); + upb_handlers_setstartmsg(h, &enumval_startmsg, NULL, NULL); + upb_handlers_setendmsg(h, &enumval_endmsg, NULL, NULL); + upb_handlers_setstring(h, f(h, "name"), &enumval_onname, NULL, NULL); + upb_handlers_setint32(h, f(h, "number"), &enumval_onnumber, NULL, NULL); } else if (m == GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO) { - upb_handlers_setstartmsg(h, &enum_startmsg); - upb_handlers_setendmsg(h, &enum_endmsg); - upb_handlers_setstring_n(h, "name", &enum_onname, NULL, NULL); + upb_handlers_setstartmsg(h, &enum_startmsg, NULL, NULL); + upb_handlers_setendmsg(h, &enum_endmsg, NULL, NULL); + upb_handlers_setstring(h, f(h, "name"), &enum_onname, NULL, NULL); } else if (m == GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO) { - upb_handlers_setstartmsg(h, &field_startmsg); - upb_handlers_setendmsg(h, &field_endmsg); - upb_handlers_setint32_n (h, "type", &field_ontype, NULL, NULL); - upb_handlers_setint32_n (h, "label", &field_onlabel, NULL, NULL); - upb_handlers_setint32_n (h, "number", &field_onnumber, NULL, NULL); - upb_handlers_setstring_n(h, "name", &field_onname, NULL, NULL); - upb_handlers_setstring_n(h, "type_name", &field_ontypename, NULL, NULL); - upb_handlers_setstring_n( - h, "default_value", &field_ondefaultval, NULL, NULL); + upb_handlers_setstartmsg(h, &field_startmsg, NULL, NULL); + upb_handlers_setendmsg(h, &field_endmsg, NULL, NULL); + upb_handlers_setint32 (h, f(h, "type"), &field_ontype, NULL, NULL); + upb_handlers_setint32 (h, f(h, "label"), &field_onlabel, NULL, NULL); + upb_handlers_setint32 (h, f(h, "number"), &field_onnumber, NULL, NULL); + upb_handlers_setstring(h, f(h, "name"), &field_onname, NULL, NULL); + upb_handlers_setstring(h, f(h, "type_name"), &field_ontypename, NULL, NULL); + upb_handlers_setstring(h, f(h, "default_value"), &field_ondefaultval, NULL, + NULL); } } diff --git a/upb/google/bridge.cc b/upb/google/bridge.cc index 93e5c27..97a91ea 100644 --- a/upb/google/bridge.cc +++ b/upb/google/bridge.cc @@ -122,15 +122,17 @@ FieldDef* AddFieldDef(const goog::Message& m, const goog::FieldDescriptor* f, #endif upb::FieldDef* upb_f = upb::FieldDef::New(&upb_f); - upb_f->set_number(f->number()); - upb_f->set_name(f->name()); - upb_f->set_label(static_cast<upb::FieldDef::Label>(f->label())); + upb::Status status; + upb_f->set_number(f->number(), &status); + upb_f->set_name(f->name(), &status); + upb_f->set_label(upb::FieldDef::ConvertLabel(f->label())); upb_f->set_descriptor_type( - weak_prototype ? UPB_DESCRIPTOR_TYPE_MESSAGE : - static_cast<upb::FieldDef::DescriptorType>(f->type())); + weak_prototype ? UPB_DESCRIPTOR_TYPE_MESSAGE + : upb::FieldDef::ConvertDescriptorType(f->type())); if (weak_prototype) { - upb_f->set_subdef_name(weak_prototype->GetDescriptor()->full_name()); + const string& name = weak_prototype->GetDescriptor()->full_name(); + upb_f->set_subdef_name(name, &status); } else { switch (upb_f->type()) { case UPB_TYPE_INT32: @@ -158,22 +160,22 @@ FieldDef* AddFieldDef(const goog::Message& m, const goog::FieldDescriptor* f, break; case UPB_TYPE_STRING: case UPB_TYPE_BYTES: - upb_f->set_default_string(f->default_value_string()); + upb_f->set_default_string(f->default_value_string(), &status); break; case UPB_TYPE_MESSAGE: - upb_f->set_subdef_name(f->message_type()->full_name()); + upb_f->set_subdef_name(f->message_type()->full_name(), &status); break; case UPB_TYPE_ENUM: // We set the enum default numerically. upb_f->set_default_value( MakeValue(static_cast<int32_t>(f->default_value_enum()->number()))); - upb_f->set_subdef_name(f->enum_type()->full_name()); + upb_f->set_subdef_name(f->enum_type()->full_name(), &status); break; } } - bool ok = md->AddField(upb_f, &upb_f); - UPB_ASSERT_VAR(ok, ok); + md->AddField(upb_f, &upb_f, &status); + UPB_ASSERT_STATUS(&status); if (weak_prototype) { *subm = weak_prototype; @@ -190,12 +192,14 @@ FieldDef* AddFieldDef(const goog::Message& m, const goog::FieldDescriptor* f, upb::EnumDef* NewEnumDef(const goog::EnumDescriptor* desc, const void* owner) { upb::EnumDef* e = upb::EnumDef::New(owner); - e->set_full_name(desc->full_name()); + upb::Status status; + e->set_full_name(desc->full_name(), &status); for (int i = 0; i < desc->value_count(); i++) { const goog::EnumValueDescriptor* val = desc->value(i); - bool success = e->AddValue(val->name(), val->number(), NULL); + bool success = e->AddValue(val->name(), val->number(), &status); UPB_ASSERT_VAR(success, success); } + UPB_ASSERT_STATUS(&status); return e; } @@ -203,7 +207,8 @@ static upb::MessageDef* NewMessageDef(const goog::Message& m, const void* owner, me::Defs* defs) { upb::MessageDef* md = upb::MessageDef::New(owner); const goog::Descriptor* d = m.GetDescriptor(); - md->set_full_name(m.GetDescriptor()->full_name()); + upb::Status status; + md->set_full_name(m.GetDescriptor()->full_name(), &status); // Must do this before processing submessages to prevent infinite recursion. defs->AddMessage(&m, md); @@ -237,8 +242,9 @@ static upb::MessageDef* NewMessageDef(const goog::Message& m, const void* owner, subdef = NewMessageDef(*subm_prototype, owner, defs)->Upcast(); } } - f->set_subdef(subdef); + f->set_subdef(subdef, &status); } + UPB_ASSERT_STATUS(&status); return md; } diff --git a/upb/handlers-inl.h b/upb/handlers-inl.h index 4a2800c..65f21a2 100644 --- a/upb/handlers-inl.h +++ b/upb/handlers-inl.h @@ -30,6 +30,50 @@ template <class T> Deleter<T> MatchDeleter(T* data) { // user's types. These also handle conversion between multiple types with // the same witdh; ie "long long" and "long" are both 64 bits on LP64. +// EndMessageHandler +template <class C> struct EndMessageHandlerWrapper2 { + template <bool F(C *, Status *)> + static bool Wrapper(void *closure, const void *hd, Status* s) { + UPB_UNUSED(hd); + return F(static_cast<C *>(closure), s); + } +}; + +template <class C, class D> struct EndMessageHandlerWrapper3 { + template <bool F(C *, const D *, Status*)> + inline static bool Wrapper(void *closure, const void *hd, Status* s) { + return F(static_cast<C *>(closure), static_cast<const D *>(hd), s); + } +}; + +template <class C> +inline EndMessageHandlerWrapper2<C> MatchWrapper(bool (*f)(C *, Status *)) { + UPB_UNUSED(f); + return EndMessageHandlerWrapper2<C>(); +} + +template <class C, class D> +inline EndMessageHandlerWrapper3<C, D> MatchWrapper(bool (*f)(C *, const D *, + Status *)) { + UPB_UNUSED(f); + return EndMessageHandlerWrapper3<C, D>(); +} + +inline Handlers::EndMessageHandler MakeHandler(bool (*wrapper)(void *, + const void *, + Status *)) { + return Handlers::EndMessageHandler::Make(wrapper, NULL, NULL); +} + +template <class C, class D> +inline Handlers::EndMessageHandler BindHandler( + bool (*wrapper)(void *, const void *, Status *), + bool (*h)(C *, const D *, Status *), D *data) { + UPB_UNUSED(h); // Only for making sure function matches "D". + return Handlers::EndMessageHandler::Make(wrapper, data, + MatchDeleter(data).Delete); +} + // ValueHandler template <class C, class T1, class T2 = typename CanonicalType<T1>::Type> struct ValueHandlerWrapper2 { @@ -63,18 +107,18 @@ inline ValueHandlerWrapper3<C, D, T> MatchWrapper(bool (*f)(C *, const D *, } template <class T> -inline typename ValueHandler<T>::H MakeHandler(bool (*wrapper)(void *, - const void *, - T)) { - return ValueHandler<T>::H::Make(wrapper, NULL, NULL); +inline typename Handlers::ValueHandler<T>::H MakeHandler( + bool (*wrapper)(void *, const void *, T)) { + return Handlers::ValueHandler<T>::H::Make(wrapper, NULL, NULL); } template <class C, class D, class T1, class T2> -inline typename ValueHandler<T1>::H BindHandler( +inline typename Handlers::ValueHandler<T1>::H BindHandler( bool (*wrapper)(void *, const void *, T1), bool (*h)(C *, const D *, T2), D *data) { UPB_UNUSED(h); // Only for making sure function matches "D". - return ValueHandler<T1>::H::Make(wrapper, data, MatchDeleter(data).Delete); + return Handlers::ValueHandler<T1>::H::Make(wrapper, data, + MatchDeleter(data).Delete); } // StartFieldHandler @@ -105,15 +149,17 @@ inline StartFieldHandlerWrapper3<R, C, D> MatchWrapper(R *(*f)(C *, return StartFieldHandlerWrapper3<R, C, D>(); } -inline StartFieldHandler MakeHandler(void *(*wrapper)(void *, const void *)) { - return StartFieldHandler::Make(wrapper, NULL, NULL); +inline Handlers::StartFieldHandler MakeHandler(void *(*wrapper)(void *, + const void *)) { + return Handlers::StartFieldHandler::Make(wrapper, NULL, NULL); } template <class R, class C, class D> -inline StartFieldHandler BindHandler(void *(*wrapper)(void *, const void *), - R *(*h)(C *, const D *), D *data) { +inline Handlers::StartFieldHandler BindHandler( + void *(*wrapper)(void *, const void *), R *(*h)(C *, const D *), D *data) { UPB_UNUSED(h); // Only for making sure function matches "D". - return StartFieldHandler::Make(wrapper, data, MatchDeleter(data).Delete); + return Handlers::StartFieldHandler::Make(wrapper, data, + MatchDeleter(data).Delete); } // EndFieldHandler @@ -144,15 +190,17 @@ inline EndFieldHandlerWrapper3<C, D> MatchWrapper(bool (*f)(C *, const D *)) { return EndFieldHandlerWrapper3<C, D>(); } -inline EndFieldHandler MakeHandler(bool (*wrapper)(void *, const void *)) { - return EndFieldHandler::Make(wrapper, NULL, NULL); +inline Handlers::EndFieldHandler MakeHandler(bool (*wrapper)(void *, + const void *)) { + return Handlers::EndFieldHandler::Make(wrapper, NULL, NULL); } template <class C, class D> -inline EndFieldHandler BindHandler(bool (*wrapper)(void *, const void *), - bool (*h)(C *, const D *), D *data) { +inline Handlers::EndFieldHandler BindHandler( + bool (*wrapper)(void *, const void *), bool (*h)(C *, const D *), D *data) { UPB_UNUSED(h); // Only for making sure function matches "D". - return EndFieldHandler::Make(wrapper, data, MatchDeleter(data).Delete); + return Handlers::EndFieldHandler::Make(wrapper, data, + MatchDeleter(data).Delete); } // StartStringHandler @@ -184,18 +232,19 @@ inline StartStringHandlerWrapper3<R, C, D> MatchWrapper(R *(*f)(C *, const D *, return StartStringHandlerWrapper3<R, C, D>(); } -inline StartStringHandler MakeHandler(void *(*wrapper)(void *, const void *, - size_t)) { - return StartStringHandler::Make(wrapper, NULL, NULL); +inline Handlers::StartStringHandler MakeHandler(void *(*wrapper)(void *, + const void *, + size_t)) { + return Handlers::StartStringHandler::Make(wrapper, NULL, NULL); } template <class R, class C, class D> -inline StartStringHandler BindHandler(void *(*wrapper)(void *, const void *, - size_t), - R *(*h)(C *, const D *, size_t), - D *data) { +inline Handlers::StartStringHandler BindHandler( + void *(*wrapper)(void *, const void *, size_t), + R *(*h)(C *, const D *, size_t), D *data) { UPB_UNUSED(h); // Only for making sure function matches "D". - return StartStringHandler::Make(wrapper, data, MatchDeleter(data).Delete); + return Handlers::StartStringHandler::Make(wrapper, data, + MatchDeleter(data).Delete); } // StringHandler @@ -231,17 +280,18 @@ inline StringHandlerWrapper3<C, D> MatchWrapper(size_t (*f)(C *, const D *, return StringHandlerWrapper3<C, D>(); } -inline StringHandler MakeHandler(size_t (*wrapper)(void *, const void *, - const char *, size_t)) { - return StringHandler::Make(wrapper, NULL, NULL); +inline Handlers::StringHandler MakeHandler( + size_t (*wrapper)(void *, const void *, const char *, size_t)) { + return Handlers::StringHandler::Make(wrapper, NULL, NULL); } template <class C, class D> -inline StringHandler BindHandler( +inline Handlers::StringHandler BindHandler( size_t (*wrapper)(void *, const void *, const char *, size_t), size_t (*h)(C *, const D *, const char *, size_t), D *data) { UPB_UNUSED(h); // Only for making sure function matches "D". - return StringHandler::Make(wrapper, data, MatchDeleter(data).Delete); + return Handlers::StringHandler::Make(wrapper, data, + MatchDeleter(data).Delete); } // utype/ltype are upper/lower-case, ctype is canonical C type, vtype is @@ -259,14 +309,6 @@ inline StringHandler BindHandler( return upb_handlers_set##ltype(this, f, handler.handler_, handler.data_, \ handler.cleanup_); \ } \ - template <> \ - inline bool Handlers::SetValueHandler<vtype>( \ - const char *f, const typename ValueHandler< \ - typename CanonicalType<vtype>::Type>::H &handler) { \ - handler.registered_ = true; \ - return upb_handlers_set##ltype##_n(this, f, handler.handler_, \ - handler.data_, handler.cleanup_); \ - } TYPE_METHODS(Double, double, double, double); TYPE_METHODS(Float, float, float, float); @@ -294,10 +336,6 @@ TYPE_METHODS(UInt64, uint64, uint64_t, upb_uint64alt_t); const utype##Handler &h) { \ return SetValueHandler<ctype>(f, h); \ } \ - inline bool Handlers::Set##utype##Handler(const char *f, \ - const utype##Handler &h) { \ - return SetValueHandler<ctype>(f, h); \ - } TYPE_METHODS(Double, double); TYPE_METHODS(Float, float); @@ -339,6 +377,12 @@ inline void Handlers::DonateRef(const void *from, const void *to) const { inline void Handlers::CheckRef(const void *owner) const { upb_handlers_checkref(this, owner); } +inline const Status* Handlers::status() { + return upb_handlers_status(this); +} +inline void Handlers::ClearError() { + return upb_handlers_clearerr(this); +} inline bool Handlers::Freeze(Handlers *const *handlers, int n, Status *s) { return upb_handlers_freeze(handlers, n, s); } @@ -348,12 +392,17 @@ inline const FrameType *Handlers::frame_type() const { inline const MessageDef *Handlers::message_def() const { return upb_handlers_msgdef(this); } -template <class T, bool F(T *)> void Handlers::SetStartMessageHandler() { - upb_handlers_setstartmsg(this, &Wrapper1<T, F>); +inline bool Handlers::SetStartMessageHandler( + const Handlers::StartMessageHandler &handler) { + handler.registered_ = true; + return upb_handlers_setstartmsg(this, handler.handler_, handler.data_, + handler.cleanup_); } -template <class T, bool F(T *, upb::Status *)> -void Handlers::SetEndMessageHandler() { - upb_handlers_setendmsg(this, &EndMessageWrapper<T, F>); +inline bool Handlers::SetEndMessageHandler( + const Handlers::EndMessageHandler &handler) { + handler.registered_ = true; + return upb_handlers_setendmsg(this, handler.handler_, handler.data_, + handler.cleanup_); } inline bool Handlers::SetStartStringHandler(const FieldDef *f, const StartStringHandler &handler) { @@ -400,48 +449,6 @@ inline bool Handlers::SetEndSequenceHandler(const FieldDef *f, inline bool Handlers::SetSubHandlers(const FieldDef *f, const Handlers *sub) { return upb_handlers_setsubhandlers(this, f, sub); } -inline bool Handlers::SetStartStringHandler(const char *name, - const StartStringHandler &handler) { - handler.registered_ = true; - return upb_handlers_setstartstr_n(this, name, handler.handler_, handler.data_, - handler.cleanup_); -} -inline bool Handlers::SetEndStringHandler(const char *name, - const EndFieldHandler &handler) { - handler.registered_ = true; - return upb_handlers_setendstr_n(this, name, handler.handler_, handler.data_, - handler.cleanup_); -} -inline bool Handlers::SetStringHandler(const char *name, - const StringHandler &handler) { - handler.registered_ = true; - return upb_handlers_setstring_n(this, name, handler.handler_, handler.data_, - handler.cleanup_); -} -inline bool Handlers::SetStartSequenceHandler( - const char *name, const StartFieldHandler &handler) { - handler.registered_ = true; - return upb_handlers_setstartseq_n(this, name, handler.handler_, handler.data_, - handler.cleanup_); -} -inline bool Handlers::SetStartSubMessageHandler( - const char *name, const StartFieldHandler &handler) { - handler.registered_ = true; - return upb_handlers_setstartsubmsg_n(this, name, handler.handler_, - handler.data_, handler.cleanup_); -} -inline bool Handlers::SetEndSubMessageHandler(const char *name, - const EndFieldHandler &handler) { - handler.registered_ = true; - return upb_handlers_setendsubmsg_n(this, name, handler.handler_, - handler.data_, handler.cleanup_); -} -inline bool Handlers::SetEndSequenceHandler(const char *name, - const EndFieldHandler &handler) { - handler.registered_ = true; - return upb_handlers_setendseq_n(this, name, handler.handler_, handler.data_, - handler.cleanup_); -} inline const Handlers *Handlers::GetSubHandlers(const FieldDef *f) const { return upb_handlers_getsubhandlers(this, f); } diff --git a/upb/handlers.c b/upb/handlers.c index 6cbe6dc..5adaee5 100644 --- a/upb/handlers.c +++ b/upb/handlers.c @@ -30,6 +30,10 @@ static void freehandlers(upb_refcounted *r) { for (size_t i = 0; i < h->cleanup_len; i++) { h->cleanup[i].cleanup(h->cleanup[i].ptr); } + if (h->status_) { + upb_status_uninit(h->status_); + free(h->status_); + } free(h->cleanup); free(h); } @@ -93,13 +97,23 @@ oom: // non-repeated submessage fields). Can change later if necessary. #define SUBH(h, field_base) h->table[field_base + 2].data -static int32_t chkset(upb_handlers *h, const upb_fielddef *f, +static int32_t getsel(upb_handlers *h, const upb_fielddef *f, upb_handlertype_t type) { upb_selector_t sel; assert(!upb_handlers_isfrozen(h)); - if (upb_handlers_msgdef(h) != upb_fielddef_msgdef(f)) return -1; - if (!upb_handlers_getselector(f, type, &sel)) return -1; - if (h->table[sel].func) return -1; + if (upb_handlers_msgdef(h) != upb_fielddef_msgdef(f)) { + upb_status_seterrf( + h->status_, "type mismatch: field %s does not belong to message %s", + upb_fielddef_name(f), upb_msgdef_fullname(upb_handlers_msgdef(h))); + return -1; + } + if (!upb_handlers_getselector(f, type, &sel)) { + upb_status_seterrf( + h->status_, + "type mismatch: cannot register handler type %d for field %s", + type, upb_fielddef_name(f)); + return -1; + } return sel; } @@ -110,6 +124,7 @@ static bool addcleanup(upb_handlers *h, void *ptr, void (*cleanup)(void*)) { if (!resized) { h->cleanup_size = h->cleanup_len; cleanup(ptr); + upb_status_seterrliteral(h->status_, "out of memory"); return false; } h->cleanup = resized; @@ -120,6 +135,20 @@ static bool addcleanup(upb_handlers *h, void *ptr, void (*cleanup)(void*)) { return true; } +static bool doset(upb_handlers *h, upb_selector_t sel, upb_func *func, + void *data, upb_handlerfree *cleanup) { + assert(!upb_handlers_isfrozen(h)); + if (h->table[sel].func) { + upb_status_seterrliteral(h->status_, + "cannot change handler once it has been set."); + return false; + } + if (cleanup && !addcleanup(h, data, cleanup)) return false; + h->table[sel].func = (upb_func*)func; + h->table[sel].data = data; + return true; +} + /* Public interface ***********************************************************/ @@ -149,10 +178,14 @@ upb_handlers *upb_handlers_new(const upb_msgdef *md, const upb_frametype *ft, const void *owner) { assert(upb_msgdef_isfrozen(md)); - int extra = sizeof(upb_handlers_tabent) * (md->selector_count - 1); + int extra = sizeof(upb_handlers_tabent) * (md->selector_count - 1 + 100); upb_handlers *h = calloc(sizeof(*h) + extra, 1); if (!h) return NULL; + h->status_ = malloc(sizeof(*h->status_)); + if (!h->status_) goto oom; + upb_status_init(h->status_); + h->msg = md; h->ft = ft; h->cleanup = NULL; @@ -191,15 +224,22 @@ const upb_handlers *upb_handlers_newfrozen(const upb_msgdef *m, return ret; } +const upb_status *upb_handlers_status(upb_handlers *h) { + assert(!upb_handlers_isfrozen(h)); + return h->status_; +} + +void upb_handlers_clearerr(upb_handlers *h) { + assert(!upb_handlers_isfrozen(h)); + upb_status_clear(h->status_); +} + #define SETTER(name, handlerctype, handlertype) \ bool upb_handlers_set ## name(upb_handlers *h, const upb_fielddef *f, \ handlerctype func, void *data, \ upb_handlerfree *cleanup) { \ - int32_t sel = chkset(h, f, handlertype); \ - if (sel < 0 || (cleanup && !addcleanup(h, data, cleanup))) return false; \ - h->table[sel].func = (upb_func*)func; \ - h->table[sel].data = data; \ - return true; \ + int32_t sel = getsel(h, f, handlertype); \ + return sel >= 0 && doset(h, sel, (upb_func*)func, data, cleanup); \ } SETTER(int32, upb_int32_handler*, UPB_HANDLER_INT32); @@ -219,6 +259,17 @@ SETTER(endseq, upb_endfield_handler*, UPB_HANDLER_ENDSEQ); #undef SETTER +bool upb_handlers_setstartmsg(upb_handlers *h, upb_startmsg_handler *handler, + void *d, upb_handlerfree *cleanup) { + return doset(h, UPB_STARTMSG_SELECTOR, (upb_func*)handler, d, cleanup); +} + +bool upb_handlers_setendmsg(upb_handlers *h, upb_endmsg_handler *handler, + void *d, upb_handlerfree *cleanup) { + assert(!upb_handlers_isfrozen(h)); + return doset(h, UPB_ENDMSG_SELECTOR, (upb_func*)handler, d, cleanup); +} + bool upb_handlers_setsubhandlers(upb_handlers *h, const upb_fielddef *f, const upb_handlers *sub) { assert(sub); @@ -251,24 +302,6 @@ const upb_frametype *upb_handlers_frametype(const upb_handlers *h) { return h->ft; } -void upb_handlers_setstartmsg(upb_handlers *h, upb_startmsg_handler *handler) { - assert(!upb_handlers_isfrozen(h)); - h->startmsg = handler; -} - -upb_startmsg_handler *upb_handlers_getstartmsg(const upb_handlers *h) { - return h->startmsg; -} - -void upb_handlers_setendmsg(upb_handlers *h, upb_endmsg_handler *handler) { - assert(!upb_handlers_isfrozen(h)); - h->endmsg = handler; -} - -upb_endmsg_handler *upb_handlers_getendmsg(const upb_handlers *h) { - return h->endmsg; -} - upb_func *upb_handlers_gethandler(const upb_handlers *h, upb_selector_t s) { return (upb_func *)h->table[s].func; } @@ -282,7 +315,25 @@ const void *upb_handlers_gethandlerdata(const upb_handlers *h, bool upb_handlers_freeze(upb_handlers *const*handlers, int n, upb_status *s) { // TODO: verify we have a transitive closure. - return upb_refcounted_freeze((upb_refcounted*const*)handlers, n, s); + for (int i = 0; i < n; i++) { + if (!upb_ok(handlers[i]->status_)) { + upb_status_seterrf(s, "handlers for message %s had error status: %s", + upb_msgdef_fullname(upb_handlers_msgdef(handlers[i])), + upb_status_getstr(handlers[i]->status_)); + return false; + } + } + + if (!upb_refcounted_freeze((upb_refcounted*const*)handlers, n, s)) { + return false; + } + + for (int i = 0; i < n; i++) { + upb_status_uninit(handlers[i]->status_); + free(handlers[i]->status_); + handlers[i]->status_ = NULL; + } + return true; } upb_handlertype_t upb_handlers_getprimitivehandlertype(const upb_fielddef *f) { diff --git a/upb/handlers.h b/upb/handlers.h index 09743ff..a80e401 100644 --- a/upb/handlers.h +++ b/upb/handlers.h @@ -25,49 +25,25 @@ #include "upb/def.h" #ifdef __cplusplus - struct upb_frametype; namespace upb { - typedef upb_frametype FrameType; class Handlers; - template <class T> class Handler; -typedef Handler<void *(*)(void *, const void *)> StartFieldHandler; -typedef Handler<bool(*)(void *, const void *)> EndFieldHandler; -typedef Handler<void *(*)(void *, const void *, size_t)> StartStringHandler; -typedef Handler<size_t(*)(void *, const void *, const char *, size_t)> - StringHandler; - -template <class T> struct ValueHandler { - typedef Handler<bool(*)(void *, const void *, T)> H; -}; - -typedef ValueHandler<upb_int32_t>::H Int32Handler; -typedef ValueHandler<upb_int64_t>::H Int64Handler; -typedef ValueHandler<upb_uint32_t>::H UInt32Handler; -typedef ValueHandler<upb_uint64_t>::H UInt64Handler; -typedef ValueHandler<float>::H FloatHandler; -typedef ValueHandler<double>::H DoubleHandler; -typedef ValueHandler<bool>::H BoolHandler; template <class T> struct CanonicalType; - } // namespace upb typedef upb::FrameType upb_frametype; typedef upb::Handlers upb_handlers; - -#else // #ifdef __cplusplus - +#else struct upb_frametype; struct upb_handlers; struct upb_sinkframe; typedef struct upb_frametype upb_frametype; typedef struct upb_handlers upb_handlers; typedef struct upb_sinkframe upb_sinkframe; - -#endif // #ifdef __cplusplus +#endif typedef struct { void (*func)(); @@ -105,6 +81,11 @@ extern char _upb_noclosure; // (for example: the STARTSUBMSG handler for field "field15"). typedef int32_t upb_selector_t; +// Message-level callbacks have static selectors. +#define UPB_STARTMSG_SELECTOR 0 +#define UPB_ENDMSG_SELECTOR 1 +#define UPB_STATIC_SELECTOR_COUNT 2 + #ifdef __cplusplus // A upb::Handlers object represents the set of handlers associated with a @@ -123,6 +104,26 @@ class upb::Handlers { typedef upb_selector_t Selector; typedef upb_handlertype_t Type; + typedef Handler<void *(*)(void *, const void *)> StartFieldHandler; + typedef Handler<bool (*)(void *, const void *)> EndFieldHandler; + typedef Handler<bool (*)(void *, const void *)> StartMessageHandler; + typedef Handler<bool (*)(void *, const void *, Status*)> EndMessageHandler; + typedef Handler<void *(*)(void *, const void *, size_t)> StartStringHandler; + typedef Handler<size_t(*)(void *, const void *, const char *, size_t)> + StringHandler; + + template <class T> struct ValueHandler { + typedef Handler<bool(*)(void *, const void *, T)> H; + }; + + typedef ValueHandler<upb_int32_t>::H Int32Handler; + typedef ValueHandler<upb_int64_t>::H Int64Handler; + typedef ValueHandler<upb_uint32_t>::H UInt32Handler; + typedef ValueHandler<upb_uint64_t>::H UInt64Handler; + typedef ValueHandler<float>::H FloatHandler; + typedef ValueHandler<double>::H DoubleHandler; + typedef ValueHandler<bool>::H BoolHandler; + // Any function pointer can be converted to this and converted back to its // correct type. typedef void GenericFunction(); @@ -155,6 +156,14 @@ class upb::Handlers { void DonateRef(const void *from, const void *to) const; void CheckRef(const void *owner) const; + // All handler registration functions return bool to indicate success or + // failure; details about failures are stored in this status object. If a + // failure does occur, it must be cleared before the Handlers are frozen, + // otherwise the freeze() operation will fail. The functions may *only* be + // used while the Handlers are mutable. + const Status* status(); + void ClearError(); + // Top-level frame type. const FrameType* frame_type() const; @@ -174,10 +183,7 @@ class upb::Handlers { // // continue. // return true; // } - // - // TODO(haberman): change this to work with UpbMakeHandler and auto-deduce, - // like all of the field handlers. - template<class T, bool F(T*)> void SetStartMessageHandler(); + bool SetStartMessageHandler(const StartMessageHandler& handler); // Sets the endmsg handler for the message, which is defined as follows: // @@ -186,10 +192,7 @@ class upb::Handlers { // // failure. "status" indicates the final status of processing, and // // can also be modified in-place to update the final status. // } - // - // TODO(haberman): change this to work with UpbMakeHandler and auto-deduce, - // like all of the field handlers. - template<class T, bool F(T*, upb::Status*)> void SetEndMessageHandler(); + bool SetEndMessageHandler(const EndMessageHandler& handler); // Sets the value handler for the given field, which is defined as follows // (this is for an int32 field; other field types will pass their native @@ -218,17 +221,6 @@ class upb::Handlers { bool SetDoubleHandler(const FieldDef* f, const DoubleHandler& h); bool SetBoolHandler (const FieldDef* f, const BoolHandler& h); - // Convenience versions that look up the field by name first. These return - // false if no field with this name exists, or for any of the other reasons - // that the FieldDef* version returns false. - bool SetInt32Handler (const char *name, const Int32Handler& h); - bool SetInt64Handler (const char *name, const Int64Handler& h); - bool SetUInt32Handler(const char *name, const UInt32Handler& h); - bool SetUInt64Handler(const char *name, const UInt64Handler& h); - bool SetFloatHandler (const char *name, const FloatHandler& h); - bool SetDoubleHandler(const char *name, const DoubleHandler& h); - bool SetBoolHandler (const char *name, const BoolHandler& h); - // Like the previous, but templated on the type on the value (ie. int32). // This is mostly useful to call from other templates. To call this you must // specify the template parameter explicitly, ie: @@ -237,10 +229,6 @@ class upb::Handlers { bool SetValueHandler( const FieldDef *f, const typename ValueHandler<typename CanonicalType<T>::Type>::H& handler); - template <class T> - bool SetValueHandler( - const char *name, - const typename ValueHandler<typename CanonicalType<T>::Type>::H& handler); // Sets handlers for a string field, which are defined as follows: // @@ -281,13 +269,6 @@ class upb::Handlers { bool SetStringHandler(const FieldDef* f, const StringHandler& h); bool SetEndStringHandler(const FieldDef* f, const EndFieldHandler& h); - // Convenience versions that look up the field by name first. These return - // false if no field with this name exists, or for any of the other reasons - // that the FieldDef* version returns false. - bool SetStartStringHandler(const char* name, const StartStringHandler& h); - bool SetStringHandler(const char* name, const StringHandler& h); - bool SetEndStringHandler(const char* name, const EndFieldHandler& h); - // Sets the startseq handler, which is defined as follows: // // MySubClosure *startseq(MyClosure* c, const MyHandlerData* d) { @@ -302,7 +283,6 @@ class upb::Handlers { // Returns "false" if "f" does not belong to this message or is not a // repeated field. bool SetStartSequenceHandler(const FieldDef* f, const StartFieldHandler& h); - bool SetStartSequenceHandler(const char* name, const StartFieldHandler& h); // Sets the startsubmsg handler for the given field, which is defined as // follows: @@ -319,7 +299,6 @@ class upb::Handlers { // Returns "false" if "f" does not belong to this message or is not a // submessage/group field. bool SetStartSubMessageHandler(const FieldDef* f, const StartFieldHandler& h); - bool SetStartSubMessageHandler(const char* name, const StartFieldHandler& h); // Sets the endsubmsg handler for the given field, which is defined as // follows: @@ -332,7 +311,6 @@ class upb::Handlers { // Returns "false" if "f" does not belong to this message or is not a // submessage/group field. bool SetEndSubMessageHandler(const FieldDef *f, const EndFieldHandler &h); - bool SetEndSubMessageHandler(const char *name, const EndFieldHandler &h); // Starts the endsubseq handler for the given field, which is defined as // follows: @@ -345,7 +323,6 @@ class upb::Handlers { // Returns "false" if "f" does not belong to this message or is not a // repeated field. bool SetEndSequenceHandler(const FieldDef* f, const EndFieldHandler& h); - bool SetEndSequenceHandler(const char* name, const EndFieldHandler& h); // Sets or gets the object that specifies handlers for the given field, which // must be a submessage or group. Returns NULL if no handlers are set. @@ -389,8 +366,7 @@ struct upb_handlers { upb_refcounted base; const upb_msgdef *msg; const upb_frametype *ft; - bool (*startmsg)(void*); - bool (*endmsg)(void*, upb_status*); + upb_status *status_; // Used only when mutable. struct { void *ptr; void (*cleanup)(void*); @@ -458,25 +434,37 @@ namespace upb { upb::BindHandler(upb::MatchWrapper(f).template Wrapper<f>, f, (d)) -// FieldHandler: a struct that contains the (handler, data, deleter) tuple that -// is used by all field-level handlers. Users could Make() these directly but -// it's more convenient to use the Upb{Bind,Make}ValueHandler macros. -// -// This class is intentionally not copyable or assignable; it can only be -// constructed as a temporary object with Make() and then must be registered as -// a handler (this is enforced with the assert() in the destructor). +// Handler: a struct that contains the (handler, data, deleter) tuple that is +// used to register all handlers. Users can Make() these directly but it's +// more convenient to use the UpbMakeHandler/UpbBind macros above. template <class T> class Handler { public: - // The underlying, non-type-safe handler function signature that upb uses - // internally. + // The underlying, handler function signature that upb uses internally. typedef T FuncPtr; - ~Handler() { assert(registered_); } - + // Creates a Handler object with the given function, data, and cleanup func. + // + // This is like a constructor but we don't want to expose the actual + // constructor publicly because letting users construct them leads to hairy + // ownership issues: + // + // Int32Handler handler(MyFunc, new MyData, MyCleanup); + // + // // What should happen to ownership of MyData? + // handlers->SetInt32Handler(f, handler); + // handlers2->SetInt32Handler(f, handler); + // + // To avoid this ownership question we prevent the Handler objects from + // being constructed, copied, or assigned. They are only available as the + // return value of this Make() function, and they must be registered exactly + // once before the temporary object is destroyed. This allows the Handler + // object to be the *unique* owner of the passed-in data. static Handler<T> Make(FuncPtr h, void* hd, void (*fr)(void*)) { return Handler<T>(h, hd, fr); } + ~Handler() { assert(registered_); } + private: friend class Handlers; @@ -494,44 +482,50 @@ template <class T> class Handler { // two for each type of handler. They need to be friends so that // they can call the copy constructor to return a temporary. + friend Handlers::EndMessageHandler MakeHandler( + bool (*wrapper)(void *, const void *, Status *)); + template <class T1> - friend typename ValueHandler<T1>::H MakeHandler(bool (*wrapper)(void *, - const void *, - T1)); + friend typename Handlers::ValueHandler<T1>::H MakeHandler( + bool (*wrapper)(void *, const void *, T1)); template <class C, class D, class T1, class T2> - friend typename ValueHandler<T1>::H BindHandler( + friend typename Handlers::ValueHandler<T1>::H BindHandler( bool (*wrapper)(void *, const void *, T1), bool (*h)(C *, const D *, T2), D *data); - friend StartFieldHandler MakeHandler(void* (*wrapper)(void *, const void *)); + friend Handlers::StartFieldHandler MakeHandler( + void *(*wrapper)(void *, const void *)); template <class R, class C, class D> - friend StartFieldHandler BindHandler(void *(*wrapper)(void *, const void *), - R *(*h)(C *, const D *), D *data); + friend Handlers::StartFieldHandler BindHandler( + void *(*wrapper)(void *, const void *), R *(*h)(C *, const D *), D *data); - friend EndFieldHandler MakeHandler(bool (*wrapper)(void *, const void *)); + friend Handlers::EndFieldHandler MakeHandler(bool (*wrapper)(void *, + const void *)); template <class C, class D> - friend EndFieldHandler BindHandler(bool (*wrapper)(void *, const void *), - bool (*h)(C *, const D *), D *data); + friend Handlers::EndFieldHandler BindHandler(bool (*wrapper)(void *, + const void *), + bool (*h)(C *, const D *), + D *data); - friend StringHandler MakeHandler(size_t (*wrapper)(void *, const void *, - const char *, size_t)); + friend Handlers::StringHandler MakeHandler( + size_t (*wrapper)(void *, const void *, const char *, size_t)); template <class C, class D> - friend StringHandler BindHandler( + friend Handlers::StringHandler BindHandler( size_t (*wrapper)(void *, const void *, const char *, size_t), size_t (*h)(C *, const D *, const char *, size_t), D *data); - friend StartStringHandler MakeHandler(void *(*wrapper)(void *, const void *, - size_t)); + friend Handlers::StartStringHandler MakeHandler(void *(*wrapper)(void *, + const void *, + size_t)); template <class R, class C, class D> - friend StartStringHandler BindHandler(void *(*wrapper)(void *, const void *, - size_t), - R *(*h)(C *, const D *, size_t), - D *data); + friend Handlers::StartStringHandler BindHandler( + void *(*wrapper)(void *, const void *, size_t), + R *(*h)(C *, const D *, size_t), D *data); }; } // namespace upb @@ -544,8 +538,8 @@ typedef void upb_handlers_callback(void *closure, upb_handlers *h); typedef void upb_handlerfree(void *d); typedef void upb_func(); -typedef bool upb_startmsg_handler(void *c); -typedef bool upb_endmsg_handler(void *c, upb_status *status); +typedef bool upb_startmsg_handler(void *c, const void*); +typedef bool upb_endmsg_handler(void *c, const void *, upb_status *status); typedef void* upb_startfield_handler(void *c, const void *hd); typedef bool upb_endfield_handler(void *c, const void *hd); typedef bool upb_int32_handler(void *c, const void *hd, int32_t val); @@ -576,12 +570,14 @@ void upb_handlers_donateref(const upb_handlers *h, const void *from, const void *to); void upb_handlers_checkref(const upb_handlers *h, const void *owner); +const upb_status *upb_handlers_status(upb_handlers *h); +void upb_handlers_clearerr(upb_handlers *h); const upb_msgdef *upb_handlers_msgdef(const upb_handlers *h); const upb_frametype *upb_handlers_frametype(const upb_handlers *h); -void upb_handlers_setstartmsg(upb_handlers *h, upb_startmsg_handler *handler); -upb_startmsg_handler *upb_handlers_getstartmsg(const upb_handlers *h); -void upb_handlers_setendmsg(upb_handlers *h, upb_endmsg_handler *handler); -upb_endmsg_handler *upb_handlers_getendmsg(const upb_handlers *h); +bool upb_handlers_setstartmsg(upb_handlers *h, upb_startmsg_handler *handler, + void *d, upb_handlerfree *fr); +bool upb_handlers_setendmsg(upb_handlers *h, upb_endmsg_handler *handler, + void *d, upb_handlerfree *fr); bool upb_handlers_setint32(upb_handlers *h, const upb_fielddef *f, upb_int32_handler *handler, void *d, upb_handlerfree *fr); @@ -650,32 +646,6 @@ uint32_t upb_handlers_selectorcount(const upb_fielddef *f); } // extern "C" #endif -// Convenience versions of the above that first look up the field by name. -#define DEFINE_NAME_SETTER(slot, type) \ - UPB_INLINE bool upb_handlers_set ## slot ## _n( \ - upb_handlers *h, const char *name, type val, \ - void *d, upb_handlerfree *fr) { \ - const upb_fielddef *f = upb_msgdef_ntof(upb_handlers_msgdef(h), name); \ - if (!f) return false; \ - return upb_handlers_set ## slot(h, f, val, d, fr); \ - } -DEFINE_NAME_SETTER(int32, upb_int32_handler*); -DEFINE_NAME_SETTER(int64, upb_int64_handler*); -DEFINE_NAME_SETTER(uint32, upb_uint32_handler*); -DEFINE_NAME_SETTER(uint64, upb_uint64_handler*); -DEFINE_NAME_SETTER(float, upb_float_handler*); -DEFINE_NAME_SETTER(double, upb_double_handler*); -DEFINE_NAME_SETTER(bool, upb_bool_handler*); -DEFINE_NAME_SETTER(startstr, upb_startstr_handler*); -DEFINE_NAME_SETTER(string, upb_string_handler*); -DEFINE_NAME_SETTER(endstr, upb_endfield_handler*); -DEFINE_NAME_SETTER(startseq, upb_startfield_handler*); -DEFINE_NAME_SETTER(startsubmsg, upb_startfield_handler*); -DEFINE_NAME_SETTER(endsubmsg, upb_endfield_handler*); -DEFINE_NAME_SETTER(endseq, upb_endfield_handler*); - -#undef DEFINE_NAME_SETTER - #include "upb/handlers-inl.h" #endif // UPB_HANDLERS_H diff --git a/upb/pb/decoder_x64.dasc b/upb/pb/decoder_x64.dasc index 154fee3..dee063a 100644 --- a/upb/pb/decoder_x64.dasc +++ b/upb/pb/decoder_x64.dasc @@ -192,9 +192,9 @@ static void upb_assert_notnull(void *addr) { assert(addr != NULL); (void)addr; } || } |.endmacro | -|.macro load_handler_data, h, f, type +|.macro loadarg2, val ||{ -|| uintptr_t data = (uintptr_t)gethandlerdata(h, f, type); +|| uintptr_t data = (uintptr_t)val; || if (data > 0xffffffff) { | mov64 ARG2_64, data || } else if (data) { @@ -205,6 +205,10 @@ static void upb_assert_notnull(void *addr) { assert(addr != NULL); (void)addr; } || } |.endmacro | +|.macro load_handler_data, h, f, type +| loadarg2 gethandlerdata(h, f, type) +|.endmacro +| |// Checkpoints our progress by writing PTR to DECODER, and |// checks for end-of-buffer. |.macro checkpoint, h @@ -768,10 +772,11 @@ static void upb_decoderplan_jit_msg(decoderplan *plan, | mov rbp, rsp // Call startmsg handler (if any): - upb_startmsg_handler *startmsg = upb_handlers_getstartmsg(h); + upb_func *startmsg = upb_handlers_gethandler(h, UPB_STARTMSG_SELECTOR); if (startmsg) { - // upb_flow_t startmsg(void *closure); + // upb_flow_t startmsg(void *closure, const void *hd); | mov ARG1_64, CLOSURE + | loadarg2 upb_handlers_gethandlerdata(h, UPB_STARTMSG_SELECTOR) | callp startmsg | check_bool_ret } @@ -821,13 +826,14 @@ static void upb_decoderplan_jit_msg(decoderplan *plan, |=>upb_getpclabel(plan, h, ENDOFMSG): // We are at end-of-submsg: call endmsg handler (if any): - upb_endmsg_handler *endmsg = upb_handlers_getendmsg(h); + upb_func *endmsg = upb_handlers_gethandler(h, UPB_ENDMSG_SELECTOR); if (endmsg) { - // void endmsg(void *closure, upb_status *status) { + // void endmsg(void *closure, const void *hd, upb_status *status) { | mov ARG1_64, CLOSURE - | mov ARG2_64, DECODER->sink - | mov ARG2_64, SINK:ARG2_64->pipeline_ - | add ARG2_64, offsetof(upb_pipeline, status_) + | loadarg2 upb_handlers_gethandlerdata(h, UPB_ENDMSG_SELECTOR) + | mov ARG3_64, DECODER->sink + | mov ARG3_64, SINK:ARG3_64->pipeline_ + | add ARG3_64, offsetof(upb_pipeline, status_) | callp endmsg } @@ -220,16 +220,27 @@ void *upb_sink_getobj(const upb_sink *s) { bool upb_sink_startmsg(upb_sink *s) { const upb_handlers *h = s->top->h; - upb_startmsg_handler *startmsg = upb_handlers_getstartmsg(h); - return startmsg ? startmsg(s->top->closure) : true; + upb_startmsg_handler *startmsg = + (upb_startmsg_handler *)upb_handlers_gethandler(h, UPB_STARTMSG_SELECTOR); + if (startmsg) { + const void *hd = upb_handlers_gethandlerdata(h, UPB_STARTMSG_SELECTOR); + bool ok = startmsg(s->top->closure, hd); + if (!ok) return false; + } + return true; } -void upb_sink_endmsg(upb_sink *s) { +bool upb_sink_endmsg(upb_sink *s) { assert(s->top == s->stack); - upb_endmsg_handler *endmsg = upb_handlers_getendmsg(s->top->h); + const upb_handlers *h = s->top->h; + upb_endmsg_handler *endmsg = + (upb_endmsg_handler *)upb_handlers_gethandler(h, UPB_ENDMSG_SELECTOR); if (endmsg) { - endmsg(s->top->closure, &s->pipeline_->status_); + const void *hd = upb_handlers_gethandlerdata(h, UPB_ENDMSG_SELECTOR); + bool ok = endmsg(s->top->closure, hd, &s->pipeline_->status_); + if (!ok) return false; } + return true; } #define PUTVAL(type, ctype) \ @@ -380,10 +391,13 @@ bool upb_sink_startsubmsg(upb_sink *s, upb_selector_t sel) { } bool upb_sink_endsubmsg(upb_sink *s, upb_selector_t sel) { - upb_endmsg_handler *endmsg = upb_handlers_getendmsg(s->top->h); + upb_endmsg_handler *endmsg = (upb_endmsg_handler *)upb_handlers_gethandler( + s->top->h, UPB_ENDMSG_SELECTOR); if (endmsg) { // TODO(haberman): check return value. - endmsg(s->top->closure, &s->pipeline_->status_); + const void *hd = + upb_handlers_gethandlerdata(s->top->h, UPB_ENDMSG_SELECTOR); + endmsg(s->top->closure, hd, &s->pipeline_->status_); } --s->top; @@ -170,7 +170,7 @@ class upb::Sink { // Should be called at the start and end of processing. bool StartMessage(); - void EndMessage(); + bool EndMessage(); // Putting of individual values. These work for both repeated and // non-repeated fields, but for repeated fields you must wrap them in @@ -230,7 +230,7 @@ void upb_sink_reset(upb_sink *s, void *closure); upb_pipeline *upb_sink_pipeline(const upb_sink *s); void *upb_sink_getobj(const upb_sink *s); bool upb_sink_startmsg(upb_sink *s); -void upb_sink_endmsg(upb_sink *s); +bool upb_sink_endmsg(upb_sink *s); bool upb_sink_putint32(upb_sink *s, upb_selector_t sel, int32_t val); bool upb_sink_putint64(upb_sink *s, upb_selector_t sel, int64_t val); bool upb_sink_putuint32(upb_sink *s, upb_selector_t sel, uint32_t val); @@ -299,8 +299,8 @@ inline T* Sink::GetObject() const { inline bool Sink::StartMessage() { return upb_sink_startmsg(this); } -inline void Sink::EndMessage() { - upb_sink_endmsg(this); +inline bool Sink::EndMessage() { + return upb_sink_endmsg(this); } inline bool Sink::PutInt32(Handlers::Selector sel, int32_t val) { return upb_sink_putint32(this, sel, val); diff --git a/upb/symtab.c b/upb/symtab.c index 2092787..8b56f89 100644 --- a/upb/symtab.c +++ b/upb/symtab.c @@ -255,17 +255,12 @@ bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, int n, void *ref_donor, upb_status_seterrf( status, "couldn't resolve name '%s' in message '%s'", name, base); goto err; - } else if (!upb_fielddef_setsubdef(f, subdef)) { - upb_status_seterrf( - status, "def '%s' had the wrong type for field '%s'", - upb_def_fullname(subdef), upb_fielddef_name(f)); + } else if (!upb_fielddef_setsubdef(f, subdef, status)) { goto err; } } - if (!upb_fielddef_resolvedefault(f)) { - upb_status_seterrf(status, "couldn't resolve enum default '%s'", - upb_fielddef_defaultstr(f, NULL)); + if (!upb_fielddef_resolveenumdefault(f, status)) { goto err; } } @@ -163,6 +163,13 @@ char *upb_strdup(const char *s); // debug mode. #define UPB_ASSERT_VAR(var, predicate) UPB_UNUSED(var); assert(predicate) +#define UPB_ASSERT_STATUS(status) do { \ + if (!upb_ok(status)) { \ + fprintf(stderr, "upb status failure: %s\n", upb_status_getstr(status)); \ + assert(upb_ok(status)); \ + } \ + } while (0) + // The maximum that any submessages can be nested. Matches proto2's limit. // At the moment this specifies the size of several statically-sized arrays // and therefore setting it high will cause more memory to be used. Will |