google-protobuf 3.7.1 → 3.8.0.rc.1
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/map.c +6 -0
- data/ext/google/protobuf_c/message.c +120 -6
- data/ext/google/protobuf_c/repeated_field.c +7 -1
- data/ext/google/protobuf_c/storage.c +37 -7
- data/ext/google/protobuf_c/upb.c +99 -140
- data/ext/google/protobuf_c/upb.h +0 -1
- data/tests/basic.rb +20 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2e7a6ca9798b4ad725d81d0935dd61664226d9266763c5aef162ac95945e2df
|
4
|
+
data.tar.gz: 1a6532de1bbea70b0bc6f1642504c78345ec99fe6c6264dbf5cec761de36ddc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fc38a9ac78e8250de92a08d34cbbdf43fec10f7a2f87532d82ce29f9c5714f7c68eb6dda7616e5a56974d10f8bbe758d65ef3404aa3d60511c2d7d155b9672f
|
7
|
+
data.tar.gz: 18cf69356ae93720d97d229e966a8091ef8f8acb719cc0c2f191e265655787f232db817c26bf97e9735aa58d0336cef8b8f0ecd4f5405c2e0b7592b83b977eeb
|
@@ -886,7 +886,7 @@ VALUE FieldDescriptor_default_set(VALUE _self, VALUE default_value) {
|
|
886
886
|
upb_fielddef* mut_def = check_field_notfrozen(self->fielddef);
|
887
887
|
|
888
888
|
switch (upb_fielddef_type(mut_def)) {
|
889
|
-
case UPB_TYPE_FLOAT:
|
889
|
+
case UPB_TYPE_FLOAT:
|
890
890
|
upb_fielddef_setdefaultfloat(mut_def, NUM2DBL(default_value));
|
891
891
|
break;
|
892
892
|
case UPB_TYPE_DOUBLE:
|
@@ -902,16 +902,16 @@ VALUE FieldDescriptor_default_set(VALUE _self, VALUE default_value) {
|
|
902
902
|
upb_fielddef_setdefaultbool(mut_def, RTEST(default_value));
|
903
903
|
break;
|
904
904
|
case UPB_TYPE_ENUM:
|
905
|
-
case UPB_TYPE_INT32:
|
905
|
+
case UPB_TYPE_INT32:
|
906
906
|
upb_fielddef_setdefaultint32(mut_def, NUM2INT(default_value));
|
907
907
|
break;
|
908
|
-
case UPB_TYPE_INT64:
|
908
|
+
case UPB_TYPE_INT64:
|
909
909
|
upb_fielddef_setdefaultint64(mut_def, NUM2INT(default_value));
|
910
910
|
break;
|
911
|
-
case UPB_TYPE_UINT32:
|
911
|
+
case UPB_TYPE_UINT32:
|
912
912
|
upb_fielddef_setdefaultuint32(mut_def, NUM2UINT(default_value));
|
913
913
|
break;
|
914
|
-
case UPB_TYPE_UINT64:
|
914
|
+
case UPB_TYPE_UINT64:
|
915
915
|
upb_fielddef_setdefaultuint64(mut_def, NUM2UINT(default_value));
|
916
916
|
break;
|
917
917
|
case UPB_TYPE_STRING:
|
@@ -2085,7 +2085,7 @@ VALUE Builder_alloc(VALUE klass) {
|
|
2085
2085
|
|
2086
2086
|
void Builder_register(VALUE module) {
|
2087
2087
|
VALUE klass = rb_define_class_under(module, "Builder", rb_cObject);
|
2088
|
-
rb_define_alloc_func(klass, Builder_alloc);
|
2088
|
+
rb_define_alloc_func(klass, Builder_alloc);
|
2089
2089
|
rb_define_method(klass, "initialize", Builder_initialize, 0);
|
2090
2090
|
rb_define_method(klass, "add_file", Builder_add_file, -1);
|
2091
2091
|
rb_define_method(klass, "add_message", Builder_add_message, 1);
|
@@ -2230,7 +2230,7 @@ VALUE Builder_finalize_to_pool(VALUE _self, VALUE pool_rb) {
|
|
2230
2230
|
VALUE def_rb = rb_ary_entry(self->pending_list, i);
|
2231
2231
|
if (CLASS_OF(def_rb) == cDescriptor) {
|
2232
2232
|
self->defs[i] = (upb_def*)ruby_to_Descriptor(def_rb)->msgdef;
|
2233
|
-
|
2233
|
+
|
2234
2234
|
if (upb_filedef_syntax(upb_def_file(self->defs[i])) == UPB_SYNTAX_PROTO3) {
|
2235
2235
|
proto3_validate_msgdef((const upb_msgdef*)self->defs[i]);
|
2236
2236
|
}
|
data/ext/google/protobuf_c/map.c
CHANGED
@@ -386,6 +386,8 @@ VALUE Map_index(VALUE _self, VALUE key) {
|
|
386
386
|
* was just inserted.
|
387
387
|
*/
|
388
388
|
VALUE Map_index_set(VALUE _self, VALUE key, VALUE value) {
|
389
|
+
rb_check_frozen(_self);
|
390
|
+
|
389
391
|
Map* self = ruby_to_Map(_self);
|
390
392
|
|
391
393
|
char keybuf[TABLE_KEY_BUF_LENGTH];
|
@@ -438,6 +440,8 @@ VALUE Map_has_key(VALUE _self, VALUE key) {
|
|
438
440
|
* nil if none was present. Throws an exception if the key is of the wrong type.
|
439
441
|
*/
|
440
442
|
VALUE Map_delete(VALUE _self, VALUE key) {
|
443
|
+
rb_check_frozen(_self);
|
444
|
+
|
441
445
|
Map* self = ruby_to_Map(_self);
|
442
446
|
|
443
447
|
char keybuf[TABLE_KEY_BUF_LENGTH];
|
@@ -461,6 +465,8 @@ VALUE Map_delete(VALUE _self, VALUE key) {
|
|
461
465
|
* Removes all entries from the map.
|
462
466
|
*/
|
463
467
|
VALUE Map_clear(VALUE _self) {
|
468
|
+
rb_check_frozen(_self);
|
469
|
+
|
464
470
|
Map* self = ruby_to_Map(_self);
|
465
471
|
|
466
472
|
// Uninit and reinit the table -- this is faster than iterating and doing a
|
@@ -118,9 +118,38 @@ enum {
|
|
118
118
|
METHOD_GETTER = 1,
|
119
119
|
METHOD_SETTER = 2,
|
120
120
|
METHOD_CLEAR = 3,
|
121
|
-
METHOD_PRESENCE = 4
|
121
|
+
METHOD_PRESENCE = 4,
|
122
|
+
METHOD_ENUM_GETTER = 5,
|
123
|
+
METHOD_WRAPPER_GETTER = 6,
|
124
|
+
METHOD_WRAPPER_SETTER = 7
|
122
125
|
};
|
123
126
|
|
127
|
+
// Check if the field is a well known wrapper type
|
128
|
+
static bool is_wrapper_type_field(const upb_fielddef* field) {
|
129
|
+
char* field_type_name = rb_class2name(field_type_class(field));
|
130
|
+
|
131
|
+
return strcmp(field_type_name, "Google::Protobuf::DoubleValue") == 0 ||
|
132
|
+
strcmp(field_type_name, "Google::Protobuf::FloatValue") == 0 ||
|
133
|
+
strcmp(field_type_name, "Google::Protobuf::Int32Value") == 0 ||
|
134
|
+
strcmp(field_type_name, "Google::Protobuf::Int64Value") == 0 ||
|
135
|
+
strcmp(field_type_name, "Google::Protobuf::UInt32Value") == 0 ||
|
136
|
+
strcmp(field_type_name, "Google::Protobuf::UInt64Value") == 0 ||
|
137
|
+
strcmp(field_type_name, "Google::Protobuf::BoolValue") == 0 ||
|
138
|
+
strcmp(field_type_name, "Google::Protobuf::StringValue") == 0 ||
|
139
|
+
strcmp(field_type_name, "Google::Protobuf::BytesValue") == 0;
|
140
|
+
}
|
141
|
+
|
142
|
+
// Get a new Ruby wrapper type and set the initial value
|
143
|
+
static VALUE ruby_wrapper_type(const upb_fielddef* field, const VALUE* value) {
|
144
|
+
if (is_wrapper_type_field(field) && value != Qnil) {
|
145
|
+
VALUE hash = rb_hash_new();
|
146
|
+
rb_hash_aset(hash, rb_str_new2("value"), value);
|
147
|
+
VALUE args[1] = { hash };
|
148
|
+
return rb_class_new_instance(1, args, field_type_class(field));
|
149
|
+
}
|
150
|
+
return Qnil;
|
151
|
+
}
|
152
|
+
|
124
153
|
static int extract_method_call(VALUE method_name, MessageHeader* self,
|
125
154
|
const upb_fielddef **f, const upb_oneofdef **o) {
|
126
155
|
Check_Type(method_name, T_SYMBOL);
|
@@ -153,9 +182,62 @@ static int extract_method_call(VALUE method_name, MessageHeader* self,
|
|
153
182
|
accessor_type = METHOD_GETTER;
|
154
183
|
}
|
155
184
|
|
185
|
+
bool has_field = upb_msgdef_lookupname(self->descriptor->msgdef, name, name_len,
|
186
|
+
&test_f, &test_o);
|
187
|
+
|
188
|
+
// Look for wrapper type accessor of the form <field_name>_as_value
|
189
|
+
if (!has_field &&
|
190
|
+
(accessor_type == METHOD_GETTER || accessor_type == METHOD_SETTER) &&
|
191
|
+
name_len > 9 && strncmp(name + name_len - 9, "_as_value", 9) == 0) {
|
192
|
+
// Find the field name
|
193
|
+
char wrapper_field_name[name_len - 8];
|
194
|
+
strncpy(wrapper_field_name, name, name_len - 9);
|
195
|
+
wrapper_field_name[name_len - 7] = '\0';
|
196
|
+
|
197
|
+
// Check if field exists and is a wrapper type
|
198
|
+
const upb_oneofdef* test_o_wrapper;
|
199
|
+
const upb_fielddef* test_f_wrapper;
|
200
|
+
if (upb_msgdef_lookupname(self->descriptor->msgdef, wrapper_field_name, name_len - 9,
|
201
|
+
&test_f_wrapper, &test_o_wrapper) &&
|
202
|
+
upb_fielddef_type(test_f_wrapper) == UPB_TYPE_MESSAGE &&
|
203
|
+
is_wrapper_type_field(test_f_wrapper)) {
|
204
|
+
// It does exist!
|
205
|
+
has_field = true;
|
206
|
+
if (accessor_type == METHOD_SETTER) {
|
207
|
+
accessor_type = METHOD_WRAPPER_SETTER;
|
208
|
+
} else {
|
209
|
+
accessor_type = METHOD_WRAPPER_GETTER;
|
210
|
+
}
|
211
|
+
test_o = test_o_wrapper;
|
212
|
+
test_f = test_f_wrapper;
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
// Look for enum accessor of the form <enum_name>_const
|
217
|
+
if (!has_field && accessor_type == METHOD_GETTER &&
|
218
|
+
name_len > 6 && strncmp(name + name_len - 6, "_const", 6) == 0) {
|
219
|
+
|
220
|
+
// Find enum field name
|
221
|
+
char enum_name[name_len - 5];
|
222
|
+
strncpy(enum_name, name, name_len - 6);
|
223
|
+
enum_name[name_len - 4] = '\0';
|
224
|
+
|
225
|
+
// Check if enum field exists
|
226
|
+
const upb_oneofdef* test_o_enum;
|
227
|
+
const upb_fielddef* test_f_enum;
|
228
|
+
if (upb_msgdef_lookupname(self->descriptor->msgdef, enum_name, name_len - 6,
|
229
|
+
&test_f_enum, &test_o_enum) &&
|
230
|
+
upb_fielddef_type(test_f_enum) == UPB_TYPE_ENUM) {
|
231
|
+
// It does exist!
|
232
|
+
has_field = true;
|
233
|
+
accessor_type = METHOD_ENUM_GETTER;
|
234
|
+
test_o = test_o_enum;
|
235
|
+
test_f = test_f_enum;
|
236
|
+
}
|
237
|
+
}
|
238
|
+
|
156
239
|
// Verify the name corresponds to a oneof or field in this message.
|
157
|
-
if (!
|
158
|
-
&test_f, &test_o)) {
|
240
|
+
if (!has_field) {
|
159
241
|
return METHOD_UNKNOWN;
|
160
242
|
}
|
161
243
|
|
@@ -212,10 +294,11 @@ VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) {
|
|
212
294
|
int accessor_type = extract_method_call(argv[0], self, &f, &o);
|
213
295
|
if (accessor_type == METHOD_UNKNOWN || (o == NULL && f == NULL) ) {
|
214
296
|
return rb_call_super(argc, argv);
|
215
|
-
} else if (accessor_type == METHOD_SETTER) {
|
297
|
+
} else if (accessor_type == METHOD_SETTER || accessor_type == METHOD_WRAPPER_SETTER) {
|
216
298
|
if (argc != 2) {
|
217
299
|
rb_raise(rb_eArgError, "Expected 2 arguments, received %d", argc);
|
218
300
|
}
|
301
|
+
rb_check_frozen(_self);
|
219
302
|
} else if (argc != 1) {
|
220
303
|
rb_raise(rb_eArgError, "Expected 1 argument, received %d", argc);
|
221
304
|
}
|
@@ -231,13 +314,13 @@ VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) {
|
|
231
314
|
return oneof_field == NULL ? Qfalse : Qtrue;
|
232
315
|
} else if (accessor_type == METHOD_CLEAR) {
|
233
316
|
if (oneof_field != NULL) {
|
234
|
-
|
317
|
+
layout_clear(self->descriptor->layout, Message_data(self), oneof_field);
|
235
318
|
}
|
236
319
|
return Qnil;
|
237
320
|
} else {
|
238
321
|
// METHOD_ACCESSOR
|
239
322
|
return oneof_field == NULL ? Qnil :
|
240
|
-
|
323
|
+
ID2SYM(rb_intern(upb_fielddef_name(oneof_field)));
|
241
324
|
}
|
242
325
|
// Otherwise we're operating on a single proto field
|
243
326
|
} else if (accessor_type == METHOD_SETTER) {
|
@@ -248,6 +331,35 @@ VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) {
|
|
248
331
|
return Qnil;
|
249
332
|
} else if (accessor_type == METHOD_PRESENCE) {
|
250
333
|
return layout_has(self->descriptor->layout, Message_data(self), f);
|
334
|
+
} else if (accessor_type == METHOD_WRAPPER_GETTER) {
|
335
|
+
VALUE value = layout_get(self->descriptor->layout, Message_data(self), f);
|
336
|
+
if (value != Qnil) {
|
337
|
+
value = rb_funcall(value, rb_intern("value"), 0);
|
338
|
+
}
|
339
|
+
return value;
|
340
|
+
} else if (accessor_type == METHOD_WRAPPER_SETTER) {
|
341
|
+
VALUE wrapper = ruby_wrapper_type(f, argv[1]);
|
342
|
+
layout_set(self->descriptor->layout, Message_data(self), f, wrapper);
|
343
|
+
return Qnil;
|
344
|
+
} else if (accessor_type == METHOD_ENUM_GETTER) {
|
345
|
+
VALUE enum_type = field_type_class(f);
|
346
|
+
VALUE method = rb_intern("const_get");
|
347
|
+
VALUE raw_value = layout_get(self->descriptor->layout, Message_data(self), f);
|
348
|
+
|
349
|
+
// Map repeated fields to a new type with ints
|
350
|
+
if (upb_fielddef_label(f) == UPB_LABEL_REPEATED) {
|
351
|
+
int array_size = FIX2INT(rb_funcall(raw_value, rb_intern("length"), 0));
|
352
|
+
VALUE array_args[1] = { ID2SYM(rb_intern("int64")) };
|
353
|
+
VALUE array = rb_class_new_instance(1, array_args, CLASS_OF(raw_value));
|
354
|
+
for (int i = 0; i < array_size; i++) {
|
355
|
+
VALUE entry = rb_funcall(enum_type, method, 1, rb_funcall(raw_value,
|
356
|
+
rb_intern("at"), 1, INT2NUM(i)));
|
357
|
+
rb_funcall(array, rb_intern("push"), 1, entry);
|
358
|
+
}
|
359
|
+
return array;
|
360
|
+
}
|
361
|
+
// Convert the value for singular fields
|
362
|
+
return rb_funcall(enum_type, method, 1, raw_value);
|
251
363
|
} else {
|
252
364
|
return layout_get(self->descriptor->layout, Message_data(self), f);
|
253
365
|
}
|
@@ -622,10 +734,12 @@ VALUE build_class_from_descriptor(Descriptor* desc) {
|
|
622
734
|
// Also define #clone so that we don't inherit Object#clone.
|
623
735
|
rb_define_method(klass, "clone", Message_dup, 0);
|
624
736
|
rb_define_method(klass, "==", Message_eq, 1);
|
737
|
+
rb_define_method(klass, "eql?", Message_eq, 1);
|
625
738
|
rb_define_method(klass, "hash", Message_hash, 0);
|
626
739
|
rb_define_method(klass, "to_h", Message_to_h, 0);
|
627
740
|
rb_define_method(klass, "to_hash", Message_to_h, 0);
|
628
741
|
rb_define_method(klass, "inspect", Message_inspect, 0);
|
742
|
+
rb_define_method(klass, "to_s", Message_inspect, 0);
|
629
743
|
rb_define_method(klass, "[]", Message_index, 1);
|
630
744
|
rb_define_method(klass, "[]=", Message_index_set, 2);
|
631
745
|
rb_define_singleton_method(klass, "decode", Message_decode, 1);
|
@@ -223,6 +223,12 @@ VALUE RepeatedField_push(VALUE _self, VALUE val) {
|
|
223
223
|
return _self;
|
224
224
|
}
|
225
225
|
|
226
|
+
VALUE RepeatedField_push_vararg(VALUE _self, VALUE args) {
|
227
|
+
for (int i = 0; i < RARRAY_LEN(args); i++) {
|
228
|
+
RepeatedField_push(_self, rb_ary_entry(args, i));
|
229
|
+
}
|
230
|
+
return _self;
|
231
|
+
}
|
226
232
|
|
227
233
|
// Used by parsing handlers.
|
228
234
|
void RepeatedField_push_native(VALUE _self, void* data) {
|
@@ -635,7 +641,7 @@ void RepeatedField_register(VALUE module) {
|
|
635
641
|
rb_define_method(klass, "[]", RepeatedField_index, -1);
|
636
642
|
rb_define_method(klass, "at", RepeatedField_index, -1);
|
637
643
|
rb_define_method(klass, "[]=", RepeatedField_index_set, 2);
|
638
|
-
rb_define_method(klass, "push",
|
644
|
+
rb_define_method(klass, "push", RepeatedField_push_vararg, -2);
|
639
645
|
rb_define_method(klass, "<<", RepeatedField_push, 1);
|
640
646
|
rb_define_private_method(klass, "pop_one", RepeatedField_pop_one, 0);
|
641
647
|
rb_define_method(klass, "replace", RepeatedField_replace, 1);
|
@@ -111,13 +111,13 @@ VALUE native_slot_encode_and_freeze_string(upb_fieldtype_t type, VALUE value) {
|
|
111
111
|
return value;
|
112
112
|
}
|
113
113
|
|
114
|
-
void native_slot_set(const char* name,
|
114
|
+
void native_slot_set(const char* name,
|
115
115
|
upb_fieldtype_t type, VALUE type_class,
|
116
116
|
void* memory, VALUE value) {
|
117
117
|
native_slot_set_value_and_case(name, type, type_class, memory, value, NULL, 0);
|
118
118
|
}
|
119
119
|
|
120
|
-
void native_slot_set_value_and_case(const char* name,
|
120
|
+
void native_slot_set_value_and_case(const char* name,
|
121
121
|
upb_fieldtype_t type, VALUE type_class,
|
122
122
|
void* memory, VALUE value,
|
123
123
|
uint32_t* case_memory,
|
@@ -178,9 +178,39 @@ void native_slot_set_value_and_case(const char* name,
|
|
178
178
|
if (CLASS_OF(value) == CLASS_OF(Qnil)) {
|
179
179
|
value = Qnil;
|
180
180
|
} else if (CLASS_OF(value) != type_class) {
|
181
|
-
|
182
|
-
|
183
|
-
|
181
|
+
// check for possible implicit conversions
|
182
|
+
VALUE converted_value = NULL;
|
183
|
+
char* field_type_name = rb_class2name(type_class);
|
184
|
+
|
185
|
+
if (strcmp(field_type_name, "Google::Protobuf::Timestamp") == 0 &&
|
186
|
+
rb_obj_is_kind_of(value, rb_cTime)) {
|
187
|
+
// Time -> Google::Protobuf::Timestamp
|
188
|
+
VALUE hash = rb_hash_new();
|
189
|
+
rb_hash_aset(hash, rb_str_new2("seconds"), rb_funcall(value, rb_intern("to_i"), 0));
|
190
|
+
rb_hash_aset(hash, rb_str_new2("nanos"), rb_funcall(value, rb_intern("nsec"), 0));
|
191
|
+
VALUE args[1] = { hash };
|
192
|
+
converted_value = rb_class_new_instance(1, args, type_class);
|
193
|
+
} else if (strcmp(field_type_name, "Google::Protobuf::Duration") == 0 &&
|
194
|
+
rb_obj_is_kind_of(value, rb_cNumeric)) {
|
195
|
+
// Numeric -> Google::Protobuf::Duration
|
196
|
+
VALUE hash = rb_hash_new();
|
197
|
+
rb_hash_aset(hash, rb_str_new2("seconds"), rb_funcall(value, rb_intern("to_i"), 0));
|
198
|
+
VALUE n_value = rb_funcall(value, rb_intern("remainder"), 1, INT2NUM(1));
|
199
|
+
n_value = rb_funcall(n_value, rb_intern("*"), 1, INT2NUM(1000000000));
|
200
|
+
n_value = rb_funcall(n_value, rb_intern("round"), 0);
|
201
|
+
rb_hash_aset(hash, rb_str_new2("nanos"), n_value);
|
202
|
+
VALUE args[1] = { hash };
|
203
|
+
converted_value = rb_class_new_instance(1, args, type_class);
|
204
|
+
}
|
205
|
+
|
206
|
+
// raise if no suitable conversaion could be found
|
207
|
+
if (converted_value == NULL) {
|
208
|
+
rb_raise(cTypeError,
|
209
|
+
"Invalid type %s to assign to submessage field '%s'.",
|
210
|
+
rb_class2name(CLASS_OF(value)), name);
|
211
|
+
} else {
|
212
|
+
value = converted_value;
|
213
|
+
}
|
184
214
|
}
|
185
215
|
DEREF(memory, VALUE) = value;
|
186
216
|
break;
|
@@ -668,7 +698,7 @@ void layout_clear(MessageLayout* layout,
|
|
668
698
|
|
669
699
|
DEREF(memory, VALUE) = ary;
|
670
700
|
} else {
|
671
|
-
native_slot_set(upb_fielddef_name(field),
|
701
|
+
native_slot_set(upb_fielddef_name(field),
|
672
702
|
upb_fielddef_type(field), field_type_class(field),
|
673
703
|
memory, layout_get_default(field));
|
674
704
|
}
|
@@ -839,7 +869,7 @@ void layout_set(MessageLayout* layout,
|
|
839
869
|
check_repeated_field_type(val, field);
|
840
870
|
DEREF(memory, VALUE) = val;
|
841
871
|
} else {
|
842
|
-
native_slot_set(upb_fielddef_name(field),
|
872
|
+
native_slot_set(upb_fielddef_name(field),
|
843
873
|
upb_fielddef_type(field), field_type_class(field),
|
844
874
|
memory, val);
|
845
875
|
}
|
data/ext/google/protobuf_c/upb.c
CHANGED
@@ -12624,6 +12624,7 @@ done:
|
|
12624
12624
|
** - handling of keys/escape-sequences/etc that span input buffers.
|
12625
12625
|
*/
|
12626
12626
|
|
12627
|
+
#include <ctype.h>
|
12627
12628
|
#include <errno.h>
|
12628
12629
|
#include <float.h>
|
12629
12630
|
#include <math.h>
|
@@ -12820,6 +12821,19 @@ typedef struct {
|
|
12820
12821
|
bool is_unknown_field;
|
12821
12822
|
} upb_jsonparser_frame;
|
12822
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
|
+
|
12823
12837
|
struct upb_json_parser {
|
12824
12838
|
upb_env *env;
|
12825
12839
|
const upb_json_parsermethod *method;
|
@@ -12867,6 +12881,13 @@ struct upb_json_parser {
|
|
12867
12881
|
struct tm tm;
|
12868
12882
|
};
|
12869
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
|
+
|
12870
12891
|
struct upb_json_parsermethod {
|
12871
12892
|
upb_refcounted base;
|
12872
12893
|
|
@@ -13824,18 +13845,11 @@ static bool start_stringval(upb_json_parser *p) {
|
|
13824
13845
|
|
13825
13846
|
/* Start a new parser frame: parser frames correspond one-to-one with
|
13826
13847
|
* handler frames, and string events occur in a sub-frame. */
|
13827
|
-
inner = p
|
13848
|
+
inner = start_jsonparser_frame(p);
|
13828
13849
|
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR);
|
13829
13850
|
upb_sink_startstr(&p->top->sink, sel, 0, &inner->sink);
|
13830
13851
|
inner->m = p->top->m;
|
13831
13852
|
inner->f = p->top->f;
|
13832
|
-
inner->name_table = NULL;
|
13833
|
-
inner->is_repeated = false;
|
13834
|
-
inner->is_map = false;
|
13835
|
-
inner->is_mapentry = false;
|
13836
|
-
inner->is_any = false;
|
13837
|
-
inner->any_frame = NULL;
|
13838
|
-
inner->is_unknown_field = false;
|
13839
13853
|
p->top = inner;
|
13840
13854
|
|
13841
13855
|
if (upb_fielddef_type(p->top->f) == UPB_TYPE_STRING) {
|
@@ -14358,18 +14372,11 @@ static bool start_fieldmask_path(upb_json_parser *p) {
|
|
14358
14372
|
|
14359
14373
|
/* Start a new parser frame: parser frames correspond one-to-one with
|
14360
14374
|
* handler frames, and string events occur in a sub-frame. */
|
14361
|
-
inner = p
|
14375
|
+
inner = start_jsonparser_frame(p);
|
14362
14376
|
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSTR);
|
14363
14377
|
upb_sink_startstr(&p->top->sink, sel, 0, &inner->sink);
|
14364
14378
|
inner->m = p->top->m;
|
14365
14379
|
inner->f = p->top->f;
|
14366
|
-
inner->name_table = NULL;
|
14367
|
-
inner->is_repeated = false;
|
14368
|
-
inner->is_map = false;
|
14369
|
-
inner->is_mapentry = false;
|
14370
|
-
inner->is_any = false;
|
14371
|
-
inner->any_frame = NULL;
|
14372
|
-
inner->is_unknown_field = false;
|
14373
14380
|
p->top = inner;
|
14374
14381
|
|
14375
14382
|
multipart_startaccum(p);
|
@@ -14505,18 +14512,12 @@ static bool handle_mapentry(upb_json_parser *p) {
|
|
14505
14512
|
mapfield = p->top->mapfield;
|
14506
14513
|
mapentrymsg = upb_fielddef_msgsubdef(mapfield);
|
14507
14514
|
|
14508
|
-
inner = p
|
14515
|
+
inner = start_jsonparser_frame(p);
|
14509
14516
|
p->top->f = mapfield;
|
14510
14517
|
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG);
|
14511
14518
|
upb_sink_startsubmsg(&p->top->sink, sel, &inner->sink);
|
14512
14519
|
inner->m = mapentrymsg;
|
14513
|
-
inner->name_table = NULL;
|
14514
14520
|
inner->mapfield = mapfield;
|
14515
|
-
inner->is_repeated = false;
|
14516
|
-
inner->is_map = false;
|
14517
|
-
inner->is_any = false;
|
14518
|
-
inner->any_frame = NULL;
|
14519
|
-
inner->is_unknown_field = false;
|
14520
14521
|
|
14521
14522
|
/* Don't set this to true *yet* -- we reuse parsing handlers below to push
|
14522
14523
|
* the key field value to the sink, and these handlers will pop the frame
|
@@ -14634,16 +14635,7 @@ static bool start_subobject(upb_json_parser *p) {
|
|
14634
14635
|
upb_jsonparser_frame *inner;
|
14635
14636
|
if (!check_stack(p)) return false;
|
14636
14637
|
|
14637
|
-
|
14638
|
-
inner->m = NULL;
|
14639
|
-
inner->f = NULL;
|
14640
|
-
inner->is_repeated = false;
|
14641
|
-
inner->is_map = false;
|
14642
|
-
inner->is_mapentry = false;
|
14643
|
-
inner->is_any = false;
|
14644
|
-
inner->any_frame = NULL;
|
14645
|
-
inner->is_unknown_field = false;
|
14646
|
-
p->top = inner;
|
14638
|
+
p->top = start_jsonparser_frame(p);
|
14647
14639
|
return true;
|
14648
14640
|
}
|
14649
14641
|
|
@@ -14655,19 +14647,12 @@ static bool start_subobject(upb_json_parser *p) {
|
|
14655
14647
|
* context. */
|
14656
14648
|
if (!check_stack(p)) return false;
|
14657
14649
|
|
14658
|
-
inner = p
|
14650
|
+
inner = start_jsonparser_frame(p);
|
14659
14651
|
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSEQ);
|
14660
14652
|
upb_sink_startseq(&p->top->sink, sel, &inner->sink);
|
14661
14653
|
inner->m = upb_fielddef_msgsubdef(p->top->f);
|
14662
|
-
inner->name_table = NULL;
|
14663
14654
|
inner->mapfield = p->top->f;
|
14664
|
-
inner->f = NULL;
|
14665
|
-
inner->is_repeated = false;
|
14666
14655
|
inner->is_map = true;
|
14667
|
-
inner->is_mapentry = false;
|
14668
|
-
inner->is_any = false;
|
14669
|
-
inner->any_frame = NULL;
|
14670
|
-
inner->is_unknown_field = false;
|
14671
14656
|
p->top = inner;
|
14672
14657
|
|
14673
14658
|
return true;
|
@@ -14679,17 +14664,11 @@ static bool start_subobject(upb_json_parser *p) {
|
|
14679
14664
|
* context. */
|
14680
14665
|
if (!check_stack(p)) return false;
|
14681
14666
|
|
14682
|
-
inner = p
|
14683
|
-
|
14667
|
+
inner = start_jsonparser_frame(p);
|
14684
14668
|
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG);
|
14685
14669
|
upb_sink_startsubmsg(&p->top->sink, sel, &inner->sink);
|
14686
14670
|
inner->m = upb_fielddef_msgsubdef(p->top->f);
|
14687
14671
|
set_name_table(p, inner);
|
14688
|
-
inner->f = NULL;
|
14689
|
-
inner->is_repeated = false;
|
14690
|
-
inner->is_map = false;
|
14691
|
-
inner->is_mapentry = false;
|
14692
|
-
inner->is_unknown_field = false;
|
14693
14672
|
p->top = inner;
|
14694
14673
|
|
14695
14674
|
if (is_wellknown_msg(p, UPB_WELLKNOWN_ANY)) {
|
@@ -14804,15 +14783,7 @@ static bool start_array(upb_json_parser *p) {
|
|
14804
14783
|
}
|
14805
14784
|
|
14806
14785
|
if (p->top->is_unknown_field) {
|
14807
|
-
inner = p
|
14808
|
-
inner->m = NULL;
|
14809
|
-
inner->name_table = NULL;
|
14810
|
-
inner->f = NULL;
|
14811
|
-
inner->is_repeated = false;
|
14812
|
-
inner->is_map = false;
|
14813
|
-
inner->is_mapentry = false;
|
14814
|
-
inner->is_any = false;
|
14815
|
-
inner->any_frame = NULL;
|
14786
|
+
inner = start_jsonparser_frame(p);
|
14816
14787
|
inner->is_unknown_field = true;
|
14817
14788
|
p->top = inner;
|
14818
14789
|
|
@@ -14829,18 +14800,12 @@ static bool start_array(upb_json_parser *p) {
|
|
14829
14800
|
|
14830
14801
|
if (!check_stack(p)) return false;
|
14831
14802
|
|
14832
|
-
inner = p
|
14803
|
+
inner = start_jsonparser_frame(p);
|
14833
14804
|
sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSEQ);
|
14834
14805
|
upb_sink_startseq(&p->top->sink, sel, &inner->sink);
|
14835
14806
|
inner->m = p->top->m;
|
14836
|
-
inner->name_table = NULL;
|
14837
14807
|
inner->f = p->top->f;
|
14838
14808
|
inner->is_repeated = true;
|
14839
|
-
inner->is_map = false;
|
14840
|
-
inner->is_mapentry = false;
|
14841
|
-
inner->is_any = false;
|
14842
|
-
inner->any_frame = NULL;
|
14843
|
-
inner->is_unknown_field = false;
|
14844
14809
|
p->top = inner;
|
14845
14810
|
|
14846
14811
|
return true;
|
@@ -15219,11 +15184,11 @@ static bool is_fieldmask_object(upb_json_parser *p) {
|
|
15219
15184
|
* final state once, when the closing '"' is seen. */
|
15220
15185
|
|
15221
15186
|
|
15222
|
-
#line
|
15187
|
+
#line 2789 "upb/json/parser.rl"
|
15223
15188
|
|
15224
15189
|
|
15225
15190
|
|
15226
|
-
#line
|
15191
|
+
#line 2592 "upb/json/parser.c"
|
15227
15192
|
static const char _json_actions[] = {
|
15228
15193
|
0, 1, 0, 1, 1, 1, 3, 1,
|
15229
15194
|
4, 1, 6, 1, 7, 1, 8, 1,
|
@@ -15478,7 +15443,7 @@ static const int json_en_value_machine = 78;
|
|
15478
15443
|
static const int json_en_main = 1;
|
15479
15444
|
|
15480
15445
|
|
15481
|
-
#line
|
15446
|
+
#line 2792 "upb/json/parser.rl"
|
15482
15447
|
|
15483
15448
|
size_t parse(void *closure, const void *hd, const char *buf, size_t size,
|
15484
15449
|
const upb_bufhandle *handle) {
|
@@ -15501,7 +15466,7 @@ size_t parse(void *closure, const void *hd, const char *buf, size_t size,
|
|
15501
15466
|
capture_resume(parser, buf);
|
15502
15467
|
|
15503
15468
|
|
15504
|
-
#line
|
15469
|
+
#line 2870 "upb/json/parser.c"
|
15505
15470
|
{
|
15506
15471
|
int _klen;
|
15507
15472
|
unsigned int _trans;
|
@@ -15576,147 +15541,147 @@ _match:
|
|
15576
15541
|
switch ( *_acts++ )
|
15577
15542
|
{
|
15578
15543
|
case 1:
|
15579
|
-
#line
|
15544
|
+
#line 2597 "upb/json/parser.rl"
|
15580
15545
|
{ p--; {cs = stack[--top]; goto _again;} }
|
15581
15546
|
break;
|
15582
15547
|
case 2:
|
15583
|
-
#line
|
15548
|
+
#line 2599 "upb/json/parser.rl"
|
15584
15549
|
{ p--; {stack[top++] = cs; cs = 23;goto _again;} }
|
15585
15550
|
break;
|
15586
15551
|
case 3:
|
15587
|
-
#line
|
15552
|
+
#line 2603 "upb/json/parser.rl"
|
15588
15553
|
{ start_text(parser, p); }
|
15589
15554
|
break;
|
15590
15555
|
case 4:
|
15591
|
-
#line
|
15556
|
+
#line 2604 "upb/json/parser.rl"
|
15592
15557
|
{ CHECK_RETURN_TOP(end_text(parser, p)); }
|
15593
15558
|
break;
|
15594
15559
|
case 5:
|
15595
|
-
#line
|
15560
|
+
#line 2610 "upb/json/parser.rl"
|
15596
15561
|
{ start_hex(parser); }
|
15597
15562
|
break;
|
15598
15563
|
case 6:
|
15599
|
-
#line
|
15564
|
+
#line 2611 "upb/json/parser.rl"
|
15600
15565
|
{ hexdigit(parser, p); }
|
15601
15566
|
break;
|
15602
15567
|
case 7:
|
15603
|
-
#line
|
15568
|
+
#line 2612 "upb/json/parser.rl"
|
15604
15569
|
{ CHECK_RETURN_TOP(end_hex(parser)); }
|
15605
15570
|
break;
|
15606
15571
|
case 8:
|
15607
|
-
#line
|
15572
|
+
#line 2618 "upb/json/parser.rl"
|
15608
15573
|
{ CHECK_RETURN_TOP(escape(parser, p)); }
|
15609
15574
|
break;
|
15610
15575
|
case 9:
|
15611
|
-
#line
|
15576
|
+
#line 2624 "upb/json/parser.rl"
|
15612
15577
|
{ p--; {cs = stack[--top]; goto _again;} }
|
15613
15578
|
break;
|
15614
15579
|
case 10:
|
15615
|
-
#line
|
15580
|
+
#line 2629 "upb/json/parser.rl"
|
15616
15581
|
{ start_year(parser, p); }
|
15617
15582
|
break;
|
15618
15583
|
case 11:
|
15619
|
-
#line
|
15584
|
+
#line 2630 "upb/json/parser.rl"
|
15620
15585
|
{ CHECK_RETURN_TOP(end_year(parser, p)); }
|
15621
15586
|
break;
|
15622
15587
|
case 12:
|
15623
|
-
#line
|
15588
|
+
#line 2634 "upb/json/parser.rl"
|
15624
15589
|
{ start_month(parser, p); }
|
15625
15590
|
break;
|
15626
15591
|
case 13:
|
15627
|
-
#line
|
15592
|
+
#line 2635 "upb/json/parser.rl"
|
15628
15593
|
{ CHECK_RETURN_TOP(end_month(parser, p)); }
|
15629
15594
|
break;
|
15630
15595
|
case 14:
|
15631
|
-
#line
|
15596
|
+
#line 2639 "upb/json/parser.rl"
|
15632
15597
|
{ start_day(parser, p); }
|
15633
15598
|
break;
|
15634
15599
|
case 15:
|
15635
|
-
#line
|
15600
|
+
#line 2640 "upb/json/parser.rl"
|
15636
15601
|
{ CHECK_RETURN_TOP(end_day(parser, p)); }
|
15637
15602
|
break;
|
15638
15603
|
case 16:
|
15639
|
-
#line
|
15604
|
+
#line 2644 "upb/json/parser.rl"
|
15640
15605
|
{ start_hour(parser, p); }
|
15641
15606
|
break;
|
15642
15607
|
case 17:
|
15643
|
-
#line
|
15608
|
+
#line 2645 "upb/json/parser.rl"
|
15644
15609
|
{ CHECK_RETURN_TOP(end_hour(parser, p)); }
|
15645
15610
|
break;
|
15646
15611
|
case 18:
|
15647
|
-
#line
|
15612
|
+
#line 2649 "upb/json/parser.rl"
|
15648
15613
|
{ start_minute(parser, p); }
|
15649
15614
|
break;
|
15650
15615
|
case 19:
|
15651
|
-
#line
|
15616
|
+
#line 2650 "upb/json/parser.rl"
|
15652
15617
|
{ CHECK_RETURN_TOP(end_minute(parser, p)); }
|
15653
15618
|
break;
|
15654
15619
|
case 20:
|
15655
|
-
#line
|
15620
|
+
#line 2654 "upb/json/parser.rl"
|
15656
15621
|
{ start_second(parser, p); }
|
15657
15622
|
break;
|
15658
15623
|
case 21:
|
15659
|
-
#line
|
15624
|
+
#line 2655 "upb/json/parser.rl"
|
15660
15625
|
{ CHECK_RETURN_TOP(end_second(parser, p)); }
|
15661
15626
|
break;
|
15662
15627
|
case 22:
|
15663
|
-
#line
|
15628
|
+
#line 2660 "upb/json/parser.rl"
|
15664
15629
|
{ start_duration_base(parser, p); }
|
15665
15630
|
break;
|
15666
15631
|
case 23:
|
15667
|
-
#line
|
15632
|
+
#line 2661 "upb/json/parser.rl"
|
15668
15633
|
{ CHECK_RETURN_TOP(end_duration_base(parser, p)); }
|
15669
15634
|
break;
|
15670
15635
|
case 24:
|
15671
|
-
#line
|
15636
|
+
#line 2663 "upb/json/parser.rl"
|
15672
15637
|
{ p--; {cs = stack[--top]; goto _again;} }
|
15673
15638
|
break;
|
15674
15639
|
case 25:
|
15675
|
-
#line
|
15640
|
+
#line 2668 "upb/json/parser.rl"
|
15676
15641
|
{ start_timestamp_base(parser); }
|
15677
15642
|
break;
|
15678
15643
|
case 26:
|
15679
|
-
#line
|
15644
|
+
#line 2670 "upb/json/parser.rl"
|
15680
15645
|
{ start_timestamp_fraction(parser, p); }
|
15681
15646
|
break;
|
15682
15647
|
case 27:
|
15683
|
-
#line
|
15648
|
+
#line 2671 "upb/json/parser.rl"
|
15684
15649
|
{ CHECK_RETURN_TOP(end_timestamp_fraction(parser, p)); }
|
15685
15650
|
break;
|
15686
15651
|
case 28:
|
15687
|
-
#line
|
15652
|
+
#line 2673 "upb/json/parser.rl"
|
15688
15653
|
{ start_timestamp_zone(parser, p); }
|
15689
15654
|
break;
|
15690
15655
|
case 29:
|
15691
|
-
#line
|
15656
|
+
#line 2674 "upb/json/parser.rl"
|
15692
15657
|
{ CHECK_RETURN_TOP(end_timestamp_zone(parser, p)); }
|
15693
15658
|
break;
|
15694
15659
|
case 30:
|
15695
|
-
#line
|
15660
|
+
#line 2676 "upb/json/parser.rl"
|
15696
15661
|
{ p--; {cs = stack[--top]; goto _again;} }
|
15697
15662
|
break;
|
15698
15663
|
case 31:
|
15699
|
-
#line
|
15664
|
+
#line 2681 "upb/json/parser.rl"
|
15700
15665
|
{ start_fieldmask_path_text(parser, p); }
|
15701
15666
|
break;
|
15702
15667
|
case 32:
|
15703
|
-
#line
|
15668
|
+
#line 2682 "upb/json/parser.rl"
|
15704
15669
|
{ end_fieldmask_path_text(parser, p); }
|
15705
15670
|
break;
|
15706
15671
|
case 33:
|
15707
|
-
#line
|
15672
|
+
#line 2687 "upb/json/parser.rl"
|
15708
15673
|
{ start_fieldmask_path(parser); }
|
15709
15674
|
break;
|
15710
15675
|
case 34:
|
15711
|
-
#line
|
15676
|
+
#line 2688 "upb/json/parser.rl"
|
15712
15677
|
{ end_fieldmask_path(parser); }
|
15713
15678
|
break;
|
15714
15679
|
case 35:
|
15715
|
-
#line
|
15680
|
+
#line 2694 "upb/json/parser.rl"
|
15716
15681
|
{ p--; {cs = stack[--top]; goto _again;} }
|
15717
15682
|
break;
|
15718
15683
|
case 36:
|
15719
|
-
#line
|
15684
|
+
#line 2699 "upb/json/parser.rl"
|
15720
15685
|
{
|
15721
15686
|
if (is_wellknown_msg(parser, UPB_WELLKNOWN_TIMESTAMP)) {
|
15722
15687
|
{stack[top++] = cs; cs = 47;goto _again;}
|
@@ -15730,11 +15695,11 @@ _match:
|
|
15730
15695
|
}
|
15731
15696
|
break;
|
15732
15697
|
case 37:
|
15733
|
-
#line
|
15698
|
+
#line 2712 "upb/json/parser.rl"
|
15734
15699
|
{ p--; {stack[top++] = cs; cs = 78;goto _again;} }
|
15735
15700
|
break;
|
15736
15701
|
case 38:
|
15737
|
-
#line
|
15702
|
+
#line 2717 "upb/json/parser.rl"
|
15738
15703
|
{
|
15739
15704
|
if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
|
15740
15705
|
start_any_member(parser, p);
|
@@ -15744,11 +15709,11 @@ _match:
|
|
15744
15709
|
}
|
15745
15710
|
break;
|
15746
15711
|
case 39:
|
15747
|
-
#line
|
15712
|
+
#line 2724 "upb/json/parser.rl"
|
15748
15713
|
{ CHECK_RETURN_TOP(end_membername(parser)); }
|
15749
15714
|
break;
|
15750
15715
|
case 40:
|
15751
|
-
#line
|
15716
|
+
#line 2727 "upb/json/parser.rl"
|
15752
15717
|
{
|
15753
15718
|
if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
|
15754
15719
|
end_any_member(parser, p);
|
@@ -15758,7 +15723,7 @@ _match:
|
|
15758
15723
|
}
|
15759
15724
|
break;
|
15760
15725
|
case 41:
|
15761
|
-
#line
|
15726
|
+
#line 2738 "upb/json/parser.rl"
|
15762
15727
|
{
|
15763
15728
|
if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
|
15764
15729
|
start_any_object(parser, p);
|
@@ -15768,7 +15733,7 @@ _match:
|
|
15768
15733
|
}
|
15769
15734
|
break;
|
15770
15735
|
case 42:
|
15771
|
-
#line
|
15736
|
+
#line 2747 "upb/json/parser.rl"
|
15772
15737
|
{
|
15773
15738
|
if (is_wellknown_msg(parser, UPB_WELLKNOWN_ANY)) {
|
15774
15739
|
CHECK_RETURN_TOP(end_any_object(parser, p));
|
@@ -15778,54 +15743,54 @@ _match:
|
|
15778
15743
|
}
|
15779
15744
|
break;
|
15780
15745
|
case 43:
|
15781
|
-
#line
|
15746
|
+
#line 2759 "upb/json/parser.rl"
|
15782
15747
|
{ CHECK_RETURN_TOP(start_array(parser)); }
|
15783
15748
|
break;
|
15784
15749
|
case 44:
|
15785
|
-
#line
|
15750
|
+
#line 2763 "upb/json/parser.rl"
|
15786
15751
|
{ end_array(parser); }
|
15787
15752
|
break;
|
15788
15753
|
case 45:
|
15789
|
-
#line
|
15754
|
+
#line 2768 "upb/json/parser.rl"
|
15790
15755
|
{ CHECK_RETURN_TOP(start_number(parser, p)); }
|
15791
15756
|
break;
|
15792
15757
|
case 46:
|
15793
|
-
#line
|
15758
|
+
#line 2769 "upb/json/parser.rl"
|
15794
15759
|
{ CHECK_RETURN_TOP(end_number(parser, p)); }
|
15795
15760
|
break;
|
15796
15761
|
case 47:
|
15797
|
-
#line
|
15762
|
+
#line 2771 "upb/json/parser.rl"
|
15798
15763
|
{ CHECK_RETURN_TOP(start_stringval(parser)); }
|
15799
15764
|
break;
|
15800
15765
|
case 48:
|
15801
|
-
#line
|
15766
|
+
#line 2772 "upb/json/parser.rl"
|
15802
15767
|
{ CHECK_RETURN_TOP(end_stringval(parser)); }
|
15803
15768
|
break;
|
15804
15769
|
case 49:
|
15805
|
-
#line
|
15770
|
+
#line 2774 "upb/json/parser.rl"
|
15806
15771
|
{ CHECK_RETURN_TOP(end_bool(parser, true)); }
|
15807
15772
|
break;
|
15808
15773
|
case 50:
|
15809
|
-
#line
|
15774
|
+
#line 2776 "upb/json/parser.rl"
|
15810
15775
|
{ CHECK_RETURN_TOP(end_bool(parser, false)); }
|
15811
15776
|
break;
|
15812
15777
|
case 51:
|
15813
|
-
#line
|
15778
|
+
#line 2778 "upb/json/parser.rl"
|
15814
15779
|
{ CHECK_RETURN_TOP(end_null(parser)); }
|
15815
15780
|
break;
|
15816
15781
|
case 52:
|
15817
|
-
#line
|
15782
|
+
#line 2780 "upb/json/parser.rl"
|
15818
15783
|
{ CHECK_RETURN_TOP(start_subobject_full(parser)); }
|
15819
15784
|
break;
|
15820
15785
|
case 53:
|
15821
|
-
#line
|
15786
|
+
#line 2781 "upb/json/parser.rl"
|
15822
15787
|
{ end_subobject_full(parser); }
|
15823
15788
|
break;
|
15824
15789
|
case 54:
|
15825
|
-
#line
|
15790
|
+
#line 2786 "upb/json/parser.rl"
|
15826
15791
|
{ p--; {cs = stack[--top]; goto _again;} }
|
15827
15792
|
break;
|
15828
|
-
#line
|
15793
|
+
#line 3194 "upb/json/parser.c"
|
15829
15794
|
}
|
15830
15795
|
}
|
15831
15796
|
|
@@ -15842,32 +15807,32 @@ _again:
|
|
15842
15807
|
while ( __nacts-- > 0 ) {
|
15843
15808
|
switch ( *__acts++ ) {
|
15844
15809
|
case 0:
|
15845
|
-
#line
|
15810
|
+
#line 2595 "upb/json/parser.rl"
|
15846
15811
|
{ p--; {cs = stack[--top]; if ( p == pe )
|
15847
15812
|
goto _test_eof;
|
15848
15813
|
goto _again;} }
|
15849
15814
|
break;
|
15850
15815
|
case 46:
|
15851
|
-
#line
|
15816
|
+
#line 2769 "upb/json/parser.rl"
|
15852
15817
|
{ CHECK_RETURN_TOP(end_number(parser, p)); }
|
15853
15818
|
break;
|
15854
15819
|
case 49:
|
15855
|
-
#line
|
15820
|
+
#line 2774 "upb/json/parser.rl"
|
15856
15821
|
{ CHECK_RETURN_TOP(end_bool(parser, true)); }
|
15857
15822
|
break;
|
15858
15823
|
case 50:
|
15859
|
-
#line
|
15824
|
+
#line 2776 "upb/json/parser.rl"
|
15860
15825
|
{ CHECK_RETURN_TOP(end_bool(parser, false)); }
|
15861
15826
|
break;
|
15862
15827
|
case 51:
|
15863
|
-
#line
|
15828
|
+
#line 2778 "upb/json/parser.rl"
|
15864
15829
|
{ CHECK_RETURN_TOP(end_null(parser)); }
|
15865
15830
|
break;
|
15866
15831
|
case 53:
|
15867
|
-
#line
|
15832
|
+
#line 2781 "upb/json/parser.rl"
|
15868
15833
|
{ end_subobject_full(parser); }
|
15869
15834
|
break;
|
15870
|
-
#line
|
15835
|
+
#line 3236 "upb/json/parser.c"
|
15871
15836
|
}
|
15872
15837
|
}
|
15873
15838
|
}
|
@@ -15875,7 +15840,7 @@ goto _again;} }
|
|
15875
15840
|
_out: {}
|
15876
15841
|
}
|
15877
15842
|
|
15878
|
-
#line
|
15843
|
+
#line 2814 "upb/json/parser.rl"
|
15879
15844
|
|
15880
15845
|
if (p != pe) {
|
15881
15846
|
upb_status_seterrf(&parser->status, "Parse error at '%.*s'\n", pe - p, p);
|
@@ -15915,23 +15880,17 @@ static void json_parser_reset(upb_json_parser *p) {
|
|
15915
15880
|
int top;
|
15916
15881
|
|
15917
15882
|
p->top = p->stack;
|
15918
|
-
p->top
|
15919
|
-
p->top->is_repeated = false;
|
15920
|
-
p->top->is_map = false;
|
15921
|
-
p->top->is_mapentry = false;
|
15922
|
-
p->top->is_any = false;
|
15923
|
-
p->top->any_frame = NULL;
|
15924
|
-
p->top->is_unknown_field = false;
|
15883
|
+
init_frame(p->top);
|
15925
15884
|
|
15926
15885
|
/* Emit Ragel initialization of the parser. */
|
15927
15886
|
|
15928
|
-
#line
|
15887
|
+
#line 3288 "upb/json/parser.c"
|
15929
15888
|
{
|
15930
15889
|
cs = json_start;
|
15931
15890
|
top = 0;
|
15932
15891
|
}
|
15933
15892
|
|
15934
|
-
#line
|
15893
|
+
#line 2857 "upb/json/parser.rl"
|
15935
15894
|
p->current_state = cs;
|
15936
15895
|
p->parser_top = top;
|
15937
15896
|
accumulate_clear(p);
|
data/ext/google/protobuf_c/upb.h
CHANGED
@@ -10639,4 +10639,3 @@ inline reffed_ptr<const Handlers> Printer::NewHandlers(
|
|
10639
10639
|
#undef UPB_FIELD_AT
|
10640
10640
|
#undef UPB_READ_ONEOF
|
10641
10641
|
#undef UPB_WRITE_ONEOF
|
10642
|
-
#undef UPB_WRITE_ONEOF
|
data/tests/basic.rb
CHANGED
@@ -357,5 +357,25 @@ module BasicTest
|
|
357
357
|
assert_equal nil, file_descriptor.name
|
358
358
|
assert_equal :proto3, file_descriptor.syntax
|
359
359
|
end
|
360
|
+
|
361
|
+
# Ruby 2.5 changed to raise FrozenError instead of RuntimeError
|
362
|
+
FrozenErrorType = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.5') ? RuntimeError : FrozenError
|
363
|
+
|
364
|
+
def test_map_freeze
|
365
|
+
m = proto_module::MapMessage.new
|
366
|
+
m.map_string_int32['a'] = 5
|
367
|
+
m.map_string_msg['b'] = proto_module::TestMessage2.new
|
368
|
+
|
369
|
+
m.map_string_int32.freeze
|
370
|
+
m.map_string_msg.freeze
|
371
|
+
|
372
|
+
assert m.map_string_int32.frozen?
|
373
|
+
assert m.map_string_msg.frozen?
|
374
|
+
|
375
|
+
assert_raise(FrozenErrorType) { m.map_string_int32['foo'] = 1 }
|
376
|
+
assert_raise(FrozenErrorType) { m.map_string_msg['bar'] = proto_module::TestMessage2.new }
|
377
|
+
assert_raise(FrozenErrorType) { m.map_string_int32.delete('a') }
|
378
|
+
assert_raise(FrozenErrorType) { m.map_string_int32.clear }
|
379
|
+
end
|
360
380
|
end
|
361
381
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-protobuf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.8.0.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Protobuf Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03
|
11
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler-dock
|
@@ -123,11 +123,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
125
|
requirements:
|
126
|
-
- - "
|
126
|
+
- - ">"
|
127
127
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
128
|
+
version: 1.3.1
|
129
129
|
requirements: []
|
130
|
-
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.7.6
|
131
132
|
signing_key:
|
132
133
|
specification_version: 4
|
133
134
|
summary: Protocol Buffers
|