protoc-gen-twirp_ruby 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97ca6bacf87a6e95b819a790aeb7b3e5f0d2498bfab796dab2dc0b18a9d7f210
4
- data.tar.gz: c6c0229b210c6fe1a963873082a56adfb92ce965af230978fb5589b97a143fcd
3
+ metadata.gz: 30f68aaf9f4bab30eb440d98f94cb4840712d18ce8dd44b846b1ba2b8c95878f
4
+ data.tar.gz: c6ca8284ee938254b60383cf3c38bb801940f758e460c0fd63cdf61468d0f9e1
5
5
  SHA512:
6
- metadata.gz: 14e1a8d938c16ec476ab6a511f0e6418452b168605bb89eb4bb30f8ac36299b261ef45d7f79b80658ce6676695daf79ddbd9f7f42da78985e04b006959bb14d2
7
- data.tar.gz: ee7fa75114eacaa2162c1615b102ea58c9669ed48e7b2813a20beb2a5094464e9caac4538a102865318960f1bf150da7e880c006314715001b4d9bc21f1b4eb8
6
+ metadata.gz: 55d98147c37865e774a5e5b68206b53fad68c25b7ac61a9a69a92bf09d0adb569a7e8175aae8dd281be1b94099b699a7830f18c7c256e78db00799b5cddb092b
7
+ data.tar.gz: b32badee47a22d048aef598801a4412e8cd85b5cc69d6f1665f88cb58fd0d3d7a0adca19145713a258529e480bef58cc5f98d14792f1b9c4e42d36c3c6d280b5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## [Unreleased]
2
2
 
3
+ - Nothing (yet)
4
+
5
+ ## [1.1.0] - 2024-05-21
6
+
7
+ - Add support for `ruby_package` option in proto files for generated output - [#28](https://github.com/collectiveidea/protoc-gen-twirp_ruby/pull/28)
8
+ - Update to `protoc` 26.1 to generate the plugin interface Ruby messages - [#27](https://github.com/collectiveidea/protoc-gen-twirp_ruby/pull/27)
9
+ - Add `generate=<service|client|both>` option to customize generated output - [#23](https://github.com/collectiveidea/protoc-gen-twirp_ruby/pull/23)
10
+ - Add `skip-empty` option to prevent generating empty scaffolding for proto files without services - [#21](https://github.com/collectiveidea/protoc-gen-twirp_ruby/pull/21)
11
+ - Refactor code generator to improve internal readability - [#12](https://github.com/collectiveidea/protoc-gen-twirp_ruby/pull/12), [#13](https://github.com/collectiveidea/protoc-gen-twirp_ruby/pull/13), [#22](https://github.com/collectiveidea/protoc-gen-twirp_ruby/pull/22), [#25](https://github.com/collectiveidea/protoc-gen-twirp_ruby/pull/25)
12
+ - Remove unnecessary extra files from packaged gem - [#11](https://github.com/collectiveidea/protoc-gen-twirp_ruby/pull/11)
13
+
3
14
  ## [1.0.0] - 2024-05-10
4
15
 
5
16
  - Initial release
data/README.md CHANGED
@@ -2,12 +2,13 @@
2
2
  [![Build](https://github.com/collectiveidea/protoc-gen-twirp_ruby/actions/workflows/main.yml/badge.svg)](https://github.com/collectiveidea/protoc-gen-twirp_ruby/actions/workflows/main.yml)
3
3
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/standardrb/standard)
4
4
 
5
- # protoc-gen-twirp_ruby
5
+ # protoc-gen-twirp_ruby
6
6
 
7
7
  This gem provides a `protoc` plugin that generates [Twirp-Ruby](https://github.com/arthurnn/twirp-ruby) services and clients.
8
8
 
9
- **NOTE:** Twirp-Ruby already has a protoc plugin available at https://github.com/arthurnn/twirp-ruby/tree/main/protoc-gen-twirp_ruby and released as a `go` module.
10
- This project creates an alternative plugin written in Ruby that is meant to be a more easily accessible alternative.
9
+ **NOTE:** Twirp-Ruby [already has a protoc plugin available](https://github.com/arthurnn/twirp-ruby/tree/main/protoc-gen-twirp_ruby)
10
+ released as a `go` module. This project creates an alternative plugin written in Ruby and distributed as a gem that
11
+ produces comparable output while being both more familiar and accessible to Ruby developers.
11
12
 
12
13
  ## Installation
13
14
 
@@ -19,22 +20,43 @@ The [Protocol Buffers](https://protobuf.dev) `protoc` command is used to auto-ge
19
20
  * Ubuntu/Debian: `sudo apt-get install -y protobuf`
20
21
  * Or download pre-compiled binaries: https://github.com/protocolbuffers/protobuf/releases
21
22
 
22
- `protoc` is able to read `.proto` files and generate the message parsers in multiple languages, including Ruby (using the `--ruby_out` option). It does not generate Twirp services and clients; that is where our plugin comes in.
23
+ `protoc` is able to read `.proto` files and generate the message parsers in multiple languages, including Ruby (using
24
+ the `--ruby_out` option). It does not generate Twirp services and clients; that is where our plugin comes in.
23
25
 
24
- ### Install the `protoc-gen-twirp_ruby ` plugin
26
+ ### Install the `protoc-gen-twirp_ruby` plugin
27
+
28
+ Install the gem by adding it to your Gemfile:
25
29
 
26
- Install the gem and add to the application's Gemfile by executing:
27
-
28
- ```bash
29
- bundle add protoc-gen-twirp_ruby --group "development, test"
30
+ ```ruby
31
+ group :development, :test do
32
+ "protoc-gen-twirp_ruby"
33
+ end
30
34
  ````
31
35
 
32
- If bundler is not being used to manage dependencies, install the gem by executing:
36
+ Alternatively, install the gem on your system:
33
37
 
34
38
  ```bash
35
39
  gem install protoc-gen-twirp_ruby
36
40
  ```
37
41
 
42
+ ## Migration from the `protoc-gen-twirp_ruby` go module
43
+
44
+ If you have previously installed the `go` version of the plugin via the [Twirp-Ruby Code Generation wiki page](https://github.com/arthurnn/twirp-ruby/wiki/Code-Generation)
45
+ instructions, then you'll want to uninstall it before invoking the `protoc` command.
46
+
47
+ ```bash
48
+ rm `go env GOPATH`/bin/protoc-gen-twirp_ruby
49
+ ```
50
+
51
+ ### Notable plugin differences
52
+
53
+ This gem generates nearly identical Twirp-Ruby output as the go version plugin. Some notable differences
54
+ that might affect migration include:
55
+
56
+ * Generated output code is in [standardrb style](https://github.com/standardrb/standard).
57
+ * Generated service and client class names are improved for well-named protobuf services. See [#6](https://github.com/collectiveidea/protoc-gen-twirp_ruby/pull/6).
58
+ * Supports various protoc command line [configuration options](https://github.com/collectiveidea/protoc-gen-twirp_ruby?tab=readme-ov-file#options).
59
+
38
60
  ## Usage
39
61
 
40
62
  Once `protoc` and the `protoc-gen-twirp_ruby` gem is installed, pass `--twirp_ruby_out` to generate Twirp-Ruby code:
@@ -43,6 +65,19 @@ Once `protoc` and the `protoc-gen-twirp_ruby` gem is installed, pass `--twirp_ru
43
65
  protoc --proto_path=. --ruby_out=. --twirp_ruby_out=. ./path/to/service.proto
44
66
  ```
45
67
 
68
+ ### Options
69
+
70
+ The plugin supports the following options to configure code generation. Pass options by
71
+ specifying `--twirp_ruby_opt=<option>` on the `protoc` command line.
72
+
73
+ * `skip-empty`: Avoid generating a `_twirp.rb` for a `.proto` with no service definitions. By default, a `_twirp.rb`
74
+ file is generated for every proto file listed on the command line, even if the file is empty scaffolding.
75
+ * `generate=<service|client|both>`: Customize generated output to include generated services, clients, or both.
76
+ * `generate=service` - only generate `::Twirp::Service` subclass(es).
77
+ * `generate=client` - only generate `::Twirp::Client` subclass(es).
78
+ * `generate=both` - generate both services and clients. This is the default option to preserve
79
+ backwards compatibility.
80
+
46
81
  ## Development
47
82
 
48
83
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -2,6 +2,19 @@
2
2
 
3
3
  # frozen_string_literal: true
4
4
 
5
- require_relative "../lib/twirp/protoc_plugin"
5
+ # Ensure `lib` is in the load path
6
+ lib = File.expand_path("../lib", __dir__)
7
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
8
 
7
- $stdout << Twirp::ProtocPlugin.process($stdin.read)
9
+ require "twirp/protoc_plugin"
10
+
11
+ begin
12
+ $stdout << Twirp::ProtocPlugin.process($stdin.read)
13
+ rescue ArgumentError => e
14
+ # Per the `CodeGeneratorResponse` message documentation in plugin.proto:
15
+ # Errors which indicate a problem in protoc itself -- such as the input
16
+ # CodeGeneratorRequest being unparseable -- should be reported by writing a
17
+ # message to stderr and exiting with a non-zero status code.
18
+ $stderr << e << "\n"
19
+ exit 1
20
+ end
@@ -10,29 +10,7 @@ require "google/protobuf/descriptor_pb"
10
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\"\x81\x02\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\x45\n\x17source_file_descriptors\x18\x11 \x03(\x0b\x32$.google.protobuf.FileDescriptorProto\x12;\n\x10\x63ompiler_version\x18\x03 \x01(\x0b\x32!.google.protobuf.compiler.Version\"\x92\x03\n\x15\x43odeGeneratorResponse\x12\r\n\x05\x65rror\x18\x01 \x01(\t\x12\x1a\n\x12supported_features\x18\x02 \x01(\x04\x12\x17\n\x0fminimum_edition\x18\x03 \x01(\x05\x12\x17\n\x0fmaximum_edition\x18\x04 \x01(\x05\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\"W\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\x12\x1d\n\x19\x46\x45\x41TURE_SUPPORTS_EDITIONS\x10\x02\x42r\n\x1c\x63om.google.protobuf.compilerB\x0cPluginProtosZ)google.golang.org/protobuf/types/pluginpb\xaa\x02\x18Google.Protobuf.Compiler"
11
11
 
12
12
  pool = Google::Protobuf::DescriptorPool.generated_pool
13
-
14
- begin
15
- pool.add_serialized_file(descriptor_data)
16
- rescue TypeError
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
13
+ pool.add_serialized_file(descriptor_data)
36
14
 
37
15
  module Google
38
16
  module Protobuf
@@ -5,30 +5,10 @@
5
5
 
6
6
  require "google/protobuf"
7
7
 
8
- descriptor_data = "\n google/protobuf/descriptor.proto\x12\x0fgoogle.protobuf\"G\n\x11\x46ileDescriptorSet\x12\x32\n\x04\x66ile\x18\x01 \x03(\x0b\x32$.google.protobuf.FileDescriptorProto\"\x86\x04\n\x13\x46ileDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07package\x18\x02 \x01(\t\x12\x12\n\ndependency\x18\x03 \x03(\t\x12\x19\n\x11public_dependency\x18\n \x03(\x05\x12\x17\n\x0fweak_dependency\x18\x0b \x03(\x05\x12\x36\n\x0cmessage_type\x18\x04 \x03(\x0b\x32 .google.protobuf.DescriptorProto\x12\x37\n\tenum_type\x18\x05 \x03(\x0b\x32$.google.protobuf.EnumDescriptorProto\x12\x38\n\x07service\x18\x06 \x03(\x0b\x32'.google.protobuf.ServiceDescriptorProto\x12\x38\n\textension\x18\x07 \x03(\x0b\x32%.google.protobuf.FieldDescriptorProto\x12-\n\x07options\x18\x08 \x01(\x0b\x32\x1c.google.protobuf.FileOptions\x12\x39\n\x10source_code_info\x18\t \x01(\x0b\x32\x1f.google.protobuf.SourceCodeInfo\x12\x0e\n\x06syntax\x18\x0c \x01(\t\x12)\n\x07\x65\x64ition\x18\x0e \x01(\x0e\x32\x18.google.protobuf.Edition\"\xa9\x05\n\x0f\x44\x65scriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x34\n\x05\x66ield\x18\x02 \x03(\x0b\x32%.google.protobuf.FieldDescriptorProto\x12\x38\n\textension\x18\x06 \x03(\x0b\x32%.google.protobuf.FieldDescriptorProto\x12\x35\n\x0bnested_type\x18\x03 \x03(\x0b\x32 .google.protobuf.DescriptorProto\x12\x37\n\tenum_type\x18\x04 \x03(\x0b\x32$.google.protobuf.EnumDescriptorProto\x12H\n\x0f\x65xtension_range\x18\x05 \x03(\x0b\x32/.google.protobuf.DescriptorProto.ExtensionRange\x12\x39\n\noneof_decl\x18\x08 \x03(\x0b\x32%.google.protobuf.OneofDescriptorProto\x12\x30\n\x07options\x18\x07 \x01(\x0b\x32\x1f.google.protobuf.MessageOptions\x12\x46\n\x0ereserved_range\x18\t \x03(\x0b\x32..google.protobuf.DescriptorProto.ReservedRange\x12\x15\n\rreserved_name\x18\n \x03(\t\x1a\x65\n\x0e\x45xtensionRange\x12\r\n\x05start\x18\x01 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x02 \x01(\x05\x12\x37\n\x07options\x18\x03 \x01(\x0b\x32&.google.protobuf.ExtensionRangeOptions\x1a+\n\rReservedRange\x12\r\n\x05start\x18\x01 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x02 \x01(\x05\"\xe5\x03\n\x15\x45xtensionRangeOptions\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\x12L\n\x0b\x64\x65\x63laration\x18\x02 \x03(\x0b\x32\x32.google.protobuf.ExtensionRangeOptions.DeclarationB\x03\x88\x01\x02\x12-\n\x08\x66\x65\x61tures\x18\x32 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12_\n\x0cverification\x18\x03 \x01(\x0e\x32\x38.google.protobuf.ExtensionRangeOptions.VerificationState:\nUNVERIFIEDB\x03\x88\x01\x02\x1ah\n\x0b\x44\x65\x63laration\x12\x0e\n\x06number\x18\x01 \x01(\x05\x12\x11\n\tfull_name\x18\x02 \x01(\t\x12\x0c\n\x04type\x18\x03 \x01(\t\x12\x10\n\x08reserved\x18\x05 \x01(\x08\x12\x10\n\x08repeated\x18\x06 \x01(\x08J\x04\x08\x04\x10\x05\"4\n\x11VerificationState\x12\x0f\n\x0b\x44\x45\x43LARATION\x10\x00\x12\x0e\n\nUNVERIFIED\x10\x01*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xd5\x05\n\x14\x46ieldDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06number\x18\x03 \x01(\x05\x12:\n\x05label\x18\x04 \x01(\x0e\x32+.google.protobuf.FieldDescriptorProto.Label\x12\x38\n\x04type\x18\x05 \x01(\x0e\x32*.google.protobuf.FieldDescriptorProto.Type\x12\x11\n\ttype_name\x18\x06 \x01(\t\x12\x10\n\x08\x65xtendee\x18\x02 \x01(\t\x12\x15\n\rdefault_value\x18\x07 \x01(\t\x12\x13\n\x0boneof_index\x18\t \x01(\x05\x12\x11\n\tjson_name\x18\n \x01(\t\x12.\n\x07options\x18\x08 \x01(\x0b\x32\x1d.google.protobuf.FieldOptions\x12\x17\n\x0fproto3_optional\x18\x11 \x01(\x08\"\xb6\x02\n\x04Type\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\"C\n\x05Label\x12\x12\n\x0eLABEL_OPTIONAL\x10\x01\x12\x12\n\x0eLABEL_REPEATED\x10\x03\x12\x12\n\x0eLABEL_REQUIRED\x10\x02\"T\n\x14OneofDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12.\n\x07options\x18\x02 \x01(\x0b\x32\x1d.google.protobuf.OneofOptions\"\xa4\x02\n\x13\x45numDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x38\n\x05value\x18\x02 \x03(\x0b\x32).google.protobuf.EnumValueDescriptorProto\x12-\n\x07options\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.EnumOptions\x12N\n\x0ereserved_range\x18\x04 \x03(\x0b\x32\x36.google.protobuf.EnumDescriptorProto.EnumReservedRange\x12\x15\n\rreserved_name\x18\x05 \x03(\t\x1a/\n\x11\x45numReservedRange\x12\r\n\x05start\x18\x01 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x02 \x01(\x05\"l\n\x18\x45numValueDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06number\x18\x02 \x01(\x05\x12\x32\n\x07options\x18\x03 \x01(\x0b\x32!.google.protobuf.EnumValueOptions\"\x90\x01\n\x16ServiceDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x36\n\x06method\x18\x02 \x03(\x0b\x32&.google.protobuf.MethodDescriptorProto\x12\x30\n\x07options\x18\x03 \x01(\x0b\x32\x1f.google.protobuf.ServiceOptions\"\xc1\x01\n\x15MethodDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\ninput_type\x18\x02 \x01(\t\x12\x13\n\x0boutput_type\x18\x03 \x01(\t\x12/\n\x07options\x18\x04 \x01(\x0b\x32\x1e.google.protobuf.MethodOptions\x12\x1f\n\x10\x63lient_streaming\x18\x05 \x01(\x08:\x05\x66\x61lse\x12\x1f\n\x10server_streaming\x18\x06 \x01(\x08:\x05\x66\x61lse\"\xb5\x06\n\x0b\x46ileOptions\x12\x14\n\x0cjava_package\x18\x01 \x01(\t\x12\x1c\n\x14java_outer_classname\x18\x08 \x01(\t\x12\"\n\x13java_multiple_files\x18\n \x01(\x08:\x05\x66\x61lse\x12)\n\x1djava_generate_equals_and_hash\x18\x14 \x01(\x08\x42\x02\x18\x01\x12%\n\x16java_string_check_utf8\x18\x1b \x01(\x08:\x05\x66\x61lse\x12\x46\n\x0coptimize_for\x18\t \x01(\x0e\x32).google.protobuf.FileOptions.OptimizeMode:\x05SPEED\x12\x12\n\ngo_package\x18\x0b \x01(\t\x12\"\n\x13\x63\x63_generic_services\x18\x10 \x01(\x08:\x05\x66\x61lse\x12$\n\x15java_generic_services\x18\x11 \x01(\x08:\x05\x66\x61lse\x12\"\n\x13py_generic_services\x18\x12 \x01(\x08:\x05\x66\x61lse\x12\x19\n\ndeprecated\x18\x17 \x01(\x08:\x05\x66\x61lse\x12\x1e\n\x10\x63\x63_enable_arenas\x18\x1f \x01(\x08:\x04true\x12\x19\n\x11objc_class_prefix\x18$ \x01(\t\x12\x18\n\x10\x63sharp_namespace\x18% \x01(\t\x12\x14\n\x0cswift_prefix\x18' \x01(\t\x12\x18\n\x10php_class_prefix\x18( \x01(\t\x12\x15\n\rphp_namespace\x18) \x01(\t\x12\x1e\n\x16php_metadata_namespace\x18, \x01(\t\x12\x14\n\x0cruby_package\x18- \x01(\t\x12-\n\x08\x66\x65\x61tures\x18\x32 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\":\n\x0cOptimizeMode\x12\t\n\x05SPEED\x10\x01\x12\r\n\tCODE_SIZE\x10\x02\x12\x10\n\x0cLITE_RUNTIME\x10\x03*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02J\x04\x08*\x10+J\x04\x08&\x10'\"\xe7\x02\n\x0eMessageOptions\x12&\n\x17message_set_wire_format\x18\x01 \x01(\x08:\x05\x66\x61lse\x12.\n\x1fno_standard_descriptor_accessor\x18\x02 \x01(\x08:\x05\x66\x61lse\x12\x19\n\ndeprecated\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x11\n\tmap_entry\x18\x07 \x01(\x08\x12\x32\n&deprecated_legacy_json_field_conflicts\x18\x0b \x01(\x08\x42\x02\x18\x01\x12-\n\x08\x66\x65\x61tures\x18\x0c \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02J\x04\x08\x04\x10\x05J\x04\x08\x05\x10\x06J\x04\x08\x06\x10\x07J\x04\x08\x08\x10\tJ\x04\x08\t\x10\n\"\xa3\x0b\n\x0c\x46ieldOptions\x12:\n\x05\x63type\x18\x01 \x01(\x0e\x32#.google.protobuf.FieldOptions.CType:\x06STRING\x12\x0e\n\x06packed\x18\x02 \x01(\x08\x12?\n\x06jstype\x18\x06 \x01(\x0e\x32$.google.protobuf.FieldOptions.JSType:\tJS_NORMAL\x12\x13\n\x04lazy\x18\x05 \x01(\x08:\x05\x66\x61lse\x12\x1e\n\x0funverified_lazy\x18\x0f \x01(\x08:\x05\x66\x61lse\x12\x19\n\ndeprecated\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x13\n\x04weak\x18\n \x01(\x08:\x05\x66\x61lse\x12\x1b\n\x0c\x64\x65\x62ug_redact\x18\x10 \x01(\x08:\x05\x66\x61lse\x12@\n\tretention\x18\x11 \x01(\x0e\x32-.google.protobuf.FieldOptions.OptionRetention\x12?\n\x07targets\x18\x13 \x03(\x0e\x32..google.protobuf.FieldOptions.OptionTargetType\x12\x46\n\x10\x65\x64ition_defaults\x18\x14 \x03(\x0b\x32,.google.protobuf.FieldOptions.EditionDefault\x12-\n\x08\x66\x65\x61tures\x18\x15 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x45\n\x0f\x66\x65\x61ture_support\x18\x16 \x01(\x0b\x32,.google.protobuf.FieldOptions.FeatureSupport\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\x1aJ\n\x0e\x45\x64itionDefault\x12)\n\x07\x65\x64ition\x18\x03 \x01(\x0e\x32\x18.google.protobuf.Edition\x12\r\n\x05value\x18\x02 \x01(\t\x1a\xcc\x01\n\x0e\x46\x65\x61tureSupport\x12\x34\n\x12\x65\x64ition_introduced\x18\x01 \x01(\x0e\x32\x18.google.protobuf.Edition\x12\x34\n\x12\x65\x64ition_deprecated\x18\x02 \x01(\x0e\x32\x18.google.protobuf.Edition\x12\x1b\n\x13\x64\x65precation_warning\x18\x03 \x01(\t\x12\x31\n\x0f\x65\x64ition_removed\x18\x04 \x01(\x0e\x32\x18.google.protobuf.Edition\"/\n\x05\x43Type\x12\n\n\x06STRING\x10\x00\x12\x08\n\x04\x43ORD\x10\x01\x12\x10\n\x0cSTRING_PIECE\x10\x02\"5\n\x06JSType\x12\r\n\tJS_NORMAL\x10\x00\x12\r\n\tJS_STRING\x10\x01\x12\r\n\tJS_NUMBER\x10\x02\"U\n\x0fOptionRetention\x12\x15\n\x11RETENTION_UNKNOWN\x10\x00\x12\x15\n\x11RETENTION_RUNTIME\x10\x01\x12\x14\n\x10RETENTION_SOURCE\x10\x02\"\x8c\x02\n\x10OptionTargetType\x12\x17\n\x13TARGET_TYPE_UNKNOWN\x10\x00\x12\x14\n\x10TARGET_TYPE_FILE\x10\x01\x12\x1f\n\x1bTARGET_TYPE_EXTENSION_RANGE\x10\x02\x12\x17\n\x13TARGET_TYPE_MESSAGE\x10\x03\x12\x15\n\x11TARGET_TYPE_FIELD\x10\x04\x12\x15\n\x11TARGET_TYPE_ONEOF\x10\x05\x12\x14\n\x10TARGET_TYPE_ENUM\x10\x06\x12\x1a\n\x16TARGET_TYPE_ENUM_ENTRY\x10\x07\x12\x17\n\x13TARGET_TYPE_SERVICE\x10\x08\x12\x16\n\x12TARGET_TYPE_METHOD\x10\t*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02J\x04\x08\x04\x10\x05J\x04\x08\x12\x10\x13\"\x8d\x01\n\x0cOneofOptions\x12-\n\x08\x66\x65\x61tures\x18\x01 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xf6\x01\n\x0b\x45numOptions\x12\x13\n\x0b\x61llow_alias\x18\x02 \x01(\x08\x12\x19\n\ndeprecated\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x32\n&deprecated_legacy_json_field_conflicts\x18\x06 \x01(\x08\x42\x02\x18\x01\x12-\n\x08\x66\x65\x61tures\x18\x07 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02J\x04\x08\x05\x10\x06\"\xc9\x01\n\x10\x45numValueOptions\x12\x19\n\ndeprecated\x18\x01 \x01(\x08:\x05\x66\x61lse\x12-\n\x08\x66\x65\x61tures\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x1b\n\x0c\x64\x65\x62ug_redact\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xaa\x01\n\x0eServiceOptions\x12-\n\x08\x66\x65\x61tures\x18\" \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x19\n\ndeprecated\x18! \x01(\x08:\x05\x66\x61lse\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xdc\x02\n\rMethodOptions\x12\x19\n\ndeprecated\x18! \x01(\x08:\x05\x66\x61lse\x12_\n\x11idempotency_level\x18\" \x01(\x0e\x32/.google.protobuf.MethodOptions.IdempotencyLevel:\x13IDEMPOTENCY_UNKNOWN\x12-\n\x08\x66\x65\x61tures\x18# \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\"P\n\x10IdempotencyLevel\x12\x17\n\x13IDEMPOTENCY_UNKNOWN\x10\x00\x12\x13\n\x0fNO_SIDE_EFFECTS\x10\x01\x12\x0e\n\nIDEMPOTENT\x10\x02*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\x9e\x02\n\x13UninterpretedOption\x12;\n\x04name\x18\x02 \x03(\x0b\x32-.google.protobuf.UninterpretedOption.NamePart\x12\x18\n\x10identifier_value\x18\x03 \x01(\t\x12\x1a\n\x12positive_int_value\x18\x04 \x01(\x04\x12\x1a\n\x12negative_int_value\x18\x05 \x01(\x03\x12\x14\n\x0c\x64ouble_value\x18\x06 \x01(\x01\x12\x14\n\x0cstring_value\x18\x07 \x01(\x0c\x12\x17\n\x0f\x61ggregate_value\x18\x08 \x01(\t\x1a\x33\n\x08NamePart\x12\x11\n\tname_part\x18\x01 \x02(\t\x12\x14\n\x0cis_extension\x18\x02 \x02(\x08\"\xdb\t\n\nFeatureSet\x12\x82\x01\n\x0e\x66ield_presence\x18\x01 \x01(\x0e\x32).google.protobuf.FeatureSet.FieldPresenceB?\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\r\x12\x08\x45XPLICIT\x18\xe6\x07\xa2\x01\r\x12\x08IMPLICIT\x18\xe7\x07\xa2\x01\r\x12\x08\x45XPLICIT\x18\xe8\x07\xb2\x01\x03\x08\xe8\x07\x12\x62\n\tenum_type\x18\x02 \x01(\x0e\x32$.google.protobuf.FeatureSet.EnumTypeB)\x88\x01\x01\x98\x01\x06\x98\x01\x01\xa2\x01\x0b\x12\x06\x43LOSED\x18\xe6\x07\xa2\x01\t\x12\x04OPEN\x18\xe7\x07\xb2\x01\x03\x08\xe8\x07\x12\x81\x01\n\x17repeated_field_encoding\x18\x03 \x01(\x0e\x32\x31.google.protobuf.FeatureSet.RepeatedFieldEncodingB-\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\r\x12\x08\x45XPANDED\x18\xe6\x07\xa2\x01\x0b\x12\x06PACKED\x18\xe7\x07\xb2\x01\x03\x08\xe8\x07\x12n\n\x0futf8_validation\x18\x04 \x01(\x0e\x32*.google.protobuf.FeatureSet.Utf8ValidationB)\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\t\x12\x04NONE\x18\xe6\x07\xa2\x01\x0b\x12\x06VERIFY\x18\xe7\x07\xb2\x01\x03\x08\xe8\x07\x12m\n\x10message_encoding\x18\x05 \x01(\x0e\x32+.google.protobuf.FeatureSet.MessageEncodingB&\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\x14\x12\x0fLENGTH_PREFIXED\x18\xe6\x07\xb2\x01\x03\x08\xe8\x07\x12v\n\x0bjson_format\x18\x06 \x01(\x0e\x32&.google.protobuf.FeatureSet.JsonFormatB9\x88\x01\x01\x98\x01\x03\x98\x01\x06\x98\x01\x01\xa2\x01\x17\x12\x12LEGACY_BEST_EFFORT\x18\xe6\x07\xa2\x01\n\x12\x05\x41LLOW\x18\xe7\x07\xb2\x01\x03\x08\xe8\x07\"\\\n\rFieldPresence\x12\x1a\n\x16\x46IELD_PRESENCE_UNKNOWN\x10\x00\x12\x0c\n\x08\x45XPLICIT\x10\x01\x12\x0c\n\x08IMPLICIT\x10\x02\x12\x13\n\x0fLEGACY_REQUIRED\x10\x03\"7\n\x08\x45numType\x12\x15\n\x11\x45NUM_TYPE_UNKNOWN\x10\x00\x12\x08\n\x04OPEN\x10\x01\x12\n\n\x06\x43LOSED\x10\x02\"V\n\x15RepeatedFieldEncoding\x12#\n\x1fREPEATED_FIELD_ENCODING_UNKNOWN\x10\x00\x12\n\n\x06PACKED\x10\x01\x12\x0c\n\x08\x45XPANDED\x10\x02\"C\n\x0eUtf8Validation\x12\x1b\n\x17UTF8_VALIDATION_UNKNOWN\x10\x00\x12\n\n\x06VERIFY\x10\x02\x12\x08\n\x04NONE\x10\x03\"S\n\x0fMessageEncoding\x12\x1c\n\x18MESSAGE_ENCODING_UNKNOWN\x10\x00\x12\x13\n\x0fLENGTH_PREFIXED\x10\x01\x12\r\n\tDELIMITED\x10\x02\"H\n\nJsonFormat\x12\x17\n\x13JSON_FORMAT_UNKNOWN\x10\x00\x12\t\n\x05\x41LLOW\x10\x01\x12\x16\n\x12LEGACY_BEST_EFFORT\x10\x02*\x06\x08\xe8\x07\x10\xe9\x07*\x06\x08\xe9\x07\x10\xea\x07*\x06\x08\xea\x07\x10\xeb\x07*\x06\x08\x86N\x10\x87N*\x06\x08\x8bN\x10\x90N*\x06\x08\x90N\x10\x91NJ\x06\x08\xe7\x07\x10\xe8\x07\"\x82\x03\n\x12\x46\x65\x61tureSetDefaults\x12N\n\x08\x64\x65\x66\x61ults\x18\x01 \x03(\x0b\x32<.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault\x12\x31\n\x0fminimum_edition\x18\x04 \x01(\x0e\x32\x18.google.protobuf.Edition\x12\x31\n\x0fmaximum_edition\x18\x05 \x01(\x0e\x32\x18.google.protobuf.Edition\x1a\xb5\x01\n\x18\x46\x65\x61tureSetEditionDefault\x12)\n\x07\x65\x64ition\x18\x03 \x01(\x0e\x32\x18.google.protobuf.Edition\x12\x39\n\x14overridable_features\x18\x04 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x33\n\x0e\x66ixed_features\x18\x05 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\"\xd5\x01\n\x0eSourceCodeInfo\x12:\n\x08location\x18\x01 \x03(\x0b\x32(.google.protobuf.SourceCodeInfo.Location\x1a\x86\x01\n\x08Location\x12\x10\n\x04path\x18\x01 \x03(\x05\x42\x02\x10\x01\x12\x10\n\x04span\x18\x02 \x03(\x05\x42\x02\x10\x01\x12\x18\n\x10leading_comments\x18\x03 \x01(\t\x12\x19\n\x11trailing_comments\x18\x04 \x01(\t\x12!\n\x19leading_detached_comments\x18\x06 \x03(\t\"\x9c\x02\n\x11GeneratedCodeInfo\x12\x41\n\nannotation\x18\x01 \x03(\x0b\x32-.google.protobuf.GeneratedCodeInfo.Annotation\x1a\xc3\x01\n\nAnnotation\x12\x10\n\x04path\x18\x01 \x03(\x05\x42\x02\x10\x01\x12\x13\n\x0bsource_file\x18\x02 \x01(\t\x12\r\n\x05\x62\x65gin\x18\x03 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x04 \x01(\x05\x12H\n\x08semantic\x18\x05 \x01(\x0e\x32\x36.google.protobuf.GeneratedCodeInfo.Annotation.Semantic\"(\n\x08Semantic\x12\x08\n\x04NONE\x10\x00\x12\x07\n\x03SET\x10\x01\x12\t\n\x05\x41LIAS\x10\x02*\xa7\x02\n\x07\x45\x64ition\x12\x13\n\x0f\x45\x44ITION_UNKNOWN\x10\x00\x12\x13\n\x0e\x45\x44ITION_LEGACY\x10\x84\x07\x12\x13\n\x0e\x45\x44ITION_PROTO2\x10\xe6\x07\x12\x13\n\x0e\x45\x44ITION_PROTO3\x10\xe7\x07\x12\x11\n\x0c\x45\x44ITION_2023\x10\xe8\x07\x12\x11\n\x0c\x45\x44ITION_2024\x10\xe9\x07\x12\x17\n\x13\x45\x44ITION_1_TEST_ONLY\x10\x01\x12\x17\n\x13\x45\x44ITION_2_TEST_ONLY\x10\x02\x12\x1d\n\x17\x45\x44ITION_99997_TEST_ONLY\x10\x9d\x8d\x06\x12\x1d\n\x17\x45\x44ITION_99998_TEST_ONLY\x10\x9e\x8d\x06\x12\x1d\n\x17\x45\x44ITION_99999_TEST_ONLY\x10\x9f\x8d\x06\x12\x13\n\x0b\x45\x44ITION_MAX\x10\xff\xff\xff\xff\x07\x42~\n\x13\x63om.google.protobufB\x10\x44\x65scriptorProtosH\x01Z-google.golang.org/protobuf/types/descriptorpb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1aGoogle.Protobuf.Reflection"
8
+ descriptor_data = "\n google/protobuf/descriptor.proto\x12\x0fgoogle.protobuf\"G\n\x11\x46ileDescriptorSet\x12\x32\n\x04\x66ile\x18\x01 \x03(\x0b\x32$.google.protobuf.FileDescriptorProto\"\x86\x04\n\x13\x46ileDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07package\x18\x02 \x01(\t\x12\x12\n\ndependency\x18\x03 \x03(\t\x12\x19\n\x11public_dependency\x18\n \x03(\x05\x12\x17\n\x0fweak_dependency\x18\x0b \x03(\x05\x12\x36\n\x0cmessage_type\x18\x04 \x03(\x0b\x32 .google.protobuf.DescriptorProto\x12\x37\n\tenum_type\x18\x05 \x03(\x0b\x32$.google.protobuf.EnumDescriptorProto\x12\x38\n\x07service\x18\x06 \x03(\x0b\x32'.google.protobuf.ServiceDescriptorProto\x12\x38\n\textension\x18\x07 \x03(\x0b\x32%.google.protobuf.FieldDescriptorProto\x12-\n\x07options\x18\x08 \x01(\x0b\x32\x1c.google.protobuf.FileOptions\x12\x39\n\x10source_code_info\x18\t \x01(\x0b\x32\x1f.google.protobuf.SourceCodeInfo\x12\x0e\n\x06syntax\x18\x0c \x01(\t\x12)\n\x07\x65\x64ition\x18\x0e \x01(\x0e\x32\x18.google.protobuf.Edition\"\xa9\x05\n\x0f\x44\x65scriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x34\n\x05\x66ield\x18\x02 \x03(\x0b\x32%.google.protobuf.FieldDescriptorProto\x12\x38\n\textension\x18\x06 \x03(\x0b\x32%.google.protobuf.FieldDescriptorProto\x12\x35\n\x0bnested_type\x18\x03 \x03(\x0b\x32 .google.protobuf.DescriptorProto\x12\x37\n\tenum_type\x18\x04 \x03(\x0b\x32$.google.protobuf.EnumDescriptorProto\x12H\n\x0f\x65xtension_range\x18\x05 \x03(\x0b\x32/.google.protobuf.DescriptorProto.ExtensionRange\x12\x39\n\noneof_decl\x18\x08 \x03(\x0b\x32%.google.protobuf.OneofDescriptorProto\x12\x30\n\x07options\x18\x07 \x01(\x0b\x32\x1f.google.protobuf.MessageOptions\x12\x46\n\x0ereserved_range\x18\t \x03(\x0b\x32..google.protobuf.DescriptorProto.ReservedRange\x12\x15\n\rreserved_name\x18\n \x03(\t\x1a\x65\n\x0e\x45xtensionRange\x12\r\n\x05start\x18\x01 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x02 \x01(\x05\x12\x37\n\x07options\x18\x03 \x01(\x0b\x32&.google.protobuf.ExtensionRangeOptions\x1a+\n\rReservedRange\x12\r\n\x05start\x18\x01 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x02 \x01(\x05\"\xe5\x03\n\x15\x45xtensionRangeOptions\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\x12L\n\x0b\x64\x65\x63laration\x18\x02 \x03(\x0b\x32\x32.google.protobuf.ExtensionRangeOptions.DeclarationB\x03\x88\x01\x02\x12-\n\x08\x66\x65\x61tures\x18\x32 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12_\n\x0cverification\x18\x03 \x01(\x0e\x32\x38.google.protobuf.ExtensionRangeOptions.VerificationState:\nUNVERIFIEDB\x03\x88\x01\x02\x1ah\n\x0b\x44\x65\x63laration\x12\x0e\n\x06number\x18\x01 \x01(\x05\x12\x11\n\tfull_name\x18\x02 \x01(\t\x12\x0c\n\x04type\x18\x03 \x01(\t\x12\x10\n\x08reserved\x18\x05 \x01(\x08\x12\x10\n\x08repeated\x18\x06 \x01(\x08J\x04\x08\x04\x10\x05\"4\n\x11VerificationState\x12\x0f\n\x0b\x44\x45\x43LARATION\x10\x00\x12\x0e\n\nUNVERIFIED\x10\x01*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xd5\x05\n\x14\x46ieldDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06number\x18\x03 \x01(\x05\x12:\n\x05label\x18\x04 \x01(\x0e\x32+.google.protobuf.FieldDescriptorProto.Label\x12\x38\n\x04type\x18\x05 \x01(\x0e\x32*.google.protobuf.FieldDescriptorProto.Type\x12\x11\n\ttype_name\x18\x06 \x01(\t\x12\x10\n\x08\x65xtendee\x18\x02 \x01(\t\x12\x15\n\rdefault_value\x18\x07 \x01(\t\x12\x13\n\x0boneof_index\x18\t \x01(\x05\x12\x11\n\tjson_name\x18\n \x01(\t\x12.\n\x07options\x18\x08 \x01(\x0b\x32\x1d.google.protobuf.FieldOptions\x12\x17\n\x0fproto3_optional\x18\x11 \x01(\x08\"\xb6\x02\n\x04Type\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\"C\n\x05Label\x12\x12\n\x0eLABEL_OPTIONAL\x10\x01\x12\x12\n\x0eLABEL_REPEATED\x10\x03\x12\x12\n\x0eLABEL_REQUIRED\x10\x02\"T\n\x14OneofDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12.\n\x07options\x18\x02 \x01(\x0b\x32\x1d.google.protobuf.OneofOptions\"\xa4\x02\n\x13\x45numDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x38\n\x05value\x18\x02 \x03(\x0b\x32).google.protobuf.EnumValueDescriptorProto\x12-\n\x07options\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.EnumOptions\x12N\n\x0ereserved_range\x18\x04 \x03(\x0b\x32\x36.google.protobuf.EnumDescriptorProto.EnumReservedRange\x12\x15\n\rreserved_name\x18\x05 \x03(\t\x1a/\n\x11\x45numReservedRange\x12\r\n\x05start\x18\x01 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x02 \x01(\x05\"l\n\x18\x45numValueDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06number\x18\x02 \x01(\x05\x12\x32\n\x07options\x18\x03 \x01(\x0b\x32!.google.protobuf.EnumValueOptions\"\x90\x01\n\x16ServiceDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x36\n\x06method\x18\x02 \x03(\x0b\x32&.google.protobuf.MethodDescriptorProto\x12\x30\n\x07options\x18\x03 \x01(\x0b\x32\x1f.google.protobuf.ServiceOptions\"\xc1\x01\n\x15MethodDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\ninput_type\x18\x02 \x01(\t\x12\x13\n\x0boutput_type\x18\x03 \x01(\t\x12/\n\x07options\x18\x04 \x01(\x0b\x32\x1e.google.protobuf.MethodOptions\x12\x1f\n\x10\x63lient_streaming\x18\x05 \x01(\x08:\x05\x66\x61lse\x12\x1f\n\x10server_streaming\x18\x06 \x01(\x08:\x05\x66\x61lse\"\xb5\x06\n\x0b\x46ileOptions\x12\x14\n\x0cjava_package\x18\x01 \x01(\t\x12\x1c\n\x14java_outer_classname\x18\x08 \x01(\t\x12\"\n\x13java_multiple_files\x18\n \x01(\x08:\x05\x66\x61lse\x12)\n\x1djava_generate_equals_and_hash\x18\x14 \x01(\x08\x42\x02\x18\x01\x12%\n\x16java_string_check_utf8\x18\x1b \x01(\x08:\x05\x66\x61lse\x12\x46\n\x0coptimize_for\x18\t \x01(\x0e\x32).google.protobuf.FileOptions.OptimizeMode:\x05SPEED\x12\x12\n\ngo_package\x18\x0b \x01(\t\x12\"\n\x13\x63\x63_generic_services\x18\x10 \x01(\x08:\x05\x66\x61lse\x12$\n\x15java_generic_services\x18\x11 \x01(\x08:\x05\x66\x61lse\x12\"\n\x13py_generic_services\x18\x12 \x01(\x08:\x05\x66\x61lse\x12\x19\n\ndeprecated\x18\x17 \x01(\x08:\x05\x66\x61lse\x12\x1e\n\x10\x63\x63_enable_arenas\x18\x1f \x01(\x08:\x04true\x12\x19\n\x11objc_class_prefix\x18$ \x01(\t\x12\x18\n\x10\x63sharp_namespace\x18% \x01(\t\x12\x14\n\x0cswift_prefix\x18' \x01(\t\x12\x18\n\x10php_class_prefix\x18( \x01(\t\x12\x15\n\rphp_namespace\x18) \x01(\t\x12\x1e\n\x16php_metadata_namespace\x18, \x01(\t\x12\x14\n\x0cruby_package\x18- \x01(\t\x12-\n\x08\x66\x65\x61tures\x18\x32 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\":\n\x0cOptimizeMode\x12\t\n\x05SPEED\x10\x01\x12\r\n\tCODE_SIZE\x10\x02\x12\x10\n\x0cLITE_RUNTIME\x10\x03*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02J\x04\x08*\x10+J\x04\x08&\x10'\"\xe7\x02\n\x0eMessageOptions\x12&\n\x17message_set_wire_format\x18\x01 \x01(\x08:\x05\x66\x61lse\x12.\n\x1fno_standard_descriptor_accessor\x18\x02 \x01(\x08:\x05\x66\x61lse\x12\x19\n\ndeprecated\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x11\n\tmap_entry\x18\x07 \x01(\x08\x12\x32\n&deprecated_legacy_json_field_conflicts\x18\x0b \x01(\x08\x42\x02\x18\x01\x12-\n\x08\x66\x65\x61tures\x18\x0c \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02J\x04\x08\x04\x10\x05J\x04\x08\x05\x10\x06J\x04\x08\x06\x10\x07J\x04\x08\x08\x10\tJ\x04\x08\t\x10\n\"\x8d\t\n\x0c\x46ieldOptions\x12:\n\x05\x63type\x18\x01 \x01(\x0e\x32#.google.protobuf.FieldOptions.CType:\x06STRING\x12\x0e\n\x06packed\x18\x02 \x01(\x08\x12?\n\x06jstype\x18\x06 \x01(\x0e\x32$.google.protobuf.FieldOptions.JSType:\tJS_NORMAL\x12\x13\n\x04lazy\x18\x05 \x01(\x08:\x05\x66\x61lse\x12\x1e\n\x0funverified_lazy\x18\x0f \x01(\x08:\x05\x66\x61lse\x12\x19\n\ndeprecated\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x13\n\x04weak\x18\n \x01(\x08:\x05\x66\x61lse\x12\x1b\n\x0c\x64\x65\x62ug_redact\x18\x10 \x01(\x08:\x05\x66\x61lse\x12@\n\tretention\x18\x11 \x01(\x0e\x32-.google.protobuf.FieldOptions.OptionRetention\x12?\n\x07targets\x18\x13 \x03(\x0e\x32..google.protobuf.FieldOptions.OptionTargetType\x12\x46\n\x10\x65\x64ition_defaults\x18\x14 \x03(\x0b\x32,.google.protobuf.FieldOptions.EditionDefault\x12-\n\x08\x66\x65\x61tures\x18\x15 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\x1aJ\n\x0e\x45\x64itionDefault\x12)\n\x07\x65\x64ition\x18\x03 \x01(\x0e\x32\x18.google.protobuf.Edition\x12\r\n\x05value\x18\x02 \x01(\t\"/\n\x05\x43Type\x12\n\n\x06STRING\x10\x00\x12\x08\n\x04\x43ORD\x10\x01\x12\x10\n\x0cSTRING_PIECE\x10\x02\"5\n\x06JSType\x12\r\n\tJS_NORMAL\x10\x00\x12\r\n\tJS_STRING\x10\x01\x12\r\n\tJS_NUMBER\x10\x02\"U\n\x0fOptionRetention\x12\x15\n\x11RETENTION_UNKNOWN\x10\x00\x12\x15\n\x11RETENTION_RUNTIME\x10\x01\x12\x14\n\x10RETENTION_SOURCE\x10\x02\"\x8c\x02\n\x10OptionTargetType\x12\x17\n\x13TARGET_TYPE_UNKNOWN\x10\x00\x12\x14\n\x10TARGET_TYPE_FILE\x10\x01\x12\x1f\n\x1bTARGET_TYPE_EXTENSION_RANGE\x10\x02\x12\x17\n\x13TARGET_TYPE_MESSAGE\x10\x03\x12\x15\n\x11TARGET_TYPE_FIELD\x10\x04\x12\x15\n\x11TARGET_TYPE_ONEOF\x10\x05\x12\x14\n\x10TARGET_TYPE_ENUM\x10\x06\x12\x1a\n\x16TARGET_TYPE_ENUM_ENTRY\x10\x07\x12\x17\n\x13TARGET_TYPE_SERVICE\x10\x08\x12\x16\n\x12TARGET_TYPE_METHOD\x10\t*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02J\x04\x08\x04\x10\x05J\x04\x08\x12\x10\x13\"\x8d\x01\n\x0cOneofOptions\x12-\n\x08\x66\x65\x61tures\x18\x01 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xf6\x01\n\x0b\x45numOptions\x12\x13\n\x0b\x61llow_alias\x18\x02 \x01(\x08\x12\x19\n\ndeprecated\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x32\n&deprecated_legacy_json_field_conflicts\x18\x06 \x01(\x08\x42\x02\x18\x01\x12-\n\x08\x66\x65\x61tures\x18\x07 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02J\x04\x08\x05\x10\x06\"\xc9\x01\n\x10\x45numValueOptions\x12\x19\n\ndeprecated\x18\x01 \x01(\x08:\x05\x66\x61lse\x12-\n\x08\x66\x65\x61tures\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x1b\n\x0c\x64\x65\x62ug_redact\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xaa\x01\n\x0eServiceOptions\x12-\n\x08\x66\x65\x61tures\x18\" \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x19\n\ndeprecated\x18! \x01(\x08:\x05\x66\x61lse\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xdc\x02\n\rMethodOptions\x12\x19\n\ndeprecated\x18! \x01(\x08:\x05\x66\x61lse\x12_\n\x11idempotency_level\x18\" \x01(\x0e\x32/.google.protobuf.MethodOptions.IdempotencyLevel:\x13IDEMPOTENCY_UNKNOWN\x12-\n\x08\x66\x65\x61tures\x18# \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\"P\n\x10IdempotencyLevel\x12\x17\n\x13IDEMPOTENCY_UNKNOWN\x10\x00\x12\x13\n\x0fNO_SIDE_EFFECTS\x10\x01\x12\x0e\n\nIDEMPOTENT\x10\x02*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\x9e\x02\n\x13UninterpretedOption\x12;\n\x04name\x18\x02 \x03(\x0b\x32-.google.protobuf.UninterpretedOption.NamePart\x12\x18\n\x10identifier_value\x18\x03 \x01(\t\x12\x1a\n\x12positive_int_value\x18\x04 \x01(\x04\x12\x1a\n\x12negative_int_value\x18\x05 \x01(\x03\x12\x14\n\x0c\x64ouble_value\x18\x06 \x01(\x01\x12\x14\n\x0cstring_value\x18\x07 \x01(\x0c\x12\x17\n\x0f\x61ggregate_value\x18\x08 \x01(\t\x1a\x33\n\x08NamePart\x12\x11\n\tname_part\x18\x01 \x02(\t\x12\x14\n\x0cis_extension\x18\x02 \x02(\x08\"\xad\t\n\nFeatureSet\x12|\n\x0e\x66ield_presence\x18\x01 \x01(\x0e\x32).google.protobuf.FeatureSet.FieldPresenceB9\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\r\x12\x08\x45XPLICIT\x18\xe6\x07\xa2\x01\r\x12\x08IMPLICIT\x18\xe7\x07\xa2\x01\r\x12\x08\x45XPLICIT\x18\xe8\x07\x12\\\n\tenum_type\x18\x02 \x01(\x0e\x32$.google.protobuf.FeatureSet.EnumTypeB#\x88\x01\x01\x98\x01\x06\x98\x01\x01\xa2\x01\x0b\x12\x06\x43LOSED\x18\xe6\x07\xa2\x01\t\x12\x04OPEN\x18\xe7\x07\x12{\n\x17repeated_field_encoding\x18\x03 \x01(\x0e\x32\x31.google.protobuf.FeatureSet.RepeatedFieldEncodingB'\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\r\x12\x08\x45XPANDED\x18\xe6\x07\xa2\x01\x0b\x12\x06PACKED\x18\xe7\x07\x12h\n\x0futf8_validation\x18\x04 \x01(\x0e\x32*.google.protobuf.FeatureSet.Utf8ValidationB#\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\t\x12\x04NONE\x18\xe6\x07\xa2\x01\x0b\x12\x06VERIFY\x18\xe7\x07\x12g\n\x10message_encoding\x18\x05 \x01(\x0e\x32+.google.protobuf.FeatureSet.MessageEncodingB \x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\x14\x12\x0fLENGTH_PREFIXED\x18\xe6\x07\x12p\n\x0bjson_format\x18\x06 \x01(\x0e\x32&.google.protobuf.FeatureSet.JsonFormatB3\x88\x01\x01\x98\x01\x03\x98\x01\x06\x98\x01\x01\xa2\x01\x17\x12\x12LEGACY_BEST_EFFORT\x18\xe6\x07\xa2\x01\n\x12\x05\x41LLOW\x18\xe7\x07\"\\\n\rFieldPresence\x12\x1a\n\x16\x46IELD_PRESENCE_UNKNOWN\x10\x00\x12\x0c\n\x08\x45XPLICIT\x10\x01\x12\x0c\n\x08IMPLICIT\x10\x02\x12\x13\n\x0fLEGACY_REQUIRED\x10\x03\"7\n\x08\x45numType\x12\x15\n\x11\x45NUM_TYPE_UNKNOWN\x10\x00\x12\x08\n\x04OPEN\x10\x01\x12\n\n\x06\x43LOSED\x10\x02\"V\n\x15RepeatedFieldEncoding\x12#\n\x1fREPEATED_FIELD_ENCODING_UNKNOWN\x10\x00\x12\n\n\x06PACKED\x10\x01\x12\x0c\n\x08\x45XPANDED\x10\x02\"C\n\x0eUtf8Validation\x12\x1b\n\x17UTF8_VALIDATION_UNKNOWN\x10\x00\x12\n\n\x06VERIFY\x10\x02\x12\x08\n\x04NONE\x10\x03\"S\n\x0fMessageEncoding\x12\x1c\n\x18MESSAGE_ENCODING_UNKNOWN\x10\x00\x12\x13\n\x0fLENGTH_PREFIXED\x10\x01\x12\r\n\tDELIMITED\x10\x02\"H\n\nJsonFormat\x12\x17\n\x13JSON_FORMAT_UNKNOWN\x10\x00\x12\t\n\x05\x41LLOW\x10\x01\x12\x16\n\x12LEGACY_BEST_EFFORT\x10\x02*\x06\x08\xe8\x07\x10\xe9\x07*\x06\x08\xe9\x07\x10\xea\x07*\x06\x08\xea\x07\x10\xeb\x07*\x06\x08\x8bN\x10\x90N*\x06\x08\x90N\x10\x91NJ\x06\x08\xe7\x07\x10\xe8\x07\"\xc0\x02\n\x12\x46\x65\x61tureSetDefaults\x12N\n\x08\x64\x65\x66\x61ults\x18\x01 \x03(\x0b\x32<.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault\x12\x31\n\x0fminimum_edition\x18\x04 \x01(\x0e\x32\x18.google.protobuf.Edition\x12\x31\n\x0fmaximum_edition\x18\x05 \x01(\x0e\x32\x18.google.protobuf.Edition\x1at\n\x18\x46\x65\x61tureSetEditionDefault\x12)\n\x07\x65\x64ition\x18\x03 \x01(\x0e\x32\x18.google.protobuf.Edition\x12-\n\x08\x66\x65\x61tures\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.FeatureSet\"\xd5\x01\n\x0eSourceCodeInfo\x12:\n\x08location\x18\x01 \x03(\x0b\x32(.google.protobuf.SourceCodeInfo.Location\x1a\x86\x01\n\x08Location\x12\x10\n\x04path\x18\x01 \x03(\x05\x42\x02\x10\x01\x12\x10\n\x04span\x18\x02 \x03(\x05\x42\x02\x10\x01\x12\x18\n\x10leading_comments\x18\x03 \x01(\t\x12\x19\n\x11trailing_comments\x18\x04 \x01(\t\x12!\n\x19leading_detached_comments\x18\x06 \x03(\t\"\x9c\x02\n\x11GeneratedCodeInfo\x12\x41\n\nannotation\x18\x01 \x03(\x0b\x32-.google.protobuf.GeneratedCodeInfo.Annotation\x1a\xc3\x01\n\nAnnotation\x12\x10\n\x04path\x18\x01 \x03(\x05\x42\x02\x10\x01\x12\x13\n\x0bsource_file\x18\x02 \x01(\t\x12\r\n\x05\x62\x65gin\x18\x03 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x04 \x01(\x05\x12H\n\x08semantic\x18\x05 \x01(\x0e\x32\x36.google.protobuf.GeneratedCodeInfo.Annotation.Semantic\"(\n\x08Semantic\x12\x08\n\x04NONE\x10\x00\x12\x07\n\x03SET\x10\x01\x12\t\n\x05\x41LIAS\x10\x02*\x92\x02\n\x07\x45\x64ition\x12\x13\n\x0f\x45\x44ITION_UNKNOWN\x10\x00\x12\x13\n\x0e\x45\x44ITION_PROTO2\x10\xe6\x07\x12\x13\n\x0e\x45\x44ITION_PROTO3\x10\xe7\x07\x12\x11\n\x0c\x45\x44ITION_2023\x10\xe8\x07\x12\x11\n\x0c\x45\x44ITION_2024\x10\xe9\x07\x12\x17\n\x13\x45\x44ITION_1_TEST_ONLY\x10\x01\x12\x17\n\x13\x45\x44ITION_2_TEST_ONLY\x10\x02\x12\x1d\n\x17\x45\x44ITION_99997_TEST_ONLY\x10\x9d\x8d\x06\x12\x1d\n\x17\x45\x44ITION_99998_TEST_ONLY\x10\x9e\x8d\x06\x12\x1d\n\x17\x45\x44ITION_99999_TEST_ONLY\x10\x9f\x8d\x06\x12\x13\n\x0b\x45\x44ITION_MAX\x10\xff\xff\xff\xff\x07\x42~\n\x13\x63om.google.protobufB\x10\x44\x65scriptorProtosH\x01Z-google.golang.org/protobuf/types/descriptorpb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1aGoogle.Protobuf.Reflection"
9
9
 
10
10
  pool = Google::Protobuf::DescriptorPool.generated_pool
11
-
12
- begin
13
- pool.add_serialized_file(descriptor_data)
14
- rescue TypeError
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
- imports.each do |type_name, expected_filename|
24
- import_file = pool.lookup(type_name).file_descriptor
25
- if import_file.name != expected_filename
26
- warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
27
- end
28
- end
29
- warn "Each proto file must use a consistent fully-qualified name."
30
- warn "This will become an error in the next major version."
31
- end
11
+ pool.add_serialized_file(descriptor_data)
32
12
 
33
13
  module Google
34
14
  module Protobuf
@@ -54,7 +34,6 @@ module Google
54
34
  MessageOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.MessageOptions").msgclass
55
35
  FieldOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions").msgclass
56
36
  FieldOptions::EditionDefault = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.EditionDefault").msgclass
57
- FieldOptions::FeatureSupport = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.FeatureSupport").msgclass
58
37
  FieldOptions::CType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.CType").enummodule
59
38
  FieldOptions::JSType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.JSType").enummodule
60
39
  FieldOptions::OptionRetention = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.OptionRetention").enummodule
@@ -1,91 +1,68 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../google/protobuf/compiler/plugin_pb"
4
3
  require "stringio"
4
+ require "google/protobuf/compiler/plugin_pb"
5
+ require "twirp/protoc_plugin/core_ext/string/snake_case"
6
+ require "twirp/protoc_plugin/descriptor_ext/service_descriptor_proto_ext"
5
7
 
6
8
  module Twirp
7
9
  module ProtocPlugin
8
10
  class CodeGenerator
9
11
  # @param proto_file [Google::Protobuf::FileDescriptorProto]
10
12
  # @param relative_ruby_protobuf [String] e.g. "example_rb.pb"
11
- def initialize(proto_file, relative_ruby_protobuf)
13
+ # @param options [Hash{Symbol => Boolean, Symbol}]
14
+ # * :skip_empty [Boolean] indicating whether generation should skip creating a twirp file
15
+ # for proto files that contain no services.
16
+ # * :generate [Symbol] one of: :service, :client, or :both.
17
+ def initialize(proto_file, relative_ruby_protobuf, options)
12
18
  @proto_file = proto_file
13
19
  @relative_ruby_protobuf = relative_ruby_protobuf
20
+ @options = options
14
21
  end
15
22
 
16
23
  # @return [String] the generated Twirp::Ruby code for the proto_file
17
24
  def generate
18
25
  output = StringIO.new
19
- output << <<~PREAMBLE
26
+ output << <<~START
20
27
  # frozen_string_literal: true
21
28
 
22
29
  # Generated by the protoc-gen-twirp_ruby gem v#{VERSION}. DO NOT EDIT!
23
30
  # source: #{@proto_file.name}
24
-
25
- PREAMBLE
26
31
 
27
- output << <<~REQUIRES
28
32
  require "twirp"
29
33
  require_relative "#{@relative_ruby_protobuf}"
30
-
31
- REQUIRES
34
+
35
+ START
32
36
 
33
37
  indent_level = 0
34
- modules = split_to_constants(@proto_file.package)
38
+ modules = @proto_file.ruby_module.delete_prefix("::").split("::")
35
39
 
36
40
  modules.each do |mod|
37
41
  output << line("module #{mod}", indent_level)
38
42
  indent_level += 1
39
43
  end
40
44
 
41
- current_module = "::" + modules.join("::")
45
+ unless @proto_file.has_service?
46
+ output << line("# No services found; To skip generating this file, specify `--twirp_ruby_opt=skip-empty`.", indent_level)
47
+ end
42
48
 
43
49
  @proto_file.service.each_with_index do |service, index| # service: <Google::Protobuf::ServiceDescriptorProto>
44
- # Add newline between service definitions when multiple are generated
50
+ # Add newline between definitions when multiple are generated
45
51
  output << "\n" if index > 0
46
52
 
47
- service_name = service.name
48
- # The generated service class name should end in "Service"; Only append the
49
- # suffix if the service is not already well-named.
50
- service_class_name = if service_name.end_with?("Service")
51
- service_name
52
- else
53
- service_name + "Service"
53
+ if %i[service both].include?(@options[:generate])
54
+ generate_service_class(output, indent_level, service)
54
55
  end
55
56
 
56
- # Generate service class
57
- output << line("class #{camel_case(service_class_name)} < ::Twirp::Service", indent_level)
58
- indent_level += 1
57
+ if @options[:generate] == :both
58
+ # Space between generated service and client when generating both
59
+ output << "\n"
59
60
 
60
- output << line("package \"#{@proto_file.package}\"", indent_level) unless @proto_file.package.to_s.empty?
61
- output << line("service \"#{service_name}\"", indent_level)
62
- service["method"].each do |method| # method: <Google::Protobuf::MethodDescriptorProto>
63
- output << rpc_line(
64
- method.name,
65
- convert_to_ruby_type(method.input_type, current_module),
66
- convert_to_ruby_type(method.output_type, current_module),
67
- snake_case(method.name),
68
- indent_level
69
- )
61
+ generate_client_class_for_service(output, indent_level, service)
62
+ elsif @options[:generate] == :client
63
+ # When generating only the client, we can't use the `client_for` DSL.
64
+ generate_client_class_standalone(output, indent_level, service)
70
65
  end
71
-
72
- indent_level -= 1
73
- output << line("end", indent_level)
74
-
75
- output << "\n"
76
-
77
- # Generate client class
78
-
79
- # Strip the "Service" suffix if present for better readability.
80
- client_class_name = service_name.delete_suffix("Service") + "Client"
81
-
82
- output << line("class #{camel_case(client_class_name)} < ::Twirp::Client", indent_level)
83
- indent_level += 1
84
-
85
- output << line("client_for #{camel_case(service_class_name)}", indent_level)
86
-
87
- indent_level -= 1
88
- output << line("end", indent_level)
89
66
  end
90
67
 
91
68
  modules.each do |_|
@@ -108,93 +85,63 @@ module Twirp
108
85
  "#{" " * indent_level}#{input}\n"
109
86
  end
110
87
 
111
- # @return [String] the `rpc` DSL line for a method within a service
112
- def rpc_line(rpc_name, rpc_input, rpc_output, rpc_ruby_method, indent_level)
113
- line("rpc :#{rpc_name}, #{rpc_input}, #{rpc_output}, ruby_method: :#{rpc_ruby_method}", indent_level)
114
- end
115
-
116
- # Converts either a package string like ".some.example.api" or a namespaced
117
- # message like "google.protobuf.Empty" to an Array of Strings that can be
118
- # used as Ruby constants (when joined with "::").
119
- #
120
- # ".some.example.api" becomes ["", Some", "Example", "Api"]
121
- # "google.protobuf.Empty" becomes ["Google", "Protobuf", "Empty"]
122
- #
123
- # @param package_or_message [String]
124
- # @return [Array<String>]
125
- def split_to_constants(package_or_message)
126
- package_or_message
127
- .split(".")
128
- .map { |s| camel_case(s) }
129
- end
130
-
131
- # Converts a protobuf message type to a string containing
132
- # the equivalent Ruby constant.
88
+ # Generates a Twirp::Service subclass for the given service class, adding the
89
+ # string to the output.
133
90
  #
134
- # Examples:
135
- #
136
- # convert_to_ruby_type("example_message") => "ExampleMessage"
137
- # convert_to_ruby_type(".foo.bar.example_message") => "::Foo::Bar::ExampleMessage"
138
- # convert_to_ruby_type(".foo.bar.example_message", "::Foo") => "Bar::ExampleMessage"
139
- # convert_to_ruby_type(".foo.bar.example_message", "::Foo::Bar") => "ExampleMessage"
140
- # convert_to_ruby_type("google.protobuf.Empty", "::Foo") => "Google::Protobuf::Empty"
141
- #
142
- # @param message_type [String]
143
- # @param current_module [String, nil]
144
- # @return [String]
145
- def convert_to_ruby_type(message_type, current_module = nil)
146
- s = split_to_constants(message_type).join("::")
147
-
148
- if !current_module.nil? && s.start_with?(current_module)
149
- # Strip current module and trailing "::" prefix
150
- s[current_module.size + 2..]
151
- else
152
- s
91
+ # @param output [#<<] the output to append the generated service code to
92
+ # @param indent_level [Integer] the number of double spaces to indent the generated code by
93
+ # @param service [Google::Protobuf::ServiceDescriptorProto]
94
+ # @return [void]
95
+ def generate_service_class(output, indent_level, service)
96
+ output << line("class #{service.service_class_name} < ::Twirp::Service", indent_level)
97
+ output << line(" package \"#{@proto_file.package}\"", indent_level) unless @proto_file.package.to_s.empty?
98
+ output << line(" service \"#{service.name}\"", indent_level)
99
+ service["method"].each do |method| # method: <Google::Protobuf::MethodDescriptorProto>
100
+ input_type = @proto_file.ruby_type_for(method.input_type)
101
+ output_type = @proto_file.ruby_type_for(method.output_type)
102
+ ruby_method_name = method.name.snake_case
103
+
104
+ output << line(" rpc :#{method.name}, #{input_type}, #{output_type}, ruby_method: :#{ruby_method_name}", indent_level)
153
105
  end
106
+ output << line("end", indent_level)
154
107
  end
155
108
 
156
- # Converts input to either lowerCamelCase or UpperCamelCase.
109
+ # Generates a Twirp::Client subclass for the given service class, adding the
110
+ # string to the output.
157
111
  #
158
- # Inspired by https://github.com/rails/rails/blob/6f0d1ad14b92b9f5906e44740fce8b4f1c7075dc/activesupport/lib/active_support/inflector/methods.rb#L70
159
- #
160
- # @param input [String] the input string to convert to CamelCase
161
- # @param uppercase_first_letter [Boolean] true for UpperCamelCase, false for lowerCamelCase
162
- # @return [String] the converted input
163
- def camel_case(input, uppercase_first_letter = true)
164
- s = if uppercase_first_letter
165
- capitalize_first(input)
166
- else
167
- input
168
- end
169
-
170
- s.gsub(/_([a-z\d]*)/i) do
171
- $1.capitalize
172
- end
173
- end
174
-
175
- # Capitalizes the first letter in the input string.,
176
- #
177
- # Inspired by https://github.com/rails/rails/blob/6f0d1ad14b92b9f5906e44740fce8b4f1c7075dc/activesupport/lib/active_support/inflector/methods.rb#L166
178
- #
179
- # @param input [String] the input string to capitalize the first letter of
180
- # @return [String] the input with the first letter capitalized
181
- def capitalize_first(input)
182
- return "" unless input.length > 0
183
-
184
- input[0].upcase + input[1..]
112
+ # @param output [#<<] the output to append the generated service code to
113
+ # @param indent_level [Integer] the number of double spaces to indent the generated code by
114
+ # @param service [Google::Protobuf::ServiceDescriptorProto]
115
+ # @return [void]
116
+ def generate_client_class_for_service(output, indent_level, service)
117
+ output << line("class #{service.client_class_name} < ::Twirp::Client", indent_level)
118
+ output << line(" client_for #{service.service_class_name}", indent_level)
119
+ output << line("end", indent_level)
185
120
  end
186
121
 
187
- # Converts input to lower_snake_case.
122
+ # Generates a Twirp::Client subclass standalone, without using the `client_for` DSL because
123
+ # there is no corresponding service to reference.
188
124
  #
189
- # Inspired by https://github.com/rails/rails/blob/6f0d1ad14b92b9f5906e44740fce8b4f1c7075dc/activesupport/lib/active_support/inflector/methods.rb#L99
125
+ # This essentially in-lines the `client_for` logic from
126
+ # https://github.com/arthurnn/twirp-ruby/blob/v1.11.0/lib/twirp/client.rb#L31
190
127
  #
191
- # @param input [String] the input string to convert to lower_snake_case
192
- # @return [String] the converted input
193
- def snake_case(input)
194
- input
195
- .gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
196
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
197
- .downcase
128
+ # @param output [#<<] the output to append the generated service code to
129
+ # @param indent_level [Integer] the number of double spaces to indent the generated code by
130
+ # @param service [Google::Protobuf::ServiceDescriptorProto]
131
+ # @return [void]
132
+ def generate_client_class_standalone(output, indent_level, service)
133
+ output << line("class #{service.client_class_name} < ::Twirp::Client", indent_level)
134
+ output << line(" package \"#{@proto_file.package}\"", indent_level) unless @proto_file.package.to_s.empty?
135
+ output << line(" service \"#{service.name}\"", indent_level)
136
+ service["method"].each do |method| # method: <Google::Protobuf::MethodDescriptorProto>
137
+ input_type = @proto_file.ruby_type_for(method.input_type)
138
+ output_type = @proto_file.ruby_type_for(method.output_type)
139
+ ruby_method_name = method.name.snake_case
140
+
141
+ # TRICKY: The service `rpc` DSL accepts a method symbol, but the client `rpc` DSL expects a string.
142
+ output << line(" rpc \"#{method.name}\", #{input_type}, #{output_type}, ruby_method: :#{ruby_method_name}", indent_level)
143
+ end
144
+ output << line("end", indent_level)
198
145
  end
199
146
  end
200
147
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "google/protobuf/compiler/plugin_pb"
4
+ require "twirp/protoc_plugin/descriptor_ext/file_descriptor_proto_ext"
5
+
6
+ class Google::Protobuf::Compiler::CodeGeneratorRequest
7
+ class << self
8
+ alias_method :old_decode, :decode
9
+
10
+ def decode(bytes)
11
+ request = old_decode(bytes)
12
+ request.send(:populate_dependency_proto_files!)
13
+
14
+ request
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ # Access the [`Google::Protobuf::RepeatedField`] of [Google::Protobuf::FileDescriptorProto]
21
+ # as a proper Array, memoizing the value in the process.
22
+ #
23
+ # This memoized value stabilizes the test suite when run via `rake spec` (whereas, interestingly,
24
+ # running standalone `rspec` was fine). I'm not certain why that is, but I wonder if it has to
25
+ # do with memory pressure and garbage collection that runs during `rake spec` but not `rspec`
26
+ # (because `rspec` loads less into memory)... and memoizing the value forces the GC to keep the
27
+ # `FileDescriptorProto` references around.
28
+ #
29
+ # Before this change, the `populate_dependency_proto_files!` method would execute and modify
30
+ # the `file_descriptor_proto`, but sometimes the changes inside the enumerator wouldn't "stick"
31
+ # after the enumeration went out of scope. (Again, only via the `rake spec` command, not via
32
+ # `rspec`). This resulted in the `dependency_proto_files` value being unexpectedly `nil` when at
33
+ # the very least an empty array was expected.
34
+ #
35
+ # @return [Array<Google::Protobuf::FileDescriptorProto>]
36
+ def proto_files
37
+ @proto_files ||= proto_file.to_ary
38
+ end
39
+
40
+ def populate_dependency_proto_files!
41
+ proto_files.each do |file_descriptor_proto|
42
+ file_descriptor_proto.dependency_proto_files = []
43
+
44
+ file_descriptor_proto.dependency.each do |dependent_file_name|
45
+ file_descriptor_proto.dependency_proto_files << proto_file_for(dependent_file_name)
46
+ end
47
+ end
48
+ end
49
+
50
+ # @param name [String]
51
+ # @return [Google::Protobuf::FileDescriptorProto, nil]
52
+ def proto_file_for(name)
53
+ proto_files.find { |proto_file| proto_file.name == name }
54
+ end
55
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class File
4
+ # @param filename [String] a filename string (with optional path),
5
+ # e.g. "some/example/hello.proto"
6
+ # @return [String] the filename (preserving optional path) minus the file extension,
7
+ # e.g. "some/example/hello"
8
+ def self.delete_extension(filename)
9
+ filename.delete_suffix(File.extname(filename))
10
+ end
11
+ end