google-protobuf 3.17.2 → 3.23.4

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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/ext/google/protobuf_c/convert.c +128 -116
  3. data/ext/google/protobuf_c/convert.h +12 -9
  4. data/ext/google/protobuf_c/defs.c +235 -1529
  5. data/ext/google/protobuf_c/defs.h +19 -19
  6. data/ext/google/protobuf_c/extconf.rb +12 -6
  7. data/ext/google/protobuf_c/map.c +105 -109
  8. data/ext/google/protobuf_c/map.h +7 -8
  9. data/ext/google/protobuf_c/message.c +447 -342
  10. data/ext/google/protobuf_c/message.h +22 -19
  11. data/ext/google/protobuf_c/protobuf.c +71 -59
  12. data/ext/google/protobuf_c/protobuf.h +13 -10
  13. data/ext/google/protobuf_c/repeated_field.c +83 -85
  14. data/ext/google/protobuf_c/repeated_field.h +6 -6
  15. data/ext/google/protobuf_c/ruby-upb.c +11760 -6644
  16. data/ext/google/protobuf_c/ruby-upb.h +10765 -3396
  17. data/ext/google/protobuf_c/third_party/utf8_range/LICENSE +22 -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 +21 -0
  22. data/ext/google/protobuf_c/wrap_memcpy.c +4 -3
  23. data/lib/google/protobuf/any_pb.rb +24 -5
  24. data/lib/google/protobuf/api_pb.rb +27 -23
  25. data/lib/google/protobuf/descriptor_dsl.rb +465 -0
  26. data/lib/google/protobuf/descriptor_pb.rb +75 -0
  27. data/lib/google/protobuf/duration_pb.rb +24 -5
  28. data/lib/google/protobuf/empty_pb.rb +24 -3
  29. data/lib/google/protobuf/field_mask_pb.rb +24 -4
  30. data/lib/google/protobuf/message_exts.rb +7 -2
  31. data/lib/google/protobuf/plugin_pb.rb +47 -0
  32. data/lib/google/protobuf/repeated_field.rb +15 -2
  33. data/lib/google/protobuf/source_context_pb.rb +24 -4
  34. data/lib/google/protobuf/struct_pb.rb +24 -20
  35. data/lib/google/protobuf/timestamp_pb.rb +24 -5
  36. data/lib/google/protobuf/type_pb.rb +27 -68
  37. data/lib/google/protobuf/well_known_types.rb +12 -2
  38. data/lib/google/protobuf/wrappers_pb.rb +24 -28
  39. data/lib/google/protobuf.rb +5 -73
  40. metadata +17 -36
  41. data/ext/google/protobuf_c/third_party/wyhash/wyhash.h +0 -145
  42. data/tests/basic.rb +0 -611
  43. data/tests/generated_code_test.rb +0 -23
  44. data/tests/stress.rb +0 -38
@@ -44,10 +44,15 @@ module Google
44
44
  self.class.encode_json(self, options)
45
45
  end
46
46
 
47
- def to_proto
48
- self.class.encode(self)
47
+ def to_proto(options = {})
48
+ self.class.encode(self, options)
49
49
  end
50
50
 
51
51
  end
52
+ class AbstractMessage
53
+ include MessageExts
54
+ extend MessageExts::ClassMethods
55
+ end
56
+ private_constant :AbstractMessage
52
57
  end
53
58
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: google/protobuf/compiler/plugin.proto
4
+
5
+ require 'google/protobuf'
6
+
7
+ require 'google/protobuf/descriptor_pb'
8
+
9
+
10
+ descriptor_data = "\n%google/protobuf/compiler/plugin.proto\x12\x18google.protobuf.compiler\x1a google/protobuf/descriptor.proto\"F\n\x07Version\x12\r\n\x05major\x18\x01 \x01(\x05\x12\r\n\x05minor\x18\x02 \x01(\x05\x12\r\n\x05patch\x18\x03 \x01(\x05\x12\x0e\n\x06suffix\x18\x04 \x01(\t\"\xba\x01\n\x14\x43odeGeneratorRequest\x12\x18\n\x10\x66ile_to_generate\x18\x01 \x03(\t\x12\x11\n\tparameter\x18\x02 \x01(\t\x12\x38\n\nproto_file\x18\x0f \x03(\x0b\x32$.google.protobuf.FileDescriptorProto\x12;\n\x10\x63ompiler_version\x18\x03 \x01(\x0b\x32!.google.protobuf.compiler.Version\"\xc1\x02\n\x15\x43odeGeneratorResponse\x12\r\n\x05\x65rror\x18\x01 \x01(\t\x12\x1a\n\x12supported_features\x18\x02 \x01(\x04\x12\x42\n\x04\x66ile\x18\x0f \x03(\x0b\x32\x34.google.protobuf.compiler.CodeGeneratorResponse.File\x1a\x7f\n\x04\x46ile\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x17\n\x0finsertion_point\x18\x02 \x01(\t\x12\x0f\n\x07\x63ontent\x18\x0f \x01(\t\x12?\n\x13generated_code_info\x18\x10 \x01(\x0b\x32\".google.protobuf.GeneratedCodeInfo\"8\n\x07\x46\x65\x61ture\x12\x10\n\x0c\x46\x45\x41TURE_NONE\x10\x00\x12\x1b\n\x17\x46\x45\x41TURE_PROTO3_OPTIONAL\x10\x01\x42r\n\x1c\x63om.google.protobuf.compilerB\x0cPluginProtosZ)google.golang.org/protobuf/types/pluginpb\xaa\x02\x18Google.Protobuf.Compiler"
11
+
12
+ pool = Google::Protobuf::DescriptorPool.generated_pool
13
+
14
+ begin
15
+ pool.add_serialized_file(descriptor_data)
16
+ rescue TypeError => e
17
+ # Compatibility code: will be removed in the next major version.
18
+ require 'google/protobuf/descriptor_pb'
19
+ parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
20
+ parsed.clear_dependency
21
+ serialized = parsed.class.encode(parsed)
22
+ file = pool.add_serialized_file(serialized)
23
+ warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
24
+ imports = [
25
+ ["google.protobuf.FileDescriptorProto", "google/protobuf/descriptor.proto"],
26
+ ]
27
+ imports.each do |type_name, expected_filename|
28
+ import_file = pool.lookup(type_name).file_descriptor
29
+ if import_file.name != expected_filename
30
+ warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
31
+ end
32
+ end
33
+ warn "Each proto file must use a consistent fully-qualified name."
34
+ warn "This will become an error in the next major version."
35
+ end
36
+
37
+ module Google
38
+ module Protobuf
39
+ module Compiler
40
+ Version = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.compiler.Version").msgclass
41
+ CodeGeneratorRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.compiler.CodeGeneratorRequest").msgclass
42
+ CodeGeneratorResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.compiler.CodeGeneratorResponse").msgclass
43
+ CodeGeneratorResponse::File = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.compiler.CodeGeneratorResponse.File").msgclass
44
+ CodeGeneratorResponse::Feature = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.compiler.CodeGeneratorResponse.Feature").enummodule
45
+ end
46
+ end
47
+ end
@@ -79,12 +79,25 @@ module Google
79
79
 
80
80
 
81
81
  def first(n=nil)
82
- n ? self[0...n] : self[0]
82
+ if n.nil?
83
+ return self[0]
84
+ elsif n < 0
85
+ raise ArgumentError, "negative array size"
86
+ else
87
+ return self[0...n]
88
+ end
83
89
  end
84
90
 
85
91
 
86
92
  def last(n=nil)
87
- n ? self[(self.size-n-1)..-1] : self[-1]
93
+ if n.nil?
94
+ return self[-1]
95
+ elsif n < 0
96
+ raise ArgumentError, "negative array size"
97
+ else
98
+ start = [self.size-n, 0].max
99
+ return self[start...self.size]
100
+ end
88
101
  end
89
102
 
90
103
 
@@ -1,14 +1,34 @@
1
+ # frozen_string_literal: true
1
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
3
  # source: google/protobuf/source_context.proto
3
4
 
4
5
  require 'google/protobuf'
5
6
 
6
- Google::Protobuf::DescriptorPool.generated_pool.build do
7
- add_file("google/protobuf/source_context.proto", :syntax => :proto3) do
8
- add_message "google.protobuf.SourceContext" do
9
- optional :file_name, :string, 1
7
+
8
+ descriptor_data = "\n$google/protobuf/source_context.proto\x12\x0fgoogle.protobuf\"\"\n\rSourceContext\x12\x11\n\tfile_name\x18\x01 \x01(\tB\x8a\x01\n\x13\x63om.google.protobufB\x12SourceContextProtoP\x01Z6google.golang.org/protobuf/types/known/sourcecontextpb\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3"
9
+
10
+ pool = Google::Protobuf::DescriptorPool.generated_pool
11
+
12
+ begin
13
+ pool.add_serialized_file(descriptor_data)
14
+ rescue TypeError => e
15
+ # Compatibility code: will be removed in the next major version.
16
+ require 'google/protobuf/descriptor_pb'
17
+ parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
18
+ parsed.clear_dependency
19
+ serialized = parsed.class.encode(parsed)
20
+ file = pool.add_serialized_file(serialized)
21
+ warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
22
+ imports = [
23
+ ]
24
+ imports.each do |type_name, expected_filename|
25
+ import_file = pool.lookup(type_name).file_descriptor
26
+ if import_file.name != expected_filename
27
+ warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
10
28
  end
11
29
  end
30
+ warn "Each proto file must use a consistent fully-qualified name."
31
+ warn "This will become an error in the next major version."
12
32
  end
13
33
 
14
34
  module Google
@@ -1,30 +1,34 @@
1
+ # frozen_string_literal: true
1
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
3
  # source: google/protobuf/struct.proto
3
4
 
4
5
  require 'google/protobuf'
5
6
 
6
- Google::Protobuf::DescriptorPool.generated_pool.build do
7
- add_file("google/protobuf/struct.proto", :syntax => :proto3) do
8
- add_message "google.protobuf.Struct" do
9
- map :fields, :string, :message, 1, "google.protobuf.Value"
10
- end
11
- add_message "google.protobuf.Value" do
12
- oneof :kind do
13
- optional :null_value, :enum, 1, "google.protobuf.NullValue"
14
- optional :number_value, :double, 2
15
- optional :string_value, :string, 3
16
- optional :bool_value, :bool, 4
17
- optional :struct_value, :message, 5, "google.protobuf.Struct"
18
- optional :list_value, :message, 6, "google.protobuf.ListValue"
19
- end
20
- end
21
- add_message "google.protobuf.ListValue" do
22
- repeated :values, :message, 1, "google.protobuf.Value"
23
- end
24
- add_enum "google.protobuf.NullValue" do
25
- value :NULL_VALUE, 0
7
+
8
+ descriptor_data = "\n\x1cgoogle/protobuf/struct.proto\x12\x0fgoogle.protobuf\"\x84\x01\n\x06Struct\x12\x33\n\x06\x66ields\x18\x01 \x03(\x0b\x32#.google.protobuf.Struct.FieldsEntry\x1a\x45\n\x0b\x46ieldsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12%\n\x05value\x18\x02 \x01(\x0b\x32\x16.google.protobuf.Value:\x02\x38\x01\"\xea\x01\n\x05Value\x12\x30\n\nnull_value\x18\x01 \x01(\x0e\x32\x1a.google.protobuf.NullValueH\x00\x12\x16\n\x0cnumber_value\x18\x02 \x01(\x01H\x00\x12\x16\n\x0cstring_value\x18\x03 \x01(\tH\x00\x12\x14\n\nbool_value\x18\x04 \x01(\x08H\x00\x12/\n\x0cstruct_value\x18\x05 \x01(\x0b\x32\x17.google.protobuf.StructH\x00\x12\x30\n\nlist_value\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.ListValueH\x00\x42\x06\n\x04kind\"3\n\tListValue\x12&\n\x06values\x18\x01 \x03(\x0b\x32\x16.google.protobuf.Value*\x1b\n\tNullValue\x12\x0e\n\nNULL_VALUE\x10\x00\x42\x7f\n\x13\x63om.google.protobufB\x0bStructProtoP\x01Z/google.golang.org/protobuf/types/known/structpb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3"
9
+
10
+ pool = Google::Protobuf::DescriptorPool.generated_pool
11
+
12
+ begin
13
+ pool.add_serialized_file(descriptor_data)
14
+ rescue TypeError => e
15
+ # Compatibility code: will be removed in the next major version.
16
+ require 'google/protobuf/descriptor_pb'
17
+ parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
18
+ parsed.clear_dependency
19
+ serialized = parsed.class.encode(parsed)
20
+ file = pool.add_serialized_file(serialized)
21
+ warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
22
+ imports = [
23
+ ]
24
+ imports.each do |type_name, expected_filename|
25
+ import_file = pool.lookup(type_name).file_descriptor
26
+ if import_file.name != expected_filename
27
+ warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
26
28
  end
27
29
  end
30
+ warn "Each proto file must use a consistent fully-qualified name."
31
+ warn "This will become an error in the next major version."
28
32
  end
29
33
 
30
34
  module Google
@@ -1,15 +1,34 @@
1
+ # frozen_string_literal: true
1
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
3
  # source: google/protobuf/timestamp.proto
3
4
 
4
5
  require 'google/protobuf'
5
6
 
6
- Google::Protobuf::DescriptorPool.generated_pool.build do
7
- add_file("google/protobuf/timestamp.proto", :syntax => :proto3) do
8
- add_message "google.protobuf.Timestamp" do
9
- optional :seconds, :int64, 1
10
- optional :nanos, :int32, 2
7
+
8
+ descriptor_data = "\n\x1fgoogle/protobuf/timestamp.proto\x12\x0fgoogle.protobuf\"+\n\tTimestamp\x12\x0f\n\x07seconds\x18\x01 \x01(\x03\x12\r\n\x05nanos\x18\x02 \x01(\x05\x42\x85\x01\n\x13\x63om.google.protobufB\x0eTimestampProtoP\x01Z2google.golang.org/protobuf/types/known/timestamppb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3"
9
+
10
+ pool = Google::Protobuf::DescriptorPool.generated_pool
11
+
12
+ begin
13
+ pool.add_serialized_file(descriptor_data)
14
+ rescue TypeError => e
15
+ # Compatibility code: will be removed in the next major version.
16
+ require 'google/protobuf/descriptor_pb'
17
+ parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
18
+ parsed.clear_dependency
19
+ serialized = parsed.class.encode(parsed)
20
+ file = pool.add_serialized_file(serialized)
21
+ warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
22
+ imports = [
23
+ ]
24
+ imports.each do |type_name, expected_filename|
25
+ import_file = pool.lookup(type_name).file_descriptor
26
+ if import_file.name != expected_filename
27
+ warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
11
28
  end
12
29
  end
30
+ warn "Each proto file must use a consistent fully-qualified name."
31
+ warn "This will become an error in the next major version."
13
32
  end
14
33
 
15
34
  module Google
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
3
  # source: google/protobuf/type.proto
3
4
 
@@ -5,76 +6,34 @@ require 'google/protobuf'
5
6
 
6
7
  require 'google/protobuf/any_pb'
7
8
  require 'google/protobuf/source_context_pb'
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
9
+
10
+
11
+ descriptor_data = "\n\x1agoogle/protobuf/type.proto\x12\x0fgoogle.protobuf\x1a\x19google/protobuf/any.proto\x1a$google/protobuf/source_context.proto\"\xe8\x01\n\x04Type\x12\x0c\n\x04name\x18\x01 \x01(\t\x12&\n\x06\x66ields\x18\x02 \x03(\x0b\x32\x16.google.protobuf.Field\x12\x0e\n\x06oneofs\x18\x03 \x03(\t\x12(\n\x07options\x18\x04 \x03(\x0b\x32\x17.google.protobuf.Option\x12\x36\n\x0esource_context\x18\x05 \x01(\x0b\x32\x1e.google.protobuf.SourceContext\x12\'\n\x06syntax\x18\x06 \x01(\x0e\x32\x17.google.protobuf.Syntax\x12\x0f\n\x07\x65\x64ition\x18\x07 \x01(\t\"\xd5\x05\n\x05\x46ield\x12)\n\x04kind\x18\x01 \x01(\x0e\x32\x1b.google.protobuf.Field.Kind\x12\x37\n\x0b\x63\x61rdinality\x18\x02 \x01(\x0e\x32\".google.protobuf.Field.Cardinality\x12\x0e\n\x06number\x18\x03 \x01(\x05\x12\x0c\n\x04name\x18\x04 \x01(\t\x12\x10\n\x08type_url\x18\x06 \x01(\t\x12\x13\n\x0boneof_index\x18\x07 \x01(\x05\x12\x0e\n\x06packed\x18\x08 \x01(\x08\x12(\n\x07options\x18\t \x03(\x0b\x32\x17.google.protobuf.Option\x12\x11\n\tjson_name\x18\n \x01(\t\x12\x15\n\rdefault_value\x18\x0b \x01(\t\"\xc8\x02\n\x04Kind\x12\x10\n\x0cTYPE_UNKNOWN\x10\x00\x12\x0f\n\x0bTYPE_DOUBLE\x10\x01\x12\x0e\n\nTYPE_FLOAT\x10\x02\x12\x0e\n\nTYPE_INT64\x10\x03\x12\x0f\n\x0bTYPE_UINT64\x10\x04\x12\x0e\n\nTYPE_INT32\x10\x05\x12\x10\n\x0cTYPE_FIXED64\x10\x06\x12\x10\n\x0cTYPE_FIXED32\x10\x07\x12\r\n\tTYPE_BOOL\x10\x08\x12\x0f\n\x0bTYPE_STRING\x10\t\x12\x0e\n\nTYPE_GROUP\x10\n\x12\x10\n\x0cTYPE_MESSAGE\x10\x0b\x12\x0e\n\nTYPE_BYTES\x10\x0c\x12\x0f\n\x0bTYPE_UINT32\x10\r\x12\r\n\tTYPE_ENUM\x10\x0e\x12\x11\n\rTYPE_SFIXED32\x10\x0f\x12\x11\n\rTYPE_SFIXED64\x10\x10\x12\x0f\n\x0bTYPE_SINT32\x10\x11\x12\x0f\n\x0bTYPE_SINT64\x10\x12\"t\n\x0b\x43\x61rdinality\x12\x17\n\x13\x43\x41RDINALITY_UNKNOWN\x10\x00\x12\x18\n\x14\x43\x41RDINALITY_OPTIONAL\x10\x01\x12\x18\n\x14\x43\x41RDINALITY_REQUIRED\x10\x02\x12\x18\n\x14\x43\x41RDINALITY_REPEATED\x10\x03\"\xdf\x01\n\x04\x45num\x12\x0c\n\x04name\x18\x01 \x01(\t\x12-\n\tenumvalue\x18\x02 \x03(\x0b\x32\x1a.google.protobuf.EnumValue\x12(\n\x07options\x18\x03 \x03(\x0b\x32\x17.google.protobuf.Option\x12\x36\n\x0esource_context\x18\x04 \x01(\x0b\x32\x1e.google.protobuf.SourceContext\x12\'\n\x06syntax\x18\x05 \x01(\x0e\x32\x17.google.protobuf.Syntax\x12\x0f\n\x07\x65\x64ition\x18\x06 \x01(\t\"S\n\tEnumValue\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06number\x18\x02 \x01(\x05\x12(\n\x07options\x18\x03 \x03(\x0b\x32\x17.google.protobuf.Option\";\n\x06Option\x12\x0c\n\x04name\x18\x01 \x01(\t\x12#\n\x05value\x18\x02 \x01(\x0b\x32\x14.google.protobuf.Any*C\n\x06Syntax\x12\x11\n\rSYNTAX_PROTO2\x10\x00\x12\x11\n\rSYNTAX_PROTO3\x10\x01\x12\x13\n\x0fSYNTAX_EDITIONS\x10\x02\x42{\n\x13\x63om.google.protobufB\tTypeProtoP\x01Z-google.golang.org/protobuf/types/known/typepb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3"
12
+
13
+ pool = Google::Protobuf::DescriptorPool.generated_pool
14
+
15
+ begin
16
+ pool.add_serialized_file(descriptor_data)
17
+ rescue TypeError => e
18
+ # Compatibility code: will be removed in the next major version.
19
+ require 'google/protobuf/descriptor_pb'
20
+ parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
21
+ parsed.clear_dependency
22
+ serialized = parsed.class.encode(parsed)
23
+ file = pool.add_serialized_file(serialized)
24
+ warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
25
+ imports = [
26
+ ["google.protobuf.SourceContext", "google/protobuf/source_context.proto"],
27
+ ["google.protobuf.Any", "google/protobuf/any.proto"],
28
+ ]
29
+ imports.each do |type_name, expected_filename|
30
+ import_file = pool.lookup(type_name).file_descriptor
31
+ if import_file.name != expected_filename
32
+ warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
76
33
  end
77
34
  end
35
+ warn "Each proto file must use a consistent fully-qualified name."
36
+ warn "This will become an error in the next major version."
78
37
  end
79
38
 
80
39
  module Google
@@ -82,9 +82,14 @@ module Google
82
82
  end
83
83
  end
84
84
 
85
+ def self.from_time(time)
86
+ new.from_time(time)
87
+ end
88
+
85
89
  def from_time(time)
86
90
  self.seconds = time.to_i
87
91
  self.nanos = time.nsec
92
+ self
88
93
  end
89
94
 
90
95
  def to_i
@@ -132,10 +137,14 @@ module Google
132
137
  end
133
138
  end
134
139
 
140
+ def self.from_ruby(value)
141
+ self.new.from_ruby(value)
142
+ end
143
+
135
144
  def from_ruby(value)
136
145
  case value
137
146
  when NilClass
138
- self.null_value = 0
147
+ self.null_value = :NULL_VALUE
139
148
  when Numeric
140
149
  self.number_value = value
141
150
  when String
@@ -155,6 +164,8 @@ module Google
155
164
  else
156
165
  raise UnexpectedStructType
157
166
  end
167
+
168
+ self
158
169
  end
159
170
  end
160
171
 
@@ -225,6 +236,5 @@ module Google
225
236
  ret
226
237
  end
227
238
  end
228
-
229
239
  end
230
240
  end
@@ -1,38 +1,34 @@
1
+ # frozen_string_literal: true
1
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
3
  # source: google/protobuf/wrappers.proto
3
4
 
4
5
  require 'google/protobuf'
5
6
 
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
7
+
8
+ descriptor_data = "\n\x1egoogle/protobuf/wrappers.proto\x12\x0fgoogle.protobuf\"\x1c\n\x0b\x44oubleValue\x12\r\n\x05value\x18\x01 \x01(\x01\"\x1b\n\nFloatValue\x12\r\n\x05value\x18\x01 \x01(\x02\"\x1b\n\nInt64Value\x12\r\n\x05value\x18\x01 \x01(\x03\"\x1c\n\x0bUInt64Value\x12\r\n\x05value\x18\x01 \x01(\x04\"\x1b\n\nInt32Value\x12\r\n\x05value\x18\x01 \x01(\x05\"\x1c\n\x0bUInt32Value\x12\r\n\x05value\x18\x01 \x01(\r\"\x1a\n\tBoolValue\x12\r\n\x05value\x18\x01 \x01(\x08\"\x1c\n\x0bStringValue\x12\r\n\x05value\x18\x01 \x01(\t\"\x1b\n\nBytesValue\x12\r\n\x05value\x18\x01 \x01(\x0c\x42\x83\x01\n\x13\x63om.google.protobufB\rWrappersProtoP\x01Z1google.golang.org/protobuf/types/known/wrapperspb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3"
9
+
10
+ pool = Google::Protobuf::DescriptorPool.generated_pool
11
+
12
+ begin
13
+ pool.add_serialized_file(descriptor_data)
14
+ rescue TypeError => e
15
+ # Compatibility code: will be removed in the next major version.
16
+ require 'google/protobuf/descriptor_pb'
17
+ parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
18
+ parsed.clear_dependency
19
+ serialized = parsed.class.encode(parsed)
20
+ file = pool.add_serialized_file(serialized)
21
+ warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
22
+ imports = [
23
+ ]
24
+ imports.each do |type_name, expected_filename|
25
+ import_file = pool.lookup(type_name).file_descriptor
26
+ if import_file.name != expected_filename
27
+ warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
34
28
  end
35
29
  end
30
+ warn "Each proto file must use a consistent fully-qualified name."
31
+ warn "This will become an error in the next major version."
36
32
  end
37
33
 
38
34
  module Google
@@ -51,92 +51,24 @@ else
51
51
  require 'google/protobuf_c'
52
52
  end
53
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
123
54
  end
124
55
 
56
+ require 'google/protobuf/descriptor_dsl'
125
57
  require 'google/protobuf/repeated_field'
126
58
 
127
59
  module Google
128
60
  module Protobuf
129
61
 
130
- def self.encode(msg)
131
- msg.to_proto
62
+ def self.encode(msg, options = {})
63
+ msg.to_proto(options)
132
64
  end
133
65
 
134
66
  def self.encode_json(msg, options = {})
135
67
  msg.to_json(options)
136
68
  end
137
69
 
138
- def self.decode(klass, proto)
139
- klass.decode(proto)
70
+ def self.decode(klass, proto, options = {})
71
+ klass.decode(proto, options)
140
72
  end
141
73
 
142
74
  def self.decode_json(klass, json, options = {})