protobuffy 3.6.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +67 -0
- data/.rubocop_todo.yml +145 -0
- data/.travis.yml +25 -5
- data/CHANGES.md +55 -0
- data/CONTRIBUTING.md +1 -1
- data/LICENSE.txt +17 -9
- data/README.md +13 -12
- data/Rakefile +15 -11
- data/bin/protoc-gen-ruby +8 -3
- data/bin/rpc_server +1 -0
- data/examples/lib/example/reverse-client.rb +2 -2
- data/install-protobuf.sh +28 -0
- data/lib/protobuf.rb +57 -53
- data/lib/protobuf/cli.rb +94 -74
- data/lib/protobuf/code_generator.rb +60 -9
- data/lib/protobuf/decoder.rb +19 -65
- data/lib/protobuf/deprecation.rb +117 -0
- data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +11 -1
- data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +55 -3
- data/lib/protobuf/encoder.rb +13 -53
- data/lib/protobuf/enum.rb +58 -63
- data/lib/protobuf/field.rb +4 -4
- data/lib/protobuf/field/base_field.rb +101 -173
- data/lib/protobuf/field/bool_field.rb +17 -11
- data/lib/protobuf/field/bytes_field.rb +21 -35
- data/lib/protobuf/field/double_field.rb +0 -1
- data/lib/protobuf/field/enum_field.rb +23 -22
- data/lib/protobuf/field/field_array.rb +5 -4
- data/lib/protobuf/field/fixed32_field.rb +1 -1
- data/lib/protobuf/field/fixed64_field.rb +0 -1
- data/lib/protobuf/field/float_field.rb +4 -1
- data/lib/protobuf/field/int32_field.rb +0 -1
- data/lib/protobuf/field/int64_field.rb +0 -1
- data/lib/protobuf/field/integer_field.rb +0 -1
- data/lib/protobuf/field/message_field.rb +13 -28
- data/lib/protobuf/field/sfixed32_field.rb +0 -1
- data/lib/protobuf/field/sfixed64_field.rb +0 -1
- data/lib/protobuf/field/signed_integer_field.rb +0 -1
- data/lib/protobuf/field/sint32_field.rb +0 -1
- data/lib/protobuf/field/sint64_field.rb +0 -1
- data/lib/protobuf/field/string_field.rb +2 -4
- data/lib/protobuf/field/uint32_field.rb +0 -1
- data/lib/protobuf/field/uint64_field.rb +0 -1
- data/lib/protobuf/field/varint_field.rb +30 -13
- data/lib/protobuf/generators/base.rb +30 -16
- data/lib/protobuf/generators/enum_generator.rb +6 -9
- data/lib/protobuf/generators/extension_generator.rb +1 -2
- data/lib/protobuf/generators/field_generator.rb +25 -13
- data/lib/protobuf/generators/file_generator.rb +157 -35
- data/lib/protobuf/generators/group_generator.rb +22 -17
- data/lib/protobuf/generators/message_generator.rb +13 -14
- data/lib/protobuf/generators/option_generator.rb +17 -0
- data/lib/protobuf/generators/printable.rb +12 -13
- data/lib/protobuf/generators/service_generator.rb +2 -3
- data/lib/protobuf/http.rb +2 -2
- data/lib/protobuf/lifecycle.rb +20 -33
- data/lib/protobuf/logging.rb +39 -0
- data/lib/protobuf/message.rb +114 -47
- data/lib/protobuf/message/fields.rb +170 -88
- data/lib/protobuf/message/serialization.rb +19 -18
- data/lib/protobuf/optionable.rb +53 -6
- data/lib/protobuf/rpc/buffer.rb +18 -19
- data/lib/protobuf/rpc/client.rb +22 -50
- data/lib/protobuf/rpc/connectors/base.rb +177 -12
- data/lib/protobuf/rpc/connectors/http.rb +14 -9
- data/lib/protobuf/rpc/connectors/ping.rb +89 -0
- data/lib/protobuf/rpc/connectors/socket.rb +13 -8
- data/lib/protobuf/rpc/connectors/zmq.rb +178 -73
- data/lib/protobuf/rpc/dynamic_discovery.pb.rb +4 -1
- data/lib/protobuf/rpc/env.rb +12 -12
- data/lib/protobuf/rpc/error.rb +3 -3
- data/lib/protobuf/rpc/error/client_error.rb +4 -4
- data/lib/protobuf/rpc/error/server_error.rb +9 -9
- data/lib/protobuf/rpc/middleware/exception_handler.rb +6 -2
- data/lib/protobuf/rpc/middleware/logger.rb +8 -4
- data/lib/protobuf/rpc/middleware/request_decoder.rb +17 -21
- data/lib/protobuf/rpc/middleware/response_encoder.rb +22 -27
- data/lib/protobuf/rpc/middleware/statsd.rb +3 -3
- data/lib/protobuf/rpc/rpc.pb.rb +4 -1
- data/lib/protobuf/rpc/server.rb +1 -1
- data/lib/protobuf/rpc/servers/http/server.rb +19 -17
- data/lib/protobuf/rpc/servers/socket/server.rb +78 -70
- data/lib/protobuf/rpc/servers/socket/worker.rb +4 -4
- data/lib/protobuf/rpc/servers/socket_runner.rb +27 -15
- data/lib/protobuf/rpc/servers/zmq/broker.rb +70 -31
- data/lib/protobuf/rpc/servers/zmq/server.rb +55 -47
- data/lib/protobuf/rpc/servers/zmq/util.rb +14 -13
- data/lib/protobuf/rpc/servers/zmq/worker.rb +16 -16
- data/lib/protobuf/rpc/servers/zmq_runner.rb +26 -7
- data/lib/protobuf/rpc/service.rb +21 -27
- data/lib/protobuf/rpc/service_directory.rb +43 -27
- data/lib/protobuf/rpc/service_dispatcher.rb +9 -10
- data/lib/protobuf/rpc/service_filters.rb +32 -55
- data/lib/protobuf/rpc/stat.rb +4 -8
- data/lib/protobuf/socket.rb +1 -2
- data/lib/protobuf/tasks/compile.rake +3 -4
- data/lib/protobuf/varint.rb +9 -0
- data/lib/protobuf/varint_pure.rb +13 -0
- data/lib/protobuf/version.rb +1 -1
- data/lib/protobuf/zmq.rb +2 -2
- data/proto/google/protobuf/descriptor.proto +190 -31
- data/protobuffy.gemspec +30 -17
- data/spec/benchmark/tasks.rb +27 -19
- data/spec/bin/protoc-gen-ruby_spec.rb +11 -6
- data/spec/encoding/all_types_spec.rb +96 -84
- data/spec/encoding/extreme_values_spec.rb +0 -0
- data/spec/functional/class_inheritance_spec.rb +52 -0
- data/spec/functional/code_generator_spec.rb +38 -0
- data/spec/functional/socket_server_spec.rb +15 -15
- data/spec/functional/zmq_server_spec.rb +29 -27
- data/spec/lib/protobuf/cli_spec.rb +82 -67
- data/spec/lib/protobuf/code_generator_spec.rb +37 -10
- data/spec/lib/protobuf/enum_spec.rb +77 -46
- data/spec/lib/protobuf/field/bool_field_spec.rb +91 -0
- data/spec/lib/protobuf/field/double_field_spec.rb +9 -0
- data/spec/lib/protobuf/field/enum_field_spec.rb +26 -0
- data/spec/lib/protobuf/field/field_array_spec.rb +69 -0
- data/spec/lib/protobuf/field/fixed32_field_spec.rb +7 -0
- data/spec/lib/protobuf/field/fixed64_field_spec.rb +7 -0
- data/spec/lib/protobuf/field/float_field_spec.rb +90 -0
- data/spec/lib/protobuf/field/int32_field_spec.rb +114 -1
- data/spec/lib/protobuf/field/int64_field_spec.rb +7 -0
- data/spec/lib/protobuf/field/message_field_spec.rb +132 -0
- data/spec/lib/protobuf/field/sfixed32_field_spec.rb +9 -0
- data/spec/lib/protobuf/field/sfixed64_field_spec.rb +9 -0
- data/spec/lib/protobuf/field/sint32_field_spec.rb +9 -0
- data/spec/lib/protobuf/field/sint64_field_spec.rb +9 -0
- data/spec/lib/protobuf/field/string_field_spec.rb +44 -11
- data/spec/lib/protobuf/field/uint32_field_spec.rb +7 -0
- data/spec/lib/protobuf/field/uint64_field_spec.rb +7 -0
- data/spec/lib/protobuf/field_spec.rb +4 -6
- data/spec/lib/protobuf/generators/base_spec.rb +80 -13
- data/spec/lib/protobuf/generators/enum_generator_spec.rb +35 -21
- data/spec/lib/protobuf/generators/extension_generator_spec.rb +12 -13
- data/spec/lib/protobuf/generators/field_generator_spec.rb +73 -21
- data/spec/lib/protobuf/generators/file_generator_spec.rb +89 -6
- data/spec/lib/protobuf/generators/service_generator_spec.rb +25 -13
- data/spec/lib/protobuf/lifecycle_spec.rb +25 -20
- data/spec/lib/protobuf/message_spec.rb +578 -79
- data/spec/lib/protobuf/optionable_spec.rb +202 -26
- data/spec/lib/protobuf/rpc/client_spec.rb +16 -16
- data/spec/lib/protobuf/rpc/connectors/base_spec.rb +167 -13
- data/spec/lib/protobuf/rpc/connectors/connector_spec.rb +4 -5
- data/spec/lib/protobuf/rpc/connectors/http_spec.rb +13 -11
- data/spec/lib/protobuf/rpc/connectors/ping_spec.rb +69 -0
- data/spec/lib/protobuf/rpc/connectors/socket_spec.rb +6 -7
- data/spec/lib/protobuf/rpc/connectors/zmq_spec.rb +35 -52
- data/spec/lib/protobuf/rpc/middleware/exception_handler_spec.rb +10 -10
- data/spec/lib/protobuf/rpc/middleware/logger_spec.rb +11 -11
- data/spec/lib/protobuf/rpc/middleware/request_decoder_spec.rb +23 -23
- data/spec/lib/protobuf/rpc/middleware/response_encoder_spec.rb +11 -11
- data/spec/lib/protobuf/rpc/middleware/statsd_spec.rb +6 -6
- data/spec/lib/protobuf/rpc/servers/http/server_spec.rb +47 -44
- data/spec/lib/protobuf/rpc/servers/socket_server_spec.rb +6 -6
- data/spec/lib/protobuf/rpc/servers/zmq/server_spec.rb +12 -10
- data/spec/lib/protobuf/rpc/servers/zmq/util_spec.rb +11 -11
- data/spec/lib/protobuf/rpc/servers/zmq/worker_spec.rb +7 -7
- data/spec/lib/protobuf/rpc/service_directory_spec.rb +47 -49
- data/spec/lib/protobuf/rpc/service_dispatcher_spec.rb +8 -25
- data/spec/lib/protobuf/rpc/service_filters_spec.rb +102 -69
- data/spec/lib/protobuf/rpc/service_spec.rb +37 -36
- data/spec/lib/protobuf/rpc/stat_spec.rb +7 -9
- data/spec/lib/protobuf/varint_spec.rb +29 -0
- data/spec/lib/protobuf_spec.rb +55 -28
- data/spec/spec_helper.rb +12 -27
- data/spec/support/all.rb +0 -1
- data/spec/support/packed_field.rb +4 -3
- data/spec/support/{test → protos}/all_types.data.bin +0 -0
- data/spec/support/{test → protos}/all_types.data.txt +0 -0
- data/spec/support/{test → protos}/enum.pb.rb +8 -4
- data/spec/support/{test → protos}/enum.proto +4 -1
- data/spec/support/{test → protos}/extreme_values.data.bin +0 -0
- data/spec/support/protos/google_unittest.bin +0 -0
- data/spec/support/protos/google_unittest.pb.rb +798 -0
- data/spec/support/{test → protos}/google_unittest.proto +237 -66
- data/spec/support/protos/google_unittest_custom_options.bin +0 -0
- data/spec/support/protos/google_unittest_custom_options.pb.rb +268 -0
- data/spec/support/protos/google_unittest_custom_options.proto +424 -0
- data/spec/support/protos/google_unittest_import.pb.rb +55 -0
- data/spec/support/{test → protos}/google_unittest_import.proto +19 -10
- data/spec/support/protos/google_unittest_import_public.pb.rb +31 -0
- data/spec/support/{test → protos}/google_unittest_import_public.proto +8 -5
- data/spec/support/{test → protos}/multi_field_extensions.pb.rb +5 -2
- data/spec/support/{test → protos}/multi_field_extensions.proto +2 -0
- data/spec/support/{test → protos}/resource.pb.rb +47 -11
- data/spec/support/{test → protos}/resource.proto +24 -1
- data/spec/support/resource_service.rb +23 -0
- data/spec/support/server.rb +32 -61
- metadata +119 -59
- data/lib/protobuf/deprecator.rb +0 -42
- data/lib/protobuf/logger.rb +0 -93
- data/lib/protobuf/rpc/connector.rb +0 -21
- data/lib/protobuf/rpc/connectors/common.rb +0 -172
- data/spec/data/data.bin +0 -3
- data/spec/data/types.bin +0 -0
- data/spec/lib/protobuf/logger_spec.rb +0 -145
- data/spec/lib/protobuf/rpc/connector_spec.rb +0 -26
- data/spec/lib/protobuf/rpc/connectors/common_spec.rb +0 -170
- data/spec/support/test/defaults.pb.rb +0 -25
- data/spec/support/test/defaults.proto +0 -9
- data/spec/support/test/extended.pb.rb +0 -22
- data/spec/support/test/extended.proto +0 -10
- data/spec/support/test/google_unittest.pb.rb +0 -543
- data/spec/support/test/google_unittest_import.pb.rb +0 -37
- data/spec/support/test/google_unittest_import_public.pb.rb +0 -8
- data/spec/support/test/resource_service.rb +0 -26
- data/spec/support/tolerance_matcher.rb +0 -40
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'active_support/core_ext/module/aliasing'
|
1
2
|
require 'protobuf/generators/file_generator'
|
2
3
|
|
3
4
|
module Protobuf
|
@@ -6,36 +7,86 @@ module Protobuf
|
|
6
7
|
CodeGeneratorFatalError = Class.new(RuntimeError)
|
7
8
|
|
8
9
|
def self.fatal(message)
|
9
|
-
|
10
|
+
fail CodeGeneratorFatalError, message
|
10
11
|
end
|
11
12
|
|
12
13
|
def self.print_tag_warning_suppress
|
13
14
|
STDERR.puts "Suppress tag warning output with PB_NO_TAG_WARNINGS=1."
|
14
|
-
def self.print_tag_warning_suppress; end
|
15
|
+
def self.print_tag_warning_suppress; end # rubocop:disable Lint/DuplicateMethods, Lint/NestedMethodDefinition
|
15
16
|
end
|
16
17
|
|
17
18
|
def self.warn(message)
|
18
19
|
STDERR.puts("[WARN] #{message}")
|
19
20
|
end
|
20
21
|
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_accessor :request
|
25
|
+
|
26
|
+
public
|
27
|
+
|
21
28
|
def initialize(request_bytes)
|
22
|
-
@
|
23
|
-
|
29
|
+
@request_bytes = request_bytes
|
30
|
+
self.request = ::Google::Protobuf::Compiler::CodeGeneratorRequest.decode(request_bytes)
|
31
|
+
end
|
32
|
+
|
33
|
+
def eval_unknown_extensions!
|
34
|
+
request.proto_file.each do |file_descriptor|
|
35
|
+
::Protobuf::Generators::FileGenerator.new(file_descriptor).eval_unknown_extensions!
|
36
|
+
end
|
37
|
+
self.request = ::Google::Protobuf::Compiler::CodeGeneratorRequest.decode(@request_bytes)
|
24
38
|
end
|
25
39
|
|
26
40
|
def generate_file(file_descriptor)
|
27
|
-
|
28
|
-
@generated_files << file_generator.generate_output_file
|
41
|
+
::Protobuf::Generators::FileGenerator.new(file_descriptor).generate_output_file
|
29
42
|
end
|
30
43
|
|
31
44
|
def response_bytes
|
32
|
-
|
45
|
+
generated_files = request.proto_file.map do |file_descriptor|
|
33
46
|
generate_file(file_descriptor)
|
34
47
|
end
|
35
48
|
|
36
|
-
|
49
|
+
::Google::Protobuf::Compiler::CodeGeneratorResponse.encode(:file => generated_files)
|
37
50
|
end
|
38
51
|
|
52
|
+
Protobuf::Field::BaseField.module_eval do
|
53
|
+
# Sets a MessageField that is known to be an option.
|
54
|
+
# We must allow fields to be set one at a time, as option syntax allows us to
|
55
|
+
# set each field within the option using a separate "option" line.
|
56
|
+
def set_with_options(message_instance, bytes)
|
57
|
+
if message_instance[name].is_a?(::Protobuf::Message)
|
58
|
+
gp = Google::Protobuf
|
59
|
+
if message_instance.is_a?(gp::EnumOptions) || message_instance.is_a?(gp::EnumValueOptions) ||
|
60
|
+
message_instance.is_a?(gp::FieldOptions) || message_instance.is_a?(gp::FileOptions) ||
|
61
|
+
message_instance.is_a?(gp::MethodOptions) || message_instance.is_a?(gp::ServiceOptions) ||
|
62
|
+
message_instance.is_a?(gp::MessageOptions)
|
63
|
+
|
64
|
+
original_field = message_instance[name]
|
65
|
+
decoded_field = decode(bytes)
|
66
|
+
decoded_field.each_field do |subfield, subvalue|
|
67
|
+
option_set(original_field, subfield, subvalue) { decoded_field.field?(subfield.tag) }
|
68
|
+
end
|
69
|
+
return
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
set_without_options(message_instance, bytes)
|
74
|
+
end
|
75
|
+
|
76
|
+
def option_set(message_field, subfield, subvalue)
|
77
|
+
return unless yield
|
78
|
+
if subfield.repeated?
|
79
|
+
message_field[subfield.tag].concat(subvalue)
|
80
|
+
elsif message_field[subfield.tag] && subvalue.is_a?(::Protobuf::Message)
|
81
|
+
subvalue.each_field do |f, v|
|
82
|
+
option_set(message_field[subfield.tag], f, v) { subvalue.field?(f.tag) }
|
83
|
+
end
|
84
|
+
else
|
85
|
+
message_field[subfield.tag] = subvalue
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
alias_method_chain :set, :options
|
90
|
+
end
|
39
91
|
end
|
40
92
|
end
|
41
|
-
|
data/lib/protobuf/decoder.rb
CHANGED
@@ -1,74 +1,28 @@
|
|
1
|
-
require 'protobuf/wire_type'
|
2
|
-
require 'protobuf/exceptions'
|
3
|
-
|
4
1
|
module Protobuf
|
5
2
|
class Decoder
|
6
3
|
|
7
4
|
# Read bytes from +stream+ and pass to +message+ object.
|
8
|
-
def self.decode_each_field(stream
|
5
|
+
def self.decode_each_field(stream)
|
9
6
|
until stream.eof?
|
10
|
-
|
11
|
-
|
7
|
+
bits = Varint.decode(stream)
|
8
|
+
wire_type = bits & 0x07
|
9
|
+
tag = bits >> 3
|
10
|
+
|
11
|
+
bytes = if wire_type == ::Protobuf::WireType::VARINT
|
12
|
+
Varint.decode(stream)
|
13
|
+
elsif wire_type == ::Protobuf::WireType::LENGTH_DELIMITED
|
14
|
+
value_length = Varint.decode(stream)
|
15
|
+
stream.read(value_length)
|
16
|
+
elsif wire_type == ::Protobuf::WireType::FIXED64
|
17
|
+
stream.read(8)
|
18
|
+
elsif wire_type == ::Protobuf::WireType::FIXED32
|
19
|
+
stream.read(4)
|
20
|
+
else
|
21
|
+
fail InvalidWireType, wire_type
|
22
|
+
end
|
23
|
+
|
24
|
+
yield(tag, bytes)
|
12
25
|
end
|
13
26
|
end
|
14
|
-
|
15
|
-
def self.read_field(stream)
|
16
|
-
tag, wire_type = read_key(stream)
|
17
|
-
bytes = case wire_type
|
18
|
-
when ::Protobuf::WireType::VARINT then
|
19
|
-
read_varint(stream)
|
20
|
-
when ::Protobuf::WireType::FIXED64 then
|
21
|
-
read_fixed64(stream)
|
22
|
-
when ::Protobuf::WireType::LENGTH_DELIMITED then
|
23
|
-
read_length_delimited(stream)
|
24
|
-
when ::Protobuf::WireType::FIXED32 then
|
25
|
-
read_fixed32(stream)
|
26
|
-
when ::Protobuf::WireType::START_GROUP then
|
27
|
-
raise NotImplementedError, 'Group is deprecated.'
|
28
|
-
when ::Protobuf::WireType::END_GROUP then
|
29
|
-
raise NotImplementedError, 'Group is deprecated.'
|
30
|
-
else
|
31
|
-
raise InvalidWireType, wire_type
|
32
|
-
end
|
33
|
-
|
34
|
-
return tag, bytes
|
35
|
-
end
|
36
|
-
|
37
|
-
# Read 32-bit string value from +stream+.
|
38
|
-
def self.read_fixed32(stream)
|
39
|
-
stream.read(4)
|
40
|
-
end
|
41
|
-
|
42
|
-
# Read 64-bit string value from +stream+.
|
43
|
-
def self.read_fixed64(stream)
|
44
|
-
stream.read(8)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Read key pair (tag and wire-type) from +stream+.
|
48
|
-
def self.read_key(stream)
|
49
|
-
bits = read_varint(stream)
|
50
|
-
wire_type = bits & 0x07
|
51
|
-
tag = bits >> 3
|
52
|
-
[tag, wire_type]
|
53
|
-
end
|
54
|
-
|
55
|
-
# Read length-delimited string value from +stream+.
|
56
|
-
def self.read_length_delimited(stream)
|
57
|
-
value_length = read_varint(stream)
|
58
|
-
stream.read(value_length)
|
59
|
-
end
|
60
|
-
|
61
|
-
# Read varint integer value from +stream+.
|
62
|
-
def self.read_varint(stream)
|
63
|
-
value = index = 0
|
64
|
-
begin
|
65
|
-
byte = stream.readbyte
|
66
|
-
value |= (byte & 0x7f) << (7 * index)
|
67
|
-
index += 1
|
68
|
-
end while (byte & 0x80).nonzero?
|
69
|
-
value
|
70
|
-
end
|
71
|
-
|
72
27
|
end
|
73
28
|
end
|
74
|
-
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'active_support/deprecation'
|
2
|
+
|
3
|
+
module Protobuf
|
4
|
+
if ::ActiveSupport::Deprecation.is_a?(Class)
|
5
|
+
class DeprecationBase < ::ActiveSupport::Deprecation
|
6
|
+
def deprecate_methods(*args)
|
7
|
+
deprecation_options = { :deprecator => self }
|
8
|
+
|
9
|
+
if args.last.is_a?(Hash)
|
10
|
+
args.last.merge!(deprecation_options)
|
11
|
+
else
|
12
|
+
args.push(deprecation_options)
|
13
|
+
end
|
14
|
+
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def deprecation_warning(deprecated_method_name, message = nil, caller_backtrace = nil)
|
19
|
+
# This ensures ActiveSupport::Deprecation doesn't look for the caller, which is very costly.
|
20
|
+
super(deprecated_method_name, message, caller_backtrace) unless ENV.key?('PB_IGNORE_DEPRECATIONS')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Deprecation < DeprecationBase
|
25
|
+
def define_deprecated_methods(target_module, method_hash)
|
26
|
+
target_module.module_eval do
|
27
|
+
method_hash.each do |old_method, new_method|
|
28
|
+
alias_method old_method, new_method
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
deprecate_methods(target_module, method_hash)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class FieldDeprecation < DeprecationBase
|
37
|
+
# this is a convenience deprecator for deprecated proto fields
|
38
|
+
|
39
|
+
def deprecate_method(target_module, method_name)
|
40
|
+
deprecate_methods(target_module, method_name => target_module)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def deprecated_method_warning(method_name, target_module)
|
46
|
+
"#{target_module.name}##{method_name} field usage is deprecated"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
else
|
50
|
+
# TODO: remove this clause when Rails < 4 support is no longer needed
|
51
|
+
deprecator = ::ActiveSupport::Deprecation.clone
|
52
|
+
deprecator.instance_eval do
|
53
|
+
def new(deprecation_horizon = nil, *)
|
54
|
+
self.deprecation_horizon = deprecation_horizon if deprecation_horizon
|
55
|
+
self
|
56
|
+
end
|
57
|
+
end
|
58
|
+
Deprecation = deprecator.clone
|
59
|
+
FieldDeprecation = deprecator.clone
|
60
|
+
|
61
|
+
Deprecation.instance_eval do
|
62
|
+
def define_deprecated_methods(target_module, method_hash)
|
63
|
+
target_module.module_eval do
|
64
|
+
method_hash.each do |old_method, new_method|
|
65
|
+
alias_method old_method, new_method
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
deprecate_methods(target_module, method_hash)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
FieldDeprecation.instance_eval do
|
74
|
+
def deprecate_method(target_module, method_name)
|
75
|
+
deprecate_methods(target_module, method_name => target_module)
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def deprecated_method_warning(method_name, target_module)
|
81
|
+
"#{target_module.name}##{method_name} field usage is deprecated"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.deprecator
|
87
|
+
@deprecator ||= Deprecation.new('4.0', to_s).tap do |deprecation|
|
88
|
+
deprecation.silenced = ENV.key?('PB_IGNORE_DEPRECATIONS')
|
89
|
+
deprecation.behavior = :stderr
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.field_deprecator
|
94
|
+
@field_deprecator ||= FieldDeprecation.new.tap do |deprecation|
|
95
|
+
deprecation.silenced = ENV.key?('PB_IGNORE_DEPRECATIONS')
|
96
|
+
deprecation.behavior = :stderr
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Print Deprecation Warnings
|
101
|
+
#
|
102
|
+
# Default: true
|
103
|
+
#
|
104
|
+
# Simple boolean to define whether we want field deprecation warnings to
|
105
|
+
# be printed to stderr or not. The rpc_server has an option to set this value
|
106
|
+
# explicitly, or you can turn this option off by setting
|
107
|
+
# ENV['PB_IGNORE_DEPRECATIONS'] to a non-empty value.
|
108
|
+
#
|
109
|
+
# The rpc_server option will override the ENV setting.
|
110
|
+
def self.print_deprecation_warnings?
|
111
|
+
!field_deprecator.silenced
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.print_deprecation_warnings=(value)
|
115
|
+
field_deprecator.silenced = !value
|
116
|
+
end
|
117
|
+
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
##
|
2
4
|
# This file is auto-generated. DO NOT EDIT!
|
3
5
|
#
|
4
|
-
require 'protobuf
|
6
|
+
require 'protobuf'
|
5
7
|
|
6
8
|
|
7
9
|
##
|
@@ -12,6 +14,7 @@ require 'google/protobuf/descriptor.pb'
|
|
12
14
|
module Google
|
13
15
|
module Protobuf
|
14
16
|
module Compiler
|
17
|
+
::Protobuf::Optionable.inject(self) { ::Google::Protobuf::FileOptions }
|
15
18
|
|
16
19
|
##
|
17
20
|
# Message Classes
|
@@ -24,6 +27,13 @@ module Google
|
|
24
27
|
|
25
28
|
|
26
29
|
|
30
|
+
##
|
31
|
+
# File Options
|
32
|
+
#
|
33
|
+
set_option :java_package, "com.google.protobuf.compiler"
|
34
|
+
set_option :java_outer_classname, "PluginProtos"
|
35
|
+
|
36
|
+
|
27
37
|
##
|
28
38
|
# Message Fields
|
29
39
|
#
|
@@ -1,10 +1,13 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
##
|
2
4
|
# This file is auto-generated. DO NOT EDIT!
|
3
5
|
#
|
4
|
-
require 'protobuf
|
6
|
+
require 'protobuf'
|
5
7
|
|
6
8
|
module Google
|
7
9
|
module Protobuf
|
10
|
+
::Protobuf::Optionable.inject(self) { ::Google::Protobuf::FileOptions }
|
8
11
|
|
9
12
|
##
|
10
13
|
# Message Classes
|
@@ -13,6 +16,7 @@ module Google
|
|
13
16
|
class FileDescriptorProto < ::Protobuf::Message; end
|
14
17
|
class DescriptorProto < ::Protobuf::Message
|
15
18
|
class ExtensionRange < ::Protobuf::Message; end
|
19
|
+
class ReservedRange < ::Protobuf::Message; end
|
16
20
|
|
17
21
|
end
|
18
22
|
|
@@ -46,6 +50,7 @@ module Google
|
|
46
50
|
|
47
51
|
end
|
48
52
|
|
53
|
+
class OneofDescriptorProto < ::Protobuf::Message; end
|
49
54
|
class EnumDescriptorProto < ::Protobuf::Message; end
|
50
55
|
class EnumValueDescriptorProto < ::Protobuf::Message; end
|
51
56
|
class ServiceDescriptorProto < ::Protobuf::Message; end
|
@@ -67,6 +72,12 @@ module Google
|
|
67
72
|
define :STRING_PIECE, 2
|
68
73
|
end
|
69
74
|
|
75
|
+
class JSType < ::Protobuf::Enum
|
76
|
+
define :JS_NORMAL, 0
|
77
|
+
define :JS_STRING, 1
|
78
|
+
define :JS_NUMBER, 2
|
79
|
+
end
|
80
|
+
|
70
81
|
end
|
71
82
|
|
72
83
|
class EnumOptions < ::Protobuf::Message; end
|
@@ -85,6 +96,17 @@ module Google
|
|
85
96
|
|
86
97
|
|
87
98
|
|
99
|
+
##
|
100
|
+
# File Options
|
101
|
+
#
|
102
|
+
set_option :java_package, "com.google.protobuf"
|
103
|
+
set_option :java_outer_classname, "DescriptorProtos"
|
104
|
+
set_option :optimize_for, ::Google::Protobuf::FileOptions::OptimizeMode::SPEED
|
105
|
+
set_option :go_package, "descriptor"
|
106
|
+
set_option :objc_class_prefix, "GPB"
|
107
|
+
set_option :csharp_namespace, "Google.Protobuf.Reflection"
|
108
|
+
|
109
|
+
|
88
110
|
##
|
89
111
|
# Message Fields
|
90
112
|
#
|
@@ -104,6 +126,7 @@ module Google
|
|
104
126
|
repeated ::Google::Protobuf::FieldDescriptorProto, :extension, 7
|
105
127
|
optional ::Google::Protobuf::FileOptions, :options, 8
|
106
128
|
optional ::Google::Protobuf::SourceCodeInfo, :source_code_info, 9
|
129
|
+
optional :string, :syntax, 12
|
107
130
|
end
|
108
131
|
|
109
132
|
class DescriptorProto
|
@@ -112,13 +135,21 @@ module Google
|
|
112
135
|
optional :int32, :end, 2
|
113
136
|
end
|
114
137
|
|
138
|
+
class ReservedRange
|
139
|
+
optional :int32, :start, 1
|
140
|
+
optional :int32, :end, 2
|
141
|
+
end
|
142
|
+
|
115
143
|
optional :string, :name, 1
|
116
144
|
repeated ::Google::Protobuf::FieldDescriptorProto, :field, 2
|
117
145
|
repeated ::Google::Protobuf::FieldDescriptorProto, :extension, 6
|
118
146
|
repeated ::Google::Protobuf::DescriptorProto, :nested_type, 3
|
119
147
|
repeated ::Google::Protobuf::EnumDescriptorProto, :enum_type, 4
|
120
148
|
repeated ::Google::Protobuf::DescriptorProto::ExtensionRange, :extension_range, 5
|
149
|
+
repeated ::Google::Protobuf::OneofDescriptorProto, :oneof_decl, 8
|
121
150
|
optional ::Google::Protobuf::MessageOptions, :options, 7
|
151
|
+
repeated ::Google::Protobuf::DescriptorProto::ReservedRange, :reserved_range, 9
|
152
|
+
repeated :string, :reserved_name, 10
|
122
153
|
end
|
123
154
|
|
124
155
|
class FieldDescriptorProto
|
@@ -129,9 +160,15 @@ module Google
|
|
129
160
|
optional :string, :type_name, 6
|
130
161
|
optional :string, :extendee, 2
|
131
162
|
optional :string, :default_value, 7
|
163
|
+
optional :int32, :oneof_index, 9
|
164
|
+
optional :string, :json_name, 10
|
132
165
|
optional ::Google::Protobuf::FieldOptions, :options, 8
|
133
166
|
end
|
134
167
|
|
168
|
+
class OneofDescriptorProto
|
169
|
+
optional :string, :name, 1
|
170
|
+
end
|
171
|
+
|
135
172
|
class EnumDescriptorProto
|
136
173
|
optional :string, :name, 1
|
137
174
|
repeated ::Google::Protobuf::EnumValueDescriptorProto, :value, 2
|
@@ -155,6 +192,8 @@ module Google
|
|
155
192
|
optional :string, :input_type, 2
|
156
193
|
optional :string, :output_type, 3
|
157
194
|
optional ::Google::Protobuf::MethodOptions, :options, 4
|
195
|
+
optional :bool, :client_streaming, 5, :default => false
|
196
|
+
optional :bool, :server_streaming, 6, :default => false
|
158
197
|
end
|
159
198
|
|
160
199
|
class FileOptions
|
@@ -162,11 +201,17 @@ module Google
|
|
162
201
|
optional :string, :java_outer_classname, 8
|
163
202
|
optional :bool, :java_multiple_files, 10, :default => false
|
164
203
|
optional :bool, :java_generate_equals_and_hash, 20, :default => false
|
204
|
+
optional :bool, :java_string_check_utf8, 27, :default => false
|
165
205
|
optional ::Google::Protobuf::FileOptions::OptimizeMode, :optimize_for, 9, :default => ::Google::Protobuf::FileOptions::OptimizeMode::SPEED
|
166
206
|
optional :string, :go_package, 11
|
167
207
|
optional :bool, :cc_generic_services, 16, :default => false
|
168
208
|
optional :bool, :java_generic_services, 17, :default => false
|
169
209
|
optional :bool, :py_generic_services, 18, :default => false
|
210
|
+
optional :bool, :deprecated, 23, :default => false
|
211
|
+
optional :bool, :cc_enable_arenas, 31, :default => false
|
212
|
+
optional :string, :objc_class_prefix, 36
|
213
|
+
optional :string, :csharp_namespace, 37
|
214
|
+
optional :bool, :javanano_use_deprecated_package, 38
|
170
215
|
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
171
216
|
# Extension Fields
|
172
217
|
extensions 1000...536870912
|
@@ -175,6 +220,8 @@ module Google
|
|
175
220
|
class MessageOptions
|
176
221
|
optional :bool, :message_set_wire_format, 1, :default => false
|
177
222
|
optional :bool, :no_standard_descriptor_accessor, 2, :default => false
|
223
|
+
optional :bool, :deprecated, 3, :default => false
|
224
|
+
optional :bool, :map_entry, 7
|
178
225
|
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
179
226
|
# Extension Fields
|
180
227
|
extensions 1000...536870912
|
@@ -183,9 +230,9 @@ module Google
|
|
183
230
|
class FieldOptions
|
184
231
|
optional ::Google::Protobuf::FieldOptions::CType, :ctype, 1, :default => ::Google::Protobuf::FieldOptions::CType::STRING
|
185
232
|
optional :bool, :packed, 2
|
233
|
+
optional ::Google::Protobuf::FieldOptions::JSType, :jstype, 6, :default => ::Google::Protobuf::FieldOptions::JSType::JS_NORMAL
|
186
234
|
optional :bool, :lazy, 5, :default => false
|
187
235
|
optional :bool, :deprecated, 3, :default => false
|
188
|
-
optional :string, :experimental_map_key, 9
|
189
236
|
optional :bool, :weak, 10, :default => false
|
190
237
|
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
191
238
|
# Extension Fields
|
@@ -193,25 +240,29 @@ module Google
|
|
193
240
|
end
|
194
241
|
|
195
242
|
class EnumOptions
|
196
|
-
optional :bool, :allow_alias, 2
|
243
|
+
optional :bool, :allow_alias, 2
|
244
|
+
optional :bool, :deprecated, 3, :default => false
|
197
245
|
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
198
246
|
# Extension Fields
|
199
247
|
extensions 1000...536870912
|
200
248
|
end
|
201
249
|
|
202
250
|
class EnumValueOptions
|
251
|
+
optional :bool, :deprecated, 1, :default => false
|
203
252
|
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
204
253
|
# Extension Fields
|
205
254
|
extensions 1000...536870912
|
206
255
|
end
|
207
256
|
|
208
257
|
class ServiceOptions
|
258
|
+
optional :bool, :deprecated, 33, :default => false
|
209
259
|
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
210
260
|
# Extension Fields
|
211
261
|
extensions 1000...536870912
|
212
262
|
end
|
213
263
|
|
214
264
|
class MethodOptions
|
265
|
+
optional :bool, :deprecated, 33, :default => false
|
215
266
|
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
216
267
|
# Extension Fields
|
217
268
|
extensions 1000...536870912
|
@@ -238,6 +289,7 @@ module Google
|
|
238
289
|
repeated :int32, :span, 2, :packed => true
|
239
290
|
optional :string, :leading_comments, 3
|
240
291
|
optional :string, :trailing_comments, 4
|
292
|
+
repeated :string, :leading_detached_comments, 6
|
241
293
|
end
|
242
294
|
|
243
295
|
repeated ::Google::Protobuf::SourceCodeInfo::Location, :location, 1
|