summaryrefslogtreecommitdiff
path: root/src/upb_decoder.c
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2010-05-24 11:15:08 -0700
committerJoshua Haberman <joshua@reverberate.org>2010-05-24 11:15:08 -0700
commit8c1e7170b74e1a6a29736f63507f83ddeb51f560 (patch)
tree728fae12fe9edab603b82c6fdc7fb0d5d4d81239 /src/upb_decoder.c
parentc615d11ce7dd2b7646af4918ffcd70329b99393b (diff)
Defined the upb_src and upb_bytesrc interfaces.
Diffstat (limited to 'src/upb_decoder.c')
-rw-r--r--src/upb_decoder.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/upb_decoder.c b/src/upb_decoder.c
index 209db56..32b8f16 100644
--- a/src/upb_decoder.c
+++ b/src/upb_decoder.c
@@ -195,18 +195,6 @@ T(FLOAT, f, uint32_t, float, _float) {
#undef GET
#undef T
-// Parses a tag, places the result in *tag.
-INLINE const uint8_t *decode_tag(const uint8_t *buf, const uint8_t *end,
- upb_tag *tag, upb_status *status)
-{
- uint32_t tag_int;
- const uint8_t *ret = upb_get_v_uint32_t(buf, end, &tag_int, status);
- tag->wire_type = (upb_wire_type_t)(tag_int & 0x07);
- tag->field_number = tag_int >> 3;
- return ret;
-}
-
-
// Parses a 64-bit varint that is known to be >= 2 bytes (the inline version
// handles 1 and 2 byte varints).
const uint8_t *upb_get_v_uint64_t_full(const uint8_t *buf, const uint8_t *end,
@@ -311,13 +299,12 @@ typedef struct {
struct upb_decoder {
// Immutable state of the decoder.
upb_msgdef *toplevel_msgdef;
- upb_sink *sink;
+ upb_bytesrc *bytesrc;
// State pertaining to a particular decode (resettable).
// Stack entries store the offset where the submsg ends (for groups, 0).
upb_decoder_frame stack[UPB_MAX_NESTING], *top, *limit;
size_t completed_offset;
- void *udata;
};
upb_decoder *upb_decoder_new(upb_msgdef *msgdef)
@@ -344,6 +331,18 @@ void upb_decoder_reset(upb_decoder *d, upb_sink *sink)
d->top->end_offset = 0;
}
+// Parses a tag, places the result in *tag.
+upb_key upb_decoder_src_getkey(upb_decoder *d)
+{
+ upb_key key;
+ upb_fill_buffer(d);
+ d->
+ const uint8_t *ret = upb_get_v_uint32_t(buf, end, &tag_int, status);
+ return ret;
+}
+
+
+
static const void *get_msgend(upb_decoder *d, const uint8_t *start)
{
if(d->top->end_offset > 0)
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback