Update upb for ruby

pull/5953/head
Bo Yang 6 years ago
parent a268b63284
commit 2d9507ec74
  1. 1
      conformance/failure_list_ruby.txt
  2. 1
      conformance/failure_list_ruby_mac.txt
  3. 246
      ruby/ext/google/protobuf_c/upb.c
  4. 1
      ruby/ext/google/protobuf_c/upb.h

@ -65,4 +65,3 @@ Required.Proto3.JsonInput.IgnoreUnknownJsonNumber.ProtobufOutput
Required.Proto3.JsonInput.IgnoreUnknownJsonObject.ProtobufOutput
Required.Proto3.JsonInput.IgnoreUnknownJsonString.ProtobufOutput
Required.Proto3.JsonInput.IgnoreUnknownJsonTrue.ProtobufOutput
Required.Proto3.JsonInput.EmptyFieldMask.JsonOutput

@ -70,4 +70,3 @@ Required.Proto3.JsonInput.IgnoreUnknownJsonObject.ProtobufOutput
Required.Proto3.JsonInput.IgnoreUnknownJsonString.ProtobufOutput
Required.Proto3.JsonInput.IgnoreUnknownJsonTrue.ProtobufOutput
Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
Required.Proto3.JsonInput.EmptyFieldMask.JsonOutput

@ -12624,6 +12624,7 @@ done:
** - handling of keys/escape-sequences/etc that span input buffers.
*/
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <math.h>
@ -12820,6 +12821,19 @@ typedef struct {
bool is_unknown_field;
} upb_jsonparser_frame;
static void init_frame(upb_jsonparser_frame* frame) {
frame->m = NULL;
frame->f = NULL;
frame->name_table = NULL;
frame->is_repeated = false;
frame->is_map = false;
frame->is_mapentry = false;
frame->mapfield = NULL;
frame->is_any = false;
frame->any_frame = NULL;
frame->is_unknown_field = false;
}
struct upb_json_parser {
upb_env *env;
const upb_json_parsermethod *method;
@ -12867,6 +12881,13 @@ struct upb_json_parser {
struct tm tm;
};
static upb_jsonparser_frame* start_jsonparser_frame(upb_json_parser *p) {
upb_jsonparser_frame *inner;
inner = p->top + 1;
init_frame(inner);
return inner;
}
struct upb_json_parsermethod {
upb_refcounted base;
@ -13824,18 +13845,11 @@ static bool start_stringval(upb_json_parser *p) {
/* Start a new parser frame: parser frames correspond one-to-one with
* handler frames, and string events occur in a sub-frame. */
inner = p->top + 1;
inner = start_jsonparser_frame(p);
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR);
upb_sink_startstr(&p->top->sink, sel, 0, &inner->sink);
inner->m = p->top->m;
inner->f = p->top->f;
inner->name_table = NULL;
inner->is_repeated = false;
inner->is_map = false;
inner->is_mapentry = false;
inner->is_any = false;
inner->any_frame = NULL;
inner->is_unknown_field = false;
p->top = inner;
if (upb_fielddef_type(p->top->f) == UPB_TYPE_STRING) {
@ -14288,7 +14302,7 @@ static void start_timestamp_zone(upb_json_parser *p, const char *ptr) {
static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) {
size_t len;
const char *buf;
int hours = 0;
int hours;
int64_t seconds;
const char *seconds_membername = "seconds";
@ -14308,11 +14322,12 @@ static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) {
if (buf[0] == '+') {
hours = -hours;
}
p->tm.tm_hour += hours;
}
/* Normalize tm */
seconds = mktime(&p->tm) - timezone;
seconds += 3600 * hours;
seconds = mktime(&p->tm);
/* Check timestamp boundary */
if (seconds < -62135596800) {
@ -14358,18 +14373,11 @@ static bool start_fieldmask_path(upb_json_parser *p) {
/* Start a new parser frame: parser frames correspond one-to-one with
* handler frames, and string events occur in a sub-frame. */
inner = p->top + 1;
inner = start_jsonparser_frame(p);
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR);
upb_sink_startstr(&p->top->sink, sel, 0, &inner->sink);
inner->m = p->top->m;
inner->f = p->top->f;
inner->name_table = NULL;
inner->is_repeated = false;
inner->is_map = false;
inner->is_mapentry = false;
inner->is_any = false;
inner->any_frame = NULL;
inner->is_unknown_field = false;
p->top = inner;
multipart_startaccum(p);
@ -14505,18 +14513,12 @@ static bool handle_mapentry(upb_json_parser *p) {
mapfield = p->top->mapfield;
mapentrymsg = upb_fielddef_msgsubdef(mapfield);
inner = p->top + 1;
inner = start_jsonparser_frame(p);
p->top->f = mapfield;
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG);
upb_sink_startsubmsg(&p->top->sink, sel, &inner->sink);
inner->m = mapentrymsg;
inner->name_table = NULL;
inner->mapfield = mapfield;
inner->is_repeated = false;
inner->is_map = false;
inner->is_any = false;
inner->any_frame = NULL;
inner->is_unknown_field = false;
/* Don't set this to true *yet* -- we reuse parsing handlers below to push
* the key field value to the sink, and these handlers will pop the frame
@ -14634,16 +14636,7 @@ static bool start_subobject(upb_json_parser *p) {
upb_jsonparser_frame *inner;
if (!check_stack(p)) return false;
inner = p->top + 1;
inner->m = NULL;
inner->f = NULL;
inner->is_repeated = false;
inner->is_map = false;
inner->is_mapentry = false;
inner->is_any = false;
inner->any_frame = NULL;
inner->is_unknown_field = false;
p->top = inner;
p->top = start_jsonparser_frame(p);
return true;
}
@ -14655,19 +14648,12 @@ static bool start_subobject(upb_json_parser *p) {
* context. */
if (!check_stack(p)) return false;
inner = p->top + 1;
inner = start_jsonparser_frame(p);
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSEQ);
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;
inner->f = NULL;
inner->is_repeated = false;
inner->is_map = true;
inner->is_mapentry = false;
inner->is_any = false;
inner->any_frame = NULL;
inner->is_unknown_field = false;
p->top = inner;
return true;
@ -14679,17 +14665,11 @@ static bool start_subobject(upb_json_parser *p) {
* context. */
if (!check_stack(p)) return false;
inner = p->top + 1;
inner = start_jsonparser_frame(p);
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG);
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;
inner->is_repeated = false;
inner->is_map = false;
inner->is_mapentry = false;
inner->is_unknown_field = false;
p->top = inner;
if (is_wellknown_msg(p, UPB_WELLKNOWN_ANY)) {
@ -14804,15 +14784,7 @@ static bool start_array(upb_json_parser *p) {
}
if (p->top->is_unknown_field) {
inner = p->top + 1;
inner->m = NULL;
inner->name_table = NULL;
inner->f = NULL;
inner->is_repeated = false;
inner->is_map = false;
inner->is_mapentry = false;
inner->is_any = false;
inner->any_frame = NULL;
inner = start_jsonparser_frame(p);
inner->is_unknown_field = true;
p->top = inner;
@ -14829,18 +14801,12 @@ static bool start_array(upb_json_parser *p) {
if (!check_stack(p)) return false;
inner = p->top + 1;
inner = start_jsonparser_frame(p);
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSEQ);
upb_sink_startseq(&p->top->sink, sel, &inner->sink);
inner->m = p->top->m;
inner->name_table = NULL;
inner->f = p->top->f;
inner->is_repeated = true;
inner->is_map = false;
inner->is_mapentry = false;
inner->is_any = false;
inner->any_frame = NULL;
inner->is_unknown_field = false;
p->top = inner;
return true;
@ -15219,11 +15185,11 @@ static bool is_fieldmask_object(upb_json_parser *p) {
* final state once, when the closing '"' is seen. */
#line 2824 "upb/json/parser.rl"
#line 2789 "upb/json/parser.rl"
#line 2627 "upb/json/parser.c"
#line 2592 "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,
@ -15478,7 +15444,7 @@ static const int json_en_value_machine = 78;
static const int json_en_main = 1;
#line 2827 "upb/json/parser.rl"
#line 2792 "upb/json/parser.rl"
size_t parse(void *closure, const void *hd, const char *buf, size_t size,
const upb_bufhandle *handle) {
@ -15501,7 +15467,7 @@ size_t parse(void *closure, const void *hd, const char *buf, size_t size,
capture_resume(parser, buf);
#line 2905 "upb/json/parser.c"
#line 2870 "upb/json/parser.c"
{
int _klen;
unsigned int _trans;
@ -15576,147 +15542,147 @@ _match:
switch ( *_acts++ )
{
case 1:
#line 2632 "upb/json/parser.rl"
#line 2597 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
case 2:
#line 2634 "upb/json/parser.rl"
#line 2599 "upb/json/parser.rl"
{ p--; {stack[top++] = cs; cs = 23;goto _again;} }
break;
case 3:
#line 2638 "upb/json/parser.rl"
#line 2603 "upb/json/parser.rl"
{ start_text(parser, p); }
break;
case 4:
#line 2639 "upb/json/parser.rl"
#line 2604 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_text(parser, p)); }
break;
case 5:
#line 2645 "upb/json/parser.rl"
#line 2610 "upb/json/parser.rl"
{ start_hex(parser); }
break;
case 6:
#line 2646 "upb/json/parser.rl"
#line 2611 "upb/json/parser.rl"
{ hexdigit(parser, p); }
break;
case 7:
#line 2647 "upb/json/parser.rl"
#line 2612 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_hex(parser)); }
break;
case 8:
#line 2653 "upb/json/parser.rl"
#line 2618 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(escape(parser, p)); }
break;
case 9:
#line 2659 "upb/json/parser.rl"
#line 2624 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
case 10:
#line 2664 "upb/json/parser.rl"
#line 2629 "upb/json/parser.rl"
{ start_year(parser, p); }
break;
case 11:
#line 2665 "upb/json/parser.rl"
#line 2630 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_year(parser, p)); }
break;
case 12:
#line 2669 "upb/json/parser.rl"
#line 2634 "upb/json/parser.rl"
{ start_month(parser, p); }
break;
case 13:
#line 2670 "upb/json/parser.rl"
#line 2635 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_month(parser, p)); }
break;
case 14:
#line 2674 "upb/json/parser.rl"
#line 2639 "upb/json/parser.rl"
{ start_day(parser, p); }
break;
case 15:
#line 2675 "upb/json/parser.rl"
#line 2640 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_day(parser, p)); }
break;
case 16:
#line 2679 "upb/json/parser.rl"
#line 2644 "upb/json/parser.rl"
{ start_hour(parser, p); }
break;
case 17:
#line 2680 "upb/json/parser.rl"
#line 2645 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_hour(parser, p)); }
break;
case 18:
#line 2684 "upb/json/parser.rl"
#line 2649 "upb/json/parser.rl"
{ start_minute(parser, p); }
break;
case 19:
#line 2685 "upb/json/parser.rl"
#line 2650 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_minute(parser, p)); }
break;
case 20:
#line 2689 "upb/json/parser.rl"
#line 2654 "upb/json/parser.rl"
{ start_second(parser, p); }
break;
case 21:
#line 2690 "upb/json/parser.rl"
#line 2655 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_second(parser, p)); }
break;
case 22:
#line 2695 "upb/json/parser.rl"
#line 2660 "upb/json/parser.rl"
{ start_duration_base(parser, p); }
break;
case 23:
#line 2696 "upb/json/parser.rl"
#line 2661 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_duration_base(parser, p)); }
break;
case 24:
#line 2698 "upb/json/parser.rl"
#line 2663 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
case 25:
#line 2703 "upb/json/parser.rl"
#line 2668 "upb/json/parser.rl"
{ start_timestamp_base(parser); }
break;
case 26:
#line 2705 "upb/json/parser.rl"
#line 2670 "upb/json/parser.rl"
{ start_timestamp_fraction(parser, p); }
break;
case 27:
#line 2706 "upb/json/parser.rl"
#line 2671 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_timestamp_fraction(parser, p)); }
break;
case 28:
#line 2708 "upb/json/parser.rl"
#line 2673 "upb/json/parser.rl"
{ start_timestamp_zone(parser, p); }
break;
case 29:
#line 2709 "upb/json/parser.rl"
#line 2674 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_timestamp_zone(parser, p)); }
break;
case 30:
#line 2711 "upb/json/parser.rl"
#line 2676 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
case 31:
#line 2716 "upb/json/parser.rl"
#line 2681 "upb/json/parser.rl"
{ start_fieldmask_path_text(parser, p); }
break;
case 32:
#line 2717 "upb/json/parser.rl"
#line 2682 "upb/json/parser.rl"
{ end_fieldmask_path_text(parser, p); }
break;
case 33:
#line 2722 "upb/json/parser.rl"
#line 2687 "upb/json/parser.rl"
{ start_fieldmask_path(parser); }
break;
case 34:
#line 2723 "upb/json/parser.rl"
#line 2688 "upb/json/parser.rl"
{ end_fieldmask_path(parser); }
break;
case 35:
#line 2729 "upb/json/parser.rl"
#line 2694 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
case 36:
#line 2734 "upb/json/parser.rl"
#line 2699 "upb/json/parser.rl"
{
if (is_wellknown_msg(parser, UPB_WELLKNOWN_TIMESTAMP)) {
{stack[top++] = cs; cs = 47;goto _again;}
@ -15730,11 +15696,11 @@ _match:
}
break;
case 37:
#line 2747 "upb/json/parser.rl"
#line 2712 "upb/json/parser.rl"
{ p--; {stack[top++] = cs; cs = 78;goto _again;} }
break;
case 38:
#line 2752 "upb/json/parser.rl"
#line 2717 "upb/json/parser.rl"
{
if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
start_any_member(parser, p);
@ -15744,11 +15710,11 @@ _match:
}
break;
case 39:
#line 2759 "upb/json/parser.rl"
#line 2724 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_membername(parser)); }
break;
case 40:
#line 2762 "upb/json/parser.rl"
#line 2727 "upb/json/parser.rl"
{
if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
end_any_member(parser, p);
@ -15758,7 +15724,7 @@ _match:
}
break;
case 41:
#line 2773 "upb/json/parser.rl"
#line 2738 "upb/json/parser.rl"
{
if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
start_any_object(parser, p);
@ -15768,7 +15734,7 @@ _match:
}
break;
case 42:
#line 2782 "upb/json/parser.rl"
#line 2747 "upb/json/parser.rl"
{
if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
CHECK_RETURN_TOP(end_any_object(parser, p));
@ -15778,54 +15744,54 @@ _match:
}
break;
case 43:
#line 2794 "upb/json/parser.rl"
#line 2759 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(start_array(parser)); }
break;
case 44:
#line 2798 "upb/json/parser.rl"
#line 2763 "upb/json/parser.rl"
{ end_array(parser); }
break;
case 45:
#line 2803 "upb/json/parser.rl"
#line 2768 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(start_number(parser, p)); }
break;
case 46:
#line 2804 "upb/json/parser.rl"
#line 2769 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_number(parser, p)); }
break;
case 47:
#line 2806 "upb/json/parser.rl"
#line 2771 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(start_stringval(parser)); }
break;
case 48:
#line 2807 "upb/json/parser.rl"
#line 2772 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_stringval(parser)); }
break;
case 49:
#line 2809 "upb/json/parser.rl"
#line 2774 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_bool(parser, true)); }
break;
case 50:
#line 2811 "upb/json/parser.rl"
#line 2776 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_bool(parser, false)); }
break;
case 51:
#line 2813 "upb/json/parser.rl"
#line 2778 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_null(parser)); }
break;
case 52:
#line 2815 "upb/json/parser.rl"
#line 2780 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(start_subobject_full(parser)); }
break;
case 53:
#line 2816 "upb/json/parser.rl"
#line 2781 "upb/json/parser.rl"
{ end_subobject_full(parser); }
break;
case 54:
#line 2821 "upb/json/parser.rl"
#line 2786 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
#line 3229 "upb/json/parser.c"
#line 3194 "upb/json/parser.c"
}
}
@ -15842,32 +15808,32 @@ _again:
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 0:
#line 2630 "upb/json/parser.rl"
#line 2595 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; if ( p == pe )
goto _test_eof;
goto _again;} }
break;
case 46:
#line 2804 "upb/json/parser.rl"
#line 2769 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_number(parser, p)); }
break;
case 49:
#line 2809 "upb/json/parser.rl"
#line 2774 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_bool(parser, true)); }
break;
case 50:
#line 2811 "upb/json/parser.rl"
#line 2776 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_bool(parser, false)); }
break;
case 51:
#line 2813 "upb/json/parser.rl"
#line 2778 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_null(parser)); }
break;
case 53:
#line 2816 "upb/json/parser.rl"
#line 2781 "upb/json/parser.rl"
{ end_subobject_full(parser); }
break;
#line 3271 "upb/json/parser.c"
#line 3236 "upb/json/parser.c"
}
}
}
@ -15875,7 +15841,7 @@ goto _again;} }
_out: {}
}
#line 2849 "upb/json/parser.rl"
#line 2814 "upb/json/parser.rl"
if (p != pe) {
upb_status_seterrf(&parser->status, "Parse error at '%.*s'\n", pe - p, p);
@ -15915,23 +15881,17 @@ static void json_parser_reset(upb_json_parser *p) {
int top;
p->top = p->stack;
p->top->f = NULL;
p->top->is_repeated = false;
p->top->is_map = false;
p->top->is_mapentry = false;
p->top->is_any = false;
p->top->any_frame = NULL;
p->top->is_unknown_field = false;
init_frame(p->top);
/* Emit Ragel initialization of the parser. */
#line 3329 "upb/json/parser.c"
#line 3288 "upb/json/parser.c"
{
cs = json_start;
top = 0;
}
#line 2898 "upb/json/parser.rl"
#line 2857 "upb/json/parser.rl"
p->current_state = cs;
p->parser_top = top;
accumulate_clear(p);

@ -10639,4 +10639,3 @@ inline reffed_ptr<const Handlers> Printer::NewHandlers(
#undef UPB_FIELD_AT
#undef UPB_READ_ONEOF
#undef UPB_WRITE_ONEOF
#undef UPB_WRITE_ONEOF

Loading…
Cancel
Save