|
|
@ -9,8 +9,6 @@ |
|
|
|
#include "upb_handlers.h" |
|
|
|
#include "upb_handlers.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* upb_handlers ***************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
upb_flow_t upb_startmsg_nop(void *closure) { |
|
|
|
upb_flow_t upb_startmsg_nop(void *closure) { |
|
|
|
(void)closure; |
|
|
|
(void)closure; |
|
|
|
return UPB_CONTINUE; |
|
|
|
return UPB_CONTINUE; |
|
|
@ -39,220 +37,162 @@ upb_flow_t upb_endsubmsg_nop(void *closure, upb_value fval) { |
|
|
|
return UPB_CONTINUE; |
|
|
|
return UPB_CONTINUE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
upb_flow_t upb_unknownval_nop(void *closure, upb_field_number_t fieldnum, |
|
|
|
|
|
|
|
upb_value val) { |
|
|
|
|
|
|
|
(void)closure; |
|
|
|
|
|
|
|
(void)fieldnum; |
|
|
|
|
|
|
|
(void)val; |
|
|
|
|
|
|
|
return UPB_CONTINUE; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void upb_msgent_init(upb_mhandlers *e) { |
|
|
|
/* upb_mhandlers **************************************************************/ |
|
|
|
upb_inttable_init(&e->fieldtab, 8, sizeof(upb_fhandlers)); |
|
|
|
|
|
|
|
e->startmsg = &upb_startmsg_nop; |
|
|
|
|
|
|
|
e->endmsg = &upb_endmsg_nop; |
|
|
|
|
|
|
|
e->tablearray = NULL; |
|
|
|
|
|
|
|
e->is_group = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void upb_handlers_init(upb_handlers *h, upb_msgdef *md) { |
|
|
|
|
|
|
|
h->msgs_len = 1; |
|
|
|
|
|
|
|
h->msgs_size = 4; |
|
|
|
|
|
|
|
h->msgs = malloc(h->msgs_size * sizeof(*h->msgs)); |
|
|
|
|
|
|
|
h->top = &h->stack[0]; |
|
|
|
|
|
|
|
h->limit = &h->stack[UPB_MAX_TYPE_DEPTH]; |
|
|
|
|
|
|
|
h->toplevel_msgdef = md; |
|
|
|
|
|
|
|
h->should_jit = true; |
|
|
|
|
|
|
|
if (md) upb_msgdef_ref(md); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h->top->msgent_index = 0; |
|
|
|
|
|
|
|
h->top->msgdef = md; |
|
|
|
|
|
|
|
h->msgent = &h->msgs[0]; |
|
|
|
|
|
|
|
upb_msgent_init(h->msgent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void upb_handlers_uninit(upb_handlers *h) { |
|
|
|
static upb_mhandlers *upb_mhandlers_new() { |
|
|
|
for (int i = 0; i < h->msgs_len; i++) { |
|
|
|
upb_mhandlers *m = malloc(sizeof(*m)); |
|
|
|
upb_inttable_free(&h->msgs[i].fieldtab); |
|
|
|
upb_inttable_init(&m->fieldtab, 8, sizeof(upb_fhandlers)); |
|
|
|
free(h->msgs[i].tablearray); |
|
|
|
m->startmsg = &upb_startmsg_nop; |
|
|
|
} |
|
|
|
m->endmsg = &upb_endmsg_nop; |
|
|
|
free(h->msgs); |
|
|
|
m->tablearray = NULL; |
|
|
|
upb_msgdef_unref(h->toplevel_msgdef); |
|
|
|
m->is_group = false; |
|
|
|
|
|
|
|
return m; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static upb_fhandlers *upb_handlers_getorcreate_without_fval( |
|
|
|
static upb_fhandlers *_upb_mhandlers_newfield(upb_mhandlers *m, uint32_t n, |
|
|
|
upb_handlers *h, upb_field_number_t fieldnum, upb_fieldtype_t type, bool repeated) { |
|
|
|
upb_fieldtype_t type, |
|
|
|
uint32_t tag = fieldnum << 3 | upb_types[type].native_wire_type; |
|
|
|
bool repeated) { |
|
|
|
upb_fhandlers *f = upb_inttable_lookup(&h->msgent->fieldtab, tag); |
|
|
|
uint32_t tag = n << 3 | upb_types[type].native_wire_type; |
|
|
|
if (!f) { |
|
|
|
upb_fhandlers *f = upb_inttable_lookup(&m->fieldtab, tag); |
|
|
|
|
|
|
|
if (f) abort(); |
|
|
|
upb_fhandlers new_f = {false, type, repeated, |
|
|
|
upb_fhandlers new_f = {false, type, repeated, |
|
|
|
repeated && upb_isprimitivetype(type), fieldnum, -1, UPB_NO_VALUE, |
|
|
|
repeated && upb_isprimitivetype(type), n, NULL, UPB_NO_VALUE, |
|
|
|
{&upb_value_nop}, &upb_endsubmsg_nop, 0, 0, 0, NULL}; |
|
|
|
&upb_value_nop, &upb_startsubmsg_nop, &upb_endsubmsg_nop, 0, 0, 0, NULL}; |
|
|
|
if (upb_issubmsgtype(type)) new_f.cb.startsubmsg = &upb_startsubmsg_nop; |
|
|
|
if (upb_issubmsgtype(type)) new_f.startsubmsg = &upb_startsubmsg_nop; |
|
|
|
upb_inttable_insert(&h->msgent->fieldtab, tag, &new_f); |
|
|
|
upb_inttable_insert(&m->fieldtab, tag, &new_f); |
|
|
|
|
|
|
|
f = upb_inttable_lookup(&m->fieldtab, tag); |
|
|
|
f = upb_inttable_lookup(&h->msgent->fieldtab, tag); |
|
|
|
|
|
|
|
assert(f); |
|
|
|
assert(f); |
|
|
|
} |
|
|
|
|
|
|
|
assert(f->type == type); |
|
|
|
assert(f->type == type); |
|
|
|
return f; |
|
|
|
return f; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static upb_fhandlers *upb_handlers_getorcreate( |
|
|
|
upb_fhandlers *upb_mhandlers_newfield(upb_mhandlers *m, uint32_t n, |
|
|
|
upb_handlers *h, upb_field_number_t fieldnum, |
|
|
|
upb_fieldtype_t type, bool repeated) { |
|
|
|
upb_fieldtype_t type, bool repeated, upb_value fval) { |
|
|
|
assert(type != UPB_TYPE(MESSAGE)); |
|
|
|
upb_fhandlers *f = |
|
|
|
assert(type != UPB_TYPE(GROUP)); |
|
|
|
upb_handlers_getorcreate_without_fval(h, fieldnum, type, repeated); |
|
|
|
return _upb_mhandlers_newfield(m, n, type, repeated); |
|
|
|
f->fval = fval; |
|
|
|
|
|
|
|
return f; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void upb_register_startend(upb_handlers *h, upb_startmsg_handler *startmsg, |
|
|
|
upb_fhandlers *upb_mhandlers_newsubmsgfield(upb_mhandlers *m, uint32_t n, |
|
|
|
upb_endmsg_handler *endmsg) { |
|
|
|
upb_fieldtype_t type, bool repeated, |
|
|
|
h->msgent->startmsg = startmsg ? startmsg : &upb_startmsg_nop; |
|
|
|
upb_mhandlers *subm) { |
|
|
|
h->msgent->endmsg = endmsg ? endmsg : &upb_endmsg_nop; |
|
|
|
assert(type == UPB_TYPE(MESSAGE) || type == UPB_TYPE(GROUP)); |
|
|
|
|
|
|
|
assert(subm); |
|
|
|
|
|
|
|
upb_fhandlers *f = _upb_mhandlers_newfield(m, n, type, repeated); |
|
|
|
|
|
|
|
f->submsg = subm; |
|
|
|
|
|
|
|
if (type == UPB_TYPE(GROUP)) |
|
|
|
|
|
|
|
_upb_mhandlers_newfield(subm, n, UPB_TYPE_ENDGROUP, false); |
|
|
|
|
|
|
|
return f; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
typedef struct { |
|
|
|
// void upb_register_unknownval(upb_handlers *h,
|
|
|
|
upb_strtable_entry e; |
|
|
|
// upb_unknownval_handler *unknown);
|
|
|
|
upb_mhandlers *mh; |
|
|
|
// bool upb_handlers_link(upb_handlers *h, upb_fielddef *f);
|
|
|
|
} upb_mtab_ent; |
|
|
|
// void upb_register_path_value(upb_handlers *h, const char *path,
|
|
|
|
|
|
|
|
// upb_value_handler *value, upb_value fval);
|
|
|
|
static upb_mhandlers *upb_regmsg_dfs(upb_handlers *h, upb_msgdef *m, |
|
|
|
|
|
|
|
upb_onmsgreg *msgreg_cb, |
|
|
|
void upb_register_all(upb_handlers *h, upb_startmsg_handler *start, |
|
|
|
upb_onfieldreg *fieldreg_cb, |
|
|
|
upb_endmsg_handler *end, |
|
|
|
void *closure, upb_strtable *mtab) { |
|
|
|
upb_value_handler *value, |
|
|
|
upb_mhandlers *mh = upb_handlers_newmsg(h); |
|
|
|
upb_startsubmsg_handler *startsubmsg, |
|
|
|
upb_mtab_ent e = {{m->base.fqname, 0}, mh}; |
|
|
|
upb_endsubmsg_handler *endsubmsg) { |
|
|
|
printf("Inserting: " UPB_STRFMT "\n", UPB_STRARG(m->base.fqname)); |
|
|
|
upb_register_startend(h, start, end); |
|
|
|
upb_strtable_insert(mtab, &e.e); |
|
|
|
//upb_register_unknownval(h, unknown);
|
|
|
|
if (msgreg_cb) msgreg_cb(closure, mh, m); |
|
|
|
upb_msgdef *m = h->top->msgdef; |
|
|
|
|
|
|
|
upb_msg_iter i; |
|
|
|
upb_msg_iter i; |
|
|
|
for(i = upb_msg_begin(m); !upb_msg_done(i); i = upb_msg_next(m, i)) { |
|
|
|
for(i = upb_msg_begin(m); !upb_msg_done(i); i = upb_msg_next(m, i)) { |
|
|
|
upb_fielddef *f = upb_msg_iter_field(i); |
|
|
|
upb_fielddef *f = upb_msg_iter_field(i); |
|
|
|
upb_value fval; |
|
|
|
upb_fhandlers *fh; |
|
|
|
upb_value_setfielddef(&fval, f); |
|
|
|
|
|
|
|
if (upb_issubmsg(f)) { |
|
|
|
if (upb_issubmsg(f)) { |
|
|
|
upb_handlers_push(h, f, startsubmsg, endsubmsg, fval, false); |
|
|
|
upb_mhandlers *sub_mh; |
|
|
|
upb_register_all(h, start, end, value, startsubmsg, endsubmsg); |
|
|
|
upb_mtab_ent *subm_ent; |
|
|
|
upb_handlers_pop(h, f); |
|
|
|
// The table lookup is necessary to break the DFS for type cycles.
|
|
|
|
|
|
|
|
printf("Testing: " UPB_STRFMT "\n", UPB_STRARG(f->def->fqname)); |
|
|
|
|
|
|
|
if ((subm_ent = upb_strtable_lookup(mtab, f->def->fqname)) != NULL) { |
|
|
|
|
|
|
|
sub_mh = subm_ent->mh; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
upb_register_value(h, f, value, fval); |
|
|
|
sub_mh = upb_regmsg_dfs(h, upb_downcast_msgdef(f->def), msgreg_cb, |
|
|
|
|
|
|
|
fieldreg_cb, closure, mtab); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fh = upb_mhandlers_newsubmsgfield( |
|
|
|
|
|
|
|
mh, f->number, f->type, upb_isarray(f), sub_mh); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
fh = upb_mhandlers_newfield(mh, f->number, f->type, upb_isarray(f)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (fieldreg_cb) fieldreg_cb(closure, fh, f); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return mh; |
|
|
|
void upb_register_typed_value(upb_handlers *h, upb_field_number_t fieldnum, |
|
|
|
|
|
|
|
upb_fieldtype_t type, bool repeated, |
|
|
|
|
|
|
|
upb_value_handler *value, upb_value fval) { |
|
|
|
|
|
|
|
upb_handlers_getorcreate(h, fieldnum, type, repeated, fval)->cb.value = |
|
|
|
|
|
|
|
value ? value : &upb_value_nop; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void upb_register_value(upb_handlers *h, upb_fielddef *f, |
|
|
|
upb_mhandlers *upb_handlers_regmsgdef(upb_handlers *h, upb_msgdef *m, |
|
|
|
upb_value_handler *value, upb_value fval) { |
|
|
|
upb_onmsgreg *msgreg_cb, |
|
|
|
assert(f->msgdef == h->top->msgdef); |
|
|
|
upb_onfieldreg *fieldreg_cb, |
|
|
|
upb_register_typed_value(h, f->number, f->type, upb_isarray(f), value, fval); |
|
|
|
void *closure) { |
|
|
|
|
|
|
|
upb_strtable mtab; |
|
|
|
|
|
|
|
upb_strtable_init(&mtab, 8, sizeof(upb_mtab_ent)); |
|
|
|
|
|
|
|
upb_mhandlers *ret = |
|
|
|
|
|
|
|
upb_regmsg_dfs(h, m, msgreg_cb, fieldreg_cb, closure, &mtab); |
|
|
|
|
|
|
|
upb_strtable_free(&mtab); |
|
|
|
|
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void upb_register_typed_submsg(upb_handlers *h, upb_field_number_t fieldnum, |
|
|
|
|
|
|
|
upb_fieldtype_t type, bool repeated, |
|
|
|
|
|
|
|
upb_startsubmsg_handler *start, |
|
|
|
|
|
|
|
upb_endsubmsg_handler *end, |
|
|
|
|
|
|
|
upb_value fval) { |
|
|
|
|
|
|
|
upb_fhandlers *f = upb_handlers_getorcreate(h, fieldnum, type, repeated, fval); |
|
|
|
|
|
|
|
f->cb.startsubmsg = start ? start : &upb_startsubmsg_nop; |
|
|
|
|
|
|
|
f->endsubmsg = end ? end : &upb_endsubmsg_nop; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void upb_handlers_typed_link(upb_handlers *h, upb_field_number_t fieldnum, |
|
|
|
/* upb_handlers ***************************************************************/ |
|
|
|
upb_fieldtype_t type, bool repeated, int frames) { |
|
|
|
|
|
|
|
assert(frames <= (h->top - h->stack)); |
|
|
|
|
|
|
|
upb_fhandlers *f = |
|
|
|
|
|
|
|
upb_handlers_getorcreate_without_fval(h, fieldnum, type, repeated); |
|
|
|
|
|
|
|
f->msgent_index = (h->top - frames)->msgent_index; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void upb_handlers_typed_push(upb_handlers *h, upb_field_number_t fieldnum, |
|
|
|
void upb_handlers_init(upb_handlers *h) { |
|
|
|
upb_fieldtype_t type, bool repeated) { |
|
|
|
h->msgs_len = 0; |
|
|
|
upb_fhandlers *f = |
|
|
|
h->msgs_size = 4; |
|
|
|
upb_handlers_getorcreate_without_fval(h, fieldnum, type, repeated); |
|
|
|
h->msgs = malloc(h->msgs_size * sizeof(*h->msgs)); |
|
|
|
if (h->top == h->limit) abort(); // TODO: make growable.
|
|
|
|
h->should_jit = true; |
|
|
|
++h->top; |
|
|
|
|
|
|
|
if (f->msgent_index == -1) { |
|
|
|
|
|
|
|
// Need to push a new msgent.
|
|
|
|
|
|
|
|
if (h->msgs_size == h->msgs_len) { |
|
|
|
|
|
|
|
h->msgs_size *= 2; |
|
|
|
|
|
|
|
h->msgs = realloc(h->msgs, h->msgs_size * sizeof(*h->msgs)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
f->msgent_index = h->msgs_len++; |
|
|
|
|
|
|
|
h->msgent = &h->msgs[f->msgent_index]; |
|
|
|
|
|
|
|
upb_msgent_init(h->msgent); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
h->msgent = &h->msgs[f->msgent_index]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
h->top->msgent_index = f->msgent_index; |
|
|
|
|
|
|
|
if (h->toplevel_msgdef) { |
|
|
|
|
|
|
|
upb_fielddef *f = upb_msgdef_itof((h->top - 1)->msgdef, fieldnum); |
|
|
|
|
|
|
|
assert(f); |
|
|
|
|
|
|
|
h->top->msgdef = upb_downcast_msgdef(f->def); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (type == UPB_TYPE(GROUP)) { |
|
|
|
|
|
|
|
// Insert a fieldent for ENDGROUP so we can easily dispatch endgroup when
|
|
|
|
void upb_handlers_uninit(upb_handlers *h) { |
|
|
|
// we see it in the submessage.
|
|
|
|
for (int i = 0; i < h->msgs_len; i++) { |
|
|
|
// TODO: assert that no other fields in the group are registered with the
|
|
|
|
upb_mhandlers *mh = h->msgs[i]; |
|
|
|
// same name or number.
|
|
|
|
upb_inttable_free(&mh->fieldtab); |
|
|
|
upb_register_typed_submsg(h, fieldnum, UPB_TYPE_ENDGROUP, false, NULL, NULL, |
|
|
|
free(mh->tablearray); |
|
|
|
UPB_NO_VALUE); |
|
|
|
free(mh); |
|
|
|
h->msgent->is_group = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
free(h->msgs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void upb_handlers_push(upb_handlers *h, upb_fielddef *f, |
|
|
|
upb_mhandlers *upb_handlers_newmsg(upb_handlers *h) { |
|
|
|
upb_startsubmsg_handler *start, |
|
|
|
if (h->msgs_len == h->msgs_size) { |
|
|
|
upb_endsubmsg_handler *end, upb_value fval, |
|
|
|
h->msgs_size *= 2; |
|
|
|
bool delegate) { |
|
|
|
h->msgs = realloc(h->msgs, h->msgs_size * sizeof(*h->msgs)); |
|
|
|
assert(f->msgdef == h->top->msgdef); |
|
|
|
|
|
|
|
(void)delegate; // TODO
|
|
|
|
|
|
|
|
upb_register_typed_submsg(h, f->number, f->type, upb_isarray(f), start, end, fval); |
|
|
|
|
|
|
|
upb_handlers_typed_push(h, f->number, f->type, upb_isarray(f)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
upb_mhandlers *mh = upb_mhandlers_new(); |
|
|
|
void upb_handlers_typed_pop(upb_handlers *h) { |
|
|
|
h->msgs[h->msgs_len++] = mh; |
|
|
|
assert(h->top > h->stack); |
|
|
|
return mh; |
|
|
|
--h->top; |
|
|
|
|
|
|
|
h->msgent = &h->msgs[h->top->msgent_index]; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void upb_handlers_pop(upb_handlers *h, upb_fielddef *f) { |
|
|
|
|
|
|
|
(void)f; // TODO: Check that this matches the corresponding push.
|
|
|
|
|
|
|
|
upb_handlers_typed_pop(h); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* upb_dispatcher *************************************************************/ |
|
|
|
/* upb_dispatcher *************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
static upb_fhandlers toplevel_f = { |
|
|
|
static upb_fhandlers toplevel_f = { |
|
|
|
false, UPB_TYPE(GROUP), false, false, 0, |
|
|
|
false, UPB_TYPE(GROUP), false, false, 0, |
|
|
|
0, // msgent_index
|
|
|
|
NULL, // submsg
|
|
|
|
#ifdef NDEBUG |
|
|
|
#ifdef NDEBUG |
|
|
|
{{0}}, |
|
|
|
{{0}}, |
|
|
|
#else |
|
|
|
#else |
|
|
|
{{0}, UPB_VALUETYPE_RAW}, |
|
|
|
{{0}, UPB_VALUETYPE_RAW}, |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
{NULL}, NULL, 0, 0, 0, NULL}; |
|
|
|
NULL, NULL, NULL, 0, 0, 0, NULL}; |
|
|
|
|
|
|
|
|
|
|
|
void upb_dispatcher_init(upb_dispatcher *d, upb_handlers *h) { |
|
|
|
void upb_dispatcher_init(upb_dispatcher *d, upb_handlers *h) { |
|
|
|
d->handlers = h; |
|
|
|
d->handlers = h; |
|
|
|
for (int i = 0; i < h->msgs_len; i++) |
|
|
|
for (int i = 0; i < h->msgs_len; i++) { |
|
|
|
upb_inttable_compact(&h->msgs[i].fieldtab); |
|
|
|
upb_mhandlers *m = h->msgs[i]; |
|
|
|
|
|
|
|
upb_inttable_compact(&m->fieldtab); |
|
|
|
|
|
|
|
} |
|
|
|
d->stack[0].f = &toplevel_f; |
|
|
|
d->stack[0].f = &toplevel_f; |
|
|
|
d->limit = &d->stack[UPB_MAX_NESTING]; |
|
|
|
d->limit = &d->stack[UPB_MAX_NESTING]; |
|
|
|
upb_status_init(&d->status); |
|
|
|
upb_status_init(&d->status); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void upb_dispatcher_reset(upb_dispatcher *d, void *top_closure, uint32_t top_end_offset) { |
|
|
|
void upb_dispatcher_reset(upb_dispatcher *d, void *top_closure, uint32_t top_end_offset) { |
|
|
|
d->msgent = &d->handlers->msgs[0]; |
|
|
|
d->msgent = d->handlers->msgs[0]; |
|
|
|
d->dispatch_table = &d->msgent->fieldtab; |
|
|
|
d->dispatch_table = &d->msgent->fieldtab; |
|
|
|
d->current_depth = 0; |
|
|
|
d->current_depth = 0; |
|
|
|
d->skip_depth = INT_MAX; |
|
|
|
d->skip_depth = INT_MAX; |
|
|
@ -296,7 +236,7 @@ upb_flow_t upb_dispatch_startsubmsg(upb_dispatcher *d, upb_fhandlers *f, |
|
|
|
size_t userval) { |
|
|
|
size_t userval) { |
|
|
|
++d->current_depth; |
|
|
|
++d->current_depth; |
|
|
|
if (upb_dispatcher_skipping(d)) return UPB_SKIPSUBMSG; |
|
|
|
if (upb_dispatcher_skipping(d)) return UPB_SKIPSUBMSG; |
|
|
|
upb_sflow_t sflow = f->cb.startsubmsg(d->top->closure, f->fval); |
|
|
|
upb_sflow_t sflow = f->startsubmsg(d->top->closure, f->fval); |
|
|
|
if (sflow.flow != UPB_CONTINUE) { |
|
|
|
if (sflow.flow != UPB_CONTINUE) { |
|
|
|
d->noframe_depth = d->current_depth; |
|
|
|
d->noframe_depth = d->current_depth; |
|
|
|
d->skip_depth = (sflow.flow == UPB_BREAK) ? |
|
|
|
d->skip_depth = (sflow.flow == UPB_BREAK) ? |
|
|
@ -315,7 +255,7 @@ upb_flow_t upb_dispatch_startsubmsg(upb_dispatcher *d, upb_fhandlers *f, |
|
|
|
d->top->end_offset = userval; |
|
|
|
d->top->end_offset = userval; |
|
|
|
d->top->closure = sflow.closure; |
|
|
|
d->top->closure = sflow.closure; |
|
|
|
d->top->is_packed = false; |
|
|
|
d->top->is_packed = false; |
|
|
|
d->msgent = upb_handlers_getmsgent(d->handlers, f); |
|
|
|
d->msgent = f->submsg; |
|
|
|
d->dispatch_table = &d->msgent->fieldtab; |
|
|
|
d->dispatch_table = &d->msgent->fieldtab; |
|
|
|
return upb_dispatch_startmsg(d); |
|
|
|
return upb_dispatch_startmsg(d); |
|
|
|
} |
|
|
|
} |
|
|
@ -329,7 +269,8 @@ upb_flow_t upb_dispatch_endsubmsg(upb_dispatcher *d) { |
|
|
|
upb_fhandlers *old_f = d->top->f; |
|
|
|
upb_fhandlers *old_f = d->top->f; |
|
|
|
d->msgent->endmsg(d->top->closure, &d->status); |
|
|
|
d->msgent->endmsg(d->top->closure, &d->status); |
|
|
|
--d->top; |
|
|
|
--d->top; |
|
|
|
d->msgent = upb_handlers_getmsgent(d->handlers, d->top->f); |
|
|
|
d->msgent = d->top->f->submsg; |
|
|
|
|
|
|
|
if (!d->msgent) d->msgent = d->handlers->msgs[0]; |
|
|
|
d->dispatch_table = &d->msgent->fieldtab; |
|
|
|
d->dispatch_table = &d->msgent->fieldtab; |
|
|
|
d->noframe_depth = INT_MAX; |
|
|
|
d->noframe_depth = INT_MAX; |
|
|
|
if (!upb_dispatcher_skipping(d)) d->skip_depth = INT_MAX; |
|
|
|
if (!upb_dispatcher_skipping(d)) d->skip_depth = INT_MAX; |
|
|
|