google-protobuf 3.21.0.rc.2-x64-mingw-ucrt

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 +361 -0
  3. data/ext/google/protobuf_c/convert.h +75 -0
  4. data/ext/google/protobuf_c/defs.c +1280 -0
  5. data/ext/google/protobuf_c/defs.h +107 -0
  6. data/ext/google/protobuf_c/extconf.rb +28 -0
  7. data/ext/google/protobuf_c/map.c +702 -0
  8. data/ext/google/protobuf_c/map.h +66 -0
  9. data/ext/google/protobuf_c/message.c +1402 -0
  10. data/ext/google/protobuf_c/message.h +104 -0
  11. data/ext/google/protobuf_c/protobuf.c +480 -0
  12. data/ext/google/protobuf_c/protobuf.h +120 -0
  13. data/ext/google/protobuf_c/repeated_field.c +657 -0
  14. data/ext/google/protobuf_c/repeated_field.h +63 -0
  15. data/ext/google/protobuf_c/ruby-upb.c +11115 -0
  16. data/ext/google/protobuf_c/ruby-upb.h +5612 -0
  17. data/ext/google/protobuf_c/third_party/utf8_range/LICENSE +21 -0
  18. data/ext/google/protobuf_c/third_party/utf8_range/naive.c +92 -0
  19. data/ext/google/protobuf_c/third_party/utf8_range/range2-neon.c +157 -0
  20. data/ext/google/protobuf_c/third_party/utf8_range/range2-sse.c +170 -0
  21. data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +9 -0
  22. data/ext/google/protobuf_c/wrap_memcpy.c +52 -0
  23. data/lib/google/3.1/protobuf_c.so +0 -0
  24. data/lib/google/protobuf/any_pb.rb +19 -0
  25. data/lib/google/protobuf/api_pb.rb +42 -0
  26. data/lib/google/protobuf/descriptor_dsl.rb +465 -0
  27. data/lib/google/protobuf/descriptor_pb.rb +269 -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 +201 -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 +92 -0
  37. data/lib/google/protobuf/well_known_types.rb +240 -0
  38. data/lib/google/protobuf/wrappers_pb.rb +50 -0
  39. data/lib/google/protobuf.rb +79 -0
  40. data/tests/basic.rb +739 -0
  41. data/tests/generated_code_test.rb +23 -0
  42. data/tests/stress.rb +38 -0
  43. metadata +138 -0
@@ -0,0 +1,92 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/protobuf/type.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/protobuf/any_pb'
7
+ require 'google/protobuf/source_context_pb'
8
+
9
+ Google::Protobuf::DescriptorPool.generated_pool.build do
10
+ add_file("google/protobuf/type.proto", :syntax => :proto3) do
11
+ add_message "google.protobuf.Type" do
12
+ optional :name, :string, 1
13
+ repeated :fields, :message, 2, "google.protobuf.Field"
14
+ repeated :oneofs, :string, 3
15
+ repeated :options, :message, 4, "google.protobuf.Option"
16
+ optional :source_context, :message, 5, "google.protobuf.SourceContext"
17
+ optional :syntax, :enum, 6, "google.protobuf.Syntax"
18
+ end
19
+ add_message "google.protobuf.Field" do
20
+ optional :kind, :enum, 1, "google.protobuf.Field.Kind"
21
+ optional :cardinality, :enum, 2, "google.protobuf.Field.Cardinality"
22
+ optional :number, :int32, 3
23
+ optional :name, :string, 4
24
+ optional :type_url, :string, 6
25
+ optional :oneof_index, :int32, 7
26
+ optional :packed, :bool, 8
27
+ repeated :options, :message, 9, "google.protobuf.Option"
28
+ optional :json_name, :string, 10
29
+ optional :default_value, :string, 11
30
+ end
31
+ add_enum "google.protobuf.Field.Kind" do
32
+ value :TYPE_UNKNOWN, 0
33
+ value :TYPE_DOUBLE, 1
34
+ value :TYPE_FLOAT, 2
35
+ value :TYPE_INT64, 3
36
+ value :TYPE_UINT64, 4
37
+ value :TYPE_INT32, 5
38
+ value :TYPE_FIXED64, 6
39
+ value :TYPE_FIXED32, 7
40
+ value :TYPE_BOOL, 8
41
+ value :TYPE_STRING, 9
42
+ value :TYPE_GROUP, 10
43
+ value :TYPE_MESSAGE, 11
44
+ value :TYPE_BYTES, 12
45
+ value :TYPE_UINT32, 13
46
+ value :TYPE_ENUM, 14
47
+ value :TYPE_SFIXED32, 15
48
+ value :TYPE_SFIXED64, 16
49
+ value :TYPE_SINT32, 17
50
+ value :TYPE_SINT64, 18
51
+ end
52
+ add_enum "google.protobuf.Field.Cardinality" do
53
+ value :CARDINALITY_UNKNOWN, 0
54
+ value :CARDINALITY_OPTIONAL, 1
55
+ value :CARDINALITY_REQUIRED, 2
56
+ value :CARDINALITY_REPEATED, 3
57
+ end
58
+ add_message "google.protobuf.Enum" do
59
+ optional :name, :string, 1
60
+ repeated :enumvalue, :message, 2, "google.protobuf.EnumValue"
61
+ repeated :options, :message, 3, "google.protobuf.Option"
62
+ optional :source_context, :message, 4, "google.protobuf.SourceContext"
63
+ optional :syntax, :enum, 5, "google.protobuf.Syntax"
64
+ end
65
+ add_message "google.protobuf.EnumValue" do
66
+ optional :name, :string, 1
67
+ optional :number, :int32, 2
68
+ repeated :options, :message, 3, "google.protobuf.Option"
69
+ end
70
+ add_message "google.protobuf.Option" do
71
+ optional :name, :string, 1
72
+ optional :value, :message, 2, "google.protobuf.Any"
73
+ end
74
+ add_enum "google.protobuf.Syntax" do
75
+ value :SYNTAX_PROTO2, 0
76
+ value :SYNTAX_PROTO3, 1
77
+ end
78
+ end
79
+ end
80
+
81
+ module Google
82
+ module Protobuf
83
+ Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Type").msgclass
84
+ Field = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field").msgclass
85
+ Field::Kind = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field.Kind").enummodule
86
+ Field::Cardinality = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field.Cardinality").enummodule
87
+ Enum = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Enum").msgclass
88
+ EnumValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumValue").msgclass
89
+ Option = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Option").msgclass
90
+ Syntax = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Syntax").enummodule
91
+ end
92
+ end
@@ -0,0 +1,240 @@
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 self.from_time(time)
86
+ new.from_time(time)
87
+ end
88
+
89
+ def from_time(time)
90
+ self.seconds = time.to_i
91
+ self.nanos = time.nsec
92
+ self
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 self.from_ruby(value)
141
+ self.new.from_ruby(value)
142
+ end
143
+
144
+ def from_ruby(value)
145
+ case value
146
+ when NilClass
147
+ self.null_value = :NULL_VALUE
148
+ when Numeric
149
+ self.number_value = value
150
+ when String
151
+ self.string_value = value
152
+ when TrueClass
153
+ self.bool_value = true
154
+ when FalseClass
155
+ self.bool_value = false
156
+ when Struct
157
+ self.struct_value = value
158
+ when Hash
159
+ self.struct_value = Struct.from_hash(value)
160
+ when ListValue
161
+ self.list_value = value
162
+ when Array
163
+ self.list_value = ListValue.from_a(value)
164
+ else
165
+ raise UnexpectedStructType
166
+ end
167
+
168
+ self
169
+ end
170
+ end
171
+
172
+ Struct.class_eval do
173
+ def [](key)
174
+ self.fields[key].to_ruby
175
+ rescue NoMethodError
176
+ nil
177
+ end
178
+
179
+ def []=(key, value)
180
+ unless key.is_a?(String)
181
+ raise UnexpectedStructType, "Struct keys must be strings."
182
+ end
183
+ self.fields[key] ||= Google::Protobuf::Value.new
184
+ self.fields[key].from_ruby(value)
185
+ end
186
+
187
+ def to_h
188
+ ret = {}
189
+ self.fields.each { |key, val| ret[key] = val.to_ruby(true) }
190
+ ret
191
+ end
192
+
193
+ def self.from_hash(hash)
194
+ ret = Struct.new
195
+ hash.each { |key, val| ret[key] = val }
196
+ ret
197
+ end
198
+
199
+ def has_key?(key)
200
+ self.fields.has_key?(key)
201
+ end
202
+ end
203
+
204
+ ListValue.class_eval do
205
+ include Enumerable
206
+
207
+ def length
208
+ self.values.length
209
+ end
210
+
211
+ def [](index)
212
+ self.values[index].to_ruby
213
+ end
214
+
215
+ def []=(index, value)
216
+ self.values[index].from_ruby(value)
217
+ end
218
+
219
+ def <<(value)
220
+ wrapper = Google::Protobuf::Value.new
221
+ wrapper.from_ruby(value)
222
+ self.values << wrapper
223
+ end
224
+
225
+ def each
226
+ self.values.each { |x| yield(x.to_ruby) }
227
+ end
228
+
229
+ def to_a
230
+ self.values.map { |x| x.to_ruby(true) }
231
+ end
232
+
233
+ def self.from_a(arr)
234
+ ret = ListValue.new
235
+ arr.each { |val| ret << val }
236
+ ret
237
+ end
238
+ end
239
+ end
240
+ 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, options = {})
63
+ msg.to_proto(options)
64
+ end
65
+
66
+ def self.encode_json(msg, options = {})
67
+ msg.to_json(options)
68
+ end
69
+
70
+ def self.decode(klass, proto, options = {})
71
+ klass.decode(proto, options)
72
+ end
73
+
74
+ def self.decode_json(klass, json, options = {})
75
+ klass.decode_json(json, options)
76
+ end
77
+
78
+ end
79
+ end