From babefc3c66552db4a0b0302324f1280b0faacd82 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 21 Jul 2009 01:44:13 -0700 Subject: Bugfixes to parser. --- src/upb_parse.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/upb_parse.h') diff --git a/src/upb_parse.h b/src/upb_parse.h index 4a432d8..8975052 100644 --- a/src/upb_parse.h +++ b/src/upb_parse.h @@ -16,6 +16,7 @@ #include #include #include "upb.h" +#include "descriptor.h" #ifdef __cplusplus extern "C" { @@ -48,6 +49,16 @@ struct upb_tag { upb_wire_type_t wire_type; }; +INLINE bool upb_issubmsgtype(upb_field_type_t type) { + return type == GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_GROUP || + type == GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_MESSAGE; +} + +INLINE bool upb_isstringtype(upb_field_type_t type) { + return type == GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_STRING || + type == GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_BYTES; +} + /* High-level parsing interface. **********************************************/ /* The general scheme is that the client registers callbacks that will be @@ -90,9 +101,8 @@ typedef void *(*upb_value_cb)(void *udata, void *buf, void *end, void *user_field_desc, jmp_buf errjmp); /* The callback that is called when a string is parsed. */ -typedef upb_status_t (*upb_str_cb)(void *udata, - struct upb_string *str, - void *user_field_desc); +typedef void (*upb_str_cb)(void *udata, struct upb_string *str, + void *user_field_desc); /* Callbacks that are called when a submessage begins and ends, respectively. * Both are called with the submessage's stack frame at the top of the stack. */ @@ -103,7 +113,8 @@ typedef void (*upb_submsg_end_cb)(void *udata); struct upb_parse_state { /* For delimited submsgs, counts from the submsg len down to zero. * For group submsgs, counts from zero down to the negative len. */ - int32_t stack[UPB_MAX_NESTING], *top, *limit; + uint32_t stack[UPB_MAX_NESTING], *top, *limit; + size_t completed_offset; void *udata; upb_tag_cb tag_cb; upb_value_cb value_cb; -- cgit v1.2.3