google-protobuf 3.19.2 → 3.21.3
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/convert.c +128 -115
- data/ext/google/protobuf_c/convert.h +12 -9
- data/ext/google/protobuf_c/defs.c +197 -201
- data/ext/google/protobuf_c/defs.h +19 -19
- data/ext/google/protobuf_c/extconf.rb +11 -3
- data/ext/google/protobuf_c/map.c +109 -101
- data/ext/google/protobuf_c/map.h +7 -8
- data/ext/google/protobuf_c/message.c +378 -305
- data/ext/google/protobuf_c/message.h +22 -19
- data/ext/google/protobuf_c/protobuf.c +68 -58
- data/ext/google/protobuf_c/protobuf.h +13 -10
- data/ext/google/protobuf_c/repeated_field.c +82 -84
- data/ext/google/protobuf_c/repeated_field.h +6 -6
- data/ext/google/protobuf_c/ruby-upb.c +5054 -3110
- data/ext/google/protobuf_c/ruby-upb.h +2838 -1930
- data/ext/google/protobuf_c/third_party/utf8_range/LICENSE +21 -0
- data/ext/google/protobuf_c/third_party/utf8_range/naive.c +92 -0
- data/ext/google/protobuf_c/third_party/utf8_range/range2-neon.c +157 -0
- data/ext/google/protobuf_c/third_party/utf8_range/range2-sse.c +170 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +9 -0
- data/ext/google/protobuf_c/wrap_memcpy.c +4 -3
- data/lib/google/protobuf/descriptor_dsl.rb +8 -1
- data/lib/google/protobuf/descriptor_pb.rb +3 -2
- data/lib/google/protobuf/message_exts.rb +2 -2
- data/lib/google/protobuf/repeated_field.rb +15 -2
- data/lib/google/protobuf/well_known_types.rb +11 -6
- data/lib/google/protobuf.rb +4 -4
- data/tests/basic.rb +110 -11
- metadata +11 -6
data/tests/basic.rb
CHANGED
@@ -66,11 +66,50 @@ module BasicTest
|
|
66
66
|
def test_issue_8559_crash
|
67
67
|
msg = TestMessage.new
|
68
68
|
msg.repeated_int32 = ::Google::Protobuf::RepeatedField.new(:int32, [1, 2, 3])
|
69
|
-
|
70
|
-
|
69
|
+
|
70
|
+
# https://github.com/jruby/jruby/issues/6818 was fixed in JRuby 9.3.0.0
|
71
|
+
if cruby_or_jruby_9_3_or_higher?
|
72
|
+
GC.start(full_mark: true, immediate_sweep: true)
|
73
|
+
end
|
71
74
|
TestMessage.encode(msg)
|
72
75
|
end
|
73
76
|
|
77
|
+
def test_issue_9440
|
78
|
+
msg = HelloRequest.new
|
79
|
+
msg.id = 8
|
80
|
+
assert_equal 8, msg.id
|
81
|
+
msg.version = '1'
|
82
|
+
assert_equal 8, msg.id
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_issue_9507
|
86
|
+
pool = Google::Protobuf::DescriptorPool.new
|
87
|
+
pool.build do
|
88
|
+
add_message "NpeMessage" do
|
89
|
+
optional :type, :enum, 1, "TestEnum"
|
90
|
+
optional :other, :string, 2
|
91
|
+
end
|
92
|
+
add_enum "TestEnum" do
|
93
|
+
value :Something, 0
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
msgclass = pool.lookup("NpeMessage").msgclass
|
98
|
+
|
99
|
+
m = msgclass.new(
|
100
|
+
other: "foo" # must be set, but can be blank
|
101
|
+
)
|
102
|
+
|
103
|
+
begin
|
104
|
+
encoded = msgclass.encode(m)
|
105
|
+
rescue java.lang.NullPointerException
|
106
|
+
flunk "NPE rescued"
|
107
|
+
end
|
108
|
+
decoded = msgclass.decode(encoded)
|
109
|
+
decoded.inspect
|
110
|
+
decoded.to_proto
|
111
|
+
end
|
112
|
+
|
74
113
|
def test_has_field
|
75
114
|
m = TestSingularFields.new
|
76
115
|
assert !m.has_singular_msg?
|
@@ -137,7 +176,7 @@ module BasicTest
|
|
137
176
|
m = TestSingularFields.new
|
138
177
|
|
139
178
|
m.singular_int32 = -42
|
140
|
-
assert_equal -42, m.singular_int32
|
179
|
+
assert_equal( -42, m.singular_int32 )
|
141
180
|
m.clear_singular_int32
|
142
181
|
assert_equal 0, m.singular_int32
|
143
182
|
|
@@ -532,8 +571,6 @@ module BasicTest
|
|
532
571
|
|
533
572
|
|
534
573
|
def test_json_maps
|
535
|
-
# TODO: Fix JSON in JRuby version.
|
536
|
-
return if RUBY_PLATFORM == "java"
|
537
574
|
m = MapMessage.new(:map_string_int32 => {"a" => 1})
|
538
575
|
expected = {mapStringInt32: {a: 1}, mapStringMsg: {}, mapStringEnum: {}}
|
539
576
|
expected_preserve = {map_string_int32: {a: 1}, map_string_msg: {}, map_string_enum: {}}
|
@@ -547,8 +584,6 @@ module BasicTest
|
|
547
584
|
end
|
548
585
|
|
549
586
|
def test_json_maps_emit_defaults_submsg
|
550
|
-
# TODO: Fix JSON in JRuby version.
|
551
|
-
return if RUBY_PLATFORM == "java"
|
552
587
|
m = MapMessage.new(:map_string_msg => {"a" => TestMessage2.new(foo: 0)})
|
553
588
|
expected = {mapStringInt32: {}, mapStringMsg: {a: {foo: 0}}, mapStringEnum: {}}
|
554
589
|
|
@@ -558,8 +593,6 @@ module BasicTest
|
|
558
593
|
end
|
559
594
|
|
560
595
|
def test_json_emit_defaults_submsg
|
561
|
-
# TODO: Fix JSON in JRuby version.
|
562
|
-
return if RUBY_PLATFORM == "java"
|
563
596
|
m = TestSingularFields.new(singular_msg: proto_module::TestMessage2.new)
|
564
597
|
|
565
598
|
expected = {
|
@@ -582,8 +615,6 @@ module BasicTest
|
|
582
615
|
end
|
583
616
|
|
584
617
|
def test_respond_to
|
585
|
-
# This test fails with JRuby 1.7.23, likely because of an old JRuby bug.
|
586
|
-
return if RUBY_PLATFORM == "java"
|
587
618
|
msg = MapMessage.new
|
588
619
|
assert msg.respond_to?(:map_string_int32)
|
589
620
|
assert !msg.respond_to?(:bacon)
|
@@ -636,5 +667,73 @@ module BasicTest
|
|
636
667
|
assert_equal 2, m.map_string_int32.size
|
637
668
|
assert_equal 1, m.map_string_msg.size
|
638
669
|
end
|
670
|
+
|
671
|
+
def test_string_with_singleton_class_enabled
|
672
|
+
str = 'foobar'
|
673
|
+
# NOTE: Accessing a singleton class of an object changes its low level class representation
|
674
|
+
# as far as the C API's CLASS_OF() method concerned, exposing the issue
|
675
|
+
str.singleton_class
|
676
|
+
m = proto_module::TestMessage.new(
|
677
|
+
optional_string: str,
|
678
|
+
optional_bytes: str
|
679
|
+
)
|
680
|
+
|
681
|
+
assert_equal str, m.optional_string
|
682
|
+
assert_equal str, m.optional_bytes
|
683
|
+
end
|
684
|
+
|
685
|
+
def test_utf8
|
686
|
+
m = proto_module::TestMessage.new(
|
687
|
+
optional_string: "µpb",
|
688
|
+
)
|
689
|
+
m2 = proto_module::TestMessage.decode(proto_module::TestMessage.encode(m))
|
690
|
+
assert_equal m2, m
|
691
|
+
end
|
692
|
+
|
693
|
+
def test_map_fields_respond_to? # regression test for issue 9202
|
694
|
+
msg = proto_module::MapMessage.new
|
695
|
+
assert msg.respond_to?(:map_string_int32=)
|
696
|
+
msg.map_string_int32 = Google::Protobuf::Map.new(:string, :int32)
|
697
|
+
assert msg.respond_to?(:map_string_int32)
|
698
|
+
assert_equal( Google::Protobuf::Map.new(:string, :int32), msg.map_string_int32 )
|
699
|
+
assert msg.respond_to?(:clear_map_string_int32)
|
700
|
+
msg.clear_map_string_int32
|
701
|
+
|
702
|
+
assert !msg.respond_to?(:has_map_string_int32?)
|
703
|
+
assert_raise NoMethodError do
|
704
|
+
msg.has_map_string_int32?
|
705
|
+
end
|
706
|
+
assert !msg.respond_to?(:map_string_int32_as_value)
|
707
|
+
assert_raise NoMethodError do
|
708
|
+
msg.map_string_int32_as_value
|
709
|
+
end
|
710
|
+
assert !msg.respond_to?(:map_string_int32_as_value=)
|
711
|
+
assert_raise NoMethodError do
|
712
|
+
msg.map_string_int32_as_value = :boom
|
713
|
+
end
|
714
|
+
end
|
715
|
+
end
|
716
|
+
|
717
|
+
def test_oneof_fields_respond_to? # regression test for issue 9202
|
718
|
+
msg = proto_module::OneofMessage.new
|
719
|
+
# `has_` prefix + "?" suffix actions should only work for oneofs fields.
|
720
|
+
assert msg.has_my_oneof?
|
721
|
+
assert msg.respond_to? :has_my_oneof?
|
722
|
+
assert !msg.respond_to?( :has_a? )
|
723
|
+
assert_raise NoMethodError do
|
724
|
+
msg.has_a?
|
725
|
+
end
|
726
|
+
assert !msg.respond_to?( :has_b? )
|
727
|
+
assert_raise NoMethodError do
|
728
|
+
msg.has_b?
|
729
|
+
end
|
730
|
+
assert !msg.respond_to?( :has_c? )
|
731
|
+
assert_raise NoMethodError do
|
732
|
+
msg.has_c?
|
733
|
+
end
|
734
|
+
assert !msg.respond_to?( :has_d? )
|
735
|
+
assert_raise NoMethodError do
|
736
|
+
msg.has_d?
|
737
|
+
end
|
639
738
|
end
|
640
739
|
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.21.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Protobuf Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler-dock
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.1
|
19
|
+
version: 1.2.1
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.1
|
26
|
+
version: 1.2.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake-compiler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,11 @@ files:
|
|
80
80
|
- ext/google/protobuf_c/repeated_field.h
|
81
81
|
- ext/google/protobuf_c/ruby-upb.c
|
82
82
|
- ext/google/protobuf_c/ruby-upb.h
|
83
|
+
- ext/google/protobuf_c/third_party/utf8_range/LICENSE
|
84
|
+
- ext/google/protobuf_c/third_party/utf8_range/naive.c
|
85
|
+
- ext/google/protobuf_c/third_party/utf8_range/range2-neon.c
|
86
|
+
- ext/google/protobuf_c/third_party/utf8_range/range2-sse.c
|
87
|
+
- ext/google/protobuf_c/third_party/utf8_range/utf8_range.h
|
83
88
|
- ext/google/protobuf_c/wrap_memcpy.c
|
84
89
|
- lib/google/protobuf.rb
|
85
90
|
- lib/google/protobuf/any_pb.rb
|
@@ -104,7 +109,7 @@ homepage: https://developers.google.com/protocol-buffers
|
|
104
109
|
licenses:
|
105
110
|
- BSD-3-Clause
|
106
111
|
metadata:
|
107
|
-
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.
|
112
|
+
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.21.3/ruby
|
108
113
|
post_install_message:
|
109
114
|
rdoc_options: []
|
110
115
|
require_paths:
|
@@ -120,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
125
|
- !ruby/object:Gem::Version
|
121
126
|
version: '0'
|
122
127
|
requirements: []
|
123
|
-
rubygems_version: 3.3.
|
128
|
+
rubygems_version: 3.3.18
|
124
129
|
signing_key:
|
125
130
|
specification_version: 4
|
126
131
|
summary: Protocol Buffers
|