protobuffy 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.travis.yml +12 -0
  4. data/.yardopts +5 -0
  5. data/CHANGES.md +261 -0
  6. data/CONTRIBUTING.md +16 -0
  7. data/Gemfile +3 -0
  8. data/LICENSE.txt +14 -0
  9. data/README.md +58 -0
  10. data/Rakefile +61 -0
  11. data/bin/protoc-gen-ruby +17 -0
  12. data/bin/rpc_server +4 -0
  13. data/examples/bin/reverse-client-http +4 -0
  14. data/examples/bin/reverse-client-socket +4 -0
  15. data/examples/bin/reverse-client-zmq +4 -0
  16. data/examples/config.ru +6 -0
  17. data/examples/definitions/example/reverse.proto +12 -0
  18. data/examples/lib/example/reverse-client.rb +23 -0
  19. data/examples/lib/example/reverse-service.rb +9 -0
  20. data/examples/lib/example/reverse.pb.rb +36 -0
  21. data/lib/protobuf.rb +106 -0
  22. data/lib/protobuf/cli.rb +249 -0
  23. data/lib/protobuf/code_generator.rb +41 -0
  24. data/lib/protobuf/decoder.rb +74 -0
  25. data/lib/protobuf/deprecator.rb +42 -0
  26. data/lib/protobuf/descriptors.rb +3 -0
  27. data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +52 -0
  28. data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +249 -0
  29. data/lib/protobuf/encoder.rb +62 -0
  30. data/lib/protobuf/enum.rb +319 -0
  31. data/lib/protobuf/exceptions.rb +9 -0
  32. data/lib/protobuf/field.rb +74 -0
  33. data/lib/protobuf/field/base_field.rb +280 -0
  34. data/lib/protobuf/field/bool_field.rb +53 -0
  35. data/lib/protobuf/field/bytes_field.rb +81 -0
  36. data/lib/protobuf/field/double_field.rb +26 -0
  37. data/lib/protobuf/field/enum_field.rb +57 -0
  38. data/lib/protobuf/field/field_array.rb +86 -0
  39. data/lib/protobuf/field/fixed32_field.rb +25 -0
  40. data/lib/protobuf/field/fixed64_field.rb +29 -0
  41. data/lib/protobuf/field/float_field.rb +38 -0
  42. data/lib/protobuf/field/int32_field.rb +22 -0
  43. data/lib/protobuf/field/int64_field.rb +22 -0
  44. data/lib/protobuf/field/integer_field.rb +24 -0
  45. data/lib/protobuf/field/message_field.rb +66 -0
  46. data/lib/protobuf/field/sfixed32_field.rb +28 -0
  47. data/lib/protobuf/field/sfixed64_field.rb +29 -0
  48. data/lib/protobuf/field/signed_integer_field.rb +30 -0
  49. data/lib/protobuf/field/sint32_field.rb +22 -0
  50. data/lib/protobuf/field/sint64_field.rb +22 -0
  51. data/lib/protobuf/field/string_field.rb +35 -0
  52. data/lib/protobuf/field/uint32_field.rb +22 -0
  53. data/lib/protobuf/field/uint64_field.rb +22 -0
  54. data/lib/protobuf/field/varint_field.rb +68 -0
  55. data/lib/protobuf/generators/base.rb +71 -0
  56. data/lib/protobuf/generators/enum_generator.rb +42 -0
  57. data/lib/protobuf/generators/extension_generator.rb +28 -0
  58. data/lib/protobuf/generators/field_generator.rb +132 -0
  59. data/lib/protobuf/generators/file_generator.rb +140 -0
  60. data/lib/protobuf/generators/group_generator.rb +113 -0
  61. data/lib/protobuf/generators/message_generator.rb +99 -0
  62. data/lib/protobuf/generators/printable.rb +161 -0
  63. data/lib/protobuf/generators/service_generator.rb +27 -0
  64. data/lib/protobuf/http.rb +20 -0
  65. data/lib/protobuf/lifecycle.rb +46 -0
  66. data/lib/protobuf/logger.rb +86 -0
  67. data/lib/protobuf/message.rb +182 -0
  68. data/lib/protobuf/message/fields.rb +122 -0
  69. data/lib/protobuf/message/serialization.rb +84 -0
  70. data/lib/protobuf/optionable.rb +23 -0
  71. data/lib/protobuf/rpc/buffer.rb +79 -0
  72. data/lib/protobuf/rpc/client.rb +168 -0
  73. data/lib/protobuf/rpc/connector.rb +21 -0
  74. data/lib/protobuf/rpc/connectors/base.rb +54 -0
  75. data/lib/protobuf/rpc/connectors/common.rb +172 -0
  76. data/lib/protobuf/rpc/connectors/http.rb +90 -0
  77. data/lib/protobuf/rpc/connectors/socket.rb +73 -0
  78. data/lib/protobuf/rpc/connectors/zmq.rb +205 -0
  79. data/lib/protobuf/rpc/dynamic_discovery.pb.rb +47 -0
  80. data/lib/protobuf/rpc/env.rb +58 -0
  81. data/lib/protobuf/rpc/error.rb +28 -0
  82. data/lib/protobuf/rpc/error/client_error.rb +31 -0
  83. data/lib/protobuf/rpc/error/server_error.rb +43 -0
  84. data/lib/protobuf/rpc/middleware.rb +25 -0
  85. data/lib/protobuf/rpc/middleware/exception_handler.rb +36 -0
  86. data/lib/protobuf/rpc/middleware/logger.rb +91 -0
  87. data/lib/protobuf/rpc/middleware/request_decoder.rb +83 -0
  88. data/lib/protobuf/rpc/middleware/response_encoder.rb +88 -0
  89. data/lib/protobuf/rpc/middleware/runner.rb +18 -0
  90. data/lib/protobuf/rpc/rpc.pb.rb +53 -0
  91. data/lib/protobuf/rpc/server.rb +39 -0
  92. data/lib/protobuf/rpc/servers/http/server.rb +101 -0
  93. data/lib/protobuf/rpc/servers/http_runner.rb +34 -0
  94. data/lib/protobuf/rpc/servers/socket/server.rb +113 -0
  95. data/lib/protobuf/rpc/servers/socket/worker.rb +56 -0
  96. data/lib/protobuf/rpc/servers/socket_runner.rb +34 -0
  97. data/lib/protobuf/rpc/servers/zmq/broker.rb +155 -0
  98. data/lib/protobuf/rpc/servers/zmq/server.rb +313 -0
  99. data/lib/protobuf/rpc/servers/zmq/util.rb +47 -0
  100. data/lib/protobuf/rpc/servers/zmq/worker.rb +105 -0
  101. data/lib/protobuf/rpc/servers/zmq_runner.rb +51 -0
  102. data/lib/protobuf/rpc/service.rb +179 -0
  103. data/lib/protobuf/rpc/service_directory.rb +245 -0
  104. data/lib/protobuf/rpc/service_dispatcher.rb +46 -0
  105. data/lib/protobuf/rpc/service_filters.rb +273 -0
  106. data/lib/protobuf/rpc/stat.rb +148 -0
  107. data/lib/protobuf/socket.rb +22 -0
  108. data/lib/protobuf/tasks.rb +1 -0
  109. data/lib/protobuf/tasks/compile.rake +61 -0
  110. data/lib/protobuf/version.rb +3 -0
  111. data/lib/protobuf/wire_type.rb +10 -0
  112. data/lib/protobuf/zmq.rb +21 -0
  113. data/proto/dynamic_discovery.proto +44 -0
  114. data/proto/google/protobuf/compiler/plugin.proto +147 -0
  115. data/proto/google/protobuf/descriptor.proto +620 -0
  116. data/proto/rpc.proto +62 -0
  117. data/protobuffy.gemspec +37 -0
  118. data/spec/benchmark/tasks.rb +113 -0
  119. data/spec/bin/protoc-gen-ruby_spec.rb +18 -0
  120. data/spec/data/data.bin +3 -0
  121. data/spec/data/types.bin +0 -0
  122. data/spec/encoding/all_types_spec.rb +91 -0
  123. data/spec/encoding/extreme_values_spec.rb +0 -0
  124. data/spec/functional/socket_server_spec.rb +59 -0
  125. data/spec/functional/zmq_server_spec.rb +103 -0
  126. data/spec/lib/protobuf/cli_spec.rb +267 -0
  127. data/spec/lib/protobuf/code_generator_spec.rb +60 -0
  128. data/spec/lib/protobuf/enum_spec.rb +239 -0
  129. data/spec/lib/protobuf/field/int32_field_spec.rb +7 -0
  130. data/spec/lib/protobuf/field/string_field_spec.rb +46 -0
  131. data/spec/lib/protobuf/field_spec.rb +194 -0
  132. data/spec/lib/protobuf/generators/base_spec.rb +87 -0
  133. data/spec/lib/protobuf/generators/enum_generator_spec.rb +68 -0
  134. data/spec/lib/protobuf/generators/extension_generator_spec.rb +43 -0
  135. data/spec/lib/protobuf/generators/field_generator_spec.rb +99 -0
  136. data/spec/lib/protobuf/generators/file_generator_spec.rb +29 -0
  137. data/spec/lib/protobuf/generators/message_generator_spec.rb +0 -0
  138. data/spec/lib/protobuf/generators/service_generator_spec.rb +43 -0
  139. data/spec/lib/protobuf/lifecycle_spec.rb +89 -0
  140. data/spec/lib/protobuf/logger_spec.rb +136 -0
  141. data/spec/lib/protobuf/message_spec.rb +368 -0
  142. data/spec/lib/protobuf/optionable_spec.rb +46 -0
  143. data/spec/lib/protobuf/rpc/client_spec.rb +66 -0
  144. data/spec/lib/protobuf/rpc/connector_spec.rb +26 -0
  145. data/spec/lib/protobuf/rpc/connectors/base_spec.rb +50 -0
  146. data/spec/lib/protobuf/rpc/connectors/common_spec.rb +170 -0
  147. data/spec/lib/protobuf/rpc/connectors/connector_spec.rb +13 -0
  148. data/spec/lib/protobuf/rpc/connectors/http_spec.rb +61 -0
  149. data/spec/lib/protobuf/rpc/connectors/socket_spec.rb +24 -0
  150. data/spec/lib/protobuf/rpc/connectors/zmq_spec.rb +129 -0
  151. data/spec/lib/protobuf/rpc/middleware/exception_handler_spec.rb +62 -0
  152. data/spec/lib/protobuf/rpc/middleware/logger_spec.rb +49 -0
  153. data/spec/lib/protobuf/rpc/middleware/request_decoder_spec.rb +115 -0
  154. data/spec/lib/protobuf/rpc/middleware/response_encoder_spec.rb +75 -0
  155. data/spec/lib/protobuf/rpc/servers/http/server_spec.rb +104 -0
  156. data/spec/lib/protobuf/rpc/servers/socket_server_spec.rb +38 -0
  157. data/spec/lib/protobuf/rpc/servers/zmq/server_spec.rb +41 -0
  158. data/spec/lib/protobuf/rpc/servers/zmq/util_spec.rb +55 -0
  159. data/spec/lib/protobuf/rpc/servers/zmq/worker_spec.rb +35 -0
  160. data/spec/lib/protobuf/rpc/service_directory_spec.rb +295 -0
  161. data/spec/lib/protobuf/rpc/service_dispatcher_spec.rb +52 -0
  162. data/spec/lib/protobuf/rpc/service_filters_spec.rb +484 -0
  163. data/spec/lib/protobuf/rpc/service_spec.rb +161 -0
  164. data/spec/lib/protobuf/rpc/stat_spec.rb +151 -0
  165. data/spec/lib/protobuf_spec.rb +78 -0
  166. data/spec/spec_helper.rb +57 -0
  167. data/spec/support/all.rb +7 -0
  168. data/spec/support/packed_field.rb +22 -0
  169. data/spec/support/server.rb +94 -0
  170. data/spec/support/test/all_types.data.bin +0 -0
  171. data/spec/support/test/all_types.data.txt +119 -0
  172. data/spec/support/test/defaults.pb.rb +25 -0
  173. data/spec/support/test/defaults.proto +9 -0
  174. data/spec/support/test/enum.pb.rb +59 -0
  175. data/spec/support/test/enum.proto +34 -0
  176. data/spec/support/test/extended.pb.rb +22 -0
  177. data/spec/support/test/extended.proto +10 -0
  178. data/spec/support/test/extreme_values.data.bin +0 -0
  179. data/spec/support/test/google_unittest.pb.rb +543 -0
  180. data/spec/support/test/google_unittest.proto +713 -0
  181. data/spec/support/test/google_unittest_import.pb.rb +37 -0
  182. data/spec/support/test/google_unittest_import.proto +64 -0
  183. data/spec/support/test/google_unittest_import_public.pb.rb +8 -0
  184. data/spec/support/test/google_unittest_import_public.proto +38 -0
  185. data/spec/support/test/multi_field_extensions.pb.rb +56 -0
  186. data/spec/support/test/multi_field_extensions.proto +33 -0
  187. data/spec/support/test/resource.pb.rb +117 -0
  188. data/spec/support/test/resource.proto +94 -0
  189. data/spec/support/test/resource_service.rb +26 -0
  190. data/spec/support/test_app_file.rb +2 -0
  191. data/spec/support/tolerance_matcher.rb +40 -0
  192. metadata +367 -0
@@ -0,0 +1,22 @@
1
+ ##
2
+ ## Socket Mode
3
+ ##
4
+ #
5
+ # Require this file if you wish to run your server and/or client RPC
6
+ # with the raw socket handlers. This is the default run mode for bin/rpc_server.
7
+ #
8
+ # To run with rpc_server either omit any mode switches, or explicitly pass `socket`:
9
+ #
10
+ # rpc_server myapp.rb
11
+ # rpc_server --socket myapp.rb
12
+ #
13
+ # To run for client-side only override the require in your Gemfile:
14
+ #
15
+ # gem 'protobuf', :require => 'protobuf/socket'
16
+ #
17
+ require 'protobuf'
18
+ ::Protobuf.connector_type = :socket
19
+
20
+ require 'protobuf/rpc/servers/socket/server'
21
+ require 'protobuf/rpc/connectors/socket'
22
+
@@ -0,0 +1 @@
1
+ load 'protobuf/tasks/compile.rake'
@@ -0,0 +1,61 @@
1
+ require 'fileutils'
2
+
3
+ namespace :protobuf do
4
+
5
+ desc 'Clean & Compile the protobuf source to ruby classes. Pass PB_NO_CLEAN=1 if you do not want to force-clean first.'
6
+ task :compile, [ :package, :source, :destination, :plugin, :file_extension ] do |tasks, args|
7
+ args.with_defaults(:destination => 'lib')
8
+ args.with_defaults(:source => 'definitions')
9
+ args.with_defaults(:plugin => 'ruby')
10
+ args.with_defaults(:file_extension => '.pb.rb')
11
+
12
+ unless do_not_clean?
13
+ force_clean!
14
+ ::Rake::Task[:clean].invoke(args[:package], args[:destination], args[:file_extension])
15
+ end
16
+
17
+ command = []
18
+ command << "protoc"
19
+ command << "--#{args[:plugin]}_out=#{args[:destination]}"
20
+ command << "-I #{args[:source]}"
21
+ command << "#{args[:source]}/#{args[:package]}/*.proto"
22
+ command << "#{args[:source]}/#{args[:package]}/**/*.proto"
23
+ full_command = command.join(' ')
24
+
25
+ puts full_command
26
+ exec(full_command)
27
+ end
28
+
29
+ desc 'Clean the generated *.pb.rb files from the destination package. Pass PB_FORCE_CLEAN=1 to skip confirmation step.'
30
+ task :clean, [ :package, :destination, :file_extension ] do |task, args|
31
+ args.with_defaults(:destination => 'lib')
32
+ args.with_defaults(:file_extension => '.pb.rb')
33
+
34
+ file_extension = args[:file_extension].sub(/\*?\.+/, '')
35
+ files_to_clean = ::File.join(args[:destination], args[:package], '**', "*.#{file_extension}")
36
+
37
+ if force_clean? || permission_to_clean?(files_to_clean)
38
+ ::Dir.glob(files_to_clean).each do |file|
39
+ ::FileUtils.rm(file)
40
+ end
41
+ end
42
+ end
43
+
44
+ def do_not_clean?
45
+ ! ::ENV.key?('PB_NO_CLEAN')
46
+ end
47
+
48
+ def force_clean?
49
+ ::ENV.key?('PB_FORCE_CLEAN')
50
+ end
51
+
52
+ def force_clean!
53
+ ::ENV['PB_FORCE_CLEAN'] = '1'
54
+ end
55
+
56
+ def permission_to_clean?(files_to_clean)
57
+ puts "Do you really want to remove files matching pattern #{files_to_clean}? (y/n)"
58
+ ::STDIN.gets.chomp =~ /y(es)?/i
59
+ end
60
+
61
+ end
@@ -0,0 +1,3 @@
1
+ module Protobuf
2
+ VERSION = '3.1.0'
3
+ end
@@ -0,0 +1,10 @@
1
+ module Protobuf
2
+ module WireType
3
+ VARINT = 0
4
+ FIXED64 = 1
5
+ LENGTH_DELIMITED = 2
6
+ START_GROUP = 3
7
+ END_GROUP = 4
8
+ FIXED32 = 5
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ ##
2
+ ## ZMQ Mode
3
+ ##
4
+ #
5
+ # Require this file if you wish to run your server and/or client RPC
6
+ # with the ZeroMQ handlers.
7
+ #
8
+ # To run with rpc_server specify the switch `zmq`:
9
+ #
10
+ # rpc_server --zmq myapp.rb
11
+ #
12
+ # To run for client-side only override the require in your Gemfile:
13
+ #
14
+ # gem 'protobuf', :require => 'protobuf/zmq'
15
+ #
16
+ require 'protobuf'
17
+ Protobuf.connector_type = :zmq
18
+
19
+ require 'ffi-rzmq'
20
+ require 'protobuf/rpc/servers/zmq/server'
21
+ require 'protobuf/rpc/connectors/zmq'
@@ -0,0 +1,44 @@
1
+ // Copyright (c) 2013 MoneyDesktop, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+
21
+ // Authors: Devin Christensen
22
+ //
23
+ // Protobufs needed for dynamic discovery zmq server and client.
24
+
25
+ package protobuf.rpc.dynamicDiscovery;
26
+
27
+ enum BeaconType {
28
+ HEARTBEAT = 0;
29
+ FLATLINE = 1;
30
+ }
31
+
32
+ message Server {
33
+ optional string uuid = 1;
34
+ optional string address = 2;
35
+ optional string port = 3;
36
+ optional int32 ttl = 4;
37
+ repeated string services = 5;
38
+ }
39
+
40
+ message Beacon {
41
+ optional BeaconType beacon_type = 1;
42
+ optional Server server = 2;
43
+ }
44
+
@@ -0,0 +1,147 @@
1
+ // Protocol Buffers - Google's data interchange format
2
+ // Copyright 2008 Google Inc. All rights reserved.
3
+ // http://code.google.com/p/protobuf/
4
+ //
5
+ // Redistribution and use in source and binary forms, with or without
6
+ // modification, are permitted provided that the following conditions are
7
+ // met:
8
+ //
9
+ // * Redistributions of source code must retain the above copyright
10
+ // notice, this list of conditions and the following disclaimer.
11
+ // * Redistributions in binary form must reproduce the above
12
+ // copyright notice, this list of conditions and the following disclaimer
13
+ // in the documentation and/or other materials provided with the
14
+ // distribution.
15
+ // * Neither the name of Google Inc. nor the names of its
16
+ // contributors may be used to endorse or promote products derived from
17
+ // this software without specific prior written permission.
18
+ //
19
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ // Author: kenton@google.com (Kenton Varda)
32
+ //
33
+ // WARNING: The plugin interface is currently EXPERIMENTAL and is subject to
34
+ // change.
35
+ //
36
+ // protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is
37
+ // just a program that reads a CodeGeneratorRequest from stdin and writes a
38
+ // CodeGeneratorResponse to stdout.
39
+ //
40
+ // Plugins written using C++ can use google/protobuf/compiler/plugin.h instead
41
+ // of dealing with the raw protocol defined here.
42
+ //
43
+ // A plugin executable needs only to be placed somewhere in the path. The
44
+ // plugin should be named "protoc-gen-$NAME", and will then be used when the
45
+ // flag "--${NAME}_out" is passed to protoc.
46
+
47
+ package google.protobuf.compiler;
48
+ option java_package = "com.google.protobuf.compiler";
49
+ option java_outer_classname = "PluginProtos";
50
+
51
+ import "google/protobuf/descriptor.proto";
52
+
53
+ // An encoded CodeGeneratorRequest is written to the plugin's stdin.
54
+ message CodeGeneratorRequest {
55
+ // The .proto files that were explicitly listed on the command-line. The
56
+ // code generator should generate code only for these files. Each file's
57
+ // descriptor will be included in proto_file, below.
58
+ repeated string file_to_generate = 1;
59
+
60
+ // The generator parameter passed on the command-line.
61
+ optional string parameter = 2;
62
+
63
+ // FileDescriptorProtos for all files in files_to_generate and everything
64
+ // they import. The files will appear in topological order, so each file
65
+ // appears before any file that imports it.
66
+ //
67
+ // protoc guarantees that all proto_files will be written after
68
+ // the fields above, even though this is not technically guaranteed by the
69
+ // protobuf wire format. This theoretically could allow a plugin to stream
70
+ // in the FileDescriptorProtos and handle them one by one rather than read
71
+ // the entire set into memory at once. However, as of this writing, this
72
+ // is not similarly optimized on protoc's end -- it will store all fields in
73
+ // memory at once before sending them to the plugin.
74
+ repeated FileDescriptorProto proto_file = 15;
75
+ }
76
+
77
+ // The plugin writes an encoded CodeGeneratorResponse to stdout.
78
+ message CodeGeneratorResponse {
79
+ // Error message. If non-empty, code generation failed. The plugin process
80
+ // should exit with status code zero even if it reports an error in this way.
81
+ //
82
+ // This should be used to indicate errors in .proto files which prevent the
83
+ // code generator from generating correct code. Errors which indicate a
84
+ // problem in protoc itself -- such as the input CodeGeneratorRequest being
85
+ // unparseable -- should be reported by writing a message to stderr and
86
+ // exiting with a non-zero status code.
87
+ optional string error = 1;
88
+
89
+ // Represents a single generated file.
90
+ message File {
91
+ // The file name, relative to the output directory. The name must not
92
+ // contain "." or ".." components and must be relative, not be absolute (so,
93
+ // the file cannot lie outside the output directory). "/" must be used as
94
+ // the path separator, not "\".
95
+ //
96
+ // If the name is omitted, the content will be appended to the previous
97
+ // file. This allows the generator to break large files into small chunks,
98
+ // and allows the generated text to be streamed back to protoc so that large
99
+ // files need not reside completely in memory at one time. Note that as of
100
+ // this writing protoc does not optimize for this -- it will read the entire
101
+ // CodeGeneratorResponse before writing files to disk.
102
+ optional string name = 1;
103
+
104
+ // If non-empty, indicates that the named file should already exist, and the
105
+ // content here is to be inserted into that file at a defined insertion
106
+ // point. This feature allows a code generator to extend the output
107
+ // produced by another code generator. The original generator may provide
108
+ // insertion points by placing special annotations in the file that look
109
+ // like:
110
+ // @@protoc_insertion_point(NAME)
111
+ // The annotation can have arbitrary text before and after it on the line,
112
+ // which allows it to be placed in a comment. NAME should be replaced with
113
+ // an identifier naming the point -- this is what other generators will use
114
+ // as the insertion_point. Code inserted at this point will be placed
115
+ // immediately above the line containing the insertion point (thus multiple
116
+ // insertions to the same point will come out in the order they were added).
117
+ // The double-@ is intended to make it unlikely that the generated code
118
+ // could contain things that look like insertion points by accident.
119
+ //
120
+ // For example, the C++ code generator places the following line in the
121
+ // .pb.h files that it generates:
122
+ // // @@protoc_insertion_point(namespace_scope)
123
+ // This line appears within the scope of the file's package namespace, but
124
+ // outside of any particular class. Another plugin can then specify the
125
+ // insertion_point "namespace_scope" to generate additional classes or
126
+ // other declarations that should be placed in this scope.
127
+ //
128
+ // Note that if the line containing the insertion point begins with
129
+ // whitespace, the same whitespace will be added to every line of the
130
+ // inserted text. This is useful for languages like Python, where
131
+ // indentation matters. In these languages, the insertion point comment
132
+ // should be indented the same amount as any inserted code will need to be
133
+ // in order to work correctly in that context.
134
+ //
135
+ // The code generator that generates the initial file and the one which
136
+ // inserts into it must both run as part of a single invocation of protoc.
137
+ // Code generators are executed in the order in which they appear on the
138
+ // command line.
139
+ //
140
+ // If |insertion_point| is present, |name| must also be present.
141
+ optional string insertion_point = 2;
142
+
143
+ // The file contents.
144
+ optional string content = 15;
145
+ }
146
+ repeated File file = 15;
147
+ }
@@ -0,0 +1,620 @@
1
+ // Protocol Buffers - Google's data interchange format
2
+ // Copyright 2008 Google Inc. All rights reserved.
3
+ // http://code.google.com/p/protobuf/
4
+ //
5
+ // Redistribution and use in source and binary forms, with or without
6
+ // modification, are permitted provided that the following conditions are
7
+ // met:
8
+ //
9
+ // * Redistributions of source code must retain the above copyright
10
+ // notice, this list of conditions and the following disclaimer.
11
+ // * Redistributions in binary form must reproduce the above
12
+ // copyright notice, this list of conditions and the following disclaimer
13
+ // in the documentation and/or other materials provided with the
14
+ // distribution.
15
+ // * Neither the name of Google Inc. nor the names of its
16
+ // contributors may be used to endorse or promote products derived from
17
+ // this software without specific prior written permission.
18
+ //
19
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ // Author: kenton@google.com (Kenton Varda)
32
+ // Based on original Protocol Buffers design by
33
+ // Sanjay Ghemawat, Jeff Dean, and others.
34
+ //
35
+ // The messages in this file describe the definitions found in .proto files.
36
+ // A valid .proto file can be translated directly to a FileDescriptorProto
37
+ // without any other information (e.g. without reading its imports).
38
+
39
+
40
+
41
+ package google.protobuf;
42
+ option java_package = "com.google.protobuf";
43
+ option java_outer_classname = "DescriptorProtos";
44
+
45
+ // descriptor.proto must be optimized for speed because reflection-based
46
+ // algorithms don't work during bootstrapping.
47
+ option optimize_for = SPEED;
48
+
49
+ // The protocol compiler can output a FileDescriptorSet containing the .proto
50
+ // files it parses.
51
+ message FileDescriptorSet {
52
+ repeated FileDescriptorProto file = 1;
53
+ }
54
+
55
+ // Describes a complete .proto file.
56
+ message FileDescriptorProto {
57
+ optional string name = 1; // file name, relative to root of source tree
58
+ optional string package = 2; // e.g. "foo", "foo.bar", etc.
59
+
60
+ // Names of files imported by this file.
61
+ repeated string dependency = 3;
62
+ // Indexes of the public imported files in the dependency list above.
63
+ repeated int32 public_dependency = 10;
64
+ // Indexes of the weak imported files in the dependency list.
65
+ // For Google-internal migration only. Do not use.
66
+ repeated int32 weak_dependency = 11;
67
+
68
+ // All top-level definitions in this file.
69
+ repeated DescriptorProto message_type = 4;
70
+ repeated EnumDescriptorProto enum_type = 5;
71
+ repeated ServiceDescriptorProto service = 6;
72
+ repeated FieldDescriptorProto extension = 7;
73
+
74
+ optional FileOptions options = 8;
75
+
76
+ // This field contains optional information about the original source code.
77
+ // You may safely remove this entire field whithout harming runtime
78
+ // functionality of the descriptors -- the information is needed only by
79
+ // development tools.
80
+ optional SourceCodeInfo source_code_info = 9;
81
+ }
82
+
83
+ // Describes a message type.
84
+ message DescriptorProto {
85
+ optional string name = 1;
86
+
87
+ repeated FieldDescriptorProto field = 2;
88
+ repeated FieldDescriptorProto extension = 6;
89
+
90
+ repeated DescriptorProto nested_type = 3;
91
+ repeated EnumDescriptorProto enum_type = 4;
92
+
93
+ message ExtensionRange {
94
+ optional int32 start = 1;
95
+ optional int32 end = 2;
96
+ }
97
+ repeated ExtensionRange extension_range = 5;
98
+
99
+ optional MessageOptions options = 7;
100
+ }
101
+
102
+ // Describes a field within a message.
103
+ message FieldDescriptorProto {
104
+ enum Type {
105
+ // 0 is reserved for errors.
106
+ // Order is weird for historical reasons.
107
+ TYPE_DOUBLE = 1;
108
+ TYPE_FLOAT = 2;
109
+ // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
110
+ // negative values are likely.
111
+ TYPE_INT64 = 3;
112
+ TYPE_UINT64 = 4;
113
+ // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
114
+ // negative values are likely.
115
+ TYPE_INT32 = 5;
116
+ TYPE_FIXED64 = 6;
117
+ TYPE_FIXED32 = 7;
118
+ TYPE_BOOL = 8;
119
+ TYPE_STRING = 9;
120
+ TYPE_GROUP = 10; // Tag-delimited aggregate.
121
+ TYPE_MESSAGE = 11; // Length-delimited aggregate.
122
+
123
+ // New in version 2.
124
+ TYPE_BYTES = 12;
125
+ TYPE_UINT32 = 13;
126
+ TYPE_ENUM = 14;
127
+ TYPE_SFIXED32 = 15;
128
+ TYPE_SFIXED64 = 16;
129
+ TYPE_SINT32 = 17; // Uses ZigZag encoding.
130
+ TYPE_SINT64 = 18; // Uses ZigZag encoding.
131
+ };
132
+
133
+ enum Label {
134
+ // 0 is reserved for errors
135
+ LABEL_OPTIONAL = 1;
136
+ LABEL_REQUIRED = 2;
137
+ LABEL_REPEATED = 3;
138
+ // TODO(sanjay): Should we add LABEL_MAP?
139
+ };
140
+
141
+ optional string name = 1;
142
+ optional int32 number = 3;
143
+ optional Label label = 4;
144
+
145
+ // If type_name is set, this need not be set. If both this and type_name
146
+ // are set, this must be either TYPE_ENUM or TYPE_MESSAGE.
147
+ optional Type type = 5;
148
+
149
+ // For message and enum types, this is the name of the type. If the name
150
+ // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
151
+ // rules are used to find the type (i.e. first the nested types within this
152
+ // message are searched, then within the parent, on up to the root
153
+ // namespace).
154
+ optional string type_name = 6;
155
+
156
+ // For extensions, this is the name of the type being extended. It is
157
+ // resolved in the same manner as type_name.
158
+ optional string extendee = 2;
159
+
160
+ // For numeric types, contains the original text representation of the value.
161
+ // For booleans, "true" or "false".
162
+ // For strings, contains the default text contents (not escaped in any way).
163
+ // For bytes, contains the C escaped value. All bytes >= 128 are escaped.
164
+ // TODO(kenton): Base-64 encode?
165
+ optional string default_value = 7;
166
+
167
+ optional FieldOptions options = 8;
168
+ }
169
+
170
+ // Describes an enum type.
171
+ message EnumDescriptorProto {
172
+ optional string name = 1;
173
+
174
+ repeated EnumValueDescriptorProto value = 2;
175
+
176
+ optional EnumOptions options = 3;
177
+ }
178
+
179
+ // Describes a value within an enum.
180
+ message EnumValueDescriptorProto {
181
+ optional string name = 1;
182
+ optional int32 number = 2;
183
+
184
+ optional EnumValueOptions options = 3;
185
+ }
186
+
187
+ // Describes a service.
188
+ message ServiceDescriptorProto {
189
+ optional string name = 1;
190
+ repeated MethodDescriptorProto method = 2;
191
+
192
+ optional ServiceOptions options = 3;
193
+ }
194
+
195
+ // Describes a method of a service.
196
+ message MethodDescriptorProto {
197
+ optional string name = 1;
198
+
199
+ // Input and output type names. These are resolved in the same way as
200
+ // FieldDescriptorProto.type_name, but must refer to a message type.
201
+ optional string input_type = 2;
202
+ optional string output_type = 3;
203
+
204
+ optional MethodOptions options = 4;
205
+ }
206
+
207
+
208
+ // ===================================================================
209
+ // Options
210
+
211
+ // Each of the definitions above may have "options" attached. These are
212
+ // just annotations which may cause code to be generated slightly differently
213
+ // or may contain hints for code that manipulates protocol messages.
214
+ //
215
+ // Clients may define custom options as extensions of the *Options messages.
216
+ // These extensions may not yet be known at parsing time, so the parser cannot
217
+ // store the values in them. Instead it stores them in a field in the *Options
218
+ // message called uninterpreted_option. This field must have the same name
219
+ // across all *Options messages. We then use this field to populate the
220
+ // extensions when we build a descriptor, at which point all protos have been
221
+ // parsed and so all extensions are known.
222
+ //
223
+ // Extension numbers for custom options may be chosen as follows:
224
+ // * For options which will only be used within a single application or
225
+ // organization, or for experimental options, use field numbers 50000
226
+ // through 99999. It is up to you to ensure that you do not use the
227
+ // same number for multiple options.
228
+ // * For options which will be published and used publicly by multiple
229
+ // independent entities, e-mail protobuf-global-extension-registry@google.com
230
+ // to reserve extension numbers. Simply provide your project name (e.g.
231
+ // Object-C plugin) and your porject website (if available) -- there's no need
232
+ // to explain how you intend to use them. Usually you only need one extension
233
+ // number. You can declare multiple options with only one extension number by
234
+ // putting them in a sub-message. See the Custom Options section of the docs
235
+ // for examples:
236
+ // http://code.google.com/apis/protocolbuffers/docs/proto.html#options
237
+ // If this turns out to be popular, a web service will be set up
238
+ // to automatically assign option numbers.
239
+
240
+
241
+ message FileOptions {
242
+
243
+ // Sets the Java package where classes generated from this .proto will be
244
+ // placed. By default, the proto package is used, but this is often
245
+ // inappropriate because proto packages do not normally start with backwards
246
+ // domain names.
247
+ optional string java_package = 1;
248
+
249
+
250
+ // If set, all the classes from the .proto file are wrapped in a single
251
+ // outer class with the given name. This applies to both Proto1
252
+ // (equivalent to the old "--one_java_file" option) and Proto2 (where
253
+ // a .proto always translates to a single class, but you may want to
254
+ // explicitly choose the class name).
255
+ optional string java_outer_classname = 8;
256
+
257
+ // If set true, then the Java code generator will generate a separate .java
258
+ // file for each top-level message, enum, and service defined in the .proto
259
+ // file. Thus, these types will *not* be nested inside the outer class
260
+ // named by java_outer_classname. However, the outer class will still be
261
+ // generated to contain the file's getDescriptor() method as well as any
262
+ // top-level extensions defined in the file.
263
+ optional bool java_multiple_files = 10 [default=false];
264
+
265
+ // If set true, then the Java code generator will generate equals() and
266
+ // hashCode() methods for all messages defined in the .proto file. This is
267
+ // purely a speed optimization, as the AbstractMessage base class includes
268
+ // reflection-based implementations of these methods.
269
+ optional bool java_generate_equals_and_hash = 20 [default=false];
270
+
271
+ // Generated classes can be optimized for speed or code size.
272
+ enum OptimizeMode {
273
+ SPEED = 1; // Generate complete code for parsing, serialization,
274
+ // etc.
275
+ CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
276
+ LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
277
+ }
278
+ optional OptimizeMode optimize_for = 9 [default=SPEED];
279
+
280
+ // Sets the Go package where structs generated from this .proto will be
281
+ // placed. There is no default.
282
+ optional string go_package = 11;
283
+
284
+
285
+
286
+ // Should generic services be generated in each language? "Generic" services
287
+ // are not specific to any particular RPC system. They are generated by the
288
+ // main code generators in each language (without additional plugins).
289
+ // Generic services were the only kind of service generation supported by
290
+ // early versions of proto2.
291
+ //
292
+ // Generic services are now considered deprecated in favor of using plugins
293
+ // that generate code specific to your particular RPC system. Therefore,
294
+ // these default to false. Old code which depends on generic services should
295
+ // explicitly set them to true.
296
+ optional bool cc_generic_services = 16 [default=false];
297
+ optional bool java_generic_services = 17 [default=false];
298
+ optional bool py_generic_services = 18 [default=false];
299
+
300
+ // The parser stores options it doesn't recognize here. See above.
301
+ repeated UninterpretedOption uninterpreted_option = 999;
302
+
303
+ // Clients can define custom options in extensions of this message. See above.
304
+ extensions 1000 to max;
305
+ }
306
+
307
+ message MessageOptions {
308
+ // Set true to use the old proto1 MessageSet wire format for extensions.
309
+ // This is provided for backwards-compatibility with the MessageSet wire
310
+ // format. You should not use this for any other reason: It's less
311
+ // efficient, has fewer features, and is more complicated.
312
+ //
313
+ // The message must be defined exactly as follows:
314
+ // message Foo {
315
+ // option message_set_wire_format = true;
316
+ // extensions 4 to max;
317
+ // }
318
+ // Note that the message cannot have any defined fields; MessageSets only
319
+ // have extensions.
320
+ //
321
+ // All extensions of your type must be singular messages; e.g. they cannot
322
+ // be int32s, enums, or repeated messages.
323
+ //
324
+ // Because this is an option, the above two restrictions are not enforced by
325
+ // the protocol compiler.
326
+ optional bool message_set_wire_format = 1 [default=false];
327
+
328
+ // Disables the generation of the standard "descriptor()" accessor, which can
329
+ // conflict with a field of the same name. This is meant to make migration
330
+ // from proto1 easier; new code should avoid fields named "descriptor".
331
+ optional bool no_standard_descriptor_accessor = 2 [default=false];
332
+
333
+ // The parser stores options it doesn't recognize here. See above.
334
+ repeated UninterpretedOption uninterpreted_option = 999;
335
+
336
+ // Clients can define custom options in extensions of this message. See above.
337
+ extensions 1000 to max;
338
+ }
339
+
340
+ message FieldOptions {
341
+ // The ctype option instructs the C++ code generator to use a different
342
+ // representation of the field than it normally would. See the specific
343
+ // options below. This option is not yet implemented in the open source
344
+ // release -- sorry, we'll try to include it in a future version!
345
+ optional CType ctype = 1 [default = STRING];
346
+ enum CType {
347
+ // Default mode.
348
+ STRING = 0;
349
+
350
+ CORD = 1;
351
+
352
+ STRING_PIECE = 2;
353
+ }
354
+ // The packed option can be enabled for repeated primitive fields to enable
355
+ // a more efficient representation on the wire. Rather than repeatedly
356
+ // writing the tag and type for each element, the entire array is encoded as
357
+ // a single length-delimited blob.
358
+ optional bool packed = 2;
359
+
360
+
361
+
362
+ // Should this field be parsed lazily? Lazy applies only to message-type
363
+ // fields. It means that when the outer message is initially parsed, the
364
+ // inner message's contents will not be parsed but instead stored in encoded
365
+ // form. The inner message will actually be parsed when it is first accessed.
366
+ //
367
+ // This is only a hint. Implementations are free to choose whether to use
368
+ // eager or lazy parsing regardless of the value of this option. However,
369
+ // setting this option true suggests that the protocol author believes that
370
+ // using lazy parsing on this field is worth the additional bookkeeping
371
+ // overhead typically needed to implement it.
372
+ //
373
+ // This option does not affect the public interface of any generated code;
374
+ // all method signatures remain the same. Furthermore, thread-safety of the
375
+ // interface is not affected by this option; const methods remain safe to
376
+ // call from multiple threads concurrently, while non-const methods continue
377
+ // to require exclusive access.
378
+ //
379
+ //
380
+ // Note that implementations may choose not to check required fields within
381
+ // a lazy sub-message. That is, calling IsInitialized() on the outher message
382
+ // may return true even if the inner message has missing required fields.
383
+ // This is necessary because otherwise the inner message would have to be
384
+ // parsed in order to perform the check, defeating the purpose of lazy
385
+ // parsing. An implementation which chooses not to check required fields
386
+ // must be consistent about it. That is, for any particular sub-message, the
387
+ // implementation must either *always* check its required fields, or *never*
388
+ // check its required fields, regardless of whether or not the message has
389
+ // been parsed.
390
+ optional bool lazy = 5 [default=false];
391
+
392
+ // Is this field deprecated?
393
+ // Depending on the target platform, this can emit Deprecated annotations
394
+ // for accessors, or it will be completely ignored; in the very least, this
395
+ // is a formalization for deprecating fields.
396
+ optional bool deprecated = 3 [default=false];
397
+
398
+ // EXPERIMENTAL. DO NOT USE.
399
+ // For "map" fields, the name of the field in the enclosed type that
400
+ // is the key for this map. For example, suppose we have:
401
+ // message Item {
402
+ // required string name = 1;
403
+ // required string value = 2;
404
+ // }
405
+ // message Config {
406
+ // repeated Item items = 1 [experimental_map_key="name"];
407
+ // }
408
+ // In this situation, the map key for Item will be set to "name".
409
+ // TODO: Fully-implement this, then remove the "experimental_" prefix.
410
+ optional string experimental_map_key = 9;
411
+
412
+ // For Google-internal migration only. Do not use.
413
+ optional bool weak = 10 [default=false];
414
+
415
+ // The parser stores options it doesn't recognize here. See above.
416
+ repeated UninterpretedOption uninterpreted_option = 999;
417
+
418
+ // Clients can define custom options in extensions of this message. See above.
419
+ extensions 1000 to max;
420
+ }
421
+
422
+ message EnumOptions {
423
+
424
+ // Set this option to false to disallow mapping different tag names to a same
425
+ // value.
426
+ optional bool allow_alias = 2 [default=true];
427
+
428
+ // The parser stores options it doesn't recognize here. See above.
429
+ repeated UninterpretedOption uninterpreted_option = 999;
430
+
431
+ // Clients can define custom options in extensions of this message. See above.
432
+ extensions 1000 to max;
433
+ }
434
+
435
+ message EnumValueOptions {
436
+ // The parser stores options it doesn't recognize here. See above.
437
+ repeated UninterpretedOption uninterpreted_option = 999;
438
+
439
+ // Clients can define custom options in extensions of this message. See above.
440
+ extensions 1000 to max;
441
+ }
442
+
443
+ message ServiceOptions {
444
+
445
+ // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
446
+ // framework. We apologize for hoarding these numbers to ourselves, but
447
+ // we were already using them long before we decided to release Protocol
448
+ // Buffers.
449
+
450
+ // The parser stores options it doesn't recognize here. See above.
451
+ repeated UninterpretedOption uninterpreted_option = 999;
452
+
453
+ // Clients can define custom options in extensions of this message. See above.
454
+ extensions 1000 to max;
455
+ }
456
+
457
+ message MethodOptions {
458
+
459
+ // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
460
+ // framework. We apologize for hoarding these numbers to ourselves, but
461
+ // we were already using them long before we decided to release Protocol
462
+ // Buffers.
463
+
464
+ // The parser stores options it doesn't recognize here. See above.
465
+ repeated UninterpretedOption uninterpreted_option = 999;
466
+
467
+ // Clients can define custom options in extensions of this message. See above.
468
+ extensions 1000 to max;
469
+ }
470
+
471
+
472
+ // A message representing a option the parser does not recognize. This only
473
+ // appears in options protos created by the compiler::Parser class.
474
+ // DescriptorPool resolves these when building Descriptor objects. Therefore,
475
+ // options protos in descriptor objects (e.g. returned by Descriptor::options(),
476
+ // or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
477
+ // in them.
478
+ message UninterpretedOption {
479
+ // The name of the uninterpreted option. Each string represents a segment in
480
+ // a dot-separated name. is_extension is true iff a segment represents an
481
+ // extension (denoted with parentheses in options specs in .proto files).
482
+ // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
483
+ // "foo.(bar.baz).qux".
484
+ message NamePart {
485
+ required string name_part = 1;
486
+ required bool is_extension = 2;
487
+ }
488
+ repeated NamePart name = 2;
489
+
490
+ // The value of the uninterpreted option, in whatever type the tokenizer
491
+ // identified it as during parsing. Exactly one of these should be set.
492
+ optional string identifier_value = 3;
493
+ optional uint64 positive_int_value = 4;
494
+ optional int64 negative_int_value = 5;
495
+ optional double double_value = 6;
496
+ optional bytes string_value = 7;
497
+ optional string aggregate_value = 8;
498
+ }
499
+
500
+ // ===================================================================
501
+ // Optional source code info
502
+
503
+ // Encapsulates information about the original source file from which a
504
+ // FileDescriptorProto was generated.
505
+ message SourceCodeInfo {
506
+ // A Location identifies a piece of source code in a .proto file which
507
+ // corresponds to a particular definition. This information is intended
508
+ // to be useful to IDEs, code indexers, documentation generators, and similar
509
+ // tools.
510
+ //
511
+ // For example, say we have a file like:
512
+ // message Foo {
513
+ // optional string foo = 1;
514
+ // }
515
+ // Let's look at just the field definition:
516
+ // optional string foo = 1;
517
+ // ^ ^^ ^^ ^ ^^^
518
+ // a bc de f ghi
519
+ // We have the following locations:
520
+ // span path represents
521
+ // [a,i) [ 4, 0, 2, 0 ] The whole field definition.
522
+ // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
523
+ // [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
524
+ // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
525
+ // [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
526
+ //
527
+ // Notes:
528
+ // - A location may refer to a repeated field itself (i.e. not to any
529
+ // particular index within it). This is used whenever a set of elements are
530
+ // logically enclosed in a single code segment. For example, an entire
531
+ // extend block (possibly containing multiple extension definitions) will
532
+ // have an outer location whose path refers to the "extensions" repeated
533
+ // field without an index.
534
+ // - Multiple locations may have the same path. This happens when a single
535
+ // logical declaration is spread out across multiple places. The most
536
+ // obvious example is the "extend" block again -- there may be multiple
537
+ // extend blocks in the same scope, each of which will have the same path.
538
+ // - A location's span is not always a subset of its parent's span. For
539
+ // example, the "extendee" of an extension declaration appears at the
540
+ // beginning of the "extend" block and is shared by all extensions within
541
+ // the block.
542
+ // - Just because a location's span is a subset of some other location's span
543
+ // does not mean that it is a descendent. For example, a "group" defines
544
+ // both a type and a field in a single declaration. Thus, the locations
545
+ // corresponding to the type and field and their components will overlap.
546
+ // - Code which tries to interpret locations should probably be designed to
547
+ // ignore those that it doesn't understand, as more types of locations could
548
+ // be recorded in the future.
549
+ repeated Location location = 1;
550
+ message Location {
551
+ // Identifies which part of the FileDescriptorProto was defined at this
552
+ // location.
553
+ //
554
+ // Each element is a field number or an index. They form a path from
555
+ // the root FileDescriptorProto to the place where the definition. For
556
+ // example, this path:
557
+ // [ 4, 3, 2, 7, 1 ]
558
+ // refers to:
559
+ // file.message_type(3) // 4, 3
560
+ // .field(7) // 2, 7
561
+ // .name() // 1
562
+ // This is because FileDescriptorProto.message_type has field number 4:
563
+ // repeated DescriptorProto message_type = 4;
564
+ // and DescriptorProto.field has field number 2:
565
+ // repeated FieldDescriptorProto field = 2;
566
+ // and FieldDescriptorProto.name has field number 1:
567
+ // optional string name = 1;
568
+ //
569
+ // Thus, the above path gives the location of a field name. If we removed
570
+ // the last element:
571
+ // [ 4, 3, 2, 7 ]
572
+ // this path refers to the whole field declaration (from the beginning
573
+ // of the label to the terminating semicolon).
574
+ repeated int32 path = 1 [packed=true];
575
+
576
+ // Always has exactly three or four elements: start line, start column,
577
+ // end line (optional, otherwise assumed same as start line), end column.
578
+ // These are packed into a single field for efficiency. Note that line
579
+ // and column numbers are zero-based -- typically you will want to add
580
+ // 1 to each before displaying to a user.
581
+ repeated int32 span = 2 [packed=true];
582
+
583
+ // If this SourceCodeInfo represents a complete declaration, these are any
584
+ // comments appearing before and after the declaration which appear to be
585
+ // attached to the declaration.
586
+ //
587
+ // A series of line comments appearing on consecutive lines, with no other
588
+ // tokens appearing on those lines, will be treated as a single comment.
589
+ //
590
+ // Only the comment content is provided; comment markers (e.g. //) are
591
+ // stripped out. For block comments, leading whitespace and an asterisk
592
+ // will be stripped from the beginning of each line other than the first.
593
+ // Newlines are included in the output.
594
+ //
595
+ // Examples:
596
+ //
597
+ // optional int32 foo = 1; // Comment attached to foo.
598
+ // // Comment attached to bar.
599
+ // optional int32 bar = 2;
600
+ //
601
+ // optional string baz = 3;
602
+ // // Comment attached to baz.
603
+ // // Another line attached to baz.
604
+ //
605
+ // // Comment attached to qux.
606
+ // //
607
+ // // Another line attached to qux.
608
+ // optional double qux = 4;
609
+ //
610
+ // optional string corge = 5;
611
+ // /* Block comment attached
612
+ // * to corge. Leading asterisks
613
+ // * will be removed. */
614
+ // /* Block comment attached to
615
+ // * grault. */
616
+ // optional int32 grault = 6;
617
+ optional string leading_comments = 3;
618
+ optional string trailing_comments = 4;
619
+ }
620
+ }