google-protobuf 3.7.0 → 3.12.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/defs.c +942 -833
- data/ext/google/protobuf_c/encode_decode.c +521 -300
- data/ext/google/protobuf_c/extconf.rb +2 -4
- data/ext/google/protobuf_c/map.c +41 -54
- data/ext/google/protobuf_c/message.c +212 -86
- data/ext/google/protobuf_c/protobuf.c +30 -15
- data/ext/google/protobuf_c/protobuf.h +114 -60
- data/ext/google/protobuf_c/repeated_field.c +55 -23
- data/ext/google/protobuf_c/storage.c +350 -171
- data/ext/google/protobuf_c/upb.c +5630 -9131
- data/ext/google/protobuf_c/upb.h +4590 -7568
- 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/lib/google/protobuf.rb +70 -0
- data/tests/basic.rb +250 -68
- data/tests/generated_code_test.rb +0 -0
- data/tests/stress.rb +0 -0
- metadata +18 -12
@@ -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/lib/google/protobuf.rb
CHANGED
@@ -50,6 +50,76 @@ 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
|
+
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
|
53
123
|
end
|
54
124
|
|
55
125
|
require 'google/protobuf/repeated_field'
|