google-protobuf 3.7.0 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of google-protobuf might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/defs.c +7 -7
- data/ext/google/protobuf_c/encode_decode.c +41 -1
- data/ext/google/protobuf_c/map.c +8 -2
- data/ext/google/protobuf_c/message.c +124 -8
- data/ext/google/protobuf_c/protobuf.h +5 -3
- data/ext/google/protobuf_c/repeated_field.c +9 -3
- data/ext/google/protobuf_c/storage.c +66 -23
- data/ext/google/protobuf_c/upb.c +478 -316
- data/ext/google/protobuf_c/upb.h +1390 -504
- data/tests/basic.rb +22 -2
- metadata +4 -5
data/ext/google/protobuf_c/upb.c
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
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(
|
57
|
-
{2, UPB_SIZE(
|
58
|
-
{3, UPB_SIZE(
|
59
|
-
{4, UPB_SIZE(
|
60
|
-
{5, UPB_SIZE(
|
61
|
-
{6, UPB_SIZE(
|
62
|
-
{7, UPB_SIZE(
|
63
|
-
{8, UPB_SIZE(
|
64
|
-
{9, UPB_SIZE(
|
65
|
-
{10, UPB_SIZE(
|
66
|
-
{11, UPB_SIZE(
|
67
|
-
{12, UPB_SIZE(
|
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(
|
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(
|
88
|
-
{2, UPB_SIZE(
|
89
|
-
{3, UPB_SIZE(
|
90
|
-
{4, UPB_SIZE(
|
91
|
-
{5, UPB_SIZE(
|
92
|
-
{6, UPB_SIZE(
|
93
|
-
{7, UPB_SIZE(
|
94
|
-
{8, UPB_SIZE(
|
95
|
-
{9, UPB_SIZE(
|
96
|
-
{10, UPB_SIZE(
|
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(
|
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(
|
175
|
-
{2, UPB_SIZE(
|
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(
|
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(
|
192
|
-
{2, UPB_SIZE(
|
193
|
-
{3, UPB_SIZE(
|
194
|
-
{4, UPB_SIZE(
|
195
|
-
{5, UPB_SIZE(
|
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,
|
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,
|
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,
|
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(
|
238
|
-
{2, UPB_SIZE(
|
239
|
-
{3, UPB_SIZE(
|
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(
|
254
|
-
{2, UPB_SIZE(
|
255
|
-
{3, UPB_SIZE(
|
256
|
-
{4, UPB_SIZE(
|
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(
|
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(
|
273
|
-
{8, UPB_SIZE(
|
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(
|
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(
|
285
|
-
{37, UPB_SIZE(
|
286
|
-
{39, UPB_SIZE(
|
287
|
-
{40, UPB_SIZE(
|
288
|
-
{41, UPB_SIZE(
|
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(
|
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(
|
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(
|
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(
|
460
|
-
{2, UPB_SIZE(
|
461
|
-
{3, UPB_SIZE(
|
462
|
-
{4, UPB_SIZE(
|
463
|
-
{6, UPB_SIZE(
|
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(
|
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(
|
488
|
-
{2, UPB_SIZE(
|
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(
|
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
|
-
|
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 =
|
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
|
-
|
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,
|
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
|
-
|
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
|
-
|
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(
|
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
|
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
|
-
|
3721
|
-
|
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
|
-
|
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(
|
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(
|
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
|
-
|
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)) {
|
@@ -12603,6 +12624,7 @@ done:
|
|
12603
12624
|
** - handling of keys/escape-sequences/etc that span input buffers.
|
12604
12625
|
*/
|
12605
12626
|
|
12627
|
+
#include <ctype.h>
|
12606
12628
|
#include <errno.h>
|
12607
12629
|
#include <float.h>
|
12608
12630
|
#include <math.h>
|
@@ -12610,6 +12632,7 @@ done:
|
|
12610
12632
|
#include <stdio.h>
|
12611
12633
|
#include <stdlib.h>
|
12612
12634
|
#include <string.h>
|
12635
|
+
|
12613
12636
|
#include <time.h>
|
12614
12637
|
|
12615
12638
|
|
@@ -12763,6 +12786,11 @@ typedef struct {
|
|
12763
12786
|
/* The table mapping json name to fielddef for this message. */
|
12764
12787
|
upb_strtable *name_table;
|
12765
12788
|
|
12789
|
+
/* We are in a repeated-field context. We need this flag to decide whether to
|
12790
|
+
* handle the array as a normal repeated field or a
|
12791
|
+
* google.protobuf.ListValue/google.protobuf.Value. */
|
12792
|
+
bool is_repeated;
|
12793
|
+
|
12766
12794
|
/* We are in a repeated-field context, ready to emit mapentries as
|
12767
12795
|
* submessages. This flag alters the start-of-object (open-brace) behavior to
|
12768
12796
|
* begin a sequence of mapentry messages rather than a single submessage. */
|
@@ -12793,6 +12821,19 @@ typedef struct {
|
|
12793
12821
|
bool is_unknown_field;
|
12794
12822
|
} upb_jsonparser_frame;
|
12795
12823
|
|
12824
|
+
static void init_frame(upb_jsonparser_frame* frame) {
|
12825
|
+
frame->m = NULL;
|
12826
|
+
frame->f = NULL;
|
12827
|
+
frame->name_table = NULL;
|
12828
|
+
frame->is_repeated = false;
|
12829
|
+
frame->is_map = false;
|
12830
|
+
frame->is_mapentry = false;
|
12831
|
+
frame->mapfield = NULL;
|
12832
|
+
frame->is_any = false;
|
12833
|
+
frame->any_frame = NULL;
|
12834
|
+
frame->is_unknown_field = false;
|
12835
|
+
}
|
12836
|
+
|
12796
12837
|
struct upb_json_parser {
|
12797
12838
|
upb_env *env;
|
12798
12839
|
const upb_json_parsermethod *method;
|
@@ -12840,6 +12881,13 @@ struct upb_json_parser {
|
|
12840
12881
|
struct tm tm;
|
12841
12882
|
};
|
12842
12883
|
|
12884
|
+
static upb_jsonparser_frame* start_jsonparser_frame(upb_json_parser *p) {
|
12885
|
+
upb_jsonparser_frame *inner;
|
12886
|
+
inner = p->top + 1;
|
12887
|
+
init_frame(inner);
|
12888
|
+
return inner;
|
12889
|
+
}
|
12890
|
+
|
12843
12891
|
struct upb_json_parsermethod {
|
12844
12892
|
upb_refcounted base;
|
12845
12893
|
|
@@ -13797,17 +13845,11 @@ static bool start_stringval(upb_json_parser *p) {
|
|
13797
13845
|
|
13798
13846
|
/* Start a new parser frame: parser frames correspond one-to-one with
|
13799
13847
|
* handler frames, and string events occur in a sub-frame. */
|
13800
|
-
inner = p
|
13848
|
+
inner = start_jsonparser_frame(p);
|
13801
13849
|
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR);
|
13802
13850
|
upb_sink_startstr(&p->top->sink, sel, 0, &inner->sink);
|
13803
13851
|
inner->m = p->top->m;
|
13804
13852
|
inner->f = p->top->f;
|
13805
|
-
inner->name_table = NULL;
|
13806
|
-
inner->is_map = false;
|
13807
|
-
inner->is_mapentry = false;
|
13808
|
-
inner->is_any = false;
|
13809
|
-
inner->any_frame = NULL;
|
13810
|
-
inner->is_unknown_field = false;
|
13811
13853
|
p->top = inner;
|
13812
13854
|
|
13813
13855
|
if (upb_fielddef_type(p->top->f) == UPB_TYPE_STRING) {
|
@@ -14100,49 +14142,100 @@ static bool end_duration_base(upb_json_parser *p, const char *ptr) {
|
|
14100
14142
|
return true;
|
14101
14143
|
}
|
14102
14144
|
|
14103
|
-
static
|
14145
|
+
static int parse_timestamp_number(upb_json_parser *p) {
|
14146
|
+
size_t len;
|
14147
|
+
const char *buf;
|
14148
|
+
char *end;
|
14149
|
+
int val;
|
14150
|
+
|
14151
|
+
/* atoi() and friends unfortunately do not support specifying the length of
|
14152
|
+
* the input string, so we need to force a copy into a NULL-terminated buffer. */
|
14153
|
+
multipart_text(p, "\0", 1, false);
|
14154
|
+
|
14155
|
+
buf = accumulate_getptr(p, &len);
|
14156
|
+
val = atoi(buf);
|
14157
|
+
multipart_end(p);
|
14158
|
+
multipart_startaccum(p);
|
14159
|
+
|
14160
|
+
return val;
|
14161
|
+
}
|
14162
|
+
|
14163
|
+
static void start_year(upb_json_parser *p, const char *ptr) {
|
14104
14164
|
capture_begin(p, ptr);
|
14105
14165
|
}
|
14106
14166
|
|
14107
|
-
|
14167
|
+
static bool end_year(upb_json_parser *p, const char *ptr) {
|
14168
|
+
if (!capture_end(p, ptr)) {
|
14169
|
+
return false;
|
14170
|
+
}
|
14171
|
+
p->tm.tm_year = parse_timestamp_number(p) - 1900;
|
14172
|
+
return true;
|
14173
|
+
}
|
14108
14174
|
|
14109
|
-
static
|
14110
|
-
|
14111
|
-
|
14112
|
-
/* 3 for GMT and 1 for ending 0 */
|
14113
|
-
char timestamp_buf[UPB_TIMESTAMP_BASE_SIZE + 4];
|
14175
|
+
static void start_month(upb_json_parser *p, const char *ptr) {
|
14176
|
+
capture_begin(p, ptr);
|
14177
|
+
}
|
14114
14178
|
|
14179
|
+
static bool end_month(upb_json_parser *p, const char *ptr) {
|
14115
14180
|
if (!capture_end(p, ptr)) {
|
14116
14181
|
return false;
|
14117
14182
|
}
|
14183
|
+
p->tm.tm_mon = parse_timestamp_number(p) - 1;
|
14184
|
+
return true;
|
14185
|
+
}
|
14118
14186
|
|
14119
|
-
|
14120
|
-
|
14121
|
-
|
14122
|
-
|
14123
|
-
|
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);
|
14187
|
+
static void start_day(upb_json_parser *p, const char *ptr) {
|
14188
|
+
capture_begin(p, ptr);
|
14189
|
+
}
|
14190
|
+
|
14191
|
+
static bool end_day(upb_json_parser *p, const char *ptr) {
|
14192
|
+
if (!capture_end(p, ptr)) {
|
14135
14193
|
return false;
|
14136
14194
|
}
|
14137
|
-
|
14195
|
+
p->tm.tm_mday = parse_timestamp_number(p);
|
14196
|
+
return true;
|
14197
|
+
}
|
14138
14198
|
|
14139
|
-
|
14140
|
-
|
14141
|
-
|
14199
|
+
static void start_hour(upb_json_parser *p, const char *ptr) {
|
14200
|
+
capture_begin(p, ptr);
|
14201
|
+
}
|
14142
14202
|
|
14203
|
+
static bool end_hour(upb_json_parser *p, const char *ptr) {
|
14204
|
+
if (!capture_end(p, ptr)) {
|
14205
|
+
return false;
|
14206
|
+
}
|
14207
|
+
p->tm.tm_hour = parse_timestamp_number(p);
|
14143
14208
|
return true;
|
14144
14209
|
}
|
14145
14210
|
|
14211
|
+
static void start_minute(upb_json_parser *p, const char *ptr) {
|
14212
|
+
capture_begin(p, ptr);
|
14213
|
+
}
|
14214
|
+
|
14215
|
+
static bool end_minute(upb_json_parser *p, const char *ptr) {
|
14216
|
+
if (!capture_end(p, ptr)) {
|
14217
|
+
return false;
|
14218
|
+
}
|
14219
|
+
p->tm.tm_min = parse_timestamp_number(p);
|
14220
|
+
return true;
|
14221
|
+
}
|
14222
|
+
|
14223
|
+
static void start_second(upb_json_parser *p, const char *ptr) {
|
14224
|
+
capture_begin(p, ptr);
|
14225
|
+
}
|
14226
|
+
|
14227
|
+
static bool end_second(upb_json_parser *p, const char *ptr) {
|
14228
|
+
if (!capture_end(p, ptr)) {
|
14229
|
+
return false;
|
14230
|
+
}
|
14231
|
+
p->tm.tm_sec = parse_timestamp_number(p);
|
14232
|
+
return true;
|
14233
|
+
}
|
14234
|
+
|
14235
|
+
static void start_timestamp_base(upb_json_parser *p) {
|
14236
|
+
memset(&p->tm, 0, sizeof(struct tm));
|
14237
|
+
}
|
14238
|
+
|
14146
14239
|
static void start_timestamp_fraction(upb_json_parser *p, const char *ptr) {
|
14147
14240
|
capture_begin(p, ptr);
|
14148
14241
|
}
|
@@ -14206,10 +14299,51 @@ static void start_timestamp_zone(upb_json_parser *p, const char *ptr) {
|
|
14206
14299
|
capture_begin(p, ptr);
|
14207
14300
|
}
|
14208
14301
|
|
14302
|
+
#define EPOCH_YEAR 1970
|
14303
|
+
#define TM_YEAR_BASE 1900
|
14304
|
+
|
14305
|
+
static bool isleap(int year) {
|
14306
|
+
return (year % 4) == 0 && (year % 100 != 0 || (year % 400) == 0);
|
14307
|
+
}
|
14308
|
+
|
14309
|
+
const unsigned short int __mon_yday[2][13] = {
|
14310
|
+
/* Normal years. */
|
14311
|
+
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
|
14312
|
+
/* Leap years. */
|
14313
|
+
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
|
14314
|
+
};
|
14315
|
+
|
14316
|
+
int64_t epoch(int year, int yday, int hour, int min, int sec) {
|
14317
|
+
int64_t years = year - EPOCH_YEAR;
|
14318
|
+
|
14319
|
+
int64_t leap_days = years / 4 - years / 100 + years / 400;
|
14320
|
+
|
14321
|
+
int64_t days = years * 365 + yday + leap_days;
|
14322
|
+
int64_t hours = days * 24 + hour;
|
14323
|
+
int64_t mins = hours * 60 + min;
|
14324
|
+
int64_t secs = mins * 60 + sec;
|
14325
|
+
return secs;
|
14326
|
+
}
|
14327
|
+
|
14328
|
+
static int64_t upb_mktime(const struct tm *tp) {
|
14329
|
+
int sec = tp->tm_sec;
|
14330
|
+
int min = tp->tm_min;
|
14331
|
+
int hour = tp->tm_hour;
|
14332
|
+
int mday = tp->tm_mday;
|
14333
|
+
int mon = tp->tm_mon;
|
14334
|
+
int year = tp->tm_year + TM_YEAR_BASE;
|
14335
|
+
|
14336
|
+
/* Calculate day of year from year, month, and day of month. */
|
14337
|
+
int mon_yday = ((__mon_yday[isleap(year)][mon]) - 1);
|
14338
|
+
int yday = mon_yday + mday;
|
14339
|
+
|
14340
|
+
return epoch(year, yday, hour, min, sec);
|
14341
|
+
}
|
14342
|
+
|
14209
14343
|
static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) {
|
14210
14344
|
size_t len;
|
14211
14345
|
const char *buf;
|
14212
|
-
int hours;
|
14346
|
+
int hours = 0;
|
14213
14347
|
int64_t seconds;
|
14214
14348
|
const char *seconds_membername = "seconds";
|
14215
14349
|
|
@@ -14229,12 +14363,11 @@ static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) {
|
|
14229
14363
|
if (buf[0] == '+') {
|
14230
14364
|
hours = -hours;
|
14231
14365
|
}
|
14232
|
-
|
14233
|
-
p->tm.tm_hour += hours;
|
14234
14366
|
}
|
14235
14367
|
|
14236
14368
|
/* Normalize tm */
|
14237
|
-
seconds =
|
14369
|
+
seconds = upb_mktime(&p->tm);
|
14370
|
+
seconds += 3600 * hours;
|
14238
14371
|
|
14239
14372
|
/* Check timestamp boundary */
|
14240
14373
|
if (seconds < -62135596800) {
|
@@ -14280,17 +14413,11 @@ static bool start_fieldmask_path(upb_json_parser *p) {
|
|
14280
14413
|
|
14281
14414
|
/* Start a new parser frame: parser frames correspond one-to-one with
|
14282
14415
|
* handler frames, and string events occur in a sub-frame. */
|
14283
|
-
inner = p
|
14416
|
+
inner = start_jsonparser_frame(p);
|
14284
14417
|
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR);
|
14285
14418
|
upb_sink_startstr(&p->top->sink, sel, 0, &inner->sink);
|
14286
14419
|
inner->m = p->top->m;
|
14287
14420
|
inner->f = p->top->f;
|
14288
|
-
inner->name_table = NULL;
|
14289
|
-
inner->is_map = false;
|
14290
|
-
inner->is_mapentry = false;
|
14291
|
-
inner->is_any = false;
|
14292
|
-
inner->any_frame = NULL;
|
14293
|
-
inner->is_unknown_field = false;
|
14294
14421
|
p->top = inner;
|
14295
14422
|
|
14296
14423
|
multipart_startaccum(p);
|
@@ -14426,17 +14553,12 @@ static bool handle_mapentry(upb_json_parser *p) {
|
|
14426
14553
|
mapfield = p->top->mapfield;
|
14427
14554
|
mapentrymsg = upb_fielddef_msgsubdef(mapfield);
|
14428
14555
|
|
14429
|
-
inner = p
|
14556
|
+
inner = start_jsonparser_frame(p);
|
14430
14557
|
p->top->f = mapfield;
|
14431
14558
|
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG);
|
14432
14559
|
upb_sink_startsubmsg(&p->top->sink, sel, &inner->sink);
|
14433
14560
|
inner->m = mapentrymsg;
|
14434
|
-
inner->name_table = NULL;
|
14435
14561
|
inner->mapfield = mapfield;
|
14436
|
-
inner->is_map = false;
|
14437
|
-
inner->is_any = false;
|
14438
|
-
inner->any_frame = NULL;
|
14439
|
-
inner->is_unknown_field = false;
|
14440
14562
|
|
14441
14563
|
/* Don't set this to true *yet* -- we reuse parsing handlers below to push
|
14442
14564
|
* the key field value to the sink, and these handlers will pop the frame
|
@@ -14554,15 +14676,7 @@ static bool start_subobject(upb_json_parser *p) {
|
|
14554
14676
|
upb_jsonparser_frame *inner;
|
14555
14677
|
if (!check_stack(p)) return false;
|
14556
14678
|
|
14557
|
-
|
14558
|
-
inner->m = NULL;
|
14559
|
-
inner->f = NULL;
|
14560
|
-
inner->is_map = false;
|
14561
|
-
inner->is_mapentry = false;
|
14562
|
-
inner->is_any = false;
|
14563
|
-
inner->any_frame = NULL;
|
14564
|
-
inner->is_unknown_field = false;
|
14565
|
-
p->top = inner;
|
14679
|
+
p->top = start_jsonparser_frame(p);
|
14566
14680
|
return true;
|
14567
14681
|
}
|
14568
14682
|
|
@@ -14574,18 +14688,12 @@ static bool start_subobject(upb_json_parser *p) {
|
|
14574
14688
|
* context. */
|
14575
14689
|
if (!check_stack(p)) return false;
|
14576
14690
|
|
14577
|
-
inner = p
|
14691
|
+
inner = start_jsonparser_frame(p);
|
14578
14692
|
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSEQ);
|
14579
14693
|
upb_sink_startseq(&p->top->sink, sel, &inner->sink);
|
14580
14694
|
inner->m = upb_fielddef_msgsubdef(p->top->f);
|
14581
|
-
inner->name_table = NULL;
|
14582
14695
|
inner->mapfield = p->top->f;
|
14583
|
-
inner->f = NULL;
|
14584
14696
|
inner->is_map = true;
|
14585
|
-
inner->is_mapentry = false;
|
14586
|
-
inner->is_any = false;
|
14587
|
-
inner->any_frame = NULL;
|
14588
|
-
inner->is_unknown_field = false;
|
14589
14697
|
p->top = inner;
|
14590
14698
|
|
14591
14699
|
return true;
|
@@ -14597,16 +14705,11 @@ static bool start_subobject(upb_json_parser *p) {
|
|
14597
14705
|
* context. */
|
14598
14706
|
if (!check_stack(p)) return false;
|
14599
14707
|
|
14600
|
-
inner = p
|
14601
|
-
|
14708
|
+
inner = start_jsonparser_frame(p);
|
14602
14709
|
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG);
|
14603
14710
|
upb_sink_startsubmsg(&p->top->sink, sel, &inner->sink);
|
14604
14711
|
inner->m = upb_fielddef_msgsubdef(p->top->f);
|
14605
14712
|
set_name_table(p, inner);
|
14606
|
-
inner->f = NULL;
|
14607
|
-
inner->is_map = false;
|
14608
|
-
inner->is_mapentry = false;
|
14609
|
-
inner->is_unknown_field = false;
|
14610
14713
|
p->top = inner;
|
14611
14714
|
|
14612
14715
|
if (is_wellknown_msg(p, UPB_WELLKNOWN_ANY)) {
|
@@ -14706,10 +14809,14 @@ static bool start_array(upb_json_parser *p) {
|
|
14706
14809
|
} else {
|
14707
14810
|
return false;
|
14708
14811
|
}
|
14709
|
-
} else if (is_wellknown_field(p, UPB_WELLKNOWN_LISTVALUE)
|
14812
|
+
} else if (is_wellknown_field(p, UPB_WELLKNOWN_LISTVALUE) &&
|
14813
|
+
(!upb_fielddef_isseq(p->top->f) ||
|
14814
|
+
p->top->is_repeated)) {
|
14710
14815
|
if (!start_subobject(p)) return false;
|
14711
14816
|
start_listvalue_object(p);
|
14712
|
-
} else if (is_wellknown_field(p, UPB_WELLKNOWN_VALUE)
|
14817
|
+
} else if (is_wellknown_field(p, UPB_WELLKNOWN_VALUE) &&
|
14818
|
+
(!upb_fielddef_isseq(p->top->f) ||
|
14819
|
+
p->top->is_repeated)) {
|
14713
14820
|
if (!start_subobject(p)) return false;
|
14714
14821
|
start_value_object(p, VALUE_LISTVALUE);
|
14715
14822
|
if (!start_subobject(p)) return false;
|
@@ -14717,14 +14824,7 @@ static bool start_array(upb_json_parser *p) {
|
|
14717
14824
|
}
|
14718
14825
|
|
14719
14826
|
if (p->top->is_unknown_field) {
|
14720
|
-
inner = p
|
14721
|
-
inner->m = NULL;
|
14722
|
-
inner->name_table = NULL;
|
14723
|
-
inner->f = NULL;
|
14724
|
-
inner->is_map = false;
|
14725
|
-
inner->is_mapentry = false;
|
14726
|
-
inner->is_any = false;
|
14727
|
-
inner->any_frame = NULL;
|
14827
|
+
inner = start_jsonparser_frame(p);
|
14728
14828
|
inner->is_unknown_field = true;
|
14729
14829
|
p->top = inner;
|
14730
14830
|
|
@@ -14741,17 +14841,12 @@ static bool start_array(upb_json_parser *p) {
|
|
14741
14841
|
|
14742
14842
|
if (!check_stack(p)) return false;
|
14743
14843
|
|
14744
|
-
inner = p
|
14844
|
+
inner = start_jsonparser_frame(p);
|
14745
14845
|
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSEQ);
|
14746
14846
|
upb_sink_startseq(&p->top->sink, sel, &inner->sink);
|
14747
14847
|
inner->m = p->top->m;
|
14748
|
-
inner->name_table = NULL;
|
14749
14848
|
inner->f = p->top->f;
|
14750
|
-
inner->
|
14751
|
-
inner->is_mapentry = false;
|
14752
|
-
inner->is_any = false;
|
14753
|
-
inner->any_frame = NULL;
|
14754
|
-
inner->is_unknown_field = false;
|
14849
|
+
inner->is_repeated = true;
|
14755
14850
|
p->top = inner;
|
14756
14851
|
|
14757
14852
|
return true;
|
@@ -15130,27 +15225,30 @@ static bool is_fieldmask_object(upb_json_parser *p) {
|
|
15130
15225
|
* final state once, when the closing '"' is seen. */
|
15131
15226
|
|
15132
15227
|
|
15133
|
-
#line
|
15228
|
+
#line 2789 "upb/json/parser.rl"
|
15134
15229
|
|
15135
15230
|
|
15136
15231
|
|
15137
|
-
#line
|
15232
|
+
#line 2592 "upb/json/parser.c"
|
15138
15233
|
static const char _json_actions[] = {
|
15139
15234
|
0, 1, 0, 1, 1, 1, 3, 1,
|
15140
15235
|
4, 1, 6, 1, 7, 1, 8, 1,
|
15141
|
-
9, 1,
|
15142
|
-
|
15143
|
-
|
15144
|
-
|
15145
|
-
|
15146
|
-
|
15147
|
-
|
15148
|
-
|
15149
|
-
2,
|
15150
|
-
|
15151
|
-
|
15152
|
-
2,
|
15153
|
-
|
15236
|
+
9, 1, 11, 1, 12, 1, 13, 1,
|
15237
|
+
14, 1, 15, 1, 16, 1, 17, 1,
|
15238
|
+
18, 1, 19, 1, 20, 1, 22, 1,
|
15239
|
+
23, 1, 24, 1, 35, 1, 37, 1,
|
15240
|
+
39, 1, 40, 1, 42, 1, 43, 1,
|
15241
|
+
44, 1, 46, 1, 48, 1, 49, 1,
|
15242
|
+
50, 1, 51, 1, 53, 1, 54, 2,
|
15243
|
+
4, 9, 2, 5, 6, 2, 7, 3,
|
15244
|
+
2, 7, 9, 2, 21, 26, 2, 25,
|
15245
|
+
10, 2, 27, 28, 2, 29, 30, 2,
|
15246
|
+
32, 34, 2, 33, 31, 2, 38, 36,
|
15247
|
+
2, 40, 42, 2, 45, 2, 2, 46,
|
15248
|
+
54, 2, 47, 36, 2, 49, 54, 2,
|
15249
|
+
50, 54, 2, 51, 54, 2, 52, 41,
|
15250
|
+
2, 53, 54, 3, 32, 34, 35, 4,
|
15251
|
+
21, 26, 27, 28
|
15154
15252
|
};
|
15155
15253
|
|
15156
15254
|
static const short _json_key_offsets[] = {
|
@@ -15334,30 +15432,30 @@ static const char _json_trans_targs[] = {
|
|
15334
15432
|
106
|
15335
15433
|
};
|
15336
15434
|
|
15337
|
-
static const char _json_trans_actions[] = {
|
15338
|
-
0, 0,
|
15339
|
-
|
15435
|
+
static const unsigned char _json_trans_actions[] = {
|
15436
|
+
0, 0, 113, 107, 53, 0, 0, 0,
|
15437
|
+
125, 59, 45, 0, 55, 0, 0, 0,
|
15340
15438
|
0, 0, 0, 0, 0, 0, 0, 0,
|
15341
|
-
0, 0,
|
15342
|
-
|
15439
|
+
0, 0, 101, 51, 47, 0, 0, 45,
|
15440
|
+
49, 49, 104, 0, 0, 0, 0, 0,
|
15343
15441
|
3, 0, 0, 0, 0, 0, 5, 15,
|
15344
|
-
0, 0,
|
15345
|
-
9, 9,
|
15346
|
-
0, 0, 0,
|
15347
|
-
0, 0,
|
15348
|
-
|
15349
|
-
0,
|
15350
|
-
0,
|
15351
|
-
|
15352
|
-
|
15353
|
-
0, 0, 0, 0, 0,
|
15354
|
-
0,
|
15355
|
-
|
15356
|
-
0, 0,
|
15357
|
-
|
15442
|
+
0, 0, 71, 7, 13, 0, 74, 9,
|
15443
|
+
9, 9, 77, 80, 11, 37, 37, 37,
|
15444
|
+
0, 0, 0, 39, 0, 41, 86, 0,
|
15445
|
+
0, 0, 17, 19, 0, 21, 23, 0,
|
15446
|
+
25, 27, 0, 29, 31, 0, 33, 35,
|
15447
|
+
0, 135, 83, 135, 0, 0, 0, 0,
|
15448
|
+
0, 92, 0, 89, 89, 98, 43, 0,
|
15449
|
+
131, 95, 113, 107, 53, 0, 0, 0,
|
15450
|
+
125, 59, 69, 110, 45, 0, 55, 0,
|
15451
|
+
0, 0, 0, 0, 0, 119, 0, 0,
|
15452
|
+
0, 122, 0, 0, 0, 116, 0, 101,
|
15453
|
+
51, 47, 0, 0, 45, 49, 49, 104,
|
15454
|
+
0, 0, 128, 0, 57, 63, 65, 61,
|
15455
|
+
67
|
15358
15456
|
};
|
15359
15457
|
|
15360
|
-
static const char _json_eof_actions[] = {
|
15458
|
+
static const unsigned char _json_eof_actions[] = {
|
15361
15459
|
0, 0, 0, 0, 0, 0, 0, 0,
|
15362
15460
|
0, 0, 0, 0, 0, 0, 0, 0,
|
15363
15461
|
0, 0, 0, 0, 0, 0, 0, 0,
|
@@ -15371,7 +15469,7 @@ static const char _json_eof_actions[] = {
|
|
15371
15469
|
0, 0, 0, 0, 0, 0, 0, 0,
|
15372
15470
|
0, 0, 0, 0, 0, 0, 0, 0,
|
15373
15471
|
0, 0, 0, 0, 0, 0, 0, 0,
|
15374
|
-
0, 0, 0,
|
15472
|
+
0, 0, 0, 57, 63, 65, 61, 67,
|
15375
15473
|
0, 0, 0, 0, 0, 0
|
15376
15474
|
};
|
15377
15475
|
|
@@ -15386,7 +15484,7 @@ static const int json_en_value_machine = 78;
|
|
15386
15484
|
static const int json_en_main = 1;
|
15387
15485
|
|
15388
15486
|
|
15389
|
-
#line
|
15487
|
+
#line 2792 "upb/json/parser.rl"
|
15390
15488
|
|
15391
15489
|
size_t parse(void *closure, const void *hd, const char *buf, size_t size,
|
15392
15490
|
const upb_bufhandle *handle) {
|
@@ -15409,7 +15507,7 @@ size_t parse(void *closure, const void *hd, const char *buf, size_t size,
|
|
15409
15507
|
capture_resume(parser, buf);
|
15410
15508
|
|
15411
15509
|
|
15412
|
-
#line
|
15510
|
+
#line 2870 "upb/json/parser.c"
|
15413
15511
|
{
|
15414
15512
|
int _klen;
|
15415
15513
|
unsigned int _trans;
|
@@ -15484,103 +15582,147 @@ _match:
|
|
15484
15582
|
switch ( *_acts++ )
|
15485
15583
|
{
|
15486
15584
|
case 1:
|
15487
|
-
#line
|
15585
|
+
#line 2597 "upb/json/parser.rl"
|
15488
15586
|
{ p--; {cs = stack[--top]; goto _again;} }
|
15489
15587
|
break;
|
15490
15588
|
case 2:
|
15491
|
-
#line
|
15589
|
+
#line 2599 "upb/json/parser.rl"
|
15492
15590
|
{ p--; {stack[top++] = cs; cs = 23;goto _again;} }
|
15493
15591
|
break;
|
15494
15592
|
case 3:
|
15495
|
-
#line
|
15593
|
+
#line 2603 "upb/json/parser.rl"
|
15496
15594
|
{ start_text(parser, p); }
|
15497
15595
|
break;
|
15498
15596
|
case 4:
|
15499
|
-
#line
|
15597
|
+
#line 2604 "upb/json/parser.rl"
|
15500
15598
|
{ CHECK_RETURN_TOP(end_text(parser, p)); }
|
15501
15599
|
break;
|
15502
15600
|
case 5:
|
15503
|
-
#line
|
15601
|
+
#line 2610 "upb/json/parser.rl"
|
15504
15602
|
{ start_hex(parser); }
|
15505
15603
|
break;
|
15506
15604
|
case 6:
|
15507
|
-
#line
|
15605
|
+
#line 2611 "upb/json/parser.rl"
|
15508
15606
|
{ hexdigit(parser, p); }
|
15509
15607
|
break;
|
15510
15608
|
case 7:
|
15511
|
-
#line
|
15609
|
+
#line 2612 "upb/json/parser.rl"
|
15512
15610
|
{ CHECK_RETURN_TOP(end_hex(parser)); }
|
15513
15611
|
break;
|
15514
15612
|
case 8:
|
15515
|
-
#line
|
15613
|
+
#line 2618 "upb/json/parser.rl"
|
15516
15614
|
{ CHECK_RETURN_TOP(escape(parser, p)); }
|
15517
15615
|
break;
|
15518
15616
|
case 9:
|
15519
|
-
#line
|
15617
|
+
#line 2624 "upb/json/parser.rl"
|
15520
15618
|
{ p--; {cs = stack[--top]; goto _again;} }
|
15521
15619
|
break;
|
15522
15620
|
case 10:
|
15523
|
-
#line
|
15524
|
-
{
|
15621
|
+
#line 2629 "upb/json/parser.rl"
|
15622
|
+
{ start_year(parser, p); }
|
15525
15623
|
break;
|
15526
15624
|
case 11:
|
15527
|
-
#line
|
15528
|
-
{ CHECK_RETURN_TOP(
|
15625
|
+
#line 2630 "upb/json/parser.rl"
|
15626
|
+
{ CHECK_RETURN_TOP(end_year(parser, p)); }
|
15529
15627
|
break;
|
15530
15628
|
case 12:
|
15531
|
-
#line
|
15532
|
-
{ p
|
15629
|
+
#line 2634 "upb/json/parser.rl"
|
15630
|
+
{ start_month(parser, p); }
|
15533
15631
|
break;
|
15534
15632
|
case 13:
|
15535
|
-
#line
|
15536
|
-
{
|
15633
|
+
#line 2635 "upb/json/parser.rl"
|
15634
|
+
{ CHECK_RETURN_TOP(end_month(parser, p)); }
|
15537
15635
|
break;
|
15538
15636
|
case 14:
|
15539
|
-
#line
|
15540
|
-
{
|
15637
|
+
#line 2639 "upb/json/parser.rl"
|
15638
|
+
{ start_day(parser, p); }
|
15541
15639
|
break;
|
15542
15640
|
case 15:
|
15543
|
-
#line
|
15544
|
-
{
|
15641
|
+
#line 2640 "upb/json/parser.rl"
|
15642
|
+
{ CHECK_RETURN_TOP(end_day(parser, p)); }
|
15545
15643
|
break;
|
15546
15644
|
case 16:
|
15547
|
-
#line
|
15548
|
-
{
|
15645
|
+
#line 2644 "upb/json/parser.rl"
|
15646
|
+
{ start_hour(parser, p); }
|
15549
15647
|
break;
|
15550
15648
|
case 17:
|
15551
|
-
#line
|
15552
|
-
{
|
15649
|
+
#line 2645 "upb/json/parser.rl"
|
15650
|
+
{ CHECK_RETURN_TOP(end_hour(parser, p)); }
|
15553
15651
|
break;
|
15554
15652
|
case 18:
|
15555
|
-
#line
|
15556
|
-
{
|
15653
|
+
#line 2649 "upb/json/parser.rl"
|
15654
|
+
{ start_minute(parser, p); }
|
15557
15655
|
break;
|
15558
15656
|
case 19:
|
15559
|
-
#line
|
15560
|
-
{ p
|
15657
|
+
#line 2650 "upb/json/parser.rl"
|
15658
|
+
{ CHECK_RETURN_TOP(end_minute(parser, p)); }
|
15561
15659
|
break;
|
15562
15660
|
case 20:
|
15563
|
-
#line
|
15564
|
-
{
|
15661
|
+
#line 2654 "upb/json/parser.rl"
|
15662
|
+
{ start_second(parser, p); }
|
15565
15663
|
break;
|
15566
15664
|
case 21:
|
15567
|
-
#line
|
15568
|
-
{
|
15665
|
+
#line 2655 "upb/json/parser.rl"
|
15666
|
+
{ CHECK_RETURN_TOP(end_second(parser, p)); }
|
15569
15667
|
break;
|
15570
15668
|
case 22:
|
15571
|
-
#line
|
15572
|
-
{
|
15669
|
+
#line 2660 "upb/json/parser.rl"
|
15670
|
+
{ start_duration_base(parser, p); }
|
15573
15671
|
break;
|
15574
15672
|
case 23:
|
15575
|
-
#line
|
15576
|
-
{
|
15673
|
+
#line 2661 "upb/json/parser.rl"
|
15674
|
+
{ CHECK_RETURN_TOP(end_duration_base(parser, p)); }
|
15577
15675
|
break;
|
15578
15676
|
case 24:
|
15579
|
-
#line
|
15677
|
+
#line 2663 "upb/json/parser.rl"
|
15580
15678
|
{ p--; {cs = stack[--top]; goto _again;} }
|
15581
15679
|
break;
|
15582
15680
|
case 25:
|
15583
|
-
#line
|
15681
|
+
#line 2668 "upb/json/parser.rl"
|
15682
|
+
{ start_timestamp_base(parser); }
|
15683
|
+
break;
|
15684
|
+
case 26:
|
15685
|
+
#line 2670 "upb/json/parser.rl"
|
15686
|
+
{ start_timestamp_fraction(parser, p); }
|
15687
|
+
break;
|
15688
|
+
case 27:
|
15689
|
+
#line 2671 "upb/json/parser.rl"
|
15690
|
+
{ CHECK_RETURN_TOP(end_timestamp_fraction(parser, p)); }
|
15691
|
+
break;
|
15692
|
+
case 28:
|
15693
|
+
#line 2673 "upb/json/parser.rl"
|
15694
|
+
{ start_timestamp_zone(parser, p); }
|
15695
|
+
break;
|
15696
|
+
case 29:
|
15697
|
+
#line 2674 "upb/json/parser.rl"
|
15698
|
+
{ CHECK_RETURN_TOP(end_timestamp_zone(parser, p)); }
|
15699
|
+
break;
|
15700
|
+
case 30:
|
15701
|
+
#line 2676 "upb/json/parser.rl"
|
15702
|
+
{ p--; {cs = stack[--top]; goto _again;} }
|
15703
|
+
break;
|
15704
|
+
case 31:
|
15705
|
+
#line 2681 "upb/json/parser.rl"
|
15706
|
+
{ start_fieldmask_path_text(parser, p); }
|
15707
|
+
break;
|
15708
|
+
case 32:
|
15709
|
+
#line 2682 "upb/json/parser.rl"
|
15710
|
+
{ end_fieldmask_path_text(parser, p); }
|
15711
|
+
break;
|
15712
|
+
case 33:
|
15713
|
+
#line 2687 "upb/json/parser.rl"
|
15714
|
+
{ start_fieldmask_path(parser); }
|
15715
|
+
break;
|
15716
|
+
case 34:
|
15717
|
+
#line 2688 "upb/json/parser.rl"
|
15718
|
+
{ end_fieldmask_path(parser); }
|
15719
|
+
break;
|
15720
|
+
case 35:
|
15721
|
+
#line 2694 "upb/json/parser.rl"
|
15722
|
+
{ p--; {cs = stack[--top]; goto _again;} }
|
15723
|
+
break;
|
15724
|
+
case 36:
|
15725
|
+
#line 2699 "upb/json/parser.rl"
|
15584
15726
|
{
|
15585
15727
|
if (is_wellknown_msg(parser, UPB_WELLKNOWN_TIMESTAMP)) {
|
15586
15728
|
{stack[top++] = cs; cs = 47;goto _again;}
|
@@ -15593,12 +15735,12 @@ _match:
|
|
15593
15735
|
}
|
15594
15736
|
}
|
15595
15737
|
break;
|
15596
|
-
case
|
15597
|
-
#line
|
15738
|
+
case 37:
|
15739
|
+
#line 2712 "upb/json/parser.rl"
|
15598
15740
|
{ p--; {stack[top++] = cs; cs = 78;goto _again;} }
|
15599
15741
|
break;
|
15600
|
-
case
|
15601
|
-
#line
|
15742
|
+
case 38:
|
15743
|
+
#line 2717 "upb/json/parser.rl"
|
15602
15744
|
{
|
15603
15745
|
if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
|
15604
15746
|
start_any_member(parser, p);
|
@@ -15607,12 +15749,12 @@ _match:
|
|
15607
15749
|
}
|
15608
15750
|
}
|
15609
15751
|
break;
|
15610
|
-
case
|
15611
|
-
#line
|
15752
|
+
case 39:
|
15753
|
+
#line 2724 "upb/json/parser.rl"
|
15612
15754
|
{ CHECK_RETURN_TOP(end_membername(parser)); }
|
15613
15755
|
break;
|
15614
|
-
case
|
15615
|
-
#line
|
15756
|
+
case 40:
|
15757
|
+
#line 2727 "upb/json/parser.rl"
|
15616
15758
|
{
|
15617
15759
|
if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
|
15618
15760
|
end_any_member(parser, p);
|
@@ -15621,8 +15763,8 @@ _match:
|
|
15621
15763
|
}
|
15622
15764
|
}
|
15623
15765
|
break;
|
15624
|
-
case
|
15625
|
-
#line
|
15766
|
+
case 41:
|
15767
|
+
#line 2738 "upb/json/parser.rl"
|
15626
15768
|
{
|
15627
15769
|
if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
|
15628
15770
|
start_any_object(parser, p);
|
@@ -15631,8 +15773,8 @@ _match:
|
|
15631
15773
|
}
|
15632
15774
|
}
|
15633
15775
|
break;
|
15634
|
-
case
|
15635
|
-
#line
|
15776
|
+
case 42:
|
15777
|
+
#line 2747 "upb/json/parser.rl"
|
15636
15778
|
{
|
15637
15779
|
if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
|
15638
15780
|
CHECK_RETURN_TOP(end_any_object(parser, p));
|
@@ -15641,55 +15783,55 @@ _match:
|
|
15641
15783
|
}
|
15642
15784
|
}
|
15643
15785
|
break;
|
15644
|
-
case
|
15645
|
-
#line
|
15786
|
+
case 43:
|
15787
|
+
#line 2759 "upb/json/parser.rl"
|
15646
15788
|
{ CHECK_RETURN_TOP(start_array(parser)); }
|
15647
15789
|
break;
|
15648
|
-
case
|
15649
|
-
#line
|
15790
|
+
case 44:
|
15791
|
+
#line 2763 "upb/json/parser.rl"
|
15650
15792
|
{ end_array(parser); }
|
15651
15793
|
break;
|
15652
|
-
case
|
15653
|
-
#line
|
15794
|
+
case 45:
|
15795
|
+
#line 2768 "upb/json/parser.rl"
|
15654
15796
|
{ CHECK_RETURN_TOP(start_number(parser, p)); }
|
15655
15797
|
break;
|
15656
|
-
case
|
15657
|
-
#line
|
15798
|
+
case 46:
|
15799
|
+
#line 2769 "upb/json/parser.rl"
|
15658
15800
|
{ CHECK_RETURN_TOP(end_number(parser, p)); }
|
15659
15801
|
break;
|
15660
|
-
case
|
15661
|
-
#line
|
15802
|
+
case 47:
|
15803
|
+
#line 2771 "upb/json/parser.rl"
|
15662
15804
|
{ CHECK_RETURN_TOP(start_stringval(parser)); }
|
15663
15805
|
break;
|
15664
|
-
case
|
15665
|
-
#line
|
15806
|
+
case 48:
|
15807
|
+
#line 2772 "upb/json/parser.rl"
|
15666
15808
|
{ CHECK_RETURN_TOP(end_stringval(parser)); }
|
15667
15809
|
break;
|
15668
|
-
case
|
15669
|
-
#line
|
15810
|
+
case 49:
|
15811
|
+
#line 2774 "upb/json/parser.rl"
|
15670
15812
|
{ CHECK_RETURN_TOP(end_bool(parser, true)); }
|
15671
15813
|
break;
|
15672
|
-
case
|
15673
|
-
#line
|
15814
|
+
case 50:
|
15815
|
+
#line 2776 "upb/json/parser.rl"
|
15674
15816
|
{ CHECK_RETURN_TOP(end_bool(parser, false)); }
|
15675
15817
|
break;
|
15676
|
-
case
|
15677
|
-
#line
|
15818
|
+
case 51:
|
15819
|
+
#line 2778 "upb/json/parser.rl"
|
15678
15820
|
{ CHECK_RETURN_TOP(end_null(parser)); }
|
15679
15821
|
break;
|
15680
|
-
case
|
15681
|
-
#line
|
15822
|
+
case 52:
|
15823
|
+
#line 2780 "upb/json/parser.rl"
|
15682
15824
|
{ CHECK_RETURN_TOP(start_subobject_full(parser)); }
|
15683
15825
|
break;
|
15684
|
-
case
|
15685
|
-
#line
|
15826
|
+
case 53:
|
15827
|
+
#line 2781 "upb/json/parser.rl"
|
15686
15828
|
{ end_subobject_full(parser); }
|
15687
15829
|
break;
|
15688
|
-
case
|
15689
|
-
#line
|
15830
|
+
case 54:
|
15831
|
+
#line 2786 "upb/json/parser.rl"
|
15690
15832
|
{ p--; {cs = stack[--top]; goto _again;} }
|
15691
15833
|
break;
|
15692
|
-
#line
|
15834
|
+
#line 3194 "upb/json/parser.c"
|
15693
15835
|
}
|
15694
15836
|
}
|
15695
15837
|
|
@@ -15706,32 +15848,32 @@ _again:
|
|
15706
15848
|
while ( __nacts-- > 0 ) {
|
15707
15849
|
switch ( *__acts++ ) {
|
15708
15850
|
case 0:
|
15709
|
-
#line
|
15851
|
+
#line 2595 "upb/json/parser.rl"
|
15710
15852
|
{ p--; {cs = stack[--top]; if ( p == pe )
|
15711
15853
|
goto _test_eof;
|
15712
15854
|
goto _again;} }
|
15713
15855
|
break;
|
15714
|
-
case
|
15715
|
-
#line
|
15856
|
+
case 46:
|
15857
|
+
#line 2769 "upb/json/parser.rl"
|
15716
15858
|
{ CHECK_RETURN_TOP(end_number(parser, p)); }
|
15717
15859
|
break;
|
15718
|
-
case
|
15719
|
-
#line
|
15860
|
+
case 49:
|
15861
|
+
#line 2774 "upb/json/parser.rl"
|
15720
15862
|
{ CHECK_RETURN_TOP(end_bool(parser, true)); }
|
15721
15863
|
break;
|
15722
|
-
case
|
15723
|
-
#line
|
15864
|
+
case 50:
|
15865
|
+
#line 2776 "upb/json/parser.rl"
|
15724
15866
|
{ CHECK_RETURN_TOP(end_bool(parser, false)); }
|
15725
15867
|
break;
|
15726
|
-
case
|
15727
|
-
#line
|
15868
|
+
case 51:
|
15869
|
+
#line 2778 "upb/json/parser.rl"
|
15728
15870
|
{ CHECK_RETURN_TOP(end_null(parser)); }
|
15729
15871
|
break;
|
15730
|
-
case
|
15731
|
-
#line
|
15872
|
+
case 53:
|
15873
|
+
#line 2781 "upb/json/parser.rl"
|
15732
15874
|
{ end_subobject_full(parser); }
|
15733
15875
|
break;
|
15734
|
-
#line
|
15876
|
+
#line 3236 "upb/json/parser.c"
|
15735
15877
|
}
|
15736
15878
|
}
|
15737
15879
|
}
|
@@ -15739,7 +15881,7 @@ goto _again;} }
|
|
15739
15881
|
_out: {}
|
15740
15882
|
}
|
15741
15883
|
|
15742
|
-
#line
|
15884
|
+
#line 2814 "upb/json/parser.rl"
|
15743
15885
|
|
15744
15886
|
if (p != pe) {
|
15745
15887
|
upb_status_seterrf(&parser->status, "Parse error at '%.*s'\n", pe - p, p);
|
@@ -15779,22 +15921,17 @@ static void json_parser_reset(upb_json_parser *p) {
|
|
15779
15921
|
int top;
|
15780
15922
|
|
15781
15923
|
p->top = p->stack;
|
15782
|
-
p->top
|
15783
|
-
p->top->is_map = false;
|
15784
|
-
p->top->is_mapentry = false;
|
15785
|
-
p->top->is_any = false;
|
15786
|
-
p->top->any_frame = NULL;
|
15787
|
-
p->top->is_unknown_field = false;
|
15924
|
+
init_frame(p->top);
|
15788
15925
|
|
15789
15926
|
/* Emit Ragel initialization of the parser. */
|
15790
15927
|
|
15791
|
-
#line
|
15928
|
+
#line 3288 "upb/json/parser.c"
|
15792
15929
|
{
|
15793
15930
|
cs = json_start;
|
15794
15931
|
top = 0;
|
15795
15932
|
}
|
15796
15933
|
|
15797
|
-
#line
|
15934
|
+
#line 2857 "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
|
-
|
16401
|
-
|
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,
|
16988
|
-
upb_handlers_setendmsg(h,
|
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);
|