google-protobuf 3.9.2 → 3.10.0.rc.1
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/defs.c +851 -830
- data/ext/google/protobuf_c/encode_decode.c +219 -285
- data/ext/google/protobuf_c/extconf.rb +2 -4
- data/ext/google/protobuf_c/map.c +15 -9
- data/ext/google/protobuf_c/message.c +84 -91
- data/ext/google/protobuf_c/protobuf.c +30 -15
- data/ext/google/protobuf_c/protobuf.h +100 -54
- data/ext/google/protobuf_c/repeated_field.c +44 -19
- data/ext/google/protobuf_c/storage.c +219 -153
- data/ext/google/protobuf_c/upb.c +4516 -8706
- data/ext/google/protobuf_c/upb.h +4920 -8476
- data/lib/google/protobuf.rb +66 -0
- data/lib/google/protobuf/any_pb.rb +1 -1
- data/lib/google/protobuf/api_pb.rb +3 -3
- data/lib/google/protobuf/duration_pb.rb +1 -1
- data/lib/google/protobuf/empty_pb.rb +1 -1
- data/lib/google/protobuf/field_mask_pb.rb +1 -1
- data/lib/google/protobuf/source_context_pb.rb +1 -1
- data/lib/google/protobuf/struct_pb.rb +4 -4
- data/lib/google/protobuf/timestamp_pb.rb +1 -1
- data/lib/google/protobuf/type_pb.rb +8 -8
- data/lib/google/protobuf/well_known_types.rb +8 -2
- data/lib/google/protobuf/wrappers_pb.rb +9 -9
- data/tests/basic.rb +22 -6
- metadata +6 -5
data/lib/google/protobuf.rb
CHANGED
@@ -50,6 +50,72 @@ else
|
|
50
50
|
rescue LoadError
|
51
51
|
require 'google/protobuf_c'
|
52
52
|
end
|
53
|
+
|
54
|
+
module Google
|
55
|
+
module Protobuf
|
56
|
+
module Internal
|
57
|
+
def self.infer_package(names)
|
58
|
+
# Package is longest common prefix ending in '.', if any.
|
59
|
+
min, max = names.minmax
|
60
|
+
last_common_dot = nil
|
61
|
+
min.size.times { |i|
|
62
|
+
if min[i] != max[i] then break end
|
63
|
+
if min[i] == ?. then last_common_dot = i end
|
64
|
+
}
|
65
|
+
if last_common_dot
|
66
|
+
return min.slice(0, last_common_dot)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class NestingBuilder
|
71
|
+
def initialize(msg_names, enum_names)
|
72
|
+
@to_pos = {nil=>nil}
|
73
|
+
@msg_children = Hash.new { |hash, key| hash[key] = [] }
|
74
|
+
@enum_children = Hash.new { |hash, key| hash[key] = [] }
|
75
|
+
|
76
|
+
msg_names.each_with_index { |name, idx| @to_pos[name] = idx }
|
77
|
+
enum_names.each_with_index { |name, idx| @to_pos[name] = idx }
|
78
|
+
|
79
|
+
msg_names.each { |name| @msg_children[parent(name)] << name }
|
80
|
+
enum_names.each { |name| @enum_children[parent(name)] << name }
|
81
|
+
end
|
82
|
+
|
83
|
+
def build(package)
|
84
|
+
return build_msg(package)
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
def build_msg(msg)
|
89
|
+
return {
|
90
|
+
:pos => @to_pos[msg],
|
91
|
+
:msgs => @msg_children[msg].map { |child| build_msg(child) },
|
92
|
+
:enums => @enum_children[msg].map { |child| @to_pos[child] },
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
def parent(name)
|
98
|
+
idx = name.rindex(?.)
|
99
|
+
if idx
|
100
|
+
return name.slice(0, idx)
|
101
|
+
else
|
102
|
+
return nil
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.fixup_descriptor(package, msg_names, enum_names)
|
108
|
+
if package.nil?
|
109
|
+
package = self.infer_package(msg_names + enum_names)
|
110
|
+
end
|
111
|
+
|
112
|
+
nesting = NestingBuilder.new(msg_names, enum_names).build(package)
|
113
|
+
|
114
|
+
return package, nesting
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
53
119
|
end
|
54
120
|
|
55
121
|
require 'google/protobuf/repeated_field'
|
@@ -34,8 +34,8 @@ end
|
|
34
34
|
|
35
35
|
module Google
|
36
36
|
module Protobuf
|
37
|
-
Api = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Api").msgclass
|
38
|
-
Method = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Method").msgclass
|
39
|
-
Mixin = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Mixin").msgclass
|
37
|
+
Api = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Api").msgclass
|
38
|
+
Method = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Method").msgclass
|
39
|
+
Mixin = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Mixin").msgclass
|
40
40
|
end
|
41
41
|
end
|
@@ -14,6 +14,6 @@ end
|
|
14
14
|
|
15
15
|
module Google
|
16
16
|
module Protobuf
|
17
|
-
Duration = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Duration").msgclass
|
17
|
+
Duration = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Duration").msgclass
|
18
18
|
end
|
19
19
|
end
|
@@ -13,6 +13,6 @@ end
|
|
13
13
|
|
14
14
|
module Google
|
15
15
|
module Protobuf
|
16
|
-
FieldMask = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldMask").msgclass
|
16
|
+
FieldMask = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldMask").msgclass
|
17
17
|
end
|
18
18
|
end
|
@@ -13,6 +13,6 @@ end
|
|
13
13
|
|
14
14
|
module Google
|
15
15
|
module Protobuf
|
16
|
-
SourceContext = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.SourceContext").msgclass
|
16
|
+
SourceContext = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.SourceContext").msgclass
|
17
17
|
end
|
18
18
|
end
|
@@ -29,9 +29,9 @@ end
|
|
29
29
|
|
30
30
|
module Google
|
31
31
|
module Protobuf
|
32
|
-
Struct = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Struct").msgclass
|
33
|
-
Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Value").msgclass
|
34
|
-
ListValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ListValue").msgclass
|
35
|
-
NullValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.NullValue").enummodule
|
32
|
+
Struct = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Struct").msgclass
|
33
|
+
Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Value").msgclass
|
34
|
+
ListValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ListValue").msgclass
|
35
|
+
NullValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.NullValue").enummodule
|
36
36
|
end
|
37
37
|
end
|
@@ -14,6 +14,6 @@ end
|
|
14
14
|
|
15
15
|
module Google
|
16
16
|
module Protobuf
|
17
|
-
Timestamp = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Timestamp").msgclass
|
17
|
+
Timestamp = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Timestamp").msgclass
|
18
18
|
end
|
19
19
|
end
|
@@ -79,13 +79,13 @@ end
|
|
79
79
|
|
80
80
|
module Google
|
81
81
|
module Protobuf
|
82
|
-
Type = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Type").msgclass
|
83
|
-
Field = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field").msgclass
|
84
|
-
Field::Kind = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field.Kind").enummodule
|
85
|
-
Field::Cardinality = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field.Cardinality").enummodule
|
86
|
-
Enum = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Enum").msgclass
|
87
|
-
EnumValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumValue").msgclass
|
88
|
-
Option = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Option").msgclass
|
89
|
-
Syntax = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Syntax").enummodule
|
82
|
+
Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Type").msgclass
|
83
|
+
Field = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field").msgclass
|
84
|
+
Field::Kind = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field.Kind").enummodule
|
85
|
+
Field::Cardinality = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field.Cardinality").enummodule
|
86
|
+
Enum = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Enum").msgclass
|
87
|
+
EnumValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumValue").msgclass
|
88
|
+
Option = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Option").msgclass
|
89
|
+
Syntax = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Syntax").enummodule
|
90
90
|
end
|
91
91
|
end
|
@@ -72,8 +72,14 @@ module Google
|
|
72
72
|
end
|
73
73
|
|
74
74
|
Timestamp.class_eval do
|
75
|
-
|
76
|
-
|
75
|
+
if RUBY_VERSION < "2.5"
|
76
|
+
def to_time
|
77
|
+
Time.at(self.to_f)
|
78
|
+
end
|
79
|
+
else
|
80
|
+
def to_time
|
81
|
+
Time.at(seconds, nanos, :nanosecond)
|
82
|
+
end
|
77
83
|
end
|
78
84
|
|
79
85
|
def from_time(time)
|
@@ -37,14 +37,14 @@ end
|
|
37
37
|
|
38
38
|
module Google
|
39
39
|
module Protobuf
|
40
|
-
DoubleValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DoubleValue").msgclass
|
41
|
-
FloatValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FloatValue").msgclass
|
42
|
-
Int64Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int64Value").msgclass
|
43
|
-
UInt64Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt64Value").msgclass
|
44
|
-
Int32Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int32Value").msgclass
|
45
|
-
UInt32Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt32Value").msgclass
|
46
|
-
BoolValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BoolValue").msgclass
|
47
|
-
StringValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.StringValue").msgclass
|
48
|
-
BytesValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BytesValue").msgclass
|
40
|
+
DoubleValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DoubleValue").msgclass
|
41
|
+
FloatValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FloatValue").msgclass
|
42
|
+
Int64Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int64Value").msgclass
|
43
|
+
UInt64Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt64Value").msgclass
|
44
|
+
Int32Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int32Value").msgclass
|
45
|
+
UInt32Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt32Value").msgclass
|
46
|
+
BoolValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BoolValue").msgclass
|
47
|
+
StringValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.StringValue").msgclass
|
48
|
+
BytesValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BytesValue").msgclass
|
49
49
|
end
|
50
50
|
end
|
data/tests/basic.rb
CHANGED
@@ -17,7 +17,6 @@ module BasicTest
|
|
17
17
|
add_message "BadFieldNames" do
|
18
18
|
optional :dup, :int32, 1
|
19
19
|
optional :class, :int32, 2
|
20
|
-
optional :"a.b", :int32, 3
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
@@ -204,6 +203,20 @@ module BasicTest
|
|
204
203
|
end
|
205
204
|
end
|
206
205
|
|
206
|
+
def test_map_field_with_symbol
|
207
|
+
m = MapMessage.new
|
208
|
+
assert m.map_string_int32 == {}
|
209
|
+
assert m.map_string_msg == {}
|
210
|
+
|
211
|
+
m = MapMessage.new(
|
212
|
+
:map_string_int32 => {a: 1, "b" => 2},
|
213
|
+
:map_string_msg => {a: TestMessage2.new(:foo => 1),
|
214
|
+
b: TestMessage2.new(:foo => 10)})
|
215
|
+
assert_equal 1, m.map_string_int32[:a]
|
216
|
+
assert_equal 2, m.map_string_int32[:b]
|
217
|
+
assert_equal 10, m.map_string_msg[:b].foo
|
218
|
+
end
|
219
|
+
|
207
220
|
def test_map_inspect
|
208
221
|
m = MapMessage.new(
|
209
222
|
:map_string_int32 => {"a" => 1, "b" => 2},
|
@@ -271,6 +284,14 @@ module BasicTest
|
|
271
284
|
assert_match(/No such field: not_in_message/, e.message)
|
272
285
|
end
|
273
286
|
|
287
|
+
#def test_json_quoted_string
|
288
|
+
# m = TestMessage.decode_json(%q(
|
289
|
+
# "optionalInt64": "1",,
|
290
|
+
# }))
|
291
|
+
# puts(m)
|
292
|
+
# assert_equal 1, m.optional_int32
|
293
|
+
#end
|
294
|
+
|
274
295
|
def test_to_h
|
275
296
|
m = TestMessage.new(:optional_bool => true, :optional_double => -10.100001, :optional_string => 'foo', :repeated_string => ['bar1', 'bar2'], :repeated_msg => [TestMessage2.new(:foo => 100)])
|
276
297
|
expected_result = {
|
@@ -357,11 +378,6 @@ module BasicTest
|
|
357
378
|
assert nil != file_descriptor
|
358
379
|
assert_equal "tests/basic_test.proto", file_descriptor.name
|
359
380
|
assert_equal :proto3, file_descriptor.syntax
|
360
|
-
|
361
|
-
file_descriptor = BadFieldNames.descriptor.file_descriptor
|
362
|
-
assert nil != file_descriptor
|
363
|
-
assert_equal nil, file_descriptor.name
|
364
|
-
assert_equal :proto3, file_descriptor.syntax
|
365
381
|
end
|
366
382
|
|
367
383
|
# Ruby 2.5 changed to raise FrozenError instead of RuntimeError
|
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.10.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-09-
|
11
|
+
date: 2019-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler-dock
|
@@ -111,7 +111,8 @@ files:
|
|
111
111
|
homepage: https://developers.google.com/protocol-buffers
|
112
112
|
licenses:
|
113
113
|
- BSD-3-Clause
|
114
|
-
metadata:
|
114
|
+
metadata:
|
115
|
+
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.10.0-rc1/ruby
|
115
116
|
post_install_message:
|
116
117
|
rdoc_options: []
|
117
118
|
require_paths:
|
@@ -123,9 +124,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
124
|
version: '2.3'
|
124
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
126
|
requirements:
|
126
|
-
- - "
|
127
|
+
- - ">"
|
127
128
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
129
|
+
version: 1.3.1
|
129
130
|
requirements: []
|
130
131
|
rubygems_version: 3.0.6
|
131
132
|
signing_key:
|