summaryrefslogtreecommitdiff
path: root/src/upb_stream.c
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2011-03-26 18:14:01 -0700
committerJosh Haberman <jhaberman@gmail.com>2011-03-26 18:14:01 -0700
commit2c86e7eddb23c92cc83391c3f751c72237ec3759 (patch)
treebd2960efa1a9ca00c58ba5356f797d05ee55e336 /src/upb_stream.c
parent484809c272df7b1f05e56d09f6a5e8e0f340cac4 (diff)
Small semantics changes in the decoder.
Simplified some of the semantics around the decoder's data structures, in anticipation of sharing them between the regular C decoder and a JIT-ted decoder.
Diffstat (limited to 'src/upb_stream.c')
-rw-r--r--src/upb_stream.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/upb_stream.c b/src/upb_stream.c
index 3b0119c..aebdb42 100644
--- a/src/upb_stream.c
+++ b/src/upb_stream.c
@@ -222,7 +222,8 @@ void upb_handlers_pop(upb_handlers *h, upb_fielddef *f) {
/* upb_dispatcher *************************************************************/
static upb_handlers_fieldent toplevel_f = {
- false, 0, 0, // The one value that is actually read
+ false, UPB_TYPE(GROUP),
+ 0, // msgent_index
#ifdef NDEBUG
{{0}},
#else
@@ -230,17 +231,15 @@ static upb_handlers_fieldent toplevel_f = {
#endif
{NULL}, NULL};
-void upb_dispatcher_init(upb_dispatcher *d, upb_handlers *h,
- size_t top_end_offset) {
+void upb_dispatcher_init(upb_dispatcher *d, upb_handlers *h) {
d->handlers = h;
for (int i = 0; i < h->msgs_len; i++)
upb_inttable_compact(&h->msgs[i].fieldtab);
- d->stack[0].end_offset = top_end_offset;
d->stack[0].f = &toplevel_f;
upb_status_init(&d->status);
}
-void upb_dispatcher_reset(upb_dispatcher *d) {
+void upb_dispatcher_reset(upb_dispatcher *d, void *top_closure, uint32_t top_end_offset) {
d->msgent = &d->handlers->msgs[0];
d->dispatch_table = &d->msgent->fieldtab;
d->current_depth = 0;
@@ -248,6 +247,8 @@ void upb_dispatcher_reset(upb_dispatcher *d) {
d->noframe_depth = INT_MAX;
d->delegated_depth = 0;
d->top = d->stack;
+ d->top->closure = top_closure;
+ d->top->end_offset = top_end_offset;
d->limit = &d->stack[UPB_MAX_NESTING];
}
@@ -261,9 +262,8 @@ void upb_dispatcher_break(upb_dispatcher *d) {
d->noframe_depth = d->current_depth;
}
-upb_flow_t upb_dispatch_startmsg(upb_dispatcher *d, void *closure) {
- d->top->closure = closure;
- upb_flow_t flow = d->msgent->startmsg(closure);
+upb_flow_t upb_dispatch_startmsg(upb_dispatcher *d) {
+ upb_flow_t flow = d->msgent->startmsg(d->top->closure);
if (flow != UPB_CONTINUE) {
d->noframe_depth = d->current_depth + 1;
d->skip_depth = (flow == UPB_BREAK) ? d->delegated_depth : d->current_depth;
@@ -304,7 +304,7 @@ upb_flow_t upb_dispatch_startsubmsg(upb_dispatcher *d,
d->top->closure = sflow.closure;
d->msgent = upb_handlers_getmsgent(d->handlers, f);
d->dispatch_table = &d->msgent->fieldtab;
- return upb_dispatch_startmsg(d, d->top->closure);
+ return upb_dispatch_startmsg(d);
}
upb_flow_t upb_dispatch_endsubmsg(upb_dispatcher *d) {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback