summaryrefslogtreecommitdiff
path: root/upb
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2019-06-02 21:09:33 -0700
committerJoshua Haberman <jhaberman@gmail.com>2019-06-02 21:09:33 -0700
commit7485261370ad0bb691c801a4128712d962cdd7d3 (patch)
tree590290a290720202ccb1bdb5e77fa65adfbd7353 /upb
parent583f24fec1f3773b86168db2d2e4f95f36c3324d (diff)
WIP.
Diffstat (limited to 'upb')
-rw-r--r--upb/decode.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/upb/decode.c b/upb/decode.c
index 17733d3..8d3b398 100644
--- a/upb/decode.c
+++ b/upb/decode.c
@@ -30,20 +30,26 @@ const uint8_t upb_desctype_to_fieldtype[] = {
/* Data pertaining to the parse. */
typedef struct {
- /* Current decoding pointer. Points to the beginning of a field until we
- * have finished decoding the whole field. */
- const char *ptr;
+ /* Parsing limit: either end of delimited region or end of buffer. */
+ const char *limit;
+
+ /* Signals how the parse ended:
+ * - when 0: parse ended at delimited limit.
+ * - when 1: parse ended due to end-of-stream.
+ * - otherwise: parse ended due to a terminating tag (either 0 or END_GROUP).
+ *
+ * In the last case, tag-1 is stored, to avoid conflicting with case 0. */
+ uint32_t parse_status;
+
upb_arena *arena;
} upb_decstate;
-/* Data pertaining to a single message frame. */
+/* Data passed by value to each parsing function. */
typedef struct {
- const char *limit;
- int32_t group_number; /* 0 if we are not parsing a group. */
-
- /* These members are unset for an unknown group frame. */
+ const char *ptr,
char *msg;
const upb_msglayout *m;
+ upb_decstate *state;
} upb_decframe;
#define CHK(x) if (!(x)) { return false; }
@@ -133,7 +139,7 @@ static void upb_set32(void *msg, size_t ofs, uint32_t val) {
static bool upb_append_unknown(upb_decstate *d, upb_decframe *frame,
const char *start) {
- upb_msg_addunknown(frame->msg, start, d->ptr - start);
+ upb_msg_addunknown(frame->msg, start, d->ptr - start, d->arena);
return true;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback