google-protobuf 3.7.0-x64-mingw32 → 3.7.1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of google-protobuf might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99e33b9b1d12da01877439e4411e5a4a89c8848a5543841604aa4f66160b98d0
4
- data.tar.gz: 2212b0c587adb5f1ce4fb3ab276018c6b77571159ce9e8f823a31e6abd8948d8
3
+ metadata.gz: f4a46cbfb561ddb6b163a7069b23146fbfd9cec73e3ac31dbf6c68304946b644
4
+ data.tar.gz: 166f72fddd8515d5148739d98033192a0c5c5b356609ee01d871f9e8c5b3f88b
5
5
  SHA512:
6
- metadata.gz: c4b9e9192e8dd330e2dedd0ff3d890141d16139c37c2f65eb87fe378a0ca1017e5677e11229dcb752e17714a97d55a0cf735b32d8171a0acad17aee810da1ed4
7
- data.tar.gz: bac3570880af9cec73f2755c18d038ba7dcdf0a571fb4041f2a91ca9203f06eb8726441f2ef3adc08cc4ce0021513de869e7bf7c1891aefdb7c2e9e224dde4a2
6
+ metadata.gz: 2e39e4465a43aab6f968e0e9548ccb965a3cd24aa2fa15c6c8ab823c5c5341d289498ac4083fae62a8a963662f2f3b8b3a4418e123821b5a701c437f867e37d4
7
+ data.tar.gz: f8a53e23f5635a2c4b875a14e2e5cb90073d95b0ffc43d8dd4204c67db1f660c666b90ab3da7865076da9d7419dd5fe4a25aa544c554cfabd8d87bfb224de929
@@ -1061,6 +1061,11 @@ static void put_ruby_value(VALUE value,
1061
1061
  upb_sink *sink,
1062
1062
  bool emit_defaults,
1063
1063
  bool is_json) {
1064
+ if (depth > ENCODE_MAX_NESTING) {
1065
+ rb_raise(rb_eRuntimeError,
1066
+ "Maximum recursion depth exceeded during encoding.");
1067
+ }
1068
+
1064
1069
  upb_selector_t sel = 0;
1065
1070
  if (upb_fielddef_isprimitive(f)) {
1066
1071
  sel = getsel(f, upb_handlers_getprimitivehandlertype(f));
@@ -1232,6 +1237,34 @@ static void putjsonany(VALUE msg_rb, const Descriptor* desc,
1232
1237
  upb_sink_endmsg(sink, &status);
1233
1238
  }
1234
1239
 
1240
+ static void putjsonlistvalue(
1241
+ VALUE msg_rb, const Descriptor* desc,
1242
+ upb_sink* sink, int depth, bool emit_defaults) {
1243
+ upb_status status;
1244
+ upb_sink subsink;
1245
+ MessageHeader* msg = NULL;
1246
+ const upb_fielddef* f = upb_msgdef_itof(desc->msgdef, 1);
1247
+ uint32_t offset =
1248
+ desc->layout->fields[upb_fielddef_index(f)].offset +
1249
+ sizeof(MessageHeader);
1250
+ VALUE ary;
1251
+
1252
+ TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg);
1253
+
1254
+ upb_sink_startmsg(sink);
1255
+
1256
+ ary = DEREF(msg, offset, VALUE);
1257
+
1258
+ if (ary == Qnil || RepeatedField_size(ary) == 0) {
1259
+ upb_sink_startseq(sink, getsel(f, UPB_HANDLER_STARTSEQ), &subsink);
1260
+ upb_sink_endseq(sink, getsel(f, UPB_HANDLER_ENDSEQ));
1261
+ } else {
1262
+ putary(ary, f, sink, depth, emit_defaults, true);
1263
+ }
1264
+
1265
+ upb_sink_endmsg(sink, &status);
1266
+ }
1267
+
1235
1268
  static void putmsg(VALUE msg_rb, const Descriptor* desc,
1236
1269
  upb_sink *sink, int depth, bool emit_defaults,
1237
1270
  bool is_json, bool open_msg) {
@@ -1239,11 +1272,18 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc,
1239
1272
  upb_msg_field_iter i;
1240
1273
  upb_status status;
1241
1274
 
1242
- if (is_json && upb_msgdef_wellknowntype(desc->msgdef) == UPB_WELLKNOWN_ANY) {
1275
+ if (is_json &&
1276
+ upb_msgdef_wellknowntype(desc->msgdef) == UPB_WELLKNOWN_ANY) {
1243
1277
  putjsonany(msg_rb, desc, sink, depth, emit_defaults);
1244
1278
  return;
1245
1279
  }
1246
1280
 
1281
+ if (is_json &&
1282
+ upb_msgdef_wellknowntype(desc->msgdef) == UPB_WELLKNOWN_LISTVALUE) {
1283
+ putjsonlistvalue(msg_rb, desc, sink, depth, emit_defaults);
1284
+ return;
1285
+ }
1286
+
1247
1287
  if (open_msg) {
1248
1288
  upb_sink_startmsg(sink);
1249
1289
  }
@@ -82,7 +82,7 @@ static VALUE table_key(Map* self, VALUE key,
82
82
  case UPB_TYPE_INT64:
83
83
  case UPB_TYPE_UINT32:
84
84
  case UPB_TYPE_UINT64:
85
- native_slot_set(self->key_type, Qnil, buf, key);
85
+ native_slot_set("", self->key_type, Qnil, buf, key);
86
86
  *out_key = buf;
87
87
  *out_length = native_slot_size(self->key_type);
88
88
  break;
@@ -396,7 +396,7 @@ VALUE Map_index_set(VALUE _self, VALUE key, VALUE value) {
396
396
  key = table_key(self, key, keybuf, &keyval, &length);
397
397
 
398
398
  mem = value_memory(&v);
399
- native_slot_set(self->value_type, self->value_type_class, mem, value);
399
+ native_slot_set("", self->value_type, self->value_type_class, mem, value);
400
400
 
401
401
  // Replace any existing value by issuing a 'remove' operation first.
402
402
  upb_strtable_remove2(&self->table, keyval, length, NULL);
@@ -315,7 +315,8 @@ int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self) {
315
315
 
316
316
  if (TYPE(val) != T_HASH) {
317
317
  rb_raise(rb_eArgError,
318
- "Expected Hash object as initializer value for map field '%s'.", name);
318
+ "Expected Hash object as initializer value for map field '%s' (given %s).",
319
+ name, rb_class2name(CLASS_OF(val)));
319
320
  }
320
321
  map = layout_get(self->descriptor->layout, Message_data(self), f);
321
322
  Map_merge_into_self(map, val);
@@ -324,7 +325,8 @@ int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self) {
324
325
 
325
326
  if (TYPE(val) != T_ARRAY) {
326
327
  rb_raise(rb_eArgError,
327
- "Expected array as initializer value for repeated field '%s'.", name);
328
+ "Expected array as initializer value for repeated field '%s' (given %s).",
329
+ name, rb_class2name(CLASS_OF(val)));
328
330
  }
329
331
  ary = layout_get(self->descriptor->layout, Message_data(self), f);
330
332
  for (int i = 0; i < RARRAY_LEN(val); i++) {
@@ -337,14 +337,16 @@ VALUE Builder_finalize_to_pool(VALUE _self, VALUE pool_rb);
337
337
  #define NATIVE_SLOT_MAX_SIZE sizeof(uint64_t)
338
338
 
339
339
  size_t native_slot_size(upb_fieldtype_t type);
340
- void native_slot_set(upb_fieldtype_t type,
340
+ void native_slot_set(const char* name,
341
+ upb_fieldtype_t type,
341
342
  VALUE type_class,
342
343
  void* memory,
343
344
  VALUE value);
344
345
  // Atomically (with respect to Ruby VM calls) either update the value and set a
345
346
  // oneof case, or do neither. If |case_memory| is null, then no case value is
346
347
  // set.
347
- void native_slot_set_value_and_case(upb_fieldtype_t type,
348
+ void native_slot_set_value_and_case(const char* name,
349
+ upb_fieldtype_t type,
348
350
  VALUE type_class,
349
351
  void* memory,
350
352
  VALUE value,
@@ -360,7 +362,7 @@ void native_slot_deep_copy(upb_fieldtype_t type, void* to, void* from);
360
362
  bool native_slot_eq(upb_fieldtype_t type, void* mem1, void* mem2);
361
363
 
362
364
  VALUE native_slot_encode_and_freeze_string(upb_fieldtype_t type, VALUE value);
363
- void native_slot_check_int_range_precision(upb_fieldtype_t type, VALUE value);
365
+ void native_slot_check_int_range_precision(const char* name, upb_fieldtype_t type, VALUE value);
364
366
 
365
367
  extern rb_encoding* kRubyStringUtf8Encoding;
366
368
  extern rb_encoding* kRubyStringASCIIEncoding;
@@ -178,7 +178,7 @@ VALUE RepeatedField_index_set(VALUE _self, VALUE _index, VALUE val) {
178
178
  }
179
179
 
180
180
  memory = RepeatedField_memoryat(self, index, element_size);
181
- native_slot_set(field_type, field_type_class, memory, val);
181
+ native_slot_set("", field_type, field_type_class, memory, val);
182
182
  return Qnil;
183
183
  }
184
184
 
@@ -217,7 +217,7 @@ VALUE RepeatedField_push(VALUE _self, VALUE val) {
217
217
 
218
218
  RepeatedField_reserve(self, self->size + 1);
219
219
  memory = (void *) (((uint8_t *)self->elements) + self->size * element_size);
220
- native_slot_set(field_type, self->field_type_class, memory, val);
220
+ native_slot_set("", field_type, self->field_type_class, memory, val);
221
221
  // native_slot_set may raise an error; bump size only after set.
222
222
  self->size++;
223
223
  return _self;
@@ -65,9 +65,10 @@ static bool is_ruby_num(VALUE value) {
65
65
  TYPE(value) == T_BIGNUM);
66
66
  }
67
67
 
68
- void native_slot_check_int_range_precision(upb_fieldtype_t type, VALUE val) {
68
+ void native_slot_check_int_range_precision(const char* name, upb_fieldtype_t type, VALUE val) {
69
69
  if (!is_ruby_num(val)) {
70
- rb_raise(cTypeError, "Expected number type for integral field.");
70
+ rb_raise(cTypeError, "Expected number type for integral field '%s' (given %s).",
71
+ name, rb_class2name(CLASS_OF(val)));
71
72
  }
72
73
 
73
74
  // NUM2{INT,UINT,LL,ULL} macros do the appropriate range checks on upper
@@ -77,13 +78,15 @@ void native_slot_check_int_range_precision(upb_fieldtype_t type, VALUE val) {
77
78
  double dbl_val = NUM2DBL(val);
78
79
  if (floor(dbl_val) != dbl_val) {
79
80
  rb_raise(rb_eRangeError,
80
- "Non-integral floating point value assigned to integer field.");
81
+ "Non-integral floating point value assigned to integer field '%s' (given %s).",
82
+ name, rb_class2name(CLASS_OF(val)));
81
83
  }
82
84
  }
83
85
  if (type == UPB_TYPE_UINT32 || type == UPB_TYPE_UINT64) {
84
86
  if (NUM2DBL(val) < 0) {
85
87
  rb_raise(rb_eRangeError,
86
- "Assigning negative value to unsigned integer field.");
88
+ "Assigning negative value to unsigned integer field '%s' (given %s).",
89
+ name, rb_class2name(CLASS_OF(val)));
87
90
  }
88
91
  }
89
92
  }
@@ -108,12 +111,14 @@ VALUE native_slot_encode_and_freeze_string(upb_fieldtype_t type, VALUE value) {
108
111
  return value;
109
112
  }
110
113
 
111
- void native_slot_set(upb_fieldtype_t type, VALUE type_class,
114
+ void native_slot_set(const char* name,
115
+ upb_fieldtype_t type, VALUE type_class,
112
116
  void* memory, VALUE value) {
113
- native_slot_set_value_and_case(type, type_class, memory, value, NULL, 0);
117
+ native_slot_set_value_and_case(name, type, type_class, memory, value, NULL, 0);
114
118
  }
115
119
 
116
- void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
120
+ void native_slot_set_value_and_case(const char* name,
121
+ upb_fieldtype_t type, VALUE type_class,
117
122
  void* memory, VALUE value,
118
123
  uint32_t* case_memory,
119
124
  uint32_t case_number) {
@@ -124,13 +129,15 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
124
129
  switch (type) {
125
130
  case UPB_TYPE_FLOAT:
126
131
  if (!is_ruby_num(value)) {
127
- rb_raise(cTypeError, "Expected number type for float field.");
132
+ rb_raise(cTypeError, "Expected number type for float field '%s' (given %s).",
133
+ name, rb_class2name(CLASS_OF(value)));
128
134
  }
129
135
  DEREF(memory, float) = NUM2DBL(value);
130
136
  break;
131
137
  case UPB_TYPE_DOUBLE:
132
138
  if (!is_ruby_num(value)) {
133
- rb_raise(cTypeError, "Expected number type for double field.");
139
+ rb_raise(cTypeError, "Expected number type for double field '%s' (given %s).",
140
+ name, rb_class2name(CLASS_OF(value)));
134
141
  }
135
142
  DEREF(memory, double) = NUM2DBL(value);
136
143
  break;
@@ -141,7 +148,8 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
141
148
  } else if (value == Qfalse) {
142
149
  val = 0;
143
150
  } else {
144
- rb_raise(cTypeError, "Invalid argument for boolean field.");
151
+ rb_raise(cTypeError, "Invalid argument for boolean field '%s' (given %s).",
152
+ name, rb_class2name(CLASS_OF(value)));
145
153
  }
146
154
  DEREF(memory, int8_t) = val;
147
155
  break;
@@ -150,7 +158,8 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
150
158
  if (CLASS_OF(value) == rb_cSymbol) {
151
159
  value = rb_funcall(value, rb_intern("to_s"), 0);
152
160
  } else if (CLASS_OF(value) != rb_cString) {
153
- rb_raise(cTypeError, "Invalid argument for string field.");
161
+ rb_raise(cTypeError, "Invalid argument for string field '%s' (given %s).",
162
+ name, rb_class2name(CLASS_OF(value)));
154
163
  }
155
164
 
156
165
  DEREF(memory, VALUE) = native_slot_encode_and_freeze_string(type, value);
@@ -158,7 +167,8 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
158
167
 
159
168
  case UPB_TYPE_BYTES: {
160
169
  if (CLASS_OF(value) != rb_cString) {
161
- rb_raise(cTypeError, "Invalid argument for string field.");
170
+ rb_raise(cTypeError, "Invalid argument for bytes field '%s' (given %s).",
171
+ name, rb_class2name(CLASS_OF(value)));
162
172
  }
163
173
 
164
174
  DEREF(memory, VALUE) = native_slot_encode_and_freeze_string(type, value);
@@ -169,8 +179,8 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
169
179
  value = Qnil;
170
180
  } else if (CLASS_OF(value) != type_class) {
171
181
  rb_raise(cTypeError,
172
- "Invalid type %s to assign to submessage field.",
173
- rb_class2name(CLASS_OF(value)));
182
+ "Invalid type %s to assign to submessage field '%s'.",
183
+ rb_class2name(CLASS_OF(value)), name);
174
184
  }
175
185
  DEREF(memory, VALUE) = value;
176
186
  break;
@@ -181,18 +191,18 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
181
191
  value = rb_funcall(value, rb_intern("to_sym"), 0);
182
192
  } else if (!is_ruby_num(value) && TYPE(value) != T_SYMBOL) {
183
193
  rb_raise(cTypeError,
184
- "Expected number or symbol type for enum field.");
194
+ "Expected number or symbol type for enum field '%s'.", name);
185
195
  }
186
196
  if (TYPE(value) == T_SYMBOL) {
187
197
  // Ensure that the given symbol exists in the enum module.
188
198
  VALUE lookup = rb_funcall(type_class, rb_intern("resolve"), 1, value);
189
199
  if (lookup == Qnil) {
190
- rb_raise(rb_eRangeError, "Unknown symbol value for enum field.");
200
+ rb_raise(rb_eRangeError, "Unknown symbol value for enum field '%s'.", name);
191
201
  } else {
192
202
  int_val = NUM2INT(lookup);
193
203
  }
194
204
  } else {
195
- native_slot_check_int_range_precision(UPB_TYPE_INT32, value);
205
+ native_slot_check_int_range_precision(name, UPB_TYPE_INT32, value);
196
206
  int_val = NUM2INT(value);
197
207
  }
198
208
  DEREF(memory, int32_t) = int_val;
@@ -202,7 +212,7 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class,
202
212
  case UPB_TYPE_INT64:
203
213
  case UPB_TYPE_UINT32:
204
214
  case UPB_TYPE_UINT64:
205
- native_slot_check_int_range_precision(type, value);
215
+ native_slot_check_int_range_precision(name, type, value);
206
216
  switch (type) {
207
217
  case UPB_TYPE_INT32:
208
218
  DEREF(memory, int32_t) = NUM2INT(value);
@@ -658,8 +668,9 @@ void layout_clear(MessageLayout* layout,
658
668
 
659
669
  DEREF(memory, VALUE) = ary;
660
670
  } else {
661
- native_slot_set(upb_fielddef_type(field), field_type_class(field),
662
- memory, layout_get_default(field));
671
+ native_slot_set(upb_fielddef_name(field),
672
+ upb_fielddef_type(field), field_type_class(field),
673
+ memory, layout_get_default(field));
663
674
  }
664
675
  }
665
676
 
@@ -816,6 +827,7 @@ void layout_set(MessageLayout* layout,
816
827
  // use native_slot_set_value_and_case(), which ensures that both the value
817
828
  // and case number are altered atomically (w.r.t. the Ruby VM).
818
829
  native_slot_set_value_and_case(
830
+ upb_fielddef_name(field),
819
831
  upb_fielddef_type(field), field_type_class(field),
820
832
  memory, val,
821
833
  oneof_case, upb_fielddef_number(field));
@@ -827,8 +839,9 @@ void layout_set(MessageLayout* layout,
827
839
  check_repeated_field_type(val, field);
828
840
  DEREF(memory, VALUE) = val;
829
841
  } else {
830
- native_slot_set(upb_fielddef_type(field), field_type_class(field), memory,
831
- val);
842
+ native_slot_set(upb_fielddef_name(field),
843
+ upb_fielddef_type(field), field_type_class(field),
844
+ memory, val);
832
845
  }
833
846
 
834
847
  if (layout->fields[upb_fielddef_index(field)].hasbit !=
@@ -1,4 +1,5 @@
1
- // Amalgamated source file
1
+ /* Amalgamated source file */
2
+ #define _XOPEN_SOURCE 700
2
3
  #include "upb.h"
3
4
 
4
5
  #if UINTPTR_MAX == 0xffffffff
@@ -53,24 +54,24 @@ static const upb_msglayout *const google_protobuf_FileDescriptorProto_submsgs[6]
53
54
  };
54
55
 
55
56
  static const upb_msglayout_field google_protobuf_FileDescriptorProto__fields[12] = {
56
- {1, UPB_SIZE(8, 16), 1, 0, 9, 1},
57
- {2, UPB_SIZE(16, 32), 2, 0, 9, 1},
58
- {3, UPB_SIZE(40, 80), 0, 0, 9, 3},
59
- {4, UPB_SIZE(44, 88), 0, 0, 11, 3},
60
- {5, UPB_SIZE(48, 96), 0, 1, 11, 3},
61
- {6, UPB_SIZE(52, 104), 0, 4, 11, 3},
62
- {7, UPB_SIZE(56, 112), 0, 2, 11, 3},
63
- {8, UPB_SIZE(32, 64), 4, 3, 11, 1},
64
- {9, UPB_SIZE(36, 72), 5, 5, 11, 1},
65
- {10, UPB_SIZE(60, 120), 0, 0, 5, 3},
66
- {11, UPB_SIZE(64, 128), 0, 0, 5, 3},
67
- {12, UPB_SIZE(24, 48), 3, 0, 9, 1},
57
+ {1, UPB_SIZE(4, 8), 1, 0, 9, 1},
58
+ {2, UPB_SIZE(12, 24), 2, 0, 9, 1},
59
+ {3, UPB_SIZE(36, 72), 0, 0, 9, 3},
60
+ {4, UPB_SIZE(40, 80), 0, 0, 11, 3},
61
+ {5, UPB_SIZE(44, 88), 0, 1, 11, 3},
62
+ {6, UPB_SIZE(48, 96), 0, 4, 11, 3},
63
+ {7, UPB_SIZE(52, 104), 0, 2, 11, 3},
64
+ {8, UPB_SIZE(28, 56), 4, 3, 11, 1},
65
+ {9, UPB_SIZE(32, 64), 5, 5, 11, 1},
66
+ {10, UPB_SIZE(56, 112), 0, 0, 5, 3},
67
+ {11, UPB_SIZE(60, 120), 0, 0, 5, 3},
68
+ {12, UPB_SIZE(20, 40), 3, 0, 9, 1},
68
69
  };
69
70
 
70
71
  const upb_msglayout google_protobuf_FileDescriptorProto_msginit = {
71
72
  &google_protobuf_FileDescriptorProto_submsgs[0],
72
73
  &google_protobuf_FileDescriptorProto__fields[0],
73
- UPB_SIZE(72, 144), 12, false,
74
+ UPB_SIZE(64, 128), 12, false,
74
75
  };
75
76
 
76
77
  static const upb_msglayout *const google_protobuf_DescriptorProto_submsgs[8] = {
@@ -84,22 +85,22 @@ static const upb_msglayout *const google_protobuf_DescriptorProto_submsgs[8] = {
84
85
  };
85
86
 
86
87
  static const upb_msglayout_field google_protobuf_DescriptorProto__fields[10] = {
87
- {1, UPB_SIZE(8, 16), 1, 0, 9, 1},
88
- {2, UPB_SIZE(20, 40), 0, 4, 11, 3},
89
- {3, UPB_SIZE(24, 48), 0, 0, 11, 3},
90
- {4, UPB_SIZE(28, 56), 0, 3, 11, 3},
91
- {5, UPB_SIZE(32, 64), 0, 1, 11, 3},
92
- {6, UPB_SIZE(36, 72), 0, 4, 11, 3},
93
- {7, UPB_SIZE(16, 32), 2, 5, 11, 1},
94
- {8, UPB_SIZE(40, 80), 0, 6, 11, 3},
95
- {9, UPB_SIZE(44, 88), 0, 2, 11, 3},
96
- {10, UPB_SIZE(48, 96), 0, 0, 9, 3},
88
+ {1, UPB_SIZE(4, 8), 1, 0, 9, 1},
89
+ {2, UPB_SIZE(16, 32), 0, 4, 11, 3},
90
+ {3, UPB_SIZE(20, 40), 0, 0, 11, 3},
91
+ {4, UPB_SIZE(24, 48), 0, 3, 11, 3},
92
+ {5, UPB_SIZE(28, 56), 0, 1, 11, 3},
93
+ {6, UPB_SIZE(32, 64), 0, 4, 11, 3},
94
+ {7, UPB_SIZE(12, 24), 2, 5, 11, 1},
95
+ {8, UPB_SIZE(36, 72), 0, 6, 11, 3},
96
+ {9, UPB_SIZE(40, 80), 0, 2, 11, 3},
97
+ {10, UPB_SIZE(44, 88), 0, 0, 9, 3},
97
98
  };
98
99
 
99
100
  const upb_msglayout google_protobuf_DescriptorProto_msginit = {
100
101
  &google_protobuf_DescriptorProto_submsgs[0],
101
102
  &google_protobuf_DescriptorProto__fields[0],
102
- UPB_SIZE(56, 112), 10, false,
103
+ UPB_SIZE(48, 96), 10, false,
103
104
  };
104
105
 
105
106
  static const upb_msglayout *const google_protobuf_DescriptorProto_ExtensionRange_submsgs[1] = {
@@ -171,14 +172,14 @@ static const upb_msglayout *const google_protobuf_OneofDescriptorProto_submsgs[1
171
172
  };
172
173
 
173
174
  static const upb_msglayout_field google_protobuf_OneofDescriptorProto__fields[2] = {
174
- {1, UPB_SIZE(8, 16), 1, 0, 9, 1},
175
- {2, UPB_SIZE(16, 32), 2, 0, 11, 1},
175
+ {1, UPB_SIZE(4, 8), 1, 0, 9, 1},
176
+ {2, UPB_SIZE(12, 24), 2, 0, 11, 1},
176
177
  };
177
178
 
178
179
  const upb_msglayout google_protobuf_OneofDescriptorProto_msginit = {
179
180
  &google_protobuf_OneofDescriptorProto_submsgs[0],
180
181
  &google_protobuf_OneofDescriptorProto__fields[0],
181
- UPB_SIZE(24, 48), 2, false,
182
+ UPB_SIZE(16, 32), 2, false,
182
183
  };
183
184
 
184
185
  static const upb_msglayout *const google_protobuf_EnumDescriptorProto_submsgs[3] = {
@@ -188,11 +189,11 @@ static const upb_msglayout *const google_protobuf_EnumDescriptorProto_submsgs[3]
188
189
  };
189
190
 
190
191
  static const upb_msglayout_field google_protobuf_EnumDescriptorProto__fields[5] = {
191
- {1, UPB_SIZE(8, 16), 1, 0, 9, 1},
192
- {2, UPB_SIZE(20, 40), 0, 2, 11, 3},
193
- {3, UPB_SIZE(16, 32), 2, 1, 11, 1},
194
- {4, UPB_SIZE(24, 48), 0, 0, 11, 3},
195
- {5, UPB_SIZE(28, 56), 0, 0, 9, 3},
192
+ {1, UPB_SIZE(4, 8), 1, 0, 9, 1},
193
+ {2, UPB_SIZE(16, 32), 0, 2, 11, 3},
194
+ {3, UPB_SIZE(12, 24), 2, 1, 11, 1},
195
+ {4, UPB_SIZE(20, 40), 0, 0, 11, 3},
196
+ {5, UPB_SIZE(24, 48), 0, 0, 9, 3},
196
197
  };
197
198
 
198
199
  const upb_msglayout google_protobuf_EnumDescriptorProto_msginit = {
@@ -217,15 +218,15 @@ static const upb_msglayout *const google_protobuf_EnumValueDescriptorProto_subms
217
218
  };
218
219
 
219
220
  static const upb_msglayout_field google_protobuf_EnumValueDescriptorProto__fields[3] = {
220
- {1, UPB_SIZE(8, 16), 2, 0, 9, 1},
221
+ {1, UPB_SIZE(8, 8), 2, 0, 9, 1},
221
222
  {2, UPB_SIZE(4, 4), 1, 0, 5, 1},
222
- {3, UPB_SIZE(16, 32), 3, 0, 11, 1},
223
+ {3, UPB_SIZE(16, 24), 3, 0, 11, 1},
223
224
  };
224
225
 
225
226
  const upb_msglayout google_protobuf_EnumValueDescriptorProto_msginit = {
226
227
  &google_protobuf_EnumValueDescriptorProto_submsgs[0],
227
228
  &google_protobuf_EnumValueDescriptorProto__fields[0],
228
- UPB_SIZE(24, 48), 3, false,
229
+ UPB_SIZE(24, 32), 3, false,
229
230
  };
230
231
 
231
232
  static const upb_msglayout *const google_protobuf_ServiceDescriptorProto_submsgs[2] = {
@@ -234,9 +235,9 @@ static const upb_msglayout *const google_protobuf_ServiceDescriptorProto_submsgs
234
235
  };
235
236
 
236
237
  static const upb_msglayout_field google_protobuf_ServiceDescriptorProto__fields[3] = {
237
- {1, UPB_SIZE(8, 16), 1, 0, 9, 1},
238
- {2, UPB_SIZE(20, 40), 0, 0, 11, 3},
239
- {3, UPB_SIZE(16, 32), 2, 1, 11, 1},
238
+ {1, UPB_SIZE(4, 8), 1, 0, 9, 1},
239
+ {2, UPB_SIZE(16, 32), 0, 0, 11, 3},
240
+ {3, UPB_SIZE(12, 24), 2, 1, 11, 1},
240
241
  };
241
242
 
242
243
  const upb_msglayout google_protobuf_ServiceDescriptorProto_msginit = {
@@ -250,10 +251,10 @@ static const upb_msglayout *const google_protobuf_MethodDescriptorProto_submsgs[
250
251
  };
251
252
 
252
253
  static const upb_msglayout_field google_protobuf_MethodDescriptorProto__fields[6] = {
253
- {1, UPB_SIZE(8, 16), 3, 0, 9, 1},
254
- {2, UPB_SIZE(16, 32), 4, 0, 9, 1},
255
- {3, UPB_SIZE(24, 48), 5, 0, 9, 1},
256
- {4, UPB_SIZE(32, 64), 6, 0, 11, 1},
254
+ {1, UPB_SIZE(4, 8), 3, 0, 9, 1},
255
+ {2, UPB_SIZE(12, 24), 4, 0, 9, 1},
256
+ {3, UPB_SIZE(20, 40), 5, 0, 9, 1},
257
+ {4, UPB_SIZE(28, 56), 6, 0, 11, 1},
257
258
  {5, UPB_SIZE(1, 1), 1, 0, 8, 1},
258
259
  {6, UPB_SIZE(2, 2), 2, 0, 8, 1},
259
260
  };
@@ -261,7 +262,7 @@ static const upb_msglayout_field google_protobuf_MethodDescriptorProto__fields[6
261
262
  const upb_msglayout google_protobuf_MethodDescriptorProto_msginit = {
262
263
  &google_protobuf_MethodDescriptorProto_submsgs[0],
263
264
  &google_protobuf_MethodDescriptorProto__fields[0],
264
- UPB_SIZE(40, 80), 6, false,
265
+ UPB_SIZE(32, 64), 6, false,
265
266
  };
266
267
 
267
268
  static const upb_msglayout *const google_protobuf_FileOptions_submsgs[1] = {
@@ -269,11 +270,11 @@ static const upb_msglayout *const google_protobuf_FileOptions_submsgs[1] = {
269
270
  };
270
271
 
271
272
  static const upb_msglayout_field google_protobuf_FileOptions__fields[19] = {
272
- {1, UPB_SIZE(32, 32), 11, 0, 9, 1},
273
- {8, UPB_SIZE(40, 48), 12, 0, 9, 1},
273
+ {1, UPB_SIZE(28, 32), 11, 0, 9, 1},
274
+ {8, UPB_SIZE(36, 48), 12, 0, 9, 1},
274
275
  {9, UPB_SIZE(8, 8), 1, 0, 14, 1},
275
276
  {10, UPB_SIZE(16, 16), 2, 0, 8, 1},
276
- {11, UPB_SIZE(48, 64), 13, 0, 9, 1},
277
+ {11, UPB_SIZE(44, 64), 13, 0, 9, 1},
277
278
  {16, UPB_SIZE(17, 17), 3, 0, 8, 1},
278
279
  {17, UPB_SIZE(18, 18), 4, 0, 8, 1},
279
280
  {18, UPB_SIZE(19, 19), 5, 0, 8, 1},
@@ -281,19 +282,19 @@ static const upb_msglayout_field google_protobuf_FileOptions__fields[19] = {
281
282
  {23, UPB_SIZE(21, 21), 7, 0, 8, 1},
282
283
  {27, UPB_SIZE(22, 22), 8, 0, 8, 1},
283
284
  {31, UPB_SIZE(23, 23), 9, 0, 8, 1},
284
- {36, UPB_SIZE(56, 80), 14, 0, 9, 1},
285
- {37, UPB_SIZE(64, 96), 15, 0, 9, 1},
286
- {39, UPB_SIZE(72, 112), 16, 0, 9, 1},
287
- {40, UPB_SIZE(80, 128), 17, 0, 9, 1},
288
- {41, UPB_SIZE(88, 144), 18, 0, 9, 1},
285
+ {36, UPB_SIZE(52, 80), 14, 0, 9, 1},
286
+ {37, UPB_SIZE(60, 96), 15, 0, 9, 1},
287
+ {39, UPB_SIZE(68, 112), 16, 0, 9, 1},
288
+ {40, UPB_SIZE(76, 128), 17, 0, 9, 1},
289
+ {41, UPB_SIZE(84, 144), 18, 0, 9, 1},
289
290
  {42, UPB_SIZE(24, 24), 10, 0, 8, 1},
290
- {999, UPB_SIZE(96, 160), 0, 0, 11, 3},
291
+ {999, UPB_SIZE(92, 160), 0, 0, 11, 3},
291
292
  };
292
293
 
293
294
  const upb_msglayout google_protobuf_FileOptions_msginit = {
294
295
  &google_protobuf_FileOptions_submsgs[0],
295
296
  &google_protobuf_FileOptions__fields[0],
296
- UPB_SIZE(104, 176), 19, false,
297
+ UPB_SIZE(96, 176), 19, false,
297
298
  };
298
299
 
299
300
  static const upb_msglayout *const google_protobuf_MessageOptions_submsgs[1] = {
@@ -431,7 +432,7 @@ const upb_msglayout google_protobuf_UninterpretedOption_msginit = {
431
432
  };
432
433
 
433
434
  static const upb_msglayout_field google_protobuf_UninterpretedOption_NamePart__fields[2] = {
434
- {1, UPB_SIZE(8, 16), 2, 0, 9, 2},
435
+ {1, UPB_SIZE(4, 8), 2, 0, 9, 2},
435
436
  {2, UPB_SIZE(1, 1), 1, 0, 8, 2},
436
437
  };
437
438
 
@@ -456,17 +457,17 @@ const upb_msglayout google_protobuf_SourceCodeInfo_msginit = {
456
457
  };
457
458
 
458
459
  static const upb_msglayout_field google_protobuf_SourceCodeInfo_Location__fields[5] = {
459
- {1, UPB_SIZE(24, 48), 0, 0, 5, 3},
460
- {2, UPB_SIZE(28, 56), 0, 0, 5, 3},
461
- {3, UPB_SIZE(8, 16), 1, 0, 9, 1},
462
- {4, UPB_SIZE(16, 32), 2, 0, 9, 1},
463
- {6, UPB_SIZE(32, 64), 0, 0, 9, 3},
460
+ {1, UPB_SIZE(20, 40), 0, 0, 5, 3},
461
+ {2, UPB_SIZE(24, 48), 0, 0, 5, 3},
462
+ {3, UPB_SIZE(4, 8), 1, 0, 9, 1},
463
+ {4, UPB_SIZE(12, 24), 2, 0, 9, 1},
464
+ {6, UPB_SIZE(28, 56), 0, 0, 9, 3},
464
465
  };
465
466
 
466
467
  const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit = {
467
468
  NULL,
468
469
  &google_protobuf_SourceCodeInfo_Location__fields[0],
469
- UPB_SIZE(40, 80), 5, false,
470
+ UPB_SIZE(32, 64), 5, false,
470
471
  };
471
472
 
472
473
  static const upb_msglayout *const google_protobuf_GeneratedCodeInfo_submsgs[1] = {
@@ -484,8 +485,8 @@ const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit = {
484
485
  };
485
486
 
486
487
  static const upb_msglayout_field google_protobuf_GeneratedCodeInfo_Annotation__fields[4] = {
487
- {1, UPB_SIZE(24, 32), 0, 0, 5, 3},
488
- {2, UPB_SIZE(16, 16), 3, 0, 9, 1},
488
+ {1, UPB_SIZE(20, 32), 0, 0, 5, 3},
489
+ {2, UPB_SIZE(12, 16), 3, 0, 9, 1},
489
490
  {3, UPB_SIZE(4, 4), 1, 0, 5, 1},
490
491
  {4, UPB_SIZE(8, 8), 2, 0, 5, 1},
491
492
  };
@@ -493,7 +494,7 @@ static const upb_msglayout_field google_protobuf_GeneratedCodeInfo_Annotation__f
493
494
  const upb_msglayout google_protobuf_GeneratedCodeInfo_Annotation_msginit = {
494
495
  NULL,
495
496
  &google_protobuf_GeneratedCodeInfo_Annotation__fields[0],
496
- UPB_SIZE(32, 48), 4, false,
497
+ UPB_SIZE(24, 48), 4, false,
497
498
  };
498
499
 
499
500
 
@@ -608,14 +609,14 @@ static int64_t upb_zzdecode_64(uint64_t n) {
608
609
  }
609
610
 
610
611
  static bool upb_decode_string(const char **ptr, const char *limit,
611
- upb_stringview *val) {
612
+ upb_strview *val) {
612
613
  uint32_t len;
613
614
 
614
615
  CHK(upb_decode_varint32(ptr, limit, &len) &&
615
616
  len < INT32_MAX &&
616
617
  limit - *ptr >= (int32_t)len);
617
618
 
618
- *val = upb_stringview_make(*ptr, len);
619
+ *val = upb_strview_make(*ptr, len);
619
620
  *ptr += len;
620
621
  return true;
621
622
  }
@@ -646,7 +647,7 @@ static bool upb_skip_unknownfielddata(upb_decstate *d, upb_decframe *frame,
646
647
  return upb_decode_64bit(&d->ptr, frame->limit, &val);
647
648
  }
648
649
  case UPB_WIRE_TYPE_DELIMITED: {
649
- upb_stringview val;
650
+ upb_strview val;
650
651
  return upb_decode_string(&d->ptr, frame->limit, &val);
651
652
  }
652
653
  case UPB_WIRE_TYPE_START_GROUP:
@@ -870,7 +871,7 @@ static bool upb_decode_32bitfield(upb_decstate *d, upb_decframe *frame,
870
871
  return true;
871
872
  }
872
873
 
873
- static bool upb_decode_fixedpacked(upb_array *arr, upb_stringview data,
874
+ static bool upb_decode_fixedpacked(upb_array *arr, upb_strview data,
874
875
  int elem_size) {
875
876
  int elements = data.size / elem_size;
876
877
  void *field_mem;
@@ -885,7 +886,7 @@ static bool upb_decode_fixedpacked(upb_array *arr, upb_stringview data,
885
886
  static bool upb_decode_toarray(upb_decstate *d, upb_decframe *frame,
886
887
  const char *field_start,
887
888
  const upb_msglayout_field *field,
888
- upb_stringview val) {
889
+ upb_strview val) {
889
890
  upb_array *arr = upb_getorcreatearr(frame, field);
890
891
 
891
892
  #define VARINT_CASE(ctype, decode) { \
@@ -966,7 +967,7 @@ static bool upb_decode_toarray(upb_decstate *d, upb_decframe *frame,
966
967
  static bool upb_decode_delimitedfield(upb_decstate *d, upb_decframe *frame,
967
968
  const char *field_start,
968
969
  const upb_msglayout_field *field) {
969
- upb_stringview val;
970
+ upb_strview val;
970
971
 
971
972
  CHK(upb_decode_string(&d->ptr, frame->limit, &val));
972
973
 
@@ -1080,7 +1081,7 @@ static bool upb_decode_message(upb_decstate *d, const char *limit,
1080
1081
  return true;
1081
1082
  }
1082
1083
 
1083
- bool upb_decode(upb_stringview buf, void *msg, const upb_msglayout *l) {
1084
+ bool upb_decode(upb_strview buf, void *msg, const upb_msglayout *l) {
1084
1085
  upb_decstate state;
1085
1086
  state.ptr = buf.data;
1086
1087
 
@@ -1752,6 +1753,8 @@ static void freefield(upb_refcounted *r) {
1752
1753
  upb_fielddef_uninit_default(f);
1753
1754
  if (f->subdef_is_symbolic)
1754
1755
  upb_gfree(f->sub.name);
1756
+ if (f->msg_is_symbolic)
1757
+ upb_gfree(f->msg.name);
1755
1758
  upb_def_uninit(upb_fielddef_upcast_mutable(f));
1756
1759
  upb_gfree(f);
1757
1760
  }
@@ -2109,7 +2112,7 @@ bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s) {
2109
2112
  s, "cannot change field number after adding to a message");
2110
2113
  return false;
2111
2114
  }
2112
- if (number == 0 || number > UPB_MAX_FIELDNUMBER) {
2115
+ if (number == 0) {
2113
2116
  upb_status_seterrf(s, "invalid field number (%u)", number);
2114
2117
  return false;
2115
2118
  }
@@ -3717,8 +3720,8 @@ do { ; } while(0)
3717
3720
  VARINT_CASE(int64_t, upb_zzencode_64(*ptr));
3718
3721
  case UPB_DESCRIPTOR_TYPE_STRING:
3719
3722
  case UPB_DESCRIPTOR_TYPE_BYTES: {
3720
- upb_stringview *start = arr->data;
3721
- upb_stringview *ptr = start + arr->len;
3723
+ upb_strview *start = arr->data;
3724
+ upb_strview *ptr = start + arr->len;
3722
3725
  do {
3723
3726
  ptr--;
3724
3727
  CHK(upb_put_bytes(e, ptr->data, ptr->size) &&
@@ -3802,7 +3805,7 @@ static bool upb_encode_scalarfield(upb_encstate *e, const char *field_mem,
3802
3805
  CASE(int64_t, varint, UPB_WIRE_TYPE_VARINT, upb_zzencode_64(val));
3803
3806
  case UPB_DESCRIPTOR_TYPE_STRING:
3804
3807
  case UPB_DESCRIPTOR_TYPE_BYTES: {
3805
- upb_stringview view = *(upb_stringview*)field_mem;
3808
+ upb_strview view = *(upb_strview*)field_mem;
3806
3809
  if (skip_zero_value && view.size == 0) {
3807
3810
  return true;
3808
3811
  }
@@ -4752,7 +4755,7 @@ static size_t upb_msgval_sizeof(upb_fieldtype_t type) {
4752
4755
  return sizeof(void*);
4753
4756
  case UPB_TYPE_BYTES:
4754
4757
  case UPB_TYPE_STRING:
4755
- return sizeof(upb_stringview);
4758
+ return sizeof(upb_strview);
4756
4759
  }
4757
4760
  UPB_UNREACHABLE();
4758
4761
  }
@@ -5242,7 +5245,7 @@ static size_t upb_msgval_sizeof2(upb_fieldtype_t type) {
5242
5245
  return sizeof(void*);
5243
5246
  case UPB_TYPE_BYTES:
5244
5247
  case UPB_TYPE_STRING:
5245
- return sizeof(upb_stringview);
5248
+ return sizeof(upb_strview);
5246
5249
  }
5247
5250
  UPB_UNREACHABLE();
5248
5251
  }
@@ -7664,7 +7667,6 @@ size_t upb_env_bytesallocated(const upb_env *e) {
7664
7667
  * Do not edit -- your changes will be discarded when the file is
7665
7668
  * regenerated. */
7666
7669
 
7667
-
7668
7670
  static const upb_msgdef msgs[22];
7669
7671
  static const upb_fielddef fields[107];
7670
7672
  static const upb_enumdef enums[5];
@@ -8900,14 +8902,21 @@ static void *file_startenum(void *closure, const void *hd) {
8900
8902
 
8901
8903
  static void *file_startext(void *closure, const void *hd) {
8902
8904
  upb_descreader *r = closure;
8903
- bool ok;
8904
8905
  r->f = upb_fielddef_new(r);
8905
- ok = upb_filedef_addext(r->file, r->f, r, NULL);
8906
8906
  UPB_UNUSED(hd);
8907
- UPB_ASSERT(ok);
8908
8907
  return r;
8909
8908
  }
8910
8909
 
8910
+ static bool file_endext(void *closure, const void *hd) {
8911
+ /* The current symtab code can't handle extensions, so we just discard
8912
+ * them for now. */
8913
+ upb_descreader *r = closure;
8914
+ upb_fielddef_unref(r->f, r);
8915
+ UPB_UNUSED(hd);
8916
+ r->f = NULL;
8917
+ return true;
8918
+ }
8919
+
8911
8920
  static size_t file_ondep(void *closure, const void *hd, const char *buf,
8912
8921
  size_t n, const upb_bufhandle *handle) {
8913
8922
  upb_descreader *r = closure;
@@ -9281,13 +9290,21 @@ static void *msg_startmsg(void *closure, const void *hd) {
9281
9290
 
9282
9291
  static void *msg_startext(void *closure, const void *hd) {
9283
9292
  upb_descreader *r = closure;
9284
- upb_fielddef *f = upb_fielddef_new(&f);
9285
- bool ok = upb_filedef_addext(r->file, f, &f, NULL);
9293
+ r->f = upb_fielddef_new(r);
9286
9294
  UPB_UNUSED(hd);
9287
- UPB_ASSERT(ok);
9288
9295
  return r;
9289
9296
  }
9290
9297
 
9298
+ static bool msg_endext(void *closure, const void *hd) {
9299
+ /* The current symtab code can't handle extensions, so we just discard
9300
+ * them for now. */
9301
+ upb_descreader *r = closure;
9302
+ upb_fielddef_unref(r->f, r);
9303
+ UPB_UNUSED(hd);
9304
+ r->f = NULL;
9305
+ return true;
9306
+ }
9307
+
9291
9308
  static void *msg_startfield(void *closure, const void *hd) {
9292
9309
  upb_descreader *r = closure;
9293
9310
  r->f = upb_fielddef_new(&r->f);
@@ -9342,6 +9359,8 @@ static void reghandlers(const void *closure, upb_handlers *h) {
9342
9359
  upb_handlers_setstring(h, F(DescriptorProto, name), &msg_name, NULL);
9343
9360
  upb_handlers_setstartsubmsg(h, F(DescriptorProto, extension), &msg_startext,
9344
9361
  NULL);
9362
+ upb_handlers_setendsubmsg(h, F(DescriptorProto, extension), &msg_endext,
9363
+ NULL);
9345
9364
  upb_handlers_setstartsubmsg(h, F(DescriptorProto, nested_type),
9346
9365
  &msg_startmsg, NULL);
9347
9366
  upb_handlers_setstartsubmsg(h, F(DescriptorProto, field),
@@ -9365,6 +9384,8 @@ static void reghandlers(const void *closure, upb_handlers *h) {
9365
9384
  &file_startenum, NULL);
9366
9385
  upb_handlers_setstartsubmsg(h, F(FileDescriptorProto, extension),
9367
9386
  &file_startext, NULL);
9387
+ upb_handlers_setendsubmsg(h, F(FileDescriptorProto, extension),
9388
+ &file_endext, NULL);
9368
9389
  upb_handlers_setstring(h, F(FileDescriptorProto, dependency),
9369
9390
  &file_ondep, NULL);
9370
9391
  } else if (upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)) {
@@ -12610,6 +12631,7 @@ done:
12610
12631
  #include <stdio.h>
12611
12632
  #include <stdlib.h>
12612
12633
  #include <string.h>
12634
+
12613
12635
  #include <time.h>
12614
12636
 
12615
12637
 
@@ -12763,6 +12785,11 @@ typedef struct {
12763
12785
  /* The table mapping json name to fielddef for this message. */
12764
12786
  upb_strtable *name_table;
12765
12787
 
12788
+ /* We are in a repeated-field context. We need this flag to decide whether to
12789
+ * handle the array as a normal repeated field or a
12790
+ * google.protobuf.ListValue/google.protobuf.Value. */
12791
+ bool is_repeated;
12792
+
12766
12793
  /* We are in a repeated-field context, ready to emit mapentries as
12767
12794
  * submessages. This flag alters the start-of-object (open-brace) behavior to
12768
12795
  * begin a sequence of mapentry messages rather than a single submessage. */
@@ -13803,6 +13830,7 @@ static bool start_stringval(upb_json_parser *p) {
13803
13830
  inner->m = p->top->m;
13804
13831
  inner->f = p->top->f;
13805
13832
  inner->name_table = NULL;
13833
+ inner->is_repeated = false;
13806
13834
  inner->is_map = false;
13807
13835
  inner->is_mapentry = false;
13808
13836
  inner->is_any = false;
@@ -14100,49 +14128,100 @@ static bool end_duration_base(upb_json_parser *p, const char *ptr) {
14100
14128
  return true;
14101
14129
  }
14102
14130
 
14103
- static void start_timestamp_base(upb_json_parser *p, const char *ptr) {
14131
+ static int parse_timestamp_number(upb_json_parser *p) {
14132
+ size_t len;
14133
+ const char *buf;
14134
+ char *end;
14135
+ int val;
14136
+
14137
+ /* atoi() and friends unfortunately do not support specifying the length of
14138
+ * the input string, so we need to force a copy into a NULL-terminated buffer. */
14139
+ multipart_text(p, "\0", 1, false);
14140
+
14141
+ buf = accumulate_getptr(p, &len);
14142
+ val = atoi(buf);
14143
+ multipart_end(p);
14144
+ multipart_startaccum(p);
14145
+
14146
+ return val;
14147
+ }
14148
+
14149
+ static void start_year(upb_json_parser *p, const char *ptr) {
14104
14150
  capture_begin(p, ptr);
14105
14151
  }
14106
14152
 
14107
- #define UPB_TIMESTAMP_BASE_SIZE 19
14153
+ static bool end_year(upb_json_parser *p, const char *ptr) {
14154
+ if (!capture_end(p, ptr)) {
14155
+ return false;
14156
+ }
14157
+ p->tm.tm_year = parse_timestamp_number(p) - 1900;
14158
+ return true;
14159
+ }
14108
14160
 
14109
- static bool end_timestamp_base(upb_json_parser *p, const char *ptr) {
14110
- size_t len;
14111
- const char *buf;
14112
- /* 3 for GMT and 1 for ending 0 */
14113
- char timestamp_buf[UPB_TIMESTAMP_BASE_SIZE + 4];
14161
+ static void start_month(upb_json_parser *p, const char *ptr) {
14162
+ capture_begin(p, ptr);
14163
+ }
14114
14164
 
14165
+ static bool end_month(upb_json_parser *p, const char *ptr) {
14115
14166
  if (!capture_end(p, ptr)) {
14116
14167
  return false;
14117
14168
  }
14169
+ p->tm.tm_mon = parse_timestamp_number(p) - 1;
14170
+ return true;
14171
+ }
14118
14172
 
14119
- buf = accumulate_getptr(p, &len);
14120
- UPB_ASSERT(len == UPB_TIMESTAMP_BASE_SIZE);
14121
- memcpy(timestamp_buf, buf, UPB_TIMESTAMP_BASE_SIZE);
14122
- memcpy(timestamp_buf + UPB_TIMESTAMP_BASE_SIZE, "GMT", 3);
14123
- timestamp_buf[UPB_TIMESTAMP_BASE_SIZE + 3] = 0;
14124
-
14125
- #if defined __MINGW32__ || defined __MINGW64__
14126
- upb_status_seterrf(
14127
- &p->status, "error parsing timestamp: mingw doesn't support strptime");
14128
- upb_env_reporterror(p->env, &p->status);
14129
- return false;
14130
- #else
14131
- /* Parse seconds */
14132
- if (strptime(timestamp_buf, "%FT%H:%M:%S%Z", &p->tm) == NULL) {
14133
- upb_status_seterrf(&p->status, "error parsing timestamp: %s", buf);
14134
- upb_env_reporterror(p->env, &p->status);
14173
+ static void start_day(upb_json_parser *p, const char *ptr) {
14174
+ capture_begin(p, ptr);
14175
+ }
14176
+
14177
+ static bool end_day(upb_json_parser *p, const char *ptr) {
14178
+ if (!capture_end(p, ptr)) {
14135
14179
  return false;
14136
14180
  }
14137
- #endif
14181
+ p->tm.tm_mday = parse_timestamp_number(p);
14182
+ return true;
14183
+ }
14138
14184
 
14139
- /* Clean up buffer */
14140
- multipart_end(p);
14141
- multipart_startaccum(p);
14185
+ static void start_hour(upb_json_parser *p, const char *ptr) {
14186
+ capture_begin(p, ptr);
14187
+ }
14142
14188
 
14189
+ static bool end_hour(upb_json_parser *p, const char *ptr) {
14190
+ if (!capture_end(p, ptr)) {
14191
+ return false;
14192
+ }
14193
+ p->tm.tm_hour = parse_timestamp_number(p);
14143
14194
  return true;
14144
14195
  }
14145
14196
 
14197
+ static void start_minute(upb_json_parser *p, const char *ptr) {
14198
+ capture_begin(p, ptr);
14199
+ }
14200
+
14201
+ static bool end_minute(upb_json_parser *p, const char *ptr) {
14202
+ if (!capture_end(p, ptr)) {
14203
+ return false;
14204
+ }
14205
+ p->tm.tm_min = parse_timestamp_number(p);
14206
+ return true;
14207
+ }
14208
+
14209
+ static void start_second(upb_json_parser *p, const char *ptr) {
14210
+ capture_begin(p, ptr);
14211
+ }
14212
+
14213
+ static bool end_second(upb_json_parser *p, const char *ptr) {
14214
+ if (!capture_end(p, ptr)) {
14215
+ return false;
14216
+ }
14217
+ p->tm.tm_sec = parse_timestamp_number(p);
14218
+ return true;
14219
+ }
14220
+
14221
+ static void start_timestamp_base(upb_json_parser *p) {
14222
+ memset(&p->tm, 0, sizeof(struct tm));
14223
+ }
14224
+
14146
14225
  static void start_timestamp_fraction(upb_json_parser *p, const char *ptr) {
14147
14226
  capture_begin(p, ptr);
14148
14227
  }
@@ -14209,7 +14288,7 @@ static void start_timestamp_zone(upb_json_parser *p, const char *ptr) {
14209
14288
  static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) {
14210
14289
  size_t len;
14211
14290
  const char *buf;
14212
- int hours;
14291
+ int hours = 0;
14213
14292
  int64_t seconds;
14214
14293
  const char *seconds_membername = "seconds";
14215
14294
 
@@ -14229,12 +14308,11 @@ static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) {
14229
14308
  if (buf[0] == '+') {
14230
14309
  hours = -hours;
14231
14310
  }
14232
-
14233
- p->tm.tm_hour += hours;
14234
14311
  }
14235
14312
 
14236
14313
  /* Normalize tm */
14237
- seconds = mktime(&p->tm);
14314
+ seconds = mktime(&p->tm) - timezone;
14315
+ seconds += 3600 * hours;
14238
14316
 
14239
14317
  /* Check timestamp boundary */
14240
14318
  if (seconds < -62135596800) {
@@ -14286,6 +14364,7 @@ static bool start_fieldmask_path(upb_json_parser *p) {
14286
14364
  inner->m = p->top->m;
14287
14365
  inner->f = p->top->f;
14288
14366
  inner->name_table = NULL;
14367
+ inner->is_repeated = false;
14289
14368
  inner->is_map = false;
14290
14369
  inner->is_mapentry = false;
14291
14370
  inner->is_any = false;
@@ -14433,6 +14512,7 @@ static bool handle_mapentry(upb_json_parser *p) {
14433
14512
  inner->m = mapentrymsg;
14434
14513
  inner->name_table = NULL;
14435
14514
  inner->mapfield = mapfield;
14515
+ inner->is_repeated = false;
14436
14516
  inner->is_map = false;
14437
14517
  inner->is_any = false;
14438
14518
  inner->any_frame = NULL;
@@ -14557,6 +14637,7 @@ static bool start_subobject(upb_json_parser *p) {
14557
14637
  inner = p->top + 1;
14558
14638
  inner->m = NULL;
14559
14639
  inner->f = NULL;
14640
+ inner->is_repeated = false;
14560
14641
  inner->is_map = false;
14561
14642
  inner->is_mapentry = false;
14562
14643
  inner->is_any = false;
@@ -14581,6 +14662,7 @@ static bool start_subobject(upb_json_parser *p) {
14581
14662
  inner->name_table = NULL;
14582
14663
  inner->mapfield = p->top->f;
14583
14664
  inner->f = NULL;
14665
+ inner->is_repeated = false;
14584
14666
  inner->is_map = true;
14585
14667
  inner->is_mapentry = false;
14586
14668
  inner->is_any = false;
@@ -14604,6 +14686,7 @@ static bool start_subobject(upb_json_parser *p) {
14604
14686
  inner->m = upb_fielddef_msgsubdef(p->top->f);
14605
14687
  set_name_table(p, inner);
14606
14688
  inner->f = NULL;
14689
+ inner->is_repeated = false;
14607
14690
  inner->is_map = false;
14608
14691
  inner->is_mapentry = false;
14609
14692
  inner->is_unknown_field = false;
@@ -14706,10 +14789,14 @@ static bool start_array(upb_json_parser *p) {
14706
14789
  } else {
14707
14790
  return false;
14708
14791
  }
14709
- } else if (is_wellknown_field(p, UPB_WELLKNOWN_LISTVALUE)) {
14792
+ } else if (is_wellknown_field(p, UPB_WELLKNOWN_LISTVALUE) &&
14793
+ (!upb_fielddef_isseq(p->top->f) ||
14794
+ p->top->is_repeated)) {
14710
14795
  if (!start_subobject(p)) return false;
14711
14796
  start_listvalue_object(p);
14712
- } else if (is_wellknown_field(p, UPB_WELLKNOWN_VALUE)) {
14797
+ } else if (is_wellknown_field(p, UPB_WELLKNOWN_VALUE) &&
14798
+ (!upb_fielddef_isseq(p->top->f) ||
14799
+ p->top->is_repeated)) {
14713
14800
  if (!start_subobject(p)) return false;
14714
14801
  start_value_object(p, VALUE_LISTVALUE);
14715
14802
  if (!start_subobject(p)) return false;
@@ -14721,6 +14808,7 @@ static bool start_array(upb_json_parser *p) {
14721
14808
  inner->m = NULL;
14722
14809
  inner->name_table = NULL;
14723
14810
  inner->f = NULL;
14811
+ inner->is_repeated = false;
14724
14812
  inner->is_map = false;
14725
14813
  inner->is_mapentry = false;
14726
14814
  inner->is_any = false;
@@ -14747,6 +14835,7 @@ static bool start_array(upb_json_parser *p) {
14747
14835
  inner->m = p->top->m;
14748
14836
  inner->name_table = NULL;
14749
14837
  inner->f = p->top->f;
14838
+ inner->is_repeated = true;
14750
14839
  inner->is_map = false;
14751
14840
  inner->is_mapentry = false;
14752
14841
  inner->is_any = false;
@@ -15130,27 +15219,30 @@ static bool is_fieldmask_object(upb_json_parser *p) {
15130
15219
  * final state once, when the closing '"' is seen. */
15131
15220
 
15132
15221
 
15133
- #line 2730 "upb/json/parser.rl"
15222
+ #line 2824 "upb/json/parser.rl"
15134
15223
 
15135
15224
 
15136
15225
 
15137
- #line 2556 "upb/json/parser.c"
15226
+ #line 2627 "upb/json/parser.c"
15138
15227
  static const char _json_actions[] = {
15139
15228
  0, 1, 0, 1, 1, 1, 3, 1,
15140
15229
  4, 1, 6, 1, 7, 1, 8, 1,
15141
- 9, 1, 10, 1, 11, 1, 12, 1,
15142
- 13, 1, 24, 1, 26, 1, 28, 1,
15143
- 29, 1, 31, 1, 32, 1, 33, 1,
15144
- 35, 1, 37, 1, 38, 1, 39, 1,
15145
- 40, 1, 42, 1, 43, 2, 4, 9,
15146
- 2, 5, 6, 2, 7, 3, 2, 7,
15147
- 9, 2, 14, 15, 2, 16, 17, 2,
15148
- 18, 19, 2, 21, 23, 2, 22, 20,
15149
- 2, 27, 25, 2, 29, 31, 2, 34,
15150
- 2, 2, 35, 43, 2, 36, 25, 2,
15151
- 38, 43, 2, 39, 43, 2, 40, 43,
15152
- 2, 41, 30, 2, 42, 43, 3, 21,
15153
- 23, 24, 4, 14, 15, 16, 17
15230
+ 9, 1, 11, 1, 12, 1, 13, 1,
15231
+ 14, 1, 15, 1, 16, 1, 17, 1,
15232
+ 18, 1, 19, 1, 20, 1, 22, 1,
15233
+ 23, 1, 24, 1, 35, 1, 37, 1,
15234
+ 39, 1, 40, 1, 42, 1, 43, 1,
15235
+ 44, 1, 46, 1, 48, 1, 49, 1,
15236
+ 50, 1, 51, 1, 53, 1, 54, 2,
15237
+ 4, 9, 2, 5, 6, 2, 7, 3,
15238
+ 2, 7, 9, 2, 21, 26, 2, 25,
15239
+ 10, 2, 27, 28, 2, 29, 30, 2,
15240
+ 32, 34, 2, 33, 31, 2, 38, 36,
15241
+ 2, 40, 42, 2, 45, 2, 2, 46,
15242
+ 54, 2, 47, 36, 2, 49, 54, 2,
15243
+ 50, 54, 2, 51, 54, 2, 52, 41,
15244
+ 2, 53, 54, 3, 32, 34, 35, 4,
15245
+ 21, 26, 27, 28
15154
15246
  };
15155
15247
 
15156
15248
  static const short _json_key_offsets[] = {
@@ -15334,30 +15426,30 @@ static const char _json_trans_targs[] = {
15334
15426
  106
15335
15427
  };
15336
15428
 
15337
- static const char _json_trans_actions[] = {
15338
- 0, 0, 92, 86, 35, 0, 0, 0,
15339
- 104, 41, 27, 0, 37, 0, 0, 0,
15429
+ static const unsigned char _json_trans_actions[] = {
15430
+ 0, 0, 113, 107, 53, 0, 0, 0,
15431
+ 125, 59, 45, 0, 55, 0, 0, 0,
15340
15432
  0, 0, 0, 0, 0, 0, 0, 0,
15341
- 0, 0, 80, 33, 29, 0, 0, 27,
15342
- 31, 31, 83, 0, 0, 0, 0, 0,
15433
+ 0, 0, 101, 51, 47, 0, 0, 45,
15434
+ 49, 49, 104, 0, 0, 0, 0, 0,
15343
15435
  3, 0, 0, 0, 0, 0, 5, 15,
15344
- 0, 0, 53, 7, 13, 0, 56, 9,
15345
- 9, 9, 59, 62, 11, 17, 17, 17,
15346
- 0, 0, 0, 19, 0, 21, 23, 0,
15347
- 0, 0, 0, 0, 0, 0, 0, 0,
15348
- 0, 0, 0, 0, 0, 0, 0, 0,
15349
- 0, 114, 65, 114, 0, 0, 0, 0,
15350
- 0, 71, 0, 68, 68, 77, 25, 0,
15351
- 110, 74, 92, 86, 35, 0, 0, 0,
15352
- 104, 41, 51, 89, 27, 0, 37, 0,
15353
- 0, 0, 0, 0, 0, 98, 0, 0,
15354
- 0, 101, 0, 0, 0, 95, 0, 80,
15355
- 33, 29, 0, 0, 27, 31, 31, 83,
15356
- 0, 0, 107, 0, 39, 45, 47, 43,
15357
- 49
15436
+ 0, 0, 71, 7, 13, 0, 74, 9,
15437
+ 9, 9, 77, 80, 11, 37, 37, 37,
15438
+ 0, 0, 0, 39, 0, 41, 86, 0,
15439
+ 0, 0, 17, 19, 0, 21, 23, 0,
15440
+ 25, 27, 0, 29, 31, 0, 33, 35,
15441
+ 0, 135, 83, 135, 0, 0, 0, 0,
15442
+ 0, 92, 0, 89, 89, 98, 43, 0,
15443
+ 131, 95, 113, 107, 53, 0, 0, 0,
15444
+ 125, 59, 69, 110, 45, 0, 55, 0,
15445
+ 0, 0, 0, 0, 0, 119, 0, 0,
15446
+ 0, 122, 0, 0, 0, 116, 0, 101,
15447
+ 51, 47, 0, 0, 45, 49, 49, 104,
15448
+ 0, 0, 128, 0, 57, 63, 65, 61,
15449
+ 67
15358
15450
  };
15359
15451
 
15360
- static const char _json_eof_actions[] = {
15452
+ static const unsigned char _json_eof_actions[] = {
15361
15453
  0, 0, 0, 0, 0, 0, 0, 0,
15362
15454
  0, 0, 0, 0, 0, 0, 0, 0,
15363
15455
  0, 0, 0, 0, 0, 0, 0, 0,
@@ -15371,7 +15463,7 @@ static const char _json_eof_actions[] = {
15371
15463
  0, 0, 0, 0, 0, 0, 0, 0,
15372
15464
  0, 0, 0, 0, 0, 0, 0, 0,
15373
15465
  0, 0, 0, 0, 0, 0, 0, 0,
15374
- 0, 0, 0, 39, 45, 47, 43, 49,
15466
+ 0, 0, 0, 57, 63, 65, 61, 67,
15375
15467
  0, 0, 0, 0, 0, 0
15376
15468
  };
15377
15469
 
@@ -15386,7 +15478,7 @@ static const int json_en_value_machine = 78;
15386
15478
  static const int json_en_main = 1;
15387
15479
 
15388
15480
 
15389
- #line 2733 "upb/json/parser.rl"
15481
+ #line 2827 "upb/json/parser.rl"
15390
15482
 
15391
15483
  size_t parse(void *closure, const void *hd, const char *buf, size_t size,
15392
15484
  const upb_bufhandle *handle) {
@@ -15409,7 +15501,7 @@ size_t parse(void *closure, const void *hd, const char *buf, size_t size,
15409
15501
  capture_resume(parser, buf);
15410
15502
 
15411
15503
 
15412
- #line 2831 "upb/json/parser.c"
15504
+ #line 2905 "upb/json/parser.c"
15413
15505
  {
15414
15506
  int _klen;
15415
15507
  unsigned int _trans;
@@ -15484,103 +15576,147 @@ _match:
15484
15576
  switch ( *_acts++ )
15485
15577
  {
15486
15578
  case 1:
15487
- #line 2561 "upb/json/parser.rl"
15579
+ #line 2632 "upb/json/parser.rl"
15488
15580
  { p--; {cs = stack[--top]; goto _again;} }
15489
15581
  break;
15490
15582
  case 2:
15491
- #line 2563 "upb/json/parser.rl"
15583
+ #line 2634 "upb/json/parser.rl"
15492
15584
  { p--; {stack[top++] = cs; cs = 23;goto _again;} }
15493
15585
  break;
15494
15586
  case 3:
15495
- #line 2567 "upb/json/parser.rl"
15587
+ #line 2638 "upb/json/parser.rl"
15496
15588
  { start_text(parser, p); }
15497
15589
  break;
15498
15590
  case 4:
15499
- #line 2568 "upb/json/parser.rl"
15591
+ #line 2639 "upb/json/parser.rl"
15500
15592
  { CHECK_RETURN_TOP(end_text(parser, p)); }
15501
15593
  break;
15502
15594
  case 5:
15503
- #line 2574 "upb/json/parser.rl"
15595
+ #line 2645 "upb/json/parser.rl"
15504
15596
  { start_hex(parser); }
15505
15597
  break;
15506
15598
  case 6:
15507
- #line 2575 "upb/json/parser.rl"
15599
+ #line 2646 "upb/json/parser.rl"
15508
15600
  { hexdigit(parser, p); }
15509
15601
  break;
15510
15602
  case 7:
15511
- #line 2576 "upb/json/parser.rl"
15603
+ #line 2647 "upb/json/parser.rl"
15512
15604
  { CHECK_RETURN_TOP(end_hex(parser)); }
15513
15605
  break;
15514
15606
  case 8:
15515
- #line 2582 "upb/json/parser.rl"
15607
+ #line 2653 "upb/json/parser.rl"
15516
15608
  { CHECK_RETURN_TOP(escape(parser, p)); }
15517
15609
  break;
15518
15610
  case 9:
15519
- #line 2588 "upb/json/parser.rl"
15611
+ #line 2659 "upb/json/parser.rl"
15520
15612
  { p--; {cs = stack[--top]; goto _again;} }
15521
15613
  break;
15522
15614
  case 10:
15523
- #line 2600 "upb/json/parser.rl"
15524
- { start_duration_base(parser, p); }
15615
+ #line 2664 "upb/json/parser.rl"
15616
+ { start_year(parser, p); }
15525
15617
  break;
15526
15618
  case 11:
15527
- #line 2601 "upb/json/parser.rl"
15528
- { CHECK_RETURN_TOP(end_duration_base(parser, p)); }
15619
+ #line 2665 "upb/json/parser.rl"
15620
+ { CHECK_RETURN_TOP(end_year(parser, p)); }
15529
15621
  break;
15530
15622
  case 12:
15531
- #line 2603 "upb/json/parser.rl"
15532
- { p--; {cs = stack[--top]; goto _again;} }
15623
+ #line 2669 "upb/json/parser.rl"
15624
+ { start_month(parser, p); }
15533
15625
  break;
15534
15626
  case 13:
15535
- #line 2608 "upb/json/parser.rl"
15536
- { start_timestamp_base(parser, p); }
15627
+ #line 2670 "upb/json/parser.rl"
15628
+ { CHECK_RETURN_TOP(end_month(parser, p)); }
15537
15629
  break;
15538
15630
  case 14:
15539
- #line 2609 "upb/json/parser.rl"
15540
- { CHECK_RETURN_TOP(end_timestamp_base(parser, p)); }
15631
+ #line 2674 "upb/json/parser.rl"
15632
+ { start_day(parser, p); }
15541
15633
  break;
15542
15634
  case 15:
15543
- #line 2611 "upb/json/parser.rl"
15544
- { start_timestamp_fraction(parser, p); }
15635
+ #line 2675 "upb/json/parser.rl"
15636
+ { CHECK_RETURN_TOP(end_day(parser, p)); }
15545
15637
  break;
15546
15638
  case 16:
15547
- #line 2612 "upb/json/parser.rl"
15548
- { CHECK_RETURN_TOP(end_timestamp_fraction(parser, p)); }
15639
+ #line 2679 "upb/json/parser.rl"
15640
+ { start_hour(parser, p); }
15549
15641
  break;
15550
15642
  case 17:
15551
- #line 2614 "upb/json/parser.rl"
15552
- { start_timestamp_zone(parser, p); }
15643
+ #line 2680 "upb/json/parser.rl"
15644
+ { CHECK_RETURN_TOP(end_hour(parser, p)); }
15553
15645
  break;
15554
15646
  case 18:
15555
- #line 2615 "upb/json/parser.rl"
15556
- { CHECK_RETURN_TOP(end_timestamp_zone(parser, p)); }
15647
+ #line 2684 "upb/json/parser.rl"
15648
+ { start_minute(parser, p); }
15557
15649
  break;
15558
15650
  case 19:
15559
- #line 2617 "upb/json/parser.rl"
15560
- { p--; {cs = stack[--top]; goto _again;} }
15651
+ #line 2685 "upb/json/parser.rl"
15652
+ { CHECK_RETURN_TOP(end_minute(parser, p)); }
15561
15653
  break;
15562
15654
  case 20:
15563
- #line 2622 "upb/json/parser.rl"
15564
- { start_fieldmask_path_text(parser, p); }
15655
+ #line 2689 "upb/json/parser.rl"
15656
+ { start_second(parser, p); }
15565
15657
  break;
15566
15658
  case 21:
15567
- #line 2623 "upb/json/parser.rl"
15568
- { end_fieldmask_path_text(parser, p); }
15659
+ #line 2690 "upb/json/parser.rl"
15660
+ { CHECK_RETURN_TOP(end_second(parser, p)); }
15569
15661
  break;
15570
15662
  case 22:
15571
- #line 2628 "upb/json/parser.rl"
15572
- { start_fieldmask_path(parser); }
15663
+ #line 2695 "upb/json/parser.rl"
15664
+ { start_duration_base(parser, p); }
15573
15665
  break;
15574
15666
  case 23:
15575
- #line 2629 "upb/json/parser.rl"
15576
- { end_fieldmask_path(parser); }
15667
+ #line 2696 "upb/json/parser.rl"
15668
+ { CHECK_RETURN_TOP(end_duration_base(parser, p)); }
15577
15669
  break;
15578
15670
  case 24:
15579
- #line 2635 "upb/json/parser.rl"
15671
+ #line 2698 "upb/json/parser.rl"
15580
15672
  { p--; {cs = stack[--top]; goto _again;} }
15581
15673
  break;
15582
15674
  case 25:
15583
- #line 2640 "upb/json/parser.rl"
15675
+ #line 2703 "upb/json/parser.rl"
15676
+ { start_timestamp_base(parser); }
15677
+ break;
15678
+ case 26:
15679
+ #line 2705 "upb/json/parser.rl"
15680
+ { start_timestamp_fraction(parser, p); }
15681
+ break;
15682
+ case 27:
15683
+ #line 2706 "upb/json/parser.rl"
15684
+ { CHECK_RETURN_TOP(end_timestamp_fraction(parser, p)); }
15685
+ break;
15686
+ case 28:
15687
+ #line 2708 "upb/json/parser.rl"
15688
+ { start_timestamp_zone(parser, p); }
15689
+ break;
15690
+ case 29:
15691
+ #line 2709 "upb/json/parser.rl"
15692
+ { CHECK_RETURN_TOP(end_timestamp_zone(parser, p)); }
15693
+ break;
15694
+ case 30:
15695
+ #line 2711 "upb/json/parser.rl"
15696
+ { p--; {cs = stack[--top]; goto _again;} }
15697
+ break;
15698
+ case 31:
15699
+ #line 2716 "upb/json/parser.rl"
15700
+ { start_fieldmask_path_text(parser, p); }
15701
+ break;
15702
+ case 32:
15703
+ #line 2717 "upb/json/parser.rl"
15704
+ { end_fieldmask_path_text(parser, p); }
15705
+ break;
15706
+ case 33:
15707
+ #line 2722 "upb/json/parser.rl"
15708
+ { start_fieldmask_path(parser); }
15709
+ break;
15710
+ case 34:
15711
+ #line 2723 "upb/json/parser.rl"
15712
+ { end_fieldmask_path(parser); }
15713
+ break;
15714
+ case 35:
15715
+ #line 2729 "upb/json/parser.rl"
15716
+ { p--; {cs = stack[--top]; goto _again;} }
15717
+ break;
15718
+ case 36:
15719
+ #line 2734 "upb/json/parser.rl"
15584
15720
  {
15585
15721
  if (is_wellknown_msg(parser, UPB_WELLKNOWN_TIMESTAMP)) {
15586
15722
  {stack[top++] = cs; cs = 47;goto _again;}
@@ -15593,12 +15729,12 @@ _match:
15593
15729
  }
15594
15730
  }
15595
15731
  break;
15596
- case 26:
15597
- #line 2653 "upb/json/parser.rl"
15732
+ case 37:
15733
+ #line 2747 "upb/json/parser.rl"
15598
15734
  { p--; {stack[top++] = cs; cs = 78;goto _again;} }
15599
15735
  break;
15600
- case 27:
15601
- #line 2658 "upb/json/parser.rl"
15736
+ case 38:
15737
+ #line 2752 "upb/json/parser.rl"
15602
15738
  {
15603
15739
  if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
15604
15740
  start_any_member(parser, p);
@@ -15607,12 +15743,12 @@ _match:
15607
15743
  }
15608
15744
  }
15609
15745
  break;
15610
- case 28:
15611
- #line 2665 "upb/json/parser.rl"
15746
+ case 39:
15747
+ #line 2759 "upb/json/parser.rl"
15612
15748
  { CHECK_RETURN_TOP(end_membername(parser)); }
15613
15749
  break;
15614
- case 29:
15615
- #line 2668 "upb/json/parser.rl"
15750
+ case 40:
15751
+ #line 2762 "upb/json/parser.rl"
15616
15752
  {
15617
15753
  if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
15618
15754
  end_any_member(parser, p);
@@ -15621,8 +15757,8 @@ _match:
15621
15757
  }
15622
15758
  }
15623
15759
  break;
15624
- case 30:
15625
- #line 2679 "upb/json/parser.rl"
15760
+ case 41:
15761
+ #line 2773 "upb/json/parser.rl"
15626
15762
  {
15627
15763
  if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
15628
15764
  start_any_object(parser, p);
@@ -15631,8 +15767,8 @@ _match:
15631
15767
  }
15632
15768
  }
15633
15769
  break;
15634
- case 31:
15635
- #line 2688 "upb/json/parser.rl"
15770
+ case 42:
15771
+ #line 2782 "upb/json/parser.rl"
15636
15772
  {
15637
15773
  if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
15638
15774
  CHECK_RETURN_TOP(end_any_object(parser, p));
@@ -15641,55 +15777,55 @@ _match:
15641
15777
  }
15642
15778
  }
15643
15779
  break;
15644
- case 32:
15645
- #line 2700 "upb/json/parser.rl"
15780
+ case 43:
15781
+ #line 2794 "upb/json/parser.rl"
15646
15782
  { CHECK_RETURN_TOP(start_array(parser)); }
15647
15783
  break;
15648
- case 33:
15649
- #line 2704 "upb/json/parser.rl"
15784
+ case 44:
15785
+ #line 2798 "upb/json/parser.rl"
15650
15786
  { end_array(parser); }
15651
15787
  break;
15652
- case 34:
15653
- #line 2709 "upb/json/parser.rl"
15788
+ case 45:
15789
+ #line 2803 "upb/json/parser.rl"
15654
15790
  { CHECK_RETURN_TOP(start_number(parser, p)); }
15655
15791
  break;
15656
- case 35:
15657
- #line 2710 "upb/json/parser.rl"
15792
+ case 46:
15793
+ #line 2804 "upb/json/parser.rl"
15658
15794
  { CHECK_RETURN_TOP(end_number(parser, p)); }
15659
15795
  break;
15660
- case 36:
15661
- #line 2712 "upb/json/parser.rl"
15796
+ case 47:
15797
+ #line 2806 "upb/json/parser.rl"
15662
15798
  { CHECK_RETURN_TOP(start_stringval(parser)); }
15663
15799
  break;
15664
- case 37:
15665
- #line 2713 "upb/json/parser.rl"
15800
+ case 48:
15801
+ #line 2807 "upb/json/parser.rl"
15666
15802
  { CHECK_RETURN_TOP(end_stringval(parser)); }
15667
15803
  break;
15668
- case 38:
15669
- #line 2715 "upb/json/parser.rl"
15804
+ case 49:
15805
+ #line 2809 "upb/json/parser.rl"
15670
15806
  { CHECK_RETURN_TOP(end_bool(parser, true)); }
15671
15807
  break;
15672
- case 39:
15673
- #line 2717 "upb/json/parser.rl"
15808
+ case 50:
15809
+ #line 2811 "upb/json/parser.rl"
15674
15810
  { CHECK_RETURN_TOP(end_bool(parser, false)); }
15675
15811
  break;
15676
- case 40:
15677
- #line 2719 "upb/json/parser.rl"
15812
+ case 51:
15813
+ #line 2813 "upb/json/parser.rl"
15678
15814
  { CHECK_RETURN_TOP(end_null(parser)); }
15679
15815
  break;
15680
- case 41:
15681
- #line 2721 "upb/json/parser.rl"
15816
+ case 52:
15817
+ #line 2815 "upb/json/parser.rl"
15682
15818
  { CHECK_RETURN_TOP(start_subobject_full(parser)); }
15683
15819
  break;
15684
- case 42:
15685
- #line 2722 "upb/json/parser.rl"
15820
+ case 53:
15821
+ #line 2816 "upb/json/parser.rl"
15686
15822
  { end_subobject_full(parser); }
15687
15823
  break;
15688
- case 43:
15689
- #line 2727 "upb/json/parser.rl"
15824
+ case 54:
15825
+ #line 2821 "upb/json/parser.rl"
15690
15826
  { p--; {cs = stack[--top]; goto _again;} }
15691
15827
  break;
15692
- #line 3111 "upb/json/parser.c"
15828
+ #line 3229 "upb/json/parser.c"
15693
15829
  }
15694
15830
  }
15695
15831
 
@@ -15706,32 +15842,32 @@ _again:
15706
15842
  while ( __nacts-- > 0 ) {
15707
15843
  switch ( *__acts++ ) {
15708
15844
  case 0:
15709
- #line 2559 "upb/json/parser.rl"
15845
+ #line 2630 "upb/json/parser.rl"
15710
15846
  { p--; {cs = stack[--top]; if ( p == pe )
15711
15847
  goto _test_eof;
15712
15848
  goto _again;} }
15713
15849
  break;
15714
- case 35:
15715
- #line 2710 "upb/json/parser.rl"
15850
+ case 46:
15851
+ #line 2804 "upb/json/parser.rl"
15716
15852
  { CHECK_RETURN_TOP(end_number(parser, p)); }
15717
15853
  break;
15718
- case 38:
15719
- #line 2715 "upb/json/parser.rl"
15854
+ case 49:
15855
+ #line 2809 "upb/json/parser.rl"
15720
15856
  { CHECK_RETURN_TOP(end_bool(parser, true)); }
15721
15857
  break;
15722
- case 39:
15723
- #line 2717 "upb/json/parser.rl"
15858
+ case 50:
15859
+ #line 2811 "upb/json/parser.rl"
15724
15860
  { CHECK_RETURN_TOP(end_bool(parser, false)); }
15725
15861
  break;
15726
- case 40:
15727
- #line 2719 "upb/json/parser.rl"
15862
+ case 51:
15863
+ #line 2813 "upb/json/parser.rl"
15728
15864
  { CHECK_RETURN_TOP(end_null(parser)); }
15729
15865
  break;
15730
- case 42:
15731
- #line 2722 "upb/json/parser.rl"
15866
+ case 53:
15867
+ #line 2816 "upb/json/parser.rl"
15732
15868
  { end_subobject_full(parser); }
15733
15869
  break;
15734
- #line 3153 "upb/json/parser.c"
15870
+ #line 3271 "upb/json/parser.c"
15735
15871
  }
15736
15872
  }
15737
15873
  }
@@ -15739,7 +15875,7 @@ goto _again;} }
15739
15875
  _out: {}
15740
15876
  }
15741
15877
 
15742
- #line 2755 "upb/json/parser.rl"
15878
+ #line 2849 "upb/json/parser.rl"
15743
15879
 
15744
15880
  if (p != pe) {
15745
15881
  upb_status_seterrf(&parser->status, "Parse error at '%.*s'\n", pe - p, p);
@@ -15780,6 +15916,7 @@ static void json_parser_reset(upb_json_parser *p) {
15780
15916
 
15781
15917
  p->top = p->stack;
15782
15918
  p->top->f = NULL;
15919
+ p->top->is_repeated = false;
15783
15920
  p->top->is_map = false;
15784
15921
  p->top->is_mapentry = false;
15785
15922
  p->top->is_any = false;
@@ -15788,13 +15925,13 @@ static void json_parser_reset(upb_json_parser *p) {
15788
15925
 
15789
15926
  /* Emit Ragel initialization of the parser. */
15790
15927
 
15791
- #line 3210 "upb/json/parser.c"
15928
+ #line 3329 "upb/json/parser.c"
15792
15929
  {
15793
15930
  cs = json_start;
15794
15931
  top = 0;
15795
15932
  }
15796
15933
 
15797
- #line 2803 "upb/json/parser.rl"
15934
+ #line 2898 "upb/json/parser.rl"
15798
15935
  p->current_state = cs;
15799
15936
  p->parser_top = top;
15800
15937
  accumulate_clear(p);
@@ -16396,9 +16533,14 @@ static size_t putbytes(void *closure, const void *handler_data, const char *str,
16396
16533
  UPB_UNUSED(handler_data);
16397
16534
  UPB_UNUSED(handle);
16398
16535
 
16536
+ print_data(p, "\"", 1);
16537
+
16399
16538
  while (remaining > 2) {
16400
- /* TODO(haberman): handle encoded lengths > sizeof(data) */
16401
- UPB_ASSERT((limit - to) >= 4);
16539
+ if (limit - to < 4) {
16540
+ bytes = to - data;
16541
+ putstring(p, data, bytes);
16542
+ to = data;
16543
+ }
16402
16544
 
16403
16545
  to[0] = base64[from[0] >> 2];
16404
16546
  to[1] = base64[((from[0] & 0x3) << 4) | (from[1] >> 4)];
@@ -16430,7 +16572,6 @@ static size_t putbytes(void *closure, const void *handler_data, const char *str,
16430
16572
  }
16431
16573
 
16432
16574
  bytes = to - data;
16433
- print_data(p, "\"", 1);
16434
16575
  putstring(p, data, bytes);
16435
16576
  print_data(p, "\"", 1);
16436
16577
  return len;
@@ -16703,7 +16844,6 @@ static void *startseq_fieldmask(void *closure, const void *handler_data) {
16703
16844
  UPB_UNUSED(handler_data);
16704
16845
  p->depth_++;
16705
16846
  p->first_elem_[p->depth_] = true;
16706
- print_data(p, "\"", 1);
16707
16847
  return closure;
16708
16848
  }
16709
16849
 
@@ -16711,7 +16851,6 @@ static bool endseq_fieldmask(void *closure, const void *handler_data) {
16711
16851
  upb_json_printer *p = closure;
16712
16852
  UPB_UNUSED(handler_data);
16713
16853
  p->depth_--;
16714
- print_data(p, "\"", 1);
16715
16854
  return true;
16716
16855
  }
16717
16856
 
@@ -16931,6 +17070,29 @@ static bool printer_endmsg_noframe(
16931
17070
  return true;
16932
17071
  }
16933
17072
 
17073
+ static bool printer_startmsg_fieldmask(
17074
+ void *closure, const void *handler_data) {
17075
+ upb_json_printer *p = closure;
17076
+ UPB_UNUSED(handler_data);
17077
+ if (p->depth_ == 0) {
17078
+ upb_bytessink_start(p->output_, 0, &p->subc_);
17079
+ }
17080
+ print_data(p, "\"", 1);
17081
+ return true;
17082
+ }
17083
+
17084
+ static bool printer_endmsg_fieldmask(
17085
+ void *closure, const void *handler_data, upb_status *s) {
17086
+ upb_json_printer *p = closure;
17087
+ UPB_UNUSED(handler_data);
17088
+ UPB_UNUSED(s);
17089
+ print_data(p, "\"", 1);
17090
+ if (p->depth_ == 0) {
17091
+ upb_bytessink_end(p->output_);
17092
+ }
17093
+ return true;
17094
+ }
17095
+
16934
17096
  static void *scalar_startstr_onlykey(
16935
17097
  void *closure, const void *handler_data, size_t size_hint) {
16936
17098
  upb_json_printer *p = closure;
@@ -16984,8 +17146,8 @@ void printer_sethandlers_fieldmask(const void *closure, upb_handlers *h) {
16984
17146
  upb_handlers_setstartseq(h, f, startseq_fieldmask, &empty_attr);
16985
17147
  upb_handlers_setendseq(h, f, endseq_fieldmask, &empty_attr);
16986
17148
 
16987
- upb_handlers_setstartmsg(h, printer_startmsg_noframe, &empty_attr);
16988
- upb_handlers_setendmsg(h, printer_endmsg_noframe, &empty_attr);
17149
+ upb_handlers_setstartmsg(h, printer_startmsg_fieldmask, &empty_attr);
17150
+ upb_handlers_setendmsg(h, printer_endmsg_fieldmask, &empty_attr);
16989
17151
 
16990
17152
  upb_handlers_setstartstr(h, f, repeated_startstr_fieldmask, &empty_attr);
16991
17153
  upb_handlers_setstring(h, f, repeated_str_fieldmask, &empty_attr);