From 8cd3b9dfa99764685727e065e43fb405ca5aa29f Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Thu, 17 Jan 2019 12:38:04 -0800 Subject: Moved some definitions to def.h --- upb/bindings/lua/def.c | 4 - upb/def.h | 31 +++++ upb/json/parser.c | 361 +++++++++---------------------------------------- upb/json/parser.rl | 20 +-- upb/json/printer.c | 5 +- upb/upb.h | 39 ------ 6 files changed, 106 insertions(+), 354 deletions(-) (limited to 'upb') diff --git a/upb/bindings/lua/def.c b/upb/bindings/lua/def.c index e16d426..3868179 100644 --- a/upb/bindings/lua/def.c +++ b/upb/bindings/lua/def.c @@ -728,10 +728,6 @@ void lupb_def_registertypes(lua_State *L) { lupb_setfieldi(L, "TYPE_UINT32", UPB_TYPE_UINT32); lupb_setfieldi(L, "TYPE_ENUM", UPB_TYPE_ENUM); - lupb_setfieldi(L, "INTFMT_VARIABLE", UPB_INTFMT_VARIABLE); - lupb_setfieldi(L, "INTFMT_FIXED", UPB_INTFMT_FIXED); - lupb_setfieldi(L, "INTFMT_ZIGZAG", UPB_INTFMT_ZIGZAG); - lupb_setfieldi(L, "DESCRIPTOR_TYPE_DOUBLE", UPB_DESCRIPTOR_TYPE_DOUBLE); lupb_setfieldi(L, "DESCRIPTOR_TYPE_FLOAT", UPB_DESCRIPTOR_TYPE_FLOAT); lupb_setfieldi(L, "DESCRIPTOR_TYPE_INT64", UPB_DESCRIPTOR_TYPE_INT64); diff --git a/upb/def.h b/upb/def.h index 7675138..2c336c5 100644 --- a/upb/def.h +++ b/upb/def.h @@ -50,6 +50,37 @@ typedef struct upb_oneofdef upb_oneofdef; struct upb_symtab; typedef struct upb_symtab upb_symtab; +typedef enum { + UPB_SYNTAX_PROTO2 = 2, + UPB_SYNTAX_PROTO3 = 3 +} upb_syntax_t; + +/* All the different kind of well known type messages. For simplicity of check, + * number wrappers and string wrappers are grouped together. Make sure the + * order and merber of these groups are not changed. + */ +typedef enum { + UPB_WELLKNOWN_UNSPECIFIED, + UPB_WELLKNOWN_ANY, + UPB_WELLKNOWN_FIELDMASK, + UPB_WELLKNOWN_DURATION, + UPB_WELLKNOWN_TIMESTAMP, + /* number wrappers */ + UPB_WELLKNOWN_DOUBLEVALUE, + UPB_WELLKNOWN_FLOATVALUE, + UPB_WELLKNOWN_INT64VALUE, + UPB_WELLKNOWN_UINT64VALUE, + UPB_WELLKNOWN_INT32VALUE, + UPB_WELLKNOWN_UINT32VALUE, + /* string wrappers */ + UPB_WELLKNOWN_STRINGVALUE, + UPB_WELLKNOWN_BYTESVALUE, + UPB_WELLKNOWN_BOOLVALUE, + UPB_WELLKNOWN_VALUE, + UPB_WELLKNOWN_LISTVALUE, + UPB_WELLKNOWN_STRUCT +} upb_wellknowntype_t; + /* upb_fielddef ***************************************************************/ /* Maximum field number allowed for FieldDefs. This is an inherent limit of the diff --git a/upb/json/parser.c b/upb/json/parser.c index 38a0535..0b9eb92 100644 --- a/upb/json/parser.c +++ b/upb/json/parser.c @@ -21,6 +21,7 @@ ** - handling of keys/escape-sequences/etc that span input buffers. */ +#include #include #include #include @@ -63,7 +64,6 @@ static bool is_string_wrapper_object(upb_json_parser *p); static bool does_string_wrapper_start(upb_json_parser *p); static bool does_string_wrapper_end(upb_json_parser *p); -static bool is_fieldmask_object(upb_json_parser *p); static bool does_fieldmask_start(upb_json_parser *p); static bool does_fieldmask_end(upb_json_parser *p); static void start_fieldmask_object(upb_json_parser *p); @@ -1332,13 +1332,8 @@ static bool end_stringval_nontop(upb_json_parser *p) { case UPB_TYPE_STRING: { upb_selector_t sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); -<<<<<<< HEAD - p->top--; upb_sink_endstr(p->top->sink, sel); -======= - upb_sink_endstr(&p->top->sink, sel); p->top--; ->>>>>>> arrayapi break; } @@ -1675,9 +1670,7 @@ static void start_fieldmask_path_text(upb_json_parser *p, const char *ptr) { } static bool end_fieldmask_path_text(upb_json_parser *p, const char *ptr) { - if (!capture_end(p, ptr)) { - return false; - } + return capture_end(p, ptr); } static bool start_fieldmask_path(upb_json_parser *p) { @@ -1690,7 +1683,7 @@ static bool start_fieldmask_path(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; @@ -1712,10 +1705,10 @@ static bool lower_camel_push( for (;ptr < limit; ptr++) { if (*ptr >= 'A' && *ptr <= 'Z' && !first) { char lower = tolower(*ptr); - upb_sink_putstring(&p->top->sink, sel, "_", 1, NULL); - upb_sink_putstring(&p->top->sink, sel, &lower, 1, NULL); + upb_sink_putstring(p->top->sink, sel, "_", 1, NULL); + upb_sink_putstring(p->top->sink, sel, &lower, 1, NULL); } else { - upb_sink_putstring(&p->top->sink, sel, ptr, 1, NULL); + upb_sink_putstring(p->top->sink, sel, ptr, 1, NULL); } first = false; } @@ -1732,7 +1725,7 @@ static bool end_fieldmask_path(upb_json_parser *p) { } sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); - upb_sink_endstr(&p->top->sink, sel); + upb_sink_endstr(p->top->sink, sel); p->top--; multipart_end(p); @@ -1796,11 +1789,7 @@ static bool parse_mapentry_key(upb_json_parser *p) { sel = getsel_for_handlertype(p, UPB_HANDLER_STRING); upb_sink_putstring(subsink, sel, buf, len, NULL); sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); -<<<<<<< HEAD - upb_sink_endstr(p->top->sink, sel); -======= - upb_sink_endstr(&subsink, sel); ->>>>>>> arrayapi + upb_sink_endstr(subsink, sel); multipart_end(p); break; } @@ -2498,10 +2487,6 @@ static bool does_fieldmask_end(upb_json_parser *p) { return p->top->m != NULL && is_fieldmask(p->top->m); } -static bool is_fieldmask_object(upb_json_parser *p) { - return p->top->m != NULL && is_fieldmask(p->top->m); -} - #define CHECK_RETURN_TOP(x) if (!(x)) goto error @@ -2523,19 +2508,11 @@ static bool is_fieldmask_object(upb_json_parser *p) { * final state once, when the closing '"' is seen. */ -<<<<<<< HEAD -#line 2542 "upb/json/parser.rl" +#line 2690 "upb/json/parser.rl" -#line 2388 "upb/json/parser.c" -======= -#line 2730 "upb/json/parser.rl" - - - -#line 2556 "upb/json/parser.c" ->>>>>>> arrayapi +#line 2516 "upb/json/parser.c" static const char _json_actions[] = { 0, 1, 0, 1, 1, 1, 3, 1, 4, 1, 6, 1, 7, 1, 8, 1, @@ -2787,11 +2764,7 @@ static const int json_en_value_machine = 78; static const int json_en_main = 1; -<<<<<<< HEAD -#line 2545 "upb/json/parser.rl" -======= -#line 2733 "upb/json/parser.rl" ->>>>>>> arrayapi +#line 2693 "upb/json/parser.rl" size_t parse(void *closure, const void *hd, const char *buf, size_t size, const upb_bufhandle *handle) { @@ -2814,11 +2787,7 @@ size_t parse(void *closure, const void *hd, const char *buf, size_t size, capture_resume(parser, buf); -<<<<<<< HEAD -#line 2658 "upb/json/parser.c" -======= -#line 2831 "upb/json/parser.c" ->>>>>>> arrayapi +#line 2791 "upb/json/parser.c" { int _klen; unsigned int _trans; @@ -2893,183 +2862,103 @@ _match: switch ( *_acts++ ) { case 1: -<<<<<<< HEAD -#line 2393 "upb/json/parser.rl" +#line 2521 "upb/json/parser.rl" { p--; {cs = stack[--top]; goto _again;} } break; case 2: -#line 2395 "upb/json/parser.rl" +#line 2523 "upb/json/parser.rl" { p--; {stack[top++] = cs; cs = 23;goto _again;} } break; case 3: -#line 2399 "upb/json/parser.rl" +#line 2527 "upb/json/parser.rl" { start_text(parser, p); } break; case 4: -#line 2400 "upb/json/parser.rl" +#line 2528 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_text(parser, p)); } break; case 5: -#line 2406 "upb/json/parser.rl" +#line 2534 "upb/json/parser.rl" { start_hex(parser); } break; case 6: -#line 2407 "upb/json/parser.rl" +#line 2535 "upb/json/parser.rl" { hexdigit(parser, p); } break; case 7: -#line 2408 "upb/json/parser.rl" +#line 2536 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_hex(parser)); } break; case 8: -#line 2414 "upb/json/parser.rl" +#line 2542 "upb/json/parser.rl" { CHECK_RETURN_TOP(escape(parser, p)); } break; case 9: -#line 2420 "upb/json/parser.rl" +#line 2548 "upb/json/parser.rl" { p--; {cs = stack[--top]; goto _again;} } break; case 10: -#line 2432 "upb/json/parser.rl" +#line 2560 "upb/json/parser.rl" { start_duration_base(parser, p); } break; case 11: -#line 2433 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_duration_base(parser, p)); } - break; - case 12: -#line 2435 "upb/json/parser.rl" - { p--; {cs = stack[--top]; goto _again;} } - break; - case 13: -#line 2440 "upb/json/parser.rl" - { start_timestamp_base(parser, p); } - break; - case 14: -#line 2441 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_timestamp_base(parser, p)); } - break; - case 15: -#line 2443 "upb/json/parser.rl" - { start_timestamp_fraction(parser, p); } - break; - case 16: -#line 2444 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_timestamp_fraction(parser, p)); } - break; - case 17: -#line 2446 "upb/json/parser.rl" - { start_timestamp_zone(parser, p); } - break; - case 18: -#line 2447 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_timestamp_zone(parser, p)); } - break; - case 19: -#line 2449 "upb/json/parser.rl" - { p--; {cs = stack[--top]; goto _again;} } - break; - case 20: -#line 2454 "upb/json/parser.rl" -======= #line 2561 "upb/json/parser.rl" - { p--; {cs = stack[--top]; goto _again;} } - break; - case 2: -#line 2563 "upb/json/parser.rl" - { p--; {stack[top++] = cs; cs = 23;goto _again;} } - break; - case 3: -#line 2567 "upb/json/parser.rl" - { start_text(parser, p); } - break; - case 4: -#line 2568 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_text(parser, p)); } - break; - case 5: -#line 2574 "upb/json/parser.rl" - { start_hex(parser); } - break; - case 6: -#line 2575 "upb/json/parser.rl" - { hexdigit(parser, p); } - break; - case 7: -#line 2576 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_hex(parser)); } - break; - case 8: -#line 2582 "upb/json/parser.rl" - { CHECK_RETURN_TOP(escape(parser, p)); } - break; - case 9: -#line 2588 "upb/json/parser.rl" - { p--; {cs = stack[--top]; goto _again;} } - break; - case 10: -#line 2600 "upb/json/parser.rl" - { start_duration_base(parser, p); } - break; - case 11: -#line 2601 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_duration_base(parser, p)); } break; case 12: -#line 2603 "upb/json/parser.rl" +#line 2563 "upb/json/parser.rl" { p--; {cs = stack[--top]; goto _again;} } break; case 13: -#line 2608 "upb/json/parser.rl" +#line 2568 "upb/json/parser.rl" { start_timestamp_base(parser, p); } break; case 14: -#line 2609 "upb/json/parser.rl" +#line 2569 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_timestamp_base(parser, p)); } break; case 15: -#line 2611 "upb/json/parser.rl" +#line 2571 "upb/json/parser.rl" { start_timestamp_fraction(parser, p); } break; case 16: -#line 2612 "upb/json/parser.rl" +#line 2572 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_timestamp_fraction(parser, p)); } break; case 17: -#line 2614 "upb/json/parser.rl" +#line 2574 "upb/json/parser.rl" { start_timestamp_zone(parser, p); } break; case 18: -#line 2615 "upb/json/parser.rl" +#line 2575 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_timestamp_zone(parser, p)); } break; case 19: -#line 2617 "upb/json/parser.rl" +#line 2577 "upb/json/parser.rl" { p--; {cs = stack[--top]; goto _again;} } break; case 20: -#line 2622 "upb/json/parser.rl" +#line 2582 "upb/json/parser.rl" { start_fieldmask_path_text(parser, p); } break; case 21: -#line 2623 "upb/json/parser.rl" +#line 2583 "upb/json/parser.rl" { end_fieldmask_path_text(parser, p); } break; case 22: -#line 2628 "upb/json/parser.rl" +#line 2588 "upb/json/parser.rl" { start_fieldmask_path(parser); } break; case 23: -#line 2629 "upb/json/parser.rl" +#line 2589 "upb/json/parser.rl" { end_fieldmask_path(parser); } break; case 24: -#line 2635 "upb/json/parser.rl" +#line 2595 "upb/json/parser.rl" { p--; {cs = stack[--top]; goto _again;} } break; case 25: -#line 2640 "upb/json/parser.rl" ->>>>>>> arrayapi +#line 2600 "upb/json/parser.rl" { if (is_wellknown_msg(parser, UPB_WELLKNOWN_TIMESTAMP)) { {stack[top++] = cs; cs = 47;goto _again;} @@ -3082,21 +2971,12 @@ _match: } } break; -<<<<<<< HEAD - case 21: -#line 2465 "upb/json/parser.rl" - { p--; {stack[top++] = cs; cs = 75;goto _again;} } - break; - case 22: -#line 2470 "upb/json/parser.rl" -======= case 26: -#line 2653 "upb/json/parser.rl" +#line 2613 "upb/json/parser.rl" { p--; {stack[top++] = cs; cs = 78;goto _again;} } break; case 27: -#line 2658 "upb/json/parser.rl" ->>>>>>> arrayapi +#line 2618 "upb/json/parser.rl" { if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) { start_any_member(parser, p); @@ -3105,21 +2985,12 @@ _match: } } break; -<<<<<<< HEAD - case 23: -#line 2477 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_membername(parser)); } - break; - case 24: -#line 2480 "upb/json/parser.rl" -======= case 28: -#line 2665 "upb/json/parser.rl" +#line 2625 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_membername(parser)); } break; case 29: -#line 2668 "upb/json/parser.rl" ->>>>>>> arrayapi +#line 2628 "upb/json/parser.rl" { if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) { end_any_member(parser, p); @@ -3128,13 +2999,8 @@ _match: } } break; -<<<<<<< HEAD - case 25: -#line 2491 "upb/json/parser.rl" -======= case 30: -#line 2679 "upb/json/parser.rl" ->>>>>>> arrayapi +#line 2639 "upb/json/parser.rl" { if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) { start_any_object(parser, p); @@ -3143,13 +3009,8 @@ _match: } } break; -<<<<<<< HEAD - case 26: -#line 2500 "upb/json/parser.rl" -======= case 31: -#line 2688 "upb/json/parser.rl" ->>>>>>> arrayapi +#line 2648 "upb/json/parser.rl" { if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) { CHECK_RETURN_TOP(end_any_object(parser, p)); @@ -3158,107 +3019,55 @@ _match: } } break; -<<<<<<< HEAD - case 27: -#line 2512 "upb/json/parser.rl" - { CHECK_RETURN_TOP(start_array(parser)); } - break; - case 28: -#line 2516 "upb/json/parser.rl" - { end_array(parser); } - break; - case 29: -#line 2521 "upb/json/parser.rl" - { CHECK_RETURN_TOP(start_number(parser, p)); } - break; - case 30: -#line 2522 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_number(parser, p)); } - break; - case 31: -#line 2524 "upb/json/parser.rl" - { CHECK_RETURN_TOP(start_stringval(parser)); } - break; - case 32: -#line 2525 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_stringval(parser)); } - break; - case 33: -#line 2527 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_bool(parser, true)); } - break; - case 34: -#line 2529 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_bool(parser, false)); } - break; - case 35: -#line 2531 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_null(parser)); } - break; - case 36: -#line 2533 "upb/json/parser.rl" - { CHECK_RETURN_TOP(start_subobject_full(parser)); } - break; - case 37: -#line 2534 "upb/json/parser.rl" - { end_subobject_full(parser); } - break; - case 38: -#line 2539 "upb/json/parser.rl" - { p--; {cs = stack[--top]; goto _again;} } - break; -#line 2916 "upb/json/parser.c" -======= case 32: -#line 2700 "upb/json/parser.rl" +#line 2660 "upb/json/parser.rl" { CHECK_RETURN_TOP(start_array(parser)); } break; case 33: -#line 2704 "upb/json/parser.rl" +#line 2664 "upb/json/parser.rl" { end_array(parser); } break; case 34: -#line 2709 "upb/json/parser.rl" +#line 2669 "upb/json/parser.rl" { CHECK_RETURN_TOP(start_number(parser, p)); } break; case 35: -#line 2710 "upb/json/parser.rl" +#line 2670 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_number(parser, p)); } break; case 36: -#line 2712 "upb/json/parser.rl" +#line 2672 "upb/json/parser.rl" { CHECK_RETURN_TOP(start_stringval(parser)); } break; case 37: -#line 2713 "upb/json/parser.rl" +#line 2673 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_stringval(parser)); } break; case 38: -#line 2715 "upb/json/parser.rl" +#line 2675 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_bool(parser, true)); } break; case 39: -#line 2717 "upb/json/parser.rl" +#line 2677 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_bool(parser, false)); } break; case 40: -#line 2719 "upb/json/parser.rl" +#line 2679 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_null(parser)); } break; case 41: -#line 2721 "upb/json/parser.rl" +#line 2681 "upb/json/parser.rl" { CHECK_RETURN_TOP(start_subobject_full(parser)); } break; case 42: -#line 2722 "upb/json/parser.rl" +#line 2682 "upb/json/parser.rl" { end_subobject_full(parser); } break; case 43: -#line 2727 "upb/json/parser.rl" +#line 2687 "upb/json/parser.rl" { p--; {cs = stack[--top]; goto _again;} } break; -#line 3111 "upb/json/parser.c" ->>>>>>> arrayapi +#line 3071 "upb/json/parser.c" } } @@ -3275,60 +3084,32 @@ _again: while ( __nacts-- > 0 ) { switch ( *__acts++ ) { case 0: -<<<<<<< HEAD -#line 2391 "upb/json/parser.rl" -======= -#line 2559 "upb/json/parser.rl" ->>>>>>> arrayapi +#line 2519 "upb/json/parser.rl" { p--; {cs = stack[--top]; if ( p == pe ) goto _test_eof; goto _again;} } break; -<<<<<<< HEAD - case 30: -#line 2522 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_number(parser, p)); } - break; - case 33: -#line 2527 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_bool(parser, true)); } - break; - case 34: -#line 2529 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_bool(parser, false)); } - break; - case 35: -#line 2531 "upb/json/parser.rl" - { CHECK_RETURN_TOP(end_null(parser)); } - break; - case 37: -#line 2534 "upb/json/parser.rl" - { end_subobject_full(parser); } - break; -#line 2958 "upb/json/parser.c" -======= case 35: -#line 2710 "upb/json/parser.rl" +#line 2670 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_number(parser, p)); } break; case 38: -#line 2715 "upb/json/parser.rl" +#line 2675 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_bool(parser, true)); } break; case 39: -#line 2717 "upb/json/parser.rl" +#line 2677 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_bool(parser, false)); } break; case 40: -#line 2719 "upb/json/parser.rl" +#line 2679 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_null(parser)); } break; case 42: -#line 2722 "upb/json/parser.rl" +#line 2682 "upb/json/parser.rl" { end_subobject_full(parser); } break; -#line 3153 "upb/json/parser.c" ->>>>>>> arrayapi +#line 3113 "upb/json/parser.c" } } } @@ -3336,11 +3117,7 @@ goto _again;} } _out: {} } -<<<<<<< HEAD -#line 2567 "upb/json/parser.rl" -======= -#line 2755 "upb/json/parser.rl" ->>>>>>> arrayapi +#line 2715 "upb/json/parser.rl" if (p != pe) { upb_status_seterrf(parser->status, "Parse error at '%.*s'\n", pe - p, p); @@ -3388,21 +3165,13 @@ static void json_parser_reset(upb_json_parser *p) { /* Emit Ragel initialization of the parser. */ -<<<<<<< HEAD -#line 3013 "upb/json/parser.c" -======= -#line 3210 "upb/json/parser.c" ->>>>>>> arrayapi +#line 3169 "upb/json/parser.c" { cs = json_start; top = 0; } -<<<<<<< HEAD -#line 2613 "upb/json/parser.rl" -======= -#line 2803 "upb/json/parser.rl" ->>>>>>> arrayapi +#line 2762 "upb/json/parser.rl" p->current_state = cs; p->parser_top = top; accumulate_clear(p); diff --git a/upb/json/parser.rl b/upb/json/parser.rl index f722d28..1ae896a 100644 --- a/upb/json/parser.rl +++ b/upb/json/parser.rl @@ -19,6 +19,7 @@ ** - handling of keys/escape-sequences/etc that span input buffers. */ +#include #include #include #include @@ -61,7 +62,6 @@ static bool is_string_wrapper_object(upb_json_parser *p); static bool does_string_wrapper_start(upb_json_parser *p); static bool does_string_wrapper_end(upb_json_parser *p); -static bool is_fieldmask_object(upb_json_parser *p); static bool does_fieldmask_start(upb_json_parser *p); static bool does_fieldmask_end(upb_json_parser *p); static void start_fieldmask_object(upb_json_parser *p); @@ -1668,9 +1668,7 @@ static void start_fieldmask_path_text(upb_json_parser *p, const char *ptr) { } static bool end_fieldmask_path_text(upb_json_parser *p, const char *ptr) { - if (!capture_end(p, ptr)) { - return false; - } + return capture_end(p, ptr); } static bool start_fieldmask_path(upb_json_parser *p) { @@ -1683,7 +1681,7 @@ static bool start_fieldmask_path(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; @@ -1705,10 +1703,10 @@ static bool lower_camel_push( for (;ptr < limit; ptr++) { if (*ptr >= 'A' && *ptr <= 'Z' && !first) { char lower = tolower(*ptr); - upb_sink_putstring(&p->top->sink, sel, "_", 1, NULL); - upb_sink_putstring(&p->top->sink, sel, &lower, 1, NULL); + upb_sink_putstring(p->top->sink, sel, "_", 1, NULL); + upb_sink_putstring(p->top->sink, sel, &lower, 1, NULL); } else { - upb_sink_putstring(&p->top->sink, sel, ptr, 1, NULL); + upb_sink_putstring(p->top->sink, sel, ptr, 1, NULL); } first = false; } @@ -1725,7 +1723,7 @@ static bool end_fieldmask_path(upb_json_parser *p) { } sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR); - upb_sink_endstr(&p->top->sink, sel); + upb_sink_endstr(p->top->sink, sel); p->top--; multipart_end(p); @@ -2487,10 +2485,6 @@ static bool does_fieldmask_end(upb_json_parser *p) { return p->top->m != NULL && is_fieldmask(p->top->m); } -static bool is_fieldmask_object(upb_json_parser *p) { - return p->top->m != NULL && is_fieldmask(p->top->m); -} - #define CHECK_RETURN_TOP(x) if (!(x)) goto error diff --git a/upb/json/printer.c b/upb/json/printer.c index 5b16861..2d566cb 100644 --- a/upb/json/printer.c +++ b/upb/json/printer.c @@ -5,8 +5,9 @@ #include "upb/json/printer.h" -#include +#include #include +#include #include struct upb_json_printer { @@ -1029,7 +1030,7 @@ void printer_sethandlers_fieldmask(const void *closure, upb_handlers *h) { const upb_msgdef *md = upb_handlers_msgdef(h); const upb_fielddef* f = upb_msgdef_itof(md, 1); - upb_handlerattr empty_attr = UPB_HANDLERATTR_INITIALIZER; + upb_handlerattr empty_attr = UPB_HANDLERATTR_INIT; upb_handlers_setstartseq(h, f, startseq_fieldmask, &empty_attr); upb_handlers_setendseq(h, f, endseq_fieldmask, &empty_attr); diff --git a/upb/upb.h b/upb/upb.h index 3848229..92db893 100644 --- a/upb/upb.h +++ b/upb/upb.h @@ -377,14 +377,6 @@ typedef enum { UPB_LABEL_REPEATED = 3 } upb_label_t; -/* How integers should be encoded in serializations that offer multiple - * integer encoding methods. */ -typedef enum { - UPB_INTFMT_VARIABLE = 1, - UPB_INTFMT_FIXED = 2, - UPB_INTFMT_ZIGZAG = 3 /* Only for signed types (INT32/INT64). */ -} upb_intfmt_t; - /* Descriptor types, as defined in descriptor.proto. */ typedef enum { UPB_DESCRIPTOR_TYPE_DOUBLE = 1, @@ -407,37 +399,6 @@ typedef enum { UPB_DESCRIPTOR_TYPE_SINT64 = 18 } upb_descriptortype_t; -typedef enum { - UPB_SYNTAX_PROTO2 = 2, - UPB_SYNTAX_PROTO3 = 3 -} upb_syntax_t; - -/* All the different kind of well known type messages. For simplicity of check, - * number wrappers and string wrappers are grouped together. Make sure the - * order and merber of these groups are not changed. - */ -typedef enum { - UPB_WELLKNOWN_UNSPECIFIED, - UPB_WELLKNOWN_ANY, - UPB_WELLKNOWN_FIELDMASK, - UPB_WELLKNOWN_DURATION, - UPB_WELLKNOWN_TIMESTAMP, - /* number wrappers */ - UPB_WELLKNOWN_DOUBLEVALUE, - UPB_WELLKNOWN_FLOATVALUE, - UPB_WELLKNOWN_INT64VALUE, - UPB_WELLKNOWN_UINT64VALUE, - UPB_WELLKNOWN_INT32VALUE, - UPB_WELLKNOWN_UINT32VALUE, - /* string wrappers */ - UPB_WELLKNOWN_STRINGVALUE, - UPB_WELLKNOWN_BYTESVALUE, - UPB_WELLKNOWN_BOOLVALUE, - UPB_WELLKNOWN_VALUE, - UPB_WELLKNOWN_LISTVALUE, - UPB_WELLKNOWN_STRUCT -} upb_wellknowntype_t; - extern const uint8_t upb_desctype_to_fieldtype[]; #endif /* UPB_H_ */ -- cgit v1.2.3