google-protobuf 3.14.0 → 3.18.0
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 +348 -0
- data/ext/google/protobuf_c/convert.h +72 -0
- data/ext/google/protobuf_c/defs.c +466 -1548
- data/ext/google/protobuf_c/defs.h +107 -0
- data/ext/google/protobuf_c/extconf.rb +4 -5
- data/ext/google/protobuf_c/map.c +311 -456
- data/ext/google/protobuf_c/map.h +67 -0
- data/ext/google/protobuf_c/message.c +903 -434
- data/ext/google/protobuf_c/message.h +101 -0
- data/ext/google/protobuf_c/protobuf.c +398 -64
- data/ext/google/protobuf_c/protobuf.h +43 -593
- data/ext/google/protobuf_c/repeated_field.c +294 -321
- data/ext/google/protobuf_c/repeated_field.h +63 -0
- data/ext/google/protobuf_c/ruby-upb.c +9171 -0
- data/ext/google/protobuf_c/{upb.h → ruby-upb.h} +1922 -3995
- data/lib/google/protobuf/api_pb.rb +2 -2
- data/lib/google/protobuf/descriptor_dsl.rb +458 -0
- data/lib/google/protobuf/descriptor_pb.rb +266 -0
- data/lib/google/protobuf/type_pb.rb +2 -2
- data/lib/google/protobuf.rb +1 -69
- data/tests/basic.rb +74 -6
- metadata +16 -10
- data/ext/google/protobuf_c/encode_decode.c +0 -1795
- data/ext/google/protobuf_c/storage.c +0 -1198
- data/ext/google/protobuf_c/upb.c +0 -13817
@@ -0,0 +1,266 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: google/protobuf/descriptor.proto
|
3
|
+
|
4
|
+
descriptor_data = File.binread(__FILE__).split("\n__END__\n", 2)[1]
|
5
|
+
Google::Protobuf::DescriptorPool.generated_pool.add_serialized_file(descriptor_data)
|
6
|
+
|
7
|
+
module Google
|
8
|
+
module Protobuf
|
9
|
+
FileDescriptorSet = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FileDescriptorSet").msgclass
|
10
|
+
FileDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FileDescriptorProto").msgclass
|
11
|
+
DescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DescriptorProto").msgclass
|
12
|
+
DescriptorProto::ExtensionRange = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DescriptorProto.ExtensionRange").msgclass
|
13
|
+
DescriptorProto::ReservedRange = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DescriptorProto.ReservedRange").msgclass
|
14
|
+
ExtensionRangeOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ExtensionRangeOptions").msgclass
|
15
|
+
FieldDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldDescriptorProto").msgclass
|
16
|
+
FieldDescriptorProto::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldDescriptorProto.Type").enummodule
|
17
|
+
FieldDescriptorProto::Label = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldDescriptorProto.Label").enummodule
|
18
|
+
OneofDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.OneofDescriptorProto").msgclass
|
19
|
+
EnumDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumDescriptorProto").msgclass
|
20
|
+
EnumDescriptorProto::EnumReservedRange = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumDescriptorProto.EnumReservedRange").msgclass
|
21
|
+
EnumValueDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumValueDescriptorProto").msgclass
|
22
|
+
ServiceDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ServiceDescriptorProto").msgclass
|
23
|
+
MethodDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.MethodDescriptorProto").msgclass
|
24
|
+
FileOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FileOptions").msgclass
|
25
|
+
FileOptions::OptimizeMode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FileOptions.OptimizeMode").enummodule
|
26
|
+
MessageOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.MessageOptions").msgclass
|
27
|
+
FieldOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions").msgclass
|
28
|
+
FieldOptions::CType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.CType").enummodule
|
29
|
+
FieldOptions::JSType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.JSType").enummodule
|
30
|
+
OneofOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.OneofOptions").msgclass
|
31
|
+
EnumOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumOptions").msgclass
|
32
|
+
EnumValueOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumValueOptions").msgclass
|
33
|
+
ServiceOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ServiceOptions").msgclass
|
34
|
+
MethodOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.MethodOptions").msgclass
|
35
|
+
MethodOptions::IdempotencyLevel = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.MethodOptions.IdempotencyLevel").enummodule
|
36
|
+
UninterpretedOption = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UninterpretedOption").msgclass
|
37
|
+
UninterpretedOption::NamePart = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UninterpretedOption.NamePart").msgclass
|
38
|
+
SourceCodeInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.SourceCodeInfo").msgclass
|
39
|
+
SourceCodeInfo::Location = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.SourceCodeInfo.Location").msgclass
|
40
|
+
GeneratedCodeInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.GeneratedCodeInfo").msgclass
|
41
|
+
GeneratedCodeInfo::Annotation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.GeneratedCodeInfo.Annotation").msgclass
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
__END__
|
46
|
+
|
47
|
+
google/protobuf/descriptor.protogoogle.protobuf"G
|
48
|
+
FileDescriptorSet2
|
49
|
+
file (2$.google.protobuf.FileDescriptorProto"�
|
50
|
+
FileDescriptorProto
|
51
|
+
name (
|
52
|
+
package (
|
53
|
+
|
54
|
+
dependency (
|
55
|
+
public_dependency
|
56
|
+
(
|
57
|
+
weak_dependency (6
|
58
|
+
message_type (2 .google.protobuf.DescriptorProto7
|
59
|
+
enum_type (2$.google.protobuf.EnumDescriptorProto8
|
60
|
+
service (2'.google.protobuf.ServiceDescriptorProto8
|
61
|
+
extension (2%.google.protobuf.FieldDescriptorProto-
|
62
|
+
options (2.google.protobuf.FileOptions9
|
63
|
+
source_code_info (2.google.protobuf.SourceCodeInfo
|
64
|
+
syntax ( "�
|
65
|
+
DescriptorProto
|
66
|
+
name ( 4
|
67
|
+
field (2%.google.protobuf.FieldDescriptorProto8
|
68
|
+
extension (2%.google.protobuf.FieldDescriptorProto5
|
69
|
+
nested_type (2 .google.protobuf.DescriptorProto7
|
70
|
+
enum_type (2$.google.protobuf.EnumDescriptorProtoH
|
71
|
+
extension_range (2/.google.protobuf.DescriptorProto.ExtensionRange9
|
72
|
+
|
73
|
+
oneof_decl (2%.google.protobuf.OneofDescriptorProto0
|
74
|
+
options (2.google.protobuf.MessageOptionsF
|
75
|
+
reserved_range (2..google.protobuf.DescriptorProto.ReservedRange
|
76
|
+
|
77
|
+
( e
|
78
|
+
ExtensionRange
|
79
|
+
start (
|
80
|
+
end (7
|
81
|
+
options (2&.google.protobuf.ExtensionRangeOptions+
|
82
|
+
|
83
|
+
start (
|
84
|
+
end ("g
|
85
|
+
ExtensionRangeOptionsC
|
86
|
+
uninterpreted_option� (2$.google.protobuf.UninterpretedOption* �����"�
|
87
|
+
FieldDescriptorProto
|
88
|
+
name (
|
89
|
+
number (:
|
90
|
+
label (2+.google.protobuf.FieldDescriptorProto.Label8
|
91
|
+
type (2*.google.protobuf.FieldDescriptorProto.Type
|
92
|
+
type_name (
|
93
|
+
extendee (
|
94
|
+
|
95
|
+
oneof_index (
|
96
|
+
json_name
|
97
|
+
( .
|
98
|
+
options (2.google.protobuf.FieldOptions
|
99
|
+
proto3_optional ("�
|
100
|
+
Type
|
101
|
+
TYPE_DOUBLE
|
102
|
+
|
103
|
+
TYPE_FLOAT
|
104
|
+
|
105
|
+
TYPE_INT64
|
106
|
+
TYPE_UINT64
|
107
|
+
|
108
|
+
TYPE_INT32
|
109
|
+
TYPE_FIXED64
|
110
|
+
TYPE_FIXED32
|
111
|
+
TYPE_BOOL
|
112
|
+
TYPE_STRING
|
113
|
+
|
114
|
+
TYPE_GROUP
|
115
|
+
|
116
|
+
TYPE_MESSAGE
|
117
|
+
|
118
|
+
TYPE_BYTES
|
119
|
+
TYPE_UINT32
|
120
|
+
TYPE_ENUM
|
121
|
+
|
122
|
+
|
123
|
+
TYPE_SINT32
|
124
|
+
TYPE_SINT64"C
|
125
|
+
Label
|
126
|
+
LABEL_OPTIONAL
|
127
|
+
LABEL_REQUIRED
|
128
|
+
LABEL_REPEATED"T
|
129
|
+
OneofDescriptorProto
|
130
|
+
name ( .
|
131
|
+
options (2.google.protobuf.OneofOptions"�
|
132
|
+
EnumDescriptorProto
|
133
|
+
name ( 8
|
134
|
+
value (2).google.protobuf.EnumValueDescriptorProto-
|
135
|
+
options (2.google.protobuf.EnumOptionsN
|
136
|
+
reserved_range (26.google.protobuf.EnumDescriptorProto.EnumReservedRange
|
137
|
+
|
138
|
+
EnumReservedRange
|
139
|
+
start (
|
140
|
+
end ("l
|
141
|
+
EnumValueDescriptorProto
|
142
|
+
name (
|
143
|
+
number (2
|
144
|
+
options (2!.google.protobuf.EnumValueOptions"�
|
145
|
+
ServiceDescriptorProto
|
146
|
+
name ( 6
|
147
|
+
method (2&.google.protobuf.MethodDescriptorProto0
|
148
|
+
options (2.google.protobuf.ServiceOptions"�
|
149
|
+
MethodDescriptorProto
|
150
|
+
name (
|
151
|
+
|
152
|
+
input_type (
|
153
|
+
output_type ( /
|
154
|
+
options (2.google.protobuf.MethodOptions
|
155
|
+
client_streaming (:false
|
156
|
+
server_streaming (:false"�
|
157
|
+
FileOptions
|
158
|
+
java_package (
|
159
|
+
java_outer_classname ( "
|
160
|
+
java_multiple_files
|
161
|
+
(:false)
|
162
|
+
java_generate_equals_and_hash (B%
|
163
|
+
java_string_check_utf8 (:falseF
|
164
|
+
optimize_for (2).google.protobuf.FileOptions.OptimizeMode:SPEED
|
165
|
+
|
166
|
+
go_package ( "
|
167
|
+
cc_generic_services (:false$
|
168
|
+
java_generic_services (:false"
|
169
|
+
py_generic_services (:false#
|
170
|
+
php_generic_services* (:false
|
171
|
+
|
172
|
+
deprecated (:false
|
173
|
+
cc_enable_arenas (:true
|
174
|
+
objc_class_prefix$ (
|
175
|
+
csharp_namespace% (
|
176
|
+
swift_prefix' (
|
177
|
+
php_class_prefix( (
|
178
|
+
|
179
|
+
php_metadata_namespace, (
|
180
|
+
ruby_package- ( C
|
181
|
+
uninterpreted_option� (2$.google.protobuf.UninterpretedOption":
|
182
|
+
OptimizeMode
|
183
|
+
SPEED
|
184
|
+
CODE_SIZE
|
185
|
+
LITE_RUNTIME* �����J&'"�
|
186
|
+
MessageOptions&
|
187
|
+
message_set_wire_format (:false.
|
188
|
+
no_standard_descriptor_accessor (:false
|
189
|
+
|
190
|
+
deprecated (:false
|
191
|
+
map_entry (C
|
192
|
+
uninterpreted_option� (2$.google.protobuf.UninterpretedOption* �����JJJJ J
|
193
|
+
"�
|
194
|
+
FieldOptions:
|
195
|
+
ctype (2#.google.protobuf.FieldOptions.CType:STRING
|
196
|
+
packed (?
|
197
|
+
jstype (2$.google.protobuf.FieldOptions.JSType: JS_NORMAL
|
198
|
+
lazy (:false
|
199
|
+
|
200
|
+
deprecated (:false
|
201
|
+
weak
|
202
|
+
(:falseC
|
203
|
+
uninterpreted_option� (2$.google.protobuf.UninterpretedOption"/
|
204
|
+
CType
|
205
|
+
|
206
|
+
STRING
|
207
|
+
CORD
|
208
|
+
STRING_PIECE"5
|
209
|
+
JSType
|
210
|
+
JS_NORMAL
|
211
|
+
JS_STRING
|
212
|
+
JS_NUMBER* �����J"^
|
213
|
+
OneofOptionsC
|
214
|
+
uninterpreted_option� (2$.google.protobuf.UninterpretedOption* �����"�
|
215
|
+
EnumOptions
|
216
|
+
allow_alias (
|
217
|
+
|
218
|
+
deprecated (:falseC
|
219
|
+
uninterpreted_option� (2$.google.protobuf.UninterpretedOption* �����J"}
|
220
|
+
EnumValueOptions
|
221
|
+
|
222
|
+
deprecated (:falseC
|
223
|
+
uninterpreted_option� (2$.google.protobuf.UninterpretedOption* �����"{
|
224
|
+
ServiceOptions
|
225
|
+
|
226
|
+
deprecated! (:falseC
|
227
|
+
uninterpreted_option� (2$.google.protobuf.UninterpretedOption* �����"�
|
228
|
+
|
229
|
+
|
230
|
+
deprecated! (:false_
|
231
|
+
idempotency_level" (2/.google.protobuf.MethodOptions.IdempotencyLevel:IDEMPOTENCY_UNKNOWNC
|
232
|
+
uninterpreted_option� (2$.google.protobuf.UninterpretedOption"P
|
233
|
+
IdempotencyLevel
|
234
|
+
IDEMPOTENCY_UNKNOWN
|
235
|
+
NO_SIDE_EFFECTS
|
236
|
+
|
237
|
+
IDEMPOTENT* �����"�
|
238
|
+
UninterpretedOption;
|
239
|
+
name (2-.google.protobuf.UninterpretedOption.NamePart
|
240
|
+
identifier_value (
|
241
|
+
positive_int_value (
|
242
|
+
negative_int_value (
|
243
|
+
double_value (
|
244
|
+
string_value (
|
245
|
+
aggregate_value ( 3
|
246
|
+
NamePart
|
247
|
+
name_part (
|
248
|
+
is_extension ("�
|
249
|
+
SourceCodeInfo:
|
250
|
+
location (2(.google.protobuf.SourceCodeInfo.Location�
|
251
|
+
Location
|
252
|
+
path (B
|
253
|
+
span (B
|
254
|
+
leading_comments (
|
255
|
+
trailing_comments ( !
|
256
|
+
leading_detached_comments ( "�
|
257
|
+
GeneratedCodeInfoA
|
258
|
+
|
259
|
+
annotation (2-.google.protobuf.GeneratedCodeInfo.AnnotationO
|
260
|
+
|
261
|
+
Annotation
|
262
|
+
path (B
|
263
|
+
source_file (
|
264
|
+
begin (
|
265
|
+
end (B~
|
266
|
+
com.google.protobufBDescriptorProtosHZ-google.golang.org/protobuf/types/descriptorpb��GPB�Google.Protobuf.Reflection
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
2
|
# source: google/protobuf/type.proto
|
3
3
|
|
4
|
-
require 'google/protobuf'
|
5
|
-
|
6
4
|
require 'google/protobuf/any_pb'
|
7
5
|
require 'google/protobuf/source_context_pb'
|
6
|
+
require 'google/protobuf'
|
7
|
+
|
8
8
|
Google::Protobuf::DescriptorPool.generated_pool.build do
|
9
9
|
add_file("google/protobuf/type.proto", :syntax => :proto3) do
|
10
10
|
add_message "google.protobuf.Type" do
|
data/lib/google/protobuf.rb
CHANGED
@@ -51,75 +51,7 @@ else
|
|
51
51
|
require 'google/protobuf_c'
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
module Protobuf
|
56
|
-
module Internal
|
57
|
-
def self.infer_package(names)
|
58
|
-
# Package is longest common prefix ending in '.', if any.
|
59
|
-
if not names.empty?
|
60
|
-
min, max = names.minmax
|
61
|
-
last_common_dot = nil
|
62
|
-
min.size.times { |i|
|
63
|
-
if min[i] != max[i] then break end
|
64
|
-
if min[i] == ?. then last_common_dot = i end
|
65
|
-
}
|
66
|
-
if last_common_dot
|
67
|
-
return min.slice(0, last_common_dot)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
nil
|
72
|
-
end
|
73
|
-
|
74
|
-
class NestingBuilder
|
75
|
-
def initialize(msg_names, enum_names)
|
76
|
-
@to_pos = {nil=>nil}
|
77
|
-
@msg_children = Hash.new { |hash, key| hash[key] = [] }
|
78
|
-
@enum_children = Hash.new { |hash, key| hash[key] = [] }
|
79
|
-
|
80
|
-
msg_names.each_with_index { |name, idx| @to_pos[name] = idx }
|
81
|
-
enum_names.each_with_index { |name, idx| @to_pos[name] = idx }
|
82
|
-
|
83
|
-
msg_names.each { |name| @msg_children[parent(name)] << name }
|
84
|
-
enum_names.each { |name| @enum_children[parent(name)] << name }
|
85
|
-
end
|
86
|
-
|
87
|
-
def build(package)
|
88
|
-
return build_msg(package)
|
89
|
-
end
|
90
|
-
|
91
|
-
private
|
92
|
-
def build_msg(msg)
|
93
|
-
return {
|
94
|
-
:pos => @to_pos[msg],
|
95
|
-
:msgs => @msg_children[msg].map { |child| build_msg(child) },
|
96
|
-
:enums => @enum_children[msg].map { |child| @to_pos[child] },
|
97
|
-
}
|
98
|
-
end
|
99
|
-
|
100
|
-
private
|
101
|
-
def parent(name)
|
102
|
-
idx = name.rindex(?.)
|
103
|
-
if idx
|
104
|
-
return name.slice(0, idx)
|
105
|
-
else
|
106
|
-
return nil
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def self.fixup_descriptor(package, msg_names, enum_names)
|
112
|
-
if package.nil?
|
113
|
-
package = self.infer_package(msg_names + enum_names)
|
114
|
-
end
|
115
|
-
|
116
|
-
nesting = NestingBuilder.new(msg_names, enum_names).build(package)
|
117
|
-
|
118
|
-
return package, nesting
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
54
|
+
require 'google/protobuf/descriptor_dsl'
|
123
55
|
end
|
124
56
|
|
125
57
|
require 'google/protobuf/repeated_field'
|
data/tests/basic.rb
CHANGED
@@ -31,6 +31,45 @@ module BasicTest
|
|
31
31
|
end
|
32
32
|
include CommonTests
|
33
33
|
|
34
|
+
def test_issue_8311_crash
|
35
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
36
|
+
add_file("inner.proto", :syntax => :proto3) do
|
37
|
+
add_message "Inner" do
|
38
|
+
# Removing either of these fixes the segfault.
|
39
|
+
optional :foo, :string, 1
|
40
|
+
optional :bar, :string, 2
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
46
|
+
add_file("outer.proto", :syntax => :proto3) do
|
47
|
+
add_message "Outer" do
|
48
|
+
repeated :inners, :message, 1, "Inner"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
outer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Outer").msgclass
|
54
|
+
|
55
|
+
outer.new(
|
56
|
+
inners: []
|
57
|
+
)['inners'].to_s
|
58
|
+
|
59
|
+
assert_raise Google::Protobuf::TypeError do
|
60
|
+
outer.new(
|
61
|
+
inners: [nil]
|
62
|
+
).to_s
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_issue_8559_crash
|
67
|
+
msg = TestMessage.new
|
68
|
+
msg.repeated_int32 = ::Google::Protobuf::RepeatedField.new(:int32, [1, 2, 3])
|
69
|
+
GC.start(full_mark: true, immediate_sweep: true)
|
70
|
+
TestMessage.encode(msg)
|
71
|
+
end
|
72
|
+
|
34
73
|
def test_has_field
|
35
74
|
m = TestSingularFields.new
|
36
75
|
assert !m.has_singular_msg?
|
@@ -216,7 +255,7 @@ module BasicTest
|
|
216
255
|
m.map_string_int32 = {}
|
217
256
|
end
|
218
257
|
|
219
|
-
assert_raise TypeError do
|
258
|
+
assert_raise Google::Protobuf::TypeError do
|
220
259
|
m = MapMessage.new(:map_string_int32 => { 1 => "I am not a number" })
|
221
260
|
end
|
222
261
|
end
|
@@ -241,8 +280,12 @@ module BasicTest
|
|
241
280
|
:map_string_msg => {"a" => TestMessage2.new(:foo => 1),
|
242
281
|
"b" => TestMessage2.new(:foo => 2)},
|
243
282
|
:map_string_enum => {"a" => :A, "b" => :B})
|
244
|
-
|
245
|
-
|
283
|
+
|
284
|
+
# JRuby doesn't keep consistent ordering so check for either version
|
285
|
+
expected_a = "<BasicTest::MapMessage: map_string_int32: {\"b\"=>2, \"a\"=>1}, map_string_msg: {\"b\"=><BasicTest::TestMessage2: foo: 2>, \"a\"=><BasicTest::TestMessage2: foo: 1>}, map_string_enum: {\"b\"=>:B, \"a\"=>:A}>"
|
286
|
+
expected_b = "<BasicTest::MapMessage: map_string_int32: {\"a\"=>1, \"b\"=>2}, map_string_msg: {\"a\"=><BasicTest::TestMessage2: foo: 1>, \"b\"=><BasicTest::TestMessage2: foo: 2>}, map_string_enum: {\"a\"=>:A, \"b\"=>:B}>"
|
287
|
+
inspect_result = m.inspect
|
288
|
+
assert expected_a == inspect_result || expected_b == inspect_result, "Incorrect inspect result: #{inspect_result}"
|
246
289
|
end
|
247
290
|
|
248
291
|
def test_map_corruption
|
@@ -443,6 +486,7 @@ module BasicTest
|
|
443
486
|
:optional_int32=>0,
|
444
487
|
:optional_int64=>0,
|
445
488
|
:optional_msg=>nil,
|
489
|
+
:optional_msg2=>nil,
|
446
490
|
:optional_string=>"foo",
|
447
491
|
:optional_uint32=>0,
|
448
492
|
:optional_uint64=>0,
|
@@ -480,9 +524,9 @@ module BasicTest
|
|
480
524
|
m = MapMessage.new(:map_string_int32 => {"a" => 1})
|
481
525
|
expected = {mapStringInt32: {a: 1}, mapStringMsg: {}, mapStringEnum: {}}
|
482
526
|
expected_preserve = {map_string_int32: {a: 1}, map_string_msg: {}, map_string_enum: {}}
|
483
|
-
assert_equal JSON.parse(MapMessage.encode_json(m), :symbolize_names => true), expected
|
527
|
+
assert_equal JSON.parse(MapMessage.encode_json(m, :emit_defaults=>true), :symbolize_names => true), expected
|
484
528
|
|
485
|
-
json = MapMessage.encode_json(m, :preserve_proto_fieldnames => true)
|
529
|
+
json = MapMessage.encode_json(m, :preserve_proto_fieldnames => true, :emit_defaults=>true)
|
486
530
|
assert_equal JSON.parse(json, :symbolize_names => true), expected_preserve
|
487
531
|
|
488
532
|
m2 = MapMessage.decode_json(MapMessage.encode_json(m))
|
@@ -492,7 +536,7 @@ module BasicTest
|
|
492
536
|
def test_json_maps_emit_defaults_submsg
|
493
537
|
# TODO: Fix JSON in JRuby version.
|
494
538
|
return if RUBY_PLATFORM == "java"
|
495
|
-
m = MapMessage.new(:map_string_msg => {"a" => TestMessage2.new})
|
539
|
+
m = MapMessage.new(:map_string_msg => {"a" => TestMessage2.new(foo: 0)})
|
496
540
|
expected = {mapStringInt32: {}, mapStringMsg: {a: {foo: 0}}, mapStringEnum: {}}
|
497
541
|
|
498
542
|
actual = MapMessage.encode_json(m, :emit_defaults => true)
|
@@ -500,6 +544,30 @@ module BasicTest
|
|
500
544
|
assert_equal JSON.parse(actual, :symbolize_names => true), expected
|
501
545
|
end
|
502
546
|
|
547
|
+
def test_json_emit_defaults_submsg
|
548
|
+
# TODO: Fix JSON in JRuby version.
|
549
|
+
return if RUBY_PLATFORM == "java"
|
550
|
+
m = TestSingularFields.new(singular_msg: proto_module::TestMessage2.new)
|
551
|
+
|
552
|
+
expected = {
|
553
|
+
singularInt32: 0,
|
554
|
+
singularInt64: "0",
|
555
|
+
singularUint32: 0,
|
556
|
+
singularUint64: "0",
|
557
|
+
singularBool: false,
|
558
|
+
singularFloat: 0,
|
559
|
+
singularDouble: 0,
|
560
|
+
singularString: "",
|
561
|
+
singularBytes: "",
|
562
|
+
singularMsg: {},
|
563
|
+
singularEnum: "Default",
|
564
|
+
}
|
565
|
+
|
566
|
+
actual = proto_module::TestMessage.encode_json(m, :emit_defaults => true)
|
567
|
+
|
568
|
+
assert_equal expected, JSON.parse(actual, :symbolize_names => true)
|
569
|
+
end
|
570
|
+
|
503
571
|
def test_respond_to
|
504
572
|
# This test fails with JRuby 1.7.23, likely because of an old JRuby bug.
|
505
573
|
return if RUBY_PLATFORM == "java"
|
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.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Protobuf Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler-dock
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0
|
19
|
+
version: 1.1.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '2.0'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.0
|
29
|
+
version: 1.1.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2.0'
|
@@ -85,21 +85,27 @@ extensions:
|
|
85
85
|
- ext/google/protobuf_c/extconf.rb
|
86
86
|
extra_rdoc_files: []
|
87
87
|
files:
|
88
|
+
- ext/google/protobuf_c/convert.c
|
89
|
+
- ext/google/protobuf_c/convert.h
|
88
90
|
- ext/google/protobuf_c/defs.c
|
89
|
-
- ext/google/protobuf_c/
|
91
|
+
- ext/google/protobuf_c/defs.h
|
90
92
|
- ext/google/protobuf_c/extconf.rb
|
91
93
|
- ext/google/protobuf_c/map.c
|
94
|
+
- ext/google/protobuf_c/map.h
|
92
95
|
- ext/google/protobuf_c/message.c
|
96
|
+
- ext/google/protobuf_c/message.h
|
93
97
|
- ext/google/protobuf_c/protobuf.c
|
94
98
|
- ext/google/protobuf_c/protobuf.h
|
95
99
|
- ext/google/protobuf_c/repeated_field.c
|
96
|
-
- ext/google/protobuf_c/
|
97
|
-
- ext/google/protobuf_c/upb.c
|
98
|
-
- ext/google/protobuf_c/upb.h
|
100
|
+
- ext/google/protobuf_c/repeated_field.h
|
101
|
+
- ext/google/protobuf_c/ruby-upb.c
|
102
|
+
- ext/google/protobuf_c/ruby-upb.h
|
99
103
|
- ext/google/protobuf_c/wrap_memcpy.c
|
100
104
|
- lib/google/protobuf.rb
|
101
105
|
- lib/google/protobuf/any_pb.rb
|
102
106
|
- lib/google/protobuf/api_pb.rb
|
107
|
+
- lib/google/protobuf/descriptor_dsl.rb
|
108
|
+
- lib/google/protobuf/descriptor_pb.rb
|
103
109
|
- lib/google/protobuf/duration_pb.rb
|
104
110
|
- lib/google/protobuf/empty_pb.rb
|
105
111
|
- lib/google/protobuf/field_mask_pb.rb
|
@@ -118,7 +124,7 @@ homepage: https://developers.google.com/protocol-buffers
|
|
118
124
|
licenses:
|
119
125
|
- BSD-3-Clause
|
120
126
|
metadata:
|
121
|
-
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.
|
127
|
+
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.18.0/ruby
|
122
128
|
post_install_message:
|
123
129
|
rdoc_options: []
|
124
130
|
require_paths:
|
@@ -134,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
140
|
- !ruby/object:Gem::Version
|
135
141
|
version: '0'
|
136
142
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.2.27
|
138
144
|
signing_key:
|
139
145
|
specification_version: 4
|
140
146
|
summary: Protocol Buffers
|