Index: third_party/protobuf/php/ext/google/protobuf/upb.c |
diff --git a/third_party/protobuf/php/ext/google/protobuf/upb.c b/third_party/protobuf/php/ext/google/protobuf/upb.c |
index 98daafc0ab5a9863fbee34172557a64b3f3fcef1..048a163a920a0a08df273bda5addd5f2d480a217 100644 |
--- a/third_party/protobuf/php/ext/google/protobuf/upb.c |
+++ b/third_party/protobuf/php/ext/google/protobuf/upb.c |
@@ -1,37 +1,7 @@ |
-// Protocol Buffers - Google's data interchange format |
-// Copyright 2008 Google Inc. All rights reserved. |
-// https://developers.google.com/protocol-buffers/ |
-// |
-// Redistribution and use in source and binary forms, with or without |
-// modification, are permitted provided that the following conditions are |
-// met: |
-// |
-// * Redistributions of source code must retain the above copyright |
-// notice, this list of conditions and the following disclaimer. |
-// * Redistributions in binary form must reproduce the above |
-// copyright notice, this list of conditions and the following disclaimer |
-// in the documentation and/or other materials provided with the |
-// distribution. |
-// * Neither the name of Google Inc. nor the names of its |
-// contributors may be used to endorse or promote products derived from |
-// this software without specific prior written permission. |
-// |
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- |
+// Amalgamated source file |
#include "upb.h" |
-#include <ctype.h> |
#include <stdlib.h> |
#include <string.h> |
@@ -41,7 +11,7 @@ typedef struct { |
} str_t; |
static str_t *newstr(const char *data, size_t len) { |
- str_t *ret = upb_gmalloc(sizeof(*ret) + len); |
+ str_t *ret = malloc(sizeof(*ret) + len); |
if (!ret) return NULL; |
ret->len = len; |
memcpy(ret->str, data, len); |
@@ -49,7 +19,7 @@ static str_t *newstr(const char *data, size_t len) { |
return ret; |
} |
-static void freestr(str_t *s) { upb_gfree(s); } |
+static void freestr(str_t *s) { free(s); } |
/* isalpha() etc. from <ctype.h> are locale-dependent, which we don't want. */ |
static bool upb_isbetween(char c, char low, char high) { |
@@ -94,22 +64,6 @@ static bool upb_isident(const char *str, size_t len, bool full, upb_status *s) { |
return !start; |
} |
-static bool upb_isoneof(const upb_refcounted *def) { |
- return def->vtbl == &upb_oneofdef_vtbl; |
-} |
- |
-static bool upb_isfield(const upb_refcounted *def) { |
- return def->vtbl == &upb_fielddef_vtbl; |
-} |
- |
-static const upb_oneofdef *upb_trygetoneof(const upb_refcounted *def) { |
- return upb_isoneof(def) ? (const upb_oneofdef*)def : NULL; |
-} |
- |
-static const upb_fielddef *upb_trygetfield(const upb_refcounted *def) { |
- return upb_isfield(def) ? (const upb_fielddef*)def : NULL; |
-} |
- |
/* upb_def ********************************************************************/ |
@@ -117,39 +71,14 @@ 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; } |
-const char *upb_def_name(const upb_def *d) { |
- const char *p; |
- |
- if (d->fullname == NULL) { |
- return NULL; |
- } else if ((p = strrchr(d->fullname, '.')) == NULL) { |
- /* No '.' in the name, return the full string. */ |
- return d->fullname; |
- } else { |
- /* Return one past the last '.'. */ |
- return p + 1; |
- } |
-} |
- |
bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s) { |
- UPB_ASSERT(!upb_def_isfrozen(def)); |
- if (!upb_isident(fullname, strlen(fullname), true, s)) { |
- return false; |
- } |
- |
- fullname = upb_gstrdup(fullname); |
- if (!fullname) { |
- upb_upberr_setoom(s); |
- return false; |
- } |
- |
- upb_gfree((void*)def->fullname); |
- def->fullname = fullname; |
+ assert(!upb_def_isfrozen(def)); |
+ if (!upb_isident(fullname, strlen(fullname), true, s)) return false; |
+ free((void*)def->fullname); |
+ def->fullname = upb_strdup(fullname); |
return true; |
} |
-const upb_filedef *upb_def_file(const upb_def *d) { return d->file; } |
- |
upb_def *upb_def_dup(const upb_def *def, const void *o) { |
switch (def->type) { |
case UPB_DEF_MSG: |
@@ -161,7 +90,7 @@ upb_def *upb_def_dup(const upb_def *def, const void *o) { |
case UPB_DEF_ENUM: |
return upb_enumdef_upcast_mutable( |
upb_enumdef_dup(upb_downcast_enumdef(def), o)); |
- default: UPB_ASSERT(false); return NULL; |
+ default: assert(false); return NULL; |
} |
} |
@@ -172,12 +101,11 @@ static bool upb_def_init(upb_def *def, upb_deftype_t type, |
def->type = type; |
def->fullname = NULL; |
def->came_from_user = false; |
- def->file = NULL; |
return true; |
} |
static void upb_def_uninit(upb_def *def) { |
- upb_gfree((void*)def->fullname); |
+ free((void*)def->fullname); |
} |
static const char *msgdef_name(const upb_msgdef *m) { |
@@ -232,14 +160,14 @@ static bool upb_validate_field(upb_fielddef *f, upb_status *s) { |
bool has_default_number = upb_fielddef_enumhasdefaultint32(f); |
/* Previously verified by upb_validate_enumdef(). */ |
- UPB_ASSERT(upb_enumdef_numvals(upb_fielddef_enumsubdef(f)) > 0); |
+ assert(upb_enumdef_numvals(upb_fielddef_enumsubdef(f)) > 0); |
/* We've already validated that we have an associated enumdef and that it |
* has at least one member, so at least one of these should be true. |
* Because if the user didn't set anything, we'll pick up the enum's |
* default, but if the user *did* set something we should at least pick up |
* the one they set (int32 or string). */ |
- UPB_ASSERT(has_default_name || has_default_number); |
+ assert(has_default_name || has_default_number); |
if (!has_default_name) { |
upb_status_seterrf(s, |
@@ -295,7 +223,7 @@ static bool upb_validate_enumdef(const upb_enumdef *e, upb_status *s) { |
uint32_t field_rank(const upb_fielddef *f) { |
uint32_t ret = upb_fielddef_number(f); |
const uint32_t high_bit = 1 << 30; |
- UPB_ASSERT(ret < high_bit); |
+ assert(ret < high_bit); |
if (!upb_fielddef_issubmsg(f)) |
ret |= high_bit; |
return ret; |
@@ -314,28 +242,17 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) { |
int i; |
uint32_t selector; |
int n = upb_msgdef_numfields(m); |
- upb_fielddef **fields; |
- |
- if (n == 0) { |
- m->selector_count = UPB_STATIC_SELECTOR_COUNT; |
- m->submsg_field_count = 0; |
- return true; |
- } |
- |
- fields = upb_gmalloc(n * sizeof(*fields)); |
- if (!fields) { |
- upb_upberr_setoom(s); |
- return false; |
- } |
+ upb_fielddef **fields = malloc(n * sizeof(*fields)); |
+ if (!fields) return false; |
m->submsg_field_count = 0; |
for(i = 0, upb_msg_field_begin(&j, m); |
!upb_msg_field_done(&j); |
upb_msg_field_next(&j), i++) { |
upb_fielddef *f = upb_msg_iter_field(&j); |
- UPB_ASSERT(f->msg.def == m); |
+ assert(f->msg.def == m); |
if (!upb_validate_field(f, s)) { |
- upb_gfree(fields); |
+ free(fields); |
return false; |
} |
if (upb_fielddef_issubmsg(f)) { |
@@ -395,12 +312,15 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) { |
#undef TRY |
#endif |
- upb_gfree(fields); |
+ free(fields); |
return true; |
} |
-bool _upb_def_validate(upb_def *const*defs, size_t n, upb_status *s) { |
- size_t i; |
+bool upb_def_freeze(upb_def *const* defs, int n, upb_status *s) { |
+ int i; |
+ int maxdepth; |
+ bool ret; |
+ upb_status_clear(s); |
/* First perform validation, in two passes so we can check that we have a |
* transitive closure without needing to search. */ |
@@ -426,9 +346,8 @@ bool _upb_def_validate(upb_def *const*defs, size_t n, upb_status *s) { |
/* Second pass of validation. Also assign selector bases and indexes, and |
* compact tables. */ |
for (i = 0; i < n; i++) { |
- upb_def *def = defs[i]; |
- upb_msgdef *m = upb_dyncast_msgdef_mutable(def); |
- upb_enumdef *e = upb_dyncast_enumdef_mutable(def); |
+ upb_msgdef *m = upb_dyncast_msgdef_mutable(defs[i]); |
+ upb_enumdef *e = upb_dyncast_enumdef_mutable(defs[i]); |
if (m) { |
upb_inttable_compact(&m->itof); |
if (!assign_msg_indices(m, s)) { |
@@ -439,68 +358,46 @@ bool _upb_def_validate(upb_def *const*defs, size_t n, upb_status *s) { |
} |
} |
- return true; |
+ /* Def graph contains FieldDefs between each MessageDef, so double the |
+ * limit. */ |
+ maxdepth = UPB_MAX_MESSAGE_DEPTH * 2; |
+ |
+ /* Validation all passed; freeze the defs. */ |
+ ret = upb_refcounted_freeze((upb_refcounted * const *)defs, n, s, maxdepth); |
+ assert(!(s && ret != upb_ok(s))); |
+ return ret; |
err: |
for (i = 0; i < n; i++) { |
- upb_def *def = defs[i]; |
- def->came_from_user = false; |
+ defs[i]->came_from_user = false; |
} |
- UPB_ASSERT(!(s && upb_ok(s))); |
+ assert(!(s && upb_ok(s))); |
return false; |
} |
-bool upb_def_freeze(upb_def *const* defs, size_t n, upb_status *s) { |
- /* Def graph contains FieldDefs between each MessageDef, so double the |
- * limit. */ |
- const size_t maxdepth = UPB_MAX_MESSAGE_DEPTH * 2; |
- |
- if (!_upb_def_validate(defs, n, s)) { |
- return false; |
- } |
- |
- |
- /* Validation all passed; freeze the objects. */ |
- return upb_refcounted_freeze((upb_refcounted *const*)defs, n, s, maxdepth); |
-} |
- |
/* upb_enumdef ****************************************************************/ |
-static void visitenum(const upb_refcounted *r, upb_refcounted_visit *visit, |
- void *closure) { |
- const upb_enumdef *e = (const upb_enumdef*)r; |
- const upb_def *def = upb_enumdef_upcast(e); |
- if (upb_def_file(def)) { |
- visit(r, upb_filedef_upcast(upb_def_file(def)), closure); |
- } |
-} |
- |
-static void freeenum(upb_refcounted *r) { |
+static void upb_enumdef_free(upb_refcounted *r) { |
upb_enumdef *e = (upb_enumdef*)r; |
upb_inttable_iter i; |
upb_inttable_begin(&i, &e->iton); |
for( ; !upb_inttable_done(&i); upb_inttable_next(&i)) { |
- /* To clean up the upb_gstrdup() from upb_enumdef_addval(). */ |
- upb_gfree(upb_value_getcstr(upb_inttable_iter_value(&i))); |
+ /* To clean up the upb_strdup() from upb_enumdef_addval(). */ |
+ free(upb_value_getcstr(upb_inttable_iter_value(&i))); |
} |
upb_strtable_uninit(&e->ntoi); |
upb_inttable_uninit(&e->iton); |
upb_def_uninit(upb_enumdef_upcast_mutable(e)); |
- upb_gfree(e); |
+ free(e); |
} |
-const struct upb_refcounted_vtbl upb_enumdef_vtbl = {&visitenum, &freeenum}; |
- |
upb_enumdef *upb_enumdef_new(const void *owner) { |
- upb_enumdef *e = upb_gmalloc(sizeof(*e)); |
+ static const struct upb_refcounted_vtbl vtbl = {NULL, &upb_enumdef_free}; |
+ upb_enumdef *e = malloc(sizeof(*e)); |
if (!e) return NULL; |
- |
- if (!upb_def_init(upb_enumdef_upcast_mutable(e), UPB_DEF_ENUM, |
- &upb_enumdef_vtbl, owner)) { |
+ if (!upb_def_init(upb_enumdef_upcast_mutable(e), UPB_DEF_ENUM, &vtbl, owner)) |
goto err2; |
- } |
- |
if (!upb_strtable_init(&e->ntoi, UPB_CTYPE_INT32)) goto err2; |
if (!upb_inttable_init(&e->iton, UPB_CTYPE_CSTR)) goto err1; |
return e; |
@@ -508,7 +405,7 @@ upb_enumdef *upb_enumdef_new(const void *owner) { |
err1: |
upb_strtable_uninit(&e->ntoi); |
err2: |
- upb_gfree(e); |
+ free(e); |
return NULL; |
} |
@@ -536,10 +433,6 @@ const char *upb_enumdef_fullname(const upb_enumdef *e) { |
return upb_def_fullname(upb_enumdef_upcast(e)); |
} |
-const char *upb_enumdef_name(const upb_enumdef *e) { |
- return upb_def_name(upb_enumdef_upcast(e)); |
-} |
- |
bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname, |
upb_status *s) { |
return upb_def_setfullname(upb_enumdef_upcast_mutable(e), fullname, s); |
@@ -547,46 +440,37 @@ bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname, |
bool upb_enumdef_addval(upb_enumdef *e, const char *name, int32_t num, |
upb_status *status) { |
- char *name2; |
- |
if (!upb_isident(name, strlen(name), false, status)) { |
return false; |
} |
- |
if (upb_enumdef_ntoiz(e, name, NULL)) { |
upb_status_seterrf(status, "name '%s' is already defined", name); |
return false; |
} |
- |
if (!upb_strtable_insert(&e->ntoi, name, upb_value_int32(num))) { |
upb_status_seterrmsg(status, "out of memory"); |
return false; |
} |
- |
- if (!upb_inttable_lookup(&e->iton, num, NULL)) { |
- name2 = upb_gstrdup(name); |
- if (!name2 || !upb_inttable_insert(&e->iton, num, upb_value_cstr(name2))) { |
- upb_status_seterrmsg(status, "out of memory"); |
- upb_strtable_remove(&e->ntoi, name, NULL); |
- return false; |
- } |
+ if (!upb_inttable_lookup(&e->iton, num, NULL) && |
+ !upb_inttable_insert(&e->iton, num, upb_value_cstr(upb_strdup(name)))) { |
+ upb_status_seterrmsg(status, "out of memory"); |
+ upb_strtable_remove(&e->ntoi, name, NULL); |
+ return false; |
} |
- |
if (upb_enumdef_numvals(e) == 1) { |
bool ok = upb_enumdef_setdefault(e, num, NULL); |
- UPB_ASSERT(ok); |
+ UPB_ASSERT_VAR(ok, ok); |
} |
- |
return true; |
} |
int32_t upb_enumdef_default(const upb_enumdef *e) { |
- UPB_ASSERT(upb_enumdef_iton(e, e->defaultval)); |
+ assert(upb_enumdef_iton(e, e->defaultval)); |
return e->defaultval; |
} |
bool upb_enumdef_setdefault(upb_enumdef *e, int32_t val, upb_status *s) { |
- UPB_ASSERT(!upb_enumdef_isfrozen(e)); |
+ assert(!upb_enumdef_isfrozen(e)); |
if (!upb_enumdef_iton(e, val)) { |
upb_status_seterrf(s, "number '%d' is not in the enum.", val); |
return false; |
@@ -641,40 +525,32 @@ static void upb_fielddef_uninit_default(upb_fielddef *f) { |
freestr(f->defaultval.bytes); |
} |
-const char *upb_fielddef_fullname(const upb_fielddef *e) { |
- return upb_def_fullname(upb_fielddef_upcast(e)); |
-} |
- |
static void visitfield(const upb_refcounted *r, upb_refcounted_visit *visit, |
void *closure) { |
const upb_fielddef *f = (const upb_fielddef*)r; |
- const upb_def *def = upb_fielddef_upcast(f); |
if (upb_fielddef_containingtype(f)) { |
visit(r, upb_msgdef_upcast2(upb_fielddef_containingtype(f)), closure); |
} |
if (upb_fielddef_containingoneof(f)) { |
- visit(r, upb_oneofdef_upcast(upb_fielddef_containingoneof(f)), closure); |
+ visit(r, upb_oneofdef_upcast2(upb_fielddef_containingoneof(f)), closure); |
} |
if (upb_fielddef_subdef(f)) { |
visit(r, upb_def_upcast(upb_fielddef_subdef(f)), closure); |
} |
- if (upb_def_file(def)) { |
- visit(r, upb_filedef_upcast(upb_def_file(def)), closure); |
- } |
} |
static void freefield(upb_refcounted *r) { |
upb_fielddef *f = (upb_fielddef*)r; |
upb_fielddef_uninit_default(f); |
if (f->subdef_is_symbolic) |
- upb_gfree(f->sub.name); |
+ free(f->sub.name); |
upb_def_uninit(upb_fielddef_upcast_mutable(f)); |
- upb_gfree(f); |
+ free(f); |
} |
static const char *enumdefaultstr(const upb_fielddef *f) { |
const upb_enumdef *e; |
- UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); |
+ assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); |
e = upb_fielddef_enumsubdef(f); |
if (f->default_is_string && f->defaultval.bytes) { |
/* Default was explicitly set as a string. */ |
@@ -691,7 +567,7 @@ static const char *enumdefaultstr(const upb_fielddef *f) { |
/* Default is completely unset; pull enumdef default. */ |
if (upb_enumdef_numvals(e) > 0) { |
const char *name = upb_enumdef_iton(e, upb_enumdef_default(e)); |
- UPB_ASSERT(name); |
+ assert(name); |
return name; |
} |
} |
@@ -701,7 +577,7 @@ static const char *enumdefaultstr(const upb_fielddef *f) { |
static bool enumdefaultint32(const upb_fielddef *f, int32_t *val) { |
const upb_enumdef *e; |
- UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); |
+ assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); |
e = upb_fielddef_enumsubdef(f); |
if (!f->default_is_string) { |
/* Default was explicitly set as an integer. */ |
@@ -725,14 +601,12 @@ static bool enumdefaultint32(const upb_fielddef *f, int32_t *val) { |
return false; |
} |
-const struct upb_refcounted_vtbl upb_fielddef_vtbl = {visitfield, freefield}; |
- |
upb_fielddef *upb_fielddef_new(const void *o) { |
- upb_fielddef *f = upb_gmalloc(sizeof(*f)); |
+ static const struct upb_refcounted_vtbl vtbl = {visitfield, freefield}; |
+ upb_fielddef *f = malloc(sizeof(*f)); |
if (!f) return NULL; |
- if (!upb_def_init(upb_fielddef_upcast_mutable(f), UPB_DEF_FIELD, |
- &upb_fielddef_vtbl, o)) { |
- upb_gfree(f); |
+ if (!upb_def_init(upb_fielddef_upcast_mutable(f), UPB_DEF_FIELD, &vtbl, o)) { |
+ free(f); |
return NULL; |
} |
f->msg.def = NULL; |
@@ -783,7 +657,7 @@ upb_fielddef *upb_fielddef_dup(const upb_fielddef *f, const void *owner) { |
srcname = f->sub.def ? upb_def_fullname(f->sub.def) : NULL; |
} |
if (srcname) { |
- char *newname = upb_gmalloc(strlen(f->sub.def->fullname) + 2); |
+ char *newname = malloc(strlen(f->sub.def->fullname) + 2); |
if (!newname) { |
upb_fielddef_unref(newf, owner); |
return NULL; |
@@ -791,7 +665,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, NULL); |
- upb_gfree(newname); |
+ free(newname); |
} |
return newf; |
@@ -802,7 +676,7 @@ bool upb_fielddef_typeisset(const upb_fielddef *f) { |
} |
upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f) { |
- UPB_ASSERT(f->type_is_set_); |
+ assert(f->type_is_set_); |
return f->type_; |
} |
@@ -842,45 +716,6 @@ const char *upb_fielddef_name(const upb_fielddef *f) { |
return upb_def_fullname(upb_fielddef_upcast(f)); |
} |
-size_t upb_fielddef_getjsonname(const upb_fielddef *f, char *buf, size_t len) { |
- const char *name = upb_fielddef_name(f); |
- size_t src, dst = 0; |
- bool ucase_next = false; |
- |
-#define WRITE(byte) \ |
- ++dst; \ |
- if (dst < len) buf[dst - 1] = byte; \ |
- else if (dst == len) buf[dst - 1] = '\0' |
- |
- if (!name) { |
- WRITE('\0'); |
- return 0; |
- } |
- |
- /* Implement the transformation as described in the spec: |
- * 1. upper case all letters after an underscore. |
- * 2. remove all underscores. |
- */ |
- for (src = 0; name[src]; src++) { |
- if (name[src] == '_') { |
- ucase_next = true; |
- continue; |
- } |
- |
- if (ucase_next) { |
- WRITE(toupper(name[src])); |
- ucase_next = false; |
- } else { |
- WRITE(name[src]); |
- } |
- } |
- |
- WRITE('\0'); |
- return dst; |
- |
-#undef WRITE |
-} |
- |
const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f) { |
return f->msg_is_symbolic ? NULL : f->msg.def; |
} |
@@ -898,28 +733,20 @@ const char *upb_fielddef_containingtypename(upb_fielddef *f) { |
} |
static void release_containingtype(upb_fielddef *f) { |
- if (f->msg_is_symbolic) upb_gfree(f->msg.name); |
+ if (f->msg_is_symbolic) free(f->msg.name); |
} |
bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name, |
upb_status *s) { |
- char *name_copy; |
- UPB_ASSERT(!upb_fielddef_isfrozen(f)); |
+ assert(!upb_fielddef_isfrozen(f)); |
if (upb_fielddef_containingtype(f)) { |
upb_status_seterrmsg(s, "field has already been added to a message."); |
return false; |
} |
/* TODO: validate name (upb_isident() doesn't quite work atm because this name |
* may have a leading "."). */ |
- |
- name_copy = upb_gstrdup(name); |
- if (!name_copy) { |
- upb_upberr_setoom(s); |
- return false; |
- } |
- |
release_containingtype(f); |
- f->msg.name = name_copy; |
+ f->msg.name = upb_strdup(name); |
f->msg_is_symbolic = true; |
return true; |
} |
@@ -935,7 +762,7 @@ bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s) { |
static void chkdefaulttype(const upb_fielddef *f, upb_fieldtype_t type) { |
UPB_UNUSED(f); |
UPB_UNUSED(type); |
- UPB_ASSERT(f->type_is_set_ && upb_fielddef_type(f) == type); |
+ assert(f->type_is_set_ && upb_fielddef_type(f) == type); |
} |
int64_t upb_fielddef_defaultint64(const upb_fielddef *f) { |
@@ -947,7 +774,7 @@ int32_t upb_fielddef_defaultint32(const upb_fielddef *f) { |
if (f->type_is_set_ && upb_fielddef_type(f) == UPB_TYPE_ENUM) { |
int32_t val; |
bool ok = enumdefaultint32(f, &val); |
- UPB_ASSERT(ok); |
+ UPB_ASSERT_VAR(ok, ok); |
return val; |
} else { |
chkdefaulttype(f, UPB_TYPE_INT32); |
@@ -981,14 +808,14 @@ double upb_fielddef_defaultdouble(const upb_fielddef *f) { |
} |
const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len) { |
- UPB_ASSERT(f->type_is_set_); |
- UPB_ASSERT(upb_fielddef_type(f) == UPB_TYPE_STRING || |
+ assert(f->type_is_set_); |
+ assert(upb_fielddef_type(f) == UPB_TYPE_STRING || |
upb_fielddef_type(f) == UPB_TYPE_BYTES || |
upb_fielddef_type(f) == UPB_TYPE_ENUM); |
if (upb_fielddef_type(f) == UPB_TYPE_ENUM) { |
const char *ret = enumdefaultstr(f); |
- UPB_ASSERT(ret); |
+ assert(ret); |
/* Enum defaults can't have embedded NULLs. */ |
if (len) *len = strlen(ret); |
return ret; |
@@ -1070,8 +897,8 @@ bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s) { |
} |
void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type) { |
- UPB_ASSERT(!upb_fielddef_isfrozen(f)); |
- UPB_ASSERT(upb_fielddef_checktype(type)); |
+ assert(!upb_fielddef_isfrozen(f)); |
+ assert(upb_fielddef_checktype(type)); |
upb_fielddef_uninit_default(f); |
f->type_ = type; |
f->type_is_set_ = true; |
@@ -1079,7 +906,7 @@ void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type) { |
} |
void upb_fielddef_setdescriptortype(upb_fielddef *f, int type) { |
- UPB_ASSERT(!upb_fielddef_isfrozen(f)); |
+ assert(!upb_fielddef_isfrozen(f)); |
switch (type) { |
case UPB_DESCRIPTOR_TYPE_DOUBLE: |
upb_fielddef_settype(f, UPB_TYPE_DOUBLE); |
@@ -1121,7 +948,7 @@ void upb_fielddef_setdescriptortype(upb_fielddef *f, int type) { |
case UPB_DESCRIPTOR_TYPE_ENUM: |
upb_fielddef_settype(f, UPB_TYPE_ENUM); |
break; |
- default: UPB_ASSERT(false); |
+ default: assert(false); |
} |
if (type == UPB_DESCRIPTOR_TYPE_FIXED64 || |
@@ -1179,34 +1006,34 @@ upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f) { |
} |
void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension) { |
- UPB_ASSERT(!upb_fielddef_isfrozen(f)); |
+ assert(!upb_fielddef_isfrozen(f)); |
f->is_extension_ = is_extension; |
} |
void upb_fielddef_setlazy(upb_fielddef *f, bool lazy) { |
- UPB_ASSERT(!upb_fielddef_isfrozen(f)); |
+ assert(!upb_fielddef_isfrozen(f)); |
f->lazy_ = lazy; |
} |
void upb_fielddef_setpacked(upb_fielddef *f, bool packed) { |
- UPB_ASSERT(!upb_fielddef_isfrozen(f)); |
+ assert(!upb_fielddef_isfrozen(f)); |
f->packed_ = packed; |
} |
void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label) { |
- UPB_ASSERT(!upb_fielddef_isfrozen(f)); |
- UPB_ASSERT(upb_fielddef_checklabel(label)); |
+ assert(!upb_fielddef_isfrozen(f)); |
+ assert(upb_fielddef_checklabel(label)); |
f->label_ = label; |
} |
void upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt) { |
- UPB_ASSERT(!upb_fielddef_isfrozen(f)); |
- UPB_ASSERT(upb_fielddef_checkintfmt(fmt)); |
+ assert(!upb_fielddef_isfrozen(f)); |
+ assert(upb_fielddef_checkintfmt(fmt)); |
f->intfmt = fmt; |
} |
void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim) { |
- UPB_ASSERT(!upb_fielddef_isfrozen(f)); |
+ assert(!upb_fielddef_isfrozen(f)); |
f->tagdelim = tag_delim; |
f->tagdelim = tag_delim; |
} |
@@ -1214,12 +1041,12 @@ void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim) { |
static bool checksetdefault(upb_fielddef *f, upb_fieldtype_t type) { |
if (!f->type_is_set_ || upb_fielddef_isfrozen(f) || |
upb_fielddef_type(f) != type) { |
- UPB_ASSERT(false); |
+ assert(false); |
return false; |
} |
if (f->default_is_string) { |
str_t *s = f->defaultval.bytes; |
- UPB_ASSERT(s || type == UPB_TYPE_ENUM); |
+ assert(s || type == UPB_TYPE_ENUM); |
if (s) freestr(s); |
} |
f->default_is_string = false; |
@@ -1267,16 +1094,16 @@ void upb_fielddef_setdefaultdouble(upb_fielddef *f, double value) { |
bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len, |
upb_status *s) { |
str_t *str2; |
- UPB_ASSERT(upb_fielddef_isstring(f) || f->type_ == UPB_TYPE_ENUM); |
+ assert(upb_fielddef_isstring(f) || f->type_ == UPB_TYPE_ENUM); |
if (f->type_ == UPB_TYPE_ENUM && !upb_isident(str, len, false, s)) |
return false; |
if (f->default_is_string) { |
str_t *s = f->defaultval.bytes; |
- UPB_ASSERT(s || f->type_ == UPB_TYPE_ENUM); |
+ assert(s || f->type_ == UPB_TYPE_ENUM); |
if (s) freestr(s); |
} else { |
- UPB_ASSERT(f->type_ == UPB_TYPE_ENUM); |
+ assert(f->type_ == UPB_TYPE_ENUM); |
} |
str2 = newstr(str, len); |
@@ -1287,18 +1114,18 @@ bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len, |
void upb_fielddef_setdefaultcstr(upb_fielddef *f, const char *str, |
upb_status *s) { |
- UPB_ASSERT(f->type_is_set_); |
+ assert(f->type_is_set_); |
upb_fielddef_setdefaultstr(f, str, str ? strlen(str) : 0, s); |
} |
bool upb_fielddef_enumhasdefaultint32(const upb_fielddef *f) { |
int32_t val; |
- UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); |
+ assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); |
return enumdefaultint32(f, &val); |
} |
bool upb_fielddef_enumhasdefaultstr(const upb_fielddef *f) { |
- UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); |
+ assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); |
return enumdefaultstr(f) != NULL; |
} |
@@ -1320,7 +1147,7 @@ static bool upb_subdef_typecheck(upb_fielddef *f, const upb_def *subdef, |
static void release_subdef(upb_fielddef *f) { |
if (f->subdef_is_symbolic) { |
- upb_gfree(f->sub.name); |
+ free(f->sub.name); |
} else if (f->sub.def) { |
upb_unref2(f->sub.def, f); |
} |
@@ -1328,8 +1155,8 @@ static void release_subdef(upb_fielddef *f) { |
bool upb_fielddef_setsubdef(upb_fielddef *f, const upb_def *subdef, |
upb_status *s) { |
- UPB_ASSERT(!upb_fielddef_isfrozen(f)); |
- UPB_ASSERT(upb_fielddef_hassubdef(f)); |
+ assert(!upb_fielddef_isfrozen(f)); |
+ assert(upb_fielddef_hassubdef(f)); |
if (subdef && !upb_subdef_typecheck(f, subdef, s)) return false; |
release_subdef(f); |
f->sub.def = subdef; |
@@ -1350,23 +1177,15 @@ bool upb_fielddef_setenumsubdef(upb_fielddef *f, const upb_enumdef *subdef, |
bool upb_fielddef_setsubdefname(upb_fielddef *f, const char *name, |
upb_status *s) { |
- char *name_copy; |
- UPB_ASSERT(!upb_fielddef_isfrozen(f)); |
+ assert(!upb_fielddef_isfrozen(f)); |
if (!upb_fielddef_hassubdef(f)) { |
upb_status_seterrmsg(s, "field type does not accept a subdef"); |
return false; |
} |
- |
- name_copy = upb_gstrdup(name); |
- if (!name_copy) { |
- upb_upberr_setoom(s); |
- return false; |
- } |
- |
/* TODO: validate name (upb_isident() doesn't quite work atm because this name |
* may have a leading "."). */ |
release_subdef(f); |
- f->sub.name = name_copy; |
+ f->sub.name = upb_strdup(name); |
f->subdef_is_symbolic = true; |
return true; |
} |
@@ -1393,16 +1212,6 @@ bool upb_fielddef_ismap(const upb_fielddef *f) { |
upb_msgdef_mapentry(upb_fielddef_msgsubdef(f)); |
} |
-bool upb_fielddef_haspresence(const upb_fielddef *f) { |
- if (upb_fielddef_isseq(f)) return false; |
- if (upb_fielddef_issubmsg(f)) return true; |
- |
- /* Primitive field: return true unless there is a message that specifies |
- * presence should not exist. */ |
- if (f->msg_is_symbolic || !f->msg.def) return true; |
- return f->msg.def->syntax == UPB_SYNTAX_PROTO2; |
-} |
- |
bool upb_fielddef_hassubdef(const upb_fielddef *f) { |
return upb_fielddef_issubmsg(f) || upb_fielddef_type(f) == UPB_TYPE_ENUM; |
} |
@@ -1425,7 +1234,6 @@ static void visitmsg(const upb_refcounted *r, upb_refcounted_visit *visit, |
void *closure) { |
upb_msg_oneof_iter o; |
const upb_msgdef *m = (const upb_msgdef*)r; |
- const upb_def *def = upb_msgdef_upcast(m); |
upb_msg_field_iter i; |
for(upb_msg_field_begin(&i, m); |
!upb_msg_field_done(&i); |
@@ -1437,42 +1245,37 @@ static void visitmsg(const upb_refcounted *r, upb_refcounted_visit *visit, |
!upb_msg_oneof_done(&o); |
upb_msg_oneof_next(&o)) { |
upb_oneofdef *f = upb_msg_iter_oneof(&o); |
- visit(r, upb_oneofdef_upcast(f), closure); |
- } |
- if (upb_def_file(def)) { |
- visit(r, upb_filedef_upcast(upb_def_file(def)), closure); |
+ visit(r, upb_oneofdef_upcast2(f), closure); |
} |
} |
static void freemsg(upb_refcounted *r) { |
upb_msgdef *m = (upb_msgdef*)r; |
+ upb_strtable_uninit(&m->ntoo); |
upb_strtable_uninit(&m->ntof); |
upb_inttable_uninit(&m->itof); |
upb_def_uninit(upb_msgdef_upcast_mutable(m)); |
- upb_gfree(m); |
+ free(m); |
} |
-const struct upb_refcounted_vtbl upb_msgdef_vtbl = {visitmsg, freemsg}; |
- |
upb_msgdef *upb_msgdef_new(const void *owner) { |
- upb_msgdef *m = upb_gmalloc(sizeof(*m)); |
+ static const struct upb_refcounted_vtbl vtbl = {visitmsg, freemsg}; |
+ upb_msgdef *m = malloc(sizeof(*m)); |
if (!m) return NULL; |
- |
- if (!upb_def_init(upb_msgdef_upcast_mutable(m), UPB_DEF_MSG, &upb_msgdef_vtbl, |
- owner)) { |
+ if (!upb_def_init(upb_msgdef_upcast_mutable(m), UPB_DEF_MSG, &vtbl, owner)) |
goto err2; |
- } |
- |
- if (!upb_inttable_init(&m->itof, UPB_CTYPE_PTR)) goto err2; |
- if (!upb_strtable_init(&m->ntof, UPB_CTYPE_PTR)) goto err1; |
+ if (!upb_inttable_init(&m->itof, UPB_CTYPE_PTR)) goto err3; |
+ if (!upb_strtable_init(&m->ntof, UPB_CTYPE_PTR)) goto err2; |
+ if (!upb_strtable_init(&m->ntoo, UPB_CTYPE_PTR)) goto err1; |
m->map_entry = false; |
- m->syntax = UPB_SYNTAX_PROTO2; |
return m; |
err1: |
- upb_inttable_uninit(&m->itof); |
+ upb_strtable_uninit(&m->ntof); |
err2: |
- upb_gfree(m); |
+ upb_inttable_uninit(&m->itof); |
+err3: |
+ free(m); |
return NULL; |
} |
@@ -1487,8 +1290,7 @@ upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner) { |
upb_def_fullname(upb_msgdef_upcast(m)), |
NULL); |
newm->map_entry = m->map_entry; |
- newm->syntax = m->syntax; |
- UPB_ASSERT(ok); |
+ UPB_ASSERT_VAR(ok, ok); |
for(upb_msg_field_begin(&i, m); |
!upb_msg_field_done(&i); |
upb_msg_field_next(&i)) { |
@@ -1521,28 +1323,11 @@ const char *upb_msgdef_fullname(const upb_msgdef *m) { |
return upb_def_fullname(upb_msgdef_upcast(m)); |
} |
-const char *upb_msgdef_name(const upb_msgdef *m) { |
- return upb_def_name(upb_msgdef_upcast(m)); |
-} |
- |
bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname, |
upb_status *s) { |
return upb_def_setfullname(upb_msgdef_upcast_mutable(m), fullname, s); |
} |
-bool upb_msgdef_setsyntax(upb_msgdef *m, upb_syntax_t syntax) { |
- if (syntax != UPB_SYNTAX_PROTO2 && syntax != UPB_SYNTAX_PROTO3) { |
- return false; |
- } |
- |
- m->syntax = syntax; |
- return true; |
-} |
- |
-upb_syntax_t upb_msgdef_syntax(const upb_msgdef *m) { |
- return m->syntax; |
-} |
- |
/* Helper: check that the field |f| is safe to add to msgdef |m|. Set an error |
* on status |s| and return false if not. */ |
static bool check_field_add(const upb_msgdef *m, const upb_fielddef *f, |
@@ -1553,11 +1338,9 @@ static bool check_field_add(const upb_msgdef *m, const upb_fielddef *f, |
} else if (upb_fielddef_name(f) == NULL || upb_fielddef_number(f) == 0) { |
upb_status_seterrmsg(s, "field name or number were not set"); |
return false; |
- } else if (upb_msgdef_itof(m, upb_fielddef_number(f))) { |
- upb_status_seterrmsg(s, "duplicate field number"); |
- return false; |
- } else if (upb_strtable_lookup(&m->ntof, upb_fielddef_name(f), NULL)) { |
- upb_status_seterrmsg(s, "name conflicts with existing field or oneof"); |
+ } else if (upb_msgdef_ntofz(m, upb_fielddef_name(f)) || |
+ upb_msgdef_itof(m, upb_fielddef_number(f))) { |
+ upb_status_seterrmsg(s, "duplicate field name or number for field"); |
return false; |
} |
return true; |
@@ -1590,7 +1373,6 @@ bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor, |
* This method is idempotent. Check if |f| is already part of this msgdef and |
* return immediately if so. */ |
if (upb_fielddef_containingtype(f) == m) { |
- if (ref_donor) upb_fielddef_unref(f, ref_donor); |
return true; |
} |
@@ -1619,8 +1401,8 @@ bool upb_msgdef_addoneof(upb_msgdef *m, upb_oneofdef *o, const void *ref_donor, |
} else if (upb_oneofdef_name(o) == NULL) { |
upb_status_seterrmsg(s, "oneofdef name was not set"); |
return false; |
- } else if (upb_strtable_lookup(&m->ntof, upb_oneofdef_name(o), NULL)) { |
- upb_status_seterrmsg(s, "name conflicts with existing field or oneof"); |
+ } else if (upb_msgdef_ntooz(m, upb_oneofdef_name(o))) { |
+ upb_status_seterrmsg(s, "duplicate oneof name"); |
return false; |
} |
@@ -1637,7 +1419,7 @@ bool upb_msgdef_addoneof(upb_msgdef *m, upb_oneofdef *o, const void *ref_donor, |
/* Add oneof itself first. */ |
o->parent = m; |
- upb_strtable_insert(&m->ntof, upb_oneofdef_name(o), upb_value_ptr(o)); |
+ upb_strtable_insert(&m->ntoo, upb_oneofdef_name(o), upb_value_ptr(o)); |
upb_ref2(o, m); |
upb_ref2(m, o); |
@@ -1661,51 +1443,27 @@ 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, |
size_t len) { |
upb_value val; |
- |
- if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) { |
- return NULL; |
- } |
- |
- return upb_trygetfield(upb_value_getptr(val)); |
+ return upb_strtable_lookup2(&m->ntof, name, len, &val) ? |
+ upb_value_getptr(val) : NULL; |
} |
const upb_oneofdef *upb_msgdef_ntoo(const upb_msgdef *m, const char *name, |
size_t len) { |
upb_value val; |
- |
- if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) { |
- return NULL; |
- } |
- |
- return upb_trygetoneof(upb_value_getptr(val)); |
-} |
- |
-bool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len, |
- const upb_fielddef **f, const upb_oneofdef **o) { |
- upb_value val; |
- |
- if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) { |
- return false; |
- } |
- |
- *o = upb_trygetoneof(upb_value_getptr(val)); |
- *f = upb_trygetfield(upb_value_getptr(val)); |
- UPB_ASSERT((*o != NULL) ^ (*f != NULL)); /* Exactly one of the two should be set. */ |
- return true; |
+ return upb_strtable_lookup2(&m->ntoo, name, len, &val) ? |
+ upb_value_getptr(val) : NULL; |
} |
int upb_msgdef_numfields(const upb_msgdef *m) { |
- /* The number table contains only fields. */ |
- return upb_inttable_count(&m->itof); |
+ return upb_strtable_count(&m->ntof); |
} |
int upb_msgdef_numoneofs(const upb_msgdef *m) { |
- /* The name table includes oneofs, and the number table does not. */ |
- return upb_strtable_count(&m->ntof) - upb_inttable_count(&m->itof); |
+ return upb_strtable_count(&m->ntoo); |
} |
void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry) { |
- UPB_ASSERT(!upb_msgdef_isfrozen(m)); |
+ assert(!upb_msgdef_isfrozen(m)); |
m->map_entry = map_entry; |
} |
@@ -1732,21 +1490,10 @@ void upb_msg_field_iter_setdone(upb_msg_field_iter *iter) { |
} |
void upb_msg_oneof_begin(upb_msg_oneof_iter *iter, const upb_msgdef *m) { |
- upb_strtable_begin(iter, &m->ntof); |
- /* We need to skip past any initial fields. */ |
- while (!upb_strtable_done(iter) && |
- !upb_isoneof(upb_value_getptr(upb_strtable_iter_value(iter)))) { |
- upb_strtable_next(iter); |
- } |
+ upb_strtable_begin(iter, &m->ntoo); |
} |
-void upb_msg_oneof_next(upb_msg_oneof_iter *iter) { |
- /* We need to skip past fields to return only oneofs. */ |
- do { |
- upb_strtable_next(iter); |
- } while (!upb_strtable_done(iter) && |
- !upb_isoneof(upb_value_getptr(upb_strtable_iter_value(iter)))); |
-} |
+void upb_msg_oneof_next(upb_msg_oneof_iter *iter) { upb_strtable_next(iter); } |
bool upb_msg_oneof_done(const upb_msg_oneof_iter *iter) { |
return upb_strtable_done(iter); |
@@ -1779,36 +1526,26 @@ static void freeoneof(upb_refcounted *r) { |
upb_oneofdef *o = (upb_oneofdef*)r; |
upb_strtable_uninit(&o->ntof); |
upb_inttable_uninit(&o->itof); |
- upb_gfree((void*)o->name); |
- upb_gfree(o); |
+ upb_def_uninit(upb_oneofdef_upcast_mutable(o)); |
+ free(o); |
} |
-const struct upb_refcounted_vtbl upb_oneofdef_vtbl = {visitoneof, freeoneof}; |
- |
upb_oneofdef *upb_oneofdef_new(const void *owner) { |
- upb_oneofdef *o = upb_gmalloc(sizeof(*o)); |
- |
- if (!o) { |
- return NULL; |
- } |
- |
+ static const struct upb_refcounted_vtbl vtbl = {visitoneof, freeoneof}; |
+ upb_oneofdef *o = malloc(sizeof(*o)); |
o->parent = NULL; |
- o->name = NULL; |
- |
- if (!upb_refcounted_init(upb_oneofdef_upcast_mutable(o), &upb_oneofdef_vtbl, |
- owner)) { |
+ if (!o) return NULL; |
+ if (!upb_def_init(upb_oneofdef_upcast_mutable(o), UPB_DEF_ONEOF, &vtbl, |
+ owner)) |
goto err2; |
- } |
- |
if (!upb_inttable_init(&o->itof, UPB_CTYPE_PTR)) goto err2; |
if (!upb_strtable_init(&o->ntof, UPB_CTYPE_PTR)) goto err1; |
- |
return o; |
err1: |
upb_inttable_uninit(&o->itof); |
err2: |
- upb_gfree(o); |
+ free(o); |
return NULL; |
} |
@@ -1817,8 +1554,9 @@ upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner) { |
upb_oneof_iter i; |
upb_oneofdef *newo = upb_oneofdef_new(owner); |
if (!newo) return NULL; |
- ok = upb_oneofdef_setname(newo, upb_oneofdef_name(o), NULL); |
- UPB_ASSERT(ok); |
+ ok = upb_def_setfullname(upb_oneofdef_upcast_mutable(newo), |
+ upb_def_fullname(upb_oneofdef_upcast(o)), NULL); |
+ UPB_ASSERT_VAR(ok, ok); |
for (upb_oneof_begin(&i, o); !upb_oneof_done(&i); upb_oneof_next(&i)) { |
upb_fielddef *f = upb_fielddef_dup(upb_oneof_iter_field(&i), &f); |
if (!f || !upb_oneofdef_addfield(newo, f, &f, NULL)) { |
@@ -1829,28 +1567,17 @@ upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner) { |
return newo; |
} |
-const char *upb_oneofdef_name(const upb_oneofdef *o) { return o->name; } |
+const char *upb_oneofdef_name(const upb_oneofdef *o) { |
+ return upb_def_fullname(upb_oneofdef_upcast(o)); |
+} |
-bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s) { |
- UPB_ASSERT(!upb_oneofdef_isfrozen(o)); |
+bool upb_oneofdef_setname(upb_oneofdef *o, const char *fullname, |
+ upb_status *s) { |
if (upb_oneofdef_containingtype(o)) { |
upb_status_seterrmsg(s, "oneof already added to a message"); |
return false; |
} |
- |
- if (!upb_isident(name, strlen(name), true, s)) { |
- return false; |
- } |
- |
- name = upb_gstrdup(name); |
- if (!name) { |
- upb_status_seterrmsg(s, "One of memory"); |
- return false; |
- } |
- |
- upb_gfree((void*)o->name); |
- o->name = name; |
- return true; |
+ return upb_def_setfullname(upb_oneofdef_upcast_mutable(o), fullname, s); |
} |
const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o) { |
@@ -1864,8 +1591,8 @@ int upb_oneofdef_numfields(const upb_oneofdef *o) { |
bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f, |
const void *ref_donor, |
upb_status *s) { |
- UPB_ASSERT(!upb_oneofdef_isfrozen(o)); |
- UPB_ASSERT(!o->parent || !upb_msgdef_isfrozen(o->parent)); |
+ assert(!upb_oneofdef_isfrozen(o)); |
+ assert(!o->parent || !upb_msgdef_isfrozen(o->parent)); |
/* This method is idempotent. Check if |f| is already part of this oneofdef |
* and return immediately if so. */ |
@@ -1969,209 +1696,287 @@ void upb_oneof_iter_setdone(upb_oneof_iter *iter) { |
upb_inttable_iter_setdone(iter); |
} |
-/* upb_filedef ****************************************************************/ |
-static void visitfiledef(const upb_refcounted *r, upb_refcounted_visit *visit, |
- void *closure) { |
- const upb_filedef *f = (const upb_filedef*)r; |
- size_t i; |
+#include <stdlib.h> |
+#include <stdio.h> |
+#include <string.h> |
- for(i = 0; i < upb_filedef_defcount(f); i++) { |
- visit(r, upb_def_upcast(upb_filedef_def(f, i)), closure); |
- } |
-} |
+typedef struct cleanup_ent { |
+ upb_cleanup_func *cleanup; |
+ void *ud; |
+ struct cleanup_ent *next; |
+} cleanup_ent; |
-static void freefiledef(upb_refcounted *r) { |
- upb_filedef *f = (upb_filedef*)r; |
- size_t i; |
+static void *seeded_alloc(void *ud, void *ptr, size_t oldsize, size_t size); |
- for(i = 0; i < upb_filedef_depcount(f); i++) { |
- upb_filedef_unref(upb_filedef_dep(f, i), f); |
- } |
+/* Default allocator **********************************************************/ |
- upb_inttable_uninit(&f->defs); |
- upb_inttable_uninit(&f->deps); |
- upb_gfree((void*)f->name); |
- upb_gfree((void*)f->package); |
- upb_gfree(f); |
-} |
+/* Just use realloc, keeping all allocated blocks in a linked list to destroy at |
+ * the end. */ |
-const struct upb_refcounted_vtbl upb_filedef_vtbl = {visitfiledef, freefiledef}; |
+typedef struct mem_block { |
+ /* List is doubly-linked, because in cases where realloc() moves an existing |
+ * block, we need to be able to remove the old pointer from the list |
+ * efficiently. */ |
+ struct mem_block *prev, *next; |
+#ifndef NDEBUG |
+ size_t size; /* Doesn't include mem_block structure. */ |
+#endif |
+} mem_block; |
-upb_filedef *upb_filedef_new(const void *owner) { |
- upb_filedef *f = upb_gmalloc(sizeof(*f)); |
+typedef struct { |
+ mem_block *head; |
+} default_alloc_ud; |
- if (!f) { |
- return NULL; |
- } |
+static void *default_alloc(void *_ud, void *ptr, size_t oldsize, size_t size) { |
+ default_alloc_ud *ud = _ud; |
+ mem_block *from, *block; |
+ void *ret; |
+ UPB_UNUSED(oldsize); |
- f->package = NULL; |
- f->name = NULL; |
- f->syntax = UPB_SYNTAX_PROTO2; |
+ from = ptr ? (void*)((char*)ptr - sizeof(mem_block)) : NULL; |
- if (!upb_refcounted_init(upb_filedef_upcast_mutable(f), &upb_filedef_vtbl, |
- owner)) { |
- goto err; |
+#ifndef NDEBUG |
+ if (from) { |
+ assert(oldsize <= from->size); |
} |
+#endif |
- if (!upb_inttable_init(&f->defs, UPB_CTYPE_CONSTPTR)) { |
- goto err; |
- } |
+ /* TODO(haberman): we probably need to provide even better alignment here, |
+ * like 16-byte alignment of the returned data pointer. */ |
+ block = realloc(from, size + sizeof(mem_block)); |
+ if (!block) return NULL; |
+ ret = (char*)block + sizeof(*block); |
- if (!upb_inttable_init(&f->deps, UPB_CTYPE_CONSTPTR)) { |
- goto err2; |
- } |
+#ifndef NDEBUG |
+ block->size = size; |
+#endif |
- return f; |
+ if (from) { |
+ if (block != from) { |
+ /* The block was moved, so pointers in next and prev blocks must be |
+ * updated to its new location. */ |
+ if (block->next) block->next->prev = block; |
+ if (block->prev) block->prev->next = block; |
+ if (ud->head == from) ud->head = block; |
+ } |
+ } else { |
+ /* Insert at head of linked list. */ |
+ block->prev = NULL; |
+ block->next = ud->head; |
+ if (block->next) block->next->prev = block; |
+ ud->head = block; |
+ } |
+ return ret; |
+} |
-err2: |
- upb_inttable_uninit(&f->defs); |
+static void default_alloc_cleanup(void *_ud) { |
+ default_alloc_ud *ud = _ud; |
+ mem_block *block = ud->head; |
-err: |
- upb_gfree(f); |
- return NULL; |
+ while (block) { |
+ void *to_free = block; |
+ block = block->next; |
+ free(to_free); |
+ } |
} |
-const char *upb_filedef_name(const upb_filedef *f) { |
- return f->name; |
-} |
-const char *upb_filedef_package(const upb_filedef *f) { |
- return f->package; |
-} |
+/* Standard error functions ***************************************************/ |
-upb_syntax_t upb_filedef_syntax(const upb_filedef *f) { |
- return f->syntax; |
+static bool default_err(void *ud, const upb_status *status) { |
+ UPB_UNUSED(ud); |
+ UPB_UNUSED(status); |
+ return false; |
} |
-size_t upb_filedef_defcount(const upb_filedef *f) { |
- return upb_inttable_count(&f->defs); |
+static bool write_err_to(void *ud, const upb_status *status) { |
+ upb_status *copy_to = ud; |
+ upb_status_copy(copy_to, status); |
+ return false; |
} |
-size_t upb_filedef_depcount(const upb_filedef *f) { |
- return upb_inttable_count(&f->deps); |
-} |
-const upb_def *upb_filedef_def(const upb_filedef *f, size_t i) { |
- upb_value v; |
+/* upb_env ********************************************************************/ |
- if (upb_inttable_lookup32(&f->defs, i, &v)) { |
- return upb_value_getconstptr(v); |
- } else { |
- return NULL; |
- } |
+void upb_env_init(upb_env *e) { |
+ default_alloc_ud *ud = (default_alloc_ud*)&e->default_alloc_ud; |
+ e->ok_ = true; |
+ e->bytes_allocated = 0; |
+ e->cleanup_head = NULL; |
+ |
+ ud->head = NULL; |
+ |
+ /* Set default functions. */ |
+ upb_env_setallocfunc(e, default_alloc, ud); |
+ upb_env_seterrorfunc(e, default_err, NULL); |
} |
-const upb_filedef *upb_filedef_dep(const upb_filedef *f, size_t i) { |
- upb_value v; |
+void upb_env_uninit(upb_env *e) { |
+ cleanup_ent *ent = e->cleanup_head; |
- if (upb_inttable_lookup32(&f->deps, i, &v)) { |
- return upb_value_getconstptr(v); |
- } else { |
- return NULL; |
+ while (ent) { |
+ ent->cleanup(ent->ud); |
+ ent = ent->next; |
} |
-} |
-bool upb_filedef_setname(upb_filedef *f, const char *name, upb_status *s) { |
- name = upb_gstrdup(name); |
- if (!name) { |
- upb_upberr_setoom(s); |
- return false; |
+ /* Must do this after running cleanup functions, because this will delete |
+ the memory we store our cleanup entries in! */ |
+ if (e->alloc == default_alloc) { |
+ default_alloc_cleanup(e->alloc_ud); |
} |
- upb_gfree((void*)f->name); |
- f->name = name; |
- return true; |
} |
-bool upb_filedef_setpackage(upb_filedef *f, const char *package, |
- upb_status *s) { |
- if (!upb_isident(package, strlen(package), true, s)) return false; |
- package = upb_gstrdup(package); |
- if (!package) { |
- upb_upberr_setoom(s); |
- return false; |
- } |
- upb_gfree((void*)f->package); |
- f->package = package; |
- return true; |
+UPB_FORCEINLINE void upb_env_setallocfunc(upb_env *e, upb_alloc_func *alloc, |
+ void *ud) { |
+ e->alloc = alloc; |
+ e->alloc_ud = ud; |
} |
-bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax, |
- upb_status *s) { |
- UPB_UNUSED(s); |
- if (syntax != UPB_SYNTAX_PROTO2 && |
- syntax != UPB_SYNTAX_PROTO3) { |
- upb_status_seterrmsg(s, "Unknown syntax value."); |
- return false; |
- } |
- f->syntax = syntax; |
+UPB_FORCEINLINE void upb_env_seterrorfunc(upb_env *e, upb_error_func *func, |
+ void *ud) { |
+ e->err = func; |
+ e->err_ud = ud; |
+} |
- { |
- /* Set all messages in this file to match. */ |
- size_t i; |
- for (i = 0; i < upb_filedef_defcount(f); i++) { |
- /* Casting const away is safe since all defs in mutable filedef must |
- * also be mutable. */ |
- upb_def *def = (upb_def*)upb_filedef_def(f, i); |
- |
- upb_msgdef *m = upb_dyncast_msgdef_mutable(def); |
- if (m) { |
- m->syntax = syntax; |
- } |
- } |
- } |
+void upb_env_reporterrorsto(upb_env *e, upb_status *status) { |
+ e->err = write_err_to; |
+ e->err_ud = status; |
+} |
- return true; |
+bool upb_env_ok(const upb_env *e) { |
+ return e->ok_; |
} |
-bool upb_filedef_adddef(upb_filedef *f, upb_def *def, const void *ref_donor, |
- upb_status *s) { |
- if (def->file) { |
- upb_status_seterrmsg(s, "Def is already part of another filedef."); |
- return false; |
- } |
+bool upb_env_reporterror(upb_env *e, const upb_status *status) { |
+ e->ok_ = false; |
+ return e->err(e->err_ud, status); |
+} |
- if (upb_inttable_push(&f->defs, upb_value_constptr(def))) { |
- def->file = f; |
- upb_ref2(def, f); |
- upb_ref2(f, def); |
- if (ref_donor) upb_def_unref(def, ref_donor); |
- if (def->type == UPB_DEF_MSG) { |
- upb_downcast_msgdef_mutable(def)->syntax = f->syntax; |
- } |
- return true; |
+bool upb_env_addcleanup(upb_env *e, upb_cleanup_func *func, void *ud) { |
+ cleanup_ent *ent = upb_env_malloc(e, sizeof(cleanup_ent)); |
+ if (!ent) return false; |
+ |
+ ent->cleanup = func; |
+ ent->ud = ud; |
+ ent->next = e->cleanup_head; |
+ e->cleanup_head = ent; |
+ |
+ return true; |
+} |
+ |
+void *upb_env_malloc(upb_env *e, size_t size) { |
+ e->bytes_allocated += size; |
+ if (e->alloc == seeded_alloc) { |
+ /* This is equivalent to the next branch, but allows inlining for a |
+ * measurable perf benefit. */ |
+ return seeded_alloc(e->alloc_ud, NULL, 0, size); |
} else { |
- upb_upberr_setoom(s); |
- return false; |
+ return e->alloc(e->alloc_ud, NULL, 0, size); |
} |
} |
-bool upb_filedef_adddep(upb_filedef *f, const upb_filedef *dep) { |
- if (upb_inttable_push(&f->deps, upb_value_constptr(dep))) { |
- /* Regular ref instead of ref2 because files can't form cycles. */ |
- upb_filedef_ref(dep, f); |
- return true; |
+void *upb_env_realloc(upb_env *e, void *ptr, size_t oldsize, size_t size) { |
+ char *ret; |
+ assert(oldsize <= size); |
+ ret = e->alloc(e->alloc_ud, ptr, oldsize, size); |
+ |
+#ifndef NDEBUG |
+ /* Overwrite non-preserved memory to ensure callers are passing the oldsize |
+ * that they truly require. */ |
+ memset(ret + oldsize, 0xff, size - oldsize); |
+#endif |
+ |
+ return ret; |
+} |
+ |
+size_t upb_env_bytesallocated(const upb_env *e) { |
+ return e->bytes_allocated; |
+} |
+ |
+ |
+/* upb_seededalloc ************************************************************/ |
+ |
+/* Be conservative and choose 16 in case anyone is using SSE. */ |
+static const size_t maxalign = 16; |
+ |
+static size_t align_up(size_t size) { |
+ return ((size + maxalign - 1) / maxalign) * maxalign; |
+} |
+ |
+UPB_FORCEINLINE static void *seeded_alloc(void *ud, void *ptr, size_t oldsize, |
+ size_t size) { |
+ upb_seededalloc *a = ud; |
+ |
+ size = align_up(size); |
+ |
+ assert(a->mem_limit >= a->mem_ptr); |
+ |
+ if (oldsize == 0 && size <= (size_t)(a->mem_limit - a->mem_ptr)) { |
+ /* Fast path: we can satisfy from the initial allocation. */ |
+ void *ret = a->mem_ptr; |
+ a->mem_ptr += size; |
+ return ret; |
} else { |
- return false; |
+ char *chptr = ptr; |
+ /* Slow path: fallback to other allocator. */ |
+ a->need_cleanup = true; |
+ /* Is `ptr` part of the user-provided initial block? Don't pass it to the |
+ * default allocator if so; otherwise, it may try to realloc() the block. */ |
+ if (chptr >= a->mem_base && chptr < a->mem_limit) { |
+ void *ret; |
+ assert(chptr + oldsize <= a->mem_limit); |
+ ret = a->alloc(a->alloc_ud, NULL, 0, size); |
+ if (ret) memcpy(ret, ptr, oldsize); |
+ return ret; |
+ } else { |
+ return a->alloc(a->alloc_ud, ptr, oldsize, size); |
+ } |
} |
} |
+ |
+void upb_seededalloc_init(upb_seededalloc *a, void *mem, size_t len) { |
+ default_alloc_ud *ud = (default_alloc_ud*)&a->default_alloc_ud; |
+ a->mem_base = mem; |
+ a->mem_ptr = mem; |
+ a->mem_limit = (char*)mem + len; |
+ a->need_cleanup = false; |
+ a->returned_allocfunc = false; |
+ |
+ ud->head = NULL; |
+ |
+ upb_seededalloc_setfallbackalloc(a, default_alloc, ud); |
+} |
+ |
+void upb_seededalloc_uninit(upb_seededalloc *a) { |
+ if (a->alloc == default_alloc && a->need_cleanup) { |
+ default_alloc_cleanup(a->alloc_ud); |
+ } |
+} |
+ |
+UPB_FORCEINLINE void upb_seededalloc_setfallbackalloc(upb_seededalloc *a, |
+ upb_alloc_func *alloc, |
+ void *ud) { |
+ assert(!a->returned_allocfunc); |
+ a->alloc = alloc; |
+ a->alloc_ud = ud; |
+} |
+ |
+upb_alloc_func *upb_seededalloc_getallocfunc(upb_seededalloc *a) { |
+ a->returned_allocfunc = true; |
+ return seeded_alloc; |
+} |
/* |
** TODO(haberman): it's unclear whether a lot of the consistency checks should |
-** UPB_ASSERT() or return false. |
+** assert() or return false. |
*/ |
+#include <stdlib.h> |
#include <string.h> |
-static void *upb_calloc(size_t size) { |
- void *mem = upb_gmalloc(size); |
- if (mem) { |
- memset(mem, 0, size); |
- } |
- return mem; |
-} |
/* Defined for the sole purpose of having a unique pointer value for |
* UPB_NO_CLOSURE. */ |
@@ -2191,8 +1996,8 @@ static void freehandlers(upb_refcounted *r) { |
upb_inttable_uninit(&h->cleanup_); |
upb_msgdef_unref(h->msg, h); |
- upb_gfree(h->sub); |
- upb_gfree(h); |
+ free(h->sub); |
+ free(h); |
} |
static void visithandlers(const upb_refcounted *r, upb_refcounted_visit *visit, |
@@ -2268,7 +2073,7 @@ oom: |
static int32_t trygetsel(upb_handlers *h, const upb_fielddef *f, |
upb_handlertype_t type) { |
upb_selector_t sel; |
- UPB_ASSERT(!upb_handlers_isfrozen(h)); |
+ assert(!upb_handlers_isfrozen(h)); |
if (upb_handlers_msgdef(h) != upb_fielddef_containingtype(f)) { |
upb_status_seterrf( |
&h->status_, "type mismatch: field %s does not belong to message %s", |
@@ -2288,7 +2093,7 @@ static int32_t trygetsel(upb_handlers *h, const upb_fielddef *f, |
static upb_selector_t handlers_getsel(upb_handlers *h, const upb_fielddef *f, |
upb_handlertype_t type) { |
int32_t sel = trygetsel(h, f, type); |
- UPB_ASSERT(sel >= 0); |
+ assert(sel >= 0); |
return sel; |
} |
@@ -2304,7 +2109,7 @@ static bool doset(upb_handlers *h, int32_t sel, const upb_fielddef *f, |
const void *closure_type; |
const void **context_closure_type; |
- UPB_ASSERT(!upb_handlers_isfrozen(h)); |
+ assert(!upb_handlers_isfrozen(h)); |
if (sel < 0) { |
upb_status_seterrmsg(&h->status_, |
@@ -2384,7 +2189,7 @@ const void *effective_closure_type(upb_handlers *h, const upb_fielddef *f, |
const void *ret; |
upb_selector_t sel; |
- UPB_ASSERT(type != UPB_HANDLER_STRING); |
+ assert(type != UPB_HANDLER_STRING); |
ret = h->top_closure_type; |
if (upb_fielddef_isseq(f) && |
@@ -2439,23 +2244,17 @@ upb_handlers *upb_handlers_new(const upb_msgdef *md, const void *owner) { |
int extra; |
upb_handlers *h; |
- UPB_ASSERT(upb_msgdef_isfrozen(md)); |
+ assert(upb_msgdef_isfrozen(md)); |
extra = sizeof(upb_handlers_tabent) * (md->selector_count - 1); |
- h = upb_calloc(sizeof(*h) + extra); |
+ h = calloc(sizeof(*h) + extra, 1); |
if (!h) return NULL; |
h->msg = md; |
upb_msgdef_ref(h->msg, h); |
upb_status_clear(&h->status_); |
- |
- if (md->submsg_field_count > 0) { |
- h->sub = upb_calloc(md->submsg_field_count * sizeof(*h->sub)); |
- if (!h->sub) goto oom; |
- } else { |
- h->sub = 0; |
- } |
- |
+ h->sub = calloc(md->submsg_field_count, sizeof(*h->sub)); |
+ if (!h->sub) goto oom; |
if (!upb_refcounted_init(upb_handlers_upcast_mutable(h), &vtbl, owner)) |
goto oom; |
if (!upb_inttable_init(&h->cleanup_, UPB_CTYPE_FPTR)) goto oom; |
@@ -2488,18 +2287,18 @@ const upb_handlers *upb_handlers_newfrozen(const upb_msgdef *m, |
r = upb_handlers_upcast_mutable(ret); |
ok = upb_refcounted_freeze(&r, 1, NULL, UPB_MAX_HANDLER_DEPTH); |
- UPB_ASSERT(ok); |
+ UPB_ASSERT_VAR(ok, ok); |
return ret; |
} |
const upb_status *upb_handlers_status(upb_handlers *h) { |
- UPB_ASSERT(!upb_handlers_isfrozen(h)); |
+ assert(!upb_handlers_isfrozen(h)); |
return &h->status_; |
} |
void upb_handlers_clearerr(upb_handlers *h) { |
- UPB_ASSERT(!upb_handlers_isfrozen(h)); |
+ assert(!upb_handlers_isfrozen(h)); |
upb_status_clear(&h->status_); |
} |
@@ -2535,16 +2334,16 @@ bool upb_handlers_setstartmsg(upb_handlers *h, upb_startmsg_handlerfunc *func, |
bool upb_handlers_setendmsg(upb_handlers *h, upb_endmsg_handlerfunc *func, |
upb_handlerattr *attr) { |
- UPB_ASSERT(!upb_handlers_isfrozen(h)); |
+ assert(!upb_handlers_isfrozen(h)); |
return doset(h, UPB_ENDMSG_SELECTOR, NULL, UPB_HANDLER_INT32, |
(upb_func *)func, attr); |
} |
bool upb_handlers_setsubhandlers(upb_handlers *h, const upb_fielddef *f, |
const upb_handlers *sub) { |
- UPB_ASSERT(sub); |
- UPB_ASSERT(!upb_handlers_isfrozen(h)); |
- UPB_ASSERT(upb_fielddef_issubmsg(f)); |
+ assert(sub); |
+ assert(!upb_handlers_isfrozen(h)); |
+ assert(upb_fielddef_issubmsg(f)); |
if (SUBH_F(h, f)) return false; /* Can't reset. */ |
if (upb_msgdef_upcast(upb_handlers_msgdef(sub)) != upb_fielddef_subdef(f)) { |
return false; |
@@ -2556,7 +2355,7 @@ bool upb_handlers_setsubhandlers(upb_handlers *h, const upb_fielddef *f, |
const upb_handlers *upb_handlers_getsubhandlers(const upb_handlers *h, |
const upb_fielddef *f) { |
- UPB_ASSERT(upb_fielddef_issubmsg(f)); |
+ assert(upb_fielddef_issubmsg(f)); |
return SUBH_F(h, f); |
} |
@@ -2582,7 +2381,7 @@ bool upb_handlers_addcleanup(upb_handlers *h, void *p, upb_handlerfree *func) { |
return false; |
} |
ok = upb_inttable_insertptr(&h->cleanup_, p, upb_value_fptr(func)); |
- UPB_ASSERT(ok); |
+ UPB_ASSERT_VAR(ok, ok); |
return true; |
} |
@@ -2683,7 +2482,7 @@ upb_handlertype_t upb_handlers_getprimitivehandlertype(const upb_fielddef *f) { |
case UPB_TYPE_FLOAT: return UPB_HANDLER_FLOAT; |
case UPB_TYPE_DOUBLE: return UPB_HANDLER_DOUBLE; |
case UPB_TYPE_BOOL: return UPB_HANDLER_BOOL; |
- default: UPB_ASSERT(false); return -1; /* Invalid input. */ |
+ default: assert(false); return -1; /* Invalid input. */ |
} |
} |
@@ -2746,7 +2545,7 @@ bool upb_handlers_getselector(const upb_fielddef *f, upb_handlertype_t type, |
*s = f->selector_base; |
break; |
} |
- UPB_ASSERT((size_t)*s < upb_fielddef_containingtype(f)->selector_count); |
+ assert((size_t)*s < upb_fielddef_containingtype(f)->selector_count); |
return true; |
} |
@@ -2870,6 +2669,7 @@ bool upb_byteshandler_setendstr(upb_byteshandler *h, |
#include <setjmp.h> |
+#include <stdlib.h> |
static void freeobj(upb_refcounted *o); |
@@ -2945,31 +2745,8 @@ void upb_unlock(); |
/* UPB_DEBUG_REFS mode counts on being able to malloc() memory in some |
* code-paths that can normally never fail, like upb_refcounted_ref(). Since |
* we have no way to propagage out-of-memory errors back to the user, and since |
- * these errors can only occur in UPB_DEBUG_REFS mode, we use an allocator that |
- * immediately aborts on failure (avoiding the global allocator, which might |
- * inject failures). */ |
- |
-#include <stdlib.h> |
- |
-static void *upb_debugrefs_allocfunc(upb_alloc *alloc, void *ptr, |
- size_t oldsize, size_t size) { |
- UPB_UNUSED(alloc); |
- UPB_UNUSED(oldsize); |
- if (size == 0) { |
- free(ptr); |
- return NULL; |
- } else { |
- void *ret = realloc(ptr, size); |
- |
- if (!ret) { |
- abort(); |
- } |
- |
- return ret; |
- } |
-} |
- |
-upb_alloc upb_alloc_debugrefs = {&upb_debugrefs_allocfunc}; |
+ * these errors can only occur in UPB_DEBUG_REFS mode, we immediately fail. */ |
+#define CHECK_OOM(predicate) if (!(predicate)) { assert(predicate); exit(1); } |
typedef struct { |
int count; /* How many refs there are (duplicates only allowed for ref2). */ |
@@ -2977,7 +2754,8 @@ typedef struct { |
} trackedref; |
static trackedref *trackedref_new(bool is_ref2) { |
- trackedref *ret = upb_malloc(&upb_alloc_debugrefs, sizeof(*ret)); |
+ trackedref *ret = malloc(sizeof(*ret)); |
+ CHECK_OOM(ret); |
ret->count = 1; |
ret->is_ref2 = is_ref2; |
return ret; |
@@ -2986,7 +2764,7 @@ static trackedref *trackedref_new(bool is_ref2) { |
static void track(const upb_refcounted *r, const void *owner, bool ref2) { |
upb_value v; |
- UPB_ASSERT(owner); |
+ assert(owner); |
if (owner == UPB_UNTRACKED_REF) return; |
upb_lock(); |
@@ -2997,20 +2775,20 @@ static void track(const upb_refcounted *r, const void *owner, bool ref2) { |
* tracking behavior we get with regular refs. Since ref2s only happen |
* inside upb, we'll accept this limitation until/unless there is a really |
* difficult upb-internal bug that can't be figured out without it. */ |
- UPB_ASSERT(ref2); |
- UPB_ASSERT(ref->is_ref2); |
+ assert(ref2); |
+ assert(ref->is_ref2); |
ref->count++; |
} else { |
trackedref *ref = trackedref_new(ref2); |
- upb_inttable_insertptr2(r->refs, owner, upb_value_ptr(ref), |
- &upb_alloc_debugrefs); |
+ bool ok = upb_inttable_insertptr(r->refs, owner, upb_value_ptr(ref)); |
+ CHECK_OOM(ok); |
if (ref2) { |
/* We know this cast is safe when it is a ref2, because it's coming from |
* another refcounted object. */ |
const upb_refcounted *from = owner; |
- UPB_ASSERT(!upb_inttable_lookupptr(from->ref2s, r, NULL)); |
- upb_inttable_insertptr2(from->ref2s, r, upb_value_ptr(NULL), |
- &upb_alloc_debugrefs); |
+ assert(!upb_inttable_lookupptr(from->ref2s, r, NULL)); |
+ ok = upb_inttable_insertptr(from->ref2s, r, upb_value_ptr(NULL)); |
+ CHECK_OOM(ok); |
} |
} |
upb_unlock(); |
@@ -3021,15 +2799,15 @@ static void untrack(const upb_refcounted *r, const void *owner, bool ref2) { |
bool found; |
trackedref *ref; |
- UPB_ASSERT(owner); |
+ assert(owner); |
if (owner == UPB_UNTRACKED_REF) return; |
upb_lock(); |
found = upb_inttable_lookupptr(r->refs, owner, &v); |
/* This assert will fail if an owner attempts to release a ref it didn't have. */ |
- UPB_ASSERT(found); |
+ UPB_ASSERT_VAR(found, found); |
ref = upb_value_getptr(v); |
- UPB_ASSERT(ref->is_ref2 == ref2); |
+ assert(ref->is_ref2 == ref2); |
if (--ref->count == 0) { |
free(ref); |
upb_inttable_removeptr(r->refs, owner, NULL); |
@@ -3038,7 +2816,7 @@ static void untrack(const upb_refcounted *r, const void *owner, bool ref2) { |
* another refcounted object. */ |
const upb_refcounted *from = owner; |
bool removed = upb_inttable_removeptr(from->ref2s, r, NULL); |
- UPB_ASSERT(removed); |
+ assert(removed); |
} |
} |
upb_unlock(); |
@@ -3051,9 +2829,9 @@ static void checkref(const upb_refcounted *r, const void *owner, bool ref2) { |
upb_lock(); |
found = upb_inttable_lookupptr(r->refs, owner, &v); |
- UPB_ASSERT(found); |
+ UPB_ASSERT_VAR(found, found); |
ref = upb_value_getptr(v); |
- UPB_ASSERT(ref->is_ref2 == ref2); |
+ assert(ref->is_ref2 == ref2); |
upb_unlock(); |
} |
@@ -3068,17 +2846,19 @@ static void getref2s(const upb_refcounted *owner, upb_inttable *tab) { |
upb_value v; |
upb_value count; |
trackedref *ref; |
+ bool ok; |
bool found; |
upb_refcounted *to = (upb_refcounted*)upb_inttable_iter_key(&i); |
/* To get the count we need to look in the target's table. */ |
found = upb_inttable_lookupptr(to->refs, owner, &v); |
- UPB_ASSERT(found); |
+ assert(found); |
ref = upb_value_getptr(v); |
count = upb_value_int32(ref->count); |
- upb_inttable_insertptr2(tab, to, count, &upb_alloc_debugrefs); |
+ ok = upb_inttable_insertptr(tab, to, count); |
+ CHECK_OOM(ok); |
} |
upb_unlock(); |
} |
@@ -3096,50 +2876,62 @@ static void visit_check(const upb_refcounted *obj, const upb_refcounted *subobj, |
bool removed; |
int32_t newcount; |
- UPB_ASSERT(obj == s->obj); |
- UPB_ASSERT(subobj); |
+ assert(obj == s->obj); |
+ assert(subobj); |
removed = upb_inttable_removeptr(ref2, subobj, &v); |
/* The following assertion will fail if the visit() function visits a subobj |
* that it did not have a ref2 on, or visits the same subobj too many times. */ |
- UPB_ASSERT(removed); |
+ assert(removed); |
newcount = upb_value_getint32(v) - 1; |
if (newcount > 0) { |
- upb_inttable_insert2(ref2, (uintptr_t)subobj, upb_value_int32(newcount), |
- &upb_alloc_debugrefs); |
+ upb_inttable_insert(ref2, (uintptr_t)subobj, upb_value_int32(newcount)); |
} |
} |
static void visit(const upb_refcounted *r, upb_refcounted_visit *v, |
void *closure) { |
+ bool ok; |
+ |
/* In DEBUG_REFS mode we know what existing ref2 refs there are, so we know |
* exactly the set of nodes that visit() should visit. So we verify visit()'s |
* correctness here. */ |
check_state state; |
state.obj = r; |
- upb_inttable_init2(&state.ref2, UPB_CTYPE_INT32, &upb_alloc_debugrefs); |
+ ok = upb_inttable_init(&state.ref2, UPB_CTYPE_INT32); |
+ CHECK_OOM(ok); |
getref2s(r, &state.ref2); |
/* This should visit any children in the ref2 table. */ |
if (r->vtbl->visit) r->vtbl->visit(r, visit_check, &state); |
/* This assertion will fail if the visit() function missed any children. */ |
- UPB_ASSERT(upb_inttable_count(&state.ref2) == 0); |
- upb_inttable_uninit2(&state.ref2, &upb_alloc_debugrefs); |
+ assert(upb_inttable_count(&state.ref2) == 0); |
+ upb_inttable_uninit(&state.ref2); |
if (r->vtbl->visit) r->vtbl->visit(r, v, closure); |
} |
-static void trackinit(upb_refcounted *r) { |
- r->refs = upb_malloc(&upb_alloc_debugrefs, sizeof(*r->refs)); |
- r->ref2s = upb_malloc(&upb_alloc_debugrefs, sizeof(*r->ref2s)); |
- upb_inttable_init2(r->refs, UPB_CTYPE_PTR, &upb_alloc_debugrefs); |
- upb_inttable_init2(r->ref2s, UPB_CTYPE_PTR, &upb_alloc_debugrefs); |
+static bool trackinit(upb_refcounted *r) { |
+ r->refs = malloc(sizeof(*r->refs)); |
+ r->ref2s = malloc(sizeof(*r->ref2s)); |
+ if (!r->refs || !r->ref2s) goto err1; |
+ |
+ if (!upb_inttable_init(r->refs, UPB_CTYPE_PTR)) goto err1; |
+ if (!upb_inttable_init(r->ref2s, UPB_CTYPE_PTR)) goto err2; |
+ return true; |
+ |
+err2: |
+ upb_inttable_uninit(r->refs); |
+err1: |
+ free(r->refs); |
+ free(r->ref2s); |
+ return false; |
} |
static void trackfree(const upb_refcounted *r) { |
- upb_inttable_uninit2(r->refs, &upb_alloc_debugrefs); |
- upb_inttable_uninit2(r->ref2s, &upb_alloc_debugrefs); |
- upb_free(&upb_alloc_debugrefs, r->refs); |
- upb_free(&upb_alloc_debugrefs, r->ref2s); |
+ upb_inttable_uninit(r->refs); |
+ upb_inttable_uninit(r->ref2s); |
+ free(r->refs); |
+ free(r->ref2s); |
} |
#else |
@@ -3162,8 +2954,9 @@ static void checkref(const upb_refcounted *r, const void *owner, bool ref2) { |
UPB_UNUSED(ref2); |
} |
-static void trackinit(upb_refcounted *r) { |
+static bool trackinit(upb_refcounted *r) { |
UPB_UNUSED(r); |
+ return true; |
} |
static void trackfree(const upb_refcounted *r) { |
@@ -3230,7 +3023,7 @@ static uint64_t trygetattr(const tarjan *t, const upb_refcounted *r) { |
static uint64_t getattr(const tarjan *t, const upb_refcounted *r) { |
upb_value v; |
bool found = upb_inttable_lookupptr(&t->objattr, r, &v); |
- UPB_ASSERT(found); |
+ UPB_ASSERT_VAR(found, found); |
return upb_value_getuint64(v); |
} |
@@ -3244,13 +3037,13 @@ static color_t color(tarjan *t, const upb_refcounted *r) { |
} |
static void set_gray(tarjan *t, const upb_refcounted *r) { |
- UPB_ASSERT(color(t, r) == BLACK); |
+ assert(color(t, r) == BLACK); |
setattr(t, r, GRAY); |
} |
/* Pushes an obj onto the Tarjan stack and sets it to GREEN. */ |
static void push(tarjan *t, const upb_refcounted *r) { |
- UPB_ASSERT(color(t, r) == BLACK || color(t, r) == GRAY); |
+ assert(color(t, r) == BLACK || color(t, r) == GRAY); |
/* This defines the attr layout for the GREEN state. "index" and "lowlink" |
* get 31 bits, which is plenty (limit of 2B objects frozen at a time). */ |
setattr(t, r, GREEN | (t->index << 2) | (t->index << 33)); |
@@ -3265,7 +3058,7 @@ static void push(tarjan *t, const upb_refcounted *r) { |
* SCC group. */ |
static upb_refcounted *pop(tarjan *t) { |
upb_refcounted *r = upb_value_getptr(upb_inttable_pop(&t->stack)); |
- UPB_ASSERT(color(t, r) == GREEN); |
+ assert(color(t, r) == GREEN); |
/* This defines the attr layout for nodes in the WHITE state. |
* Top of group stack is [group, NULL]; we point at group. */ |
setattr(t, r, WHITE | (upb_inttable_count(&t->groups) - 2) << 8); |
@@ -3273,19 +3066,19 @@ static upb_refcounted *pop(tarjan *t) { |
} |
static void tarjan_newgroup(tarjan *t) { |
- uint32_t *group = upb_gmalloc(sizeof(*group)); |
+ uint32_t *group = malloc(sizeof(*group)); |
if (!group) oom(t); |
/* Push group and empty group leader (we'll fill in leader later). */ |
if (!upb_inttable_push(&t->groups, upb_value_ptr(group)) || |
!upb_inttable_push(&t->groups, upb_value_ptr(NULL))) { |
- upb_gfree(group); |
+ free(group); |
oom(t); |
} |
*group = 0; |
} |
static uint32_t idx(tarjan *t, const upb_refcounted *r) { |
- UPB_ASSERT(color(t, r) == GREEN); |
+ assert(color(t, r) == GREEN); |
return (getattr(t, r) >> 2) & 0x7FFFFFFF; |
} |
@@ -3298,7 +3091,7 @@ static uint32_t lowlink(tarjan *t, const upb_refcounted *r) { |
} |
static void set_lowlink(tarjan *t, const upb_refcounted *r, uint32_t lowlink) { |
- UPB_ASSERT(color(t, r) == GREEN); |
+ assert(color(t, r) == GREEN); |
setattr(t, r, ((uint64_t)lowlink << 33) | (getattr(t, r) & 0x1FFFFFFFF)); |
} |
@@ -3307,10 +3100,10 @@ static uint32_t *group(tarjan *t, upb_refcounted *r) { |
upb_value v; |
bool found; |
- UPB_ASSERT(color(t, r) == WHITE); |
+ assert(color(t, r) == WHITE); |
groupnum = getattr(t, r) >> 8; |
found = upb_inttable_lookup(&t->groups, groupnum, &v); |
- UPB_ASSERT(found); |
+ UPB_ASSERT_VAR(found, found); |
return upb_value_getptr(v); |
} |
@@ -3321,10 +3114,10 @@ static upb_refcounted *groupleader(tarjan *t, upb_refcounted *r) { |
upb_value v; |
bool found; |
- UPB_ASSERT(color(t, r) == WHITE); |
+ assert(color(t, r) == WHITE); |
leader_slot = (getattr(t, r) >> 8) + 1; |
found = upb_inttable_lookup(&t->groups, leader_slot, &v); |
- UPB_ASSERT(found); |
+ UPB_ASSERT_VAR(found, found); |
if (upb_value_getptr(v)) { |
return upb_value_getptr(v); |
} else { |
@@ -3384,7 +3177,7 @@ static void do_tarjan(const upb_refcounted *obj, tarjan *t) { |
static void crossref(const upb_refcounted *r, const upb_refcounted *subobj, |
void *_t) { |
tarjan *t = _t; |
- UPB_ASSERT(color(t, r) > BLACK); |
+ assert(color(t, r) > BLACK); |
if (color(t, subobj) > BLACK && r->group != subobj->group) { |
/* Previously this ref was not reflected in subobj->group because they |
* were in the same group; now that they are split a ref must be taken. */ |
@@ -3452,13 +3245,13 @@ static bool freeze(upb_refcounted *const*roots, int n, upb_status *s, |
upb_refcounted *move = obj->next; |
if (obj == move) { |
/* Removing the last object from a group. */ |
- UPB_ASSERT(*obj->group == obj->individual_count); |
- upb_gfree(obj->group); |
+ assert(*obj->group == obj->individual_count); |
+ free(obj->group); |
} else { |
obj->next = move->next; |
/* This may decrease to zero; we'll collect GRAY objects (if any) that |
* remain in the group in the third pass. */ |
- UPB_ASSERT(*move->group >= move->individual_count); |
+ assert(*move->group >= move->individual_count); |
*move->group -= move->individual_count; |
} |
@@ -3471,7 +3264,7 @@ static bool freeze(upb_refcounted *const*roots, int n, upb_status *s, |
*move->group = move->individual_count; |
} else { |
/* Group already has at least one object in it. */ |
- UPB_ASSERT(leader->group == group(&t, move)); |
+ assert(leader->group == group(&t, move)); |
move->group = group(&t, move); |
move->next = leader->next; |
leader->next = move; |
@@ -3509,7 +3302,7 @@ static bool freeze(upb_refcounted *const*roots, int n, upb_status *s, |
/* We eagerly free() the group's count (since we can't easily determine |
* the group's remaining size it's the easiest way to ensure it gets |
* done). */ |
- upb_gfree(obj->group); |
+ free(obj->group); |
/* Visit to release ref2's (done in a separate pass since release_ref2 |
* depends on o->group being unmodified so it can test merged()). */ |
@@ -3529,7 +3322,7 @@ err4: |
if (!ret) { |
upb_inttable_begin(&iter, &t.groups); |
for(; !upb_inttable_done(&iter); upb_inttable_next(&iter)) |
- upb_gfree(upb_value_getptr(upb_inttable_iter_value(&iter))); |
+ free(upb_value_getptr(upb_inttable_iter_value(&iter))); |
} |
upb_inttable_uninit(&t.groups); |
err3: |
@@ -3553,7 +3346,7 @@ static void merge(upb_refcounted *r, upb_refcounted *from) { |
if (merged(r, from)) return; |
*r->group += *from->group; |
- upb_gfree(from->group); |
+ free(from->group); |
base = from; |
/* Set all refcount pointers in the "from" chain to the merged refcount. |
@@ -3561,7 +3354,7 @@ static void merge(upb_refcounted *r, upb_refcounted *from) { |
* TODO(haberman): this linear algorithm can result in an overall O(n^2) bound |
* if the user continuously extends a group by one object. Prevent this by |
* using one of the techniques in this paper: |
- * http://bioinfo.ict.ac.cn/~dbu/AlgorithmCourses/Lectures/Union-Find-Tarjan.pdf */ |
+ * ftp://www.ncedc.org/outgoing/geomorph/dino/orals/p245-tarjan.pdf */ |
do { from->group = r->group; } while ((from = from->next) != base); |
/* Merge the two circularly linked lists by swapping their next pointers. */ |
@@ -3578,7 +3371,7 @@ static void release_ref2(const upb_refcounted *obj, |
UPB_UNUSED(closure); |
untrack(subobj, obj, true); |
if (!merged(obj, subobj)) { |
- UPB_ASSERT(subobj->is_frozen); |
+ assert(subobj->is_frozen); |
unref(subobj); |
} |
} |
@@ -3587,7 +3380,7 @@ static void unref(const upb_refcounted *r) { |
if (unrefgroup(r->group)) { |
const upb_refcounted *o; |
- upb_gfree(r->group); |
+ free(r->group); |
/* In two passes, since release_ref2 needs a guarantee that any subobjs |
* are alive. */ |
@@ -3597,7 +3390,7 @@ static void unref(const upb_refcounted *r) { |
o = r; |
do { |
const upb_refcounted *next = o->next; |
- UPB_ASSERT(o->is_frozen || o->individual_count == 0); |
+ assert(o->is_frozen || o->individual_count == 0); |
freeobj((upb_refcounted*)o); |
o = next; |
} while(o != r); |
@@ -3621,9 +3414,9 @@ bool upb_refcounted_init(upb_refcounted *r, |
* basically every program using upb. */ |
const int x = 1; |
#ifdef UPB_BIG_ENDIAN |
- UPB_ASSERT(*(char*)&x != 1); |
+ assert(*(char*)&x != 1); |
#else |
- UPB_ASSERT(*(char*)&x == 1); |
+ assert(*(char*)&x == 1); |
#endif |
#endif |
@@ -3631,10 +3424,13 @@ bool upb_refcounted_init(upb_refcounted *r, |
r->vtbl = vtbl; |
r->individual_count = 0; |
r->is_frozen = false; |
- r->group = upb_gmalloc(sizeof(*r->group)); |
+ r->group = malloc(sizeof(*r->group)); |
if (!r->group) return false; |
*r->group = 0; |
- trackinit(r); |
+ if (!trackinit(r)) { |
+ free(r->group); |
+ return false; |
+ } |
upb_refcounted_ref(r, owner); |
return true; |
} |
@@ -3658,7 +3454,7 @@ void upb_refcounted_unref(const upb_refcounted *r, const void *owner) { |
} |
void upb_refcounted_ref2(const upb_refcounted *r, upb_refcounted *from) { |
- UPB_ASSERT(!from->is_frozen); /* Non-const pointer implies this. */ |
+ assert(!from->is_frozen); /* Non-const pointer implies this. */ |
track(r, from, true); |
if (r->is_frozen) { |
refgroup(r->group); |
@@ -3668,18 +3464,18 @@ void upb_refcounted_ref2(const upb_refcounted *r, upb_refcounted *from) { |
} |
void upb_refcounted_unref2(const upb_refcounted *r, upb_refcounted *from) { |
- UPB_ASSERT(!from->is_frozen); /* Non-const pointer implies this. */ |
+ assert(!from->is_frozen); /* Non-const pointer implies this. */ |
untrack(r, from, true); |
if (r->is_frozen) { |
unref(r); |
} else { |
- UPB_ASSERT(merged(r, from)); |
+ assert(merged(r, from)); |
} |
} |
void upb_refcounted_donateref( |
const upb_refcounted *r, const void *from, const void *to) { |
- UPB_ASSERT(from != to); |
+ assert(from != to); |
if (to != NULL) |
upb_refcounted_ref(r, to); |
if (from != NULL) |
@@ -3693,16 +3489,15 @@ void upb_refcounted_checkref(const upb_refcounted *r, const void *owner) { |
bool upb_refcounted_freeze(upb_refcounted *const*roots, int n, upb_status *s, |
int maxdepth) { |
int i; |
- bool ret; |
for (i = 0; i < n; i++) { |
- UPB_ASSERT(!roots[i]->is_frozen); |
+ assert(!roots[i]->is_frozen); |
} |
- ret = freeze(roots, n, s, maxdepth); |
- UPB_ASSERT(!s || ret == upb_ok(s)); |
- return ret; |
+ return freeze(roots, n, s, maxdepth); |
} |
+#include <stdlib.h> |
+ |
/* Fallback implementation if the shim is not specialized by the JIT. */ |
#define SHIM_WRITER(type, ctype) \ |
bool upb_shim_set ## type (void *c, const void *hd, ctype val) { \ |
@@ -3728,14 +3523,14 @@ bool upb_shim_set(upb_handlers *h, const upb_fielddef *f, size_t offset, |
upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER; |
bool ok; |
- upb_shim_data *d = upb_gmalloc(sizeof(*d)); |
+ upb_shim_data *d = malloc(sizeof(*d)); |
if (!d) return false; |
d->offset = offset; |
d->hasbit = hasbit; |
upb_handlerattr_sethandlerdata(&attr, d); |
upb_handlerattr_setalwaysok(&attr, true); |
- upb_handlers_addcleanup(h, d, upb_gfree); |
+ upb_handlers_addcleanup(h, d, free); |
#define TYPE(u, l) \ |
case UPB_TYPE_##u: \ |
@@ -3752,7 +3547,7 @@ bool upb_shim_set(upb_handlers *h, const upb_fielddef *f, size_t offset, |
TYPE(DOUBLE, double); |
TYPE(FLOAT, float); |
TYPE(BOOL, bool); |
- default: UPB_ASSERT(false); break; |
+ default: assert(false); break; |
} |
#undef TYPE |
@@ -3786,6 +3581,7 @@ const upb_shim_data *upb_shim_getdata(const upb_handlers *h, upb_selector_t s, |
} |
+#include <stdlib.h> |
#include <string.h> |
static void upb_symtab_free(upb_refcounted *r) { |
@@ -3797,17 +3593,13 @@ static void upb_symtab_free(upb_refcounted *r) { |
upb_def_unref(def, s); |
} |
upb_strtable_uninit(&s->symtab); |
- upb_gfree(s); |
+ free(s); |
} |
+ |
upb_symtab *upb_symtab_new(const void *owner) { |
static const struct upb_refcounted_vtbl vtbl = {NULL, &upb_symtab_free}; |
- |
- upb_symtab *s = upb_gmalloc(sizeof(*s)); |
- if (!s) { |
- return NULL; |
- } |
- |
+ upb_symtab *s = malloc(sizeof(*s)); |
upb_refcounted_init(upb_symtab_upcast_mutable(s), &vtbl, owner); |
upb_strtable_init(&s->symtab, UPB_CTYPE_PTR); |
return s; |
@@ -3817,13 +3609,13 @@ void upb_symtab_freeze(upb_symtab *s) { |
upb_refcounted *r; |
bool ok; |
- UPB_ASSERT(!upb_symtab_isfrozen(s)); |
+ assert(!upb_symtab_isfrozen(s)); |
r = upb_symtab_upcast_mutable(s); |
/* The symtab does not take ref2's (see refcounted.h) on the defs, because |
* defs cannot refer back to the table and therefore cannot create cycles. So |
* 0 will suffice for maxdepth here. */ |
ok = upb_refcounted_freeze(&r, 1, NULL, 0); |
- UPB_ASSERT(ok); |
+ UPB_ASSERT_VAR(ok, ok); |
} |
const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym) { |
@@ -3861,7 +3653,7 @@ static upb_def *upb_resolvename(const upb_strtable *t, |
/* Remove components from base until we find an entry or run out. |
* TODO: This branch is totally broken, but currently not used. */ |
(void)base; |
- UPB_ASSERT(false); |
+ assert(false); |
return NULL; |
} |
} |
@@ -3923,7 +3715,7 @@ static bool upb_resolve_dfs(const upb_def *def, upb_strtable *addtab, |
upb_value v; |
const upb_msgdef *m; |
- UPB_ASSERT(upb_def_isfrozen(def)); |
+ assert(upb_def_isfrozen(def)); |
if (def->type == UPB_DEF_FIELD) continue; |
if (upb_strtable_lookup(addtab, upb_def_fullname(def), &v)) { |
need_dup = true; |
@@ -3981,24 +3773,15 @@ oom: |
/* TODO(haberman): we need a lot more testing of error conditions. |
* The came_from_user stuff in particular is not tested. */ |
-static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, |
- void *ref_donor, upb_refcounted *freeze_also, |
- upb_status *status) { |
- size_t i; |
- size_t add_n; |
- size_t freeze_n; |
+bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, int n, void *ref_donor, |
+ upb_status *status) { |
+ int i; |
upb_strtable_iter iter; |
- upb_refcounted **add_objs = NULL; |
upb_def **add_defs = NULL; |
- size_t add_objs_size; |
upb_strtable addtab; |
upb_inttable seen; |
- if (n == 0 && !freeze_also) { |
- return true; |
- } |
- |
- UPB_ASSERT(!upb_symtab_isfrozen(s)); |
+ assert(!upb_symtab_isfrozen(s)); |
if (!upb_strtable_init(&addtab, UPB_CTYPE_PTR)) { |
upb_status_seterrmsg(status, "out of memory"); |
return false; |
@@ -4014,7 +3797,7 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, |
upb_status_seterrmsg(status, "added defs must be mutable"); |
goto err; |
} |
- UPB_ASSERT(!upb_def_isfrozen(def)); |
+ assert(!upb_def_isfrozen(def)); |
fullname = upb_def_fullname(def); |
if (!fullname) { |
upb_status_seterrmsg( |
@@ -4058,7 +3841,7 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, |
if (!f) continue; |
msgname = upb_fielddef_containingtypename(f); |
/* We validated this earlier in this function. */ |
- UPB_ASSERT(msgname); |
+ assert(msgname); |
/* If the extendee name is absolutely qualified, move past the initial ".". |
* TODO(haberman): it is not obvious what it would mean if this was not |
@@ -4139,38 +3922,15 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, |
} |
} |
- /* We need an array of the defs in addtab, for passing to |
- * upb_refcounted_freeze(). */ |
- add_objs_size = upb_strtable_count(&addtab); |
- if (freeze_also) { |
- add_objs_size++; |
- } |
- |
- add_defs = upb_gmalloc(sizeof(void*) * add_objs_size); |
+ /* We need an array of the defs in addtab, for passing to upb_def_freeze. */ |
+ add_defs = malloc(sizeof(void*) * upb_strtable_count(&addtab)); |
if (add_defs == NULL) goto oom_err; |
upb_strtable_begin(&iter, &addtab); |
- for (add_n = 0; !upb_strtable_done(&iter); upb_strtable_next(&iter)) { |
- add_defs[add_n++] = upb_value_getptr(upb_strtable_iter_value(&iter)); |
- } |
- |
- /* Validate defs. */ |
- if (!_upb_def_validate(add_defs, add_n, status)) { |
- goto err; |
- } |
- |
- /* Cheat a little and give the array a new type. |
- * This is probably undefined behavior, but this code will be deleted soon. */ |
- add_objs = (upb_refcounted**)add_defs; |
- |
- freeze_n = add_n; |
- if (freeze_also) { |
- add_objs[freeze_n++] = freeze_also; |
+ for (n = 0; !upb_strtable_done(&iter); upb_strtable_next(&iter)) { |
+ add_defs[n++] = upb_value_getptr(upb_strtable_iter_value(&iter)); |
} |
- if (!upb_refcounted_freeze(add_objs, freeze_n, status, |
- UPB_MAX_MESSAGE_DEPTH * 2)) { |
- goto err; |
- } |
+ if (!upb_def_freeze(add_defs, n, status)) goto err; |
/* This must be delayed until all errors have been detected, since error |
* recovery code uses this table to cleanup defs. */ |
@@ -4178,8 +3938,8 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, |
/* TODO(haberman) we don't properly handle errors after this point (like |
* OOM in upb_strtable_insert() below). */ |
- for (i = 0; i < add_n; i++) { |
- upb_def *def = (upb_def*)add_objs[i]; |
+ for (i = 0; i < n; i++) { |
+ upb_def *def = add_defs[i]; |
const char *name = upb_def_fullname(def); |
upb_value v; |
bool success; |
@@ -4189,9 +3949,9 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, |
upb_def_unref(def, s); |
} |
success = upb_strtable_insert(&s->symtab, name, upb_value_ptr(def)); |
- UPB_ASSERT(success == true); |
+ UPB_ASSERT_VAR(success, success == true); |
} |
- upb_gfree(add_defs); |
+ free(add_defs); |
return true; |
oom_err: |
@@ -4212,40 +3972,11 @@ err: { |
} |
} |
upb_strtable_uninit(&addtab); |
- upb_gfree(add_defs); |
- UPB_ASSERT(!upb_ok(status)); |
+ free(add_defs); |
+ assert(!upb_ok(status)); |
return false; |
} |
-bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, |
- void *ref_donor, upb_status *status) { |
- return symtab_add(s, defs, n, ref_donor, NULL, status); |
-} |
- |
-bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status *status) { |
- size_t n; |
- size_t i; |
- upb_def **defs; |
- bool ret; |
- |
- n = upb_filedef_defcount(file); |
- defs = upb_gmalloc(sizeof(*defs) * n); |
- |
- if (defs == NULL) { |
- upb_status_seterrmsg(status, "Out of memory"); |
- return false; |
- } |
- |
- for (i = 0; i < n; i++) { |
- defs[i] = upb_filedef_mutabledef(file, i); |
- } |
- |
- ret = symtab_add(s, defs, n, NULL, upb_filedef_upcast_mutable(file), status); |
- |
- upb_gfree(defs); |
- return ret; |
-} |
- |
/* Iteration. */ |
static void advance_to_matching(upb_symtab_iter *iter) { |
@@ -4284,6 +4015,7 @@ const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter) { |
*/ |
+#include <stdlib.h> |
#include <string.h> |
#define UPB_MAXARRSIZE 16 /* 64k. */ |
@@ -4292,12 +4024,6 @@ const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter) { |
#define ARRAY_SIZE(x) \ |
((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) |
-static void upb_check_alloc(upb_table *t, upb_alloc *a) { |
- UPB_UNUSED(t); |
- UPB_UNUSED(a); |
- UPB_ASSERT_DEBUGVAR(t->alloc == a); |
-} |
- |
static const double MAX_LOAD = 0.85; |
/* The minimum utilization of the array part of a mixed hash/array table. This |
@@ -4315,11 +4041,11 @@ int log2ceil(uint64_t v) { |
return UPB_MIN(UPB_MAXARRSIZE, ret); |
} |
-char *upb_strdup(const char *s, upb_alloc *a) { |
- return upb_strdup2(s, strlen(s), a); |
+char *upb_strdup(const char *s) { |
+ return upb_strdup2(s, strlen(s)); |
} |
-char *upb_strdup2(const char *s, size_t len, upb_alloc *a) { |
+char *upb_strdup2(const char *s, size_t len) { |
size_t n; |
char *p; |
@@ -4328,7 +4054,7 @@ char *upb_strdup2(const char *s, size_t len, upb_alloc *a) { |
/* Always null-terminate, even if binary data; but don't rely on the input to |
* have a null-terminating byte since it may be a raw binary buffer. */ |
n = len + 1; |
- p = upb_malloc(a, n); |
+ p = malloc(n); |
if (p) { |
memcpy(p, s, len); |
p[len] = 0; |
@@ -4369,27 +4095,19 @@ static upb_tabent *mutable_entries(upb_table *t) { |
} |
static bool isfull(upb_table *t) { |
- if (upb_table_size(t) == 0) { |
- return true; |
- } else { |
- return ((double)(t->count + 1) / upb_table_size(t)) > MAX_LOAD; |
- } |
+ return (double)(t->count + 1) / upb_table_size(t) > MAX_LOAD; |
} |
-static bool init(upb_table *t, upb_ctype_t ctype, uint8_t size_lg2, |
- upb_alloc *a) { |
+static bool init(upb_table *t, upb_ctype_t ctype, uint8_t size_lg2) { |
size_t bytes; |
t->count = 0; |
t->ctype = ctype; |
t->size_lg2 = size_lg2; |
t->mask = upb_table_size(t) ? upb_table_size(t) - 1 : 0; |
-#ifndef NDEBUG |
- t->alloc = a; |
-#endif |
bytes = upb_table_size(t) * sizeof(upb_tabent); |
if (bytes > 0) { |
- t->entries = upb_malloc(a, bytes); |
+ t->entries = malloc(bytes); |
if (!t->entries) return false; |
memset(mutable_entries(t), 0, bytes); |
} else { |
@@ -4398,14 +4116,11 @@ static bool init(upb_table *t, upb_ctype_t ctype, uint8_t size_lg2, |
return true; |
} |
-static void uninit(upb_table *t, upb_alloc *a) { |
- upb_check_alloc(t, a); |
- upb_free(a, mutable_entries(t)); |
-} |
+static void uninit(upb_table *t) { free(mutable_entries(t)); } |
static upb_tabent *emptyent(upb_table *t) { |
upb_tabent *e = mutable_entries(t) + upb_table_size(t); |
- while (1) { if (upb_tabent_isempty(--e)) return e; UPB_ASSERT(e > t->entries); } |
+ while (1) { if (upb_tabent_isempty(--e)) return e; assert(e > t->entries); } |
} |
static upb_tabent *getentry_mutable(upb_table *t, uint32_t hash) { |
@@ -4450,8 +4165,10 @@ static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey, |
upb_tabent *mainpos_e; |
upb_tabent *our_e; |
- UPB_ASSERT(findentry(t, key, hash, eql) == NULL); |
- UPB_ASSERT_DEBUGVAR(val.ctype == t->ctype); |
+ UPB_UNUSED(eql); |
+ UPB_UNUSED(key); |
+ assert(findentry(t, key, hash, eql) == NULL); |
+ assert(val.ctype == t->ctype); |
t->count++; |
mainpos_e = getentry_mutable(t, hash); |
@@ -4478,7 +4195,7 @@ static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey, |
*new_e = *mainpos_e; /* copies next. */ |
while (chain->next != mainpos_e) { |
chain = (upb_tabent*)chain->next; |
- UPB_ASSERT(chain); |
+ assert(chain); |
} |
chain->next = new_e; |
our_e = mainpos_e; |
@@ -4487,7 +4204,7 @@ static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey, |
} |
our_e->key = tabkey; |
our_e->val.val = val.val; |
- UPB_ASSERT(findentry(t, key, hash, eql) == our_e); |
+ assert(findentry(t, key, hash, eql) == our_e); |
} |
static bool rm(upb_table *t, lookupkey_t key, upb_value *val, |
@@ -4497,33 +4214,38 @@ static bool rm(upb_table *t, lookupkey_t key, upb_value *val, |
if (eql(chain->key, key)) { |
/* Element to remove is at the head of its chain. */ |
t->count--; |
- if (val) _upb_value_setval(val, chain->val.val, t->ctype); |
- if (removed) *removed = chain->key; |
+ if (val) { |
+ _upb_value_setval(val, chain->val.val, t->ctype); |
+ } |
if (chain->next) { |
upb_tabent *move = (upb_tabent*)chain->next; |
*chain = *move; |
+ if (removed) *removed = move->key; |
move->key = 0; /* Make the slot empty. */ |
} else { |
+ if (removed) *removed = chain->key; |
chain->key = 0; /* Make the slot empty. */ |
} |
return true; |
} else { |
/* Element to remove is either in a non-head position or not in the |
* table. */ |
- while (chain->next && !eql(chain->next->key, key)) { |
+ while (chain->next && !eql(chain->next->key, key)) |
chain = (upb_tabent*)chain->next; |
- } |
if (chain->next) { |
/* Found element to remove. */ |
- upb_tabent *rm = (upb_tabent*)chain->next; |
- t->count--; |
- if (val) _upb_value_setval(val, chain->next->val.val, t->ctype); |
+ upb_tabent *rm; |
+ |
+ if (val) { |
+ _upb_value_setval(val, chain->next->val.val, t->ctype); |
+ } |
+ rm = (upb_tabent*)chain->next; |
if (removed) *removed = rm->key; |
- rm->key = 0; /* Make the slot empty. */ |
+ rm->key = 0; |
chain->next = rm->next; |
+ t->count--; |
return true; |
} else { |
- /* Element to remove is not in the table. */ |
return false; |
} |
} |
@@ -4547,8 +4269,8 @@ static size_t begin(const upb_table *t) { |
/* A simple "subclass" of upb_table that only adds a hash function for strings. */ |
-static upb_tabkey strcopy(lookupkey_t k2, upb_alloc *a) { |
- char *str = upb_malloc(a, k2.str.len + sizeof(uint32_t) + 1); |
+static upb_tabkey strcopy(lookupkey_t k2) { |
+ char *str = malloc(k2.str.len + sizeof(uint32_t) + 1); |
if (str == NULL) return 0; |
memcpy(str, &k2.str.len, sizeof(uint32_t)); |
memcpy(str + sizeof(uint32_t), k2.str.str, k2.str.len + 1); |
@@ -4567,56 +4289,51 @@ static bool streql(upb_tabkey k1, lookupkey_t k2) { |
return len == k2.str.len && memcmp(str, k2.str.str, len) == 0; |
} |
-bool upb_strtable_init2(upb_strtable *t, upb_ctype_t ctype, upb_alloc *a) { |
- return init(&t->t, ctype, 2, a); |
+bool upb_strtable_init(upb_strtable *t, upb_ctype_t ctype) { |
+ return init(&t->t, ctype, 2); |
} |
-void upb_strtable_uninit2(upb_strtable *t, upb_alloc *a) { |
+void upb_strtable_uninit(upb_strtable *t) { |
size_t i; |
for (i = 0; i < upb_table_size(&t->t); i++) |
- upb_free(a, (void*)t->t.entries[i].key); |
- uninit(&t->t, a); |
+ free((void*)t->t.entries[i].key); |
+ uninit(&t->t); |
} |
-bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_alloc *a) { |
+bool upb_strtable_resize(upb_strtable *t, size_t size_lg2) { |
upb_strtable new_table; |
upb_strtable_iter i; |
- upb_check_alloc(&t->t, a); |
- |
- if (!init(&new_table.t, t->t.ctype, size_lg2, a)) |
+ if (!init(&new_table.t, t->t.ctype, size_lg2)) |
return false; |
upb_strtable_begin(&i, t); |
for ( ; !upb_strtable_done(&i); upb_strtable_next(&i)) { |
- upb_strtable_insert3( |
+ upb_strtable_insert2( |
&new_table, |
upb_strtable_iter_key(&i), |
upb_strtable_iter_keylength(&i), |
- upb_strtable_iter_value(&i), |
- a); |
+ upb_strtable_iter_value(&i)); |
} |
- upb_strtable_uninit2(t, a); |
+ upb_strtable_uninit(t); |
*t = new_table; |
return true; |
} |
-bool upb_strtable_insert3(upb_strtable *t, const char *k, size_t len, |
- upb_value v, upb_alloc *a) { |
+bool upb_strtable_insert2(upb_strtable *t, const char *k, size_t len, |
+ upb_value v) { |
lookupkey_t key; |
upb_tabkey tabkey; |
uint32_t hash; |
- upb_check_alloc(&t->t, a); |
- |
if (isfull(&t->t)) { |
/* Need to resize. New table of double the size, add old elements to it. */ |
- if (!upb_strtable_resize(t, t->t.size_lg2 + 1, a)) { |
+ if (!upb_strtable_resize(t, t->t.size_lg2 + 1)) { |
return false; |
} |
} |
key = strkey2(k, len); |
- tabkey = strcopy(key, a); |
+ tabkey = strcopy(key); |
if (tabkey == 0) return false; |
hash = MurmurHash2(key.str.str, key.str.len, 0); |
@@ -4630,12 +4347,12 @@ bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len, |
return lookup(&t->t, strkey2(key, len), v, hash, &streql); |
} |
-bool upb_strtable_remove3(upb_strtable *t, const char *key, size_t len, |
- upb_value *val, upb_alloc *alloc) { |
- uint32_t hash = MurmurHash2(key, len, 0); |
+bool upb_strtable_remove2(upb_strtable *t, const char *key, size_t len, |
+ upb_value *val) { |
+ uint32_t hash = MurmurHash2(key, strlen(key), 0); |
upb_tabkey tabkey; |
if (rm(&t->t, strkey2(key, len), val, &tabkey, hash, &streql)) { |
- upb_free(alloc, (void*)tabkey); |
+ free((void*)tabkey); |
return true; |
} else { |
return false; |
@@ -4662,20 +4379,20 @@ bool upb_strtable_done(const upb_strtable_iter *i) { |
upb_tabent_isempty(str_tabent(i)); |
} |
-const char *upb_strtable_iter_key(const upb_strtable_iter *i) { |
- UPB_ASSERT(!upb_strtable_done(i)); |
+const char *upb_strtable_iter_key(upb_strtable_iter *i) { |
+ assert(!upb_strtable_done(i)); |
return upb_tabstr(str_tabent(i)->key, NULL); |
} |
-size_t upb_strtable_iter_keylength(const upb_strtable_iter *i) { |
+size_t upb_strtable_iter_keylength(upb_strtable_iter *i) { |
uint32_t len; |
- UPB_ASSERT(!upb_strtable_done(i)); |
+ assert(!upb_strtable_done(i)); |
upb_tabstr(str_tabent(i)->key, &len); |
return len; |
} |
upb_value upb_strtable_iter_value(const upb_strtable_iter *i) { |
- UPB_ASSERT(!upb_strtable_done(i)); |
+ assert(!upb_strtable_done(i)); |
return _upb_value_val(str_tabent(i)->val.val, i->t->t.ctype); |
} |
@@ -4734,26 +4451,26 @@ static void check(upb_inttable *t) { |
upb_inttable_iter i; |
upb_inttable_begin(&i, t); |
for(; !upb_inttable_done(&i); upb_inttable_next(&i), count++) { |
- UPB_ASSERT(upb_inttable_lookup(t, upb_inttable_iter_key(&i), NULL)); |
+ assert(upb_inttable_lookup(t, upb_inttable_iter_key(&i), NULL)); |
} |
- UPB_ASSERT(count == upb_inttable_count(t)); |
+ assert(count == upb_inttable_count(t)); |
} |
#endif |
} |
bool upb_inttable_sizedinit(upb_inttable *t, upb_ctype_t ctype, |
- size_t asize, int hsize_lg2, upb_alloc *a) { |
+ size_t asize, int hsize_lg2) { |
size_t array_bytes; |
- if (!init(&t->t, ctype, hsize_lg2, a)) return false; |
+ if (!init(&t->t, ctype, hsize_lg2)) return false; |
/* Always make the array part at least 1 long, so that we know key 0 |
* won't be in the hash part, which simplifies things. */ |
t->array_size = UPB_MAX(1, asize); |
t->array_count = 0; |
array_bytes = t->array_size * sizeof(upb_value); |
- t->array = upb_malloc(a, array_bytes); |
+ t->array = malloc(array_bytes); |
if (!t->array) { |
- uninit(&t->t, a); |
+ uninit(&t->t); |
return false; |
} |
memset(mutable_array(t), 0xff, array_bytes); |
@@ -4761,25 +4478,25 @@ bool upb_inttable_sizedinit(upb_inttable *t, upb_ctype_t ctype, |
return true; |
} |
-bool upb_inttable_init2(upb_inttable *t, upb_ctype_t ctype, upb_alloc *a) { |
- return upb_inttable_sizedinit(t, ctype, 0, 4, a); |
+bool upb_inttable_init(upb_inttable *t, upb_ctype_t ctype) { |
+ return upb_inttable_sizedinit(t, ctype, 0, 4); |
} |
-void upb_inttable_uninit2(upb_inttable *t, upb_alloc *a) { |
- uninit(&t->t, a); |
- upb_free(a, mutable_array(t)); |
+void upb_inttable_uninit(upb_inttable *t) { |
+ uninit(&t->t); |
+ free(mutable_array(t)); |
} |
-bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val, |
- upb_alloc *a) { |
+bool upb_inttable_insert(upb_inttable *t, uintptr_t key, upb_value val) { |
+ /* XXX: Table can't store value (uint64_t)-1. Need to somehow statically |
+ * guarantee that this is not necessary, or fix the limitation. */ |
upb_tabval tabval; |
tabval.val = val.val; |
- UPB_ASSERT(upb_arrhas(tabval)); /* This will reject (uint64_t)-1. Fix this. */ |
- |
- upb_check_alloc(&t->t, a); |
+ UPB_UNUSED(tabval); |
+ assert(upb_arrhas(tabval)); |
if (key < t->array_size) { |
- UPB_ASSERT(!upb_arrhas(t->array[key])); |
+ assert(!upb_arrhas(t->array[key])); |
t->array_count++; |
mutable_array(t)[key].val = val.val; |
} else { |
@@ -4787,11 +4504,8 @@ bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val, |
/* Need to resize the hash part, but we re-use the array part. */ |
size_t i; |
upb_table new_table; |
- |
- if (!init(&new_table, t->t.ctype, t->t.size_lg2 + 1, a)) { |
+ if (!init(&new_table, t->t.ctype, t->t.size_lg2 + 1)) |
return false; |
- } |
- |
for (i = begin(&t->t); i < upb_table_size(&t->t); i = next(&t->t, i)) { |
const upb_tabent *e = &t->t.entries[i]; |
uint32_t hash; |
@@ -4802,9 +4516,9 @@ bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val, |
insert(&new_table, intkey(e->key), e->key, v, hash, &inthash, &inteql); |
} |
- UPB_ASSERT(t->t.count == new_table.count); |
+ assert(t->t.count == new_table.count); |
- uninit(&t->t, a); |
+ uninit(&t->t); |
t->t = new_table; |
} |
insert(&t->t, intkey(key), key, val, upb_inthash(key), &inthash, &inteql); |
@@ -4842,28 +4556,27 @@ bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val) { |
success = false; |
} |
} else { |
- success = rm(&t->t, intkey(key), val, NULL, upb_inthash(key), &inteql); |
+ upb_tabkey removed; |
+ uint32_t hash = upb_inthash(key); |
+ success = rm(&t->t, intkey(key), val, &removed, hash, &inteql); |
} |
check(t); |
return success; |
} |
-bool upb_inttable_push2(upb_inttable *t, upb_value val, upb_alloc *a) { |
- upb_check_alloc(&t->t, a); |
- return upb_inttable_insert2(t, upb_inttable_count(t), val, a); |
+bool upb_inttable_push(upb_inttable *t, upb_value val) { |
+ return upb_inttable_insert(t, upb_inttable_count(t), val); |
} |
upb_value upb_inttable_pop(upb_inttable *t) { |
upb_value val; |
bool ok = upb_inttable_remove(t, upb_inttable_count(t) - 1, &val); |
- UPB_ASSERT(ok); |
+ UPB_ASSERT_VAR(ok, ok); |
return val; |
} |
-bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val, |
- upb_alloc *a) { |
- upb_check_alloc(&t->t, a); |
- return upb_inttable_insert2(t, (uintptr_t)key, val, a); |
+bool upb_inttable_insertptr(upb_inttable *t, const void *key, upb_value val) { |
+ return upb_inttable_insert(t, (uintptr_t)key, val); |
} |
bool upb_inttable_lookupptr(const upb_inttable *t, const void *key, |
@@ -4875,74 +4588,77 @@ bool upb_inttable_removeptr(upb_inttable *t, const void *key, upb_value *val) { |
return upb_inttable_remove(t, (uintptr_t)key, val); |
} |
-void upb_inttable_compact2(upb_inttable *t, upb_alloc *a) { |
- /* A power-of-two histogram of the table keys. */ |
- size_t counts[UPB_MAXARRSIZE + 1] = {0}; |
- |
- /* The max key in each bucket. */ |
- uintptr_t max[UPB_MAXARRSIZE + 1] = {0}; |
- |
+void upb_inttable_compact(upb_inttable *t) { |
+ /* Create a power-of-two histogram of the table keys. */ |
+ int counts[UPB_MAXARRSIZE + 1] = {0}; |
+ uintptr_t max_key = 0; |
upb_inttable_iter i; |
- size_t arr_count; |
- int size_lg2; |
+ size_t arr_size; |
+ int arr_count; |
upb_inttable new_t; |
- upb_check_alloc(&t->t, a); |
- |
upb_inttable_begin(&i, t); |
for (; !upb_inttable_done(&i); upb_inttable_next(&i)) { |
uintptr_t key = upb_inttable_iter_key(&i); |
- int bucket = log2ceil(key); |
- max[bucket] = UPB_MAX(max[bucket], key); |
- counts[bucket]++; |
+ if (key > max_key) { |
+ max_key = key; |
+ } |
+ counts[log2ceil(key)]++; |
} |
- /* Find the largest power of two that satisfies the MIN_DENSITY |
- * definition (while actually having some keys). */ |
+ arr_size = 1; |
arr_count = upb_inttable_count(t); |
- for (size_lg2 = ARRAY_SIZE(counts) - 1; size_lg2 > 0; size_lg2--) { |
- if (counts[size_lg2] == 0) { |
- /* We can halve again without losing any entries. */ |
- continue; |
- } else if (arr_count >= (1 << size_lg2) * MIN_DENSITY) { |
- break; |
+ if (upb_inttable_count(t) >= max_key * MIN_DENSITY) { |
+ /* We can put 100% of the entries in the array part. */ |
+ arr_size = max_key + 1; |
+ } else { |
+ /* Find the largest power of two that satisfies the MIN_DENSITY |
+ * definition. */ |
+ int size_lg2; |
+ for (size_lg2 = ARRAY_SIZE(counts) - 1; size_lg2 > 1; size_lg2--) { |
+ arr_size = 1 << size_lg2; |
+ arr_count -= counts[size_lg2]; |
+ if (arr_count >= arr_size * MIN_DENSITY) { |
+ break; |
+ } |
} |
- |
- arr_count -= counts[size_lg2]; |
} |
- UPB_ASSERT(arr_count <= upb_inttable_count(t)); |
+ /* Array part must always be at least 1 entry large to catch lookups of key |
+ * 0. Key 0 must always be in the array part because "0" in the hash part |
+ * denotes an empty entry. */ |
+ arr_size = UPB_MAX(arr_size, 1); |
{ |
/* Insert all elements into new, perfectly-sized table. */ |
- size_t arr_size = max[size_lg2] + 1; /* +1 so arr[max] will fit. */ |
- size_t hash_count = upb_inttable_count(t) - arr_count; |
- size_t hash_size = hash_count ? (hash_count / MAX_LOAD) + 1 : 0; |
- size_t hashsize_lg2 = log2ceil(hash_size); |
+ int hash_count = upb_inttable_count(t) - arr_count; |
+ int hash_size = hash_count ? (hash_count / MAX_LOAD) + 1 : 0; |
+ int hashsize_lg2 = log2ceil(hash_size); |
- upb_inttable_sizedinit(&new_t, t->t.ctype, arr_size, hashsize_lg2, a); |
+ assert(hash_count >= 0); |
+ upb_inttable_sizedinit(&new_t, t->t.ctype, arr_size, hashsize_lg2); |
upb_inttable_begin(&i, t); |
for (; !upb_inttable_done(&i); upb_inttable_next(&i)) { |
uintptr_t k = upb_inttable_iter_key(&i); |
- upb_inttable_insert2(&new_t, k, upb_inttable_iter_value(&i), a); |
+ upb_inttable_insert(&new_t, k, upb_inttable_iter_value(&i)); |
} |
- UPB_ASSERT(new_t.array_size == arr_size); |
- UPB_ASSERT(new_t.t.size_lg2 == hashsize_lg2); |
+ assert(new_t.array_size == arr_size); |
+ assert(new_t.t.size_lg2 == hashsize_lg2); |
} |
- upb_inttable_uninit2(t, a); |
+ upb_inttable_uninit(t); |
*t = new_t; |
} |
/* Iteration. */ |
static const upb_tabent *int_tabent(const upb_inttable_iter *i) { |
- UPB_ASSERT(!i->array_part); |
+ assert(!i->array_part); |
return &i->t->t.entries[i->index]; |
} |
static upb_tabval int_arrent(const upb_inttable_iter *i) { |
- UPB_ASSERT(i->array_part); |
+ assert(i->array_part); |
return i->t->array[i->index]; |
} |
@@ -4979,12 +4695,12 @@ bool upb_inttable_done(const upb_inttable_iter *i) { |
} |
uintptr_t upb_inttable_iter_key(const upb_inttable_iter *i) { |
- UPB_ASSERT(!upb_inttable_done(i)); |
+ assert(!upb_inttable_done(i)); |
return i->array_part ? i->index : int_tabent(i)->key; |
} |
upb_value upb_inttable_iter_value(const upb_inttable_iter *i) { |
- UPB_ASSERT(!upb_inttable_done(i)); |
+ assert(!upb_inttable_done(i)); |
return _upb_value_val( |
i->array_part ? i->t->array[i->index].val : int_tabent(i)->val.val, |
i->t->t.ctype); |
@@ -5202,23 +4918,10 @@ bool upb_dumptostderr(void *closure, const upb_status* status) { |
static void nullz(upb_status *status) { |
const char *ellipsis = "..."; |
size_t len = strlen(ellipsis); |
- UPB_ASSERT(sizeof(status->msg) > len); |
+ assert(sizeof(status->msg) > len); |
memcpy(status->msg + sizeof(status->msg) - len, ellipsis, len); |
} |
- |
-/* upb_upberr *****************************************************************/ |
- |
-upb_errorspace upb_upberr = {"upb error"}; |
- |
-void upb_upberr_setoom(upb_status *status) { |
- status->error_space_ = &upb_upberr; |
- upb_status_seterrmsg(status, "Out of memory"); |
-} |
- |
- |
-/* upb_status *****************************************************************/ |
- |
void upb_status_clear(upb_status *status) { |
if (!status) return; |
status->ok_ = true; |
@@ -5257,604 +4960,311 @@ void upb_status_vseterrf(upb_status *status, const char *fmt, va_list args) { |
nullz(status); |
} |
+void upb_status_seterrcode(upb_status *status, upb_errorspace *space, |
+ int code) { |
+ if (!status) return; |
+ status->ok_ = false; |
+ status->error_space_ = space; |
+ status->code_ = code; |
+ space->set_message(status, code); |
+} |
+ |
void upb_status_copy(upb_status *to, const upb_status *from) { |
if (!to) return; |
*to = *from; |
} |
+/* This file was generated by upbc (the upb compiler). |
+ * Do not edit -- your changes will be discarded when the file is |
+ * regenerated. */ |
-/* upb_alloc ******************************************************************/ |
- |
-static void *upb_global_allocfunc(upb_alloc *alloc, void *ptr, size_t oldsize, |
- size_t size) { |
- UPB_UNUSED(alloc); |
- UPB_UNUSED(oldsize); |
- if (size == 0) { |
- free(ptr); |
- return NULL; |
- } else { |
- return realloc(ptr, size); |
- } |
-} |
- |
-upb_alloc upb_alloc_global = {&upb_global_allocfunc}; |
- |
- |
-/* upb_arena ******************************************************************/ |
- |
-/* Be conservative and choose 16 in case anyone is using SSE. */ |
-static const size_t maxalign = 16; |
- |
-static size_t align_up(size_t size) { |
- return ((size + maxalign - 1) / maxalign) * maxalign; |
-} |
- |
-typedef struct mem_block { |
- struct mem_block *next; |
- size_t size; |
- size_t used; |
- bool owned; |
- /* Data follows. */ |
-} mem_block; |
- |
-typedef struct cleanup_ent { |
- struct cleanup_ent *next; |
- upb_cleanup_func *cleanup; |
- void *ud; |
-} cleanup_ent; |
- |
-static void upb_arena_addblock(upb_arena *a, void *ptr, size_t size, |
- bool owned) { |
- mem_block *block = ptr; |
- |
- block->next = a->block_head; |
- block->size = size; |
- block->used = align_up(sizeof(mem_block)); |
- block->owned = owned; |
- |
- a->block_head = block; |
- |
- /* TODO(haberman): ASAN poison. */ |
-} |
- |
- |
-static mem_block *upb_arena_allocblock(upb_arena *a, size_t size) { |
- size_t block_size = UPB_MAX(size, a->next_block_size) + sizeof(mem_block); |
- mem_block *block = upb_malloc(a->block_alloc, block_size); |
- |
- if (!block) { |
- return NULL; |
- } |
- |
- upb_arena_addblock(a, block, block_size, true); |
- a->next_block_size = UPB_MIN(block_size * 2, a->max_block_size); |
- |
- return block; |
-} |
- |
-static void *upb_arena_doalloc(upb_alloc *alloc, void *ptr, size_t oldsize, |
- size_t size) { |
- upb_arena *a = (upb_arena*)alloc; /* upb_alloc is initial member. */ |
- mem_block *block = a->block_head; |
- void *ret; |
- |
- if (size == 0) { |
- return NULL; /* We are an arena, don't need individual frees. */ |
- } |
- |
- size = align_up(size); |
- |
- /* TODO(haberman): special-case if this is a realloc of the last alloc? */ |
- |
- if (!block || block->size - block->used < size) { |
- /* Slow path: have to allocate a new block. */ |
- block = upb_arena_allocblock(a, size); |
- |
- if (!block) { |
- return NULL; /* Out of memory. */ |
- } |
- } |
- |
- ret = (char*)block + block->used; |
- block->used += size; |
- |
- if (oldsize > 0) { |
- memcpy(ret, ptr, oldsize); /* Preserve existing data. */ |
- } |
- |
- /* TODO(haberman): ASAN unpoison. */ |
- |
- a->bytes_allocated += size; |
- return ret; |
-} |
- |
-/* Public Arena API ***********************************************************/ |
- |
-void upb_arena_init(upb_arena *a) { |
- a->alloc.func = &upb_arena_doalloc; |
- a->block_alloc = &upb_alloc_global; |
- a->bytes_allocated = 0; |
- a->next_block_size = 256; |
- a->max_block_size = 16384; |
- a->cleanup_head = NULL; |
- a->block_head = NULL; |
-} |
- |
-void upb_arena_init2(upb_arena *a, void *mem, size_t size, upb_alloc *alloc) { |
- upb_arena_init(a); |
- |
- if (size > sizeof(mem_block)) { |
- upb_arena_addblock(a, mem, size, false); |
- } |
- |
- if (alloc) { |
- a->block_alloc = alloc; |
- } |
-} |
- |
-void upb_arena_uninit(upb_arena *a) { |
- cleanup_ent *ent = a->cleanup_head; |
- mem_block *block = a->block_head; |
+static const upb_msgdef msgs[20]; |
+static const upb_fielddef fields[81]; |
+static const upb_enumdef enums[4]; |
+static const upb_tabent strentries[236]; |
+static const upb_tabent intentries[14]; |
+static const upb_tabval arrays[232]; |
- while (ent) { |
- ent->cleanup(ent->ud); |
- ent = ent->next; |
- } |
+#ifdef UPB_DEBUG_REFS |
+static upb_inttable reftables[212]; |
+#endif |
- /* Must do this after running cleanup functions, because this will delete |
- * the memory we store our cleanup entries in! */ |
- while (block) { |
- mem_block *next = block->next; |
+static const upb_msgdef msgs[20] = { |
+ UPB_MSGDEF_INIT("google.protobuf.DescriptorProto", 27, 6, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[0], 8, 7), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[0]),&reftables[0], &reftables[1]), |
+ UPB_MSGDEF_INIT("google.protobuf.DescriptorProto.ExtensionRange", 4, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[8], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[16]),&reftables[2], &reftables[3]), |
+ UPB_MSGDEF_INIT("google.protobuf.EnumDescriptorProto", 11, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[11], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[20]),&reftables[4], &reftables[5]), |
+ UPB_MSGDEF_INIT("google.protobuf.EnumOptions", 7, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[0], &arrays[15], 8, 1), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[24]),&reftables[6], &reftables[7]), |
+ UPB_MSGDEF_INIT("google.protobuf.EnumValueDescriptorProto", 8, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[23], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[28]),&reftables[8], &reftables[9]), |
+ UPB_MSGDEF_INIT("google.protobuf.EnumValueOptions", 6, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[2], &arrays[27], 4, 0), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[32]),&reftables[10], &reftables[11]), |
+ UPB_MSGDEF_INIT("google.protobuf.FieldDescriptorProto", 19, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[31], 9, 8), UPB_STRTABLE_INIT(8, 15, UPB_CTYPE_PTR, 4, &strentries[36]),&reftables[12], &reftables[13]), |
+ UPB_MSGDEF_INIT("google.protobuf.FieldOptions", 14, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[4], &arrays[40], 32, 6), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[52]),&reftables[14], &reftables[15]), |
+ UPB_MSGDEF_INIT("google.protobuf.FileDescriptorProto", 39, 6, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[72], 12, 11), UPB_STRTABLE_INIT(11, 15, UPB_CTYPE_PTR, 4, &strentries[68]),&reftables[16], &reftables[17]), |
+ UPB_MSGDEF_INIT("google.protobuf.FileDescriptorSet", 6, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[84], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[84]),&reftables[18], &reftables[19]), |
+ UPB_MSGDEF_INIT("google.protobuf.FileOptions", 21, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[6], &arrays[86], 64, 9), UPB_STRTABLE_INIT(10, 15, UPB_CTYPE_PTR, 4, &strentries[88]),&reftables[20], &reftables[21]), |
+ UPB_MSGDEF_INIT("google.protobuf.MessageOptions", 8, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[8], &arrays[150], 16, 2), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[104]),&reftables[22], &reftables[23]), |
+ UPB_MSGDEF_INIT("google.protobuf.MethodDescriptorProto", 13, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[166], 5, 4), UPB_STRTABLE_INIT(4, 7, UPB_CTYPE_PTR, 3, &strentries[108]),&reftables[24], &reftables[25]), |
+ UPB_MSGDEF_INIT("google.protobuf.MethodOptions", 6, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[10], &arrays[171], 4, 0), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[116]),&reftables[26], &reftables[27]), |
+ UPB_MSGDEF_INIT("google.protobuf.ServiceDescriptorProto", 11, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[175], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[120]),&reftables[28], &reftables[29]), |
+ UPB_MSGDEF_INIT("google.protobuf.ServiceOptions", 6, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[12], &arrays[179], 4, 0), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[124]),&reftables[30], &reftables[31]), |
+ UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo", 6, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[183], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[128]),&reftables[32], &reftables[33]), |
+ UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo.Location", 14, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[185], 5, 4), UPB_STRTABLE_INIT(4, 7, UPB_CTYPE_PTR, 3, &strentries[132]),&reftables[34], &reftables[35]), |
+ UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption", 18, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[190], 9, 7), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[140]),&reftables[36], &reftables[37]), |
+ UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption.NamePart", 6, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[199], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[156]),&reftables[38], &reftables[39]), |
+}; |
- if (block->owned) { |
- upb_free(a->block_alloc, block); |
- } |
+static const upb_fielddef fields[81] = { |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "aggregate_value", 8, &msgs[18], NULL, 15, 6, {0},&reftables[40], &reftables[41]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "allow_alias", 2, &msgs[3], NULL, 6, 1, {0},&reftables[42], &reftables[43]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "cc_generic_services", 16, &msgs[10], NULL, 17, 6, {0},&reftables[44], &reftables[45]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "ctype", 1, &msgs[7], (const upb_def*)(&enums[2]), 6, 1, {0},&reftables[46], &reftables[47]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "default_value", 7, &msgs[6], NULL, 16, 7, {0},&reftables[48], &reftables[49]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "dependency", 3, &msgs[8], NULL, 30, 8, {0},&reftables[50], &reftables[51]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[7], NULL, 8, 3, {0},&reftables[52], &reftables[53]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_DOUBLE, 0, false, false, false, false, "double_value", 6, &msgs[18], NULL, 11, 4, {0},&reftables[54], &reftables[55]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "end", 2, &msgs[1], NULL, 3, 1, {0},&reftables[56], &reftables[57]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 4, &msgs[0], (const upb_def*)(&msgs[2]), 16, 2, {0},&reftables[58], &reftables[59]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 5, &msgs[8], (const upb_def*)(&msgs[2]), 13, 1, {0},&reftables[60], &reftables[61]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "experimental_map_key", 9, &msgs[7], NULL, 10, 5, {0},&reftables[62], &reftables[63]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "extendee", 2, &msgs[6], NULL, 7, 2, {0},&reftables[64], &reftables[65]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 7, &msgs[8], (const upb_def*)(&msgs[6]), 19, 3, {0},&reftables[66], &reftables[67]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 6, &msgs[0], (const upb_def*)(&msgs[6]), 22, 4, {0},&reftables[68], &reftables[69]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension_range", 5, &msgs[0], (const upb_def*)(&msgs[1]), 19, 3, {0},&reftables[70], &reftables[71]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "field", 2, &msgs[0], (const upb_def*)(&msgs[6]), 10, 0, {0},&reftables[72], &reftables[73]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "file", 1, &msgs[9], (const upb_def*)(&msgs[8]), 5, 0, {0},&reftables[74], &reftables[75]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "go_package", 11, &msgs[10], NULL, 14, 5, {0},&reftables[76], &reftables[77]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "identifier_value", 3, &msgs[18], NULL, 6, 1, {0},&reftables[78], &reftables[79]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "input_type", 2, &msgs[12], NULL, 7, 2, {0},&reftables[80], &reftables[81]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_BOOL, 0, false, false, false, false, "is_extension", 2, &msgs[19], NULL, 5, 1, {0},&reftables[82], &reftables[83]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_generate_equals_and_hash", 20, &msgs[10], NULL, 20, 9, {0},&reftables[84], &reftables[85]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_generic_services", 17, &msgs[10], NULL, 18, 7, {0},&reftables[86], &reftables[87]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_multiple_files", 10, &msgs[10], NULL, 13, 4, {0},&reftables[88], &reftables[89]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "java_outer_classname", 8, &msgs[10], NULL, 9, 2, {0},&reftables[90], &reftables[91]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "java_package", 1, &msgs[10], NULL, 6, 1, {0},&reftables[92], &reftables[93]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "label", 4, &msgs[6], (const upb_def*)(&enums[0]), 11, 4, {0},&reftables[94], &reftables[95]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "lazy", 5, &msgs[7], NULL, 9, 4, {0},&reftables[96], &reftables[97]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "leading_comments", 3, &msgs[17], NULL, 8, 2, {0},&reftables[98], &reftables[99]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "location", 1, &msgs[16], (const upb_def*)(&msgs[17]), 5, 0, {0},&reftables[100], &reftables[101]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "message_set_wire_format", 1, &msgs[11], NULL, 6, 1, {0},&reftables[102], &reftables[103]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "message_type", 4, &msgs[8], (const upb_def*)(&msgs[0]), 10, 0, {0},&reftables[104], &reftables[105]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "method", 2, &msgs[14], (const upb_def*)(&msgs[12]), 6, 0, {0},&reftables[106], &reftables[107]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[8], NULL, 22, 6, {0},&reftables[108], &reftables[109]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[14], NULL, 8, 2, {0},&reftables[110], &reftables[111]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "name", 2, &msgs[18], (const upb_def*)(&msgs[19]), 5, 0, {0},&reftables[112], &reftables[113]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[4], NULL, 4, 1, {0},&reftables[114], &reftables[115]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[0], NULL, 24, 6, {0},&reftables[116], &reftables[117]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[12], NULL, 4, 1, {0},&reftables[118], &reftables[119]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[2], NULL, 8, 2, {0},&reftables[120], &reftables[121]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[6], NULL, 4, 1, {0},&reftables[122], &reftables[123]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_STRING, 0, false, false, false, false, "name_part", 1, &msgs[19], NULL, 2, 0, {0},&reftables[124], &reftables[125]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT64, UPB_INTFMT_VARIABLE, false, false, false, false, "negative_int_value", 5, &msgs[18], NULL, 10, 3, {0},&reftables[126], &reftables[127]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "nested_type", 3, &msgs[0], (const upb_def*)(&msgs[0]), 13, 1, {0},&reftables[128], &reftables[129]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "no_standard_descriptor_accessor", 2, &msgs[11], NULL, 7, 2, {0},&reftables[130], &reftables[131]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 3, &msgs[6], NULL, 10, 3, {0},&reftables[132], &reftables[133]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 2, &msgs[4], NULL, 7, 2, {0},&reftables[134], &reftables[135]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "optimize_for", 9, &msgs[10], (const upb_def*)(&enums[3]), 12, 3, {0},&reftables[136], &reftables[137]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 7, &msgs[0], (const upb_def*)(&msgs[11]), 23, 5, {0},&reftables[138], &reftables[139]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[2], (const upb_def*)(&msgs[3]), 7, 1, {0},&reftables[140], &reftables[141]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[6], (const upb_def*)(&msgs[7]), 3, 0, {0},&reftables[142], &reftables[143]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[4], (const upb_def*)(&msgs[5]), 3, 0, {0},&reftables[144], &reftables[145]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[8], (const upb_def*)(&msgs[10]), 20, 4, {0},&reftables[146], &reftables[147]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[14], (const upb_def*)(&msgs[15]), 7, 1, {0},&reftables[148], &reftables[149]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 4, &msgs[12], (const upb_def*)(&msgs[13]), 3, 0, {0},&reftables[150], &reftables[151]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "output_type", 3, &msgs[12], NULL, 10, 3, {0},&reftables[152], &reftables[153]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "package", 2, &msgs[8], NULL, 25, 7, {0},&reftables[154], &reftables[155]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "packed", 2, &msgs[7], NULL, 7, 2, {0},&reftables[156], &reftables[157]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "path", 1, &msgs[17], NULL, 4, 0, {0},&reftables[158], &reftables[159]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_UINT64, UPB_INTFMT_VARIABLE, false, false, false, false, "positive_int_value", 4, &msgs[18], NULL, 9, 2, {0},&reftables[160], &reftables[161]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "public_dependency", 10, &msgs[8], NULL, 35, 9, {0},&reftables[162], &reftables[163]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "py_generic_services", 18, &msgs[10], NULL, 19, 8, {0},&reftables[164], &reftables[165]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "service", 6, &msgs[8], (const upb_def*)(&msgs[14]), 16, 2, {0},&reftables[166], &reftables[167]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "source_code_info", 9, &msgs[8], (const upb_def*)(&msgs[16]), 21, 5, {0},&reftables[168], &reftables[169]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "span", 2, &msgs[17], NULL, 7, 1, {0},&reftables[170], &reftables[171]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[1], NULL, 2, 0, {0},&reftables[172], &reftables[173]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, false, false, false, "string_value", 7, &msgs[18], NULL, 12, 5, {0},&reftables[174], &reftables[175]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "trailing_comments", 4, &msgs[17], NULL, 11, 3, {0},&reftables[176], &reftables[177]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "type", 5, &msgs[6], (const upb_def*)(&enums[1]), 12, 5, {0},&reftables[178], &reftables[179]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "type_name", 6, &msgs[6], NULL, 13, 6, {0},&reftables[180], &reftables[181]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[5], (const upb_def*)(&msgs[18]), 5, 0, {0},&reftables[182], &reftables[183]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[15], (const upb_def*)(&msgs[18]), 5, 0, {0},&reftables[184], &reftables[185]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[3], (const upb_def*)(&msgs[18]), 5, 0, {0},&reftables[186], &reftables[187]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[13], (const upb_def*)(&msgs[18]), 5, 0, {0},&reftables[188], &reftables[189]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[10], (const upb_def*)(&msgs[18]), 5, 0, {0},&reftables[190], &reftables[191]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[11], (const upb_def*)(&msgs[18]), 5, 0, {0},&reftables[192], &reftables[193]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[7], (const upb_def*)(&msgs[18]), 5, 0, {0},&reftables[194], &reftables[195]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "value", 2, &msgs[2], (const upb_def*)(&msgs[4]), 6, 0, {0},&reftables[196], &reftables[197]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "weak", 10, &msgs[7], NULL, 13, 6, {0},&reftables[198], &reftables[199]), |
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "weak_dependency", 11, &msgs[8], NULL, 38, 10, {0},&reftables[200], &reftables[201]), |
+}; |
- block = next; |
- } |
-} |
- |
-bool upb_arena_addcleanup(upb_arena *a, upb_cleanup_func *func, void *ud) { |
- cleanup_ent *ent = upb_malloc(&a->alloc, sizeof(cleanup_ent)); |
- if (!ent) { |
- return false; /* Out of memory. */ |
- } |
- |
- ent->cleanup = func; |
- ent->ud = ud; |
- ent->next = a->cleanup_head; |
- a->cleanup_head = ent; |
- |
- return true; |
-} |
- |
-size_t upb_arena_bytesallocated(const upb_arena *a) { |
- return a->bytes_allocated; |
-} |
- |
- |
-/* Standard error functions ***************************************************/ |
- |
-static bool default_err(void *ud, const upb_status *status) { |
- UPB_UNUSED(ud); |
- UPB_UNUSED(status); |
- return false; |
-} |
- |
-static bool write_err_to(void *ud, const upb_status *status) { |
- upb_status *copy_to = ud; |
- upb_status_copy(copy_to, status); |
- return false; |
-} |
- |
- |
-/* upb_env ********************************************************************/ |
- |
-void upb_env_initonly(upb_env *e) { |
- e->ok_ = true; |
- e->error_func_ = &default_err; |
- e->error_ud_ = NULL; |
-} |
- |
-void upb_env_init(upb_env *e) { |
- upb_arena_init(&e->arena_); |
- upb_env_initonly(e); |
-} |
- |
-void upb_env_init2(upb_env *e, void *mem, size_t n, upb_alloc *alloc) { |
- upb_arena_init2(&e->arena_, mem, n, alloc); |
- upb_env_initonly(e); |
-} |
- |
-void upb_env_uninit(upb_env *e) { |
- upb_arena_uninit(&e->arena_); |
-} |
- |
-void upb_env_seterrorfunc(upb_env *e, upb_error_func *func, void *ud) { |
- e->error_func_ = func; |
- e->error_ud_ = ud; |
-} |
- |
-void upb_env_reporterrorsto(upb_env *e, upb_status *s) { |
- e->error_func_ = &write_err_to; |
- e->error_ud_ = s; |
-} |
- |
-bool upb_env_reporterror(upb_env *e, const upb_status *status) { |
- e->ok_ = false; |
- return e->error_func_(e->error_ud_, status); |
-} |
- |
-void *upb_env_malloc(upb_env *e, size_t size) { |
- return upb_malloc(&e->arena_.alloc, size); |
-} |
- |
-void *upb_env_realloc(upb_env *e, void *ptr, size_t oldsize, size_t size) { |
- return upb_realloc(&e->arena_.alloc, ptr, oldsize, size); |
-} |
- |
-void upb_env_free(upb_env *e, void *ptr) { |
- upb_free(&e->arena_.alloc, ptr); |
-} |
- |
-bool upb_env_addcleanup(upb_env *e, upb_cleanup_func *func, void *ud) { |
- return upb_arena_addcleanup(&e->arena_, func, ud); |
-} |
- |
-size_t upb_env_bytesallocated(const upb_env *e) { |
- return upb_arena_bytesallocated(&e->arena_); |
-} |
-/* This file was generated by upbc (the upb compiler) from the input |
- * file: |
- * |
- * upb/descriptor/descriptor.proto |
- * |
- * Do not edit -- your changes will be discarded when the file is |
- * regenerated. */ |
- |
- |
-static const upb_msgdef msgs[22]; |
-static const upb_fielddef fields[105]; |
-static const upb_enumdef enums[5]; |
-static const upb_tabent strentries[236]; |
-static const upb_tabent intentries[18]; |
-static const upb_tabval arrays[184]; |
- |
-#ifdef UPB_DEBUG_REFS |
-static upb_inttable reftables[264]; |
-#endif |
- |
-static const upb_msgdef msgs[22] = { |
- UPB_MSGDEF_INIT("google.protobuf.DescriptorProto", 40, 8, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[0], 11, 10), UPB_STRTABLE_INIT(10, 15, UPB_CTYPE_PTR, 4, &strentries[0]), false, UPB_SYNTAX_PROTO2, &reftables[0], &reftables[1]), |
- UPB_MSGDEF_INIT("google.protobuf.DescriptorProto.ExtensionRange", 4, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[11], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[16]), false, UPB_SYNTAX_PROTO2, &reftables[2], &reftables[3]), |
- UPB_MSGDEF_INIT("google.protobuf.DescriptorProto.ReservedRange", 4, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[14], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[20]), false, UPB_SYNTAX_PROTO2, &reftables[4], &reftables[5]), |
- UPB_MSGDEF_INIT("google.protobuf.EnumDescriptorProto", 11, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[17], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[24]), false, UPB_SYNTAX_PROTO2, &reftables[6], &reftables[7]), |
- UPB_MSGDEF_INIT("google.protobuf.EnumOptions", 8, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[0], &arrays[21], 4, 2), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[28]), false, UPB_SYNTAX_PROTO2, &reftables[8], &reftables[9]), |
- UPB_MSGDEF_INIT("google.protobuf.EnumValueDescriptorProto", 8, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[25], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[32]), false, UPB_SYNTAX_PROTO2, &reftables[10], &reftables[11]), |
- UPB_MSGDEF_INIT("google.protobuf.EnumValueOptions", 7, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[2], &arrays[29], 2, 1), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[36]), false, UPB_SYNTAX_PROTO2, &reftables[12], &reftables[13]), |
- UPB_MSGDEF_INIT("google.protobuf.FieldDescriptorProto", 23, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[31], 11, 10), UPB_STRTABLE_INIT(10, 15, UPB_CTYPE_PTR, 4, &strentries[40]), false, UPB_SYNTAX_PROTO2, &reftables[14], &reftables[15]), |
- UPB_MSGDEF_INIT("google.protobuf.FieldOptions", 12, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[4], &arrays[42], 11, 6), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[56]), false, UPB_SYNTAX_PROTO2, &reftables[16], &reftables[17]), |
- UPB_MSGDEF_INIT("google.protobuf.FileDescriptorProto", 42, 6, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[53], 13, 12), UPB_STRTABLE_INIT(12, 15, UPB_CTYPE_PTR, 4, &strentries[72]), false, UPB_SYNTAX_PROTO2, &reftables[18], &reftables[19]), |
- UPB_MSGDEF_INIT("google.protobuf.FileDescriptorSet", 6, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[66], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[88]), false, UPB_SYNTAX_PROTO2, &reftables[20], &reftables[21]), |
- UPB_MSGDEF_INIT("google.protobuf.FileOptions", 31, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[6], &arrays[68], 39, 15), UPB_STRTABLE_INIT(16, 31, UPB_CTYPE_PTR, 5, &strentries[92]), false, UPB_SYNTAX_PROTO2, &reftables[22], &reftables[23]), |
- UPB_MSGDEF_INIT("google.protobuf.MessageOptions", 10, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[8], &arrays[107], 8, 4), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[124]), false, UPB_SYNTAX_PROTO2, &reftables[24], &reftables[25]), |
- UPB_MSGDEF_INIT("google.protobuf.MethodDescriptorProto", 15, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[115], 7, 6), UPB_STRTABLE_INIT(6, 7, UPB_CTYPE_PTR, 3, &strentries[132]), false, UPB_SYNTAX_PROTO2, &reftables[26], &reftables[27]), |
- UPB_MSGDEF_INIT("google.protobuf.MethodOptions", 7, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[10], &arrays[122], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[140]), false, UPB_SYNTAX_PROTO2, &reftables[28], &reftables[29]), |
- UPB_MSGDEF_INIT("google.protobuf.OneofDescriptorProto", 5, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[123], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[144]), false, UPB_SYNTAX_PROTO2, &reftables[30], &reftables[31]), |
- UPB_MSGDEF_INIT("google.protobuf.ServiceDescriptorProto", 11, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[125], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[148]), false, UPB_SYNTAX_PROTO2, &reftables[32], &reftables[33]), |
- UPB_MSGDEF_INIT("google.protobuf.ServiceOptions", 7, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[14], &arrays[129], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[152]), false, UPB_SYNTAX_PROTO2, &reftables[34], &reftables[35]), |
- UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo", 6, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[130], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[156]), false, UPB_SYNTAX_PROTO2, &reftables[36], &reftables[37]), |
- UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo.Location", 19, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[132], 7, 5), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[160]), false, UPB_SYNTAX_PROTO2, &reftables[38], &reftables[39]), |
- UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption", 18, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[139], 9, 7), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[168]), false, UPB_SYNTAX_PROTO2, &reftables[40], &reftables[41]), |
- UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption.NamePart", 6, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[148], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[184]), false, UPB_SYNTAX_PROTO2, &reftables[42], &reftables[43]), |
-}; |
- |
-static const upb_fielddef fields[105] = { |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "aggregate_value", 8, &msgs[20], NULL, 15, 6, {0},&reftables[44], &reftables[45]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "allow_alias", 2, &msgs[4], NULL, 6, 1, {0},&reftables[46], &reftables[47]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "cc_enable_arenas", 31, &msgs[11], NULL, 23, 12, {0},&reftables[48], &reftables[49]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "cc_generic_services", 16, &msgs[11], NULL, 17, 6, {0},&reftables[50], &reftables[51]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "client_streaming", 5, &msgs[13], NULL, 13, 4, {0},&reftables[52], &reftables[53]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "csharp_namespace", 37, &msgs[11], NULL, 27, 14, {0},&reftables[54], &reftables[55]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "ctype", 1, &msgs[8], (const upb_def*)(&enums[2]), 6, 1, {0},&reftables[56], &reftables[57]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "default_value", 7, &msgs[7], NULL, 16, 7, {0},&reftables[58], &reftables[59]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "dependency", 3, &msgs[9], NULL, 30, 8, {0},&reftables[60], &reftables[61]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[12], NULL, 8, 3, {0},&reftables[62], &reftables[63]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[8], NULL, 8, 3, {0},&reftables[64], &reftables[65]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[14], NULL, 6, 1, {0},&reftables[66], &reftables[67]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 23, &msgs[11], NULL, 21, 10, {0},&reftables[68], &reftables[69]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[4], NULL, 7, 2, {0},&reftables[70], &reftables[71]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[17], NULL, 6, 1, {0},&reftables[72], &reftables[73]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 1, &msgs[6], NULL, 6, 1, {0},&reftables[74], &reftables[75]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_DOUBLE, 0, false, false, false, false, "double_value", 6, &msgs[20], NULL, 11, 4, {0},&reftables[76], &reftables[77]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "end", 2, &msgs[2], NULL, 3, 1, {0},&reftables[78], &reftables[79]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "end", 2, &msgs[1], NULL, 3, 1, {0},&reftables[80], &reftables[81]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 4, &msgs[0], (const upb_def*)(&msgs[3]), 18, 2, {0},&reftables[82], &reftables[83]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 5, &msgs[9], (const upb_def*)(&msgs[3]), 13, 1, {0},&reftables[84], &reftables[85]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "extendee", 2, &msgs[7], NULL, 7, 2, {0},&reftables[86], &reftables[87]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 6, &msgs[0], (const upb_def*)(&msgs[7]), 24, 4, {0},&reftables[88], &reftables[89]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 7, &msgs[9], (const upb_def*)(&msgs[7]), 19, 3, {0},&reftables[90], &reftables[91]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension_range", 5, &msgs[0], (const upb_def*)(&msgs[1]), 21, 3, {0},&reftables[92], &reftables[93]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "field", 2, &msgs[0], (const upb_def*)(&msgs[7]), 12, 0, {0},&reftables[94], &reftables[95]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "file", 1, &msgs[10], (const upb_def*)(&msgs[9]), 5, 0, {0},&reftables[96], &reftables[97]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "go_package", 11, &msgs[11], NULL, 14, 5, {0},&reftables[98], &reftables[99]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "identifier_value", 3, &msgs[20], NULL, 6, 1, {0},&reftables[100], &reftables[101]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "input_type", 2, &msgs[13], NULL, 7, 2, {0},&reftables[102], &reftables[103]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_BOOL, 0, false, false, false, false, "is_extension", 2, &msgs[21], NULL, 5, 1, {0},&reftables[104], &reftables[105]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_generate_equals_and_hash", 20, &msgs[11], NULL, 20, 9, {0},&reftables[106], &reftables[107]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_generic_services", 17, &msgs[11], NULL, 18, 7, {0},&reftables[108], &reftables[109]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_multiple_files", 10, &msgs[11], NULL, 13, 4, {0},&reftables[110], &reftables[111]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "java_outer_classname", 8, &msgs[11], NULL, 9, 2, {0},&reftables[112], &reftables[113]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "java_package", 1, &msgs[11], NULL, 6, 1, {0},&reftables[114], &reftables[115]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_string_check_utf8", 27, &msgs[11], NULL, 22, 11, {0},&reftables[116], &reftables[117]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "javanano_use_deprecated_package", 38, &msgs[11], NULL, 30, 15, {0},&reftables[118], &reftables[119]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "json_name", 10, &msgs[7], NULL, 20, 9, {0},&reftables[120], &reftables[121]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "jstype", 6, &msgs[8], (const upb_def*)(&enums[3]), 10, 5, {0},&reftables[122], &reftables[123]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "label", 4, &msgs[7], (const upb_def*)(&enums[0]), 11, 4, {0},&reftables[124], &reftables[125]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "lazy", 5, &msgs[8], NULL, 9, 4, {0},&reftables[126], &reftables[127]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "leading_comments", 3, &msgs[19], NULL, 8, 2, {0},&reftables[128], &reftables[129]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "leading_detached_comments", 6, &msgs[19], NULL, 16, 4, {0},&reftables[130], &reftables[131]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "location", 1, &msgs[18], (const upb_def*)(&msgs[19]), 5, 0, {0},&reftables[132], &reftables[133]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "map_entry", 7, &msgs[12], NULL, 9, 4, {0},&reftables[134], &reftables[135]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "message_set_wire_format", 1, &msgs[12], NULL, 6, 1, {0},&reftables[136], &reftables[137]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "message_type", 4, &msgs[9], (const upb_def*)(&msgs[0]), 10, 0, {0},&reftables[138], &reftables[139]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "method", 2, &msgs[16], (const upb_def*)(&msgs[13]), 6, 0, {0},&reftables[140], &reftables[141]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[3], NULL, 8, 2, {0},&reftables[142], &reftables[143]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[15], NULL, 2, 0, {0},&reftables[144], &reftables[145]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "name", 2, &msgs[20], (const upb_def*)(&msgs[21]), 5, 0, {0},&reftables[146], &reftables[147]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[0], NULL, 32, 8, {0},&reftables[148], &reftables[149]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[5], NULL, 4, 1, {0},&reftables[150], &reftables[151]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[9], NULL, 22, 6, {0},&reftables[152], &reftables[153]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[7], NULL, 4, 1, {0},&reftables[154], &reftables[155]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[13], NULL, 4, 1, {0},&reftables[156], &reftables[157]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[16], NULL, 8, 2, {0},&reftables[158], &reftables[159]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_STRING, 0, false, false, false, false, "name_part", 1, &msgs[21], NULL, 2, 0, {0},&reftables[160], &reftables[161]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT64, UPB_INTFMT_VARIABLE, false, false, false, false, "negative_int_value", 5, &msgs[20], NULL, 10, 3, {0},&reftables[162], &reftables[163]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "nested_type", 3, &msgs[0], (const upb_def*)(&msgs[0]), 15, 1, {0},&reftables[164], &reftables[165]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "no_standard_descriptor_accessor", 2, &msgs[12], NULL, 7, 2, {0},&reftables[166], &reftables[167]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 2, &msgs[5], NULL, 7, 2, {0},&reftables[168], &reftables[169]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 3, &msgs[7], NULL, 10, 3, {0},&reftables[170], &reftables[171]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "objc_class_prefix", 36, &msgs[11], NULL, 24, 13, {0},&reftables[172], &reftables[173]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "oneof_decl", 8, &msgs[0], (const upb_def*)(&msgs[15]), 28, 6, {0},&reftables[174], &reftables[175]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "oneof_index", 9, &msgs[7], NULL, 19, 8, {0},&reftables[176], &reftables[177]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "optimize_for", 9, &msgs[11], (const upb_def*)(&enums[4]), 12, 3, {0},&reftables[178], &reftables[179]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 7, &msgs[0], (const upb_def*)(&msgs[12]), 25, 5, {0},&reftables[180], &reftables[181]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[9], (const upb_def*)(&msgs[11]), 20, 4, {0},&reftables[182], &reftables[183]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 4, &msgs[13], (const upb_def*)(&msgs[14]), 3, 0, {0},&reftables[184], &reftables[185]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[7], (const upb_def*)(&msgs[8]), 3, 0, {0},&reftables[186], &reftables[187]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[16], (const upb_def*)(&msgs[17]), 7, 1, {0},&reftables[188], &reftables[189]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[5], (const upb_def*)(&msgs[6]), 3, 0, {0},&reftables[190], &reftables[191]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[3], (const upb_def*)(&msgs[4]), 7, 1, {0},&reftables[192], &reftables[193]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "output_type", 3, &msgs[13], NULL, 10, 3, {0},&reftables[194], &reftables[195]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "package", 2, &msgs[9], NULL, 25, 7, {0},&reftables[196], &reftables[197]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "packed", 2, &msgs[8], NULL, 7, 2, {0},&reftables[198], &reftables[199]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "path", 1, &msgs[19], NULL, 4, 0, {0},&reftables[200], &reftables[201]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_UINT64, UPB_INTFMT_VARIABLE, false, false, false, false, "positive_int_value", 4, &msgs[20], NULL, 9, 2, {0},&reftables[202], &reftables[203]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "public_dependency", 10, &msgs[9], NULL, 35, 9, {0},&reftables[204], &reftables[205]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "py_generic_services", 18, &msgs[11], NULL, 19, 8, {0},&reftables[206], &reftables[207]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "reserved_name", 10, &msgs[0], NULL, 37, 9, {0},&reftables[208], &reftables[209]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "reserved_range", 9, &msgs[0], (const upb_def*)(&msgs[2]), 31, 7, {0},&reftables[210], &reftables[211]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "server_streaming", 6, &msgs[13], NULL, 14, 5, {0},&reftables[212], &reftables[213]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "service", 6, &msgs[9], (const upb_def*)(&msgs[16]), 16, 2, {0},&reftables[214], &reftables[215]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "source_code_info", 9, &msgs[9], (const upb_def*)(&msgs[18]), 21, 5, {0},&reftables[216], &reftables[217]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "span", 2, &msgs[19], NULL, 7, 1, {0},&reftables[218], &reftables[219]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[2], NULL, 2, 0, {0},&reftables[220], &reftables[221]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[1], NULL, 2, 0, {0},&reftables[222], &reftables[223]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, false, false, false, "string_value", 7, &msgs[20], NULL, 12, 5, {0},&reftables[224], &reftables[225]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "syntax", 12, &msgs[9], NULL, 39, 11, {0},&reftables[226], &reftables[227]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "trailing_comments", 4, &msgs[19], NULL, 11, 3, {0},&reftables[228], &reftables[229]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "type", 5, &msgs[7], (const upb_def*)(&enums[1]), 12, 5, {0},&reftables[230], &reftables[231]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "type_name", 6, &msgs[7], NULL, 13, 6, {0},&reftables[232], &reftables[233]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[11], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[234], &reftables[235]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[12], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[236], &reftables[237]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[6], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[238], &reftables[239]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[4], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[240], &reftables[241]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[8], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[242], &reftables[243]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[14], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[244], &reftables[245]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[17], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[246], &reftables[247]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "value", 2, &msgs[3], (const upb_def*)(&msgs[5]), 6, 0, {0},&reftables[248], &reftables[249]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "weak", 10, &msgs[8], NULL, 11, 6, {0},&reftables[250], &reftables[251]), |
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "weak_dependency", 11, &msgs[9], NULL, 38, 10, {0},&reftables[252], &reftables[253]), |
-}; |
- |
-static const upb_enumdef enums[5] = { |
- UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Label", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[188]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[151], 4, 3), 0, &reftables[254], &reftables[255]), |
- UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Type", UPB_STRTABLE_INIT(18, 31, UPB_CTYPE_INT32, 5, &strentries[192]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[155], 19, 18), 0, &reftables[256], &reftables[257]), |
- UPB_ENUMDEF_INIT("google.protobuf.FieldOptions.CType", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[224]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[174], 3, 3), 0, &reftables[258], &reftables[259]), |
- UPB_ENUMDEF_INIT("google.protobuf.FieldOptions.JSType", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[228]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[177], 3, 3), 0, &reftables[260], &reftables[261]), |
- UPB_ENUMDEF_INIT("google.protobuf.FileOptions.OptimizeMode", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[232]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[180], 4, 3), 0, &reftables[262], &reftables[263]), |
-}; |
+static const upb_enumdef enums[4] = { |
+ UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Label", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[160]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[202], 4, 3), 0, &reftables[202], &reftables[203]), |
+ UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Type", UPB_STRTABLE_INIT(18, 31, UPB_CTYPE_INT32, 5, &strentries[164]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[206], 19, 18), 0, &reftables[204], &reftables[205]), |
+ UPB_ENUMDEF_INIT("google.protobuf.FieldOptions.CType", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[196]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[225], 3, 3), 0, &reftables[206], &reftables[207]), |
+ UPB_ENUMDEF_INIT("google.protobuf.FileOptions.OptimizeMode", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[200]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[228], 4, 3), 0, &reftables[208], &reftables[209]), |
+}; |
static const upb_tabent strentries[236] = { |
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_TABVALUE_PTR_INIT(&fields[22]), NULL}, |
+ {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_TABVALUE_PTR_INIT(&fields[14]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "reserved_name"), UPB_TABVALUE_PTR_INIT(&fields[82]), NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[52]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[38]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "field"), UPB_TABVALUE_PTR_INIT(&fields[25]), &strentries[12]}, |
- {UPB_TABKEY_STR("\017", "\000", "\000", "\000", "extension_range"), UPB_TABVALUE_PTR_INIT(&fields[24]), &strentries[14]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "nested_type"), UPB_TABVALUE_PTR_INIT(&fields[60]), NULL}, |
+ {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "field"), UPB_TABVALUE_PTR_INIT(&fields[16]), NULL}, |
+ {UPB_TABKEY_STR("\017", "\000", "\000", "\000", "extension_range"), UPB_TABVALUE_PTR_INIT(&fields[15]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\016", "\000", "\000", "\000", "reserved_range"), UPB_TABVALUE_PTR_INIT(&fields[83]), NULL}, |
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[68]), NULL}, |
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "oneof_decl"), UPB_TABVALUE_PTR_INIT(&fields[65]), NULL}, |
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[19]), &strentries[13]}, |
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[89]), NULL}, |
- {UPB_TABKEY_STR("\003", "\000", "\000", "\000", "end"), UPB_TABVALUE_PTR_INIT(&fields[18]), NULL}, |
+ {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "nested_type"), UPB_TABVALUE_PTR_INIT(&fields[44]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[88]), NULL}, |
- {UPB_TABKEY_STR("\003", "\000", "\000", "\000", "end"), UPB_TABVALUE_PTR_INIT(&fields[17]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[49]), NULL}, |
+ {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[9]), &strentries[14]}, |
+ {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[66]), NULL}, |
+ {UPB_TABKEY_STR("\003", "\000", "\000", "\000", "end"), UPB_TABVALUE_PTR_INIT(&fields[8]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "value"), UPB_TABVALUE_PTR_INIT(&fields[102]), NULL}, |
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[74]), NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[49]), &strentries[26]}, |
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL}, |
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[13]), NULL}, |
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "allow_alias"), UPB_TABVALUE_PTR_INIT(&fields[1]), NULL}, |
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[62]), NULL}, |
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[73]), NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[53]), &strentries[34]}, |
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[97]), NULL}, |
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[15]), NULL}, |
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "oneof_index"), UPB_TABVALUE_PTR_INIT(&fields[66]), NULL}, |
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "label"), UPB_TABVALUE_PTR_INIT(&fields[40]), NULL}, |
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[55]), NULL}, |
+ {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "value"), UPB_TABVALUE_PTR_INIT(&fields[78]), NULL}, |
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[50]), NULL}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[40]), &strentries[22]}, |
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[73]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "allow_alias"), UPB_TABVALUE_PTR_INIT(&fields[1]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[47]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[52]), NULL}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[37]), &strentries[30]}, |
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[71]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[63]), &strentries[53]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\010", "\000", "\000", "\000", "extendee"), UPB_TABVALUE_PTR_INIT(&fields[21]), NULL}, |
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "type_name"), UPB_TABVALUE_PTR_INIT(&fields[94]), NULL}, |
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "json_name"), UPB_TABVALUE_PTR_INIT(&fields[38]), NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "type"), UPB_TABVALUE_PTR_INIT(&fields[93]), &strentries[50]}, |
- {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "default_value"), UPB_TABVALUE_PTR_INIT(&fields[7]), NULL}, |
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[71]), NULL}, |
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "weak"), UPB_TABVALUE_PTR_INIT(&fields[103]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "label"), UPB_TABVALUE_PTR_INIT(&fields[27]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[41]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "packed"), UPB_TABVALUE_PTR_INIT(&fields[77]), NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "lazy"), UPB_TABVALUE_PTR_INIT(&fields[41]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "ctype"), UPB_TABVALUE_PTR_INIT(&fields[6]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "jstype"), UPB_TABVALUE_PTR_INIT(&fields[39]), NULL}, |
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[10]), NULL}, |
+ {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[46]), &strentries[49]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_TABVALUE_PTR_INIT(&fields[23]), NULL}, |
- {UPB_TABKEY_STR("\017", "\000", "\000", "\000", "weak_dependency"), UPB_TABVALUE_PTR_INIT(&fields[104]), NULL}, |
+ {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "type_name"), UPB_TABVALUE_PTR_INIT(&fields[70]), NULL}, |
+ {UPB_TABKEY_STR("\010", "\000", "\000", "\000", "extendee"), UPB_TABVALUE_PTR_INIT(&fields[12]), NULL}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "type"), UPB_TABVALUE_PTR_INIT(&fields[69]), &strentries[48]}, |
+ {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "default_value"), UPB_TABVALUE_PTR_INIT(&fields[4]), NULL}, |
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[51]), NULL}, |
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "experimental_map_key"), UPB_TABVALUE_PTR_INIT(&fields[11]), &strentries[67]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[54]), NULL}, |
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "service"), UPB_TABVALUE_PTR_INIT(&fields[85]), NULL}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "weak"), UPB_TABVALUE_PTR_INIT(&fields[79]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "source_code_info"), UPB_TABVALUE_PTR_INIT(&fields[86]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "syntax"), UPB_TABVALUE_PTR_INIT(&fields[91]), NULL}, |
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "dependency"), UPB_TABVALUE_PTR_INIT(&fields[8]), NULL}, |
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "message_type"), UPB_TABVALUE_PTR_INIT(&fields[47]), NULL}, |
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "package"), UPB_TABVALUE_PTR_INIT(&fields[76]), NULL}, |
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[69]), &strentries[86]}, |
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[20]), NULL}, |
- {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "public_dependency"), UPB_TABVALUE_PTR_INIT(&fields[80]), &strentries[85]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "file"), UPB_TABVALUE_PTR_INIT(&fields[26]), NULL}, |
+ {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "packed"), UPB_TABVALUE_PTR_INIT(&fields[58]), NULL}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "lazy"), UPB_TABVALUE_PTR_INIT(&fields[28]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "ctype"), UPB_TABVALUE_PTR_INIT(&fields[3]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[6]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "cc_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[3]), NULL}, |
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "csharp_namespace"), UPB_TABVALUE_PTR_INIT(&fields[5]), NULL}, |
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[77]), NULL}, |
+ {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_TABVALUE_PTR_INIT(&fields[13]), NULL}, |
+ {UPB_TABKEY_STR("\017", "\000", "\000", "\000", "weak_dependency"), UPB_TABVALUE_PTR_INIT(&fields[80]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[34]), NULL}, |
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "service"), UPB_TABVALUE_PTR_INIT(&fields[63]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "source_code_info"), UPB_TABVALUE_PTR_INIT(&fields[64]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "dependency"), UPB_TABVALUE_PTR_INIT(&fields[5]), NULL}, |
+ {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "message_type"), UPB_TABVALUE_PTR_INIT(&fields[32]), NULL}, |
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "package"), UPB_TABVALUE_PTR_INIT(&fields[57]), NULL}, |
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[53]), &strentries[82]}, |
+ {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[10]), NULL}, |
+ {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "public_dependency"), UPB_TABVALUE_PTR_INIT(&fields[61]), &strentries[81]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "file"), UPB_TABVALUE_PTR_INIT(&fields[17]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "go_package"), UPB_TABVALUE_PTR_INIT(&fields[27]), NULL}, |
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "java_package"), UPB_TABVALUE_PTR_INIT(&fields[35]), &strentries[120]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[75]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "java_outer_classname"), UPB_TABVALUE_PTR_INIT(&fields[34]), NULL}, |
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[95]), NULL}, |
+ {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "cc_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[2]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "java_multiple_files"), UPB_TABVALUE_PTR_INIT(&fields[24]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\025", "\000", "\000", "\000", "java_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[23]), &strentries[102]}, |
+ {UPB_TABKEY_STR("\035", "\000", "\000", "\000", "java_generate_equals_and_hash"), UPB_TABVALUE_PTR_INIT(&fields[22]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "java_multiple_files"), UPB_TABVALUE_PTR_INIT(&fields[33]), &strentries[117]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\025", "\000", "\000", "\000", "java_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[32]), &strentries[118]}, |
- {UPB_TABKEY_STR("\035", "\000", "\000", "\000", "java_generate_equals_and_hash"), UPB_TABVALUE_PTR_INIT(&fields[31]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\037", "\000", "\000", "\000", "javanano_use_deprecated_package"), UPB_TABVALUE_PTR_INIT(&fields[37]), &strentries[123]}, |
- {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "py_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[81]), NULL}, |
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "optimize_for"), UPB_TABVALUE_PTR_INIT(&fields[67]), NULL}, |
- {UPB_TABKEY_STR("\026", "\000", "\000", "\000", "java_string_check_utf8"), UPB_TABVALUE_PTR_INIT(&fields[36]), NULL}, |
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[12]), &strentries[119]}, |
- {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "objc_class_prefix"), UPB_TABVALUE_PTR_INIT(&fields[64]), NULL}, |
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "cc_enable_arenas"), UPB_TABVALUE_PTR_INIT(&fields[2]), NULL}, |
- {UPB_TABKEY_STR("\027", "\000", "\000", "\000", "message_set_wire_format"), UPB_TABVALUE_PTR_INIT(&fields[46]), &strentries[128]}, |
+ {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "go_package"), UPB_TABVALUE_PTR_INIT(&fields[18]), NULL}, |
+ {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "java_package"), UPB_TABVALUE_PTR_INIT(&fields[26]), NULL}, |
+ {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "optimize_for"), UPB_TABVALUE_PTR_INIT(&fields[48]), NULL}, |
+ {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "py_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[62]), NULL}, |
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "java_outer_classname"), UPB_TABVALUE_PTR_INIT(&fields[25]), NULL}, |
+ {UPB_TABKEY_STR("\027", "\000", "\000", "\000", "message_set_wire_format"), UPB_TABVALUE_PTR_INIT(&fields[31]), &strentries[106]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[76]), NULL}, |
+ {UPB_TABKEY_STR("\037", "\000", "\000", "\000", "no_standard_descriptor_accessor"), UPB_TABVALUE_PTR_INIT(&fields[45]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[96]), NULL}, |
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[9]), NULL}, |
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "map_entry"), UPB_TABVALUE_PTR_INIT(&fields[45]), NULL}, |
- {UPB_TABKEY_STR("\037", "\000", "\000", "\000", "no_standard_descriptor_accessor"), UPB_TABVALUE_PTR_INIT(&fields[61]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "client_streaming"), UPB_TABVALUE_PTR_INIT(&fields[4]), NULL}, |
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "server_streaming"), UPB_TABVALUE_PTR_INIT(&fields[84]), NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[56]), NULL}, |
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "input_type"), UPB_TABVALUE_PTR_INIT(&fields[29]), NULL}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[39]), NULL}, |
+ {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "input_type"), UPB_TABVALUE_PTR_INIT(&fields[20]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "output_type"), UPB_TABVALUE_PTR_INIT(&fields[75]), NULL}, |
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[70]), NULL}, |
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL}, |
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[11]), NULL}, |
+ {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "output_type"), UPB_TABVALUE_PTR_INIT(&fields[56]), NULL}, |
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[55]), NULL}, |
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[74]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[54]), &strentries[122]}, |
+ {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "method"), UPB_TABVALUE_PTR_INIT(&fields[33]), NULL}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[35]), &strentries[121]}, |
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[72]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[50]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[72]), &strentries[150]}, |
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "method"), UPB_TABVALUE_PTR_INIT(&fields[48]), NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[57]), &strentries[149]}, |
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL}, |
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[14]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\010", "\000", "\000", "\000", "location"), UPB_TABVALUE_PTR_INIT(&fields[30]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\010", "\000", "\000", "\000", "location"), UPB_TABVALUE_PTR_INIT(&fields[44]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "span"), UPB_TABVALUE_PTR_INIT(&fields[65]), &strentries[139]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "span"), UPB_TABVALUE_PTR_INIT(&fields[87]), &strentries[167]}, |
- {UPB_TABKEY_STR("\031", "\000", "\000", "\000", "leading_detached_comments"), UPB_TABVALUE_PTR_INIT(&fields[43]), &strentries[165]}, |
- {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "trailing_comments"), UPB_TABVALUE_PTR_INIT(&fields[92]), NULL}, |
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "leading_comments"), UPB_TABVALUE_PTR_INIT(&fields[42]), &strentries[164]}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "path"), UPB_TABVALUE_PTR_INIT(&fields[78]), NULL}, |
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "double_value"), UPB_TABVALUE_PTR_INIT(&fields[16]), NULL}, |
+ {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "trailing_comments"), UPB_TABVALUE_PTR_INIT(&fields[68]), NULL}, |
+ {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "leading_comments"), UPB_TABVALUE_PTR_INIT(&fields[29]), &strentries[137]}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "path"), UPB_TABVALUE_PTR_INIT(&fields[59]), NULL}, |
+ {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "double_value"), UPB_TABVALUE_PTR_INIT(&fields[7]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[51]), NULL}, |
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[36]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\022", "\000", "\000", "\000", "negative_int_value"), UPB_TABVALUE_PTR_INIT(&fields[59]), NULL}, |
+ {UPB_TABKEY_STR("\022", "\000", "\000", "\000", "negative_int_value"), UPB_TABVALUE_PTR_INIT(&fields[43]), NULL}, |
{UPB_TABKEY_STR("\017", "\000", "\000", "\000", "aggregate_value"), UPB_TABVALUE_PTR_INIT(&fields[0]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\022", "\000", "\000", "\000", "positive_int_value"), UPB_TABVALUE_PTR_INIT(&fields[79]), NULL}, |
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "identifier_value"), UPB_TABVALUE_PTR_INIT(&fields[28]), NULL}, |
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "string_value"), UPB_TABVALUE_PTR_INIT(&fields[90]), &strentries[182]}, |
+ {UPB_TABKEY_STR("\022", "\000", "\000", "\000", "positive_int_value"), UPB_TABVALUE_PTR_INIT(&fields[60]), NULL}, |
+ {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "identifier_value"), UPB_TABVALUE_PTR_INIT(&fields[19]), NULL}, |
+ {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "string_value"), UPB_TABVALUE_PTR_INIT(&fields[67]), &strentries[154]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "is_extension"), UPB_TABVALUE_PTR_INIT(&fields[30]), NULL}, |
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "name_part"), UPB_TABVALUE_PTR_INIT(&fields[58]), NULL}, |
- {UPB_TABKEY_STR("\016", "\000", "\000", "\000", "LABEL_REQUIRED"), UPB_TABVALUE_INT_INIT(2), &strentries[190]}, |
+ {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "is_extension"), UPB_TABVALUE_PTR_INIT(&fields[21]), NULL}, |
+ {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "name_part"), UPB_TABVALUE_PTR_INIT(&fields[42]), NULL}, |
+ {UPB_TABKEY_STR("\016", "\000", "\000", "\000", "LABEL_REQUIRED"), UPB_TABVALUE_INT_INIT(2), &strentries[162]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_STR("\016", "\000", "\000", "\000", "LABEL_REPEATED"), UPB_TABVALUE_INT_INIT(3), NULL}, |
{UPB_TABKEY_STR("\016", "\000", "\000", "\000", "LABEL_OPTIONAL"), UPB_TABVALUE_INT_INIT(1), NULL}, |
@@ -5864,17 +5274,17 @@ static const upb_tabent strentries[236] = { |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_STRING"), UPB_TABVALUE_INT_INIT(9), NULL}, |
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_FLOAT"), UPB_TABVALUE_INT_INIT(2), &strentries[221]}, |
+ {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_FLOAT"), UPB_TABVALUE_INT_INIT(2), &strentries[193]}, |
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_DOUBLE"), UPB_TABVALUE_INT_INIT(1), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_INT32"), UPB_TABVALUE_INT_INIT(5), NULL}, |
{UPB_TABKEY_STR("\015", "\000", "\000", "\000", "TYPE_SFIXED32"), UPB_TABVALUE_INT_INIT(15), NULL}, |
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "TYPE_FIXED32"), UPB_TABVALUE_INT_INIT(7), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "TYPE_MESSAGE"), UPB_TABVALUE_INT_INIT(11), &strentries[222]}, |
+ {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "TYPE_MESSAGE"), UPB_TABVALUE_INT_INIT(11), &strentries[194]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_INT64"), UPB_TABVALUE_INT_INIT(3), &strentries[219]}, |
+ {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_INT64"), UPB_TABVALUE_INT_INIT(3), &strentries[191]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
@@ -5882,7 +5292,7 @@ static const upb_tabent strentries[236] = { |
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "TYPE_ENUM"), UPB_TABVALUE_INT_INIT(14), NULL}, |
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_UINT32"), UPB_TABVALUE_INT_INIT(13), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_UINT64"), UPB_TABVALUE_INT_INIT(4), &strentries[218]}, |
+ {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_UINT64"), UPB_TABVALUE_INT_INIT(4), &strentries[190]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_STR("\015", "\000", "\000", "\000", "TYPE_SFIXED64"), UPB_TABVALUE_INT_INIT(16), NULL}, |
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_BYTES"), UPB_TABVALUE_INT_INIT(12), NULL}, |
@@ -5892,191 +5302,266 @@ static const upb_tabent strentries[236] = { |
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_SINT32"), UPB_TABVALUE_INT_INIT(17), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "CORD"), UPB_TABVALUE_INT_INIT(1), NULL}, |
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "STRING"), UPB_TABVALUE_INT_INIT(0), &strentries[225]}, |
+ {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "STRING"), UPB_TABVALUE_INT_INIT(0), &strentries[197]}, |
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "STRING_PIECE"), UPB_TABVALUE_INT_INIT(2), NULL}, |
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "JS_NORMAL"), UPB_TABVALUE_INT_INIT(0), NULL}, |
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "JS_NUMBER"), UPB_TABVALUE_INT_INIT(2), NULL}, |
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "JS_STRING"), UPB_TABVALUE_INT_INIT(1), NULL}, |
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "CODE_SIZE"), UPB_TABVALUE_INT_INIT(2), NULL}, |
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "SPEED"), UPB_TABVALUE_INT_INIT(1), &strentries[235]}, |
+ {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "SPEED"), UPB_TABVALUE_INT_INIT(1), &strentries[203]}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "LITE_RUNTIME"), UPB_TABVALUE_INT_INIT(3), NULL}, |
-}; |
- |
-static const upb_tabent intentries[18] = { |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[97]), NULL}, |
+ {UPB_TABKEY_STR("\047", "\000", "\000", "\000", "google.protobuf.SourceCodeInfo.Location"), UPB_TABVALUE_PTR_INIT(&msgs[17]), NULL}, |
+ {UPB_TABKEY_STR("\043", "\000", "\000", "\000", "google.protobuf.UninterpretedOption"), UPB_TABVALUE_PTR_INIT(&msgs[18]), NULL}, |
+ {UPB_TABKEY_STR("\043", "\000", "\000", "\000", "google.protobuf.FileDescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[8]), NULL}, |
+ {UPB_TABKEY_STR("\045", "\000", "\000", "\000", "google.protobuf.MethodDescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[12]), NULL}, |
+ {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\040", "\000", "\000", "\000", "google.protobuf.EnumValueOptions"), UPB_TABVALUE_PTR_INIT(&msgs[5]), NULL}, |
+ {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\037", "\000", "\000", "\000", "google.protobuf.DescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[0]), &strentries[228]}, |
+ {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_STR("\036", "\000", "\000", "\000", "google.protobuf.SourceCodeInfo"), UPB_TABVALUE_PTR_INIT(&msgs[16]), NULL}, |
+ {UPB_TABKEY_STR("\051", "\000", "\000", "\000", "google.protobuf.FieldDescriptorProto.Type"), UPB_TABVALUE_PTR_INIT(&enums[1]), NULL}, |
+ {UPB_TABKEY_STR("\056", "\000", "\000", "\000", "google.protobuf.DescriptorProto.ExtensionRange"), UPB_TABVALUE_PTR_INIT(&msgs[1]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL}, |
+ {UPB_TABKEY_STR("\050", "\000", "\000", "\000", "google.protobuf.EnumValueDescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[4]), NULL}, |
+ {UPB_TABKEY_STR("\034", "\000", "\000", "\000", "google.protobuf.FieldOptions"), UPB_TABVALUE_PTR_INIT(&msgs[7]), NULL}, |
+ {UPB_TABKEY_STR("\033", "\000", "\000", "\000", "google.protobuf.FileOptions"), UPB_TABVALUE_PTR_INIT(&msgs[10]), NULL}, |
+ {UPB_TABKEY_STR("\043", "\000", "\000", "\000", "google.protobuf.EnumDescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[2]), &strentries[233]}, |
+ {UPB_TABKEY_STR("\052", "\000", "\000", "\000", "google.protobuf.FieldDescriptorProto.Label"), UPB_TABVALUE_PTR_INIT(&enums[0]), NULL}, |
+ {UPB_TABKEY_STR("\046", "\000", "\000", "\000", "google.protobuf.ServiceDescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[14]), NULL}, |
+ {UPB_TABKEY_STR("\042", "\000", "\000", "\000", "google.protobuf.FieldOptions.CType"), UPB_TABVALUE_PTR_INIT(&enums[2]), &strentries[229]}, |
+ {UPB_TABKEY_STR("\041", "\000", "\000", "\000", "google.protobuf.FileDescriptorSet"), UPB_TABVALUE_PTR_INIT(&msgs[9]), &strentries[235]}, |
+ {UPB_TABKEY_STR("\033", "\000", "\000", "\000", "google.protobuf.EnumOptions"), UPB_TABVALUE_PTR_INIT(&msgs[3]), NULL}, |
+ {UPB_TABKEY_STR("\044", "\000", "\000", "\000", "google.protobuf.FieldDescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[6]), NULL}, |
+ {UPB_TABKEY_STR("\050", "\000", "\000", "\000", "google.protobuf.FileOptions.OptimizeMode"), UPB_TABVALUE_PTR_INIT(&enums[3]), &strentries[221]}, |
+ {UPB_TABKEY_STR("\036", "\000", "\000", "\000", "google.protobuf.ServiceOptions"), UPB_TABVALUE_PTR_INIT(&msgs[15]), NULL}, |
+ {UPB_TABKEY_STR("\036", "\000", "\000", "\000", "google.protobuf.MessageOptions"), UPB_TABVALUE_PTR_INIT(&msgs[11]), NULL}, |
+ {UPB_TABKEY_STR("\035", "\000", "\000", "\000", "google.protobuf.MethodOptions"), UPB_TABVALUE_PTR_INIT(&msgs[13]), &strentries[226]}, |
+ {UPB_TABKEY_STR("\054", "\000", "\000", "\000", "google.protobuf.UninterpretedOption.NamePart"), UPB_TABVALUE_PTR_INIT(&msgs[19]), NULL}, |
+}; |
+ |
+static const upb_tabent intentries[14] = { |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[95]), NULL}, |
+ {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[73]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[96]), NULL}, |
+ {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[71]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[11]), NULL}, |
+ {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[77]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL}, |
+ {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[75]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[14]), NULL}, |
+ {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[76]), NULL}, |
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL}, |
+ {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[74]), NULL}, |
+ {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, |
+ {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[72]), NULL}, |
}; |
-static const upb_tabval arrays[184] = { |
+static const upb_tabval arrays[232] = { |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[38]), |
+ UPB_TABVALUE_PTR_INIT(&fields[16]), |
+ UPB_TABVALUE_PTR_INIT(&fields[44]), |
+ UPB_TABVALUE_PTR_INIT(&fields[9]), |
+ UPB_TABVALUE_PTR_INIT(&fields[15]), |
+ UPB_TABVALUE_PTR_INIT(&fields[14]), |
+ UPB_TABVALUE_PTR_INIT(&fields[49]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[66]), |
+ UPB_TABVALUE_PTR_INIT(&fields[8]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[40]), |
+ UPB_TABVALUE_PTR_INIT(&fields[78]), |
+ UPB_TABVALUE_PTR_INIT(&fields[50]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[1]), |
UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[37]), |
+ UPB_TABVALUE_PTR_INIT(&fields[47]), |
UPB_TABVALUE_PTR_INIT(&fields[52]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[41]), |
+ UPB_TABVALUE_PTR_INIT(&fields[12]), |
+ UPB_TABVALUE_PTR_INIT(&fields[46]), |
+ UPB_TABVALUE_PTR_INIT(&fields[27]), |
+ UPB_TABVALUE_PTR_INIT(&fields[69]), |
+ UPB_TABVALUE_PTR_INIT(&fields[70]), |
+ UPB_TABVALUE_PTR_INIT(&fields[4]), |
+ UPB_TABVALUE_PTR_INIT(&fields[51]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[3]), |
+ UPB_TABVALUE_PTR_INIT(&fields[58]), |
+ UPB_TABVALUE_PTR_INIT(&fields[6]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[28]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[11]), |
+ UPB_TABVALUE_PTR_INIT(&fields[79]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[34]), |
+ UPB_TABVALUE_PTR_INIT(&fields[57]), |
+ UPB_TABVALUE_PTR_INIT(&fields[5]), |
+ UPB_TABVALUE_PTR_INIT(&fields[32]), |
+ UPB_TABVALUE_PTR_INIT(&fields[10]), |
+ UPB_TABVALUE_PTR_INIT(&fields[63]), |
+ UPB_TABVALUE_PTR_INIT(&fields[13]), |
+ UPB_TABVALUE_PTR_INIT(&fields[53]), |
+ UPB_TABVALUE_PTR_INIT(&fields[64]), |
+ UPB_TABVALUE_PTR_INIT(&fields[61]), |
+ UPB_TABVALUE_PTR_INIT(&fields[80]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[17]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[26]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_PTR_INIT(&fields[25]), |
- UPB_TABVALUE_PTR_INIT(&fields[60]), |
- UPB_TABVALUE_PTR_INIT(&fields[19]), |
+ UPB_TABVALUE_PTR_INIT(&fields[48]), |
UPB_TABVALUE_PTR_INIT(&fields[24]), |
+ UPB_TABVALUE_PTR_INIT(&fields[18]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[2]), |
+ UPB_TABVALUE_PTR_INIT(&fields[23]), |
+ UPB_TABVALUE_PTR_INIT(&fields[62]), |
+ UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_PTR_INIT(&fields[22]), |
- UPB_TABVALUE_PTR_INIT(&fields[68]), |
- UPB_TABVALUE_PTR_INIT(&fields[65]), |
- UPB_TABVALUE_PTR_INIT(&fields[83]), |
- UPB_TABVALUE_PTR_INIT(&fields[82]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[89]), |
- UPB_TABVALUE_PTR_INIT(&fields[18]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[88]), |
- UPB_TABVALUE_PTR_INIT(&fields[17]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[49]), |
- UPB_TABVALUE_PTR_INIT(&fields[102]), |
- UPB_TABVALUE_PTR_INIT(&fields[74]), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[1]), |
- UPB_TABVALUE_PTR_INIT(&fields[13]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[53]), |
- UPB_TABVALUE_PTR_INIT(&fields[62]), |
- UPB_TABVALUE_PTR_INIT(&fields[73]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[15]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[55]), |
- UPB_TABVALUE_PTR_INIT(&fields[21]), |
- UPB_TABVALUE_PTR_INIT(&fields[63]), |
- UPB_TABVALUE_PTR_INIT(&fields[40]), |
- UPB_TABVALUE_PTR_INIT(&fields[93]), |
- UPB_TABVALUE_PTR_INIT(&fields[94]), |
- UPB_TABVALUE_PTR_INIT(&fields[7]), |
- UPB_TABVALUE_PTR_INIT(&fields[71]), |
- UPB_TABVALUE_PTR_INIT(&fields[66]), |
- UPB_TABVALUE_PTR_INIT(&fields[38]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[6]), |
- UPB_TABVALUE_PTR_INIT(&fields[77]), |
- UPB_TABVALUE_PTR_INIT(&fields[10]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[41]), |
- UPB_TABVALUE_PTR_INIT(&fields[39]), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[103]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[54]), |
- UPB_TABVALUE_PTR_INIT(&fields[76]), |
- UPB_TABVALUE_PTR_INIT(&fields[8]), |
- UPB_TABVALUE_PTR_INIT(&fields[47]), |
- UPB_TABVALUE_PTR_INIT(&fields[20]), |
- UPB_TABVALUE_PTR_INIT(&fields[85]), |
- UPB_TABVALUE_PTR_INIT(&fields[23]), |
- UPB_TABVALUE_PTR_INIT(&fields[69]), |
- UPB_TABVALUE_PTR_INIT(&fields[86]), |
- UPB_TABVALUE_PTR_INIT(&fields[80]), |
- UPB_TABVALUE_PTR_INIT(&fields[104]), |
- UPB_TABVALUE_PTR_INIT(&fields[91]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[26]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[35]), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[34]), |
- UPB_TABVALUE_PTR_INIT(&fields[67]), |
- UPB_TABVALUE_PTR_INIT(&fields[33]), |
- UPB_TABVALUE_PTR_INIT(&fields[27]), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[3]), |
- UPB_TABVALUE_PTR_INIT(&fields[32]), |
- UPB_TABVALUE_PTR_INIT(&fields[81]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[31]), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[12]), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[36]), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[2]), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[64]), |
- UPB_TABVALUE_PTR_INIT(&fields[5]), |
- UPB_TABVALUE_PTR_INIT(&fields[37]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[46]), |
- UPB_TABVALUE_PTR_INIT(&fields[61]), |
- UPB_TABVALUE_PTR_INIT(&fields[9]), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[31]), |
UPB_TABVALUE_PTR_INIT(&fields[45]), |
UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[39]), |
+ UPB_TABVALUE_PTR_INIT(&fields[20]), |
UPB_TABVALUE_PTR_INIT(&fields[56]), |
- UPB_TABVALUE_PTR_INIT(&fields[29]), |
- UPB_TABVALUE_PTR_INIT(&fields[75]), |
- UPB_TABVALUE_PTR_INIT(&fields[70]), |
- UPB_TABVALUE_PTR_INIT(&fields[4]), |
- UPB_TABVALUE_PTR_INIT(&fields[84]), |
+ UPB_TABVALUE_PTR_INIT(&fields[55]), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[50]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[57]), |
- UPB_TABVALUE_PTR_INIT(&fields[48]), |
- UPB_TABVALUE_PTR_INIT(&fields[72]), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[44]), |
+ UPB_TABVALUE_PTR_INIT(&fields[35]), |
+ UPB_TABVALUE_PTR_INIT(&fields[33]), |
+ UPB_TABVALUE_PTR_INIT(&fields[54]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[78]), |
- UPB_TABVALUE_PTR_INIT(&fields[87]), |
- UPB_TABVALUE_PTR_INIT(&fields[42]), |
- UPB_TABVALUE_PTR_INIT(&fields[92]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[43]), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[51]), |
- UPB_TABVALUE_PTR_INIT(&fields[28]), |
- UPB_TABVALUE_PTR_INIT(&fields[79]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[30]), |
+ UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_PTR_INIT(&fields[59]), |
- UPB_TABVALUE_PTR_INIT(&fields[16]), |
- UPB_TABVALUE_PTR_INIT(&fields[90]), |
+ UPB_TABVALUE_PTR_INIT(&fields[65]), |
+ UPB_TABVALUE_PTR_INIT(&fields[29]), |
+ UPB_TABVALUE_PTR_INIT(&fields[68]), |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_EMPTY_INIT, |
+ UPB_TABVALUE_PTR_INIT(&fields[36]), |
+ UPB_TABVALUE_PTR_INIT(&fields[19]), |
+ UPB_TABVALUE_PTR_INIT(&fields[60]), |
+ UPB_TABVALUE_PTR_INIT(&fields[43]), |
+ UPB_TABVALUE_PTR_INIT(&fields[7]), |
+ UPB_TABVALUE_PTR_INIT(&fields[67]), |
UPB_TABVALUE_PTR_INIT(&fields[0]), |
UPB_TABVALUE_EMPTY_INIT, |
- UPB_TABVALUE_PTR_INIT(&fields[58]), |
- UPB_TABVALUE_PTR_INIT(&fields[30]), |
+ UPB_TABVALUE_PTR_INIT(&fields[42]), |
+ UPB_TABVALUE_PTR_INIT(&fields[21]), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_PTR_INIT("LABEL_OPTIONAL"), |
UPB_TABVALUE_PTR_INIT("LABEL_REQUIRED"), |
@@ -6103,69 +5588,21 @@ static const upb_tabval arrays[184] = { |
UPB_TABVALUE_PTR_INIT("STRING"), |
UPB_TABVALUE_PTR_INIT("CORD"), |
UPB_TABVALUE_PTR_INIT("STRING_PIECE"), |
- UPB_TABVALUE_PTR_INIT("JS_NORMAL"), |
- UPB_TABVALUE_PTR_INIT("JS_STRING"), |
- UPB_TABVALUE_PTR_INIT("JS_NUMBER"), |
UPB_TABVALUE_EMPTY_INIT, |
UPB_TABVALUE_PTR_INIT("SPEED"), |
UPB_TABVALUE_PTR_INIT("CODE_SIZE"), |
UPB_TABVALUE_PTR_INIT("LITE_RUNTIME"), |
}; |
+static const upb_symtab symtab = UPB_SYMTAB_INIT(UPB_STRTABLE_INIT(24, 31, UPB_CTYPE_PTR, 5, &strentries[204]), &reftables[210], &reftables[211]); |
+ |
+const upb_symtab *upbdefs_google_protobuf_descriptor(const void *owner) { |
+ upb_symtab_ref(&symtab, owner); |
+ return &symtab; |
+} |
+ |
#ifdef UPB_DEBUG_REFS |
-static upb_inttable reftables[264] = { |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
+static upb_inttable reftables[212] = { |
UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), |
@@ -6381,45 +5818,6 @@ static upb_inttable reftables[264] = { |
}; |
#endif |
-static const upb_msgdef *refm(const upb_msgdef *m, const void *owner) { |
- upb_msgdef_ref(m, owner); |
- return m; |
-} |
- |
-static const upb_enumdef *refe(const upb_enumdef *e, const void *owner) { |
- upb_enumdef_ref(e, owner); |
- return e; |
-} |
- |
-/* Public API. */ |
-const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_get(const void *owner) { return refm(&msgs[0], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_get(const void *owner) { return refm(&msgs[1], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_get(const void *owner) { return refm(&msgs[2], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_EnumDescriptorProto_get(const void *owner) { return refm(&msgs[3], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_EnumOptions_get(const void *owner) { return refm(&msgs[4], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_EnumValueDescriptorProto_get(const void *owner) { return refm(&msgs[5], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_EnumValueOptions_get(const void *owner) { return refm(&msgs[6], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_FieldDescriptorProto_get(const void *owner) { return refm(&msgs[7], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_FieldOptions_get(const void *owner) { return refm(&msgs[8], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_FileDescriptorProto_get(const void *owner) { return refm(&msgs[9], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_FileDescriptorSet_get(const void *owner) { return refm(&msgs[10], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_FileOptions_get(const void *owner) { return refm(&msgs[11], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_MessageOptions_get(const void *owner) { return refm(&msgs[12], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_MethodDescriptorProto_get(const void *owner) { return refm(&msgs[13], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_MethodOptions_get(const void *owner) { return refm(&msgs[14], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_OneofDescriptorProto_get(const void *owner) { return refm(&msgs[15], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_ServiceDescriptorProto_get(const void *owner) { return refm(&msgs[16], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_ServiceOptions_get(const void *owner) { return refm(&msgs[17], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_get(const void *owner) { return refm(&msgs[18], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_Location_get(const void *owner) { return refm(&msgs[19], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_get(const void *owner) { return refm(&msgs[20], owner); } |
-const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_NamePart_get(const void *owner) { return refm(&msgs[21], owner); } |
- |
-const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Label_get(const void *owner) { return refe(&enums[0], owner); } |
-const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Type_get(const void *owner) { return refe(&enums[1], owner); } |
-const upb_enumdef *upbdefs_google_protobuf_FieldOptions_CType_get(const void *owner) { return refe(&enums[2], owner); } |
-const upb_enumdef *upbdefs_google_protobuf_FieldOptions_JSType_get(const void *owner) { return refe(&enums[3], owner); } |
-const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode_get(const void *owner) { return refe(&enums[4], owner); } |
/* |
** XXX: The routines in this file that consume a string do not currently |
** support having the string span buffers. In the future, as upb_sink and |
@@ -6433,10 +5831,14 @@ const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode_get(const vo |
#include <stdlib.h> |
#include <string.h> |
-/* Compares a NULL-terminated string with a non-NULL-terminated string. */ |
-static bool upb_streq(const char *str, const char *buf, size_t n) { |
- return strlen(str) == n && memcmp(str, buf, n) == 0; |
-} |
+/* upb_deflist is an internal-only dynamic array for storing a growing list of |
+ * upb_defs. */ |
+typedef struct { |
+ upb_def **defs; |
+ size_t len; |
+ size_t size; |
+ bool owned; |
+} upb_deflist; |
/* We keep a stack of all the messages scopes we are currently in, as well as |
* the top-level file scope. This is necessary to correctly qualify the |
@@ -6447,8 +5849,6 @@ typedef struct { |
/* Index of the first def that is under this scope. For msgdefs, the |
* msgdef itself is at start-1. */ |
int start; |
- uint32_t oneof_start; |
- uint32_t oneof_index; |
} upb_descreader_frame; |
/* The maximum number of nested declarations that are allowed, ie. |
@@ -6465,11 +5865,9 @@ typedef struct { |
struct upb_descreader { |
upb_sink sink; |
- upb_inttable files; |
- upb_filedef *file; /* The last file in files. */ |
+ upb_deflist defs; |
upb_descreader_frame stack[UPB_MAX_MESSAGE_NESTING]; |
int stack_len; |
- upb_inttable oneofs; |
uint32_t number; |
char *name; |
@@ -6482,7 +5880,7 @@ struct upb_descreader { |
}; |
static char *upb_strndup(const char *buf, size_t n) { |
- char *ret = upb_gmalloc(n + 1); |
+ char *ret = malloc(n + 1); |
if (!ret) return NULL; |
memcpy(ret, buf, n); |
ret[n] = '\0'; |
@@ -6496,12 +5894,9 @@ static char *upb_strndup(const char *buf, size_t n) { |
* Caller owns a ref on the returned string. */ |
static char *upb_join(const char *base, const char *name) { |
if (!base || strlen(base) == 0) { |
- return upb_gstrdup(name); |
+ return upb_strdup(name); |
} else { |
- char *ret = upb_gmalloc(strlen(base) + strlen(name) + 2); |
- if (!ret) { |
- return NULL; |
- } |
+ char *ret = malloc(strlen(base) + strlen(name) + 2); |
ret[0] = '\0'; |
strcat(ret, base); |
strcat(ret, "."); |
@@ -6510,200 +5905,121 @@ static char *upb_join(const char *base, const char *name) { |
} |
} |
-/* Qualify the defname for all defs starting with offset "start" with "str". */ |
-static bool upb_descreader_qualify(upb_filedef *f, char *str, int32_t start) { |
- size_t i; |
- for (i = start; i < upb_filedef_defcount(f); i++) { |
- upb_def *def = upb_filedef_mutabledef(f, i); |
- char *name = upb_join(str, upb_def_fullname(def)); |
- if (!name) { |
- /* Need better logic here; at this point we've qualified some names but |
- * not others. */ |
- return false; |
- } |
- upb_def_setfullname(def, name, NULL); |
- upb_gfree(name); |
- } |
- return true; |
-} |
- |
-/* upb_descreader ************************************************************/ |
+/* upb_deflist ****************************************************************/ |
-static upb_msgdef *upb_descreader_top(upb_descreader *r) { |
- int index; |
- UPB_ASSERT(r->stack_len > 1); |
- index = r->stack[r->stack_len-1].start - 1; |
- UPB_ASSERT(index >= 0); |
- return upb_downcast_msgdef_mutable(upb_filedef_mutabledef(r->file, index)); |
+void upb_deflist_init(upb_deflist *l) { |
+ l->size = 0; |
+ l->defs = NULL; |
+ l->len = 0; |
+ l->owned = true; |
} |
-static upb_def *upb_descreader_last(upb_descreader *r) { |
- return upb_filedef_mutabledef(r->file, upb_filedef_defcount(r->file) - 1); |
-} |
- |
-/* Start/end handlers for FileDescriptorProto and DescriptorProto (the two |
- * entities that have names and can contain sub-definitions. */ |
-void upb_descreader_startcontainer(upb_descreader *r) { |
- upb_descreader_frame *f = &r->stack[r->stack_len++]; |
- f->start = upb_filedef_defcount(r->file); |
- f->oneof_start = upb_inttable_count(&r->oneofs); |
- f->oneof_index = 0; |
- f->name = NULL; |
+void upb_deflist_uninit(upb_deflist *l) { |
+ size_t i; |
+ if (l->owned) |
+ for(i = 0; i < l->len; i++) |
+ upb_def_unref(l->defs[i], l); |
+ free(l->defs); |
} |
-bool upb_descreader_endcontainer(upb_descreader *r) { |
- upb_descreader_frame *f = &r->stack[r->stack_len - 1]; |
- |
- while (upb_inttable_count(&r->oneofs) > f->oneof_start) { |
- upb_oneofdef *o = upb_value_getptr(upb_inttable_pop(&r->oneofs)); |
- bool ok = upb_msgdef_addoneof(upb_descreader_top(r), o, &r->oneofs, NULL); |
- UPB_ASSERT(ok); |
+bool upb_deflist_push(upb_deflist *l, upb_def *d) { |
+ if(++l->len >= l->size) { |
+ size_t new_size = UPB_MAX(l->size, 4); |
+ new_size *= 2; |
+ l->defs = realloc(l->defs, new_size * sizeof(void *)); |
+ if (!l->defs) return false; |
+ l->size = new_size; |
} |
- |
- if (!upb_descreader_qualify(r->file, f->name, f->start)) { |
- return false; |
- } |
- upb_gfree(f->name); |
- f->name = NULL; |
- |
- r->stack_len--; |
+ l->defs[l->len - 1] = d; |
return true; |
} |
-void upb_descreader_setscopename(upb_descreader *r, char *str) { |
- upb_descreader_frame *f = &r->stack[r->stack_len-1]; |
- upb_gfree(f->name); |
- f->name = str; |
-} |
- |
-static upb_oneofdef *upb_descreader_getoneof(upb_descreader *r, |
- uint32_t index) { |
- bool found; |
- upb_value val; |
- upb_descreader_frame *f = &r->stack[r->stack_len-1]; |
- |
- /* DescriptorProto messages can be nested, so we will see the nested messages |
- * between when we see the FieldDescriptorProto and the OneofDescriptorProto. |
- * We need to preserve the oneofs in between these two things. */ |
- index += f->oneof_start; |
- |
- while (upb_inttable_count(&r->oneofs) <= index) { |
- upb_inttable_push(&r->oneofs, upb_value_ptr(upb_oneofdef_new(&r->oneofs))); |
- } |
- |
- found = upb_inttable_lookup(&r->oneofs, index, &val); |
- UPB_ASSERT(found); |
- return upb_value_getptr(val); |
+void upb_deflist_donaterefs(upb_deflist *l, void *owner) { |
+ size_t i; |
+ assert(l->owned); |
+ for (i = 0; i < l->len; i++) |
+ upb_def_donateref(l->defs[i], l, owner); |
+ l->owned = false; |
} |
-/** Handlers for google.protobuf.FileDescriptorSet. ***************************/ |
- |
-static void *fileset_startfile(void *closure, const void *hd) { |
- upb_descreader *r = closure; |
- UPB_UNUSED(hd); |
- r->file = upb_filedef_new(&r->files); |
- upb_inttable_push(&r->files, upb_value_ptr(r->file)); |
- return r; |
+static upb_def *upb_deflist_last(upb_deflist *l) { |
+ return l->defs[l->len-1]; |
} |
-/** Handlers for google.protobuf.FileDescriptorProto. *************************/ |
- |
-static bool file_start(void *closure, const void *hd) { |
- upb_descreader *r = closure; |
- UPB_UNUSED(hd); |
- upb_descreader_startcontainer(r); |
- return true; |
-} |
- |
-static bool file_end(void *closure, const void *hd, upb_status *status) { |
- upb_descreader *r = closure; |
- UPB_UNUSED(hd); |
- UPB_UNUSED(status); |
- return upb_descreader_endcontainer(r); |
+/* Qualify the defname for all defs starting with offset "start" with "str". */ |
+static void upb_deflist_qualify(upb_deflist *l, char *str, int32_t start) { |
+ uint32_t i; |
+ for (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, NULL); |
+ free(name); |
+ } |
} |
-static size_t file_onname(void *closure, const void *hd, const char *buf, |
- size_t n, const upb_bufhandle *handle) { |
- upb_descreader *r = closure; |
- char *name; |
- bool ok; |
- UPB_UNUSED(hd); |
- UPB_UNUSED(handle); |
- name = upb_strndup(buf, n); |
- /* XXX: see comment at the top of the file. */ |
- ok = upb_filedef_setname(r->file, name, NULL); |
- upb_gfree(name); |
- UPB_ASSERT(ok); |
- return n; |
-} |
+/* upb_descreader ************************************************************/ |
-static size_t file_onpackage(void *closure, const void *hd, const char *buf, |
- size_t n, const upb_bufhandle *handle) { |
- upb_descreader *r = closure; |
- char *package; |
- bool ok; |
- UPB_UNUSED(hd); |
- UPB_UNUSED(handle); |
+static upb_msgdef *upb_descreader_top(upb_descreader *r) { |
+ int index; |
+ assert(r->stack_len > 1); |
+ index = r->stack[r->stack_len-1].start - 1; |
+ assert(index >= 0); |
+ return upb_downcast_msgdef_mutable(r->defs.defs[index]); |
+} |
- package = upb_strndup(buf, n); |
- /* XXX: see comment at the top of the file. */ |
- upb_descreader_setscopename(r, package); |
- ok = upb_filedef_setpackage(r->file, package, NULL); |
- UPB_ASSERT(ok); |
- return n; |
+static upb_def *upb_descreader_last(upb_descreader *r) { |
+ return upb_deflist_last(&r->defs); |
} |
-static size_t file_onsyntax(void *closure, const void *hd, const char *buf, |
- size_t n, const upb_bufhandle *handle) { |
- upb_descreader *r = closure; |
- bool ok; |
- UPB_UNUSED(hd); |
- UPB_UNUSED(handle); |
- /* XXX: see comment at the top of the file. */ |
- if (upb_streq("proto2", buf, n)) { |
- ok = upb_filedef_setsyntax(r->file, UPB_SYNTAX_PROTO2, NULL); |
- } else if (upb_streq("proto3", buf, n)) { |
- ok = upb_filedef_setsyntax(r->file, UPB_SYNTAX_PROTO3, NULL); |
- } else { |
- ok = false; |
- } |
+/* Start/end handlers for FileDescriptorProto and DescriptorProto (the two |
+ * entities that have names and can contain sub-definitions. */ |
+void upb_descreader_startcontainer(upb_descreader *r) { |
+ upb_descreader_frame *f = &r->stack[r->stack_len++]; |
+ f->start = r->defs.len; |
+ f->name = NULL; |
+} |
- UPB_ASSERT(ok); |
- return n; |
+void upb_descreader_endcontainer(upb_descreader *r) { |
+ upb_descreader_frame *f = &r->stack[--r->stack_len]; |
+ upb_deflist_qualify(&r->defs, f->name, f->start); |
+ free(f->name); |
+ f->name = NULL; |
} |
-static void *file_startmsg(void *closure, const void *hd) { |
- upb_descreader *r = closure; |
- upb_msgdef *m = upb_msgdef_new(&m); |
- bool ok = upb_filedef_addmsg(r->file, m, &m, NULL); |
+void upb_descreader_setscopename(upb_descreader *r, char *str) { |
+ upb_descreader_frame *f = &r->stack[r->stack_len-1]; |
+ free(f->name); |
+ f->name = str; |
+} |
+ |
+/* Handlers for google.protobuf.FileDescriptorProto. */ |
+static bool file_startmsg(void *r, const void *hd) { |
UPB_UNUSED(hd); |
- UPB_ASSERT(ok); |
- return r; |
+ upb_descreader_startcontainer(r); |
+ return true; |
} |
-static void *file_startenum(void *closure, const void *hd) { |
+static bool file_endmsg(void *closure, const void *hd, upb_status *status) { |
upb_descreader *r = closure; |
- upb_enumdef *e = upb_enumdef_new(&e); |
- bool ok = upb_filedef_addenum(r->file, e, &e, NULL); |
UPB_UNUSED(hd); |
- UPB_ASSERT(ok); |
- return r; |
+ UPB_UNUSED(status); |
+ upb_descreader_endcontainer(r); |
+ return true; |
} |
-static void *file_startext(void *closure, const void *hd) { |
+static size_t file_onpackage(void *closure, const void *hd, const char *buf, |
+ size_t n, const upb_bufhandle *handle) { |
upb_descreader *r = closure; |
- bool ok; |
- r->f = upb_fielddef_new(r); |
- ok = upb_filedef_addext(r->file, r->f, r, NULL); |
UPB_UNUSED(hd); |
- UPB_ASSERT(ok); |
- return r; |
+ UPB_UNUSED(handle); |
+ /* XXX: see comment at the top of the file. */ |
+ upb_descreader_setscopename(r, upb_strndup(buf, n)); |
+ return n; |
} |
-/** Handlers for google.protobuf.EnumValueDescriptorProto. *********************/ |
- |
+/* Handlers for google.protobuf.EnumValueDescriptorProto. */ |
static bool enumval_startmsg(void *closure, const void *hd) { |
upb_descreader *r = closure; |
UPB_UNUSED(hd); |
@@ -6718,7 +6034,7 @@ static size_t enumval_onname(void *closure, const void *hd, const char *buf, |
UPB_UNUSED(hd); |
UPB_UNUSED(handle); |
/* XXX: see comment at the top of the file. */ |
- upb_gfree(r->name); |
+ free(r->name); |
r->name = upb_strndup(buf, n); |
r->saw_name = true; |
return n; |
@@ -6743,12 +6059,20 @@ static bool enumval_endmsg(void *closure, const void *hd, upb_status *status) { |
} |
e = upb_downcast_enumdef_mutable(upb_descreader_last(r)); |
upb_enumdef_addval(e, r->name, r->number, status); |
- upb_gfree(r->name); |
+ free(r->name); |
r->name = NULL; |
return true; |
} |
-/** Handlers for google.protobuf.EnumDescriptorProto. *************************/ |
+ |
+/* Handlers for google.protobuf.EnumDescriptorProto. */ |
+static bool enum_startmsg(void *closure, const void *hd) { |
+ upb_descreader *r = closure; |
+ UPB_UNUSED(hd); |
+ upb_deflist_push(&r->defs, |
+ upb_enumdef_upcast_mutable(upb_enumdef_new(&r->defs))); |
+ return true; |
+} |
static bool enum_endmsg(void *closure, const void *hd, upb_status *status) { |
upb_descreader *r = closure; |
@@ -6775,17 +6099,16 @@ static size_t enum_onname(void *closure, const void *hd, const char *buf, |
UPB_UNUSED(handle); |
/* XXX: see comment at the top of the file. */ |
upb_def_setfullname(upb_descreader_last(r), fullname, NULL); |
- upb_gfree(fullname); |
+ free(fullname); |
return n; |
} |
-/** Handlers for google.protobuf.FieldDescriptorProto *************************/ |
- |
+/* Handlers for google.protobuf.FieldDescriptorProto */ |
static bool field_startmsg(void *closure, const void *hd) { |
upb_descreader *r = closure; |
UPB_UNUSED(hd); |
- UPB_ASSERT(r->f); |
- upb_gfree(r->default_string); |
+ r->f = upb_fielddef_new(&r->defs); |
+ free(r->default_string); |
r->default_string = NULL; |
/* fielddefs default to packed, but descriptors default to non-packed. */ |
@@ -6870,9 +6193,9 @@ static bool field_endmsg(void *closure, const void *hd, upb_status *status) { |
UPB_UNUSED(hd); |
/* TODO: verify that all required fields were present. */ |
- UPB_ASSERT(upb_fielddef_number(f) != 0); |
- UPB_ASSERT(upb_fielddef_name(f) != NULL); |
- UPB_ASSERT((upb_fielddef_subdefname(f) != NULL) == upb_fielddef_hassubdef(f)); |
+ assert(upb_fielddef_number(f) != 0); |
+ assert(upb_fielddef_name(f) != NULL); |
+ assert((upb_fielddef_subdefname(f) != NULL) == upb_fielddef_hassubdef(f)); |
if (r->default_string) { |
if (upb_fielddef_issubmsg(f)) { |
@@ -6927,11 +6250,10 @@ 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_descreader *r = closure; |
- bool ok; |
+ bool ok = upb_fielddef_setnumber(r->f, val, NULL); |
UPB_UNUSED(hd); |
- ok = upb_fielddef_setnumber(r->f, val, NULL); |
- UPB_ASSERT(ok); |
+ UPB_ASSERT_VAR(ok, ok); |
return true; |
} |
@@ -6944,7 +6266,7 @@ static size_t field_onname(void *closure, const void *hd, const char *buf, |
/* XXX: see comment at the top of the file. */ |
upb_fielddef_setname(r->f, name, NULL); |
- upb_gfree(name); |
+ free(name); |
return n; |
} |
@@ -6957,7 +6279,7 @@ static size_t field_ontypename(void *closure, const void *hd, const char *buf, |
/* XXX: see comment at the top of the file. */ |
upb_fielddef_setsubdefname(r->f, name, NULL); |
- upb_gfree(name); |
+ free(name); |
return n; |
} |
@@ -6970,7 +6292,7 @@ static size_t field_onextendee(void *closure, const void *hd, const char *buf, |
/* XXX: see comment at the top of the file. */ |
upb_fielddef_setcontainingtypename(r->f, name, NULL); |
- upb_gfree(name); |
+ free(name); |
return n; |
} |
@@ -6983,49 +6305,23 @@ static size_t field_ondefaultval(void *closure, const void *hd, const char *buf, |
/* Have to convert from string to the correct type, but we might not know the |
* type yet, so we save it as a string until the end of the field. |
* XXX: see comment at the top of the file. */ |
- upb_gfree(r->default_string); |
+ free(r->default_string); |
r->default_string = upb_strndup(buf, n); |
return n; |
} |
-static bool field_ononeofindex(void *closure, const void *hd, int32_t index) { |
- upb_descreader *r = closure; |
- upb_oneofdef *o = upb_descreader_getoneof(r, index); |
- bool ok = upb_oneofdef_addfield(o, r->f, &r->f, NULL); |
- UPB_UNUSED(hd); |
- |
- UPB_ASSERT(ok); |
- return true; |
-} |
- |
-/** Handlers for google.protobuf.OneofDescriptorProto. ************************/ |
- |
-static size_t oneof_name(void *closure, const void *hd, const char *buf, |
- size_t n, const upb_bufhandle *handle) { |
- upb_descreader *r = closure; |
- upb_descreader_frame *f = &r->stack[r->stack_len-1]; |
- upb_oneofdef *o = upb_descreader_getoneof(r, f->oneof_index++); |
- char *name_null_terminated = upb_strndup(buf, n); |
- bool ok = upb_oneofdef_setname(o, name_null_terminated, NULL); |
- UPB_UNUSED(hd); |
- UPB_UNUSED(handle); |
- |
- UPB_ASSERT(ok); |
- free(name_null_terminated); |
- return n; |
-} |
- |
-/** Handlers for google.protobuf.DescriptorProto ******************************/ |
- |
-static bool msg_start(void *closure, const void *hd) { |
+/* Handlers for google.protobuf.DescriptorProto (representing a message). */ |
+static bool msg_startmsg(void *closure, const void *hd) { |
upb_descreader *r = closure; |
UPB_UNUSED(hd); |
+ upb_deflist_push(&r->defs, |
+ upb_msgdef_upcast_mutable(upb_msgdef_new(&r->defs))); |
upb_descreader_startcontainer(r); |
return true; |
} |
-static bool msg_end(void *closure, const void *hd, upb_status *status) { |
+static bool msg_endmsg(void *closure, const void *hd, upb_status *status) { |
upb_descreader *r = closure; |
upb_msgdef *m = upb_descreader_top(r); |
UPB_UNUSED(hd); |
@@ -7034,11 +6330,12 @@ static bool msg_end(void *closure, const void *hd, upb_status *status) { |
upb_status_seterrmsg(status, "Encountered message with no name."); |
return false; |
} |
- return upb_descreader_endcontainer(r); |
+ upb_descreader_endcontainer(r); |
+ return true; |
} |
-static size_t msg_name(void *closure, const void *hd, const char *buf, |
- size_t n, const upb_bufhandle *handle) { |
+static size_t msg_onname(void *closure, const void *hd, const char *buf, |
+ size_t n, const upb_bufhandle *handle) { |
upb_descreader *r = closure; |
upb_msgdef *m = upb_descreader_top(r); |
/* XXX: see comment at the top of the file. */ |
@@ -7051,158 +6348,91 @@ static size_t msg_name(void *closure, const void *hd, const char *buf, |
return n; |
} |
-static void *msg_startmsg(void *closure, const void *hd) { |
- upb_descreader *r = closure; |
- upb_msgdef *m = upb_msgdef_new(&m); |
- bool ok = upb_filedef_addmsg(r->file, m, &m, NULL); |
- UPB_UNUSED(hd); |
- UPB_ASSERT(ok); |
- return r; |
-} |
- |
-static void *msg_startext(void *closure, const void *hd) { |
- upb_descreader *r = closure; |
- upb_fielddef *f = upb_fielddef_new(&f); |
- bool ok = upb_filedef_addext(r->file, f, &f, NULL); |
- UPB_UNUSED(hd); |
- UPB_ASSERT(ok); |
- return r; |
-} |
- |
-static void *msg_startfield(void *closure, const void *hd) { |
- upb_descreader *r = closure; |
- r->f = upb_fielddef_new(&r->f); |
- /* We can't add the new field to the message until its name/number are |
- * filled in. */ |
- UPB_UNUSED(hd); |
- return r; |
-} |
- |
-static bool msg_endfield(void *closure, const void *hd) { |
+static bool msg_onendfield(void *closure, const void *hd) { |
upb_descreader *r = closure; |
upb_msgdef *m = upb_descreader_top(r); |
- bool ok; |
UPB_UNUSED(hd); |
- /* Oneof fields are added to the msgdef through their oneof, so don't need to |
- * be added here. */ |
- if (upb_fielddef_containingoneof(r->f) == NULL) { |
- ok = upb_msgdef_addfield(m, r->f, &r->f, NULL); |
- UPB_ASSERT(ok); |
- } |
+ upb_msgdef_addfield(m, r->f, &r->defs, NULL); |
r->f = NULL; |
return true; |
} |
-static bool msg_onmapentry(void *closure, const void *hd, bool mapentry) { |
+static bool pushextension(void *closure, const void *hd) { |
upb_descreader *r = closure; |
- upb_msgdef *m = upb_descreader_top(r); |
UPB_UNUSED(hd); |
- upb_msgdef_setmapentry(m, mapentry); |
+ assert(upb_fielddef_containingtypename(r->f)); |
+ upb_fielddef_setisextension(r->f, true); |
+ upb_deflist_push(&r->defs, upb_fielddef_upcast_mutable(r->f)); |
r->f = NULL; |
return true; |
} |
- |
- |
-/** Code to register handlers *************************************************/ |
- |
-#define F(msg, field) upbdefs_google_protobuf_ ## msg ## _f_ ## field(m) |
+#define D(name) upbdefs_google_protobuf_ ## name(s) |
static void reghandlers(const void *closure, upb_handlers *h) { |
+ const upb_symtab *s = closure; |
const upb_msgdef *m = upb_handlers_msgdef(h); |
- UPB_UNUSED(closure); |
- if (upbdefs_google_protobuf_FileDescriptorSet_is(m)) { |
- upb_handlers_setstartsubmsg(h, F(FileDescriptorSet, file), |
- &fileset_startfile, NULL); |
- } else if (upbdefs_google_protobuf_DescriptorProto_is(m)) { |
- upb_handlers_setstartmsg(h, &msg_start, NULL); |
- upb_handlers_setendmsg(h, &msg_end, NULL); |
- upb_handlers_setstring(h, F(DescriptorProto, name), &msg_name, NULL); |
- upb_handlers_setstartsubmsg(h, F(DescriptorProto, extension), &msg_startext, |
- NULL); |
- upb_handlers_setstartsubmsg(h, F(DescriptorProto, nested_type), |
- &msg_startmsg, NULL); |
- upb_handlers_setstartsubmsg(h, F(DescriptorProto, field), |
- &msg_startfield, NULL); |
- upb_handlers_setendsubmsg(h, F(DescriptorProto, field), |
- &msg_endfield, NULL); |
- upb_handlers_setstartsubmsg(h, F(DescriptorProto, enum_type), |
- &file_startenum, NULL); |
- } else if (upbdefs_google_protobuf_FileDescriptorProto_is(m)) { |
- upb_handlers_setstartmsg(h, &file_start, NULL); |
- upb_handlers_setendmsg(h, &file_end, NULL); |
- upb_handlers_setstring(h, F(FileDescriptorProto, name), &file_onname, |
- NULL); |
- upb_handlers_setstring(h, F(FileDescriptorProto, package), &file_onpackage, |
+ if (m == D(DescriptorProto)) { |
+ upb_handlers_setstartmsg(h, &msg_startmsg, NULL); |
+ upb_handlers_setendmsg(h, &msg_endmsg, NULL); |
+ upb_handlers_setstring(h, D(DescriptorProto_name), &msg_onname, NULL); |
+ upb_handlers_setendsubmsg(h, D(DescriptorProto_field), &msg_onendfield, |
+ NULL); |
+ upb_handlers_setendsubmsg(h, D(DescriptorProto_extension), &pushextension, |
+ NULL); |
+ } else if (m == D(FileDescriptorProto)) { |
+ upb_handlers_setstartmsg(h, &file_startmsg, NULL); |
+ upb_handlers_setendmsg(h, &file_endmsg, NULL); |
+ upb_handlers_setstring(h, D(FileDescriptorProto_package), &file_onpackage, |
NULL); |
- upb_handlers_setstring(h, F(FileDescriptorProto, syntax), &file_onsyntax, |
- NULL); |
- upb_handlers_setstartsubmsg(h, F(FileDescriptorProto, message_type), |
- &file_startmsg, NULL); |
- upb_handlers_setstartsubmsg(h, F(FileDescriptorProto, enum_type), |
- &file_startenum, NULL); |
- upb_handlers_setstartsubmsg(h, F(FileDescriptorProto, extension), |
- &file_startext, NULL); |
- } else if (upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)) { |
+ upb_handlers_setendsubmsg(h, D(FileDescriptorProto_extension), &pushextension, |
+ NULL); |
+ } else if (m == D(EnumValueDescriptorProto)) { |
upb_handlers_setstartmsg(h, &enumval_startmsg, NULL); |
upb_handlers_setendmsg(h, &enumval_endmsg, NULL); |
- upb_handlers_setstring(h, F(EnumValueDescriptorProto, name), &enumval_onname, NULL); |
- upb_handlers_setint32(h, F(EnumValueDescriptorProto, number), &enumval_onnumber, |
+ upb_handlers_setstring(h, D(EnumValueDescriptorProto_name), &enumval_onname, NULL); |
+ upb_handlers_setint32(h, D(EnumValueDescriptorProto_number), &enumval_onnumber, |
NULL); |
- } else if (upbdefs_google_protobuf_EnumDescriptorProto_is(m)) { |
+ } else if (m == D(EnumDescriptorProto)) { |
+ upb_handlers_setstartmsg(h, &enum_startmsg, NULL); |
upb_handlers_setendmsg(h, &enum_endmsg, NULL); |
- upb_handlers_setstring(h, F(EnumDescriptorProto, name), &enum_onname, NULL); |
- } else if (upbdefs_google_protobuf_FieldDescriptorProto_is(m)) { |
+ upb_handlers_setstring(h, D(EnumDescriptorProto_name), &enum_onname, NULL); |
+ } else if (m == D(FieldDescriptorProto)) { |
upb_handlers_setstartmsg(h, &field_startmsg, NULL); |
upb_handlers_setendmsg(h, &field_endmsg, NULL); |
- upb_handlers_setint32(h, F(FieldDescriptorProto, type), &field_ontype, |
+ upb_handlers_setint32(h, D(FieldDescriptorProto_type), &field_ontype, |
NULL); |
- upb_handlers_setint32(h, F(FieldDescriptorProto, label), &field_onlabel, |
+ upb_handlers_setint32(h, D(FieldDescriptorProto_label), &field_onlabel, |
NULL); |
- upb_handlers_setint32(h, F(FieldDescriptorProto, number), &field_onnumber, |
+ upb_handlers_setint32(h, D(FieldDescriptorProto_number), &field_onnumber, |
NULL); |
- upb_handlers_setstring(h, F(FieldDescriptorProto, name), &field_onname, |
+ upb_handlers_setstring(h, D(FieldDescriptorProto_name), &field_onname, |
NULL); |
- upb_handlers_setstring(h, F(FieldDescriptorProto, type_name), |
+ upb_handlers_setstring(h, D(FieldDescriptorProto_type_name), |
&field_ontypename, NULL); |
- upb_handlers_setstring(h, F(FieldDescriptorProto, extendee), |
+ upb_handlers_setstring(h, D(FieldDescriptorProto_extendee), |
&field_onextendee, NULL); |
- upb_handlers_setstring(h, F(FieldDescriptorProto, default_value), |
+ upb_handlers_setstring(h, D(FieldDescriptorProto_default_value), |
&field_ondefaultval, NULL); |
- upb_handlers_setint32(h, F(FieldDescriptorProto, oneof_index), |
- &field_ononeofindex, NULL); |
- } else if (upbdefs_google_protobuf_OneofDescriptorProto_is(m)) { |
- upb_handlers_setstring(h, F(OneofDescriptorProto, name), &oneof_name, NULL); |
- } else if (upbdefs_google_protobuf_FieldOptions_is(m)) { |
- upb_handlers_setbool(h, F(FieldOptions, lazy), &field_onlazy, NULL); |
- upb_handlers_setbool(h, F(FieldOptions, packed), &field_onpacked, NULL); |
- } else if (upbdefs_google_protobuf_MessageOptions_is(m)) { |
- upb_handlers_setbool(h, F(MessageOptions, map_entry), &msg_onmapentry, NULL); |
+ } else if (m == D(FieldOptions)) { |
+ upb_handlers_setbool(h, D(FieldOptions_lazy), &field_onlazy, NULL); |
+ upb_handlers_setbool(h, D(FieldOptions_packed), &field_onpacked, NULL); |
} |
- |
- UPB_ASSERT(upb_ok(upb_handlers_status(h))); |
} |
-#undef F |
+#undef D |
void descreader_cleanup(void *_r) { |
upb_descreader *r = _r; |
- size_t i; |
- |
- for (i = 0; i < upb_descreader_filecount(r); i++) { |
- upb_filedef_unref(upb_descreader_file(r, i), &r->files); |
- } |
- |
- upb_gfree(r->name); |
- upb_inttable_uninit(&r->files); |
- upb_inttable_uninit(&r->oneofs); |
- upb_gfree(r->default_string); |
+ free(r->name); |
+ upb_deflist_uninit(&r->defs); |
+ free(r->default_string); |
while (r->stack_len > 0) { |
upb_descreader_frame *f = &r->stack[--r->stack_len]; |
- upb_gfree(f->name); |
+ free(f->name); |
} |
} |
@@ -7215,8 +6445,7 @@ upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h) { |
return NULL; |
} |
- upb_inttable_init(&r->files, UPB_CTYPE_PTR); |
- upb_inttable_init(&r->oneofs, UPB_CTYPE_PTR); |
+ upb_deflist_init(&r->defs); |
upb_sink_reset(upb_descreader_input(r), h, r); |
r->stack_len = 0; |
r->name = NULL; |
@@ -7225,17 +6454,10 @@ upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h) { |
return r; |
} |
-size_t upb_descreader_filecount(const upb_descreader *r) { |
- return upb_inttable_count(&r->files); |
-} |
- |
-upb_filedef *upb_descreader_file(const upb_descreader *r, size_t i) { |
- upb_value v; |
- if (upb_inttable_lookup(&r->files, i, &v)) { |
- return upb_value_getptr(v); |
- } else { |
- return NULL; |
- } |
+upb_def **upb_descreader_getdefs(upb_descreader *r, void *owner, int *n) { |
+ *n = r->defs.len; |
+ upb_deflist_donaterefs(&r->defs, owner); |
+ return r->defs.defs; |
} |
upb_sink *upb_descreader_input(upb_descreader *r) { |
@@ -7243,9 +6465,10 @@ upb_sink *upb_descreader_input(upb_descreader *r) { |
} |
const upb_handlers *upb_descreader_newhandlers(const void *owner) { |
- const upb_msgdef *m = upbdefs_google_protobuf_FileDescriptorSet_get(&m); |
- const upb_handlers *h = upb_handlers_newfrozen(m, owner, reghandlers, NULL); |
- upb_msgdef_unref(m, &m); |
+ const upb_symtab *s = upbdefs_google_protobuf_descriptor(&s); |
+ const upb_handlers *h = upb_handlers_newfrozen( |
+ upbdefs_google_protobuf_FileDescriptorSet(s), owner, reghandlers, s); |
+ upb_symtab_unref(s, &s); |
return h; |
} |
/* |
@@ -7279,8 +6502,8 @@ static void freegroup(upb_refcounted *r) { |
#ifdef UPB_USE_JIT_X64 |
upb_pbdecoder_freejit(g); |
#endif |
- upb_gfree(g->bytecode); |
- upb_gfree(g); |
+ free(g->bytecode); |
+ free(g); |
} |
static void visitgroup(const upb_refcounted *r, upb_refcounted_visit *visit, |
@@ -7295,7 +6518,7 @@ static void visitgroup(const upb_refcounted *r, upb_refcounted_visit *visit, |
} |
mgroup *newgroup(const void *owner) { |
- mgroup *g = upb_gmalloc(sizeof(*g)); |
+ mgroup *g = malloc(sizeof(*g)); |
static const struct upb_refcounted_vtbl vtbl = {visitgroup, freegroup}; |
upb_refcounted_init(mgroup_upcast_mutable(g), &vtbl, owner); |
upb_inttable_init(&g->methods, UPB_CTYPE_PTR); |
@@ -7315,7 +6538,7 @@ static void freemethod(upb_refcounted *r) { |
} |
upb_inttable_uninit(&method->dispatch); |
- upb_gfree(method); |
+ free(method); |
} |
static void visitmethod(const upb_refcounted *r, upb_refcounted_visit *visit, |
@@ -7327,7 +6550,7 @@ static void visitmethod(const upb_refcounted *r, upb_refcounted_visit *visit, |
static upb_pbdecodermethod *newmethod(const upb_handlers *dest_handlers, |
mgroup *group) { |
static const struct upb_refcounted_vtbl vtbl = {visitmethod, freemethod}; |
- upb_pbdecodermethod *ret = upb_gmalloc(sizeof(*ret)); |
+ upb_pbdecodermethod *ret = malloc(sizeof(*ret)); |
upb_refcounted_init(upb_pbdecodermethod_upcast_mutable(ret), &vtbl, &ret); |
upb_byteshandler_init(&ret->input_handler_); |
@@ -7390,7 +6613,7 @@ typedef struct { |
} compiler; |
static compiler *newcompiler(mgroup *group, bool lazy) { |
- compiler *ret = upb_gmalloc(sizeof(*ret)); |
+ compiler *ret = malloc(sizeof(*ret)); |
int i; |
ret->group = group; |
@@ -7403,7 +6626,7 @@ static compiler *newcompiler(mgroup *group, bool lazy) { |
} |
static void freecompiler(compiler *c) { |
- upb_gfree(c); |
+ free(c); |
} |
const size_t ptr_words = sizeof(void*) / sizeof(uint32_t); |
@@ -7431,7 +6654,7 @@ bool op_has_longofs(int32_t instruction) { |
case OP_TAGN: |
return false; |
default: |
- UPB_ASSERT(false); |
+ assert(false); |
return false; |
} |
} |
@@ -7450,7 +6673,7 @@ static void setofs(uint32_t *instruction, int32_t ofs) { |
} else { |
*instruction = (*instruction & ~0xff00) | ((ofs & 0xff) << 8); |
} |
- UPB_ASSERT(getofs(*instruction) == ofs); /* Would fail in cases of overflow. */ |
+ assert(getofs(*instruction) == ofs); /* Would fail in cases of overflow. */ |
} |
static uint32_t pcofs(compiler *c) { return c->pc - c->group->bytecode; } |
@@ -7462,7 +6685,7 @@ static void label(compiler *c, unsigned int label) { |
int val; |
uint32_t *codep; |
- UPB_ASSERT(label < MAXLABEL); |
+ assert(label < MAXLABEL); |
val = c->fwd_labels[label]; |
codep = (val == EMPTYLABEL) ? NULL : c->group->bytecode + val; |
while (codep) { |
@@ -7483,7 +6706,7 @@ static void label(compiler *c, unsigned int label) { |
* The returned value is the offset that should be written into the instruction. |
*/ |
static int32_t labelref(compiler *c, int label) { |
- UPB_ASSERT(label < MAXLABEL); |
+ assert(label < MAXLABEL); |
if (label == LABEL_DISPATCH) { |
/* No resolving required. */ |
return 0; |
@@ -7507,8 +6730,7 @@ static void put32(compiler *c, uint32_t v) { |
size_t oldsize = g->bytecode_end - g->bytecode; |
size_t newsize = UPB_MAX(oldsize * 2, 64); |
/* TODO(haberman): handle OOM. */ |
- g->bytecode = upb_grealloc(g->bytecode, oldsize * sizeof(uint32_t), |
- newsize * sizeof(uint32_t)); |
+ g->bytecode = realloc(g->bytecode, newsize * sizeof(uint32_t)); |
g->bytecode_end = g->bytecode + newsize; |
c->pc = g->bytecode + ofs; |
} |
@@ -7583,7 +6805,7 @@ static void putop(compiler *c, opcode op, ...) { |
int label = va_arg(ap, int); |
uint64_t tag = va_arg(ap, uint64_t); |
uint32_t instruction = op | (tag << 16); |
- UPB_ASSERT(tag <= 0xffff); |
+ assert(tag <= 0xffff); |
setofs(&instruction, labelref(c, label)); |
put32(c, instruction); |
break; |
@@ -7720,7 +6942,7 @@ static uint64_t get_encoded_tag(const upb_fielddef *f, int wire_type) { |
uint32_t tag = (upb_fielddef_number(f) << 3) | wire_type; |
uint64_t encoded_tag = upb_vencode32(tag); |
/* No tag should be greater than 5 bytes. */ |
- UPB_ASSERT(encoded_tag <= 0xffffffffff); |
+ assert(encoded_tag <= 0xffffffffff); |
return encoded_tag; |
} |
@@ -7743,7 +6965,7 @@ static void putchecktag(compiler *c, const upb_fielddef *f, |
static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) { |
upb_selector_t selector; |
bool ok = upb_handlers_getselector(f, type, &selector); |
- UPB_ASSERT(ok); |
+ UPB_ASSERT_VAR(ok, ok); |
return selector; |
} |
@@ -7755,7 +6977,7 @@ static uint64_t repack(uint64_t dispatch, int new_wt2) { |
uint8_t wt1; |
uint8_t old_wt2; |
upb_pbdecoder_unpackdispatch(dispatch, &ofs, &wt1, &old_wt2); |
- UPB_ASSERT(old_wt2 == NO_WIRE_TYPE); /* wt2 should not be set yet. */ |
+ assert(old_wt2 == NO_WIRE_TYPE); /* wt2 should not be set yet. */ |
return upb_pbdecoder_packdispatch(ofs, wt1, new_wt2); |
} |
@@ -7845,12 +7067,7 @@ static void generate_msgfield(compiler *c, const upb_fielddef *f, |
if (!sub_m) { |
/* Don't emit any code for this field at all; it will be parsed as an |
- * unknown field. |
- * |
- * TODO(haberman): we should change this to parse it as a string field |
- * instead. It will probably be faster, but more importantly, once we |
- * start vending unknown fields, a field shouldn't be treated as unknown |
- * just because it doesn't have subhandlers registered. */ |
+ * unknown field. */ |
return; |
} |
@@ -7957,7 +7174,7 @@ static void generate_primitivefield(compiler *c, const upb_fielddef *f, |
* setting in the fielddef. This will favor (in speed) whichever was |
* specified. */ |
- UPB_ASSERT((int)parse_type >= 0 && parse_type <= OP_MAX); |
+ assert((int)parse_type >= 0 && parse_type <= OP_MAX); |
sel = getsel(f, upb_handlers_getprimitivehandlertype(f)); |
wire_type = upb_pb_native_wire_types[upb_fielddef_descriptortype(f)]; |
if (upb_fielddef_isseq(f)) { |
@@ -7999,7 +7216,7 @@ static void compile_method(compiler *c, upb_pbdecodermethod *method) { |
upb_msg_field_iter i; |
upb_value val; |
- UPB_ASSERT(method); |
+ assert(method); |
/* Clear all entries in the dispatch table. */ |
upb_inttable_uninit(&method->dispatch); |
@@ -8147,7 +7364,7 @@ const mgroup *mgroup_new(const upb_handlers *dest, bool allowjit, bool lazy, |
compiler *c; |
UPB_UNUSED(allowjit); |
- UPB_ASSERT(upb_handlers_isfrozen(dest)); |
+ assert(upb_handlers_isfrozen(dest)); |
g = newgroup(owner); |
c = newcompiler(g, lazy); |
@@ -8167,16 +7384,11 @@ const mgroup *mgroup_new(const upb_handlers *dest, bool allowjit, bool lazy, |
#ifdef UPB_DUMP_BYTECODE |
{ |
- FILE *f = fopen("/tmp/upb-bytecode", "w"); |
- UPB_ASSERT(f); |
+ FILE *f = fopen("/tmp/upb-bytecode", "wb"); |
+ assert(f); |
dumpbc(g->bytecode, g->bytecode_end, stderr); |
dumpbc(g->bytecode, g->bytecode_end, f); |
fclose(f); |
- |
- f = fopen("/tmp/upb-bytecode.bin", "wb"); |
- UPB_ASSERT(f); |
- fwrite(g->bytecode, 1, g->bytecode_end - g->bytecode, f); |
- fclose(f); |
} |
#endif |
@@ -8224,7 +7436,7 @@ const upb_pbdecodermethod *upb_pbcodecache_getdecodermethod( |
upb_inttable_push(&c->groups, upb_value_constptr(g)); |
ok = upb_inttable_lookupptr(&g->methods, opts->handlers, &v); |
- UPB_ASSERT(ok); |
+ UPB_ASSERT_VAR(ok, ok); |
return upb_value_getptr(v); |
} |
@@ -8276,11 +7488,6 @@ static const char *kUnterminatedVarint = "Unterminated varint."; |
static opcode halt = OP_HALT; |
-/* A dummy character we can point to when the user passes us a NULL buffer. |
- * We need this because in C (NULL + 0) and (NULL - NULL) are undefined |
- * behavior, which would invalidate functions like curbufleft(). */ |
-static const char dummy_char; |
- |
/* Whether an op consumes any of the input buffer. */ |
static bool consumes_input(opcode op) { |
switch (op) { |
@@ -8357,7 +7564,7 @@ void upb_pbdecoder_seterr(upb_pbdecoder *d, const char *msg) { |
/* How many bytes can be safely read from d->ptr without reading past end-of-buf |
* or past the current delimited end. */ |
static size_t curbufleft(const upb_pbdecoder *d) { |
- UPB_ASSERT(d->data_end >= d->ptr); |
+ assert(d->data_end >= d->ptr); |
return d->data_end - d->ptr; |
} |
@@ -8378,7 +7585,7 @@ size_t delim_remaining(const upb_pbdecoder *d) { |
/* Advances d->ptr. */ |
static void advance(upb_pbdecoder *d, size_t len) { |
- UPB_ASSERT(curbufleft(d) >= len); |
+ assert(curbufleft(d) >= len); |
d->ptr += len; |
} |
@@ -8411,7 +7618,7 @@ static void switchtobuf(upb_pbdecoder *d, const char *buf, const char *end) { |
} |
static void advancetobuf(upb_pbdecoder *d, const char *buf, size_t len) { |
- UPB_ASSERT(curbufleft(d) == 0); |
+ assert(curbufleft(d) == 0); |
d->bufstart_ofs += (d->end - d->buf); |
switchtobuf(d, buf, buf + len); |
} |
@@ -8420,7 +7627,7 @@ static void checkpoint(upb_pbdecoder *d) { |
/* The assertion here is in the interests of efficiency, not correctness. |
* We are trying to ensure that we don't checkpoint() more often than |
* necessary. */ |
- UPB_ASSERT(d->checkpoint != d->ptr); |
+ assert(d->checkpoint != d->ptr); |
d->checkpoint = d->ptr; |
} |
@@ -8431,12 +7638,12 @@ static void checkpoint(upb_pbdecoder *d) { |
* won't actually be read. |
*/ |
static int32_t skip(upb_pbdecoder *d, size_t bytes) { |
- UPB_ASSERT(!in_residual_buf(d, d->ptr) || d->size_param == 0); |
- UPB_ASSERT(d->skip == 0); |
+ assert(!in_residual_buf(d, d->ptr) || d->size_param == 0); |
+ assert(d->skip == 0); |
if (bytes > delim_remaining(d)) { |
seterr(d, "Skipped value extended beyond enclosing submessage."); |
return upb_pbdecoder_suspend(d); |
- } else if (bufleft(d) >= bytes) { |
+ } else if (bufleft(d) > bytes) { |
/* Skipped data is all in current buffer, and more is still available. */ |
advance(d, bytes); |
d->skip = 0; |
@@ -8458,60 +7665,36 @@ int32_t upb_pbdecoder_resume(upb_pbdecoder *d, void *p, const char *buf, |
size_t size, const upb_bufhandle *handle) { |
UPB_UNUSED(p); /* Useless; just for the benefit of the JIT. */ |
- /* d->skip and d->residual_end could probably elegantly be represented |
- * as a single variable, to more easily represent this invariant. */ |
- UPB_ASSERT(!(d->skip && d->residual_end > d->residual)); |
- |
- /* We need to remember the original size_param, so that the value we return |
- * is relative to it, even if we do some skipping first. */ |
+ d->buf_param = buf; |
d->size_param = size; |
d->handle = handle; |
- /* Have to handle this case specially (ie. not with skip()) because the user |
- * is allowed to pass a NULL buffer here, which won't allow us to safely |
- * calculate a d->end or use our normal functions like curbufleft(). */ |
- if (d->skip && d->skip >= size) { |
- d->skip -= size; |
- d->bufstart_ofs += size; |
- buf = &dummy_char; |
- size = 0; |
- |
- /* We can't just return now, because we might need to execute some ops |
- * like CHECKDELIM, which could call some callbacks and pop the stack. */ |
- } |
- |
- /* We need to pretend that this was the actual buffer param, since some of the |
- * calculations assume that d->ptr/d->buf is relative to this. */ |
- d->buf_param = buf; |
- |
- if (!buf) { |
- /* NULL buf is ok if its entire span is covered by the "skip" above, but |
- * by this point we know that "skip" doesn't cover the buffer. */ |
- seterr(d, "Passed NULL buffer over non-skippable region."); |
- return upb_pbdecoder_suspend(d); |
- } |
- |
if (d->residual_end > d->residual) { |
/* We have residual bytes from the last buffer. */ |
- UPB_ASSERT(d->ptr == d->residual); |
+ assert(d->ptr == d->residual); |
} else { |
switchtobuf(d, buf, buf + size); |
} |
d->checkpoint = d->ptr; |
- /* Handle skips that don't cover the whole buffer (as above). */ |
if (d->skip) { |
size_t skip_bytes = d->skip; |
d->skip = 0; |
CHECK_RETURN(skip(d, skip_bytes)); |
- checkpoint(d); |
+ d->checkpoint = d->ptr; |
+ } |
+ |
+ if (!buf) { |
+ /* NULL buf is ok if its entire span is covered by the "skip" above, but |
+ * by this point we know that "skip" doesn't cover the buffer. */ |
+ seterr(d, "Passed NULL buffer over non-skippable region."); |
+ return upb_pbdecoder_suspend(d); |
} |
- /* If we're inside an unknown group, continue to parse unknown values. */ |
if (d->top->groupnum < 0) { |
CHECK_RETURN(upb_pbdecoder_skipunknown(d, -1, 0)); |
- checkpoint(d); |
+ d->checkpoint = d->ptr; |
} |
return DECODE_OK; |
@@ -8526,14 +7709,15 @@ size_t upb_pbdecoder_suspend(upb_pbdecoder *d) { |
d->ptr = d->residual; |
return 0; |
} else { |
- size_t ret = d->size_param - (d->end - d->checkpoint); |
- UPB_ASSERT(!in_residual_buf(d, d->checkpoint)); |
- UPB_ASSERT(d->buf == d->buf_param || d->buf == &dummy_char); |
+ size_t consumed; |
+ assert(!in_residual_buf(d, d->checkpoint)); |
+ assert(d->buf == d->buf_param); |
- d->bufstart_ofs += (d->checkpoint - d->buf); |
+ consumed = d->checkpoint - d->buf; |
+ d->bufstart_ofs += consumed; |
d->residual_end = d->residual; |
switchtobuf(d, d->residual, d->residual_end); |
- return ret; |
+ return consumed; |
} |
} |
@@ -8548,7 +7732,7 @@ static size_t suspend_save(upb_pbdecoder *d) { |
if (d->checkpoint == d->residual) { |
/* Checkpoint was in residual buf; append user byte(s) to residual buf. */ |
- UPB_ASSERT((d->residual_end - d->residual) + d->size_param <= |
+ assert((d->residual_end - d->residual) + d->size_param <= |
sizeof(d->residual)); |
if (!in_residual_buf(d, d->ptr)) { |
d->bufstart_ofs -= (d->residual_end - d->residual); |
@@ -8558,11 +7742,11 @@ static size_t suspend_save(upb_pbdecoder *d) { |
} else { |
/* Checkpoint was in user buf; old residual bytes not needed. */ |
size_t save; |
- UPB_ASSERT(!in_residual_buf(d, d->checkpoint)); |
+ assert(!in_residual_buf(d, d->checkpoint)); |
d->ptr = d->checkpoint; |
save = curbufleft(d); |
- UPB_ASSERT(save <= sizeof(d->residual)); |
+ assert(save <= sizeof(d->residual)); |
memcpy(d->residual, d->ptr, save); |
d->residual_end = d->residual + save; |
d->bufstart_ofs = offset(d); |
@@ -8576,7 +7760,7 @@ static size_t suspend_save(upb_pbdecoder *d) { |
* Requires that this many bytes are available in the current buffer. */ |
UPB_FORCEINLINE static void consumebytes(upb_pbdecoder *d, void *buf, |
size_t bytes) { |
- UPB_ASSERT(bytes <= curbufleft(d)); |
+ assert(bytes <= curbufleft(d)); |
memcpy(buf, d->ptr, bytes); |
advance(d, bytes); |
} |
@@ -8589,7 +7773,7 @@ UPB_NOINLINE static int32_t getbytes_slow(upb_pbdecoder *d, void *buf, |
const size_t avail = curbufleft(d); |
consumebytes(d, buf, avail); |
bytes -= avail; |
- UPB_ASSERT(bytes > 0); |
+ assert(bytes > 0); |
if (in_residual_buf(d, d->ptr)) { |
advancetobuf(d, d->buf_param, d->size_param); |
} |
@@ -8651,7 +7835,8 @@ UPB_NOINLINE int32_t upb_pbdecoder_decode_varint_slow(upb_pbdecoder *d, |
int bitpos; |
*u64 = 0; |
for(bitpos = 0; bitpos < 70 && (byte & 0x80); bitpos += 7) { |
- CHECK_RETURN(getbytes(d, &byte, 1)); |
+ int32_t ret = getbytes(d, &byte, 1); |
+ if (ret >= 0) return ret; |
*u64 |= (uint64_t)(byte & 0x7F) << bitpos; |
} |
if(bitpos == 70 && (byte & 0x80)) { |
@@ -8772,7 +7957,7 @@ UPB_NOINLINE int32_t upb_pbdecoder_checktag_slow(upb_pbdecoder *d, |
if (read == bytes && data == expected) { |
/* Advance past matched bytes. */ |
int32_t ok = getbytes(d, &data, read); |
- UPB_ASSERT(ok < 0); |
+ UPB_ASSERT_VAR(ok, ok < 0); |
return DECODE_OK; |
} else if (read < bytes && memcmp(&data, &expected, read) == 0) { |
return suspend_save(d); |
@@ -8847,7 +8032,7 @@ have_tag: |
static void goto_endmsg(upb_pbdecoder *d) { |
upb_value v; |
bool found = upb_inttable_lookup32(d->top->dispatch, DISPATCH_ENDMSG, &v); |
- UPB_ASSERT(found); |
+ UPB_ASSERT_VAR(found, found); |
d->pc = d->top->base + upb_value_getuint64(v); |
} |
@@ -8881,7 +8066,7 @@ static int32_t dispatch(upb_pbdecoder *d) { |
} else if (wire_type == ((v >> 8) & 0xff)) { |
bool found = |
upb_inttable_lookup(dispatch, fieldnum + UPB_MAX_FIELDNUMBER, &val); |
- UPB_ASSERT(found); |
+ UPB_ASSERT_VAR(found, found); |
d->pc = d->top->base + upb_value_getuint64(val); |
return DECODE_OK; |
} |
@@ -8893,7 +8078,7 @@ static int32_t dispatch(upb_pbdecoder *d) { |
* can re-check the delimited end. */ |
d->last--; /* Necessary if we get suspended */ |
d->pc = d->last; |
- UPB_ASSERT(getop(*d->last) == OP_CHECKDELIM); |
+ assert(getop(*d->last) == OP_CHECKDELIM); |
/* Unknown field or ENDGROUP. */ |
retval = upb_pbdecoder_skipunknown(d, fieldnum, wire_type); |
@@ -8911,7 +8096,7 @@ static int32_t dispatch(upb_pbdecoder *d) { |
/* Callers know that the stack is more than one deep because the opcodes that |
* call this only occur after PUSH operations. */ |
upb_pbdecoder_frame *outer_frame(upb_pbdecoder *d) { |
- UPB_ASSERT(d->top != d->stack); |
+ assert(d->top != d->stack); |
return d->top - 1; |
} |
@@ -8943,7 +8128,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group, |
op = getop(instruction); |
arg = instruction >> 8; |
longofs = arg; |
- UPB_ASSERT(d->ptr != d->residual_end); |
+ assert(d->ptr != d->residual_end); |
UPB_UNUSED(group); |
#ifdef UPB_DUMP_BYTECODE |
fprintf(stderr, "s_ofs=%d buf_ofs=%d data_rem=%d buf_rem=%d delim_rem=%d " |
@@ -9018,7 +8203,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group, |
} else { |
int32_t ret = skip(d, n); |
/* This shouldn't return DECODE_OK, because n > len. */ |
- UPB_ASSERT(ret >= 0); |
+ assert(ret >= 0); |
return ret; |
} |
} |
@@ -9040,7 +8225,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group, |
d->top->groupnum = *d->pc++; |
) |
VMCASE(OP_POP, |
- UPB_ASSERT(d->top > d->stack); |
+ assert(d->top > d->stack); |
decoder_pop(d); |
) |
VMCASE(OP_PUSHLENDELIM, |
@@ -9056,7 +8241,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group, |
/* We are guaranteed of this assert because we never allow ourselves to |
* consume bytes beyond data_end, which covers delim_end when non-NULL. |
*/ |
- UPB_ASSERT(!(d->delim_end && d->ptr > d->delim_end)); |
+ assert(!(d->delim_end && d->ptr > d->delim_end)); |
if (d->ptr == d->delim_end) |
d->pc += longofs; |
) |
@@ -9065,7 +8250,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group, |
d->pc += longofs; |
) |
VMCASE(OP_RET, |
- UPB_ASSERT(d->call_len > 0); |
+ assert(d->call_len > 0); |
d->pc = d->callstack[--d->call_len]; |
) |
VMCASE(OP_BRANCH, |
@@ -9192,7 +8377,7 @@ bool upb_pbdecoder_end(void *closure, const void *handler_data) { |
if (p != method->code_base.ptr) p--; |
if (getop(*p) == OP_CHECKDELIM) { |
/* Rewind from OP_TAG* to OP_CHECKDELIM. */ |
- UPB_ASSERT(getop(*d->pc) == OP_TAG1 || |
+ assert(getop(*d->pc) == OP_TAG1 || |
getop(*d->pc) == OP_TAG2 || |
getop(*d->pc) == OP_TAGN || |
getop(*d->pc) == OP_DISPATCH); |
@@ -9251,12 +8436,11 @@ upb_pbdecoder *upb_pbdecoder_create(upb_env *e, const upb_pbdecodermethod *m, |
d->env = e; |
d->limit = d->stack + default_max_nesting - 1; |
d->stack_size = default_max_nesting; |
- d->status = NULL; |
upb_pbdecoder_reset(d); |
upb_bytessink_reset(&d->input_, &m->input_handler_, d); |
- UPB_ASSERT(sink); |
+ assert(sink); |
if (d->method_->dest_handlers_) { |
if (sink->handlers != d->method_->dest_handlers_) |
return NULL; |
@@ -9264,8 +8448,7 @@ upb_pbdecoder *upb_pbdecoder_create(upb_env *e, const upb_pbdecodermethod *m, |
upb_sink_reset(&d->top->sink, sink->handlers, sink->closure); |
/* If this fails, increase the value in decoder.h. */ |
- UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(e) - size_before <= |
- UPB_PB_DECODER_SIZE); |
+ assert(upb_env_bytesallocated(e) - size_before <= UPB_PB_DECODER_SIZE); |
return d; |
} |
@@ -9286,7 +8469,7 @@ size_t upb_pbdecoder_maxnesting(const upb_pbdecoder *d) { |
} |
bool upb_pbdecoder_setmaxnesting(upb_pbdecoder *d, size_t max) { |
- UPB_ASSERT(d->top >= d->stack); |
+ assert(d->top >= d->stack); |
if (max < (size_t)(d->top - d->stack)) { |
/* Can't set a limit smaller than what we are currently at. */ |
@@ -9374,6 +8557,7 @@ bool upb_pbdecoder_setmaxnesting(upb_pbdecoder *d, size_t max) { |
*/ |
+#include <stdlib.h> |
/* The output buffer is divided into segments; a segment is a string of data |
* that is "ready to go" -- it does not need any varint lengths inserted into |
@@ -9445,7 +8629,7 @@ struct upb_pb_encoder { |
/* TODO(haberman): handle pushback */ |
static void putbuf(upb_pb_encoder *e, const char *buf, size_t len) { |
size_t n = upb_bytessink_putbuf(e->output_, e->subc, buf, len, NULL); |
- UPB_ASSERT(n == len); |
+ UPB_ASSERT_VAR(n, n == len); |
} |
static upb_pb_encoder_segment *top(upb_pb_encoder *e) { |
@@ -9485,7 +8669,7 @@ static bool reserve(upb_pb_encoder *e, size_t bytes) { |
/* Call when "bytes" bytes have been writte at e->ptr. The caller *must* have |
* previously called reserve() with at least this many bytes. */ |
static void encoder_advance(upb_pb_encoder *e, size_t bytes) { |
- UPB_ASSERT((size_t)(e->limit - e->ptr) >= bytes); |
+ assert((size_t)(e->limit - e->ptr) >= bytes); |
e->ptr += bytes; |
} |
@@ -9520,7 +8704,7 @@ static bool encode_bytes(upb_pb_encoder *e, const void *data, size_t len) { |
* length. */ |
static void accumulate(upb_pb_encoder *e) { |
size_t run_len; |
- UPB_ASSERT(e->ptr >= e->runbegin); |
+ assert(e->ptr >= e->runbegin); |
run_len = e->ptr - e->runbegin; |
e->segptr->seglen += run_len; |
top(e)->msglen += run_len; |
@@ -9618,12 +8802,12 @@ static void new_tag(upb_handlers *h, const upb_fielddef *f, upb_wiretype_t wt, |
upb_handlerattr *attr) { |
uint32_t n = upb_fielddef_number(f); |
- tag_t *tag = upb_gmalloc(sizeof(tag_t)); |
+ tag_t *tag = malloc(sizeof(tag_t)); |
tag->bytes = upb_vencode64((n << 3) | wt, tag->tag); |
upb_handlerattr_init(attr); |
upb_handlerattr_sethandlerdata(attr, tag); |
- upb_handlers_addcleanup(h, tag, upb_gfree); |
+ upb_handlers_addcleanup(h, tag, free); |
} |
static bool encode_tag(upb_pb_encoder *e, const tag_t *tag) { |
@@ -9875,17 +9059,19 @@ upb_pb_encoder *upb_pb_encoder_create(upb_env *env, const upb_handlers *h, |
e->ptr = e->buf; |
/* If this fails, increase the value in encoder.h. */ |
- UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(env) - size_before <= |
- UPB_PB_ENCODER_SIZE); |
+ assert(upb_env_bytesallocated(env) - size_before <= UPB_PB_ENCODER_SIZE); |
return e; |
} |
upb_sink *upb_pb_encoder_input(upb_pb_encoder *e) { return &e->input_; } |
+#include <stdio.h> |
+#include <stdlib.h> |
+#include <string.h> |
-upb_filedef **upb_loaddescriptor(const char *buf, size_t n, const void *owner, |
- upb_status *status) { |
+upb_def **upb_load_defs_from_descriptor(const char *str, size_t len, int *n, |
+ void *owner, upb_status *status) { |
/* Create handlers. */ |
const upb_pbdecodermethod *decoder_m; |
const upb_handlers *reader_h = upb_descreader_newhandlers(&reader_h); |
@@ -9894,8 +9080,8 @@ upb_filedef **upb_loaddescriptor(const char *buf, size_t n, const void *owner, |
upb_pbdecoder *decoder; |
upb_descreader *reader; |
bool ok; |
- size_t i; |
- upb_filedef **ret = NULL; |
+ upb_def **ret = NULL; |
+ upb_def **defs; |
upb_pbdecodermethodopts_init(&opts, reader_h); |
decoder_m = upb_pbdecodermethod_new(&opts, &decoder_m); |
@@ -9907,24 +9093,12 @@ upb_filedef **upb_loaddescriptor(const char *buf, size_t n, const void *owner, |
decoder = upb_pbdecoder_create(&env, decoder_m, upb_descreader_input(reader)); |
/* Push input data. */ |
- ok = upb_bufsrc_putbuf(buf, n, upb_pbdecoder_input(decoder)); |
- |
- if (!ok) { |
- goto cleanup; |
- } |
- |
- ret = upb_gmalloc(sizeof (*ret) * (upb_descreader_filecount(reader) + 1)); |
- |
- if (!ret) { |
- goto cleanup; |
- } |
- |
- for (i = 0; i < upb_descreader_filecount(reader); i++) { |
- ret[i] = upb_descreader_file(reader, i); |
- upb_filedef_ref(ret[i], owner); |
- } |
+ ok = upb_bufsrc_putbuf(str, len, upb_pbdecoder_input(decoder)); |
- ret[i] = NULL; |
+ if (!ok) goto cleanup; |
+ defs = upb_descreader_getdefs(reader, owner, n); |
+ ret = malloc(sizeof(upb_def*) * (*n)); |
+ memcpy(ret, defs, sizeof(upb_def*) * (*n)); |
cleanup: |
upb_env_uninit(&env); |
@@ -9932,6 +9106,51 @@ cleanup: |
upb_pbdecodermethod_unref(decoder_m, &decoder_m); |
return ret; |
} |
+ |
+bool upb_load_descriptor_into_symtab(upb_symtab *s, const char *str, size_t len, |
+ upb_status *status) { |
+ int n; |
+ bool success; |
+ upb_def **defs = upb_load_defs_from_descriptor(str, len, &n, &defs, status); |
+ if (!defs) return false; |
+ success = upb_symtab_add(s, defs, n, &defs, status); |
+ free(defs); |
+ return success; |
+} |
+ |
+char *upb_readfile(const char *filename, size_t *len) { |
+ long size; |
+ char *buf; |
+ FILE *f = fopen(filename, "rb"); |
+ if(!f) return NULL; |
+ if(fseek(f, 0, SEEK_END) != 0) goto error; |
+ size = ftell(f); |
+ if(size < 0) goto error; |
+ if(fseek(f, 0, SEEK_SET) != 0) goto error; |
+ buf = malloc(size + 1); |
+ if(size && fread(buf, size, 1, f) != 1) goto error; |
+ fclose(f); |
+ if (len) *len = size; |
+ return buf; |
+ |
+error: |
+ fclose(f); |
+ return NULL; |
+} |
+ |
+bool upb_load_descriptor_file_into_symtab(upb_symtab *symtab, const char *fname, |
+ upb_status *status) { |
+ size_t len; |
+ bool success; |
+ char *data = upb_readfile(fname, &len); |
+ if (!data) { |
+ if (status) upb_status_seterrf(status, "Couldn't read file: %s", fname); |
+ return false; |
+ } |
+ success = upb_load_descriptor_into_symtab(symtab, data, len, status); |
+ free(data); |
+ return success; |
+} |
/* |
* upb::pb::TextPrinter |
* |
@@ -9945,6 +9164,7 @@ cleanup: |
#include <inttypes.h> |
#include <stdarg.h> |
#include <stdio.h> |
+#include <stdlib.h> |
#include <string.h> |
@@ -10040,14 +9260,14 @@ bool putf(upb_textprinter *p, const char *fmt, ...) { |
va_end(args_copy); |
/* + 1 for NULL terminator (vsprintf() requires it even if we don't). */ |
- str = upb_gmalloc(len + 1); |
+ str = malloc(len + 1); |
if (!str) return false; |
written = vsprintf(str, fmt, args); |
va_end(args); |
- UPB_ASSERT(written == len); |
+ UPB_ASSERT_VAR(written, written == len); |
ok = upb_bytessink_putbuf(p->output_, p->subc, str, len, NULL); |
- upb_gfree(str); |
+ free(str); |
return ok; |
} |
@@ -10416,11 +9636,12 @@ upb_decoderet upb_vdecode_max8_wright(upb_decoderet r) { |
** - handling of keys/escape-sequences/etc that span input buffers. |
*/ |
-#include <assert.h> |
-#include <errno.h> |
+#include <stdio.h> |
#include <stdint.h> |
-#include <stdlib.h> |
+#include <assert.h> |
#include <string.h> |
+#include <stdlib.h> |
+#include <errno.h> |
#define UPB_JSON_MAX_DEPTH 64 |
@@ -10433,9 +9654,6 @@ typedef struct { |
const upb_msgdef *m; |
const upb_fielddef *f; |
- /* The table mapping json name to fielddef for this message. */ |
- upb_strtable *name_table; |
- |
/* We are in a repeated-field context, ready to emit mapentries as |
* submessages. This flag alters the start-of-object (open-brace) behavior to |
* begin a sequence of mapentry messages rather than a single submessage. */ |
@@ -10456,7 +9674,7 @@ typedef struct { |
struct upb_json_parser { |
upb_env *env; |
- const upb_json_parsermethod *method; |
+ upb_byteshandler input_handler_; |
upb_bytessink input_; |
/* Stack to track the JSON scopes we are in. */ |
@@ -10491,19 +9709,6 @@ struct upb_json_parser { |
uint32_t digit; |
}; |
-struct upb_json_parsermethod { |
- upb_refcounted base; |
- |
- upb_byteshandler input_handler_; |
- |
- /* Mainly for the purposes of refcounting, so all the fielddefs we point |
- * to stay alive. */ |
- const upb_msgdef *msg; |
- |
- /* Keys are upb_msgdef*, values are upb_strtable (json_name -> fielddef) */ |
- upb_inttable name_tables; |
-}; |
- |
#define PARSER_CHECK_RETURN(x) if (!(x)) return false |
/* Used to signal that a capture has been suspended. */ |
@@ -10513,7 +9718,7 @@ static upb_selector_t getsel_for_handlertype(upb_json_parser *p, |
upb_handlertype_t type) { |
upb_selector_t sel; |
bool ok = upb_handlers_getselector(p->top->f, type, &sel); |
- UPB_ASSERT(ok); |
+ UPB_ASSERT_VAR(ok, ok); |
return sel; |
} |
@@ -10532,13 +9737,6 @@ static bool check_stack(upb_json_parser *p) { |
return true; |
} |
-static void set_name_table(upb_json_parser *p, upb_jsonparser_frame *frame) { |
- upb_value v; |
- bool ok = upb_inttable_lookupptr(&p->method->name_tables, frame->m, &v); |
- UPB_ASSERT(ok); |
- frame->name_table = upb_value_getptr(v); |
-} |
- |
/* There are GCC/Clang built-ins for overflow checking which we could start |
* using if there was any performance benefit to it. */ |
@@ -10658,7 +9856,7 @@ otherchar: |
val = b64lookup(ptr[0]) << 18 | |
b64lookup(ptr[1]) << 12; |
- UPB_ASSERT(!(val & 0x80000000)); |
+ assert(!(val & 0x80000000)); |
output = val >> 16; |
upb_sink_putstring(&p->top->sink, sel, &output, 1, NULL); |
return true; |
@@ -10712,8 +9910,9 @@ badpadding: |
* the true value in a contiguous buffer. */ |
static void assert_accumulate_empty(upb_json_parser *p) { |
- UPB_ASSERT(p->accumulated == NULL); |
- UPB_ASSERT(p->accumulated_len == 0); |
+ UPB_UNUSED(p); |
+ assert(p->accumulated == NULL); |
+ assert(p->accumulated_len == 0); |
} |
static void accumulate_clear(upb_json_parser *p) { |
@@ -10779,7 +9978,7 @@ static bool accumulate_append(upb_json_parser *p, const char *buf, size_t len, |
* call, and writes the length to *len. This with point either to the input |
* buffer or a temporary accumulate buffer. */ |
static const char *accumulate_getptr(upb_json_parser *p, size_t *len) { |
- UPB_ASSERT(p->accumulated); |
+ assert(p->accumulated); |
*len = p->accumulated_len; |
return p->accumulated; |
} |
@@ -10817,7 +10016,7 @@ enum { |
* the end. */ |
static void multipart_startaccum(upb_json_parser *p) { |
assert_accumulate_empty(p); |
- UPB_ASSERT(p->multipart_state == MULTIPART_INACTIVE); |
+ assert(p->multipart_state == MULTIPART_INACTIVE); |
p->multipart_state = MULTIPART_ACCUMULATE; |
} |
@@ -10825,7 +10024,7 @@ static void multipart_startaccum(upb_json_parser *p) { |
* value with the given selector. */ |
static void multipart_start(upb_json_parser *p, upb_selector_t sel) { |
assert_accumulate_empty(p); |
- UPB_ASSERT(p->multipart_state == MULTIPART_INACTIVE); |
+ assert(p->multipart_state == MULTIPART_INACTIVE); |
p->multipart_state = MULTIPART_PUSHEAGERLY; |
p->string_selector = sel; |
} |
@@ -10858,7 +10057,7 @@ static bool multipart_text(upb_json_parser *p, const char *buf, size_t len, |
/* Note: this invalidates the accumulate buffer! Call only after reading its |
* contents. */ |
static void multipart_end(upb_json_parser *p) { |
- UPB_ASSERT(p->multipart_state != MULTIPART_INACTIVE); |
+ assert(p->multipart_state != MULTIPART_INACTIVE); |
p->multipart_state = MULTIPART_INACTIVE; |
accumulate_clear(p); |
} |
@@ -10871,13 +10070,13 @@ static void multipart_end(upb_json_parser *p) { |
* region. */ |
static void capture_begin(upb_json_parser *p, const char *ptr) { |
- UPB_ASSERT(p->multipart_state != MULTIPART_INACTIVE); |
- UPB_ASSERT(p->capture == NULL); |
+ assert(p->multipart_state != MULTIPART_INACTIVE); |
+ assert(p->capture == NULL); |
p->capture = ptr; |
} |
static bool capture_end(upb_json_parser *p, const char *ptr) { |
- UPB_ASSERT(p->capture); |
+ assert(p->capture); |
if (multipart_text(p, p->capture, ptr - p->capture, true)) { |
p->capture = NULL; |
return true; |
@@ -10910,7 +10109,7 @@ static void capture_suspend(upb_json_parser *p, const char **ptr) { |
static void capture_resume(upb_json_parser *p, const char *ptr) { |
if (p->capture) { |
- UPB_ASSERT(p->capture == &suspend_capture); |
+ assert(p->capture == &suspend_capture); |
p->capture = ptr; |
} |
} |
@@ -10932,7 +10131,7 @@ static char escape_char(char in) { |
case '"': return '"'; |
case '\\': return '\\'; |
default: |
- UPB_ASSERT(0); |
+ assert(0); |
return 'x'; |
} |
} |
@@ -10956,7 +10155,7 @@ static void hexdigit(upb_json_parser *p, const char *ptr) { |
} else if (ch >= 'a' && ch <= 'f') { |
p->digit += ((ch - 'a') + 10); |
} else { |
- UPB_ASSERT(ch >= 'A' && ch <= 'F'); |
+ assert(ch >= 'A' && ch <= 'F'); |
p->digit += ((ch - 'A') + 10); |
} |
} |
@@ -11087,7 +10286,7 @@ static bool parse_number(upb_json_parser *p) { |
break; |
} |
default: |
- UPB_ASSERT(false); |
+ assert(false); |
} |
multipart_end(p); |
@@ -11113,13 +10312,13 @@ static bool parser_putbool(upb_json_parser *p, bool val) { |
} |
ok = upb_sink_putbool(&p->top->sink, parser_getsel(p), val); |
- UPB_ASSERT(ok); |
+ UPB_ASSERT_VAR(ok, ok); |
return true; |
} |
static bool start_stringval(upb_json_parser *p) { |
- UPB_ASSERT(p->top->f); |
+ assert(p->top->f); |
if (upb_fielddef_isstring(p->top->f)) { |
upb_jsonparser_frame *inner; |
@@ -11134,7 +10333,6 @@ static bool start_stringval(upb_json_parser *p) { |
upb_sink_startstr(&p->top->sink, sel, 0, &inner->sink); |
inner->m = p->top->m; |
inner->f = p->top->f; |
- inner->name_table = NULL; |
inner->is_map = false; |
inner->is_mapentry = false; |
p->top = inner; |
@@ -11181,8 +10379,8 @@ static bool end_stringval(upb_json_parser *p) { |
case UPB_TYPE_STRING: { |
upb_selector_t sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); |
- p->top--; |
upb_sink_endstr(&p->top->sink, sel); |
+ p->top--; |
break; |
} |
@@ -11209,7 +10407,7 @@ static bool end_stringval(upb_json_parser *p) { |
} |
default: |
- UPB_ASSERT(false); |
+ assert(false); |
upb_status_seterrmsg(&p->status, "Internal error in JSON decoder"); |
upb_env_reporterror(p->env, &p->status); |
ok = false; |
@@ -11222,7 +10420,7 @@ static bool end_stringval(upb_json_parser *p) { |
} |
static void start_member(upb_json_parser *p) { |
- UPB_ASSERT(!p->top->f); |
+ assert(!p->top->f); |
multipart_startaccum(p); |
} |
@@ -11280,7 +10478,7 @@ static bool parse_mapentry_key(upb_json_parser *p) { |
sel = getsel_for_handlertype(p, UPB_HANDLER_STRING); |
upb_sink_putstring(&subsink, sel, buf, len, NULL); |
sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); |
- upb_sink_endstr(&p->top->sink, sel); |
+ upb_sink_endstr(&subsink, sel); |
multipart_end(p); |
break; |
} |
@@ -11321,7 +10519,6 @@ static bool handle_mapentry(upb_json_parser *p) { |
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG); |
upb_sink_startsubmsg(&p->top->sink, sel, &inner->sink); |
inner->m = mapentrymsg; |
- inner->name_table = NULL; |
inner->mapfield = mapfield; |
inner->is_map = false; |
@@ -11351,27 +10548,27 @@ static bool handle_mapentry(upb_json_parser *p) { |
} |
static bool end_membername(upb_json_parser *p) { |
- UPB_ASSERT(!p->top->f); |
+ assert(!p->top->f); |
if (p->top->is_map) { |
return handle_mapentry(p); |
} else { |
size_t len; |
const char *buf = accumulate_getptr(p, &len); |
- upb_value v; |
- |
- if (upb_strtable_lookup2(p->top->name_table, buf, len, &v)) { |
- p->top->f = upb_value_getconstptr(v); |
- multipart_end(p); |
+ const upb_fielddef *f = upb_msgdef_ntof(p->top->m, buf, len); |
- return true; |
- } else { |
+ if (!f) { |
/* TODO(haberman): Ignore unknown fields if requested/configured to do |
* so. */ |
upb_status_seterrf(&p->status, "No such field: %.*s\n", (int)len, buf); |
upb_env_reporterror(p->env, &p->status); |
return false; |
} |
+ |
+ p->top->f = f; |
+ multipart_end(p); |
+ |
+ return true; |
} |
} |
@@ -11383,7 +10580,7 @@ static void end_member(upb_json_parser *p) { |
bool ok; |
const upb_fielddef *mapfield; |
- UPB_ASSERT(p->top > p->stack); |
+ assert(p->top > p->stack); |
/* send ENDMSG on submsg. */ |
upb_sink_endmsg(&p->top->sink, &s); |
mapfield = p->top->mapfield; |
@@ -11391,7 +10588,7 @@ static void end_member(upb_json_parser *p) { |
/* send ENDSUBMSG in repeated-field-of-mapentries frame. */ |
p->top--; |
ok = upb_handlers_getselector(mapfield, UPB_HANDLER_ENDSUBMSG, &sel); |
- UPB_ASSERT(ok); |
+ UPB_ASSERT_VAR(ok, ok); |
upb_sink_endsubmsg(&p->top->sink, sel); |
} |
@@ -11399,7 +10596,7 @@ static void end_member(upb_json_parser *p) { |
} |
static bool start_subobject(upb_json_parser *p) { |
- UPB_ASSERT(p->top->f); |
+ assert(p->top->f); |
if (upb_fielddef_ismap(p->top->f)) { |
upb_jsonparser_frame *inner; |
@@ -11413,7 +10610,6 @@ static bool start_subobject(upb_json_parser *p) { |
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSEQ); |
upb_sink_startseq(&p->top->sink, sel, &inner->sink); |
inner->m = upb_fielddef_msgsubdef(p->top->f); |
- inner->name_table = NULL; |
inner->mapfield = p->top->f; |
inner->f = NULL; |
inner->is_map = true; |
@@ -11434,7 +10630,6 @@ static bool start_subobject(upb_json_parser *p) { |
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG); |
upb_sink_startsubmsg(&p->top->sink, sel, &inner->sink); |
inner->m = upb_fielddef_msgsubdef(p->top->f); |
- set_name_table(p, inner); |
inner->f = NULL; |
inner->is_map = false; |
inner->is_mapentry = false; |
@@ -11468,7 +10663,7 @@ static bool start_array(upb_json_parser *p) { |
upb_jsonparser_frame *inner; |
upb_selector_t sel; |
- UPB_ASSERT(p->top->f); |
+ assert(p->top->f); |
if (!upb_fielddef_isseq(p->top->f)) { |
upb_status_seterrf(&p->status, |
@@ -11484,7 +10679,6 @@ static bool start_array(upb_json_parser *p) { |
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSEQ); |
upb_sink_startseq(&p->top->sink, sel, &inner->sink); |
inner->m = p->top->m; |
- inner->name_table = NULL; |
inner->f = p->top->f; |
inner->is_map = false; |
inner->is_mapentry = false; |
@@ -11496,7 +10690,7 @@ static bool start_array(upb_json_parser *p) { |
static void end_array(upb_json_parser *p) { |
upb_selector_t sel; |
- UPB_ASSERT(p->top > p->stack); |
+ assert(p->top > p->stack); |
p->top--; |
sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSEQ); |
@@ -11542,11 +10736,11 @@ static void end_object(upb_json_parser *p) { |
* final state once, when the closing '"' is seen. */ |
-#line 1244 "upb/json/parser.rl" |
+#line 1218 "upb/json/parser.rl" |
-#line 1156 "upb/json/parser.c" |
+#line 1130 "upb/json/parser.c" |
static const char _json_actions[] = { |
0, 1, 0, 1, 2, 1, 3, 1, |
5, 1, 6, 1, 7, 1, 8, 1, |
@@ -11695,7 +10889,7 @@ static const int json_en_value_machine = 27; |
static const int json_en_main = 1; |
-#line 1247 "upb/json/parser.rl" |
+#line 1221 "upb/json/parser.rl" |
size_t parse(void *closure, const void *hd, const char *buf, size_t size, |
const upb_bufhandle *handle) { |
@@ -11717,7 +10911,7 @@ size_t parse(void *closure, const void *hd, const char *buf, size_t size, |
capture_resume(parser, buf); |
-#line 1327 "upb/json/parser.c" |
+#line 1301 "upb/json/parser.c" |
{ |
int _klen; |
unsigned int _trans; |
@@ -11792,118 +10986,118 @@ _match: |
switch ( *_acts++ ) |
{ |
case 0: |
-#line 1159 "upb/json/parser.rl" |
+#line 1133 "upb/json/parser.rl" |
{ p--; {cs = stack[--top]; goto _again;} } |
break; |
case 1: |
-#line 1160 "upb/json/parser.rl" |
+#line 1134 "upb/json/parser.rl" |
{ p--; {stack[top++] = cs; cs = 10; goto _again;} } |
break; |
case 2: |
-#line 1164 "upb/json/parser.rl" |
+#line 1138 "upb/json/parser.rl" |
{ start_text(parser, p); } |
break; |
case 3: |
-#line 1165 "upb/json/parser.rl" |
+#line 1139 "upb/json/parser.rl" |
{ CHECK_RETURN_TOP(end_text(parser, p)); } |
break; |
case 4: |
-#line 1171 "upb/json/parser.rl" |
+#line 1145 "upb/json/parser.rl" |
{ start_hex(parser); } |
break; |
case 5: |
-#line 1172 "upb/json/parser.rl" |
+#line 1146 "upb/json/parser.rl" |
{ hexdigit(parser, p); } |
break; |
case 6: |
-#line 1173 "upb/json/parser.rl" |
+#line 1147 "upb/json/parser.rl" |
{ CHECK_RETURN_TOP(end_hex(parser)); } |
break; |
case 7: |
-#line 1179 "upb/json/parser.rl" |
+#line 1153 "upb/json/parser.rl" |
{ CHECK_RETURN_TOP(escape(parser, p)); } |
break; |
case 8: |
-#line 1185 "upb/json/parser.rl" |
+#line 1159 "upb/json/parser.rl" |
{ p--; {cs = stack[--top]; goto _again;} } |
break; |
case 9: |
-#line 1188 "upb/json/parser.rl" |
+#line 1162 "upb/json/parser.rl" |
{ {stack[top++] = cs; cs = 19; goto _again;} } |
break; |
case 10: |
-#line 1190 "upb/json/parser.rl" |
+#line 1164 "upb/json/parser.rl" |
{ p--; {stack[top++] = cs; cs = 27; goto _again;} } |
break; |
case 11: |
-#line 1195 "upb/json/parser.rl" |
+#line 1169 "upb/json/parser.rl" |
{ start_member(parser); } |
break; |
case 12: |
-#line 1196 "upb/json/parser.rl" |
+#line 1170 "upb/json/parser.rl" |
{ CHECK_RETURN_TOP(end_membername(parser)); } |
break; |
case 13: |
-#line 1199 "upb/json/parser.rl" |
+#line 1173 "upb/json/parser.rl" |
{ end_member(parser); } |
break; |
case 14: |
-#line 1205 "upb/json/parser.rl" |
+#line 1179 "upb/json/parser.rl" |
{ start_object(parser); } |
break; |
case 15: |
-#line 1208 "upb/json/parser.rl" |
+#line 1182 "upb/json/parser.rl" |
{ end_object(parser); } |
break; |
case 16: |
-#line 1214 "upb/json/parser.rl" |
+#line 1188 "upb/json/parser.rl" |
{ CHECK_RETURN_TOP(start_array(parser)); } |
break; |
case 17: |
-#line 1218 "upb/json/parser.rl" |
+#line 1192 "upb/json/parser.rl" |
{ end_array(parser); } |
break; |
case 18: |
-#line 1223 "upb/json/parser.rl" |
+#line 1197 "upb/json/parser.rl" |
{ start_number(parser, p); } |
break; |
case 19: |
-#line 1224 "upb/json/parser.rl" |
+#line 1198 "upb/json/parser.rl" |
{ CHECK_RETURN_TOP(end_number(parser, p)); } |
break; |
case 20: |
-#line 1226 "upb/json/parser.rl" |
+#line 1200 "upb/json/parser.rl" |
{ CHECK_RETURN_TOP(start_stringval(parser)); } |
break; |
case 21: |
-#line 1227 "upb/json/parser.rl" |
+#line 1201 "upb/json/parser.rl" |
{ CHECK_RETURN_TOP(end_stringval(parser)); } |
break; |
case 22: |
-#line 1229 "upb/json/parser.rl" |
+#line 1203 "upb/json/parser.rl" |
{ CHECK_RETURN_TOP(parser_putbool(parser, true)); } |
break; |
case 23: |
-#line 1231 "upb/json/parser.rl" |
+#line 1205 "upb/json/parser.rl" |
{ CHECK_RETURN_TOP(parser_putbool(parser, false)); } |
break; |
case 24: |
-#line 1233 "upb/json/parser.rl" |
+#line 1207 "upb/json/parser.rl" |
{ /* null value */ } |
break; |
case 25: |
-#line 1235 "upb/json/parser.rl" |
+#line 1209 "upb/json/parser.rl" |
{ CHECK_RETURN_TOP(start_subobject(parser)); } |
break; |
case 26: |
-#line 1236 "upb/json/parser.rl" |
+#line 1210 "upb/json/parser.rl" |
{ end_subobject(parser); } |
break; |
case 27: |
-#line 1241 "upb/json/parser.rl" |
+#line 1215 "upb/json/parser.rl" |
{ p--; {cs = stack[--top]; goto _again;} } |
break; |
-#line 1513 "upb/json/parser.c" |
+#line 1487 "upb/json/parser.c" |
} |
} |
@@ -11916,10 +11110,10 @@ _again: |
_out: {} |
} |
-#line 1268 "upb/json/parser.rl" |
+#line 1242 "upb/json/parser.rl" |
if (p != pe) { |
- upb_status_seterrf(&parser->status, "Parse error at '%.*s'\n", pe - p, p); |
+ upb_status_seterrf(&parser->status, "Parse error at %s\n", p); |
upb_env_reporterror(parser->env, &parser->status); |
} else { |
capture_suspend(parser, &p); |
@@ -11957,13 +11151,13 @@ static void json_parser_reset(upb_json_parser *p) { |
/* Emit Ragel initialization of the parser. */ |
-#line 1567 "upb/json/parser.c" |
+#line 1541 "upb/json/parser.c" |
{ |
cs = json_start; |
top = 0; |
} |
-#line 1308 "upb/json/parser.rl" |
+#line 1282 "upb/json/parser.rl" |
p->current_state = cs; |
p->parser_top = top; |
accumulate_clear(p); |
@@ -11973,84 +11167,10 @@ static void json_parser_reset(upb_json_parser *p) { |
upb_status_clear(&p->status); |
} |
-static void visit_json_parsermethod(const upb_refcounted *r, |
- upb_refcounted_visit *visit, |
- void *closure) { |
- const upb_json_parsermethod *method = (upb_json_parsermethod*)r; |
- visit(r, upb_msgdef_upcast2(method->msg), closure); |
-} |
- |
-static void free_json_parsermethod(upb_refcounted *r) { |
- upb_json_parsermethod *method = (upb_json_parsermethod*)r; |
- |
- upb_inttable_iter i; |
- upb_inttable_begin(&i, &method->name_tables); |
- for(; !upb_inttable_done(&i); upb_inttable_next(&i)) { |
- upb_value val = upb_inttable_iter_value(&i); |
- upb_strtable *t = upb_value_getptr(val); |
- upb_strtable_uninit(t); |
- upb_gfree(t); |
- } |
- |
- upb_inttable_uninit(&method->name_tables); |
- |
- upb_gfree(r); |
-} |
- |
-static void add_jsonname_table(upb_json_parsermethod *m, const upb_msgdef* md) { |
- upb_msg_field_iter i; |
- upb_strtable *t; |
- |
- /* It would be nice to stack-allocate this, but protobufs do not limit the |
- * length of fields to any reasonable limit. */ |
- char *buf = NULL; |
- size_t len = 0; |
- |
- if (upb_inttable_lookupptr(&m->name_tables, md, NULL)) { |
- return; |
- } |
- |
- /* TODO(haberman): handle malloc failure. */ |
- t = upb_gmalloc(sizeof(*t)); |
- upb_strtable_init(t, UPB_CTYPE_CONSTPTR); |
- upb_inttable_insertptr(&m->name_tables, md, upb_value_ptr(t)); |
- |
- for(upb_msg_field_begin(&i, md); |
- !upb_msg_field_done(&i); |
- upb_msg_field_next(&i)) { |
- const upb_fielddef *f = upb_msg_iter_field(&i); |
- |
- /* Add an entry for the JSON name. */ |
- size_t field_len = upb_fielddef_getjsonname(f, buf, len); |
- if (field_len > len) { |
- size_t len2; |
- buf = upb_grealloc(buf, 0, field_len); |
- len = field_len; |
- len2 = upb_fielddef_getjsonname(f, buf, len); |
- UPB_ASSERT(len == len2); |
- } |
- upb_strtable_insert(t, buf, upb_value_constptr(f)); |
- |
- if (strcmp(buf, upb_fielddef_name(f)) != 0) { |
- /* Since the JSON name is different from the regular field name, add an |
- * entry for the raw name (compliant proto3 JSON parsers must accept |
- * both). */ |
- upb_strtable_insert(t, upb_fielddef_name(f), upb_value_constptr(f)); |
- } |
- |
- if (upb_fielddef_issubmsg(f)) { |
- add_jsonname_table(m, upb_fielddef_msgsubdef(f)); |
- } |
- } |
- |
- upb_gfree(buf); |
-} |
/* Public API *****************************************************************/ |
-upb_json_parser *upb_json_parser_create(upb_env *env, |
- const upb_json_parsermethod *method, |
- upb_sink *output) { |
+upb_json_parser *upb_json_parser_create(upb_env *env, upb_sink *output) { |
#ifndef NDEBUG |
const size_t size_before = upb_env_bytesallocated(env); |
#endif |
@@ -12058,59 +11178,35 @@ upb_json_parser *upb_json_parser_create(upb_env *env, |
if (!p) return false; |
p->env = env; |
- p->method = method; |
p->limit = p->stack + UPB_JSON_MAX_DEPTH; |
p->accumulate_buf = NULL; |
p->accumulate_buf_size = 0; |
- upb_bytessink_reset(&p->input_, &method->input_handler_, p); |
+ upb_byteshandler_init(&p->input_handler_); |
+ upb_byteshandler_setstring(&p->input_handler_, parse, NULL); |
+ upb_byteshandler_setendstr(&p->input_handler_, end, NULL); |
+ upb_bytessink_reset(&p->input_, &p->input_handler_, p); |
json_parser_reset(p); |
upb_sink_reset(&p->top->sink, output->handlers, output->closure); |
p->top->m = upb_handlers_msgdef(output->handlers); |
- set_name_table(p, p->top); |
/* If this fails, uncomment and increase the value in parser.h. */ |
/* fprintf(stderr, "%zd\n", upb_env_bytesallocated(env) - size_before); */ |
- UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(env) - size_before <= |
- UPB_JSON_PARSER_SIZE); |
+ assert(upb_env_bytesallocated(env) - size_before <= UPB_JSON_PARSER_SIZE); |
return p; |
} |
upb_bytessink *upb_json_parser_input(upb_json_parser *p) { |
return &p->input_; |
} |
- |
-upb_json_parsermethod *upb_json_parsermethod_new(const upb_msgdef* md, |
- const void* owner) { |
- static const struct upb_refcounted_vtbl vtbl = {visit_json_parsermethod, |
- free_json_parsermethod}; |
- upb_json_parsermethod *ret = upb_gmalloc(sizeof(*ret)); |
- upb_refcounted_init(upb_json_parsermethod_upcast_mutable(ret), &vtbl, owner); |
- |
- ret->msg = md; |
- upb_ref2(md, ret); |
- |
- upb_byteshandler_init(&ret->input_handler_); |
- upb_byteshandler_setstring(&ret->input_handler_, parse, ret); |
- upb_byteshandler_setendstr(&ret->input_handler_, end, ret); |
- |
- upb_inttable_init(&ret->name_tables, UPB_CTYPE_PTR); |
- |
- add_jsonname_table(ret, md); |
- |
- return ret; |
-} |
- |
-const upb_byteshandler *upb_json_parsermethod_inputhandler( |
- const upb_json_parsermethod *m) { |
- return &m->input_handler_; |
-} |
/* |
** This currently uses snprintf() to format primitives, and could be optimized |
** further. |
*/ |
+#include <stdlib.h> |
+#include <stdio.h> |
#include <string.h> |
#include <stdint.h> |
@@ -12137,34 +11233,15 @@ struct upb_json_printer { |
/* StringPiece; a pointer plus a length. */ |
typedef struct { |
- char *ptr; |
+ const char *ptr; |
size_t len; |
} strpc; |
-void freestrpc(void *ptr) { |
- strpc *pc = ptr; |
- upb_gfree(pc->ptr); |
- upb_gfree(pc); |
-} |
- |
-/* Convert fielddef name to JSON name and return as a string piece. */ |
-strpc *newstrpc(upb_handlers *h, const upb_fielddef *f, |
- bool preserve_fieldnames) { |
- /* TODO(haberman): handle malloc failure. */ |
- strpc *ret = upb_gmalloc(sizeof(*ret)); |
- if (preserve_fieldnames) { |
- ret->ptr = upb_gstrdup(upb_fielddef_name(f)); |
- ret->len = strlen(ret->ptr); |
- } else { |
- size_t len; |
- ret->len = upb_fielddef_getjsonname(f, NULL, 0); |
- ret->ptr = upb_gmalloc(ret->len); |
- len = upb_fielddef_getjsonname(f, ret->ptr, ret->len); |
- UPB_ASSERT(len == ret->len); |
- ret->len--; /* NULL */ |
- } |
- |
- upb_handlers_addcleanup(h, ret, freestrpc); |
+strpc *newstrpc(upb_handlers *h, const upb_fielddef *f) { |
+ strpc *ret = malloc(sizeof(*ret)); |
+ ret->ptr = upb_fielddef_name(f); |
+ ret->len = strlen(ret->ptr); |
+ upb_handlers_addcleanup(h, ret, free); |
return ret; |
} |
@@ -12174,7 +11251,7 @@ static void print_data( |
upb_json_printer *p, const char *buf, unsigned int len) { |
/* TODO: Will need to change if we support pushback from the sink. */ |
size_t n = upb_bytessink_putbuf(p->output_, p->subc_, buf, len, NULL); |
- UPB_ASSERT(n == len); |
+ UPB_ASSERT_VAR(n, n == len); |
} |
static void print_comma(upb_json_printer *p) { |
@@ -12195,7 +11272,7 @@ UPB_INLINE bool is_json_escaped(char c) { |
return uc < kControlCharLimit || uc == '"' || uc == '\\'; |
} |
-UPB_INLINE const char* json_nice_escape(char c) { |
+UPB_INLINE char* json_nice_escape(char c) { |
switch (c) { |
case '"': return "\\\""; |
case '\\': return "\\\\"; |
@@ -12524,7 +11601,7 @@ static size_t putbytes(void *closure, const void *handler_data, const char *str, |
while (remaining > 2) { |
/* TODO(haberman): handle encoded lengths > sizeof(data) */ |
- UPB_ASSERT((limit - to) >= 4); |
+ UPB_ASSERT_VAR(limit, (limit - to) >= 4); |
to[0] = base64[from[0] >> 2]; |
to[1] = base64[((from[0] & 0x3) << 4) | (from[1] >> 4)]; |
@@ -12668,12 +11745,11 @@ static size_t mapkey_bytes(void *closure, const void *handler_data, |
static void set_enum_hd(upb_handlers *h, |
const upb_fielddef *f, |
- bool preserve_fieldnames, |
upb_handlerattr *attr) { |
- EnumHandlerData *hd = upb_gmalloc(sizeof(EnumHandlerData)); |
+ EnumHandlerData *hd = malloc(sizeof(EnumHandlerData)); |
hd->enumdef = (const upb_enumdef *)upb_fielddef_subdef(f); |
- hd->keyname = newstrpc(h, f, preserve_fieldnames); |
- upb_handlers_addcleanup(h, hd, upb_gfree); |
+ hd->keyname = newstrpc(h, f); |
+ upb_handlers_addcleanup(h, hd, free); |
upb_handlerattr_sethandlerdata(attr, hd); |
} |
@@ -12689,8 +11765,7 @@ static void set_enum_hd(upb_handlers *h, |
* our sources that emit mapentry messages do so canonically (with one key |
* field, and then one value field), so this is not a pressing concern at the |
* moment. */ |
-void printer_sethandlers_mapentry(const void *closure, bool preserve_fieldnames, |
- upb_handlers *h) { |
+void printer_sethandlers_mapentry(const void *closure, upb_handlers *h) { |
const upb_msgdef *md = upb_handlers_msgdef(h); |
/* A mapentry message is printed simply as '"key": value'. Rather than |
@@ -12728,7 +11803,7 @@ void printer_sethandlers_mapentry(const void *closure, bool preserve_fieldnames, |
upb_handlers_setstring(h, key_field, mapkey_bytes, &empty_attr); |
break; |
default: |
- UPB_ASSERT(false); |
+ assert(false); |
break; |
} |
@@ -12764,7 +11839,7 @@ void printer_sethandlers_mapentry(const void *closure, bool preserve_fieldnames, |
break; |
case UPB_TYPE_ENUM: { |
upb_handlerattr enum_attr = UPB_HANDLERATTR_INITIALIZER; |
- set_enum_hd(h, value_field, preserve_fieldnames, &enum_attr); |
+ set_enum_hd(h, value_field, &enum_attr); |
upb_handlers_setint32(h, value_field, mapvalue_enum, &enum_attr); |
upb_handlerattr_uninit(&enum_attr); |
break; |
@@ -12783,13 +11858,13 @@ void printer_sethandlers(const void *closure, upb_handlers *h) { |
bool is_mapentry = upb_msgdef_mapentry(md); |
upb_handlerattr empty_attr = UPB_HANDLERATTR_INITIALIZER; |
upb_msg_field_iter i; |
- const bool *preserve_fieldnames_ptr = closure; |
- const bool preserve_fieldnames = *preserve_fieldnames_ptr; |
+ |
+ UPB_UNUSED(closure); |
if (is_mapentry) { |
/* mapentry messages are sufficiently different that we handle them |
* separately. */ |
- printer_sethandlers_mapentry(closure, preserve_fieldnames, h); |
+ printer_sethandlers_mapentry(closure, h); |
return; |
} |
@@ -12810,8 +11885,7 @@ void printer_sethandlers(const void *closure, upb_handlers *h) { |
const upb_fielddef *f = upb_msg_iter_field(&i); |
upb_handlerattr name_attr = UPB_HANDLERATTR_INITIALIZER; |
- upb_handlerattr_sethandlerdata(&name_attr, |
- newstrpc(h, f, preserve_fieldnames)); |
+ upb_handlerattr_sethandlerdata(&name_attr, newstrpc(h, f)); |
if (upb_fielddef_ismap(f)) { |
upb_handlers_setstartseq(h, f, startmap, &name_attr); |
@@ -12834,7 +11908,7 @@ void printer_sethandlers(const void *closure, upb_handlers *h) { |
* option later to control this behavior, but we will wait for a real |
* need first. */ |
upb_handlerattr enum_attr = UPB_HANDLERATTR_INITIALIZER; |
- set_enum_hd(h, f, preserve_fieldnames, &enum_attr); |
+ set_enum_hd(h, f, &enum_attr); |
if (upb_fielddef_isseq(f)) { |
upb_handlers_setint32(h, f, repeated_enum, &enum_attr); |
@@ -12902,8 +11976,7 @@ upb_json_printer *upb_json_printer_create(upb_env *e, const upb_handlers *h, |
upb_sink_reset(&p->input_, h, p); |
/* If this fails, increase the value in printer.h. */ |
- UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(e) - size_before <= |
- UPB_JSON_PRINTER_SIZE); |
+ assert(upb_env_bytesallocated(e) - size_before <= UPB_JSON_PRINTER_SIZE); |
return p; |
} |
@@ -12912,8 +11985,6 @@ upb_sink *upb_json_printer_input(upb_json_printer *p) { |
} |
const upb_handlers *upb_json_printer_newhandlers(const upb_msgdef *md, |
- bool preserve_fieldnames, |
const void *owner) { |
- return upb_handlers_newfrozen( |
- md, owner, printer_sethandlers, &preserve_fieldnames); |
+ return upb_handlers_newfrozen(md, owner, printer_sethandlers, NULL); |
} |