protobuf-cucumber 3.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.rubocop.yml +70 -0
- data/.rubocop_todo.yml +145 -0
- data/.travis.yml +40 -0
- data/.yardopts +5 -0
- data/CHANGES.md +344 -0
- data/CONTRIBUTING.md +16 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +64 -0
- data/bin/protoc-gen-ruby +22 -0
- data/bin/rpc_server +5 -0
- data/install-protobuf.sh +28 -0
- data/lib/protobuf.rb +129 -0
- data/lib/protobuf/cli.rb +257 -0
- data/lib/protobuf/code_generator.rb +120 -0
- data/lib/protobuf/decoder.rb +28 -0
- data/lib/protobuf/deprecation.rb +117 -0
- data/lib/protobuf/descriptors.rb +3 -0
- data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +62 -0
- data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +301 -0
- data/lib/protobuf/encoder.rb +11 -0
- data/lib/protobuf/enum.rb +365 -0
- data/lib/protobuf/exceptions.rb +9 -0
- data/lib/protobuf/field.rb +74 -0
- data/lib/protobuf/field/base_field.rb +380 -0
- data/lib/protobuf/field/base_field_object_definitions.rb +504 -0
- data/lib/protobuf/field/bool_field.rb +64 -0
- data/lib/protobuf/field/bytes_field.rb +78 -0
- data/lib/protobuf/field/double_field.rb +25 -0
- data/lib/protobuf/field/enum_field.rb +61 -0
- data/lib/protobuf/field/field_array.rb +104 -0
- data/lib/protobuf/field/field_hash.rb +122 -0
- data/lib/protobuf/field/fixed32_field.rb +25 -0
- data/lib/protobuf/field/fixed64_field.rb +28 -0
- data/lib/protobuf/field/float_field.rb +43 -0
- data/lib/protobuf/field/int32_field.rb +21 -0
- data/lib/protobuf/field/int64_field.rb +34 -0
- data/lib/protobuf/field/integer_field.rb +23 -0
- data/lib/protobuf/field/message_field.rb +51 -0
- data/lib/protobuf/field/sfixed32_field.rb +27 -0
- data/lib/protobuf/field/sfixed64_field.rb +28 -0
- data/lib/protobuf/field/signed_integer_field.rb +29 -0
- data/lib/protobuf/field/sint32_field.rb +21 -0
- data/lib/protobuf/field/sint64_field.rb +21 -0
- data/lib/protobuf/field/string_field.rb +51 -0
- data/lib/protobuf/field/uint32_field.rb +21 -0
- data/lib/protobuf/field/uint64_field.rb +21 -0
- data/lib/protobuf/field/varint_field.rb +77 -0
- data/lib/protobuf/generators/base.rb +85 -0
- data/lib/protobuf/generators/enum_generator.rb +39 -0
- data/lib/protobuf/generators/extension_generator.rb +27 -0
- data/lib/protobuf/generators/field_generator.rb +193 -0
- data/lib/protobuf/generators/file_generator.rb +262 -0
- data/lib/protobuf/generators/group_generator.rb +122 -0
- data/lib/protobuf/generators/message_generator.rb +104 -0
- data/lib/protobuf/generators/option_generator.rb +17 -0
- data/lib/protobuf/generators/printable.rb +160 -0
- data/lib/protobuf/generators/service_generator.rb +50 -0
- data/lib/protobuf/lifecycle.rb +33 -0
- data/lib/protobuf/logging.rb +39 -0
- data/lib/protobuf/message.rb +260 -0
- data/lib/protobuf/message/fields.rb +233 -0
- data/lib/protobuf/message/serialization.rb +85 -0
- data/lib/protobuf/optionable.rb +70 -0
- data/lib/protobuf/rpc/buffer.rb +78 -0
- data/lib/protobuf/rpc/client.rb +140 -0
- data/lib/protobuf/rpc/connectors/base.rb +221 -0
- data/lib/protobuf/rpc/connectors/ping.rb +89 -0
- data/lib/protobuf/rpc/connectors/socket.rb +78 -0
- data/lib/protobuf/rpc/connectors/zmq.rb +319 -0
- data/lib/protobuf/rpc/dynamic_discovery.pb.rb +50 -0
- data/lib/protobuf/rpc/env.rb +60 -0
- data/lib/protobuf/rpc/error.rb +28 -0
- data/lib/protobuf/rpc/error/client_error.rb +31 -0
- data/lib/protobuf/rpc/error/server_error.rb +43 -0
- data/lib/protobuf/rpc/middleware.rb +25 -0
- data/lib/protobuf/rpc/middleware/exception_handler.rb +40 -0
- data/lib/protobuf/rpc/middleware/logger.rb +95 -0
- data/lib/protobuf/rpc/middleware/request_decoder.rb +79 -0
- data/lib/protobuf/rpc/middleware/response_encoder.rb +83 -0
- data/lib/protobuf/rpc/middleware/runner.rb +18 -0
- data/lib/protobuf/rpc/rpc.pb.rb +64 -0
- data/lib/protobuf/rpc/rpc_method.rb +16 -0
- data/lib/protobuf/rpc/server.rb +39 -0
- data/lib/protobuf/rpc/servers/socket/server.rb +121 -0
- data/lib/protobuf/rpc/servers/socket/worker.rb +56 -0
- data/lib/protobuf/rpc/servers/socket_runner.rb +46 -0
- data/lib/protobuf/rpc/servers/zmq/broker.rb +194 -0
- data/lib/protobuf/rpc/servers/zmq/server.rb +321 -0
- data/lib/protobuf/rpc/servers/zmq/util.rb +48 -0
- data/lib/protobuf/rpc/servers/zmq/worker.rb +105 -0
- data/lib/protobuf/rpc/servers/zmq_runner.rb +70 -0
- data/lib/protobuf/rpc/service.rb +172 -0
- data/lib/protobuf/rpc/service_directory.rb +261 -0
- data/lib/protobuf/rpc/service_dispatcher.rb +45 -0
- data/lib/protobuf/rpc/service_filters.rb +250 -0
- data/lib/protobuf/rpc/stat.rb +119 -0
- data/lib/protobuf/socket.rb +21 -0
- data/lib/protobuf/tasks.rb +1 -0
- data/lib/protobuf/tasks/compile.rake +80 -0
- data/lib/protobuf/varint.rb +20 -0
- data/lib/protobuf/varint_pure.rb +31 -0
- data/lib/protobuf/version.rb +3 -0
- data/lib/protobuf/wire_type.rb +10 -0
- data/lib/protobuf/zmq.rb +21 -0
- data/profile.html +5103 -0
- data/proto/dynamic_discovery.proto +44 -0
- data/proto/google/protobuf/compiler/plugin.proto +147 -0
- data/proto/google/protobuf/descriptor.proto +779 -0
- data/proto/rpc.proto +69 -0
- data/protobuf-cucumber.gemspec +57 -0
- data/spec/benchmark/tasks.rb +143 -0
- data/spec/bin/protoc-gen-ruby_spec.rb +23 -0
- data/spec/encoding/all_types_spec.rb +103 -0
- 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 +58 -0
- data/spec/functional/socket_server_spec.rb +59 -0
- data/spec/functional/zmq_server_spec.rb +105 -0
- data/spec/lib/protobuf/cli_spec.rb +317 -0
- data/spec/lib/protobuf/code_generator_spec.rb +87 -0
- data/spec/lib/protobuf/enum_spec.rb +307 -0
- 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 +44 -0
- data/spec/lib/protobuf/field/field_array_spec.rb +105 -0
- data/spec/lib/protobuf/field/field_hash_spec.rb +168 -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 +120 -0
- 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 +79 -0
- 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 +192 -0
- data/spec/lib/protobuf/generators/base_spec.rb +154 -0
- data/spec/lib/protobuf/generators/enum_generator_spec.rb +82 -0
- data/spec/lib/protobuf/generators/extension_generator_spec.rb +42 -0
- data/spec/lib/protobuf/generators/field_generator_spec.rb +197 -0
- data/spec/lib/protobuf/generators/file_generator_spec.rb +119 -0
- data/spec/lib/protobuf/generators/message_generator_spec.rb +0 -0
- data/spec/lib/protobuf/generators/service_generator_spec.rb +99 -0
- data/spec/lib/protobuf/lifecycle_spec.rb +94 -0
- data/spec/lib/protobuf/message_spec.rb +944 -0
- data/spec/lib/protobuf/optionable_spec.rb +265 -0
- data/spec/lib/protobuf/rpc/client_spec.rb +66 -0
- data/spec/lib/protobuf/rpc/connectors/base_spec.rb +226 -0
- data/spec/lib/protobuf/rpc/connectors/ping_spec.rb +69 -0
- data/spec/lib/protobuf/rpc/connectors/socket_spec.rb +34 -0
- data/spec/lib/protobuf/rpc/connectors/zmq_spec.rb +110 -0
- data/spec/lib/protobuf/rpc/middleware/exception_handler_spec.rb +62 -0
- data/spec/lib/protobuf/rpc/middleware/logger_spec.rb +49 -0
- data/spec/lib/protobuf/rpc/middleware/request_decoder_spec.rb +115 -0
- data/spec/lib/protobuf/rpc/middleware/response_encoder_spec.rb +91 -0
- data/spec/lib/protobuf/rpc/servers/socket_server_spec.rb +38 -0
- data/spec/lib/protobuf/rpc/servers/zmq/server_spec.rb +43 -0
- data/spec/lib/protobuf/rpc/servers/zmq/util_spec.rb +55 -0
- data/spec/lib/protobuf/rpc/servers/zmq/worker_spec.rb +35 -0
- data/spec/lib/protobuf/rpc/service_directory_spec.rb +293 -0
- data/spec/lib/protobuf/rpc/service_dispatcher_spec.rb +35 -0
- data/spec/lib/protobuf/rpc/service_filters_spec.rb +517 -0
- data/spec/lib/protobuf/rpc/service_spec.rb +162 -0
- data/spec/lib/protobuf/rpc/stat_spec.rb +101 -0
- data/spec/lib/protobuf/varint_spec.rb +29 -0
- data/spec/lib/protobuf_spec.rb +105 -0
- data/spec/spec_helper.rb +42 -0
- data/spec/support/all.rb +6 -0
- data/spec/support/packed_field.rb +23 -0
- data/spec/support/protos/all_types.data.bin +0 -0
- data/spec/support/protos/all_types.data.txt +119 -0
- data/spec/support/protos/enum.pb.rb +63 -0
- data/spec/support/protos/enum.proto +37 -0
- data/spec/support/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/protos/google_unittest.proto +884 -0
- data/spec/support/protos/google_unittest_custom_options.bin +0 -0
- data/spec/support/protos/google_unittest_custom_options.pb.rb +361 -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/protos/google_unittest_import.proto +73 -0
- data/spec/support/protos/google_unittest_import_public.pb.rb +31 -0
- data/spec/support/protos/google_unittest_import_public.proto +41 -0
- data/spec/support/protos/map-test.bin +157 -0
- data/spec/support/protos/map-test.pb.rb +85 -0
- data/spec/support/protos/map-test.proto +68 -0
- data/spec/support/protos/multi_field_extensions.pb.rb +59 -0
- data/spec/support/protos/multi_field_extensions.proto +35 -0
- data/spec/support/protos/resource.pb.rb +172 -0
- data/spec/support/protos/resource.proto +137 -0
- data/spec/support/resource_service.rb +23 -0
- data/spec/support/server.rb +65 -0
- data/spec/support/test_app_file.rb +2 -0
- data/varint_prof.rb +82 -0
- metadata +579 -0
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'active_support/core_ext/module/aliasing'
|
2
|
+
require 'protobuf/generators/file_generator'
|
3
|
+
|
4
|
+
module Protobuf
|
5
|
+
class CodeGenerator
|
6
|
+
|
7
|
+
CodeGeneratorFatalError = Class.new(RuntimeError)
|
8
|
+
|
9
|
+
def self.fatal(message)
|
10
|
+
fail CodeGeneratorFatalError, message
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.print_tag_warning_suppress
|
14
|
+
STDERR.puts "Suppress tag warning output with PB_NO_TAG_WARNINGS=1."
|
15
|
+
def self.print_tag_warning_suppress; end # rubocop:disable Lint/DuplicateMethods, Lint/NestedMethodDefinition
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.warn(message)
|
19
|
+
STDERR.puts("[WARN] #{message}")
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_accessor :request
|
25
|
+
|
26
|
+
public
|
27
|
+
|
28
|
+
def initialize(request_bytes)
|
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)
|
38
|
+
end
|
39
|
+
|
40
|
+
def generate_file(file_descriptor)
|
41
|
+
::Protobuf::Generators::FileGenerator.new(file_descriptor).generate_output_file
|
42
|
+
end
|
43
|
+
|
44
|
+
def response_bytes
|
45
|
+
generated_files = request.proto_file.map do |file_descriptor|
|
46
|
+
generate_file(file_descriptor)
|
47
|
+
end
|
48
|
+
|
49
|
+
::Google::Protobuf::Compiler::CodeGeneratorResponse.encode(:file => generated_files)
|
50
|
+
end
|
51
|
+
|
52
|
+
Protobuf::Field::BaseField.module_eval do
|
53
|
+
def define_set_method!
|
54
|
+
end
|
55
|
+
|
56
|
+
def set_without_options(message_instance, bytes)
|
57
|
+
return message_instance[name] = decode(bytes) unless repeated?
|
58
|
+
|
59
|
+
if map?
|
60
|
+
hash = message_instance[name]
|
61
|
+
entry = decode(bytes)
|
62
|
+
# decoded value could be nil for an
|
63
|
+
# enum value that is not recognized
|
64
|
+
hash[entry.key] = entry.value unless entry.value.nil?
|
65
|
+
return hash[entry.key]
|
66
|
+
end
|
67
|
+
|
68
|
+
return message_instance[name] << decode(bytes) unless packed?
|
69
|
+
|
70
|
+
array = message_instance[name]
|
71
|
+
stream = StringIO.new(bytes)
|
72
|
+
|
73
|
+
if wire_type == ::Protobuf::WireType::VARINT
|
74
|
+
array << decode(Varint.decode(stream)) until stream.eof?
|
75
|
+
elsif wire_type == ::Protobuf::WireType::FIXED64
|
76
|
+
array << decode(stream.read(8)) until stream.eof?
|
77
|
+
elsif wire_type == ::Protobuf::WireType::FIXED32
|
78
|
+
array << decode(stream.read(4)) until stream.eof?
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Sets a MessageField that is known to be an option.
|
83
|
+
# We must allow fields to be set one at a time, as option syntax allows us to
|
84
|
+
# set each field within the option using a separate "option" line.
|
85
|
+
def set_with_options(message_instance, bytes)
|
86
|
+
if message_instance[name].is_a?(::Protobuf::Message)
|
87
|
+
gp = Google::Protobuf
|
88
|
+
if message_instance.is_a?(gp::EnumOptions) || message_instance.is_a?(gp::EnumValueOptions) ||
|
89
|
+
message_instance.is_a?(gp::FieldOptions) || message_instance.is_a?(gp::FileOptions) ||
|
90
|
+
message_instance.is_a?(gp::MethodOptions) || message_instance.is_a?(gp::ServiceOptions) ||
|
91
|
+
message_instance.is_a?(gp::MessageOptions)
|
92
|
+
|
93
|
+
original_field = message_instance[name]
|
94
|
+
decoded_field = decode(bytes)
|
95
|
+
decoded_field.each_field do |subfield, subvalue|
|
96
|
+
option_set(original_field, subfield, subvalue) { decoded_field.field?(subfield.tag) }
|
97
|
+
end
|
98
|
+
return
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
set_without_options(message_instance, bytes)
|
103
|
+
end
|
104
|
+
alias_method :set, :set_with_options
|
105
|
+
|
106
|
+
def option_set(message_field, subfield, subvalue)
|
107
|
+
return unless yield
|
108
|
+
if subfield.repeated?
|
109
|
+
message_field[subfield.tag].concat(subvalue)
|
110
|
+
elsif message_field[subfield.tag] && subvalue.is_a?(::Protobuf::Message)
|
111
|
+
subvalue.each_field do |f, v|
|
112
|
+
option_set(message_field[subfield.tag], f, v) { subvalue.field?(f.tag) }
|
113
|
+
end
|
114
|
+
else
|
115
|
+
message_field[subfield.tag] = subvalue
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Protobuf
|
2
|
+
class Decoder
|
3
|
+
|
4
|
+
# Read bytes from +stream+ and pass to +message+ object.
|
5
|
+
def self.decode_each_field(stream)
|
6
|
+
until stream.eof?
|
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)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -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
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
##
|
4
|
+
# This file is auto-generated. DO NOT EDIT!
|
5
|
+
#
|
6
|
+
require 'protobuf'
|
7
|
+
|
8
|
+
|
9
|
+
##
|
10
|
+
# Imports
|
11
|
+
#
|
12
|
+
require 'google/protobuf/descriptor.pb'
|
13
|
+
|
14
|
+
module Google
|
15
|
+
module Protobuf
|
16
|
+
module Compiler
|
17
|
+
::Protobuf::Optionable.inject(self) { ::Google::Protobuf::FileOptions }
|
18
|
+
|
19
|
+
##
|
20
|
+
# Message Classes
|
21
|
+
#
|
22
|
+
class CodeGeneratorRequest < ::Protobuf::Message; end
|
23
|
+
class CodeGeneratorResponse < ::Protobuf::Message
|
24
|
+
class File < ::Protobuf::Message; end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
##
|
31
|
+
# File Options
|
32
|
+
#
|
33
|
+
set_option :java_package, "com.google.protobuf.compiler"
|
34
|
+
set_option :java_outer_classname, "PluginProtos"
|
35
|
+
|
36
|
+
|
37
|
+
##
|
38
|
+
# Message Fields
|
39
|
+
#
|
40
|
+
class CodeGeneratorRequest
|
41
|
+
repeated :string, :file_to_generate, 1
|
42
|
+
optional :string, :parameter, 2
|
43
|
+
repeated ::Google::Protobuf::FileDescriptorProto, :proto_file, 15
|
44
|
+
end
|
45
|
+
|
46
|
+
class CodeGeneratorResponse
|
47
|
+
class File
|
48
|
+
optional :string, :name, 1
|
49
|
+
optional :string, :insertion_point, 2
|
50
|
+
optional :string, :content, 15
|
51
|
+
end
|
52
|
+
|
53
|
+
optional :string, :error, 1
|
54
|
+
repeated ::Google::Protobuf::Compiler::CodeGeneratorResponse::File, :file, 15
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,301 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
##
|
4
|
+
# This file is auto-generated. DO NOT EDIT!
|
5
|
+
#
|
6
|
+
require 'protobuf'
|
7
|
+
|
8
|
+
module Google
|
9
|
+
module Protobuf
|
10
|
+
::Protobuf::Optionable.inject(self) { ::Google::Protobuf::FileOptions }
|
11
|
+
|
12
|
+
##
|
13
|
+
# Message Classes
|
14
|
+
#
|
15
|
+
class FileDescriptorSet < ::Protobuf::Message; end
|
16
|
+
class FileDescriptorProto < ::Protobuf::Message; end
|
17
|
+
class DescriptorProto < ::Protobuf::Message
|
18
|
+
class ExtensionRange < ::Protobuf::Message; end
|
19
|
+
class ReservedRange < ::Protobuf::Message; end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class FieldDescriptorProto < ::Protobuf::Message
|
24
|
+
class Type < ::Protobuf::Enum
|
25
|
+
define :TYPE_DOUBLE, 1
|
26
|
+
define :TYPE_FLOAT, 2
|
27
|
+
define :TYPE_INT64, 3
|
28
|
+
define :TYPE_UINT64, 4
|
29
|
+
define :TYPE_INT32, 5
|
30
|
+
define :TYPE_FIXED64, 6
|
31
|
+
define :TYPE_FIXED32, 7
|
32
|
+
define :TYPE_BOOL, 8
|
33
|
+
define :TYPE_STRING, 9
|
34
|
+
define :TYPE_GROUP, 10
|
35
|
+
define :TYPE_MESSAGE, 11
|
36
|
+
define :TYPE_BYTES, 12
|
37
|
+
define :TYPE_UINT32, 13
|
38
|
+
define :TYPE_ENUM, 14
|
39
|
+
define :TYPE_SFIXED32, 15
|
40
|
+
define :TYPE_SFIXED64, 16
|
41
|
+
define :TYPE_SINT32, 17
|
42
|
+
define :TYPE_SINT64, 18
|
43
|
+
end
|
44
|
+
|
45
|
+
class Label < ::Protobuf::Enum
|
46
|
+
define :LABEL_OPTIONAL, 1
|
47
|
+
define :LABEL_REQUIRED, 2
|
48
|
+
define :LABEL_REPEATED, 3
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
class OneofDescriptorProto < ::Protobuf::Message; end
|
54
|
+
class EnumDescriptorProto < ::Protobuf::Message; end
|
55
|
+
class EnumValueDescriptorProto < ::Protobuf::Message; end
|
56
|
+
class ServiceDescriptorProto < ::Protobuf::Message; end
|
57
|
+
class MethodDescriptorProto < ::Protobuf::Message; end
|
58
|
+
class FileOptions < ::Protobuf::Message
|
59
|
+
class OptimizeMode < ::Protobuf::Enum
|
60
|
+
define :SPEED, 1
|
61
|
+
define :CODE_SIZE, 2
|
62
|
+
define :LITE_RUNTIME, 3
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
class MessageOptions < ::Protobuf::Message; end
|
68
|
+
class FieldOptions < ::Protobuf::Message
|
69
|
+
class CType < ::Protobuf::Enum
|
70
|
+
define :STRING, 0
|
71
|
+
define :CORD, 1
|
72
|
+
define :STRING_PIECE, 2
|
73
|
+
end
|
74
|
+
|
75
|
+
class JSType < ::Protobuf::Enum
|
76
|
+
define :JS_NORMAL, 0
|
77
|
+
define :JS_STRING, 1
|
78
|
+
define :JS_NUMBER, 2
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
class EnumOptions < ::Protobuf::Message; end
|
84
|
+
class EnumValueOptions < ::Protobuf::Message; end
|
85
|
+
class ServiceOptions < ::Protobuf::Message; end
|
86
|
+
class MethodOptions < ::Protobuf::Message; end
|
87
|
+
class UninterpretedOption < ::Protobuf::Message
|
88
|
+
class NamePart < ::Protobuf::Message; end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
class SourceCodeInfo < ::Protobuf::Message
|
93
|
+
class Location < ::Protobuf::Message; end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
|
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
|
+
|
110
|
+
##
|
111
|
+
# Message Fields
|
112
|
+
#
|
113
|
+
class FileDescriptorSet
|
114
|
+
repeated ::Google::Protobuf::FileDescriptorProto, :file, 1
|
115
|
+
end
|
116
|
+
|
117
|
+
class FileDescriptorProto
|
118
|
+
optional :string, :name, 1
|
119
|
+
optional :string, :package, 2
|
120
|
+
repeated :string, :dependency, 3
|
121
|
+
repeated :int32, :public_dependency, 10
|
122
|
+
repeated :int32, :weak_dependency, 11
|
123
|
+
repeated ::Google::Protobuf::DescriptorProto, :message_type, 4
|
124
|
+
repeated ::Google::Protobuf::EnumDescriptorProto, :enum_type, 5
|
125
|
+
repeated ::Google::Protobuf::ServiceDescriptorProto, :service, 6
|
126
|
+
repeated ::Google::Protobuf::FieldDescriptorProto, :extension, 7
|
127
|
+
optional ::Google::Protobuf::FileOptions, :options, 8
|
128
|
+
optional ::Google::Protobuf::SourceCodeInfo, :source_code_info, 9
|
129
|
+
optional :string, :syntax, 12
|
130
|
+
end
|
131
|
+
|
132
|
+
class DescriptorProto
|
133
|
+
class ExtensionRange
|
134
|
+
optional :int32, :start, 1
|
135
|
+
optional :int32, :end, 2
|
136
|
+
end
|
137
|
+
|
138
|
+
class ReservedRange
|
139
|
+
optional :int32, :start, 1
|
140
|
+
optional :int32, :end, 2
|
141
|
+
end
|
142
|
+
|
143
|
+
optional :string, :name, 1
|
144
|
+
repeated ::Google::Protobuf::FieldDescriptorProto, :field, 2
|
145
|
+
repeated ::Google::Protobuf::FieldDescriptorProto, :extension, 6
|
146
|
+
repeated ::Google::Protobuf::DescriptorProto, :nested_type, 3
|
147
|
+
repeated ::Google::Protobuf::EnumDescriptorProto, :enum_type, 4
|
148
|
+
repeated ::Google::Protobuf::DescriptorProto::ExtensionRange, :extension_range, 5
|
149
|
+
repeated ::Google::Protobuf::OneofDescriptorProto, :oneof_decl, 8
|
150
|
+
optional ::Google::Protobuf::MessageOptions, :options, 7
|
151
|
+
repeated ::Google::Protobuf::DescriptorProto::ReservedRange, :reserved_range, 9
|
152
|
+
repeated :string, :reserved_name, 10
|
153
|
+
end
|
154
|
+
|
155
|
+
class FieldDescriptorProto
|
156
|
+
optional :string, :name, 1
|
157
|
+
optional :int32, :number, 3
|
158
|
+
optional ::Google::Protobuf::FieldDescriptorProto::Label, :label, 4
|
159
|
+
optional ::Google::Protobuf::FieldDescriptorProto::Type, :type, 5
|
160
|
+
optional :string, :type_name, 6
|
161
|
+
optional :string, :extendee, 2
|
162
|
+
optional :string, :default_value, 7
|
163
|
+
optional :int32, :oneof_index, 9
|
164
|
+
optional :string, :json_name, 10
|
165
|
+
optional ::Google::Protobuf::FieldOptions, :options, 8
|
166
|
+
end
|
167
|
+
|
168
|
+
class OneofDescriptorProto
|
169
|
+
optional :string, :name, 1
|
170
|
+
end
|
171
|
+
|
172
|
+
class EnumDescriptorProto
|
173
|
+
optional :string, :name, 1
|
174
|
+
repeated ::Google::Protobuf::EnumValueDescriptorProto, :value, 2
|
175
|
+
optional ::Google::Protobuf::EnumOptions, :options, 3
|
176
|
+
end
|
177
|
+
|
178
|
+
class EnumValueDescriptorProto
|
179
|
+
optional :string, :name, 1
|
180
|
+
optional :int32, :number, 2
|
181
|
+
optional ::Google::Protobuf::EnumValueOptions, :options, 3
|
182
|
+
end
|
183
|
+
|
184
|
+
class ServiceDescriptorProto
|
185
|
+
optional :string, :name, 1
|
186
|
+
repeated ::Google::Protobuf::MethodDescriptorProto, :method, 2
|
187
|
+
optional ::Google::Protobuf::ServiceOptions, :options, 3
|
188
|
+
end
|
189
|
+
|
190
|
+
class MethodDescriptorProto
|
191
|
+
optional :string, :name, 1
|
192
|
+
optional :string, :input_type, 2
|
193
|
+
optional :string, :output_type, 3
|
194
|
+
optional ::Google::Protobuf::MethodOptions, :options, 4
|
195
|
+
optional :bool, :client_streaming, 5, :default => false
|
196
|
+
optional :bool, :server_streaming, 6, :default => false
|
197
|
+
end
|
198
|
+
|
199
|
+
class FileOptions
|
200
|
+
optional :string, :java_package, 1
|
201
|
+
optional :string, :java_outer_classname, 8
|
202
|
+
optional :bool, :java_multiple_files, 10, :default => false
|
203
|
+
optional :bool, :java_generate_equals_and_hash, 20, :default => false
|
204
|
+
optional :bool, :java_string_check_utf8, 27, :default => false
|
205
|
+
optional ::Google::Protobuf::FileOptions::OptimizeMode, :optimize_for, 9, :default => ::Google::Protobuf::FileOptions::OptimizeMode::SPEED
|
206
|
+
optional :string, :go_package, 11
|
207
|
+
optional :bool, :cc_generic_services, 16, :default => false
|
208
|
+
optional :bool, :java_generic_services, 17, :default => false
|
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
|
215
|
+
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
216
|
+
# Extension Fields
|
217
|
+
extensions 1000...536870912
|
218
|
+
end
|
219
|
+
|
220
|
+
class MessageOptions
|
221
|
+
optional :bool, :message_set_wire_format, 1, :default => false
|
222
|
+
optional :bool, :no_standard_descriptor_accessor, 2, :default => false
|
223
|
+
optional :bool, :deprecated, 3, :default => false
|
224
|
+
optional :bool, :map_entry, 7
|
225
|
+
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
226
|
+
# Extension Fields
|
227
|
+
extensions 1000...536870912
|
228
|
+
end
|
229
|
+
|
230
|
+
class FieldOptions
|
231
|
+
optional ::Google::Protobuf::FieldOptions::CType, :ctype, 1, :default => ::Google::Protobuf::FieldOptions::CType::STRING
|
232
|
+
optional :bool, :packed, 2
|
233
|
+
optional ::Google::Protobuf::FieldOptions::JSType, :jstype, 6, :default => ::Google::Protobuf::FieldOptions::JSType::JS_NORMAL
|
234
|
+
optional :bool, :lazy, 5, :default => false
|
235
|
+
optional :bool, :deprecated, 3, :default => false
|
236
|
+
optional :bool, :weak, 10, :default => false
|
237
|
+
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
238
|
+
# Extension Fields
|
239
|
+
extensions 1000...536870912
|
240
|
+
end
|
241
|
+
|
242
|
+
class EnumOptions
|
243
|
+
optional :bool, :allow_alias, 2
|
244
|
+
optional :bool, :deprecated, 3, :default => false
|
245
|
+
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
246
|
+
# Extension Fields
|
247
|
+
extensions 1000...536870912
|
248
|
+
end
|
249
|
+
|
250
|
+
class EnumValueOptions
|
251
|
+
optional :bool, :deprecated, 1, :default => false
|
252
|
+
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
253
|
+
# Extension Fields
|
254
|
+
extensions 1000...536870912
|
255
|
+
end
|
256
|
+
|
257
|
+
class ServiceOptions
|
258
|
+
optional :bool, :deprecated, 33, :default => false
|
259
|
+
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
260
|
+
# Extension Fields
|
261
|
+
extensions 1000...536870912
|
262
|
+
end
|
263
|
+
|
264
|
+
class MethodOptions
|
265
|
+
optional :bool, :deprecated, 33, :default => false
|
266
|
+
repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
|
267
|
+
# Extension Fields
|
268
|
+
extensions 1000...536870912
|
269
|
+
end
|
270
|
+
|
271
|
+
class UninterpretedOption
|
272
|
+
class NamePart
|
273
|
+
required :string, :name_part, 1
|
274
|
+
required :bool, :is_extension, 2
|
275
|
+
end
|
276
|
+
|
277
|
+
repeated ::Google::Protobuf::UninterpretedOption::NamePart, :name, 2
|
278
|
+
optional :string, :identifier_value, 3
|
279
|
+
optional :uint64, :positive_int_value, 4
|
280
|
+
optional :int64, :negative_int_value, 5
|
281
|
+
optional :double, :double_value, 6
|
282
|
+
optional :bytes, :string_value, 7
|
283
|
+
optional :string, :aggregate_value, 8
|
284
|
+
end
|
285
|
+
|
286
|
+
class SourceCodeInfo
|
287
|
+
class Location
|
288
|
+
repeated :int32, :path, 1, :packed => true
|
289
|
+
repeated :int32, :span, 2, :packed => true
|
290
|
+
optional :string, :leading_comments, 3
|
291
|
+
optional :string, :trailing_comments, 4
|
292
|
+
repeated :string, :leading_detached_comments, 6
|
293
|
+
end
|
294
|
+
|
295
|
+
repeated ::Google::Protobuf::SourceCodeInfo::Location, :location, 1
|
296
|
+
end
|
297
|
+
|
298
|
+
end
|
299
|
+
|
300
|
+
end
|
301
|
+
|