diff --git a/upb/json/parser.c b/upb/json/parser.c index 5fe20efc13..70ebfcf5d7 100644 --- a/upb/json/parser.c +++ b/upb/json/parser.c @@ -487,7 +487,7 @@ static bool base64_push(upb_json_parser *p, upb_selector_t sel, const char *ptr, output[0] = val >> 16; output[1] = (val >> 8) & 0xff; output[2] = val & 0xff; - upb_sink_putstring(&p->top->sink, sel, output, 3, NULL); + upb_sink_putstring(p->top->sink, sel, output, 3, NULL); } return true; @@ -512,7 +512,7 @@ otherchar: UPB_ASSERT(!(val & 0x80000000)); output = val >> 16; - upb_sink_putstring(&p->top->sink, sel, &output, 1, NULL); + upb_sink_putstring(p->top->sink, sel, &output, 1, NULL); return true; } else { uint32_t val; @@ -529,7 +529,7 @@ otherchar: output[0] = val >> 16; output[1] = (val >> 8) & 0xff; - upb_sink_putstring(&p->top->sink, sel, output, 2, NULL); + upb_sink_putstring(p->top->sink, sel, output, 2, NULL); return true; } @@ -695,7 +695,7 @@ static bool multipart_text(upb_json_parser *p, const char *buf, size_t len, case MULTIPART_PUSHEAGERLY: { const upb_bufhandle *handle = can_alias ? p->handle : NULL; - upb_sink_putstring(&p->top->sink, p->string_selector, buf, len, handle); + upb_sink_putstring(p->top->sink, p->string_selector, buf, len, handle); break; } } @@ -941,7 +941,7 @@ static bool parse_number_from_buffer(upb_json_parser *p, const char *buf, } else if (val > INT32_MAX || val < INT32_MIN) { return false; } else { - upb_sink_putint32(&p->top->sink, parser_getsel(p), val); + upb_sink_putint32(p->top->sink, parser_getsel(p), val); return true; } } @@ -952,7 +952,7 @@ static bool parse_number_from_buffer(upb_json_parser *p, const char *buf, } else if (val > UINT32_MAX || errno == ERANGE) { return false; } else { - upb_sink_putuint32(&p->top->sink, parser_getsel(p), val); + upb_sink_putuint32(p->top->sink, parser_getsel(p), val); return true; } } @@ -963,7 +963,7 @@ static bool parse_number_from_buffer(upb_json_parser *p, const char *buf, if (errno == ERANGE || end != bufend) { break; } else { - upb_sink_putint64(&p->top->sink, parser_getsel(p), val); + upb_sink_putint64(p->top->sink, parser_getsel(p), val); return true; } } @@ -974,7 +974,7 @@ static bool parse_number_from_buffer(upb_json_parser *p, const char *buf, } else if (errno == ERANGE) { return false; } else { - upb_sink_putuint64(&p->top->sink, parser_getsel(p), val); + upb_sink_putuint64(p->top->sink, parser_getsel(p), val); return true; } } @@ -1005,7 +1005,7 @@ static bool parse_number_from_buffer(upb_json_parser *p, const char *buf, if (modf(val, &dummy) != 0 || val > max || val < min) { \ return false; \ } else { \ - upb_sink_put ## smalltype(&p->top->sink, parser_getsel(p), \ + upb_sink_put ## smalltype(p->top->sink, parser_getsel(p), \ (ctype)val); \ return true; \ } \ @@ -1019,13 +1019,13 @@ static bool parse_number_from_buffer(upb_json_parser *p, const char *buf, #undef CASE case UPB_TYPE_DOUBLE: - upb_sink_putdouble(&p->top->sink, parser_getsel(p), val); + upb_sink_putdouble(p->top->sink, parser_getsel(p), val); return true; case UPB_TYPE_FLOAT: if ((val > FLT_MAX || val < -FLT_MAX) && val != inf && val != -inf) { return false; } else { - upb_sink_putfloat(&p->top->sink, parser_getsel(p), val); + upb_sink_putfloat(p->top->sink, parser_getsel(p), val); return true; } default: @@ -1069,7 +1069,7 @@ static bool parser_putbool(upb_json_parser *p, bool val) { return false; } - ok = upb_sink_putbool(&p->top->sink, parser_getsel(p), val); + ok = upb_sink_putbool(p->top->sink, parser_getsel(p), val); UPB_ASSERT(ok); return true; @@ -1209,7 +1209,7 @@ static bool start_stringval(upb_json_parser *p) { * handler frames, and string events occur in a sub-frame. */ inner = p->top + 1; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR); - upb_sink_startstr(&p->top->sink, sel, 0, &inner->sink); + upb_sink_startstr(p->top->sink, sel, 0, &inner->sink); inner->m = p->top->m; inner->f = p->top->f; inner->name_table = NULL; @@ -1258,11 +1258,11 @@ static bool end_any_stringval(upb_json_parser *p) { inner = p->top + 1; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR); - upb_sink_startstr(&p->top->sink, sel, 0, &inner->sink); + upb_sink_startstr(p->top->sink, sel, 0, &inner->sink); sel = getsel_for_handlertype(p, UPB_HANDLER_STRING); - upb_sink_putstring(&inner->sink, sel, buf, len, NULL); + upb_sink_putstring(inner->sink, sel, buf, len, NULL); sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); - upb_sink_endstr(&inner->sink, sel); + upb_sink_endstr(inner->sink, sel); multipart_end(p); @@ -1318,7 +1318,7 @@ static bool end_stringval_nontop(upb_json_parser *p) { case UPB_TYPE_STRING: { upb_selector_t sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); p->top--; - upb_sink_endstr(&p->top->sink, sel); + upb_sink_endstr(p->top->sink, sel); break; } @@ -1334,7 +1334,7 @@ static bool end_stringval_nontop(upb_json_parser *p) { if (ok) { upb_selector_t sel = parser_getsel(p); - upb_sink_putint32(&p->top->sink, sel, int_val); + upb_sink_putint32(p->top->sink, sel, int_val); } else { upb_status_seterrf(p->status, "Enum value unknown: '%.*s'", len, buf); } @@ -1472,7 +1472,7 @@ static bool end_duration_base(upb_json_parser *p, const char *ptr) { capture_begin(p, seconds_membername); capture_end(p, seconds_membername + 7); end_membername(p); - upb_sink_putint64(&p->top->sink, parser_getsel(p), seconds); + upb_sink_putint64(p->top->sink, parser_getsel(p), seconds); end_member(p); /* Set nanos */ @@ -1480,7 +1480,7 @@ static bool end_duration_base(upb_json_parser *p, const char *ptr) { capture_begin(p, nanos_membername); capture_end(p, nanos_membername + 5); end_membername(p); - upb_sink_putint32(&p->top->sink, parser_getsel(p), nanos); + upb_sink_putint32(p->top->sink, parser_getsel(p), nanos); end_member(p); /* Continue previous arena */ @@ -1572,7 +1572,7 @@ static bool end_timestamp_fraction(upb_json_parser *p, const char *ptr) { capture_begin(p, nanos_membername); capture_end(p, nanos_membername + 5); end_membername(p); - upb_sink_putint32(&p->top->sink, parser_getsel(p), nanos); + upb_sink_putint32(p->top->sink, parser_getsel(p), nanos); end_member(p); /* Continue previous environment */ @@ -1630,7 +1630,7 @@ static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) { capture_begin(p, seconds_membername); capture_end(p, seconds_membername + 7); end_membername(p); - upb_sink_putint64(&p->top->sink, parser_getsel(p), seconds); + upb_sink_putint64(p->top->sink, parser_getsel(p), seconds); end_member(p); /* Continue previous environment */ @@ -1692,11 +1692,11 @@ static bool parse_mapentry_key(upb_json_parser *p) { case UPB_TYPE_BYTES: { upb_sink subsink; upb_selector_t sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR); - upb_sink_startstr(&p->top->sink, sel, len, &subsink); + upb_sink_startstr(p->top->sink, sel, len, &subsink); sel = getsel_for_handlertype(p, UPB_HANDLER_STRING); - upb_sink_putstring(&subsink, sel, buf, len, NULL); + upb_sink_putstring(subsink, sel, buf, len, NULL); sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); - upb_sink_endstr(&p->top->sink, sel); + upb_sink_endstr(p->top->sink, sel); multipart_end(p); break; } @@ -1734,7 +1734,7 @@ static bool handle_mapentry(upb_json_parser *p) { inner = p->top + 1; p->top->f = mapfield; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG); - upb_sink_startsubmsg(&p->top->sink, sel, &inner->sink); + upb_sink_startsubmsg(p->top->sink, sel, &inner->sink); inner->m = mapentrymsg; inner->name_table = NULL; inner->mapfield = mapfield; @@ -1751,7 +1751,7 @@ static bool handle_mapentry(upb_json_parser *p) { p->top = inner; /* send STARTMSG in submsg frame. */ - upb_sink_startmsg(&p->top->sink); + upb_sink_startmsg(p->top->sink); parse_mapentry_key(p); @@ -1827,14 +1827,14 @@ static void end_member(upb_json_parser *p) { UPB_ASSERT(p->top > p->stack); /* send ENDMSG on submsg. */ - upb_sink_endmsg(&p->top->sink, p->status); + upb_sink_endmsg(p->top->sink, p->status); mapfield = p->top->mapfield; /* send ENDSUBMSG in repeated-field-of-mapentries frame. */ p->top--; ok = upb_handlers_getselector(mapfield, UPB_HANDLER_ENDSUBMSG, &sel); UPB_ASSERT(ok); - upb_sink_endsubmsg(&p->top->sink, sel); + upb_sink_endsubmsg(p->top->sink, sel); } p->top->f = NULL; @@ -1878,7 +1878,7 @@ static bool start_subobject(upb_json_parser *p) { inner = p->top + 1; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSEQ); - upb_sink_startseq(&p->top->sink, sel, &inner->sink); + upb_sink_startseq(p->top->sink, sel, &inner->sink); inner->m = upb_fielddef_msgsubdef(p->top->f); inner->name_table = NULL; inner->mapfield = p->top->f; @@ -1902,7 +1902,7 @@ static bool start_subobject(upb_json_parser *p) { inner = p->top + 1; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG); - upb_sink_startsubmsg(&p->top->sink, sel, &inner->sink); + upb_sink_startsubmsg(p->top->sink, sel, &inner->sink); inner->m = upb_fielddef_msgsubdef(p->top->f); set_name_table(p, inner); inner->f = NULL; @@ -1961,14 +1961,14 @@ static void end_subobject(upb_json_parser *p) { upb_selector_t sel; p->top--; sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSEQ); - upb_sink_endseq(&p->top->sink, sel); + upb_sink_endseq(p->top->sink, sel); } else { upb_selector_t sel; bool is_unknown = p->top->m == NULL; p->top--; if (!is_unknown) { sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSUBMSG); - upb_sink_endsubmsg(&p->top->sink, sel); + upb_sink_endsubmsg(p->top->sink, sel); } } } @@ -2041,7 +2041,7 @@ static bool start_array(upb_json_parser *p) { inner = p->top + 1; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSEQ); - upb_sink_startseq(&p->top->sink, sel, &inner->sink); + upb_sink_startseq(p->top->sink, sel, &inner->sink); inner->m = p->top->m; inner->name_table = NULL; inner->f = p->top->f; @@ -2067,7 +2067,7 @@ static void end_array(upb_json_parser *p) { } sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSEQ); - upb_sink_endseq(&p->top->sink, sel); + upb_sink_endseq(p->top->sink, sel); if (is_wellknown_msg(p, UPB_WELLKNOWN_LISTVALUE)) { end_listvalue_object(p); @@ -2086,13 +2086,13 @@ static void end_array(upb_json_parser *p) { static void start_object(upb_json_parser *p) { if (!p->top->is_map && p->top->m != NULL) { - upb_sink_startmsg(&p->top->sink); + upb_sink_startmsg(p->top->sink); } } static void end_object(upb_json_parser *p) { if (!p->top->is_map && p->top->m != NULL) { - upb_sink_endmsg(&p->top->sink, p->status); + upb_sink_endmsg(p->top->sink, p->status); } } @@ -2198,12 +2198,12 @@ static bool end_any_object(upb_json_parser *p, const char *ptr) { inner = p->top + 1; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR); - upb_sink_startstr(&p->top->sink, sel, 0, &inner->sink); + upb_sink_startstr(p->top->sink, sel, 0, &inner->sink); sel = getsel_for_handlertype(p, UPB_HANDLER_STRING); - upb_sink_putstring(&inner->sink, sel, p->top->any_frame->stringsink.ptr, + upb_sink_putstring(inner->sink, sel, p->top->any_frame->stringsink.ptr, p->top->any_frame->stringsink.len, NULL); sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); - upb_sink_endstr(&inner->sink, sel); + upb_sink_endstr(inner->sink, sel); end_member(p); diff --git a/upb/json/parser.rl b/upb/json/parser.rl index 6f27630754..11a6955288 100644 --- a/upb/json/parser.rl +++ b/upb/json/parser.rl @@ -485,7 +485,7 @@ static bool base64_push(upb_json_parser *p, upb_selector_t sel, const char *ptr, output[0] = val >> 16; output[1] = (val >> 8) & 0xff; output[2] = val & 0xff; - upb_sink_putstring(&p->top->sink, sel, output, 3, NULL); + upb_sink_putstring(p->top->sink, sel, output, 3, NULL); } return true; @@ -510,7 +510,7 @@ otherchar: UPB_ASSERT(!(val & 0x80000000)); output = val >> 16; - upb_sink_putstring(&p->top->sink, sel, &output, 1, NULL); + upb_sink_putstring(p->top->sink, sel, &output, 1, NULL); return true; } else { uint32_t val; @@ -527,7 +527,7 @@ otherchar: output[0] = val >> 16; output[1] = (val >> 8) & 0xff; - upb_sink_putstring(&p->top->sink, sel, output, 2, NULL); + upb_sink_putstring(p->top->sink, sel, output, 2, NULL); return true; } @@ -693,7 +693,7 @@ static bool multipart_text(upb_json_parser *p, const char *buf, size_t len, case MULTIPART_PUSHEAGERLY: { const upb_bufhandle *handle = can_alias ? p->handle : NULL; - upb_sink_putstring(&p->top->sink, p->string_selector, buf, len, handle); + upb_sink_putstring(p->top->sink, p->string_selector, buf, len, handle); break; } } @@ -939,7 +939,7 @@ static bool parse_number_from_buffer(upb_json_parser *p, const char *buf, } else if (val > INT32_MAX || val < INT32_MIN) { return false; } else { - upb_sink_putint32(&p->top->sink, parser_getsel(p), val); + upb_sink_putint32(p->top->sink, parser_getsel(p), val); return true; } } @@ -950,7 +950,7 @@ static bool parse_number_from_buffer(upb_json_parser *p, const char *buf, } else if (val > UINT32_MAX || errno == ERANGE) { return false; } else { - upb_sink_putuint32(&p->top->sink, parser_getsel(p), val); + upb_sink_putuint32(p->top->sink, parser_getsel(p), val); return true; } } @@ -961,7 +961,7 @@ static bool parse_number_from_buffer(upb_json_parser *p, const char *buf, if (errno == ERANGE || end != bufend) { break; } else { - upb_sink_putint64(&p->top->sink, parser_getsel(p), val); + upb_sink_putint64(p->top->sink, parser_getsel(p), val); return true; } } @@ -972,7 +972,7 @@ static bool parse_number_from_buffer(upb_json_parser *p, const char *buf, } else if (errno == ERANGE) { return false; } else { - upb_sink_putuint64(&p->top->sink, parser_getsel(p), val); + upb_sink_putuint64(p->top->sink, parser_getsel(p), val); return true; } } @@ -1003,7 +1003,7 @@ static bool parse_number_from_buffer(upb_json_parser *p, const char *buf, if (modf(val, &dummy) != 0 || val > max || val < min) { \ return false; \ } else { \ - upb_sink_put ## smalltype(&p->top->sink, parser_getsel(p), \ + upb_sink_put ## smalltype(p->top->sink, parser_getsel(p), \ (ctype)val); \ return true; \ } \ @@ -1017,13 +1017,13 @@ static bool parse_number_from_buffer(upb_json_parser *p, const char *buf, #undef CASE case UPB_TYPE_DOUBLE: - upb_sink_putdouble(&p->top->sink, parser_getsel(p), val); + upb_sink_putdouble(p->top->sink, parser_getsel(p), val); return true; case UPB_TYPE_FLOAT: if ((val > FLT_MAX || val < -FLT_MAX) && val != inf && val != -inf) { return false; } else { - upb_sink_putfloat(&p->top->sink, parser_getsel(p), val); + upb_sink_putfloat(p->top->sink, parser_getsel(p), val); return true; } default: @@ -1067,7 +1067,7 @@ static bool parser_putbool(upb_json_parser *p, bool val) { return false; } - ok = upb_sink_putbool(&p->top->sink, parser_getsel(p), val); + ok = upb_sink_putbool(p->top->sink, parser_getsel(p), val); UPB_ASSERT(ok); return true; @@ -1207,7 +1207,7 @@ static bool start_stringval(upb_json_parser *p) { * handler frames, and string events occur in a sub-frame. */ inner = p->top + 1; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR); - upb_sink_startstr(&p->top->sink, sel, 0, &inner->sink); + upb_sink_startstr(p->top->sink, sel, 0, &inner->sink); inner->m = p->top->m; inner->f = p->top->f; inner->name_table = NULL; @@ -1256,11 +1256,11 @@ static bool end_any_stringval(upb_json_parser *p) { inner = p->top + 1; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR); - upb_sink_startstr(&p->top->sink, sel, 0, &inner->sink); + upb_sink_startstr(p->top->sink, sel, 0, &inner->sink); sel = getsel_for_handlertype(p, UPB_HANDLER_STRING); - upb_sink_putstring(&inner->sink, sel, buf, len, NULL); + upb_sink_putstring(inner->sink, sel, buf, len, NULL); sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); - upb_sink_endstr(&inner->sink, sel); + upb_sink_endstr(inner->sink, sel); multipart_end(p); @@ -1316,7 +1316,7 @@ static bool end_stringval_nontop(upb_json_parser *p) { case UPB_TYPE_STRING: { upb_selector_t sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); p->top--; - upb_sink_endstr(&p->top->sink, sel); + upb_sink_endstr(p->top->sink, sel); break; } @@ -1332,7 +1332,7 @@ static bool end_stringval_nontop(upb_json_parser *p) { if (ok) { upb_selector_t sel = parser_getsel(p); - upb_sink_putint32(&p->top->sink, sel, int_val); + upb_sink_putint32(p->top->sink, sel, int_val); } else { upb_status_seterrf(p->status, "Enum value unknown: '%.*s'", len, buf); } @@ -1470,7 +1470,7 @@ static bool end_duration_base(upb_json_parser *p, const char *ptr) { capture_begin(p, seconds_membername); capture_end(p, seconds_membername + 7); end_membername(p); - upb_sink_putint64(&p->top->sink, parser_getsel(p), seconds); + upb_sink_putint64(p->top->sink, parser_getsel(p), seconds); end_member(p); /* Set nanos */ @@ -1478,7 +1478,7 @@ static bool end_duration_base(upb_json_parser *p, const char *ptr) { capture_begin(p, nanos_membername); capture_end(p, nanos_membername + 5); end_membername(p); - upb_sink_putint32(&p->top->sink, parser_getsel(p), nanos); + upb_sink_putint32(p->top->sink, parser_getsel(p), nanos); end_member(p); /* Continue previous arena */ @@ -1570,7 +1570,7 @@ static bool end_timestamp_fraction(upb_json_parser *p, const char *ptr) { capture_begin(p, nanos_membername); capture_end(p, nanos_membername + 5); end_membername(p); - upb_sink_putint32(&p->top->sink, parser_getsel(p), nanos); + upb_sink_putint32(p->top->sink, parser_getsel(p), nanos); end_member(p); /* Continue previous environment */ @@ -1628,7 +1628,7 @@ static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) { capture_begin(p, seconds_membername); capture_end(p, seconds_membername + 7); end_membername(p); - upb_sink_putint64(&p->top->sink, parser_getsel(p), seconds); + upb_sink_putint64(p->top->sink, parser_getsel(p), seconds); end_member(p); /* Continue previous environment */ @@ -1690,11 +1690,11 @@ static bool parse_mapentry_key(upb_json_parser *p) { case UPB_TYPE_BYTES: { upb_sink subsink; upb_selector_t sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR); - upb_sink_startstr(&p->top->sink, sel, len, &subsink); + upb_sink_startstr(p->top->sink, sel, len, &subsink); sel = getsel_for_handlertype(p, UPB_HANDLER_STRING); - upb_sink_putstring(&subsink, sel, buf, len, NULL); + upb_sink_putstring(subsink, sel, buf, len, NULL); sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); - upb_sink_endstr(&p->top->sink, sel); + upb_sink_endstr(p->top->sink, sel); multipart_end(p); break; } @@ -1732,7 +1732,7 @@ static bool handle_mapentry(upb_json_parser *p) { inner = p->top + 1; p->top->f = mapfield; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG); - upb_sink_startsubmsg(&p->top->sink, sel, &inner->sink); + upb_sink_startsubmsg(p->top->sink, sel, &inner->sink); inner->m = mapentrymsg; inner->name_table = NULL; inner->mapfield = mapfield; @@ -1749,7 +1749,7 @@ static bool handle_mapentry(upb_json_parser *p) { p->top = inner; /* send STARTMSG in submsg frame. */ - upb_sink_startmsg(&p->top->sink); + upb_sink_startmsg(p->top->sink); parse_mapentry_key(p); @@ -1825,14 +1825,14 @@ static void end_member(upb_json_parser *p) { UPB_ASSERT(p->top > p->stack); /* send ENDMSG on submsg. */ - upb_sink_endmsg(&p->top->sink, p->status); + upb_sink_endmsg(p->top->sink, p->status); mapfield = p->top->mapfield; /* send ENDSUBMSG in repeated-field-of-mapentries frame. */ p->top--; ok = upb_handlers_getselector(mapfield, UPB_HANDLER_ENDSUBMSG, &sel); UPB_ASSERT(ok); - upb_sink_endsubmsg(&p->top->sink, sel); + upb_sink_endsubmsg(p->top->sink, sel); } p->top->f = NULL; @@ -1876,7 +1876,7 @@ static bool start_subobject(upb_json_parser *p) { inner = p->top + 1; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSEQ); - upb_sink_startseq(&p->top->sink, sel, &inner->sink); + upb_sink_startseq(p->top->sink, sel, &inner->sink); inner->m = upb_fielddef_msgsubdef(p->top->f); inner->name_table = NULL; inner->mapfield = p->top->f; @@ -1900,7 +1900,7 @@ static bool start_subobject(upb_json_parser *p) { inner = p->top + 1; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG); - upb_sink_startsubmsg(&p->top->sink, sel, &inner->sink); + upb_sink_startsubmsg(p->top->sink, sel, &inner->sink); inner->m = upb_fielddef_msgsubdef(p->top->f); set_name_table(p, inner); inner->f = NULL; @@ -1959,14 +1959,14 @@ static void end_subobject(upb_json_parser *p) { upb_selector_t sel; p->top--; sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSEQ); - upb_sink_endseq(&p->top->sink, sel); + upb_sink_endseq(p->top->sink, sel); } else { upb_selector_t sel; bool is_unknown = p->top->m == NULL; p->top--; if (!is_unknown) { sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSUBMSG); - upb_sink_endsubmsg(&p->top->sink, sel); + upb_sink_endsubmsg(p->top->sink, sel); } } } @@ -2039,7 +2039,7 @@ static bool start_array(upb_json_parser *p) { inner = p->top + 1; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSEQ); - upb_sink_startseq(&p->top->sink, sel, &inner->sink); + upb_sink_startseq(p->top->sink, sel, &inner->sink); inner->m = p->top->m; inner->name_table = NULL; inner->f = p->top->f; @@ -2065,7 +2065,7 @@ static void end_array(upb_json_parser *p) { } sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSEQ); - upb_sink_endseq(&p->top->sink, sel); + upb_sink_endseq(p->top->sink, sel); if (is_wellknown_msg(p, UPB_WELLKNOWN_LISTVALUE)) { end_listvalue_object(p); @@ -2084,13 +2084,13 @@ static void end_array(upb_json_parser *p) { static void start_object(upb_json_parser *p) { if (!p->top->is_map && p->top->m != NULL) { - upb_sink_startmsg(&p->top->sink); + upb_sink_startmsg(p->top->sink); } } static void end_object(upb_json_parser *p) { if (!p->top->is_map && p->top->m != NULL) { - upb_sink_endmsg(&p->top->sink, p->status); + upb_sink_endmsg(p->top->sink, p->status); } } @@ -2196,12 +2196,12 @@ static bool end_any_object(upb_json_parser *p, const char *ptr) { inner = p->top + 1; sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR); - upb_sink_startstr(&p->top->sink, sel, 0, &inner->sink); + upb_sink_startstr(p->top->sink, sel, 0, &inner->sink); sel = getsel_for_handlertype(p, UPB_HANDLER_STRING); - upb_sink_putstring(&inner->sink, sel, p->top->any_frame->stringsink.ptr, + upb_sink_putstring(inner->sink, sel, p->top->any_frame->stringsink.ptr, p->top->any_frame->stringsink.len, NULL); sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); - upb_sink_endstr(&inner->sink, sel); + upb_sink_endstr(inner->sink, sel); end_member(p); diff --git a/upb/json/printer.c b/upb/json/printer.c index bc18055cbd..2bc978a4d6 100644 --- a/upb/json/printer.c +++ b/upb/json/printer.c @@ -87,7 +87,7 @@ strpc *newstrpc_str(upb_handlers *h, const char * str) { static void print_data( upb_json_printer *p, const char *buf, unsigned int len) { /* TODO: Will need to change if we support pushback from the sink. */ - size_t n = upb_bytessink_putbuf(&p->output_, p->subc_, buf, len, NULL); + size_t n = upb_bytessink_putbuf(p->output_, p->subc_, buf, len, NULL); UPB_ASSERT(n == len); } @@ -369,7 +369,7 @@ static bool printer_startmsg(void *closure, const void *handler_data) { upb_json_printer *p = closure; UPB_UNUSED(handler_data); if (p->depth_ == 0) { - upb_bytessink_start(&p->output_, 0, &p->subc_); + upb_bytessink_start(p->output_, 0, &p->subc_); } start_frame(p); return true; @@ -381,7 +381,7 @@ static bool printer_endmsg(void *closure, const void *handler_data, upb_status * UPB_UNUSED(s); end_frame(p); if (p->depth_ == 0) { - upb_bytessink_end(&p->output_); + upb_bytessink_end(p->output_); } return true; } @@ -770,7 +770,7 @@ static bool printer_startdurationmsg(void *closure, const void *handler_data) { upb_json_printer *p = closure; UPB_UNUSED(handler_data); if (p->depth_ == 0) { - upb_bytessink_start(&p->output_, 0, &p->subc_); + upb_bytessink_start(p->output_, 0, &p->subc_); } return true; } @@ -828,7 +828,7 @@ static bool printer_enddurationmsg(void *closure, const void *handler_data, print_data(p, "\"", 1); if (p->depth_ == 0) { - upb_bytessink_end(&p->output_); + upb_bytessink_end(p->output_); } UPB_UNUSED(handler_data); @@ -839,7 +839,7 @@ static bool printer_starttimestampmsg(void *closure, const void *handler_data) { upb_json_printer *p = closure; UPB_UNUSED(handler_data); if (p->depth_ == 0) { - upb_bytessink_start(&p->output_, 0, &p->subc_); + upb_bytessink_start(p->output_, 0, &p->subc_); } return true; } @@ -902,7 +902,7 @@ static bool printer_endtimestampmsg(void *closure, const void *handler_data, print_data(p, "\"", 1); if (p->depth_ == 0) { - upb_bytessink_end(&p->output_); + upb_bytessink_end(p->output_); } UPB_UNUSED(handler_data); @@ -914,7 +914,7 @@ static bool printer_startmsg_noframe(void *closure, const void *handler_data) { upb_json_printer *p = closure; UPB_UNUSED(handler_data); if (p->depth_ == 0) { - upb_bytessink_start(&p->output_, 0, &p->subc_); + upb_bytessink_start(p->output_, 0, &p->subc_); } return true; } @@ -925,7 +925,7 @@ static bool printer_endmsg_noframe( UPB_UNUSED(handler_data); UPB_UNUSED(s); if (p->depth_ == 0) { - upb_bytessink_end(&p->output_); + upb_bytessink_end(p->output_); } return true; } diff --git a/upb/pb/decoder.c b/upb/pb/decoder.c index f1617dbe37..23843124ba 100644 --- a/upb/pb/decoder.c +++ b/upb/pb/decoder.c @@ -594,7 +594,7 @@ have_tag: if (d->top->groupnum >= 0) { /* TODO: More code needed for handling unknown groups. */ - upb_sink_putunknown(&d->top->sink, d->checkpoint, d->ptr - d->checkpoint); + upb_sink_putunknown(d->top->sink, d->checkpoint, d->ptr - d->checkpoint); return DECODE_OK; } @@ -688,7 +688,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group, VMCASE(OP_PARSE_ ## type, { \ ctype val; \ CHECK_RETURN(decode_ ## wt(d, &val)); \ - upb_sink_put ## name(&d->top->sink, arg, (convfunc)(val)); \ + upb_sink_put ## name(d->top->sink, arg, (convfunc)(val)); \ }) while(1) { @@ -740,36 +740,36 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group, d->pc += sizeof(void*) / sizeof(uint32_t); ) VMCASE(OP_STARTMSG, - CHECK_SUSPEND(upb_sink_startmsg(&d->top->sink)); + CHECK_SUSPEND(upb_sink_startmsg(d->top->sink)); ) VMCASE(OP_ENDMSG, - CHECK_SUSPEND(upb_sink_endmsg(&d->top->sink, d->status)); + CHECK_SUSPEND(upb_sink_endmsg(d->top->sink, d->status)); ) VMCASE(OP_STARTSEQ, upb_pbdecoder_frame *outer = outer_frame(d); - CHECK_SUSPEND(upb_sink_startseq(&outer->sink, arg, &d->top->sink)); + CHECK_SUSPEND(upb_sink_startseq(outer->sink, arg, &d->top->sink)); ) VMCASE(OP_ENDSEQ, - CHECK_SUSPEND(upb_sink_endseq(&d->top->sink, arg)); + CHECK_SUSPEND(upb_sink_endseq(d->top->sink, arg)); ) VMCASE(OP_STARTSUBMSG, upb_pbdecoder_frame *outer = outer_frame(d); - CHECK_SUSPEND(upb_sink_startsubmsg(&outer->sink, arg, &d->top->sink)); + CHECK_SUSPEND(upb_sink_startsubmsg(outer->sink, arg, &d->top->sink)); ) VMCASE(OP_ENDSUBMSG, - CHECK_SUSPEND(upb_sink_endsubmsg(&d->top->sink, arg)); + CHECK_SUSPEND(upb_sink_endsubmsg(d->top->sink, arg)); ) VMCASE(OP_STARTSTR, uint32_t len = delim_remaining(d); upb_pbdecoder_frame *outer = outer_frame(d); - CHECK_SUSPEND(upb_sink_startstr(&outer->sink, arg, len, &d->top->sink)); + CHECK_SUSPEND(upb_sink_startstr(outer->sink, arg, len, &d->top->sink)); if (len == 0) { d->pc++; /* Skip OP_STRING. */ } ) VMCASE(OP_STRING, uint32_t len = curbufleft(d); - size_t n = upb_sink_putstring(&d->top->sink, arg, d->ptr, len, handle); + size_t n = upb_sink_putstring(d->top->sink, arg, d->ptr, len, handle); if (n > len) { if (n > delim_remaining(d)) { seterr(d, "Tried to skip past end of string."); @@ -790,7 +790,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group, } ) VMCASE(OP_ENDSTR, - CHECK_SUSPEND(upb_sink_endstr(&d->top->sink, arg)); + CHECK_SUSPEND(upb_sink_endstr(d->top->sink, arg)); ) VMCASE(OP_PUSHTAGDELIM, CHECK_SUSPEND(pushtagdelim(d, arg)); diff --git a/upb/pb/encoder.c b/upb/pb/encoder.c index 722cc5bf4b..2da34dbf66 100644 --- a/upb/pb/encoder.c +++ b/upb/pb/encoder.c @@ -127,7 +127,7 @@ struct upb_pb_encoder { /* TODO(haberman): handle pushback */ static void putbuf(upb_pb_encoder *e, const char *buf, size_t len) { - size_t n = upb_bytessink_putbuf(&e->output_, e->subc, buf, len, NULL); + size_t n = upb_bytessink_putbuf(e->output_, e->subc, buf, len, NULL); UPB_ASSERT(n == len); } @@ -353,7 +353,7 @@ static bool startmsg(void *c, const void *hd) { upb_pb_encoder *e = c; UPB_UNUSED(hd); if (e->depth++ == 0) { - upb_bytessink_start(&e->output_, 0, &e->subc); + upb_bytessink_start(e->output_, 0, &e->subc); } return true; } @@ -363,7 +363,7 @@ static bool endmsg(void *c, const void *hd, upb_status *status) { UPB_UNUSED(hd); UPB_UNUSED(status); if (--e->depth == 0) { - upb_bytessink_end(&e->output_); + upb_bytessink_end(e->output_); } return true; } diff --git a/upb/pb/textprinter.c b/upb/pb/textprinter.c index 91d0d55497..934130ede3 100644 --- a/upb/pb/textprinter.c +++ b/upb/pb/textprinter.c @@ -35,13 +35,13 @@ static int indent(upb_textprinter *p) { int i; if (!p->single_line_) for (i = 0; i < p->indent_depth_; i++) - upb_bytessink_putbuf(&p->output_, p->subc, " ", 2, NULL); + upb_bytessink_putbuf(p->output_, p->subc, " ", 2, NULL); return 0; } static int endfield(upb_textprinter *p) { const char ch = (p->single_line_ ? ' ' : '\n'); - upb_bytessink_putbuf(&p->output_, p->subc, &ch, 1, NULL); + upb_bytessink_putbuf(p->output_, p->subc, &ch, 1, NULL); return 0; } @@ -60,7 +60,7 @@ static int putescaped(upb_textprinter *p, const char *buf, size_t len, bool is_hex_escape; if (dstend - dst < 4) { - upb_bytessink_putbuf(&p->output_, p->subc, dstbuf, dst - dstbuf, NULL); + upb_bytessink_putbuf(p->output_, p->subc, dstbuf, dst - dstbuf, NULL); dst = dstbuf; } @@ -88,7 +88,7 @@ static int putescaped(upb_textprinter *p, const char *buf, size_t len, last_hex_escape = is_hex_escape; } /* Flush remaining data. */ - upb_bytessink_putbuf(&p->output_, p->subc, dstbuf, dst - dstbuf, NULL); + upb_bytessink_putbuf(p->output_, p->subc, dstbuf, dst - dstbuf, NULL); return 0; } @@ -114,7 +114,7 @@ bool putf(upb_textprinter *p, const char *fmt, ...) { va_end(args); UPB_ASSERT(written == len); - ok = upb_bytessink_putbuf(&p->output_, p->subc, str, len, NULL); + ok = upb_bytessink_putbuf(p->output_, p->subc, str, len, NULL); upb_gfree(str); return ok; } @@ -126,7 +126,7 @@ static bool textprinter_startmsg(void *c, const void *hd) { upb_textprinter *p = c; UPB_UNUSED(hd); if (p->indent_depth_ == 0) { - upb_bytessink_start(&p->output_, 0, &p->subc); + upb_bytessink_start(p->output_, 0, &p->subc); } return true; } @@ -136,7 +136,7 @@ static bool textprinter_endmsg(void *c, const void *hd, upb_status *s) { UPB_UNUSED(hd); UPB_UNUSED(s); if (p->indent_depth_ == 0) { - upb_bytessink_end(&p->output_); + upb_bytessink_end(p->output_); } return true; } @@ -241,7 +241,7 @@ static bool textprinter_endsubmsg(void *closure, const void *handler_data) { UPB_UNUSED(handler_data); p->indent_depth_--; CHECK(indent(p)); - upb_bytessink_putbuf(&p->output_, p->subc, "}", 1, NULL); + upb_bytessink_putbuf(p->output_, p->subc, "}", 1, NULL); CHECK(endfield(p)); return true; err: diff --git a/upb/sink.c b/upb/sink.c index 7a7eeb41c8..d55d258b23 100644 --- a/upb/sink.c +++ b/upb/sink.c @@ -6,12 +6,12 @@ bool upb_bufsrc_putbuf(const char *buf, size_t len, upb_bytessink sink) { bool ret; upb_bufhandle handle = UPB_BUFHANDLE_INIT; handle.buf = buf; - ret = upb_bytessink_start(&sink, len, &subc); + ret = upb_bytessink_start(sink, len, &subc); if (ret && len != 0) { - ret = (upb_bytessink_putbuf(&sink, subc, buf, len, &handle) >= len); + ret = (upb_bytessink_putbuf(sink, subc, buf, len, &handle) >= len); } if (ret) { - ret = upb_bytessink_end(&sink); + ret = upb_bytessink_end(sink); } return ret; } diff --git a/upb/sink.h b/upb/sink.h index d93d966622..e41feae24e 100644 --- a/upb/sink.h +++ b/upb/sink.h @@ -38,16 +38,16 @@ typedef struct { void *closure; } upb_sink; -#define PUTVAL(type, ctype) \ - UPB_INLINE bool upb_sink_put##type(upb_sink *s, upb_selector_t sel, \ - ctype val) { \ - typedef upb_##type##_handlerfunc functype; \ - functype *func; \ - const void *hd; \ - if (!s->handlers) return true; \ - func = (functype *)upb_handlers_gethandler(s->handlers, sel, &hd); \ - if (!func) return true; \ - return func(s->closure, hd, val); \ +#define PUTVAL(type, ctype) \ + UPB_INLINE bool upb_sink_put##type(upb_sink s, upb_selector_t sel, \ + ctype val) { \ + typedef upb_##type##_handlerfunc functype; \ + functype *func; \ + const void *hd; \ + if (!s.handlers) return true; \ + func = (functype *)upb_handlers_gethandler(s.handlers, sel, &hd); \ + if (!func) return true; \ + return func(s.closure, hd, val); \ } PUTVAL(int32, int32_t) @@ -64,134 +64,134 @@ UPB_INLINE void upb_sink_reset(upb_sink *s, const upb_handlers *h, void *c) { s->closure = c; } -UPB_INLINE size_t upb_sink_putstring(upb_sink *s, upb_selector_t sel, +UPB_INLINE size_t upb_sink_putstring(upb_sink s, upb_selector_t sel, const char *buf, size_t n, const upb_bufhandle *handle) { typedef upb_string_handlerfunc func; func *handler; const void *hd; - if (!s->handlers) return n; - handler = (func *)upb_handlers_gethandler(s->handlers, sel, &hd); + if (!s.handlers) return n; + handler = (func *)upb_handlers_gethandler(s.handlers, sel, &hd); if (!handler) return n; - return handler(s->closure, hd, buf, n, handle); + return handler(s.closure, hd, buf, n, handle); } -UPB_INLINE bool upb_sink_putunknown(upb_sink *s, const char *buf, size_t n) { +UPB_INLINE bool upb_sink_putunknown(upb_sink s, const char *buf, size_t n) { typedef upb_unknown_handlerfunc func; func *handler; const void *hd; - if (!s->handlers) return true; + if (!s.handlers) return true; handler = - (func *)upb_handlers_gethandler(s->handlers, UPB_UNKNOWN_SELECTOR, &hd); + (func *)upb_handlers_gethandler(s.handlers, UPB_UNKNOWN_SELECTOR, &hd); if (!handler) return n; - return handler(s->closure, hd, buf, n); + return handler(s.closure, hd, buf, n); } -UPB_INLINE bool upb_sink_startmsg(upb_sink *s) { +UPB_INLINE bool upb_sink_startmsg(upb_sink s) { typedef upb_startmsg_handlerfunc func; func *startmsg; const void *hd; - if (!s->handlers) return true; + if (!s.handlers) return true; startmsg = - (func *)upb_handlers_gethandler(s->handlers, UPB_STARTMSG_SELECTOR, &hd); + (func *)upb_handlers_gethandler(s.handlers, UPB_STARTMSG_SELECTOR, &hd); if (!startmsg) return true; - return startmsg(s->closure, hd); + return startmsg(s.closure, hd); } -UPB_INLINE bool upb_sink_endmsg(upb_sink *s, upb_status *status) { +UPB_INLINE bool upb_sink_endmsg(upb_sink s, upb_status *status) { typedef upb_endmsg_handlerfunc func; func *endmsg; const void *hd; - if (!s->handlers) return true; + if (!s.handlers) return true; endmsg = - (func *)upb_handlers_gethandler(s->handlers, UPB_ENDMSG_SELECTOR, &hd); + (func *)upb_handlers_gethandler(s.handlers, UPB_ENDMSG_SELECTOR, &hd); if (!endmsg) return true; - return endmsg(s->closure, hd, status); + return endmsg(s.closure, hd, status); } -UPB_INLINE bool upb_sink_startseq(upb_sink *s, upb_selector_t sel, +UPB_INLINE bool upb_sink_startseq(upb_sink s, upb_selector_t sel, upb_sink *sub) { typedef upb_startfield_handlerfunc func; func *startseq; const void *hd; - sub->closure = s->closure; - sub->handlers = s->handlers; - if (!s->handlers) return true; - startseq = (func*)upb_handlers_gethandler(s->handlers, sel, &hd); + sub->closure = s.closure; + sub->handlers = s.handlers; + if (!s.handlers) return true; + startseq = (func*)upb_handlers_gethandler(s.handlers, sel, &hd); if (!startseq) return true; - sub->closure = startseq(s->closure, hd); + sub->closure = startseq(s.closure, hd); return sub->closure ? true : false; } -UPB_INLINE bool upb_sink_endseq(upb_sink *s, upb_selector_t sel) { +UPB_INLINE bool upb_sink_endseq(upb_sink s, upb_selector_t sel) { typedef upb_endfield_handlerfunc func; func *endseq; const void *hd; - if (!s->handlers) return true; - endseq = (func*)upb_handlers_gethandler(s->handlers, sel, &hd); + if (!s.handlers) return true; + endseq = (func*)upb_handlers_gethandler(s.handlers, sel, &hd); if (!endseq) return true; - return endseq(s->closure, hd); + return endseq(s.closure, hd); } -UPB_INLINE bool upb_sink_startstr(upb_sink *s, upb_selector_t sel, +UPB_INLINE bool upb_sink_startstr(upb_sink s, upb_selector_t sel, size_t size_hint, upb_sink *sub) { typedef upb_startstr_handlerfunc func; func *startstr; const void *hd; - sub->closure = s->closure; - sub->handlers = s->handlers; - if (!s->handlers) return true; - startstr = (func*)upb_handlers_gethandler(s->handlers, sel, &hd); + sub->closure = s.closure; + sub->handlers = s.handlers; + if (!s.handlers) return true; + startstr = (func*)upb_handlers_gethandler(s.handlers, sel, &hd); if (!startstr) return true; - sub->closure = startstr(s->closure, hd, size_hint); + sub->closure = startstr(s.closure, hd, size_hint); return sub->closure ? true : false; } -UPB_INLINE bool upb_sink_endstr(upb_sink *s, upb_selector_t sel) { +UPB_INLINE bool upb_sink_endstr(upb_sink s, upb_selector_t sel) { typedef upb_endfield_handlerfunc func; func *endstr; const void *hd; - if (!s->handlers) return true; - endstr = (func*)upb_handlers_gethandler(s->handlers, sel, &hd); + if (!s.handlers) return true; + endstr = (func*)upb_handlers_gethandler(s.handlers, sel, &hd); if (!endstr) return true; - return endstr(s->closure, hd); + return endstr(s.closure, hd); } -UPB_INLINE bool upb_sink_startsubmsg(upb_sink *s, upb_selector_t sel, +UPB_INLINE bool upb_sink_startsubmsg(upb_sink s, upb_selector_t sel, upb_sink *sub) { typedef upb_startfield_handlerfunc func; func *startsubmsg; const void *hd; - sub->closure = s->closure; - if (!s->handlers) { + sub->closure = s.closure; + if (!s.handlers) { sub->handlers = NULL; return true; } - sub->handlers = upb_handlers_getsubhandlers_sel(s->handlers, sel); - startsubmsg = (func*)upb_handlers_gethandler(s->handlers, sel, &hd); + sub->handlers = upb_handlers_getsubhandlers_sel(s.handlers, sel); + startsubmsg = (func*)upb_handlers_gethandler(s.handlers, sel, &hd); if (!startsubmsg) return true; - sub->closure = startsubmsg(s->closure, hd); + sub->closure = startsubmsg(s.closure, hd); return sub->closure ? true : false; } -UPB_INLINE bool upb_sink_endsubmsg(upb_sink *s, upb_selector_t sel) { +UPB_INLINE bool upb_sink_endsubmsg(upb_sink s, upb_selector_t sel) { typedef upb_endfield_handlerfunc func; func *endsubmsg; const void *hd; - if (!s->handlers) return true; - endsubmsg = (func*)upb_handlers_gethandler(s->handlers, sel, &hd); + if (!s.handlers) return true; + endsubmsg = (func*)upb_handlers_gethandler(s.handlers, sel, &hd); - if (!endsubmsg) return s->closure; - return endsubmsg(s->closure, hd); + if (!endsubmsg) return s.closure; + return endsubmsg(s.closure, hd); } #ifdef __cplusplus @@ -288,40 +288,40 @@ class upb::Sink { * // ... * sink->EndMessage(&status); * sink->EndSubMessage(endsubmsg_selector); */ - bool StartMessage() { return upb_sink_startmsg(&sink_); } + bool StartMessage() { return upb_sink_startmsg(sink_); } bool EndMessage(upb_status *status) { - return upb_sink_endmsg(&sink_, status); + return upb_sink_endmsg(sink_, status); } /* Putting of individual values. These work for both repeated and * non-repeated fields, but for repeated fields you must wrap them in * calls to StartSequence()/EndSequence(). */ bool PutInt32(HandlersPtr::Selector s, int32_t val) { - return upb_sink_putint32(&sink_, s, val); + return upb_sink_putint32(sink_, s, val); } bool PutInt64(HandlersPtr::Selector s, int64_t val) { - return upb_sink_putint64(&sink_, s, val); + return upb_sink_putint64(sink_, s, val); } bool PutUInt32(HandlersPtr::Selector s, uint32_t val) { - return upb_sink_putuint32(&sink_, s, val); + return upb_sink_putuint32(sink_, s, val); } bool PutUInt64(HandlersPtr::Selector s, uint64_t val) { - return upb_sink_putuint64(&sink_, s, val); + return upb_sink_putuint64(sink_, s, val); } bool PutFloat(HandlersPtr::Selector s, float val) { - return upb_sink_putfloat(&sink_, s, val); + return upb_sink_putfloat(sink_, s, val); } bool PutDouble(HandlersPtr::Selector s, double val) { - return upb_sink_putdouble(&sink_, s, val); + return upb_sink_putdouble(sink_, s, val); } bool PutBool(HandlersPtr::Selector s, bool val) { - return upb_sink_putbool(&sink_, s, val); + return upb_sink_putbool(sink_, s, val); } /* Putting of string/bytes values. Each string can consist of zero or more @@ -331,18 +331,18 @@ class upb::Sink { * The sub-sink must be used for any/all PutStringBuffer() calls. */ bool StartString(HandlersPtr::Selector s, size_t size_hint, Sink* sub) { upb_sink sub_c; - bool ret = upb_sink_startstr(&sink_, s, size_hint, &sub_c); + bool ret = upb_sink_startstr(sink_, s, size_hint, &sub_c); *sub = sub_c; return ret; } size_t PutStringBuffer(HandlersPtr::Selector s, const char *buf, size_t len, const upb_bufhandle *handle) { - return upb_sink_putstring(&sink_, s, buf, len, handle); + return upb_sink_putstring(sink_, s, buf, len, handle); } bool EndString(HandlersPtr::Selector s) { - return upb_sink_endstr(&sink_, s); + return upb_sink_endstr(sink_, s); } /* For submessage fields. @@ -352,13 +352,13 @@ class upb::Sink { * submessage. */ bool StartSubMessage(HandlersPtr::Selector s, Sink* sub) { upb_sink sub_c; - bool ret = upb_sink_startsubmsg(&sink_, s, &sub_c); + bool ret = upb_sink_startsubmsg(sink_, s, &sub_c); *sub = sub_c; return ret; } bool EndSubMessage(HandlersPtr::Selector s) { - return upb_sink_endsubmsg(&sink_, s); + return upb_sink_endsubmsg(sink_, s); } /* For repeated fields of any type, the sequence of values must be wrapped in @@ -369,13 +369,13 @@ class upb::Sink { * sequence. */ bool StartSequence(HandlersPtr::Selector s, Sink* sub) { upb_sink sub_c; - bool ret = upb_sink_startseq(&sink_, s, &sub_c); + bool ret = upb_sink_startseq(sink_, s, &sub_c); *sub = sub_c; return ret; } bool EndSequence(HandlersPtr::Selector s) { - return upb_sink_endseq(&sink_, s); + return upb_sink_endseq(sink_, s); } /* Copy and assign specifically allowed. @@ -396,49 +396,49 @@ typedef struct { void *closure; } upb_bytessink ; -UPB_INLINE void upb_bytessink_reset(upb_bytessink *s, const upb_byteshandler *h, +UPB_INLINE void upb_bytessink_reset(upb_bytessink* s, const upb_byteshandler *h, void *closure) { s->handler = h; s->closure = closure; } -UPB_INLINE bool upb_bytessink_start(upb_bytessink *s, size_t size_hint, +UPB_INLINE bool upb_bytessink_start(upb_bytessink s, size_t size_hint, void **subc) { typedef upb_startstr_handlerfunc func; func *start; - *subc = s->closure; - if (!s->handler) return true; - start = (func *)s->handler->table[UPB_STARTSTR_SELECTOR].func; + *subc = s.closure; + if (!s.handler) return true; + start = (func *)s.handler->table[UPB_STARTSTR_SELECTOR].func; if (!start) return true; - *subc = start(s->closure, - s->handler->table[UPB_STARTSTR_SELECTOR].attr.handler_data, + *subc = start(s.closure, + s.handler->table[UPB_STARTSTR_SELECTOR].attr.handler_data, size_hint); return *subc != NULL; } -UPB_INLINE size_t upb_bytessink_putbuf(upb_bytessink *s, void *subc, +UPB_INLINE size_t upb_bytessink_putbuf(upb_bytessink s, void *subc, const char *buf, size_t size, const upb_bufhandle* handle) { typedef upb_string_handlerfunc func; func *putbuf; - if (!s->handler) return true; - putbuf = (func *)s->handler->table[UPB_STRING_SELECTOR].func; + if (!s.handler) return true; + putbuf = (func *)s.handler->table[UPB_STRING_SELECTOR].func; if (!putbuf) return true; - return putbuf(subc, s->handler->table[UPB_STRING_SELECTOR].attr.handler_data, + return putbuf(subc, s.handler->table[UPB_STRING_SELECTOR].attr.handler_data, buf, size, handle); } -UPB_INLINE bool upb_bytessink_end(upb_bytessink *s) { +UPB_INLINE bool upb_bytessink_end(upb_bytessink s) { typedef upb_endfield_handlerfunc func; func *end; - if (!s->handler) return true; - end = (func *)s->handler->table[UPB_ENDSTR_SELECTOR].func; + if (!s.handler) return true; + end = (func *)s.handler->table[UPB_ENDSTR_SELECTOR].func; if (!end) return true; - return end(s->closure, - s->handler->table[UPB_ENDSTR_SELECTOR].attr.handler_data); + return end(s.closure, + s.handler->table[UPB_ENDSTR_SELECTOR].attr.handler_data); } #ifdef __cplusplus @@ -463,7 +463,7 @@ class upb::BytesSink { * TODO(haberman): once the Handlers know the expected closure type, verify * that T matches it. */ template BytesSink(const upb_byteshandler* handler, T* closure) { - upb_bytessink_reset(&sink_, handler, closure); + upb_bytessink_reset(sink_, handler, closure); } /* Resets the value of the sink. */ @@ -472,16 +472,16 @@ class upb::BytesSink { } bool Start(size_t size_hint, void **subc) { - return upb_bytessink_start(&sink_, size_hint, subc); + return upb_bytessink_start(sink_, size_hint, subc); } size_t PutBuffer(void *subc, const char *buf, size_t len, const upb_bufhandle *handle) { - return upb_bytessink_putbuf(&sink_, subc, buf, len, handle); + return upb_bytessink_putbuf(sink_, subc, buf, len, handle); } bool End() { - return upb_bytessink_end(&sink_); + return upb_bytessink_end(sink_); } private: