From 527c0945000315ed8589436d2807bd5f8ad7a543 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Fri, 8 Jan 2010 18:42:24 -0800 Subject: Reduced the complexity of the cbparser interface. --- src/upb_data.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/upb_data.c') diff --git a/src/upb_data.c b/src/upb_data.c index a0a588a..3dc39f5 100644 --- a/src/upb_data.c +++ b/src/upb_data.c @@ -324,10 +324,8 @@ static union upb_value_ptr get_value_ptr(upb_msg *msg, struct upb_fielddef *f) // Callbacks for the stream parser. // TODO: implement these in terms of public interfaces. -static bool value_cb(void *udata, struct upb_msgdef *msgdef, - struct upb_fielddef *f, union upb_value val) +static bool value_cb(void *udata, struct upb_fielddef *f, union upb_value val) { - (void)msgdef; struct upb_msgparser *mp = udata; upb_msg *msg = mp->top->msg; union upb_value_ptr p = get_value_ptr(msg, f); @@ -336,22 +334,20 @@ static bool value_cb(void *udata, struct upb_msgdef *msgdef, return true; } -static bool str_cb(void *udata, struct upb_msgdef *msgdef, - struct upb_fielddef *f, const uint8_t *str, size_t avail_len, - size_t total_len) +static bool str_cb(void *udata, struct upb_fielddef *f, upb_strptr str, + int32_t start, uint32_t end) { - (void)msgdef; struct upb_msgparser *mp = udata; upb_msg *msg = mp->top->msg; union upb_value_ptr p = get_value_ptr(msg, f); upb_msg_sethas(msg, f); - if(avail_len != total_len) abort(); /* TODO: support streaming. */ + if(end > upb_strlen(str)) abort(); /* TODO: support streaming. */ if(upb_string_isnull(*p.str) || !upb_data_only(*p.data)) { if(!upb_string_isnull(*p.str)) upb_string_unref(*p.str); *p.str = upb_string_new(); } - upb_strcpylen(*p.str, str, avail_len); + upb_strcpylen(*p.str, upb_string_getrobuf(str) + start, end - start); return true; } -- cgit v1.2.3