From 559e23c796f973a65d05c76e211835b126ee8ac8 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Fri, 17 Jun 2011 10:34:29 -0700 Subject: Major refactoring: abandon upb_msg, add upb_accessors. Next on the chopping block is upb_string. --- src/upb_decoder.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/upb_decoder.c') diff --git a/src/upb_decoder.c b/src/upb_decoder.c index 34cd811..a44b561 100644 --- a/src/upb_decoder.c +++ b/src/upb_decoder.c @@ -11,6 +11,7 @@ #include "upb_bytestream.h" #include "upb_decoder.h" #include "upb_varint.h" +#include "upb_msg.h" // Used for frames that have no specific end offset: groups, repeated primitive // fields inside groups, and the top-level message. @@ -346,7 +347,7 @@ static void upb_decoder_skip(void *_d, upb_dispatcher_frame *top, d->ptr = d->buf + bottom->end_offset; } -void upb_decoder_init(upb_decoder *d, upb_handlers *handlers) { +void upb_decoder_initforhandlers(upb_decoder *d, upb_handlers *handlers) { upb_dispatcher_init( &d->dispatcher, handlers, upb_decoder_skip, upb_decoder_exit2, d); #ifdef UPB_USE_JIT_X64 @@ -388,6 +389,13 @@ void upb_decoder_init(upb_decoder *d, upb_handlers *handlers) { } } +void upb_decoder_initformsgdef(upb_decoder *d, upb_msgdef *m) { + upb_handlers *h = upb_handlers_new(); + upb_accessors_reghandlers(h, m); + upb_decoder_initforhandlers(d, h); + upb_handlers_unref(h); +} + void upb_decoder_reset(upb_decoder *d, upb_bytesrc *bytesrc, void *closure) { upb_dispatcher_reset(&d->dispatcher, closure)->end_offset = UPB_NONDELIMITED; d->bytesrc = bytesrc; -- cgit v1.2.3