google-protobuf 3.19.0.rc.1-x86_64-darwin

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.

Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/ext/google/protobuf_c/convert.c +348 -0
  3. data/ext/google/protobuf_c/convert.h +72 -0
  4. data/ext/google/protobuf_c/defs.c +1284 -0
  5. data/ext/google/protobuf_c/defs.h +107 -0
  6. data/ext/google/protobuf_c/extconf.rb +20 -0
  7. data/ext/google/protobuf_c/map.c +694 -0
  8. data/ext/google/protobuf_c/map.h +67 -0
  9. data/ext/google/protobuf_c/message.c +1328 -0
  10. data/ext/google/protobuf_c/message.h +101 -0
  11. data/ext/google/protobuf_c/protobuf.c +470 -0
  12. data/ext/google/protobuf_c/protobuf.h +117 -0
  13. data/ext/google/protobuf_c/repeated_field.c +659 -0
  14. data/ext/google/protobuf_c/repeated_field.h +63 -0
  15. data/ext/google/protobuf_c/ruby-upb.c +9171 -0
  16. data/ext/google/protobuf_c/ruby-upb.h +4704 -0
  17. data/ext/google/protobuf_c/wrap_memcpy.c +51 -0
  18. data/lib/google/2.3/protobuf_c.bundle +0 -0
  19. data/lib/google/2.4/protobuf_c.bundle +0 -0
  20. data/lib/google/2.5/protobuf_c.bundle +0 -0
  21. data/lib/google/2.6/protobuf_c.bundle +0 -0
  22. data/lib/google/2.7/protobuf_c.bundle +0 -0
  23. data/lib/google/3.0/protobuf_c.bundle +0 -0
  24. data/lib/google/protobuf/any_pb.rb +19 -0
  25. data/lib/google/protobuf/api_pb.rb +41 -0
  26. data/lib/google/protobuf/descriptor_dsl.rb +458 -0
  27. data/lib/google/protobuf/descriptor_pb.rb +266 -0
  28. data/lib/google/protobuf/duration_pb.rb +19 -0
  29. data/lib/google/protobuf/empty_pb.rb +17 -0
  30. data/lib/google/protobuf/field_mask_pb.rb +18 -0
  31. data/lib/google/protobuf/message_exts.rb +53 -0
  32. data/lib/google/protobuf/repeated_field.rb +188 -0
  33. data/lib/google/protobuf/source_context_pb.rb +18 -0
  34. data/lib/google/protobuf/struct_pb.rb +37 -0
  35. data/lib/google/protobuf/timestamp_pb.rb +19 -0
  36. data/lib/google/protobuf/type_pb.rb +91 -0
  37. data/lib/google/protobuf/well_known_types.rb +235 -0
  38. data/lib/google/protobuf/wrappers_pb.rb +50 -0
  39. data/lib/google/protobuf.rb +79 -0
  40. data/tests/basic.rb +640 -0
  41. data/tests/generated_code_test.rb +23 -0
  42. data/tests/stress.rb +38 -0
  43. metadata +144 -0
@@ -0,0 +1,91 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/protobuf/type.proto
3
+
4
+ require 'google/protobuf/any_pb'
5
+ require 'google/protobuf/source_context_pb'
6
+ require 'google/protobuf'
7
+
8
+ Google::Protobuf::DescriptorPool.generated_pool.build do
9
+ add_file("google/protobuf/type.proto", :syntax => :proto3) do
10
+ add_message "google.protobuf.Type" do
11
+ optional :name, :string, 1
12
+ repeated :fields, :message, 2, "google.protobuf.Field"
13
+ repeated :oneofs, :string, 3
14
+ repeated :options, :message, 4, "google.protobuf.Option"
15
+ optional :source_context, :message, 5, "google.protobuf.SourceContext"
16
+ optional :syntax, :enum, 6, "google.protobuf.Syntax"
17
+ end
18
+ add_message "google.protobuf.Field" do
19
+ optional :kind, :enum, 1, "google.protobuf.Field.Kind"
20
+ optional :cardinality, :enum, 2, "google.protobuf.Field.Cardinality"
21
+ optional :number, :int32, 3
22
+ optional :name, :string, 4
23
+ optional :type_url, :string, 6
24
+ optional :oneof_index, :int32, 7
25
+ optional :packed, :bool, 8
26
+ repeated :options, :message, 9, "google.protobuf.Option"
27
+ optional :json_name, :string, 10
28
+ optional :default_value, :string, 11
29
+ end
30
+ add_enum "google.protobuf.Field.Kind" do
31
+ value :TYPE_UNKNOWN, 0
32
+ value :TYPE_DOUBLE, 1
33
+ value :TYPE_FLOAT, 2
34
+ value :TYPE_INT64, 3
35
+ value :TYPE_UINT64, 4
36
+ value :TYPE_INT32, 5
37
+ value :TYPE_FIXED64, 6
38
+ value :TYPE_FIXED32, 7
39
+ value :TYPE_BOOL, 8
40
+ value :TYPE_STRING, 9
41
+ value :TYPE_GROUP, 10
42
+ value :TYPE_MESSAGE, 11
43
+ value :TYPE_BYTES, 12
44
+ value :TYPE_UINT32, 13
45
+ value :TYPE_ENUM, 14
46
+ value :TYPE_SFIXED32, 15
47
+ value :TYPE_SFIXED64, 16
48
+ value :TYPE_SINT32, 17
49
+ value :TYPE_SINT64, 18
50
+ end
51
+ add_enum "google.protobuf.Field.Cardinality" do
52
+ value :CARDINALITY_UNKNOWN, 0
53
+ value :CARDINALITY_OPTIONAL, 1
54
+ value :CARDINALITY_REQUIRED, 2
55
+ value :CARDINALITY_REPEATED, 3
56
+ end
57
+ add_message "google.protobuf.Enum" do
58
+ optional :name, :string, 1
59
+ repeated :enumvalue, :message, 2, "google.protobuf.EnumValue"
60
+ repeated :options, :message, 3, "google.protobuf.Option"
61
+ optional :source_context, :message, 4, "google.protobuf.SourceContext"
62
+ optional :syntax, :enum, 5, "google.protobuf.Syntax"
63
+ end
64
+ add_message "google.protobuf.EnumValue" do
65
+ optional :name, :string, 1
66
+ optional :number, :int32, 2
67
+ repeated :options, :message, 3, "google.protobuf.Option"
68
+ end
69
+ add_message "google.protobuf.Option" do
70
+ optional :name, :string, 1
71
+ optional :value, :message, 2, "google.protobuf.Any"
72
+ end
73
+ add_enum "google.protobuf.Syntax" do
74
+ value :SYNTAX_PROTO2, 0
75
+ value :SYNTAX_PROTO3, 1
76
+ end
77
+ end
78
+ end
79
+
80
+ module Google
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
90
+ end
91
+ end
@@ -0,0 +1,235 @@
1
+ #!/usr/bin/ruby
2
+ # Protocol Buffers - Google's data interchange format
3
+ # Copyright 2008 Google Inc. All rights reserved.
4
+ # https://developers.google.com/protocol-buffers/
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are
8
+ # met:
9
+ #
10
+ # * Redistributions of source code must retain the above copyright
11
+ # notice, this list of conditions and the following disclaimer.
12
+ # * Redistributions in binary form must reproduce the above
13
+ # copyright notice, this list of conditions and the following disclaimer
14
+ # in the documentation and/or other materials provided with the
15
+ # distribution.
16
+ # * Neither the name of Google Inc. nor the names of its
17
+ # contributors may be used to endorse or promote products derived from
18
+ # this software without specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+
32
+ require 'google/protobuf/any_pb'
33
+ require 'google/protobuf/duration_pb'
34
+ require 'google/protobuf/field_mask_pb'
35
+ require 'google/protobuf/struct_pb'
36
+ require 'google/protobuf/timestamp_pb'
37
+
38
+ module Google
39
+ module Protobuf
40
+
41
+ Any.class_eval do
42
+ def self.pack(msg, type_url_prefix='type.googleapis.com/')
43
+ any = self.new
44
+ any.pack(msg, type_url_prefix)
45
+ any
46
+ end
47
+
48
+ def pack(msg, type_url_prefix='type.googleapis.com/')
49
+ if type_url_prefix.empty? or type_url_prefix[-1] != '/' then
50
+ self.type_url = "#{type_url_prefix}/#{msg.class.descriptor.name}"
51
+ else
52
+ self.type_url = "#{type_url_prefix}#{msg.class.descriptor.name}"
53
+ end
54
+ self.value = msg.to_proto
55
+ end
56
+
57
+ def unpack(klass)
58
+ if self.is(klass) then
59
+ klass.decode(self.value)
60
+ else
61
+ nil
62
+ end
63
+ end
64
+
65
+ def type_name
66
+ return self.type_url.split("/")[-1]
67
+ end
68
+
69
+ def is(klass)
70
+ return self.type_name == klass.descriptor.name
71
+ end
72
+ end
73
+
74
+ Timestamp.class_eval do
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
83
+ end
84
+
85
+ def from_time(time)
86
+ self.seconds = time.to_i
87
+ self.nanos = time.nsec
88
+ self
89
+ end
90
+
91
+ def self.from_time(time)
92
+ new.from_time(time)
93
+ end
94
+
95
+ def to_i
96
+ self.seconds
97
+ end
98
+
99
+ def to_f
100
+ self.seconds + (self.nanos.quo(1_000_000_000))
101
+ end
102
+ end
103
+
104
+ Duration.class_eval do
105
+ def to_f
106
+ self.seconds + (self.nanos.to_f / 1_000_000_000)
107
+ end
108
+ end
109
+
110
+ class UnexpectedStructType < Google::Protobuf::Error; end
111
+
112
+ Value.class_eval do
113
+ def to_ruby(recursive = false)
114
+ case self.kind
115
+ when :struct_value
116
+ if recursive
117
+ self.struct_value.to_h
118
+ else
119
+ self.struct_value
120
+ end
121
+ when :list_value
122
+ if recursive
123
+ self.list_value.to_a
124
+ else
125
+ self.list_value
126
+ end
127
+ when :null_value
128
+ nil
129
+ when :number_value
130
+ self.number_value
131
+ when :string_value
132
+ self.string_value
133
+ when :bool_value
134
+ self.bool_value
135
+ else
136
+ raise UnexpectedStructType
137
+ end
138
+ end
139
+
140
+ def from_ruby(value)
141
+ case value
142
+ when NilClass
143
+ self.null_value = 0
144
+ when Numeric
145
+ self.number_value = value
146
+ when String
147
+ self.string_value = value
148
+ when TrueClass
149
+ self.bool_value = true
150
+ when FalseClass
151
+ self.bool_value = false
152
+ when Struct
153
+ self.struct_value = value
154
+ when Hash
155
+ self.struct_value = Struct.from_hash(value)
156
+ when ListValue
157
+ self.list_value = value
158
+ when Array
159
+ self.list_value = ListValue.from_a(value)
160
+ else
161
+ raise UnexpectedStructType
162
+ end
163
+ end
164
+ end
165
+
166
+ Struct.class_eval do
167
+ def [](key)
168
+ self.fields[key].to_ruby
169
+ rescue NoMethodError
170
+ nil
171
+ end
172
+
173
+ def []=(key, value)
174
+ unless key.is_a?(String)
175
+ raise UnexpectedStructType, "Struct keys must be strings."
176
+ end
177
+ self.fields[key] ||= Google::Protobuf::Value.new
178
+ self.fields[key].from_ruby(value)
179
+ end
180
+
181
+ def to_h
182
+ ret = {}
183
+ self.fields.each { |key, val| ret[key] = val.to_ruby(true) }
184
+ ret
185
+ end
186
+
187
+ def self.from_hash(hash)
188
+ ret = Struct.new
189
+ hash.each { |key, val| ret[key] = val }
190
+ ret
191
+ end
192
+
193
+ def has_key?(key)
194
+ self.fields.has_key?(key)
195
+ end
196
+ end
197
+
198
+ ListValue.class_eval do
199
+ include Enumerable
200
+
201
+ def length
202
+ self.values.length
203
+ end
204
+
205
+ def [](index)
206
+ self.values[index].to_ruby
207
+ end
208
+
209
+ def []=(index, value)
210
+ self.values[index].from_ruby(value)
211
+ end
212
+
213
+ def <<(value)
214
+ wrapper = Google::Protobuf::Value.new
215
+ wrapper.from_ruby(value)
216
+ self.values << wrapper
217
+ end
218
+
219
+ def each
220
+ self.values.each { |x| yield(x.to_ruby) }
221
+ end
222
+
223
+ def to_a
224
+ self.values.map { |x| x.to_ruby(true) }
225
+ end
226
+
227
+ def self.from_a(arr)
228
+ ret = ListValue.new
229
+ arr.each { |val| ret << val }
230
+ ret
231
+ end
232
+ end
233
+
234
+ end
235
+ end
@@ -0,0 +1,50 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/protobuf/wrappers.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ add_file("google/protobuf/wrappers.proto", :syntax => :proto3) do
8
+ add_message "google.protobuf.DoubleValue" do
9
+ optional :value, :double, 1
10
+ end
11
+ add_message "google.protobuf.FloatValue" do
12
+ optional :value, :float, 1
13
+ end
14
+ add_message "google.protobuf.Int64Value" do
15
+ optional :value, :int64, 1
16
+ end
17
+ add_message "google.protobuf.UInt64Value" do
18
+ optional :value, :uint64, 1
19
+ end
20
+ add_message "google.protobuf.Int32Value" do
21
+ optional :value, :int32, 1
22
+ end
23
+ add_message "google.protobuf.UInt32Value" do
24
+ optional :value, :uint32, 1
25
+ end
26
+ add_message "google.protobuf.BoolValue" do
27
+ optional :value, :bool, 1
28
+ end
29
+ add_message "google.protobuf.StringValue" do
30
+ optional :value, :string, 1
31
+ end
32
+ add_message "google.protobuf.BytesValue" do
33
+ optional :value, :bytes, 1
34
+ end
35
+ end
36
+ end
37
+
38
+ module Google
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
49
+ end
50
+ end
@@ -0,0 +1,79 @@
1
+ # Protocol Buffers - Google's data interchange format
2
+ # Copyright 2008 Google Inc. All rights reserved.
3
+ # https://developers.google.com/protocol-buffers/
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are
7
+ # met:
8
+ #
9
+ # * Redistributions of source code must retain the above copyright
10
+ # notice, this list of conditions and the following disclaimer.
11
+ # * Redistributions in binary form must reproduce the above
12
+ # copyright notice, this list of conditions and the following disclaimer
13
+ # in the documentation and/or other materials provided with the
14
+ # distribution.
15
+ # * Neither the name of Google Inc. nor the names of its
16
+ # contributors may be used to endorse or promote products derived from
17
+ # this software without specific prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ # require mixins before we hook them into the java & c code
32
+ require 'google/protobuf/message_exts'
33
+
34
+ # We define these before requiring the platform-specific modules.
35
+ # That way the module init can grab references to these.
36
+ module Google
37
+ module Protobuf
38
+ class Error < StandardError; end
39
+ class ParseError < Error; end
40
+ class TypeError < ::TypeError; end
41
+ end
42
+ end
43
+
44
+ if RUBY_PLATFORM == "java"
45
+ require 'json'
46
+ require 'google/protobuf_java'
47
+ else
48
+ begin
49
+ require "google/#{RUBY_VERSION.sub(/\.\d+$/, '')}/protobuf_c"
50
+ rescue LoadError
51
+ require 'google/protobuf_c'
52
+ end
53
+
54
+ end
55
+
56
+ require 'google/protobuf/descriptor_dsl'
57
+ require 'google/protobuf/repeated_field'
58
+
59
+ module Google
60
+ module Protobuf
61
+
62
+ def self.encode(msg)
63
+ msg.to_proto
64
+ end
65
+
66
+ def self.encode_json(msg, options = {})
67
+ msg.to_json(options)
68
+ end
69
+
70
+ def self.decode(klass, proto)
71
+ klass.decode(proto)
72
+ end
73
+
74
+ def self.decode_json(klass, json, options = {})
75
+ klass.decode_json(json, options)
76
+ end
77
+
78
+ end
79
+ end