google-protobuf 3.11.3-x64-mingw32 → 3.11.4-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of google-protobuf might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/encode_decode.c +58 -23
- data/lib/google/2.3/protobuf_c.so +0 -0
- data/lib/google/2.4/protobuf_c.so +0 -0
- data/lib/google/2.5/protobuf_c.so +0 -0
- data/lib/google/2.6/protobuf_c.so +0 -0
- data/tests/basic.rb +80 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77b98d8cf95f29ee461e98f4b00098e47ef6eabf11c94fc29425c31e87ed9fb8
|
4
|
+
data.tar.gz: bfac2f3a5fd120f7b5f4c92ee717299de975dbd57eb8c1d2e72b8bfc2c36f67f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 277e9a92e8084c804ced1680e37d441d8f1cb3f333a674ee23a333809fd8950fedc6cc7a878f1da29f2243949f35bb52af5fd3bb4d71b060fa2af3f188a3d480
|
7
|
+
data.tar.gz: b3953ad12386cd68f0b128759f34c16d0841e3912cb18261bdf390df97ee764e0eadce12c481aa604e24aa76e252d92622da8cb12c3afce95d8db90e1b28d037
|
@@ -44,6 +44,23 @@ VALUE noleak_rb_str_cat(VALUE rb_str, const char *str, long len) {
|
|
44
44
|
return rb_str;
|
45
45
|
}
|
46
46
|
|
47
|
+
bool is_wrapper(const upb_msgdef* m) {
|
48
|
+
switch (upb_msgdef_wellknowntype(m)) {
|
49
|
+
case UPB_WELLKNOWN_DOUBLEVALUE:
|
50
|
+
case UPB_WELLKNOWN_FLOATVALUE:
|
51
|
+
case UPB_WELLKNOWN_INT64VALUE:
|
52
|
+
case UPB_WELLKNOWN_UINT64VALUE:
|
53
|
+
case UPB_WELLKNOWN_INT32VALUE:
|
54
|
+
case UPB_WELLKNOWN_UINT32VALUE:
|
55
|
+
case UPB_WELLKNOWN_STRINGVALUE:
|
56
|
+
case UPB_WELLKNOWN_BYTESVALUE:
|
57
|
+
case UPB_WELLKNOWN_BOOLVALUE:
|
58
|
+
return true;
|
59
|
+
default:
|
60
|
+
return false;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
47
64
|
// The code below also comes from upb's prototype Ruby binding, developed by
|
48
65
|
// haberman@.
|
49
66
|
|
@@ -117,19 +134,26 @@ static const void* newhandlerdata(upb_handlers* h, uint32_t ofs, int32_t hasbit)
|
|
117
134
|
typedef struct {
|
118
135
|
size_t ofs;
|
119
136
|
int32_t hasbit;
|
137
|
+
upb_fieldtype_t wrapped_type; // Only for wrappers.
|
120
138
|
VALUE subklass;
|
121
139
|
} submsg_handlerdata_t;
|
122
140
|
|
123
141
|
// Creates a handlerdata that contains offset and submessage type information.
|
124
142
|
static const void *newsubmsghandlerdata(upb_handlers* h,
|
143
|
+
const upb_fielddef *f,
|
125
144
|
uint32_t ofs,
|
126
145
|
int32_t hasbit,
|
127
146
|
VALUE subklass) {
|
128
147
|
submsg_handlerdata_t *hd = ALLOC(submsg_handlerdata_t);
|
148
|
+
const upb_msgdef *subm = upb_fielddef_msgsubdef(f);
|
129
149
|
hd->ofs = ofs;
|
130
150
|
hd->hasbit = hasbit;
|
131
151
|
hd->subklass = subklass;
|
132
152
|
upb_handlers_addcleanup(h, hd, xfree);
|
153
|
+
if (is_wrapper(subm)) {
|
154
|
+
const upb_fielddef *value_f = upb_msgdef_itof(subm, 1);
|
155
|
+
hd->wrapped_type = upb_fielddef_type(value_f);
|
156
|
+
}
|
133
157
|
return hd;
|
134
158
|
}
|
135
159
|
|
@@ -310,12 +334,39 @@ static void *submsg_handler(void *closure, const void *hd) {
|
|
310
334
|
}
|
311
335
|
|
312
336
|
static void* startwrapper(void* closure, const void* hd) {
|
313
|
-
char* msg = closure;
|
314
337
|
const submsg_handlerdata_t* submsgdata = hd;
|
338
|
+
char* msg = closure;
|
339
|
+
VALUE* field = (VALUE*)(msg + submsgdata->ofs);
|
315
340
|
|
316
341
|
set_hasbit(closure, submsgdata->hasbit);
|
317
342
|
|
318
|
-
|
343
|
+
switch (submsgdata->wrapped_type) {
|
344
|
+
case UPB_TYPE_FLOAT:
|
345
|
+
case UPB_TYPE_DOUBLE:
|
346
|
+
*field = DBL2NUM(0);
|
347
|
+
break;
|
348
|
+
case UPB_TYPE_BOOL:
|
349
|
+
*field = Qfalse;
|
350
|
+
break;
|
351
|
+
case UPB_TYPE_STRING:
|
352
|
+
*field = get_frozen_string(NULL, 0, false);
|
353
|
+
break;
|
354
|
+
case UPB_TYPE_BYTES:
|
355
|
+
*field = get_frozen_string(NULL, 0, true);
|
356
|
+
break;
|
357
|
+
case UPB_TYPE_ENUM:
|
358
|
+
case UPB_TYPE_INT32:
|
359
|
+
case UPB_TYPE_INT64:
|
360
|
+
case UPB_TYPE_UINT32:
|
361
|
+
case UPB_TYPE_UINT64:
|
362
|
+
*field = INT2NUM(0);
|
363
|
+
break;
|
364
|
+
case UPB_TYPE_MESSAGE:
|
365
|
+
rb_raise(rb_eRuntimeError,
|
366
|
+
"Internal logic error with well-known types.");
|
367
|
+
}
|
368
|
+
|
369
|
+
return field;
|
319
370
|
}
|
320
371
|
|
321
372
|
// Handler data for startmap/endmap handlers.
|
@@ -522,23 +573,6 @@ static void* oneof_startwrapper(void* closure, const void* hd) {
|
|
522
573
|
return msg + oneofdata->ofs;
|
523
574
|
}
|
524
575
|
|
525
|
-
bool is_wrapper(const upb_msgdef* m) {
|
526
|
-
switch (upb_msgdef_wellknowntype(m)) {
|
527
|
-
case UPB_WELLKNOWN_DOUBLEVALUE:
|
528
|
-
case UPB_WELLKNOWN_FLOATVALUE:
|
529
|
-
case UPB_WELLKNOWN_INT64VALUE:
|
530
|
-
case UPB_WELLKNOWN_UINT64VALUE:
|
531
|
-
case UPB_WELLKNOWN_INT32VALUE:
|
532
|
-
case UPB_WELLKNOWN_UINT32VALUE:
|
533
|
-
case UPB_WELLKNOWN_STRINGVALUE:
|
534
|
-
case UPB_WELLKNOWN_BYTESVALUE:
|
535
|
-
case UPB_WELLKNOWN_BOOLVALUE:
|
536
|
-
return true;
|
537
|
-
default:
|
538
|
-
return false;
|
539
|
-
}
|
540
|
-
}
|
541
|
-
|
542
576
|
// Set up handlers for a repeated field.
|
543
577
|
static void add_handlers_for_repeated_field(upb_handlers *h,
|
544
578
|
const Descriptor* desc,
|
@@ -579,7 +613,7 @@ static void add_handlers_for_repeated_field(upb_handlers *h,
|
|
579
613
|
case UPB_TYPE_MESSAGE: {
|
580
614
|
VALUE subklass = field_type_class(desc->layout, f);
|
581
615
|
upb_handlerattr attr = UPB_HANDLERATTR_INIT;
|
582
|
-
attr.handler_data = newsubmsghandlerdata(h, 0, -1, subklass);
|
616
|
+
attr.handler_data = newsubmsghandlerdata(h, f, 0, -1, subklass);
|
583
617
|
if (is_wrapper(upb_fielddef_msgsubdef(f))) {
|
584
618
|
upb_handlers_setstartsubmsg(h, f, appendwrapper_handler, &attr);
|
585
619
|
} else {
|
@@ -708,7 +742,7 @@ static void add_handlers_for_singular_field(const Descriptor* desc,
|
|
708
742
|
case UPB_TYPE_MESSAGE: {
|
709
743
|
upb_handlerattr attr = UPB_HANDLERATTR_INIT;
|
710
744
|
attr.handler_data = newsubmsghandlerdata(
|
711
|
-
h, offset, hasbit, field_type_class(desc->layout, f));
|
745
|
+
h, f, offset, hasbit, field_type_class(desc->layout, f));
|
712
746
|
if (is_wrapper(upb_fielddef_msgsubdef(f))) {
|
713
747
|
upb_handlers_setstartsubmsg(h, f, startwrapper, &attr);
|
714
748
|
} else {
|
@@ -1432,6 +1466,7 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc,
|
|
1432
1466
|
MessageHeader* msg;
|
1433
1467
|
upb_msg_field_iter i;
|
1434
1468
|
upb_status status;
|
1469
|
+
bool json_wrapper = is_wrapper(desc->msgdef) && is_json;
|
1435
1470
|
|
1436
1471
|
if (is_json &&
|
1437
1472
|
upb_msgdef_wellknowntype(desc->msgdef) == UPB_WELLKNOWN_ANY) {
|
@@ -1508,7 +1543,7 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc,
|
|
1508
1543
|
is_default = RSTRING_LEN(str) == 0;
|
1509
1544
|
}
|
1510
1545
|
|
1511
|
-
if (is_matching_oneof || emit_defaults || !is_default) {
|
1546
|
+
if (is_matching_oneof || emit_defaults || !is_default || json_wrapper) {
|
1512
1547
|
putstr(str, f, sink);
|
1513
1548
|
}
|
1514
1549
|
} else if (upb_fielddef_issubmsg(f)) {
|
@@ -1528,7 +1563,7 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc,
|
|
1528
1563
|
} else if (upb_msgdef_syntax(desc->msgdef) == UPB_SYNTAX_PROTO3) { \
|
1529
1564
|
is_default = default_value == value; \
|
1530
1565
|
} \
|
1531
|
-
if (is_matching_oneof || emit_defaults || !is_default) {
|
1566
|
+
if (is_matching_oneof || emit_defaults || !is_default || json_wrapper) { \
|
1532
1567
|
upb_sink_put##upbtype(sink, sel, value); \
|
1533
1568
|
} \
|
1534
1569
|
} break;
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/tests/basic.rb
CHANGED
@@ -276,6 +276,86 @@ module BasicTest
|
|
276
276
|
assert_equal m5, m
|
277
277
|
end
|
278
278
|
|
279
|
+
def test_map_wrappers_with_default_values
|
280
|
+
run_asserts = ->(m) {
|
281
|
+
assert_equal 0.0, m.map_double[0].value
|
282
|
+
assert_equal 0.0, m.map_float[0].value
|
283
|
+
assert_equal 0, m.map_int32[0].value
|
284
|
+
assert_equal 0, m.map_int64[0].value
|
285
|
+
assert_equal 0, m.map_uint32[0].value
|
286
|
+
assert_equal 0, m.map_uint64[0].value
|
287
|
+
assert_equal false, m.map_bool[0].value
|
288
|
+
assert_equal '', m.map_string[0].value
|
289
|
+
assert_equal '', m.map_bytes[0].value
|
290
|
+
}
|
291
|
+
|
292
|
+
m = proto_module::Wrapper.new(
|
293
|
+
map_double: {0 => Google::Protobuf::DoubleValue.new(value: 0.0)},
|
294
|
+
map_float: {0 => Google::Protobuf::FloatValue.new(value: 0.0)},
|
295
|
+
map_int32: {0 => Google::Protobuf::Int32Value.new(value: 0)},
|
296
|
+
map_int64: {0 => Google::Protobuf::Int64Value.new(value: 0)},
|
297
|
+
map_uint32: {0 => Google::Protobuf::UInt32Value.new(value: 0)},
|
298
|
+
map_uint64: {0 => Google::Protobuf::UInt64Value.new(value: 0)},
|
299
|
+
map_bool: {0 => Google::Protobuf::BoolValue.new(value: false)},
|
300
|
+
map_string: {0 => Google::Protobuf::StringValue.new(value: '')},
|
301
|
+
map_bytes: {0 => Google::Protobuf::BytesValue.new(value: '')},
|
302
|
+
)
|
303
|
+
|
304
|
+
run_asserts.call(m)
|
305
|
+
serialized = proto_module::Wrapper::encode(m)
|
306
|
+
m2 = proto_module::Wrapper::decode(serialized)
|
307
|
+
run_asserts.call(m2)
|
308
|
+
|
309
|
+
# Test the case where we are serializing directly from the parsed form
|
310
|
+
# (before anything lazy is materialized).
|
311
|
+
m3 = proto_module::Wrapper::decode(serialized)
|
312
|
+
serialized2 = proto_module::Wrapper::encode(m3)
|
313
|
+
m4 = proto_module::Wrapper::decode(serialized2)
|
314
|
+
run_asserts.call(m4)
|
315
|
+
|
316
|
+
# Test that the lazy form compares equal to the expanded form.
|
317
|
+
m5 = proto_module::Wrapper::decode(serialized2)
|
318
|
+
assert_equal m5, m
|
319
|
+
end
|
320
|
+
|
321
|
+
def test_map_wrappers_with_no_value
|
322
|
+
run_asserts = ->(m) {
|
323
|
+
assert_equal 0.0, m.map_double[0].value
|
324
|
+
assert_equal 0.0, m.map_float[0].value
|
325
|
+
assert_equal 0, m.map_int32[0].value
|
326
|
+
assert_equal 0, m.map_int64[0].value
|
327
|
+
assert_equal 0, m.map_uint32[0].value
|
328
|
+
assert_equal 0, m.map_uint64[0].value
|
329
|
+
assert_equal false, m.map_bool[0].value
|
330
|
+
assert_equal '', m.map_string[0].value
|
331
|
+
assert_equal '', m.map_bytes[0].value
|
332
|
+
}
|
333
|
+
|
334
|
+
m = proto_module::Wrapper.new(
|
335
|
+
map_double: {0 => Google::Protobuf::DoubleValue.new()},
|
336
|
+
map_float: {0 => Google::Protobuf::FloatValue.new()},
|
337
|
+
map_int32: {0 => Google::Protobuf::Int32Value.new()},
|
338
|
+
map_int64: {0 => Google::Protobuf::Int64Value.new()},
|
339
|
+
map_uint32: {0 => Google::Protobuf::UInt32Value.new()},
|
340
|
+
map_uint64: {0 => Google::Protobuf::UInt64Value.new()},
|
341
|
+
map_bool: {0 => Google::Protobuf::BoolValue.new()},
|
342
|
+
map_string: {0 => Google::Protobuf::StringValue.new()},
|
343
|
+
map_bytes: {0 => Google::Protobuf::BytesValue.new()},
|
344
|
+
)
|
345
|
+
run_asserts.call(m)
|
346
|
+
|
347
|
+
serialized = proto_module::Wrapper::encode(m)
|
348
|
+
m2 = proto_module::Wrapper::decode(serialized)
|
349
|
+
run_asserts.call(m2)
|
350
|
+
|
351
|
+
# Test the case where we are serializing directly from the parsed form
|
352
|
+
# (before anything lazy is materialized).
|
353
|
+
m3 = proto_module::Wrapper::decode(serialized)
|
354
|
+
serialized2 = proto_module::Wrapper::encode(m3)
|
355
|
+
m4 = proto_module::Wrapper::decode(serialized2)
|
356
|
+
run_asserts.call(m4)
|
357
|
+
end
|
358
|
+
|
279
359
|
def test_concurrent_decoding
|
280
360
|
o = Outer.new
|
281
361
|
o.items[0] = Inner.new
|
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.11.
|
4
|
+
version: 3.11.4
|
5
5
|
platform: x64-mingw32
|
6
6
|
authors:
|
7
7
|
- Protobuf Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler-dock
|
@@ -115,7 +115,7 @@ homepage: https://developers.google.com/protocol-buffers
|
|
115
115
|
licenses:
|
116
116
|
- BSD-3-Clause
|
117
117
|
metadata:
|
118
|
-
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.11.
|
118
|
+
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.11.4/ruby
|
119
119
|
post_install_message:
|
120
120
|
rdoc_options: []
|
121
121
|
require_paths:
|