diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-08-07 20:47:26 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-08-07 20:47:26 -0700 |
commit | 8fa6a92f534cb01b6f5b4f48e3982f686d6c3123 (patch) | |
tree | 8026d8bd1bdf22c764623195a1cbd2829a0feeaa /src/upb_parse.c | |
parent | 952ea88db21635f804ba67428ba504d497690d9b (diff) |
Major refactoring of upb_msg. Temporary functionality regression.
There is significant refactoring here, as well as some more trivial
name changes. upb_msg has become upb_msgdef, to reflect the fact
that a upb_msg is not *itself* a message, it describes a message.
There are other renamings, such as upb_parse_state -> upb_stream_parser.
More significantly, the upb_msg class and parser have been refactored
to reflect my recent realization about how memory management should
work. upb_msg now has no memory management, and a memory mangement
scheme (that works beautifully with multiple language runtimes) will
be layered on top of it.
This iteration has the new, read-only upb_msg. upb_mm_msg (a
memory-managed message class) will come in the next change.
Diffstat (limited to 'src/upb_parse.c')
-rw-r--r-- | src/upb_parse.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/upb_parse.c b/src/upb_parse.c index fd76051..b7f3832 100644 --- a/src/upb_parse.c +++ b/src/upb_parse.c @@ -100,7 +100,7 @@ upb_status_t upb_parse_value(uint8_t *buf, uint8_t *end, upb_field_type_t ft, #undef CASE } -void upb_parse_reset(struct upb_parse_state *state, void *udata) +void upb_stream_parser_reset(struct upb_stream_parser *state, void *udata) { state->top = state->stack; state->limit = &state->stack[UPB_MAX_NESTING]; @@ -111,18 +111,7 @@ void upb_parse_reset(struct upb_parse_state *state, void *udata) state->udata = udata; } -void upb_parse_init(struct upb_parse_state *state, void *udata) -{ - memset(state, 0, sizeof(struct upb_parse_state)); /* Clear all callbacks. */ - upb_parse_reset(state, udata); -} - -void upb_parse_free(struct upb_parse_state *state) -{ - (void)state; -} - -static void *pop_stack_frame(struct upb_parse_state *s, uint8_t *buf) +static void *pop_stack_frame(struct upb_stream_parser *s, uint8_t *buf) { if(s->submsg_end_cb) s->submsg_end_cb(s->udata); s->top--; @@ -130,7 +119,7 @@ static void *pop_stack_frame(struct upb_parse_state *s, uint8_t *buf) } /* Returns the next end offset. */ -static upb_status_t push_stack_frame(struct upb_parse_state *s, +static upb_status_t push_stack_frame(struct upb_stream_parser *s, uint8_t *buf, uint32_t len, void *user_field_desc, uint8_t **submsg_end) { @@ -142,8 +131,8 @@ static upb_status_t push_stack_frame(struct upb_parse_state *s, return UPB_STATUS_OK; } -upb_status_t upb_parse(struct upb_parse_state *s, void *_buf, size_t len, - size_t *read) +upb_status_t upb_stream_parser_parse(struct upb_stream_parser *s, + void *_buf, size_t len, size_t *read) { uint8_t *buf = _buf; uint8_t *completed = buf; |