Fix Any json encoding/decoding for ruby. (#5592)
* Fix Any json encoding/decoding for ruby.
* Revert unnecessary changes
diff --git a/conformance/failure_list_ruby.txt b/conformance/failure_list_ruby.txt
index 44f67a9..651cb55 100644
--- a/conformance/failure_list_ruby.txt
+++ b/conformance/failure_list_ruby.txt
@@ -5,6 +5,7 @@
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator
Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator
+Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
Recommended.Proto3.JsonInput.Int64FieldBeString.Validator
Recommended.Proto3.JsonInput.MapFieldValueIsNull
Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull
@@ -18,26 +19,6 @@
Recommended.Proto3.JsonInput.Uint64FieldBeString.Validator
Required.DurationProtoInputTooLarge.JsonOutput
Required.DurationProtoInputTooSmall.JsonOutput
-Required.Proto3.JsonInput.Any.JsonOutput
-Required.Proto3.JsonInput.Any.ProtobufOutput
-Required.Proto3.JsonInput.AnyNested.JsonOutput
-Required.Proto3.JsonInput.AnyNested.ProtobufOutput
-Required.Proto3.JsonInput.AnyUnorderedTypeTag.JsonOutput
-Required.Proto3.JsonInput.AnyUnorderedTypeTag.ProtobufOutput
-Required.Proto3.JsonInput.AnyWithDuration.JsonOutput
-Required.Proto3.JsonInput.AnyWithDuration.ProtobufOutput
-Required.Proto3.JsonInput.AnyWithFieldMask.JsonOutput
-Required.Proto3.JsonInput.AnyWithFieldMask.ProtobufOutput
-Required.Proto3.JsonInput.AnyWithInt32ValueWrapper.JsonOutput
-Required.Proto3.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
-Required.Proto3.JsonInput.AnyWithStruct.JsonOutput
-Required.Proto3.JsonInput.AnyWithStruct.ProtobufOutput
-Required.Proto3.JsonInput.AnyWithTimestamp.JsonOutput
-Required.Proto3.JsonInput.AnyWithTimestamp.ProtobufOutput
-Required.Proto3.JsonInput.AnyWithValueForInteger.JsonOutput
-Required.Proto3.JsonInput.AnyWithValueForInteger.ProtobufOutput
-Required.Proto3.JsonInput.AnyWithValueForJsonObject.JsonOutput
-Required.Proto3.JsonInput.AnyWithValueForJsonObject.ProtobufOutput
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.JsonOutput
@@ -45,8 +26,6 @@
Required.Proto3.JsonInput.DoubleFieldNan.JsonOutput
Required.Proto3.JsonInput.DurationMinValue.JsonOutput
Required.Proto3.JsonInput.DurationRepeatedValue.JsonOutput
-Required.Proto3.JsonInput.FieldMask.JsonOutput
-Required.Proto3.JsonInput.FieldMask.ProtobufOutput
Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput
Required.Proto3.JsonInput.FloatFieldNan.JsonOutput
Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput
diff --git a/ruby/ext/google/protobuf_c/encode_decode.c b/ruby/ext/google/protobuf_c/encode_decode.c
index a14f0bc..c5078bc 100644
--- a/ruby/ext/google/protobuf_c/encode_decode.c
+++ b/ruby/ext/google/protobuf_c/encode_decode.c
@@ -254,18 +254,13 @@
}
static bool stringdata_end_handler(void* closure, const void* hd) {
- MessageHeader* msg = closure;
- const size_t *ofs = hd;
- VALUE rb_str = DEREF(msg, *ofs, VALUE);
+ VALUE rb_str = closure;
rb_obj_freeze(rb_str);
return true;
}
static bool appendstring_end_handler(void* closure, const void* hd) {
- VALUE ary = (VALUE)closure;
- int size = RepeatedField_size(ary);
- VALUE* last = RepeatedField_index_native(ary, size - 1);
- VALUE rb_str = *last;
+ VALUE rb_str = closure;
rb_obj_freeze(rb_str);
return true;
}
@@ -481,9 +476,8 @@
}
static bool oneofstring_end_handler(void* closure, const void* hd) {
- MessageHeader* msg = closure;
- const oneof_handlerdata_t *oneofdata = hd;
- rb_obj_freeze(DEREF(msg, oneofdata->ofs, VALUE));
+ VALUE rb_str = rb_str_new2("");
+ rb_obj_freeze(rb_str);
return true;
}
@@ -938,10 +932,12 @@
stackenv se;
upb_sink sink;
upb_json_parser* parser;
+ DescriptorPool* pool = ruby_to_DescriptorPool(generated_pool);
stackenv_init(&se, "Error occurred during parsing: %s");
upb_sink_reset(&sink, get_fill_handlers(desc), msg);
- parser = upb_json_parser_create(&se.env, method, &sink, ignore_unknown_fields);
+ parser = upb_json_parser_create(&se.env, method, pool->symtab,
+ &sink, ignore_unknown_fields);
upb_bufsrc_putbuf(RSTRING_PTR(data), RSTRING_LEN(data),
upb_json_parser_input(parser));
@@ -958,7 +954,8 @@
/* msgvisitor *****************************************************************/
static void putmsg(VALUE msg, const Descriptor* desc,
- upb_sink *sink, int depth, bool emit_defaults);
+ upb_sink *sink, int depth, bool emit_defaults,
+ bool is_json, bool open_msg);
static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) {
upb_selector_t ret;
@@ -990,7 +987,7 @@
}
static void putsubmsg(VALUE submsg, const upb_fielddef *f, upb_sink *sink,
- int depth, bool emit_defaults) {
+ int depth, bool emit_defaults, bool is_json) {
upb_sink subsink;
VALUE descriptor;
Descriptor* subdesc;
@@ -1001,12 +998,12 @@
subdesc = ruby_to_Descriptor(descriptor);
upb_sink_startsubmsg(sink, getsel(f, UPB_HANDLER_STARTSUBMSG), &subsink);
- putmsg(submsg, subdesc, &subsink, depth + 1, emit_defaults);
+ putmsg(submsg, subdesc, &subsink, depth + 1, emit_defaults, is_json, true);
upb_sink_endsubmsg(sink, getsel(f, UPB_HANDLER_ENDSUBMSG));
}
static void putary(VALUE ary, const upb_fielddef *f, upb_sink *sink,
- int depth, bool emit_defaults) {
+ int depth, bool emit_defaults, bool is_json) {
upb_sink subsink;
upb_fieldtype_t type = upb_fielddef_type(f);
upb_selector_t sel = 0;
@@ -1046,7 +1043,8 @@
putstr(*((VALUE *)memory), f, &subsink);
break;
case UPB_TYPE_MESSAGE:
- putsubmsg(*((VALUE *)memory), f, &subsink, depth, emit_defaults);
+ putsubmsg(*((VALUE *)memory), f, &subsink, depth,
+ emit_defaults, is_json);
break;
#undef T
@@ -1061,7 +1059,8 @@
VALUE type_class,
int depth,
upb_sink *sink,
- bool emit_defaults) {
+ bool emit_defaults,
+ bool is_json) {
upb_selector_t sel = 0;
if (upb_fielddef_isprimitive(f)) {
sel = getsel(f, upb_handlers_getprimitivehandlertype(f));
@@ -1101,12 +1100,12 @@
putstr(value, f, sink);
break;
case UPB_TYPE_MESSAGE:
- putsubmsg(value, f, sink, depth, emit_defaults);
+ putsubmsg(value, f, sink, depth, emit_defaults, is_json);
}
}
static void putmap(VALUE map, const upb_fielddef *f, upb_sink *sink,
- int depth, bool emit_defaults) {
+ int depth, bool emit_defaults, bool is_json) {
Map* self;
upb_sink subsink;
const upb_fielddef* key_field;
@@ -1134,9 +1133,10 @@
&entry_sink);
upb_sink_startmsg(&entry_sink);
- put_ruby_value(key, key_field, Qnil, depth + 1, &entry_sink, emit_defaults);
+ put_ruby_value(key, key_field, Qnil, depth + 1, &entry_sink,
+ emit_defaults, is_json);
put_ruby_value(value, value_field, self->value_type_class, depth + 1,
- &entry_sink, emit_defaults);
+ &entry_sink, emit_defaults, is_json);
upb_sink_endmsg(&entry_sink, &status);
upb_sink_endsubmsg(&subsink, getsel(f, UPB_HANDLER_ENDSUBMSG));
@@ -1145,13 +1145,108 @@
upb_sink_endseq(sink, getsel(f, UPB_HANDLER_ENDSEQ));
}
+static const upb_handlers* msgdef_json_serialize_handlers(
+ Descriptor* desc, bool preserve_proto_fieldnames);
+
+static void putjsonany(VALUE msg_rb, const Descriptor* desc,
+ upb_sink* sink, int depth, bool emit_defaults) {
+ upb_status status;
+ MessageHeader* msg = NULL;
+ const upb_fielddef* type_field = upb_msgdef_itof(desc->msgdef, UPB_ANY_TYPE);
+ const upb_fielddef* value_field = upb_msgdef_itof(desc->msgdef, UPB_ANY_VALUE);
+
+ size_t type_url_offset;
+ VALUE type_url_str_rb;
+ const upb_msgdef *payload_type = NULL;
+
+ TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg);
+
+ upb_sink_startmsg(sink);
+
+ /* Handle type url */
+ type_url_offset = desc->layout->fields[upb_fielddef_index(type_field)].offset;
+ type_url_str_rb = DEREF(Message_data(msg), type_url_offset, VALUE);
+ if (RSTRING_LEN(type_url_str_rb) > 0) {
+ putstr(type_url_str_rb, type_field, sink);
+ }
+
+ {
+ const char* type_url_str = RSTRING_PTR(type_url_str_rb);
+ size_t type_url_len = RSTRING_LEN(type_url_str_rb);
+ DescriptorPool* pool = ruby_to_DescriptorPool(generated_pool);
+
+ if (type_url_len <= 20 ||
+ strncmp(type_url_str, "type.googleapis.com/", 20) != 0) {
+ rb_raise(rb_eRuntimeError, "Invalid type url: %s", type_url_str);
+ return;
+ }
+
+ /* Resolve type url */
+ type_url_str += 20;
+ type_url_len -= 20;
+
+ payload_type = upb_symtab_lookupmsg2(
+ pool->symtab, type_url_str, type_url_len);
+ if (payload_type == NULL) {
+ rb_raise(rb_eRuntimeError, "Unknown type: %s", type_url_str);
+ return;
+ }
+ }
+
+ {
+ uint32_t value_offset;
+ VALUE value_str_rb;
+ const char* value_str;
+ size_t value_len;
+
+ value_offset = desc->layout->fields[upb_fielddef_index(value_field)].offset;
+ value_str_rb = DEREF(Message_data(msg), value_offset, VALUE);
+ value_str = RSTRING_PTR(value_str_rb);
+ value_len = RSTRING_LEN(value_str_rb);
+
+ if (value_len > 0) {
+ VALUE payload_desc_rb = get_def_obj(payload_type);
+ Descriptor* payload_desc = ruby_to_Descriptor(payload_desc_rb);
+ VALUE payload_class = Descriptor_msgclass(payload_desc_rb);
+ upb_sink subsink;
+ bool is_wellknown;
+
+ VALUE payload_msg_rb = Message_decode(payload_class, value_str_rb);
+
+ is_wellknown =
+ upb_msgdef_wellknowntype(payload_desc->msgdef) !=
+ UPB_WELLKNOWN_UNSPECIFIED;
+ if (is_wellknown) {
+ upb_sink_startstr(sink, getsel(value_field, UPB_HANDLER_STARTSTR), 0,
+ &subsink);
+ }
+
+ subsink.handlers =
+ msgdef_json_serialize_handlers(payload_desc, true);
+ subsink.closure = sink->closure;
+ putmsg(payload_msg_rb, payload_desc, &subsink, depth, emit_defaults, true,
+ is_wellknown);
+ }
+ }
+
+ upb_sink_endmsg(sink, &status);
+}
+
static void putmsg(VALUE msg_rb, const Descriptor* desc,
- upb_sink *sink, int depth, bool emit_defaults) {
+ upb_sink *sink, int depth, bool emit_defaults,
+ bool is_json, bool open_msg) {
MessageHeader* msg;
upb_msg_field_iter i;
upb_status status;
- upb_sink_startmsg(sink);
+ if (is_json && upb_msgdef_wellknowntype(desc->msgdef) == UPB_WELLKNOWN_ANY) {
+ putjsonany(msg_rb, desc, sink, depth, emit_defaults);
+ return;
+ }
+
+ if (open_msg) {
+ upb_sink_startmsg(sink);
+ }
// Protect against cycles (possible because users may freely reassign message
// and repeated fields) by imposing a maximum recursion depth.
@@ -1196,12 +1291,12 @@
if (is_map_field(f)) {
VALUE map = DEREF(msg, offset, VALUE);
if (map != Qnil || emit_defaults) {
- putmap(map, f, sink, depth, emit_defaults);
+ putmap(map, f, sink, depth, emit_defaults, is_json);
}
} else if (upb_fielddef_isseq(f)) {
VALUE ary = DEREF(msg, offset, VALUE);
if (ary != Qnil) {
- putary(ary, f, sink, depth, emit_defaults);
+ putary(ary, f, sink, depth, emit_defaults, is_json);
}
} else if (upb_fielddef_isstring(f)) {
VALUE str = DEREF(msg, offset, VALUE);
@@ -1217,7 +1312,8 @@
putstr(str, f, sink);
}
} else if (upb_fielddef_issubmsg(f)) {
- putsubmsg(DEREF(msg, offset, VALUE), f, sink, depth, emit_defaults);
+ putsubmsg(DEREF(msg, offset, VALUE), f, sink, depth,
+ emit_defaults, is_json);
} else {
upb_selector_t sel = getsel(f, upb_handlers_getprimitivehandlertype(f));
@@ -1261,7 +1357,9 @@
upb_sink_putunknown(sink, unknown->ptr, unknown->len);
}
- upb_sink_endmsg(sink, &status);
+ if (open_msg) {
+ upb_sink_endmsg(sink, &status);
+ }
}
static const upb_handlers* msgdef_pb_serialize_handlers(Descriptor* desc) {
@@ -1316,7 +1414,7 @@
stackenv_init(&se, "Error occurred during encoding: %s");
encoder = upb_pb_encoder_create(&se.env, serialize_handlers, &sink.sink);
- putmsg(msg_rb, desc, upb_pb_encoder_input(encoder), 0, false);
+ putmsg(msg_rb, desc, upb_pb_encoder_input(encoder), 0, false, false, true);
ret = rb_str_new(sink.ptr, sink.len);
@@ -1374,7 +1472,8 @@
stackenv_init(&se, "Error occurred during encoding: %s");
printer = upb_json_printer_create(&se.env, serialize_handlers, &sink.sink);
- putmsg(msg_rb, desc, upb_json_printer_input(printer), 0, RTEST(emit_defaults));
+ putmsg(msg_rb, desc, upb_json_printer_input(printer), 0,
+ RTEST(emit_defaults), true, true);
ret = rb_enc_str_new(sink.ptr, sink.len, rb_utf8_encoding());
diff --git a/ruby/ext/google/protobuf_c/protobuf.h b/ruby/ext/google/protobuf_c/protobuf.h
index 616947c..eff212e 100644
--- a/ruby/ext/google/protobuf_c/protobuf.h
+++ b/ruby/ext/google/protobuf_c/protobuf.h
@@ -196,6 +196,8 @@
VALUE DescriptorPool_lookup(VALUE _self, VALUE name);
VALUE DescriptorPool_generated_pool(VALUE _self);
+extern VALUE generated_pool;
+
void Descriptor_mark(void* _self);
void Descriptor_free(void* _self);
VALUE Descriptor_alloc(VALUE klass);
diff --git a/ruby/ext/google/protobuf_c/upb.c b/ruby/ext/google/protobuf_c/upb.c
index 049e2bb..b001d7a 100644
--- a/ruby/ext/google/protobuf_c/upb.c
+++ b/ruby/ext/google/protobuf_c/upb.c
@@ -1458,7 +1458,11 @@
m->well_known_type = UPB_WELLKNOWN_UNSPECIFIED;
return;
}
- if (!strcmp(name, "google.protobuf.Duration")) {
+ if (!strcmp(name, "google.protobuf.Any")) {
+ m->well_known_type = UPB_WELLKNOWN_ANY;
+ } else if (!strcmp(name, "google.protobuf.FieldMask")) {
+ m->well_known_type = UPB_WELLKNOWN_FIELDMASK;
+ } else if (!strcmp(name, "google.protobuf.Duration")) {
m->well_known_type = UPB_WELLKNOWN_DURATION;
} else if (!strcmp(name, "google.protobuf.Timestamp")) {
m->well_known_type = UPB_WELLKNOWN_TIMESTAMP;
@@ -3233,6 +3237,14 @@
return def ? upb_dyncast_msgdef(def) : NULL;
}
+const upb_msgdef *upb_symtab_lookupmsg2(const upb_symtab *s, const char *sym,
+ size_t len) {
+ upb_value v;
+ upb_def *def = upb_strtable_lookup2(&s->symtab, sym, len, &v) ?
+ upb_value_getptr(v) : NULL;
+ return def ? upb_dyncast_msgdef(def) : NULL;
+}
+
const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym) {
upb_value v;
upb_def *def = upb_strtable_lookup(&s->symtab, sym, &v) ?
@@ -5451,6 +5463,29 @@
return l;
}
}
+
+#if UINTPTR_MAX == 0xffffffff
+#define UPB_SIZE(size32, size64) size32
+#else
+#define UPB_SIZE(size32, size64) size64
+#endif
+
+#define UPB_FIELD_AT(msg, fieldtype, offset) \
+ *(fieldtype*)((const char*)(msg) + offset)
+
+#define UPB_READ_ONEOF(msg, fieldtype, offset, case_offset, case_val, default) \
+ UPB_FIELD_AT(msg, int, case_offset) == case_val \
+ ? UPB_FIELD_AT(msg, fieldtype, offset) \
+ : default
+
+#define UPB_WRITE_ONEOF(msg, fieldtype, offset, value, case_offset, case_val) \
+ UPB_FIELD_AT(msg, int, case_offset) = case_val; \
+ UPB_FIELD_AT(msg, fieldtype, offset) = value;
+
+#undef UPB_SIZE
+#undef UPB_FIELD_AT
+#undef UPB_READ_ONEOF
+#undef UPB_WRITE_ONEOF
/*
** upb::RefCounted Implementation
**
@@ -10109,8 +10144,8 @@
putop(c, OP_STARTSTR, getsel(f, UPB_HANDLER_STARTSTR));
/* Need to emit even if no handler to skip past the string. */
putop(c, OP_STRING, getsel(f, UPB_HANDLER_STRING));
- putop(c, OP_POP);
maybeput(c, OP_ENDSTR, h, f, UPB_HANDLER_ENDSTR);
+ putop(c, OP_POP);
putop(c, OP_SETDELIM);
putop(c, OP_CHECKDELIM, LABEL_LOOPBREAK);
putchecktag(c, f, UPB_WIRE_TYPE_DELIMITED, LABEL_LOOPBREAK);
@@ -10125,8 +10160,8 @@
putop(c, OP_PUSHLENDELIM);
putop(c, OP_STARTSTR, getsel(f, UPB_HANDLER_STARTSTR));
putop(c, OP_STRING, getsel(f, UPB_HANDLER_STRING));
- putop(c, OP_POP);
maybeput(c, OP_ENDSTR, h, f, UPB_HANDLER_ENDSTR);
+ putop(c, OP_POP);
putop(c, OP_SETDELIM);
}
}
@@ -12546,7 +12581,7 @@
return r;
}
-//#line 1 "upb/json/parser.rl"
+#line 1 "upb/json/parser.rl"
/*
** upb::json::Parser (upb_json_parser)
**
@@ -12608,6 +12643,12 @@
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);
+static void end_fieldmask_object(upb_json_parser *p);
+
static void start_wrapper_object(upb_json_parser *p);
static void end_wrapper_object(upb_json_parser *p);
@@ -12623,6 +12664,9 @@
static void start_object(upb_json_parser *p);
static void end_object(upb_json_parser *p);
+static void start_any_object(upb_json_parser *p, const char *ptr);
+static bool end_any_object(upb_json_parser *p, const char *ptr);
+
static bool start_subobject(upb_json_parser *p);
static void end_subobject(upb_json_parser *p);
@@ -12630,8 +12674,89 @@
static void end_member(upb_json_parser *p);
static bool end_membername(upb_json_parser *p);
+static void start_any_member(upb_json_parser *p, const char *ptr);
+static void end_any_member(upb_json_parser *p, const char *ptr);
+static bool end_any_membername(upb_json_parser *p);
+
+size_t parse(void *closure, const void *hd, const char *buf, size_t size,
+ const upb_bufhandle *handle);
+static bool end(void *closure, const void *hd);
+
static const char eof_ch = 'e';
+/* stringsink */
+typedef struct {
+ upb_byteshandler handler;
+ upb_bytessink sink;
+ char *ptr;
+ size_t len, size;
+} upb_stringsink;
+
+
+static void *stringsink_start(void *_sink, const void *hd, size_t size_hint) {
+ upb_stringsink *sink = _sink;
+ sink->len = 0;
+ UPB_UNUSED(hd);
+ UPB_UNUSED(size_hint);
+ return sink;
+}
+
+static size_t stringsink_string(void *_sink, const void *hd, const char *ptr,
+ size_t len, const upb_bufhandle *handle) {
+ upb_stringsink *sink = _sink;
+ size_t new_size = sink->size;
+
+ UPB_UNUSED(hd);
+ UPB_UNUSED(handle);
+
+ while (sink->len + len > new_size) {
+ new_size *= 2;
+ }
+
+ if (new_size != sink->size) {
+ sink->ptr = realloc(sink->ptr, new_size);
+ sink->size = new_size;
+ }
+
+ memcpy(sink->ptr + sink->len, ptr, len);
+ sink->len += len;
+
+ return len;
+}
+
+void upb_stringsink_init(upb_stringsink *sink) {
+ upb_byteshandler_init(&sink->handler);
+ upb_byteshandler_setstartstr(&sink->handler, stringsink_start, NULL);
+ upb_byteshandler_setstring(&sink->handler, stringsink_string, NULL);
+
+ upb_bytessink_reset(&sink->sink, &sink->handler, sink);
+
+ sink->size = 32;
+ sink->ptr = malloc(sink->size);
+ sink->len = 0;
+}
+
+void upb_stringsink_uninit(upb_stringsink *sink) { free(sink->ptr); }
+
+typedef struct {
+ /* For encoding Any value field in binary format. */
+ const upb_handlers *encoder_handlers;
+ upb_pb_encoder *encoder;
+ upb_stringsink stringsink;
+
+ /* For decoding Any value field in json format. */
+ upb_json_parsermethod *parser_method;
+ upb_json_parser* parser;
+ upb_sink sink;
+
+ /* Mark the range of uninterpreted values in json input before type url. */
+ const char *before_type_url_start;
+ const char *before_type_url_end;
+
+ /* Mark the range of uninterpreted values in json input after type url. */
+ const char *after_type_url_start;
+} upb_jsonparser_any_frame;
+
typedef struct {
upb_sink sink;
@@ -12660,6 +12785,15 @@
* message itself), not the parent's field that leads to this map. */
const upb_fielddef *mapfield;
+ /* We are in an Any message context. This flag is set when parsing the Any
+ * message and indicates to all field parsers (subobjects, strings, numbers,
+ * and bools) that the parsed field should be serialized as binary data or
+ * cached (type url not found yet). */
+ bool is_any;
+
+ /* The type of packed message in Any. */
+ upb_jsonparser_any_frame *any_frame;
+
/* True if the field to be parsed is unknown. */
bool is_unknown_field;
} upb_jsonparser_frame;
@@ -12700,6 +12834,9 @@
/* Intermediate result of parsing a unicode escape sequence. */
uint32_t digit;
+ /* For resolve type url in Any. */
+ const upb_symtab *symtab;
+
/* Whether to proceed if unknown field is met. */
bool ignore_json_unknown;
@@ -12723,6 +12860,84 @@
#define PARSER_CHECK_RETURN(x) if (!(x)) return false
+static void json_parser_any_frame_reset(upb_jsonparser_any_frame *frame) {
+ frame->encoder_handlers = NULL;
+ frame->encoder = NULL;
+ frame->parser_method = NULL;
+ frame->parser = NULL;
+ frame->before_type_url_start = NULL;
+ frame->before_type_url_end = NULL;
+ frame->after_type_url_start = NULL;
+}
+
+static void json_parser_any_frame_set_payload_type(
+ upb_json_parser *p,
+ upb_jsonparser_any_frame *frame,
+ const upb_msgdef *payload_type) {
+ /* Initialize encoder. */
+ frame->encoder_handlers =
+ upb_pb_encoder_newhandlers(payload_type, &frame->encoder_handlers);
+ upb_stringsink_init(&frame->stringsink);
+ frame->encoder =
+ upb_pb_encoder_create(
+ p->env, frame->encoder_handlers,
+ &frame->stringsink.sink);
+
+ /* Initialize parser. */
+ frame->parser_method =
+ upb_json_parsermethod_new(payload_type, &frame->parser_method);
+ upb_sink_reset(&frame->sink, frame->encoder_handlers, frame->encoder);
+ frame->parser =
+ upb_json_parser_create(p->env, frame->parser_method, p->symtab,
+ &frame->sink, p->ignore_json_unknown);
+}
+
+static void json_parser_any_frame_free(upb_jsonparser_any_frame *frame) {
+ upb_handlers_unref(frame->encoder_handlers,
+ &frame->encoder_handlers);
+ upb_json_parsermethod_unref(frame->parser_method,
+ &frame->parser_method);
+ upb_stringsink_uninit(&frame->stringsink);
+}
+
+static bool json_parser_any_frame_has_type_url(
+ upb_jsonparser_any_frame *frame) {
+ return frame->encoder != NULL;
+}
+
+static bool json_parser_any_frame_has_value_before_type_url(
+ upb_jsonparser_any_frame *frame) {
+ return frame->before_type_url_start != frame->before_type_url_end;
+}
+
+static bool json_parser_any_frame_has_value_after_type_url(
+ upb_jsonparser_any_frame *frame) {
+ return frame->after_type_url_start != NULL;
+}
+
+static bool json_parser_any_frame_has_value(
+ upb_jsonparser_any_frame *frame) {
+ return json_parser_any_frame_has_value_before_type_url(frame) ||
+ json_parser_any_frame_has_value_after_type_url(frame);
+}
+
+static void json_parser_any_frame_set_before_type_url_end(
+ upb_jsonparser_any_frame *frame,
+ const char *ptr) {
+ if (frame->encoder == NULL) {
+ frame->before_type_url_end = ptr;
+ }
+}
+
+static void json_parser_any_frame_set_after_type_url_start_once(
+ upb_jsonparser_any_frame *frame,
+ const char *ptr) {
+ if (json_parser_any_frame_has_type_url(frame) &&
+ frame->after_type_url_start == NULL) {
+ frame->after_type_url_start = ptr;
+ }
+}
+
/* Used to signal that a capture has been suspended. */
static char suspend_capture;
@@ -13526,10 +13741,18 @@
return true;
}
+static bool start_any_stringval(upb_json_parser *p) {
+ multipart_startaccum(p);
+ return true;
+}
+
static bool start_stringval(upb_json_parser *p) {
if (is_top_level(p)) {
if (is_string_wrapper_object(p)) {
start_wrapper_object(p);
+ } else if (is_wellknown_msg(p, UPB_WELLKNOWN_FIELDMASK)) {
+ start_fieldmask_object(p);
+ return true;
} else if (is_wellknown_msg(p, UPB_WELLKNOWN_TIMESTAMP) ||
is_wellknown_msg(p, UPB_WELLKNOWN_DURATION)) {
start_object(p);
@@ -13543,6 +13766,12 @@
return false;
}
start_wrapper_object(p);
+ } else if (does_fieldmask_start(p)) {
+ if (!start_subobject(p)) {
+ return false;
+ }
+ start_fieldmask_object(p);
+ return true;
} else if (is_wellknown_field(p, UPB_WELLKNOWN_TIMESTAMP) ||
is_wellknown_field(p, UPB_WELLKNOWN_DURATION)) {
if (!start_subobject(p)) {
@@ -13561,6 +13790,10 @@
return true;
}
+ if (p->top->is_any) {
+ return start_any_stringval(p);
+ }
+
if (upb_fielddef_isstring(p->top->f)) {
upb_jsonparser_frame *inner;
upb_selector_t sel;
@@ -13577,6 +13810,8 @@
inner->name_table = NULL;
inner->is_map = false;
inner->is_mapentry = false;
+ inner->is_any = false;
+ inner->any_frame = NULL;
inner->is_unknown_field = false;
p->top = inner;
@@ -13608,6 +13843,50 @@
}
}
+static bool end_any_stringval(upb_json_parser *p) {
+ size_t len;
+ const char *buf = accumulate_getptr(p, &len);
+
+ /* Set type_url */
+ upb_selector_t sel;
+ upb_jsonparser_frame *inner;
+ if (!check_stack(p)) return false;
+ inner = p->top + 1;
+
+ sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR);
+ 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);
+ sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR);
+ upb_sink_endstr(&inner->sink, sel);
+
+ multipart_end(p);
+
+ /* Resolve type url */
+ if (strncmp(buf, "type.googleapis.com/", 20) == 0 && len > 20) {
+ const upb_msgdef *payload_type = NULL;
+ buf += 20;
+ len -= 20;
+
+ payload_type = upb_symtab_lookupmsg2(p->symtab, buf, len);
+ if (payload_type == NULL) {
+ upb_status_seterrf(
+ &p->status, "Cannot find packed type: %.*s\n", (int)len, buf);
+ upb_env_reporterror(p->env, &p->status);
+ return false;
+ }
+
+ json_parser_any_frame_set_payload_type(p, p->top->any_frame, payload_type);
+
+ return true;
+ } else {
+ upb_status_seterrf(
+ &p->status, "Invalid type url: %.*s\n", (int)len, buf);
+ upb_env_reporterror(p->env, &p->status);
+ return false;
+ }
+}
+
static bool end_stringval_nontop(upb_json_parser *p) {
bool ok = true;
@@ -13622,6 +13901,10 @@
return true;
}
+ if (p->top->is_any) {
+ return end_any_stringval(p);
+ }
+
switch (upb_fielddef_type(p->top->f)) {
case UPB_TYPE_BYTES:
if (!base64_push(p, getsel_for_handlertype(p, UPB_HANDLER_STRING),
@@ -13632,8 +13915,8 @@
case UPB_TYPE_STRING: {
upb_selector_t sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR);
- p->top--;
upb_sink_endstr(&p->top->sink, sel);
+ p->top--;
break;
}
@@ -13682,6 +13965,16 @@
}
static bool end_stringval(upb_json_parser *p) {
+ /* FieldMask's stringvals have been ended when handling them. Only need to
+ * close FieldMask here.*/
+ if (does_fieldmask_end(p)) {
+ end_fieldmask_object(p);
+ if (!is_top_level(p)) {
+ end_subobject(p);
+ }
+ return true;
+ }
+
if (!end_stringval_nontop(p)) {
return false;
}
@@ -13703,7 +13996,8 @@
}
if (is_wellknown_msg(p, UPB_WELLKNOWN_TIMESTAMP) ||
- is_wellknown_msg(p, UPB_WELLKNOWN_DURATION)) {
+ is_wellknown_msg(p, UPB_WELLKNOWN_DURATION) ||
+ is_wellknown_msg(p, UPB_WELLKNOWN_FIELDMASK)) {
end_object(p);
if (!is_top_level(p)) {
end_subobject(p);
@@ -13966,6 +14260,75 @@
return true;
}
+static void start_fieldmask_path_text(upb_json_parser *p, const char *ptr) {
+ capture_begin(p, ptr);
+}
+
+static bool end_fieldmask_path_text(upb_json_parser *p, const char *ptr) {
+ if (!capture_end(p, ptr)) {
+ return false;
+ }
+}
+
+static bool start_fieldmask_path(upb_json_parser *p) {
+ upb_jsonparser_frame *inner;
+ upb_selector_t sel;
+
+ if (!check_stack(p)) return false;
+
+ /* 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;
+ 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_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);
+ return true;
+}
+
+static bool lower_camel_push(
+ upb_json_parser *p, upb_selector_t sel, const char *ptr, size_t len) {
+ const char *limit = ptr + len;
+ bool first = true;
+ 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);
+ } else {
+ upb_sink_putstring(&p->top->sink, sel, ptr, 1, NULL);
+ }
+ first = false;
+ }
+ return true;
+}
+
+static bool end_fieldmask_path(upb_json_parser *p) {
+ upb_selector_t sel;
+
+ if (!lower_camel_push(
+ p, getsel_for_handlertype(p, UPB_HANDLER_STRING),
+ p->accumulated, p->accumulated_len)) {
+ return false;
+ }
+
+ sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR);
+ upb_sink_endstr(&p->top->sink, sel);
+ p->top--;
+
+ multipart_end(p);
+ return true;
+}
+
static void start_member(upb_json_parser *p) {
UPB_ASSERT(!p->top->f);
multipart_startaccum(p);
@@ -14025,7 +14388,7 @@
sel = getsel_for_handlertype(p, UPB_HANDLER_STRING);
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(&subsink, sel);
multipart_end(p);
break;
}
@@ -14069,6 +14432,8 @@
inner->name_table = NULL;
inner->mapfield = mapfield;
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
@@ -14105,7 +14470,9 @@
return true;
}
- if (p->top->is_map) {
+ if (p->top->is_any) {
+ return end_any_membername(p);
+ } else if (p->top->is_map) {
return handle_mapentry(p);
} else {
size_t len;
@@ -14129,6 +14496,23 @@
}
}
+static bool end_any_membername(upb_json_parser *p) {
+ size_t len;
+ const char *buf = accumulate_getptr(p, &len);
+ upb_value v;
+
+ if (len == 5 && strncmp(buf, "@type", len) == 0) {
+ upb_strtable_lookup2(p->top->name_table, "type_url", 8, &v);
+ p->top->f = upb_value_getconstptr(v);
+ multipart_end(p);
+ return true;
+ } else {
+ p->top->is_unknown_field = true;
+ multipart_end(p);
+ return true;
+ }
+}
+
static void end_member(upb_json_parser *p) {
/* If we just parsed a map-entry value, end that frame too. */
if (p->top->is_mapentry) {
@@ -14153,6 +14537,16 @@
p->top->is_unknown_field = false;
}
+static void start_any_member(upb_json_parser *p, const char *ptr) {
+ start_member(p);
+ json_parser_any_frame_set_after_type_url_start_once(p->top->any_frame, ptr);
+}
+
+static void end_any_member(upb_json_parser *p, const char *ptr) {
+ json_parser_any_frame_set_before_type_url_end(p->top->any_frame, ptr);
+ end_member(p);
+}
+
static bool start_subobject(upb_json_parser *p) {
if (p->top->is_unknown_field) {
upb_jsonparser_frame *inner;
@@ -14163,6 +14557,8 @@
inner->f = NULL;
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;
@@ -14185,6 +14581,8 @@
inner->f = NULL;
inner->is_map = true;
inner->is_mapentry = false;
+ inner->is_any = false;
+ inner->any_frame = NULL;
inner->is_unknown_field = false;
p->top = inner;
@@ -14209,6 +14607,16 @@
inner->is_unknown_field = false;
p->top = inner;
+ if (is_wellknown_msg(p, UPB_WELLKNOWN_ANY)) {
+ p->top->is_any = true;
+ p->top->any_frame =
+ upb_env_malloc(p->env, sizeof(upb_jsonparser_any_frame));
+ json_parser_any_frame_reset(p->top->any_frame);
+ } else {
+ p->top->is_any = false;
+ p->top->any_frame = NULL;
+ }
+
return true;
} else {
upb_status_seterrf(&p->status,
@@ -14313,6 +14721,8 @@
inner->f = NULL;
inner->is_map = false;
inner->is_mapentry = false;
+ inner->is_any = false;
+ inner->any_frame = NULL;
inner->is_unknown_field = true;
p->top = inner;
@@ -14337,6 +14747,8 @@
inner->f = p->top->f;
inner->is_map = false;
inner->is_mapentry = false;
+ inner->is_any = false;
+ inner->any_frame = NULL;
inner->is_unknown_field = false;
p->top = inner;
@@ -14389,12 +14801,160 @@
}
}
+static void start_any_object(upb_json_parser *p, const char *ptr) {
+ start_object(p);
+ p->top->any_frame->before_type_url_start = ptr;
+ p->top->any_frame->before_type_url_end = ptr;
+}
+
+static bool end_any_object(upb_json_parser *p, const char *ptr) {
+ const char *value_membername = "value";
+ bool is_well_known_packed = false;
+ const char *packed_end = ptr + 1;
+ upb_selector_t sel;
+ upb_jsonparser_frame *inner;
+
+ if (json_parser_any_frame_has_value(p->top->any_frame) &&
+ !json_parser_any_frame_has_type_url(p->top->any_frame)) {
+ upb_status_seterrmsg(&p->status, "No valid type url");
+ upb_env_reporterror(p->env, &p->status);
+ return false;
+ }
+
+ /* Well known types data is represented as value field. */
+ if (upb_msgdef_wellknowntype(p->top->any_frame->parser->top->m) !=
+ UPB_WELLKNOWN_UNSPECIFIED) {
+ is_well_known_packed = true;
+
+ if (json_parser_any_frame_has_value_before_type_url(p->top->any_frame)) {
+ p->top->any_frame->before_type_url_start =
+ memchr(p->top->any_frame->before_type_url_start, ':',
+ p->top->any_frame->before_type_url_end -
+ p->top->any_frame->before_type_url_start);
+ if (p->top->any_frame->before_type_url_start == NULL) {
+ upb_status_seterrmsg(&p->status, "invalid data for well known type.");
+ upb_env_reporterror(p->env, &p->status);
+ return false;
+ }
+ p->top->any_frame->before_type_url_start++;
+ }
+
+ if (json_parser_any_frame_has_value_after_type_url(p->top->any_frame)) {
+ p->top->any_frame->after_type_url_start =
+ memchr(p->top->any_frame->after_type_url_start, ':',
+ (ptr + 1) -
+ p->top->any_frame->after_type_url_start);
+ if (p->top->any_frame->after_type_url_start == NULL) {
+ upb_status_seterrmsg(&p->status, "Invalid data for well known type.");
+ upb_env_reporterror(p->env, &p->status);
+ return false;
+ }
+ p->top->any_frame->after_type_url_start++;
+ packed_end = ptr;
+ }
+ }
+
+ if (json_parser_any_frame_has_value_before_type_url(p->top->any_frame)) {
+ if (!parse(p->top->any_frame->parser, NULL,
+ p->top->any_frame->before_type_url_start,
+ p->top->any_frame->before_type_url_end -
+ p->top->any_frame->before_type_url_start, NULL)) {
+ return false;
+ }
+ } else {
+ if (!is_well_known_packed) {
+ if (!parse(p->top->any_frame->parser, NULL, "{", 1, NULL)) {
+ return false;
+ }
+ }
+ }
+
+ if (json_parser_any_frame_has_value_before_type_url(p->top->any_frame) &&
+ json_parser_any_frame_has_value_after_type_url(p->top->any_frame)) {
+ if (!parse(p->top->any_frame->parser, NULL, ",", 1, NULL)) {
+ return false;
+ }
+ }
+
+ if (json_parser_any_frame_has_value_after_type_url(p->top->any_frame)) {
+ if (!parse(p->top->any_frame->parser, NULL,
+ p->top->any_frame->after_type_url_start,
+ packed_end - p->top->any_frame->after_type_url_start, NULL)) {
+ return false;
+ }
+ } else {
+ if (!is_well_known_packed) {
+ if (!parse(p->top->any_frame->parser, NULL, "}", 1, NULL)) {
+ return false;
+ }
+ }
+ }
+
+ if (!end(p->top->any_frame->parser, NULL)) {
+ return false;
+ }
+
+ p->top->is_any = false;
+
+ /* Set value */
+ start_member(p);
+ capture_begin(p, value_membername);
+ capture_end(p, value_membername + 5);
+ end_membername(p);
+
+ if (!check_stack(p)) return false;
+ inner = p->top + 1;
+
+ sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR);
+ 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,
+ p->top->any_frame->stringsink.len, NULL);
+ sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR);
+ upb_sink_endstr(&inner->sink, sel);
+
+ end_member(p);
+
+ end_object(p);
+
+ /* Deallocate any parse frame. */
+ json_parser_any_frame_free(p->top->any_frame);
+ upb_env_free(p->env, p->top->any_frame);
+
+ return true;
+}
+
static bool is_string_wrapper(const upb_msgdef *m) {
upb_wellknowntype_t type = upb_msgdef_wellknowntype(m);
return type == UPB_WELLKNOWN_STRINGVALUE ||
type == UPB_WELLKNOWN_BYTESVALUE;
}
+static bool is_fieldmask(const upb_msgdef *m) {
+ upb_wellknowntype_t type = upb_msgdef_wellknowntype(m);
+ return type == UPB_WELLKNOWN_FIELDMASK;
+}
+
+static void start_fieldmask_object(upb_json_parser *p) {
+ const char *membername = "paths";
+
+ start_object(p);
+
+ /* Set up context for parsing value */
+ start_member(p);
+ capture_begin(p, membername);
+ capture_end(p, membername + 5);
+ end_membername(p);
+
+ start_array(p);
+}
+
+static void end_fieldmask_object(upb_json_parser *p) {
+ end_array(p);
+ end_member(p);
+ end_object(p);
+}
+
static void start_wrapper_object(upb_json_parser *p) {
const char *membername = "value";
@@ -14533,6 +15093,20 @@
return p->top->m != NULL && is_string_wrapper(p->top->m);
}
+static bool does_fieldmask_start(upb_json_parser *p) {
+ return p->top->f != NULL &&
+ upb_fielddef_issubmsg(p->top->f) &&
+ is_fieldmask(upb_fielddef_msgsubdef(p->top->f));
+}
+
+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
@@ -14554,44 +15128,45 @@
* final state once, when the closing '"' is seen. */
-//#line 2147 "upb/json/parser.rl"
+#line 2730 "upb/json/parser.rl"
-//#line 2016 "upb/json/parser.c"
+#line 2556 "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,
9, 1, 10, 1, 11, 1, 12, 1,
- 13, 1, 21, 1, 23, 1, 24, 1,
- 25, 1, 27, 1, 28, 1, 30, 1,
- 32, 1, 33, 1, 34, 1, 35, 1,
- 36, 1, 38, 2, 4, 9, 2, 5,
- 6, 2, 7, 3, 2, 7, 9, 2,
- 14, 15, 2, 16, 17, 2, 18, 19,
- 2, 22, 20, 2, 26, 37, 2, 29,
- 2, 2, 30, 38, 2, 31, 20, 2,
- 33, 38, 2, 34, 38, 2, 35, 38,
- 3, 25, 22, 20, 3, 26, 37, 38,
- 4, 14, 15, 16, 17
+ 13, 1, 24, 1, 26, 1, 28, 1,
+ 29, 1, 31, 1, 32, 1, 33, 1,
+ 35, 1, 37, 1, 38, 1, 39, 1,
+ 40, 1, 42, 1, 43, 2, 4, 9,
+ 2, 5, 6, 2, 7, 3, 2, 7,
+ 9, 2, 14, 15, 2, 16, 17, 2,
+ 18, 19, 2, 21, 23, 2, 22, 20,
+ 2, 27, 25, 2, 29, 31, 2, 34,
+ 2, 2, 35, 43, 2, 36, 25, 2,
+ 38, 43, 2, 39, 43, 2, 40, 43,
+ 2, 41, 30, 2, 42, 43, 3, 21,
+ 23, 24, 4, 14, 15, 16, 17
};
static const short _json_key_offsets[] = {
0, 0, 12, 13, 18, 23, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37,
- 38, 43, 48, 49, 53, 58, 63, 68,
- 72, 76, 79, 82, 84, 88, 92, 94,
- 96, 101, 103, 105, 114, 120, 126, 132,
- 138, 140, 144, 147, 149, 151, 154, 155,
- 159, 161, 163, 165, 167, 168, 170, 172,
- 173, 175, 177, 178, 180, 182, 183, 185,
- 187, 188, 190, 192, 196, 198, 200, 201,
- 202, 203, 204, 206, 211, 220, 221, 221,
- 221, 226, 231, 236, 237, 238, 239, 240,
- 240, 241, 242, 243, 243, 244, 245, 246,
- 246, 251, 256, 257, 261, 266, 271, 276,
- 280, 280, 283, 286, 289, 292, 295, 298,
- 298, 298, 298, 298
+ 38, 43, 44, 48, 53, 58, 63, 67,
+ 71, 74, 77, 79, 83, 87, 89, 91,
+ 96, 98, 100, 109, 115, 121, 127, 133,
+ 135, 139, 142, 144, 146, 149, 150, 154,
+ 156, 158, 160, 162, 163, 165, 167, 168,
+ 170, 172, 173, 175, 177, 178, 180, 182,
+ 183, 185, 187, 191, 193, 195, 196, 197,
+ 198, 199, 201, 206, 208, 210, 212, 221,
+ 222, 222, 222, 227, 232, 237, 238, 239,
+ 240, 241, 241, 242, 243, 244, 244, 245,
+ 246, 247, 247, 252, 253, 257, 262, 267,
+ 272, 276, 276, 279, 282, 285, 288, 291,
+ 294, 294, 294, 294, 294, 294
};
static const char _json_trans_keys[] = {
@@ -14600,93 +15175,92 @@
9, 13, 32, 44, 93, 9, 13, 32,
93, 125, 9, 13, 97, 108, 115, 101,
117, 108, 108, 114, 117, 101, 32, 34,
- 125, 9, 13, 32, 34, 125, 9, 13,
- 34, 32, 58, 9, 13, 32, 93, 125,
+ 125, 9, 13, 34, 32, 58, 9, 13,
+ 32, 93, 125, 9, 13, 32, 44, 125,
9, 13, 32, 44, 125, 9, 13, 32,
- 44, 125, 9, 13, 32, 34, 9, 13,
- 45, 48, 49, 57, 48, 49, 57, 46,
- 69, 101, 48, 57, 69, 101, 48, 57,
- 43, 45, 48, 57, 48, 57, 48, 57,
- 46, 69, 101, 48, 57, 34, 92, 34,
- 92, 34, 47, 92, 98, 102, 110, 114,
- 116, 117, 48, 57, 65, 70, 97, 102,
- 48, 57, 65, 70, 97, 102, 48, 57,
- 65, 70, 97, 102, 48, 57, 65, 70,
- 97, 102, 34, 92, 45, 48, 49, 57,
- 48, 49, 57, 46, 115, 48, 57, 115,
- 48, 57, 34, 46, 115, 48, 57, 48,
- 57, 48, 57, 48, 57, 48, 57, 45,
- 48, 57, 48, 57, 45, 48, 57, 48,
- 57, 84, 48, 57, 48, 57, 58, 48,
- 57, 48, 57, 58, 48, 57, 48, 57,
- 43, 45, 46, 90, 48, 57, 48, 57,
- 58, 48, 48, 34, 48, 57, 43, 45,
- 90, 48, 57, 34, 45, 91, 102, 110,
- 116, 123, 48, 57, 34, 32, 93, 125,
- 9, 13, 32, 44, 93, 9, 13, 32,
- 93, 125, 9, 13, 97, 108, 115, 101,
- 117, 108, 108, 114, 117, 101, 32, 34,
- 125, 9, 13, 32, 34, 125, 9, 13,
- 34, 32, 58, 9, 13, 32, 93, 125,
- 9, 13, 32, 44, 125, 9, 13, 32,
- 44, 125, 9, 13, 32, 34, 9, 13,
- 32, 9, 13, 32, 9, 13, 32, 9,
- 13, 32, 9, 13, 32, 9, 13, 32,
- 9, 13, 0
+ 34, 9, 13, 45, 48, 49, 57, 48,
+ 49, 57, 46, 69, 101, 48, 57, 69,
+ 101, 48, 57, 43, 45, 48, 57, 48,
+ 57, 48, 57, 46, 69, 101, 48, 57,
+ 34, 92, 34, 92, 34, 47, 92, 98,
+ 102, 110, 114, 116, 117, 48, 57, 65,
+ 70, 97, 102, 48, 57, 65, 70, 97,
+ 102, 48, 57, 65, 70, 97, 102, 48,
+ 57, 65, 70, 97, 102, 34, 92, 45,
+ 48, 49, 57, 48, 49, 57, 46, 115,
+ 48, 57, 115, 48, 57, 34, 46, 115,
+ 48, 57, 48, 57, 48, 57, 48, 57,
+ 48, 57, 45, 48, 57, 48, 57, 45,
+ 48, 57, 48, 57, 84, 48, 57, 48,
+ 57, 58, 48, 57, 48, 57, 58, 48,
+ 57, 48, 57, 43, 45, 46, 90, 48,
+ 57, 48, 57, 58, 48, 48, 34, 48,
+ 57, 43, 45, 90, 48, 57, 34, 44,
+ 34, 44, 34, 44, 34, 45, 91, 102,
+ 110, 116, 123, 48, 57, 34, 32, 93,
+ 125, 9, 13, 32, 44, 93, 9, 13,
+ 32, 93, 125, 9, 13, 97, 108, 115,
+ 101, 117, 108, 108, 114, 117, 101, 32,
+ 34, 125, 9, 13, 34, 32, 58, 9,
+ 13, 32, 93, 125, 9, 13, 32, 44,
+ 125, 9, 13, 32, 44, 125, 9, 13,
+ 32, 34, 9, 13, 32, 9, 13, 32,
+ 9, 13, 32, 9, 13, 32, 9, 13,
+ 32, 9, 13, 32, 9, 13, 0
};
static const char _json_single_lengths[] = {
0, 8, 1, 3, 3, 3, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
- 3, 3, 1, 2, 3, 3, 3, 2,
- 2, 1, 3, 0, 2, 2, 0, 0,
- 3, 2, 2, 9, 0, 0, 0, 0,
- 2, 2, 1, 2, 0, 1, 1, 2,
- 0, 0, 0, 0, 1, 0, 0, 1,
- 0, 0, 1, 0, 0, 1, 0, 0,
- 1, 0, 0, 4, 0, 0, 1, 1,
- 1, 1, 0, 3, 7, 1, 0, 0,
- 3, 3, 3, 1, 1, 1, 1, 0,
- 1, 1, 1, 0, 1, 1, 1, 0,
- 3, 3, 1, 2, 3, 3, 3, 2,
- 0, 1, 1, 1, 1, 1, 1, 0,
- 0, 0, 0, 0
+ 3, 1, 2, 3, 3, 3, 2, 2,
+ 1, 3, 0, 2, 2, 0, 0, 3,
+ 2, 2, 9, 0, 0, 0, 0, 2,
+ 2, 1, 2, 0, 1, 1, 2, 0,
+ 0, 0, 0, 1, 0, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0, 0, 1,
+ 0, 0, 4, 0, 0, 1, 1, 1,
+ 1, 0, 3, 2, 2, 2, 7, 1,
+ 0, 0, 3, 3, 3, 1, 1, 1,
+ 1, 0, 1, 1, 1, 0, 1, 1,
+ 1, 0, 3, 1, 2, 3, 3, 3,
+ 2, 0, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0
};
static const char _json_range_lengths[] = {
0, 2, 0, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 0, 1, 1, 1, 1, 1,
- 1, 1, 0, 1, 1, 1, 1, 1,
- 1, 0, 0, 0, 3, 3, 3, 3,
- 0, 1, 1, 0, 1, 1, 0, 1,
- 1, 1, 1, 1, 0, 1, 1, 0,
+ 1, 0, 1, 1, 1, 1, 1, 1,
+ 1, 0, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 3, 3, 3, 3, 0,
1, 1, 0, 1, 1, 0, 1, 1,
- 0, 1, 1, 0, 1, 1, 0, 0,
+ 1, 1, 1, 0, 1, 1, 0, 1,
+ 1, 0, 1, 1, 0, 1, 1, 0,
+ 1, 1, 0, 1, 1, 0, 0, 0,
+ 0, 1, 1, 0, 0, 0, 1, 0,
0, 0, 1, 1, 1, 0, 0, 0,
- 1, 1, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 0, 1, 1, 1, 1, 1,
- 0, 1, 1, 1, 1, 1, 1, 0,
- 0, 0, 0, 0
+ 0, 0, 1, 0, 1, 1, 1, 1,
+ 1, 0, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0
};
static const short _json_index_offsets[] = {
0, 0, 11, 13, 18, 23, 28, 30,
32, 34, 36, 38, 40, 42, 44, 46,
- 48, 53, 58, 60, 64, 69, 74, 79,
- 83, 87, 90, 94, 96, 100, 104, 106,
- 108, 113, 116, 119, 129, 133, 137, 141,
- 145, 148, 152, 155, 158, 160, 163, 165,
- 169, 171, 173, 175, 177, 179, 181, 183,
- 185, 187, 189, 191, 193, 195, 197, 199,
- 201, 203, 205, 207, 212, 214, 216, 218,
- 220, 222, 224, 226, 231, 240, 242, 243,
- 244, 249, 254, 259, 261, 263, 265, 267,
- 268, 270, 272, 274, 275, 277, 279, 281,
- 282, 287, 292, 294, 298, 303, 308, 313,
- 317, 318, 321, 324, 327, 330, 333, 336,
- 337, 338, 339, 340
+ 48, 53, 55, 59, 64, 69, 74, 78,
+ 82, 85, 89, 91, 95, 99, 101, 103,
+ 108, 111, 114, 124, 128, 132, 136, 140,
+ 143, 147, 150, 153, 155, 158, 160, 164,
+ 166, 168, 170, 172, 174, 176, 178, 180,
+ 182, 184, 186, 188, 190, 192, 194, 196,
+ 198, 200, 202, 207, 209, 211, 213, 215,
+ 217, 219, 221, 226, 229, 232, 235, 244,
+ 246, 247, 248, 253, 258, 263, 265, 267,
+ 269, 271, 272, 274, 276, 278, 279, 281,
+ 283, 285, 286, 291, 293, 297, 302, 307,
+ 312, 316, 317, 320, 323, 326, 329, 332,
+ 335, 336, 337, 338, 339, 340
};
static const unsigned char _json_indicies[] = {
@@ -14696,97 +15270,96 @@
1, 1, 14, 10, 15, 1, 16, 1,
17, 1, 18, 1, 19, 1, 20, 1,
21, 1, 22, 1, 23, 1, 24, 1,
- 25, 26, 27, 25, 1, 28, 29, 30,
- 28, 1, 31, 1, 32, 33, 32, 1,
- 33, 1, 1, 33, 34, 35, 36, 37,
- 35, 1, 38, 39, 30, 38, 1, 39,
- 29, 39, 1, 40, 41, 42, 1, 41,
- 42, 1, 44, 45, 45, 43, 46, 1,
- 45, 45, 46, 43, 47, 47, 48, 1,
- 48, 1, 48, 43, 44, 45, 45, 42,
- 43, 50, 51, 49, 53, 54, 52, 55,
- 55, 55, 55, 55, 55, 55, 55, 56,
- 1, 57, 57, 57, 1, 58, 58, 58,
- 1, 59, 59, 59, 1, 60, 60, 60,
- 1, 62, 63, 61, 64, 65, 66, 1,
- 67, 68, 1, 69, 70, 1, 71, 1,
- 70, 71, 1, 72, 1, 69, 70, 68,
- 1, 73, 1, 74, 1, 75, 1, 76,
- 1, 77, 1, 78, 1, 79, 1, 80,
- 1, 81, 1, 82, 1, 83, 1, 84,
- 1, 85, 1, 86, 1, 87, 1, 88,
- 1, 89, 1, 90, 1, 91, 1, 92,
- 92, 93, 94, 1, 95, 1, 96, 1,
- 97, 1, 98, 1, 99, 1, 100, 1,
- 101, 1, 102, 102, 103, 101, 1, 104,
- 105, 106, 107, 108, 109, 110, 105, 1,
- 111, 1, 112, 113, 115, 116, 1, 115,
- 114, 117, 118, 116, 117, 1, 118, 1,
- 1, 118, 114, 119, 1, 120, 1, 121,
- 1, 122, 1, 123, 124, 1, 125, 1,
- 126, 1, 127, 128, 1, 129, 1, 130,
- 1, 131, 132, 133, 134, 132, 1, 135,
- 136, 137, 135, 1, 138, 1, 139, 140,
- 139, 1, 140, 1, 1, 140, 141, 142,
- 143, 144, 142, 1, 145, 146, 137, 145,
- 1, 146, 136, 146, 1, 147, 148, 148,
- 1, 149, 149, 1, 150, 150, 1, 151,
- 151, 1, 152, 152, 1, 153, 153, 1,
+ 25, 26, 27, 25, 1, 28, 1, 29,
+ 30, 29, 1, 30, 1, 1, 30, 31,
+ 32, 33, 34, 32, 1, 35, 36, 27,
+ 35, 1, 36, 26, 36, 1, 37, 38,
+ 39, 1, 38, 39, 1, 41, 42, 42,
+ 40, 43, 1, 42, 42, 43, 40, 44,
+ 44, 45, 1, 45, 1, 45, 40, 41,
+ 42, 42, 39, 40, 47, 48, 46, 50,
+ 51, 49, 52, 52, 52, 52, 52, 52,
+ 52, 52, 53, 1, 54, 54, 54, 1,
+ 55, 55, 55, 1, 56, 56, 56, 1,
+ 57, 57, 57, 1, 59, 60, 58, 61,
+ 62, 63, 1, 64, 65, 1, 66, 67,
+ 1, 68, 1, 67, 68, 1, 69, 1,
+ 66, 67, 65, 1, 70, 1, 71, 1,
+ 72, 1, 73, 1, 74, 1, 75, 1,
+ 76, 1, 77, 1, 78, 1, 79, 1,
+ 80, 1, 81, 1, 82, 1, 83, 1,
+ 84, 1, 85, 1, 86, 1, 87, 1,
+ 88, 1, 89, 89, 90, 91, 1, 92,
+ 1, 93, 1, 94, 1, 95, 1, 96,
+ 1, 97, 1, 98, 1, 99, 99, 100,
+ 98, 1, 102, 1, 101, 104, 105, 103,
+ 1, 1, 101, 106, 107, 108, 109, 110,
+ 111, 112, 107, 1, 113, 1, 114, 115,
+ 117, 118, 1, 117, 116, 119, 120, 118,
+ 119, 1, 120, 1, 1, 120, 116, 121,
+ 1, 122, 1, 123, 1, 124, 1, 125,
+ 126, 1, 127, 1, 128, 1, 129, 130,
+ 1, 131, 1, 132, 1, 133, 134, 135,
+ 136, 134, 1, 137, 1, 138, 139, 138,
+ 1, 139, 1, 1, 139, 140, 141, 142,
+ 143, 141, 1, 144, 145, 136, 144, 1,
+ 145, 135, 145, 1, 146, 147, 147, 1,
+ 148, 148, 1, 149, 149, 1, 150, 150,
+ 1, 151, 151, 1, 152, 152, 1, 1,
1, 1, 1, 1, 1, 0
};
static const char _json_trans_targs[] = {
- 1, 0, 2, 106, 3, 6, 10, 13,
- 16, 105, 4, 3, 105, 4, 5, 7,
- 8, 9, 107, 11, 12, 108, 14, 15,
- 109, 17, 18, 110, 17, 18, 110, 19,
- 19, 20, 21, 22, 23, 110, 22, 23,
- 25, 26, 32, 111, 27, 29, 28, 30,
- 31, 34, 112, 35, 34, 112, 35, 33,
- 36, 37, 38, 39, 40, 34, 112, 35,
- 42, 43, 47, 43, 47, 44, 46, 45,
- 113, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 74, 73, 69,
- 70, 71, 72, 73, 114, 75, 68, 73,
- 77, 79, 80, 83, 88, 92, 96, 78,
- 115, 115, 81, 80, 78, 81, 82, 84,
- 85, 86, 87, 115, 89, 90, 91, 115,
- 93, 94, 95, 115, 97, 98, 104, 97,
- 98, 104, 99, 99, 100, 101, 102, 103,
- 104, 102, 103, 115, 105, 105, 105, 105,
- 105, 105
+ 1, 0, 2, 107, 3, 6, 10, 13,
+ 16, 106, 4, 3, 106, 4, 5, 7,
+ 8, 9, 108, 11, 12, 109, 14, 15,
+ 110, 16, 17, 111, 18, 18, 19, 20,
+ 21, 22, 111, 21, 22, 24, 25, 31,
+ 112, 26, 28, 27, 29, 30, 33, 113,
+ 34, 33, 113, 34, 32, 35, 36, 37,
+ 38, 39, 33, 113, 34, 41, 42, 46,
+ 42, 46, 43, 45, 44, 114, 48, 49,
+ 50, 51, 52, 53, 54, 55, 56, 57,
+ 58, 59, 60, 61, 62, 63, 64, 65,
+ 66, 67, 73, 72, 68, 69, 70, 71,
+ 72, 115, 74, 67, 72, 76, 116, 76,
+ 116, 77, 79, 81, 82, 85, 90, 94,
+ 98, 80, 117, 117, 83, 82, 80, 83,
+ 84, 86, 87, 88, 89, 117, 91, 92,
+ 93, 117, 95, 96, 97, 117, 98, 99,
+ 105, 100, 100, 101, 102, 103, 104, 105,
+ 103, 104, 117, 106, 106, 106, 106, 106,
+ 106
};
static const char _json_trans_actions[] = {
- 0, 0, 84, 78, 33, 0, 0, 0,
- 47, 39, 25, 0, 35, 0, 0, 0,
+ 0, 0, 92, 86, 35, 0, 0, 0,
+ 104, 41, 27, 0, 37, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 31, 96, 31, 0, 72, 0, 27,
- 0, 0, 25, 29, 29, 29, 0, 0,
- 0, 0, 0, 3, 0, 0, 0, 0,
- 0, 5, 15, 0, 0, 51, 7, 13,
- 0, 54, 9, 9, 9, 57, 60, 11,
- 17, 17, 17, 0, 0, 0, 19, 0,
- 21, 23, 0, 0, 0, 0, 0, 0,
+ 0, 0, 80, 33, 29, 0, 0, 27,
+ 31, 31, 83, 0, 0, 0, 0, 0,
+ 3, 0, 0, 0, 0, 0, 5, 15,
+ 0, 0, 53, 7, 13, 0, 56, 9,
+ 9, 9, 59, 62, 11, 17, 17, 17,
+ 0, 0, 0, 19, 0, 21, 23, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 104, 63, 104, 0,
- 0, 0, 0, 0, 69, 0, 66, 66,
- 84, 78, 33, 0, 0, 0, 47, 39,
- 49, 81, 25, 0, 35, 0, 0, 0,
- 0, 0, 0, 90, 0, 0, 0, 93,
- 0, 0, 0, 87, 31, 96, 31, 0,
- 72, 0, 27, 0, 0, 25, 29, 29,
- 29, 0, 0, 100, 0, 37, 43, 45,
- 41, 75
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 114, 65, 114, 0, 0, 0, 0,
+ 0, 71, 0, 68, 68, 77, 25, 0,
+ 110, 74, 92, 86, 35, 0, 0, 0,
+ 104, 41, 51, 89, 27, 0, 37, 0,
+ 0, 0, 0, 0, 0, 98, 0, 0,
+ 0, 101, 0, 0, 0, 95, 0, 80,
+ 33, 29, 0, 0, 27, 31, 31, 83,
+ 0, 0, 107, 0, 39, 45, 47, 43,
+ 49
};
static const char _json_eof_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 1, 0, 1, 0, 0, 1,
- 1, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 0, 1, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -14795,21 +15368,23 @@
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 37, 43, 45, 41, 75, 0,
- 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 39, 45, 47, 43, 49,
+ 0, 0, 0, 0, 0, 0
};
static const int json_start = 1;
-static const int json_en_number_machine = 24;
-static const int json_en_string_machine = 33;
-static const int json_en_duration_machine = 41;
-static const int json_en_timestamp_machine = 48;
-static const int json_en_value_machine = 76;
+static const int json_en_number_machine = 23;
+static const int json_en_string_machine = 32;
+static const int json_en_duration_machine = 40;
+static const int json_en_timestamp_machine = 47;
+static const int json_en_fieldmask_machine = 75;
+static const int json_en_value_machine = 78;
static const int json_en_main = 1;
-//#line 2150 "upb/json/parser.rl"
+#line 2733 "upb/json/parser.rl"
size_t parse(void *closure, const void *hd, const char *buf, size_t size,
const upb_bufhandle *handle) {
@@ -14832,7 +15407,7 @@
capture_resume(parser, buf);
-//#line 2290 "upb/json/parser.c"
+#line 2831 "upb/json/parser.c"
{
int _klen;
unsigned int _trans;
@@ -14907,166 +15482,212 @@
switch ( *_acts++ )
{
case 1:
-//#line 2021 "upb/json/parser.rl"
+#line 2561 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
case 2:
-//#line 2023 "upb/json/parser.rl"
- { p--; {stack[top++] = cs; cs = 24; goto _again;} }
+#line 2563 "upb/json/parser.rl"
+ { p--; {stack[top++] = cs; cs = 23;goto _again;} }
break;
case 3:
-//#line 2027 "upb/json/parser.rl"
+#line 2567 "upb/json/parser.rl"
{ start_text(parser, p); }
break;
case 4:
-//#line 2028 "upb/json/parser.rl"
+#line 2568 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_text(parser, p)); }
break;
case 5:
-//#line 2034 "upb/json/parser.rl"
+#line 2574 "upb/json/parser.rl"
{ start_hex(parser); }
break;
case 6:
-//#line 2035 "upb/json/parser.rl"
+#line 2575 "upb/json/parser.rl"
{ hexdigit(parser, p); }
break;
case 7:
-//#line 2036 "upb/json/parser.rl"
+#line 2576 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_hex(parser)); }
break;
case 8:
-//#line 2042 "upb/json/parser.rl"
+#line 2582 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(escape(parser, p)); }
break;
case 9:
-//#line 2048 "upb/json/parser.rl"
+#line 2588 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
case 10:
-//#line 2060 "upb/json/parser.rl"
+#line 2600 "upb/json/parser.rl"
{ start_duration_base(parser, p); }
break;
case 11:
-//#line 2061 "upb/json/parser.rl"
+#line 2601 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_duration_base(parser, p)); }
break;
case 12:
-//#line 2063 "upb/json/parser.rl"
+#line 2603 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
case 13:
-//#line 2068 "upb/json/parser.rl"
+#line 2608 "upb/json/parser.rl"
{ start_timestamp_base(parser, p); }
break;
case 14:
-//#line 2069 "upb/json/parser.rl"
+#line 2609 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_timestamp_base(parser, p)); }
break;
case 15:
-//#line 2071 "upb/json/parser.rl"
+#line 2611 "upb/json/parser.rl"
{ start_timestamp_fraction(parser, p); }
break;
case 16:
-//#line 2072 "upb/json/parser.rl"
+#line 2612 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_timestamp_fraction(parser, p)); }
break;
case 17:
-//#line 2074 "upb/json/parser.rl"
+#line 2614 "upb/json/parser.rl"
{ start_timestamp_zone(parser, p); }
break;
case 18:
-//#line 2075 "upb/json/parser.rl"
+#line 2615 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_timestamp_zone(parser, p)); }
break;
case 19:
-//#line 2077 "upb/json/parser.rl"
+#line 2617 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
case 20:
-//#line 2082 "upb/json/parser.rl"
+#line 2622 "upb/json/parser.rl"
+ { start_fieldmask_path_text(parser, p); }
+ break;
+ case 21:
+#line 2623 "upb/json/parser.rl"
+ { end_fieldmask_path_text(parser, p); }
+ break;
+ case 22:
+#line 2628 "upb/json/parser.rl"
+ { start_fieldmask_path(parser); }
+ break;
+ case 23:
+#line 2629 "upb/json/parser.rl"
+ { end_fieldmask_path(parser); }
+ break;
+ case 24:
+#line 2635 "upb/json/parser.rl"
+ { p--; {cs = stack[--top]; goto _again;} }
+ break;
+ case 25:
+#line 2640 "upb/json/parser.rl"
{
if (is_wellknown_msg(parser, UPB_WELLKNOWN_TIMESTAMP)) {
- {stack[top++] = cs; cs = 48; goto _again;}
+ {stack[top++] = cs; cs = 47;goto _again;}
} else if (is_wellknown_msg(parser, UPB_WELLKNOWN_DURATION)) {
- {stack[top++] = cs; cs = 41; goto _again;}
+ {stack[top++] = cs; cs = 40;goto _again;}
+ } else if (is_wellknown_msg(parser, UPB_WELLKNOWN_FIELDMASK)) {
+ {stack[top++] = cs; cs = 75;goto _again;}
} else {
- {stack[top++] = cs; cs = 33; goto _again;}
+ {stack[top++] = cs; cs = 32;goto _again;}
}
}
break;
- case 21:
-//#line 2093 "upb/json/parser.rl"
- { p--; {stack[top++] = cs; cs = 76; goto _again;} }
- break;
- case 22:
-//#line 2098 "upb/json/parser.rl"
- { start_member(parser); }
- break;
- case 23:
-//#line 2099 "upb/json/parser.rl"
- { CHECK_RETURN_TOP(end_membername(parser)); }
- break;
- case 24:
-//#line 2102 "upb/json/parser.rl"
- { end_member(parser); }
- break;
- case 25:
-//#line 2108 "upb/json/parser.rl"
- { start_object(parser); }
- break;
case 26:
-//#line 2111 "upb/json/parser.rl"
- { end_object(parser); }
+#line 2653 "upb/json/parser.rl"
+ { p--; {stack[top++] = cs; cs = 78;goto _again;} }
break;
case 27:
-//#line 2117 "upb/json/parser.rl"
- { CHECK_RETURN_TOP(start_array(parser)); }
+#line 2658 "upb/json/parser.rl"
+ {
+ if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
+ start_any_member(parser, p);
+ } else {
+ start_member(parser);
+ }
+ }
break;
case 28:
-//#line 2121 "upb/json/parser.rl"
- { end_array(parser); }
+#line 2665 "upb/json/parser.rl"
+ { CHECK_RETURN_TOP(end_membername(parser)); }
break;
case 29:
-//#line 2126 "upb/json/parser.rl"
- { CHECK_RETURN_TOP(start_number(parser, p)); }
+#line 2668 "upb/json/parser.rl"
+ {
+ if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
+ end_any_member(parser, p);
+ } else {
+ end_member(parser);
+ }
+ }
break;
case 30:
-//#line 2127 "upb/json/parser.rl"
- { CHECK_RETURN_TOP(end_number(parser, p)); }
+#line 2679 "upb/json/parser.rl"
+ {
+ if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
+ start_any_object(parser, p);
+ } else {
+ start_object(parser);
+ }
+ }
break;
case 31:
-//#line 2129 "upb/json/parser.rl"
- { CHECK_RETURN_TOP(start_stringval(parser)); }
+#line 2688 "upb/json/parser.rl"
+ {
+ if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
+ CHECK_RETURN_TOP(end_any_object(parser, p));
+ } else {
+ end_object(parser);
+ }
+ }
break;
case 32:
-//#line 2130 "upb/json/parser.rl"
- { CHECK_RETURN_TOP(end_stringval(parser)); }
+#line 2700 "upb/json/parser.rl"
+ { CHECK_RETURN_TOP(start_array(parser)); }
break;
case 33:
-//#line 2132 "upb/json/parser.rl"
- { CHECK_RETURN_TOP(end_bool(parser, true)); }
+#line 2704 "upb/json/parser.rl"
+ { end_array(parser); }
break;
case 34:
-//#line 2134 "upb/json/parser.rl"
- { CHECK_RETURN_TOP(end_bool(parser, false)); }
+#line 2709 "upb/json/parser.rl"
+ { CHECK_RETURN_TOP(start_number(parser, p)); }
break;
case 35:
-//#line 2136 "upb/json/parser.rl"
- { CHECK_RETURN_TOP(end_null(parser)); }
+#line 2710 "upb/json/parser.rl"
+ { CHECK_RETURN_TOP(end_number(parser, p)); }
break;
case 36:
-//#line 2138 "upb/json/parser.rl"
- { CHECK_RETURN_TOP(start_subobject_full(parser)); }
+#line 2712 "upb/json/parser.rl"
+ { CHECK_RETURN_TOP(start_stringval(parser)); }
break;
case 37:
-//#line 2139 "upb/json/parser.rl"
- { end_subobject_full(parser); }
+#line 2713 "upb/json/parser.rl"
+ { CHECK_RETURN_TOP(end_stringval(parser)); }
break;
case 38:
-//#line 2144 "upb/json/parser.rl"
+#line 2715 "upb/json/parser.rl"
+ { CHECK_RETURN_TOP(end_bool(parser, true)); }
+ break;
+ case 39:
+#line 2717 "upb/json/parser.rl"
+ { CHECK_RETURN_TOP(end_bool(parser, false)); }
+ break;
+ case 40:
+#line 2719 "upb/json/parser.rl"
+ { CHECK_RETURN_TOP(end_null(parser)); }
+ break;
+ case 41:
+#line 2721 "upb/json/parser.rl"
+ { CHECK_RETURN_TOP(start_subobject_full(parser)); }
+ break;
+ case 42:
+#line 2722 "upb/json/parser.rl"
+ { end_subobject_full(parser); }
+ break;
+ case 43:
+#line 2727 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
-//#line 2524 "upb/json/parser.c"
+#line 3111 "upb/json/parser.c"
}
}
@@ -15083,34 +15704,32 @@
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 0:
-//#line 2019 "upb/json/parser.rl"
- { p--; {cs = stack[--top]; goto _again;} }
- break;
- case 26:
-//#line 2111 "upb/json/parser.rl"
- { end_object(parser); }
- break;
- case 30:
-//#line 2127 "upb/json/parser.rl"
- { CHECK_RETURN_TOP(end_number(parser, p)); }
- break;
- case 33:
-//#line 2132 "upb/json/parser.rl"
- { CHECK_RETURN_TOP(end_bool(parser, true)); }
- break;
- case 34:
-//#line 2134 "upb/json/parser.rl"
- { CHECK_RETURN_TOP(end_bool(parser, false)); }
+#line 2559 "upb/json/parser.rl"
+ { p--; {cs = stack[--top]; if ( p == pe )
+ goto _test_eof;
+goto _again;} }
break;
case 35:
-//#line 2136 "upb/json/parser.rl"
+#line 2710 "upb/json/parser.rl"
+ { CHECK_RETURN_TOP(end_number(parser, p)); }
+ break;
+ case 38:
+#line 2715 "upb/json/parser.rl"
+ { CHECK_RETURN_TOP(end_bool(parser, true)); }
+ break;
+ case 39:
+#line 2717 "upb/json/parser.rl"
+ { CHECK_RETURN_TOP(end_bool(parser, false)); }
+ break;
+ case 40:
+#line 2719 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_null(parser)); }
break;
- case 37:
-//#line 2139 "upb/json/parser.rl"
+ case 42:
+#line 2722 "upb/json/parser.rl"
{ end_subobject_full(parser); }
break;
-//#line 2568 "upb/json/parser.c"
+#line 3153 "upb/json/parser.c"
}
}
}
@@ -15118,7 +15737,7 @@
_out: {}
}
-//#line 2172 "upb/json/parser.rl"
+#line 2755 "upb/json/parser.rl"
if (p != pe) {
upb_status_seterrf(&parser->status, "Parse error at '%.*s'\n", pe - p, p);
@@ -15135,12 +15754,13 @@
return p - buf;
}
-bool end(void *closure, const void *hd) {
+static bool end(void *closure, const void *hd) {
upb_json_parser *parser = closure;
/* Prevent compile warning on unused static constants. */
UPB_UNUSED(json_start);
UPB_UNUSED(json_en_duration_machine);
+ UPB_UNUSED(json_en_fieldmask_machine);
UPB_UNUSED(json_en_number_machine);
UPB_UNUSED(json_en_string_machine);
UPB_UNUSED(json_en_timestamp_machine);
@@ -15149,11 +15769,7 @@
parse(parser, hd, &eof_ch, 0, NULL);
- return parser->current_state >=
-//#line 2608 "upb/json/parser.c"
-105
-//#line 2202 "upb/json/parser.rl"
-;
+ return parser->current_state >= 106;
}
static void json_parser_reset(upb_json_parser *p) {
@@ -15164,17 +15780,19 @@
p->top->f = NULL;
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;
/* Emit Ragel initialization of the parser. */
-//#line 2626 "upb/json/parser.c"
+#line 3210 "upb/json/parser.c"
{
cs = json_start;
top = 0;
}
-//#line 2217 "upb/json/parser.rl"
+#line 2803 "upb/json/parser.rl"
p->current_state = cs;
p->parser_top = top;
accumulate_clear(p);
@@ -15261,6 +15879,7 @@
upb_json_parser *upb_json_parser_create(upb_env *env,
const upb_json_parsermethod *method,
+ const upb_symtab* symtab,
upb_sink *output,
bool ignore_json_unknown) {
#ifndef NDEBUG
@@ -15279,7 +15898,17 @@
json_parser_reset(p);
upb_sink_reset(&p->top->sink, output->handlers, output->closure);
p->top->m = upb_handlers_msgdef(output->handlers);
+ if (is_wellknown_msg(p, UPB_WELLKNOWN_ANY)) {
+ p->top->is_any = true;
+ p->top->any_frame =
+ upb_env_malloc(p->env, sizeof(upb_jsonparser_any_frame));
+ json_parser_any_frame_reset(p->top->any_frame);
+ } else {
+ p->top->is_any = false;
+ p->top->any_frame = NULL;
+ }
set_name_table(p, p->top);
+ p->symtab = symtab;
p->ignore_json_unknown = ignore_json_unknown;
@@ -15389,6 +16018,15 @@
return ret;
}
+/* Convert a null-terminated const char* to a string piece. */
+strpc *newstrpc_str(upb_handlers *h, const char * str) {
+ strpc * ret = upb_gmalloc(sizeof(*ret));
+ ret->ptr = upb_gstrdup(str);
+ ret->len = strlen(str);
+ upb_handlers_addcleanup(h, ret, freestrpc);
+ return ret;
+}
+
/* ------------ JSON string printing: values, maps, arrays ------------------ */
static void print_data(
@@ -16058,6 +16696,57 @@
return closure;
}
+static void *startseq_fieldmask(void *closure, const void *handler_data) {
+ upb_json_printer *p = closure;
+ UPB_UNUSED(handler_data);
+ p->depth_++;
+ p->first_elem_[p->depth_] = true;
+ print_data(p, "\"", 1);
+ return closure;
+}
+
+static bool endseq_fieldmask(void *closure, const void *handler_data) {
+ upb_json_printer *p = closure;
+ UPB_UNUSED(handler_data);
+ p->depth_--;
+ print_data(p, "\"", 1);
+ return true;
+}
+
+static void *repeated_startstr_fieldmask(
+ void *closure, const void *handler_data,
+ size_t size_hint) {
+ upb_json_printer *p = closure;
+ UPB_UNUSED(handler_data);
+ UPB_UNUSED(size_hint);
+ print_comma(p);
+ return p;
+}
+
+static size_t repeated_str_fieldmask(
+ void *closure, const void *handler_data,
+ const char *str, size_t len,
+ const upb_bufhandle *handle) {
+ const char* limit = str + len;
+ bool upper = false;
+ size_t result_len = 0;
+ for (; str < limit; str++) {
+ if (*str == '_') {
+ upper = true;
+ continue;
+ }
+ if (upper && *str >= 'a' && *str <= 'z') {
+ char upper_char = toupper(*str);
+ CHK(putstr(closure, handler_data, &upper_char, 1, handle));
+ } else {
+ CHK(putstr(closure, handler_data, str, 1, handle));
+ }
+ upper = false;
+ result_len++;
+ }
+ return result_len;
+}
+
static void *startmap_nokey(void *closure, const void *handler_data) {
upb_json_printer *p = closure;
UPB_UNUSED(handler_data);
@@ -16240,6 +16929,68 @@
return true;
}
+static void *scalar_startstr_onlykey(
+ void *closure, const void *handler_data, size_t size_hint) {
+ upb_json_printer *p = closure;
+ UPB_UNUSED(size_hint);
+ CHK(putkey(closure, handler_data));
+ return p;
+}
+
+/* Set up handlers for an Any submessage. */
+void printer_sethandlers_any(const void *closure, upb_handlers *h) {
+ const upb_msgdef *md = upb_handlers_msgdef(h);
+
+ const upb_fielddef* type_field = upb_msgdef_itof(md, UPB_ANY_TYPE);
+ const upb_fielddef* value_field = upb_msgdef_itof(md, UPB_ANY_VALUE);
+
+ upb_handlerattr empty_attr = UPB_HANDLERATTR_INITIALIZER;
+
+ /* type_url's json name is "@type" */
+ upb_handlerattr type_name_attr = UPB_HANDLERATTR_INITIALIZER;
+ upb_handlerattr value_name_attr = UPB_HANDLERATTR_INITIALIZER;
+ strpc *type_url_json_name = newstrpc_str(h, "@type");
+ strpc *value_json_name = newstrpc_str(h, "value");
+
+ upb_handlerattr_sethandlerdata(&type_name_attr, type_url_json_name);
+ upb_handlerattr_sethandlerdata(&value_name_attr, value_json_name);
+
+ /* Set up handlers. */
+ upb_handlers_setstartmsg(h, printer_startmsg, &empty_attr);
+ upb_handlers_setendmsg(h, printer_endmsg, &empty_attr);
+
+ upb_handlers_setstartstr(h, type_field, scalar_startstr, &type_name_attr);
+ upb_handlers_setstring(h, type_field, scalar_str, &empty_attr);
+ upb_handlers_setendstr(h, type_field, scalar_endstr, &empty_attr);
+
+ /* This is not the full and correct JSON encoding for the Any value field. It
+ * requires further processing by the wrapper code based on the type URL.
+ */
+ upb_handlers_setstartstr(h, value_field, scalar_startstr_onlykey,
+ &value_name_attr);
+
+ UPB_UNUSED(closure);
+}
+
+/* Set up handlers for a fieldmask submessage. */
+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_handlers_setstartseq(h, f, startseq_fieldmask, &empty_attr);
+ upb_handlers_setendseq(h, f, endseq_fieldmask, &empty_attr);
+
+ upb_handlers_setstartmsg(h, printer_startmsg_noframe, &empty_attr);
+ upb_handlers_setendmsg(h, printer_endmsg_noframe, &empty_attr);
+
+ upb_handlers_setstartstr(h, f, repeated_startstr_fieldmask, &empty_attr);
+ upb_handlers_setstring(h, f, repeated_str_fieldmask, &empty_attr);
+
+ UPB_UNUSED(closure);
+}
+
/* Set up handlers for a duration submessage. */
void printer_sethandlers_duration(const void *closure, upb_handlers *h) {
const upb_msgdef *md = upb_handlers_msgdef(h);
@@ -16393,6 +17144,12 @@
switch (upb_msgdef_wellknowntype(md)) {
case UPB_WELLKNOWN_UNSPECIFIED:
break;
+ case UPB_WELLKNOWN_ANY:
+ printer_sethandlers_any(closure, h);
+ return;
+ case UPB_WELLKNOWN_FIELDMASK:
+ printer_sethandlers_fieldmask(closure, h);
+ return;
case UPB_WELLKNOWN_DURATION:
printer_sethandlers_duration(closure, h);
return;
diff --git a/ruby/ext/google/protobuf_c/upb.h b/ruby/ext/google/protobuf_c/upb.h
index 0670a81..7b3981b 100644
--- a/ruby/ext/google/protobuf_c/upb.h
+++ b/ruby/ext/google/protobuf_c/upb.h
@@ -1,11 +1,5 @@
// Amalgamated source file
-// php.h intentionally defined NDEBUG. We have to define this macro in order to
-// be used together with php.h
-#ifndef NDEBUG
-#define NDEBUG
-#endif
-
#if UINTPTR_MAX == 0xffffffff
#define UPB_SIZE(size32, size64) size32
#else
@@ -2013,6 +2007,8 @@
*/
typedef enum {
UPB_WELLKNOWN_UNSPECIFIED,
+ UPB_WELLKNOWN_ANY,
+ UPB_WELLKNOWN_FIELDMASK,
UPB_WELLKNOWN_DURATION,
UPB_WELLKNOWN_TIMESTAMP,
/* number wrappers */
@@ -2416,6 +2412,10 @@
#define UPB_MAPENTRY_KEY 1
#define UPB_MAPENTRY_VALUE 2
+/* Well-known field tag numbers for Any messages. */
+#define UPB_ANY_TYPE 1
+#define UPB_ANY_VALUE 2
+
/* Well-known field tag numbers for timestamp messages. */
#define UPB_DURATION_SECONDS 1
#define UPB_DURATION_NANOS 2
@@ -3271,6 +3271,8 @@
const char *sym);
const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym);
const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
+const upb_msgdef *upb_symtab_lookupmsg2(
+ const upb_symtab *s, const char *sym, size_t len);
const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
void *ref_donor, upb_status *status);
@@ -6877,7 +6879,7 @@
extern const upb_msglayout google_protobuf_FileDescriptorSet_msginit;
UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_FileDescriptorSet_msginit, arena);
+ return (google_protobuf_FileDescriptorSet *)upb_msg_new(&google_protobuf_FileDescriptorSet_msginit, arena);
}
UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_FileDescriptorSet *ret = google_protobuf_FileDescriptorSet_new(arena);
@@ -6896,7 +6898,7 @@
extern const upb_msglayout google_protobuf_FileDescriptorProto_msginit;
UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_FileDescriptorProto_msginit, arena);
+ return (google_protobuf_FileDescriptorProto *)upb_msg_new(&google_protobuf_FileDescriptorProto_msginit, arena);
}
UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_FileDescriptorProto *ret = google_protobuf_FileDescriptorProto_new(arena);
@@ -6937,7 +6939,7 @@
extern const upb_msglayout google_protobuf_DescriptorProto_msginit;
UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena);
+ return (google_protobuf_DescriptorProto *)upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena);
}
UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_DescriptorProto *ret = google_protobuf_DescriptorProto_new(arena);
@@ -6974,7 +6976,7 @@
extern const upb_msglayout google_protobuf_DescriptorProto_ExtensionRange_msginit;
UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_DescriptorProto_ExtensionRange_msginit, arena);
+ return (google_protobuf_DescriptorProto_ExtensionRange *)upb_msg_new(&google_protobuf_DescriptorProto_ExtensionRange_msginit, arena);
}
UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_DescriptorProto_ExtensionRange *ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena);
@@ -6997,7 +6999,7 @@
extern const upb_msglayout google_protobuf_DescriptorProto_ReservedRange_msginit;
UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_DescriptorProto_ReservedRange_msginit, arena);
+ return (google_protobuf_DescriptorProto_ReservedRange *)upb_msg_new(&google_protobuf_DescriptorProto_ReservedRange_msginit, arena);
}
UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_DescriptorProto_ReservedRange *ret = google_protobuf_DescriptorProto_ReservedRange_new(arena);
@@ -7018,7 +7020,7 @@
extern const upb_msglayout google_protobuf_ExtensionRangeOptions_msginit;
UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_ExtensionRangeOptions_msginit, arena);
+ return (google_protobuf_ExtensionRangeOptions *)upb_msg_new(&google_protobuf_ExtensionRangeOptions_msginit, arena);
}
UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_ExtensionRangeOptions *ret = google_protobuf_ExtensionRangeOptions_new(arena);
@@ -7037,7 +7039,7 @@
extern const upb_msglayout google_protobuf_FieldDescriptorProto_msginit;
UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena);
+ return (google_protobuf_FieldDescriptorProto *)upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena);
}
UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_FieldDescriptorProto *ret = google_protobuf_FieldDescriptorProto_new(arena);
@@ -7074,7 +7076,7 @@
extern const upb_msglayout google_protobuf_OneofDescriptorProto_msginit;
UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_OneofDescriptorProto_msginit, arena);
+ return (google_protobuf_OneofDescriptorProto *)upb_msg_new(&google_protobuf_OneofDescriptorProto_msginit, arena);
}
UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_OneofDescriptorProto *ret = google_protobuf_OneofDescriptorProto_new(arena);
@@ -7095,7 +7097,7 @@
extern const upb_msglayout google_protobuf_EnumDescriptorProto_msginit;
UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena);
+ return (google_protobuf_EnumDescriptorProto *)upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena);
}
UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_EnumDescriptorProto *ret = google_protobuf_EnumDescriptorProto_new(arena);
@@ -7122,7 +7124,7 @@
extern const upb_msglayout google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit;
UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena);
+ return (google_protobuf_EnumDescriptorProto_EnumReservedRange *)upb_msg_new(&google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena);
}
UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_EnumDescriptorProto_EnumReservedRange *ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena);
@@ -7143,7 +7145,7 @@
extern const upb_msglayout google_protobuf_EnumValueDescriptorProto_msginit;
UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_EnumValueDescriptorProto_msginit, arena);
+ return (google_protobuf_EnumValueDescriptorProto *)upb_msg_new(&google_protobuf_EnumValueDescriptorProto_msginit, arena);
}
UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_EnumValueDescriptorProto *ret = google_protobuf_EnumValueDescriptorProto_new(arena);
@@ -7166,7 +7168,7 @@
extern const upb_msglayout google_protobuf_ServiceDescriptorProto_msginit;
UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_ServiceDescriptorProto_msginit, arena);
+ return (google_protobuf_ServiceDescriptorProto *)upb_msg_new(&google_protobuf_ServiceDescriptorProto_msginit, arena);
}
UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_ServiceDescriptorProto *ret = google_protobuf_ServiceDescriptorProto_new(arena);
@@ -7189,7 +7191,7 @@
extern const upb_msglayout google_protobuf_MethodDescriptorProto_msginit;
UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_MethodDescriptorProto_msginit, arena);
+ return (google_protobuf_MethodDescriptorProto *)upb_msg_new(&google_protobuf_MethodDescriptorProto_msginit, arena);
}
UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_MethodDescriptorProto *ret = google_protobuf_MethodDescriptorProto_new(arena);
@@ -7218,7 +7220,7 @@
extern const upb_msglayout google_protobuf_FileOptions_msginit;
UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_FileOptions_msginit, arena);
+ return (google_protobuf_FileOptions *)upb_msg_new(&google_protobuf_FileOptions_msginit, arena);
}
UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_FileOptions *ret = google_protobuf_FileOptions_new(arena);
@@ -7273,7 +7275,7 @@
extern const upb_msglayout google_protobuf_MessageOptions_msginit;
UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_MessageOptions_msginit, arena);
+ return (google_protobuf_MessageOptions *)upb_msg_new(&google_protobuf_MessageOptions_msginit, arena);
}
UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_MessageOptions *ret = google_protobuf_MessageOptions_new(arena);
@@ -7300,7 +7302,7 @@
extern const upb_msglayout google_protobuf_FieldOptions_msginit;
UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_FieldOptions_msginit, arena);
+ return (google_protobuf_FieldOptions *)upb_msg_new(&google_protobuf_FieldOptions_msginit, arena);
}
UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_FieldOptions *ret = google_protobuf_FieldOptions_new(arena);
@@ -7331,7 +7333,7 @@
extern const upb_msglayout google_protobuf_OneofOptions_msginit;
UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_OneofOptions_msginit, arena);
+ return (google_protobuf_OneofOptions *)upb_msg_new(&google_protobuf_OneofOptions_msginit, arena);
}
UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_OneofOptions *ret = google_protobuf_OneofOptions_new(arena);
@@ -7350,7 +7352,7 @@
extern const upb_msglayout google_protobuf_EnumOptions_msginit;
UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_EnumOptions_msginit, arena);
+ return (google_protobuf_EnumOptions *)upb_msg_new(&google_protobuf_EnumOptions_msginit, arena);
}
UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_EnumOptions *ret = google_protobuf_EnumOptions_new(arena);
@@ -7373,7 +7375,7 @@
extern const upb_msglayout google_protobuf_EnumValueOptions_msginit;
UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_EnumValueOptions_msginit, arena);
+ return (google_protobuf_EnumValueOptions *)upb_msg_new(&google_protobuf_EnumValueOptions_msginit, arena);
}
UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_EnumValueOptions *ret = google_protobuf_EnumValueOptions_new(arena);
@@ -7394,7 +7396,7 @@
extern const upb_msglayout google_protobuf_ServiceOptions_msginit;
UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_ServiceOptions_msginit, arena);
+ return (google_protobuf_ServiceOptions *)upb_msg_new(&google_protobuf_ServiceOptions_msginit, arena);
}
UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_ServiceOptions *ret = google_protobuf_ServiceOptions_new(arena);
@@ -7415,7 +7417,7 @@
extern const upb_msglayout google_protobuf_MethodOptions_msginit;
UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_MethodOptions_msginit, arena);
+ return (google_protobuf_MethodOptions *)upb_msg_new(&google_protobuf_MethodOptions_msginit, arena);
}
UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_MethodOptions *ret = google_protobuf_MethodOptions_new(arena);
@@ -7438,7 +7440,7 @@
extern const upb_msglayout google_protobuf_UninterpretedOption_msginit;
UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
+ return (google_protobuf_UninterpretedOption *)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
}
UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_UninterpretedOption *ret = google_protobuf_UninterpretedOption_new(arena);
@@ -7469,7 +7471,7 @@
extern const upb_msglayout google_protobuf_UninterpretedOption_NamePart_msginit;
UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_UninterpretedOption_NamePart_msginit, arena);
+ return (google_protobuf_UninterpretedOption_NamePart *)upb_msg_new(&google_protobuf_UninterpretedOption_NamePart_msginit, arena);
}
UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_UninterpretedOption_NamePart *ret = google_protobuf_UninterpretedOption_NamePart_new(arena);
@@ -7490,7 +7492,7 @@
extern const upb_msglayout google_protobuf_SourceCodeInfo_msginit;
UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_SourceCodeInfo_msginit, arena);
+ return (google_protobuf_SourceCodeInfo *)upb_msg_new(&google_protobuf_SourceCodeInfo_msginit, arena);
}
UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_SourceCodeInfo *ret = google_protobuf_SourceCodeInfo_new(arena);
@@ -7509,7 +7511,7 @@
extern const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit;
UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_SourceCodeInfo_Location_msginit, arena);
+ return (google_protobuf_SourceCodeInfo_Location *)upb_msg_new(&google_protobuf_SourceCodeInfo_Location_msginit, arena);
}
UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_SourceCodeInfo_Location *ret = google_protobuf_SourceCodeInfo_Location_new(arena);
@@ -7536,7 +7538,7 @@
extern const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit;
UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_GeneratedCodeInfo_msginit, arena);
+ return (google_protobuf_GeneratedCodeInfo *)upb_msg_new(&google_protobuf_GeneratedCodeInfo_msginit, arena);
}
UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_GeneratedCodeInfo *ret = google_protobuf_GeneratedCodeInfo_new(arena);
@@ -7555,7 +7557,7 @@
extern const upb_msglayout google_protobuf_GeneratedCodeInfo_Annotation_msginit;
UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_new(upb_arena *arena) {
- return upb_msg_new(&google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena);
+ return (google_protobuf_GeneratedCodeInfo_Annotation *)upb_msg_new(&google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena);
}
UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_parsenew(upb_stringview buf, upb_arena *arena) {
google_protobuf_GeneratedCodeInfo_Annotation *ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena);
@@ -9567,7 +9569,7 @@
* constructed. This hint may be an overestimate for some build configurations.
* But if the parser library is upgraded without recompiling the application,
* it may be an underestimate. */
-#define UPB_JSON_PARSER_SIZE 4160
+#define UPB_JSON_PARSER_SIZE 5712
#ifdef __cplusplus
@@ -9576,6 +9578,7 @@
class upb::json::Parser {
public:
static Parser* Create(Environment* env, const ParserMethod* method,
+ const SymbolTable* symtab,
Sink* output, bool ignore_json_unknown);
BytesSink* input();
@@ -9610,6 +9613,7 @@
upb_json_parser* upb_json_parser_create(upb_env* e,
const upb_json_parsermethod* m,
+ const upb_symtab* symtab,
upb_sink* output,
bool ignore_json_unknown);
upb_bytessink *upb_json_parser_input(upb_json_parser *p);
@@ -9631,8 +9635,10 @@
namespace upb {
namespace json {
inline Parser* Parser::Create(Environment* env, const ParserMethod* method,
+ const SymbolTable* symtab,
Sink* output, bool ignore_json_unknown) {
- return upb_json_parser_create(env, method, output, ignore_json_unknown);
+ return upb_json_parser_create(
+ env, method, symtab, output, ignore_json_unknown);
}
inline BytesSink* Parser::input() {
return upb_json_parser_input(this);
diff --git a/ruby/tests/encode_decode_test.rb b/ruby/tests/encode_decode_test.rb
index d2b25fd..d3cebab 100644
--- a/ruby/tests/encode_decode_test.rb
+++ b/ruby/tests/encode_decode_test.rb
@@ -22,8 +22,8 @@
# Test discard unknown for singular message field.
unknown_msg = A::B::C::TestUnknown.new(
- :optional_unknown =>
- A::B::C::TestUnknown.new(:unknown_field => 1))
+ :optional_unknown =>
+ A::B::C::TestUnknown.new(:unknown_field => 1))
from = A::B::C::TestUnknown.encode(unknown_msg)
m = A::B::C::TestMessage.decode(from)
Google::Protobuf.discard_unknown(m)
@@ -32,8 +32,8 @@
# Test discard unknown for repeated message field.
unknown_msg = A::B::C::TestUnknown.new(
- :repeated_unknown =>
- [A::B::C::TestUnknown.new(:unknown_field => 1)])
+ :repeated_unknown =>
+ [A::B::C::TestUnknown.new(:unknown_field => 1)])
from = A::B::C::TestUnknown.encode(unknown_msg)
m = A::B::C::TestMessage.decode(from)
Google::Protobuf.discard_unknown(m)
@@ -42,8 +42,8 @@
# Test discard unknown for map value message field.
unknown_msg = A::B::C::TestUnknown.new(
- :map_unknown =>
- {"" => A::B::C::TestUnknown.new(:unknown_field => 1)})
+ :map_unknown =>
+ {"" => A::B::C::TestUnknown.new(:unknown_field => 1)})
from = A::B::C::TestUnknown.encode(unknown_msg)
m = A::B::C::TestMessage.decode(from)
Google::Protobuf.discard_unknown(m)
@@ -52,8 +52,8 @@
# Test discard unknown for oneof message field.
unknown_msg = A::B::C::TestUnknown.new(
- :oneof_unknown =>
- A::B::C::TestUnknown.new(:unknown_field => 1))
+ :oneof_unknown =>
+ A::B::C::TestUnknown.new(:unknown_field => 1))
from = A::B::C::TestUnknown.encode(unknown_msg)
m = A::B::C::TestMessage.decode(from)
Google::Protobuf.discard_unknown(m)