summaryrefslogtreecommitdiff
path: root/src/upb_parse.h
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-08-07 20:47:26 -0700
committerJoshua Haberman <joshua@reverberate.org>2009-08-07 20:47:26 -0700
commit8fa6a92f534cb01b6f5b4f48e3982f686d6c3123 (patch)
tree8026d8bd1bdf22c764623195a1cbd2829a0feeaa /src/upb_parse.h
parent952ea88db21635f804ba67428ba504d497690d9b (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.h')
-rw-r--r--src/upb_parse.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/upb_parse.h b/src/upb_parse.h
index f0ec5e2..de4cb2c 100644
--- a/src/upb_parse.h
+++ b/src/upb_parse.h
@@ -42,14 +42,11 @@ INLINE bool upb_isstringtype(upb_field_type_t type) {
* as data becomes available. The parser is fully streaming-capable, so the
* data need not all be available at the same time. */
-struct upb_parse_state;
+struct upb_stream_parser;
-/* Initialize and free (respectively) the given parse state, which must have
- * been previously allocated. udata_size specifies how much space will be
- * available at parse_stack_frame.user_data in each frame for user data. */
-void upb_parse_init(struct upb_parse_state *state, void *udata);
-void upb_parse_reset(struct upb_parse_state *state, void *udata);
-void upb_parse_free(struct upb_parse_state *state);
+/* Resets the internal state of an already-allocated parser. udata will be
+ * passed to callbacks as appropriate. */
+void upb_stream_parser_reset(struct upb_stream_parser *p, void *udata);
/* The callback that is called immediately after a tag has been parsed. The
* client should determine whether it wants to parse or skip the corresponding
@@ -86,7 +83,7 @@ typedef void (*upb_submsg_start_cb)(void *udata,
void *user_field_desc);
typedef void (*upb_submsg_end_cb)(void *udata);
-struct upb_parse_state {
+struct upb_stream_parser {
/* For delimited submsgs, counts from the submsg len down to zero.
* For group submsgs, counts from zero down to the negative len. */
uint32_t stack[UPB_MAX_NESTING], *top, *limit;
@@ -115,8 +112,8 @@ struct upb_parse_state {
*
* TODO: see if we can provide the following guarantee efficiently:
* *read will always be >= len. */
-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 *p,
+ void *buf, size_t len, size_t *read);
extern upb_wire_type_t upb_expected_wire_types[];
/* Returns true if wt is the correct on-the-wire type for ft. */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback