descriptor.proto 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  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. // Author: kenton@google.com (Kenton Varda)
  31. // Based on original Protocol Buffers design by
  32. // Sanjay Ghemawat, Jeff Dean, and others.
  33. //
  34. // The messages in this file describe the definitions found in .proto files.
  35. // A valid .proto file can be translated directly to a FileDescriptorProto
  36. // without any other information (e.g. without reading its imports).
  37. syntax = "proto2";
  38. package google.protobuf;
  39. option go_package = "descriptor";
  40. option java_package = "com.google.protobuf";
  41. option java_outer_classname = "DescriptorProtos";
  42. option csharp_namespace = "Google.Protobuf.Reflection";
  43. option objc_class_prefix = "GPB";
  44. // descriptor.proto must be optimized for speed because reflection-based
  45. // algorithms don't work during bootstrapping.
  46. option optimize_for = SPEED;
  47. // The protocol compiler can output a FileDescriptorSet containing the .proto
  48. // files it parses.
  49. message FileDescriptorSet {
  50. repeated FileDescriptorProto file = 1;
  51. }
  52. // Describes a complete .proto file.
  53. message FileDescriptorProto {
  54. optional string name = 1; // file name, relative to root of source tree
  55. optional string package = 2; // e.g. "foo", "foo.bar", etc.
  56. // Names of files imported by this file.
  57. repeated string dependency = 3;
  58. // Indexes of the public imported files in the dependency list above.
  59. repeated int32 public_dependency = 10;
  60. // Indexes of the weak imported files in the dependency list.
  61. // For Google-internal migration only. Do not use.
  62. repeated int32 weak_dependency = 11;
  63. // All top-level definitions in this file.
  64. repeated DescriptorProto message_type = 4;
  65. repeated EnumDescriptorProto enum_type = 5;
  66. repeated ServiceDescriptorProto service = 6;
  67. repeated FieldDescriptorProto extension = 7;
  68. optional FileOptions options = 8;
  69. // This field contains optional information about the original source code.
  70. // You may safely remove this entire field without harming runtime
  71. // functionality of the descriptors -- the information is needed only by
  72. // development tools.
  73. optional SourceCodeInfo source_code_info = 9;
  74. // The syntax of the proto file.
  75. // The supported values are "proto2" and "proto3".
  76. optional string syntax = 12;
  77. }
  78. // Describes a message type.
  79. message DescriptorProto {
  80. optional string name = 1;
  81. repeated FieldDescriptorProto field = 2;
  82. repeated FieldDescriptorProto extension = 6;
  83. repeated DescriptorProto nested_type = 3;
  84. repeated EnumDescriptorProto enum_type = 4;
  85. message ExtensionRange {
  86. optional int32 start = 1;
  87. optional int32 end = 2;
  88. }
  89. repeated ExtensionRange extension_range = 5;
  90. repeated OneofDescriptorProto oneof_decl = 8;
  91. optional MessageOptions options = 7;
  92. // Range of reserved tag numbers. Reserved tag numbers may not be used by
  93. // fields or extension ranges in the same message. Reserved ranges may
  94. // not overlap.
  95. message ReservedRange {
  96. optional int32 start = 1; // Inclusive.
  97. optional int32 end = 2; // Exclusive.
  98. }
  99. repeated ReservedRange reserved_range = 9;
  100. // Reserved field names, which may not be used by fields in the same message.
  101. // A given name may only be reserved once.
  102. repeated string reserved_name = 10;
  103. }
  104. // Describes a field within a message.
  105. message FieldDescriptorProto {
  106. enum Type {
  107. // 0 is reserved for errors.
  108. // Order is weird for historical reasons.
  109. TYPE_DOUBLE = 1;
  110. TYPE_FLOAT = 2;
  111. // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
  112. // negative values are likely.
  113. TYPE_INT64 = 3;
  114. TYPE_UINT64 = 4;
  115. // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
  116. // negative values are likely.
  117. TYPE_INT32 = 5;
  118. TYPE_FIXED64 = 6;
  119. TYPE_FIXED32 = 7;
  120. TYPE_BOOL = 8;
  121. TYPE_STRING = 9;
  122. TYPE_GROUP = 10; // Tag-delimited aggregate.
  123. TYPE_MESSAGE = 11; // Length-delimited aggregate.
  124. // New in version 2.
  125. TYPE_BYTES = 12;
  126. TYPE_UINT32 = 13;
  127. TYPE_ENUM = 14;
  128. TYPE_SFIXED32 = 15;
  129. TYPE_SFIXED64 = 16;
  130. TYPE_SINT32 = 17; // Uses ZigZag encoding.
  131. TYPE_SINT64 = 18; // Uses ZigZag encoding.
  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. optional string name = 1;
  141. optional int32 number = 3;
  142. optional Label label = 4;
  143. // If type_name is set, this need not be set. If both this and type_name
  144. // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
  145. optional Type type = 5;
  146. // For message and enum types, this is the name of the type. If the name
  147. // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
  148. // rules are used to find the type (i.e. first the nested types within this
  149. // message are searched, then within the parent, on up to the root
  150. // namespace).
  151. optional string type_name = 6;
  152. // For extensions, this is the name of the type being extended. It is
  153. // resolved in the same manner as type_name.
  154. optional string extendee = 2;
  155. // For numeric types, contains the original text representation of the value.
  156. // For booleans, "true" or "false".
  157. // For strings, contains the default text contents (not escaped in any way).
  158. // For bytes, contains the C escaped value. All bytes >= 128 are escaped.
  159. // TODO(kenton): Base-64 encode?
  160. optional string default_value = 7;
  161. // If set, gives the index of a oneof in the containing type's oneof_decl
  162. // list. This field is a member of that oneof.
  163. optional int32 oneof_index = 9;
  164. // JSON name of this field. The value is set by protocol compiler. If the
  165. // user has set a "json_name" option on this field, that option's value
  166. // will be used. Otherwise, it's deduced from the field's name by converting
  167. // it to camelCase.
  168. optional string json_name = 10;
  169. optional FieldOptions options = 8;
  170. }
  171. // Describes a oneof.
  172. message OneofDescriptorProto {
  173. optional string name = 1;
  174. }
  175. // Describes an enum type.
  176. message EnumDescriptorProto {
  177. optional string name = 1;
  178. repeated EnumValueDescriptorProto value = 2;
  179. optional EnumOptions options = 3;
  180. }
  181. // Describes a value within an enum.
  182. message EnumValueDescriptorProto {
  183. optional string name = 1;
  184. optional int32 number = 2;
  185. optional EnumValueOptions options = 3;
  186. }
  187. // Describes a service.
  188. message ServiceDescriptorProto {
  189. optional string name = 1;
  190. repeated MethodDescriptorProto method = 2;
  191. optional ServiceOptions options = 3;
  192. }
  193. // Describes a method of a service.
  194. message MethodDescriptorProto {
  195. optional string name = 1;
  196. // Input and output type names. These are resolved in the same way as
  197. // FieldDescriptorProto.type_name, but must refer to a message type.
  198. optional string input_type = 2;
  199. optional string output_type = 3;
  200. optional MethodOptions options = 4;
  201. // Identifies if client streams multiple client messages
  202. optional bool client_streaming = 5 [default=false];
  203. // Identifies if server streams multiple server messages
  204. optional bool server_streaming = 6 [default=false];
  205. }
  206. // ===================================================================
  207. // Options
  208. // Each of the definitions above may have "options" attached. These are
  209. // just annotations which may cause code to be generated slightly differently
  210. // or may contain hints for code that manipulates protocol messages.
  211. //
  212. // Clients may define custom options as extensions of the *Options messages.
  213. // These extensions may not yet be known at parsing time, so the parser cannot
  214. // store the values in them. Instead it stores them in a field in the *Options
  215. // message called uninterpreted_option. This field must have the same name
  216. // across all *Options messages. We then use this field to populate the
  217. // extensions when we build a descriptor, at which point all protos have been
  218. // parsed and so all extensions are known.
  219. //
  220. // Extension numbers for custom options may be chosen as follows:
  221. // * For options which will only be used within a single application or
  222. // organization, or for experimental options, use field numbers 50000
  223. // through 99999. It is up to you to ensure that you do not use the
  224. // same number for multiple options.
  225. // * For options which will be published and used publicly by multiple
  226. // independent entities, e-mail protobuf-global-extension-registry@google.com
  227. // to reserve extension numbers. Simply provide your project name (e.g.
  228. // Objective-C plugin) and your project website (if available) -- there's no
  229. // need to explain how you intend to use them. Usually you only need one
  230. // extension number. You can declare multiple options with only one extension
  231. // number by putting them in a sub-message. See the Custom Options section of
  232. // the docs for examples:
  233. // https://developers.google.com/protocol-buffers/docs/proto#options
  234. // If this turns out to be popular, a web service will be set up
  235. // to automatically assign option numbers.
  236. message FileOptions {
  237. // Sets the Java package where classes generated from this .proto will be
  238. // placed. By default, the proto package is used, but this is often
  239. // inappropriate because proto packages do not normally start with backwards
  240. // domain names.
  241. optional string java_package = 1;
  242. // If set, all the classes from the .proto file are wrapped in a single
  243. // outer class with the given name. This applies to both Proto1
  244. // (equivalent to the old "--one_java_file" option) and Proto2 (where
  245. // a .proto always translates to a single class, but you may want to
  246. // explicitly choose the class name).
  247. optional string java_outer_classname = 8;
  248. // If set true, then the Java code generator will generate a separate .java
  249. // file for each top-level message, enum, and service defined in the .proto
  250. // file. Thus, these types will *not* be nested inside the outer class
  251. // named by java_outer_classname. However, the outer class will still be
  252. // generated to contain the file's getDescriptor() method as well as any
  253. // top-level extensions defined in the file.
  254. optional bool java_multiple_files = 10 [default=false];
  255. // If set true, then the Java code generator will generate equals() and
  256. // hashCode() methods for all messages defined in the .proto file.
  257. // This increases generated code size, potentially substantially for large
  258. // protos, which may harm a memory-constrained application.
  259. // - In the full runtime this is a speed optimization, as the
  260. // AbstractMessage base class includes reflection-based implementations of
  261. // these methods.
  262. // - In the lite runtime, setting this option changes the semantics of
  263. // equals() and hashCode() to more closely match those of the full runtime;
  264. // the generated methods compute their results based on field values rather
  265. // than object identity. (Implementations should not assume that hashcodes
  266. // will be consistent across runtimes or versions of the protocol compiler.)
  267. optional bool java_generate_equals_and_hash = 20 [default=false];
  268. // If set true, then the Java2 code generator will generate code that
  269. // throws an exception whenever an attempt is made to assign a non-UTF-8
  270. // byte sequence to a string field.
  271. // Message reflection will do the same.
  272. // However, an extension field still accepts non-UTF-8 byte sequences.
  273. // This option has no effect on when used with the lite runtime.
  274. optional bool java_string_check_utf8 = 27 [default=false];
  275. // Generated classes can be optimized for speed or code size.
  276. enum OptimizeMode {
  277. SPEED = 1; // Generate complete code for parsing, serialization,
  278. // etc.
  279. CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
  280. LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
  281. }
  282. optional OptimizeMode optimize_for = 9 [default=SPEED];
  283. // Sets the Go package where structs generated from this .proto will be
  284. // placed. If omitted, the Go package will be derived from the following:
  285. // - The basename of the package import path, if provided.
  286. // - Otherwise, the package statement in the .proto file, if present.
  287. // - Otherwise, the basename of the .proto file, without extension.
  288. optional string go_package = 11;
  289. // Should generic services be generated in each language? "Generic" services
  290. // are not specific to any particular RPC system. They are generated by the
  291. // main code generators in each language (without additional plugins).
  292. // Generic services were the only kind of service generation supported by
  293. // early versions of google.protobuf.
  294. //
  295. // Generic services are now considered deprecated in favor of using plugins
  296. // that generate code specific to your particular RPC system. Therefore,
  297. // these default to false. Old code which depends on generic services should
  298. // explicitly set them to true.
  299. optional bool cc_generic_services = 16 [default=false];
  300. optional bool java_generic_services = 17 [default=false];
  301. optional bool py_generic_services = 18 [default=false];
  302. // Is this file deprecated?
  303. // Depending on the target platform, this can emit Deprecated annotations
  304. // for everything in the file, or it will be completely ignored; in the very
  305. // least, this is a formalization for deprecating files.
  306. optional bool deprecated = 23 [default=false];
  307. // Enables the use of arenas for the proto messages in this file. This applies
  308. // only to generated classes for C++.
  309. optional bool cc_enable_arenas = 31 [default=false];
  310. // Sets the objective c class prefix which is prepended to all objective c
  311. // generated classes from this .proto. There is no default.
  312. optional string objc_class_prefix = 36;
  313. // Namespace for generated classes; defaults to the package.
  314. optional string csharp_namespace = 37;
  315. // The parser stores options it doesn't recognize here. See above.
  316. repeated UninterpretedOption uninterpreted_option = 999;
  317. // Clients can define custom options in extensions of this message. See above.
  318. extensions 1000 to max;
  319. reserved 38;
  320. }
  321. message MessageOptions {
  322. // Set true to use the old proto1 MessageSet wire format for extensions.
  323. // This is provided for backwards-compatibility with the MessageSet wire
  324. // format. You should not use this for any other reason: It's less
  325. // efficient, has fewer features, and is more complicated.
  326. //
  327. // The message must be defined exactly as follows:
  328. // message Foo {
  329. // option message_set_wire_format = true;
  330. // extensions 4 to max;
  331. // }
  332. // Note that the message cannot have any defined fields; MessageSets only
  333. // have extensions.
  334. //
  335. // All extensions of your type must be singular messages; e.g. they cannot
  336. // be int32s, enums, or repeated messages.
  337. //
  338. // Because this is an option, the above two restrictions are not enforced by
  339. // the protocol compiler.
  340. optional bool message_set_wire_format = 1 [default=false];
  341. // Disables the generation of the standard "descriptor()" accessor, which can
  342. // conflict with a field of the same name. This is meant to make migration
  343. // from proto1 easier; new code should avoid fields named "descriptor".
  344. optional bool no_standard_descriptor_accessor = 2 [default=false];
  345. // Is this message deprecated?
  346. // Depending on the target platform, this can emit Deprecated annotations
  347. // for the message, or it will be completely ignored; in the very least,
  348. // this is a formalization for deprecating messages.
  349. optional bool deprecated = 3 [default=false];
  350. // Whether the message is an automatically generated map entry type for the
  351. // maps field.
  352. //
  353. // For maps fields:
  354. // map<KeyType, ValueType> map_field = 1;
  355. // The parsed descriptor looks like:
  356. // message MapFieldEntry {
  357. // option map_entry = true;
  358. // optional KeyType key = 1;
  359. // optional ValueType value = 2;
  360. // }
  361. // repeated MapFieldEntry map_field = 1;
  362. //
  363. // Implementations may choose not to generate the map_entry=true message, but
  364. // use a native map in the target language to hold the keys and values.
  365. // The reflection APIs in such implementions still need to work as
  366. // if the field is a repeated message field.
  367. //
  368. // NOTE: Do not set the option in .proto files. Always use the maps syntax
  369. // instead. The option should only be implicitly set by the proto compiler
  370. // parser.
  371. optional bool map_entry = 7;
  372. // The parser stores options it doesn't recognize here. See above.
  373. repeated UninterpretedOption uninterpreted_option = 999;
  374. // Clients can define custom options in extensions of this message. See above.
  375. extensions 1000 to max;
  376. }
  377. message FieldOptions {
  378. // The ctype option instructs the C++ code generator to use a different
  379. // representation of the field than it normally would. See the specific
  380. // options below. This option is not yet implemented in the open source
  381. // release -- sorry, we'll try to include it in a future version!
  382. optional CType ctype = 1 [default = STRING];
  383. enum CType {
  384. // Default mode.
  385. STRING = 0;
  386. CORD = 1;
  387. STRING_PIECE = 2;
  388. }
  389. // The packed option can be enabled for repeated primitive fields to enable
  390. // a more efficient representation on the wire. Rather than repeatedly
  391. // writing the tag and type for each element, the entire array is encoded as
  392. // a single length-delimited blob. In proto3, only explicit setting it to
  393. // false will avoid using packed encoding.
  394. optional bool packed = 2;
  395. // The jstype option determines the JavaScript type used for values of the
  396. // field. The option is permitted only for 64 bit integral and fixed types
  397. // (int64, uint64, sint64, fixed64, sfixed64). By default these types are
  398. // represented as JavaScript strings. This avoids loss of precision that can
  399. // happen when a large value is converted to a floating point JavaScript
  400. // numbers. Specifying JS_NUMBER for the jstype causes the generated
  401. // JavaScript code to use the JavaScript "number" type instead of strings.
  402. // This option is an enum to permit additional types to be added,
  403. // e.g. goog.math.Integer.
  404. optional JSType jstype = 6 [default = JS_NORMAL];
  405. enum JSType {
  406. // Use the default type.
  407. JS_NORMAL = 0;
  408. // Use JavaScript strings.
  409. JS_STRING = 1;
  410. // Use JavaScript numbers.
  411. JS_NUMBER = 2;
  412. }
  413. // Should this field be parsed lazily? Lazy applies only to message-type
  414. // fields. It means that when the outer message is initially parsed, the
  415. // inner message's contents will not be parsed but instead stored in encoded
  416. // form. The inner message will actually be parsed when it is first accessed.
  417. //
  418. // This is only a hint. Implementations are free to choose whether to use
  419. // eager or lazy parsing regardless of the value of this option. However,
  420. // setting this option true suggests that the protocol author believes that
  421. // using lazy parsing on this field is worth the additional bookkeeping
  422. // overhead typically needed to implement it.
  423. //
  424. // This option does not affect the public interface of any generated code;
  425. // all method signatures remain the same. Furthermore, thread-safety of the
  426. // interface is not affected by this option; const methods remain safe to
  427. // call from multiple threads concurrently, while non-const methods continue
  428. // to require exclusive access.
  429. //
  430. //
  431. // Note that implementations may choose not to check required fields within
  432. // a lazy sub-message. That is, calling IsInitialized() on the outher message
  433. // may return true even if the inner message has missing required fields.
  434. // This is necessary because otherwise the inner message would have to be
  435. // parsed in order to perform the check, defeating the purpose of lazy
  436. // parsing. An implementation which chooses not to check required fields
  437. // must be consistent about it. That is, for any particular sub-message, the
  438. // implementation must either *always* check its required fields, or *never*
  439. // check its required fields, regardless of whether or not the message has
  440. // been parsed.
  441. optional bool lazy = 5 [default=false];
  442. // Is this field deprecated?
  443. // Depending on the target platform, this can emit Deprecated annotations
  444. // for accessors, or it will be completely ignored; in the very least, this
  445. // is a formalization for deprecating fields.
  446. optional bool deprecated = 3 [default=false];
  447. // For Google-internal migration only. Do not use.
  448. optional bool weak = 10 [default=false];
  449. // The parser stores options it doesn't recognize here. See above.
  450. repeated UninterpretedOption uninterpreted_option = 999;
  451. // Clients can define custom options in extensions of this message. See above.
  452. extensions 1000 to max;
  453. }
  454. message EnumOptions {
  455. // Set this option to true to allow mapping different tag names to the same
  456. // value.
  457. optional bool allow_alias = 2;
  458. // Is this enum deprecated?
  459. // Depending on the target platform, this can emit Deprecated annotations
  460. // for the enum, or it will be completely ignored; in the very least, this
  461. // is a formalization for deprecating enums.
  462. optional bool deprecated = 3 [default=false];
  463. // The parser stores options it doesn't recognize here. See above.
  464. repeated UninterpretedOption uninterpreted_option = 999;
  465. // Clients can define custom options in extensions of this message. See above.
  466. extensions 1000 to max;
  467. }
  468. message EnumValueOptions {
  469. // Is this enum value deprecated?
  470. // Depending on the target platform, this can emit Deprecated annotations
  471. // for the enum value, or it will be completely ignored; in the very least,
  472. // this is a formalization for deprecating enum values.
  473. optional bool deprecated = 1 [default=false];
  474. // The parser stores options it doesn't recognize here. See above.
  475. repeated UninterpretedOption uninterpreted_option = 999;
  476. // Clients can define custom options in extensions of this message. See above.
  477. extensions 1000 to max;
  478. }
  479. message ServiceOptions {
  480. // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
  481. // framework. We apologize for hoarding these numbers to ourselves, but
  482. // we were already using them long before we decided to release Protocol
  483. // Buffers.
  484. // Is this service deprecated?
  485. // Depending on the target platform, this can emit Deprecated annotations
  486. // for the service, or it will be completely ignored; in the very least,
  487. // this is a formalization for deprecating services.
  488. optional bool deprecated = 33 [default=false];
  489. // The parser stores options it doesn't recognize here. See above.
  490. repeated UninterpretedOption uninterpreted_option = 999;
  491. // Clients can define custom options in extensions of this message. See above.
  492. extensions 1000 to max;
  493. }
  494. message MethodOptions {
  495. // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
  496. // framework. We apologize for hoarding these numbers to ourselves, but
  497. // we were already using them long before we decided to release Protocol
  498. // Buffers.
  499. // Is this method deprecated?
  500. // Depending on the target platform, this can emit Deprecated annotations
  501. // for the method, or it will be completely ignored; in the very least,
  502. // this is a formalization for deprecating methods.
  503. optional bool deprecated = 33 [default=false];
  504. // The parser stores options it doesn't recognize here. See above.
  505. repeated UninterpretedOption uninterpreted_option = 999;
  506. // Clients can define custom options in extensions of this message. See above.
  507. extensions 1000 to max;
  508. }
  509. // A message representing a option the parser does not recognize. This only
  510. // appears in options protos created by the compiler::Parser class.
  511. // DescriptorPool resolves these when building Descriptor objects. Therefore,
  512. // options protos in descriptor objects (e.g. returned by Descriptor::options(),
  513. // or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
  514. // in them.
  515. message UninterpretedOption {
  516. // The name of the uninterpreted option. Each string represents a segment in
  517. // a dot-separated name. is_extension is true iff a segment represents an
  518. // extension (denoted with parentheses in options specs in .proto files).
  519. // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
  520. // "foo.(bar.baz).qux".
  521. message NamePart {
  522. required string name_part = 1;
  523. required bool is_extension = 2;
  524. }
  525. repeated NamePart name = 2;
  526. // The value of the uninterpreted option, in whatever type the tokenizer
  527. // identified it as during parsing. Exactly one of these should be set.
  528. optional string identifier_value = 3;
  529. optional uint64 positive_int_value = 4;
  530. optional int64 negative_int_value = 5;
  531. optional double double_value = 6;
  532. optional bytes string_value = 7;
  533. optional string aggregate_value = 8;
  534. }
  535. // ===================================================================
  536. // Optional source code info
  537. // Encapsulates information about the original source file from which a
  538. // FileDescriptorProto was generated.
  539. message SourceCodeInfo {
  540. // A Location identifies a piece of source code in a .proto file which
  541. // corresponds to a particular definition. This information is intended
  542. // to be useful to IDEs, code indexers, documentation generators, and similar
  543. // tools.
  544. //
  545. // For example, say we have a file like:
  546. // message Foo {
  547. // optional string foo = 1;
  548. // }
  549. // Let's look at just the field definition:
  550. // optional string foo = 1;
  551. // ^ ^^ ^^ ^ ^^^
  552. // a bc de f ghi
  553. // We have the following locations:
  554. // span path represents
  555. // [a,i) [ 4, 0, 2, 0 ] The whole field definition.
  556. // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
  557. // [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
  558. // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
  559. // [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
  560. //
  561. // Notes:
  562. // - A location may refer to a repeated field itself (i.e. not to any
  563. // particular index within it). This is used whenever a set of elements are
  564. // logically enclosed in a single code segment. For example, an entire
  565. // extend block (possibly containing multiple extension definitions) will
  566. // have an outer location whose path refers to the "extensions" repeated
  567. // field without an index.
  568. // - Multiple locations may have the same path. This happens when a single
  569. // logical declaration is spread out across multiple places. The most
  570. // obvious example is the "extend" block again -- there may be multiple
  571. // extend blocks in the same scope, each of which will have the same path.
  572. // - A location's span is not always a subset of its parent's span. For
  573. // example, the "extendee" of an extension declaration appears at the
  574. // beginning of the "extend" block and is shared by all extensions within
  575. // the block.
  576. // - Just because a location's span is a subset of some other location's span
  577. // does not mean that it is a descendent. For example, a "group" defines
  578. // both a type and a field in a single declaration. Thus, the locations
  579. // corresponding to the type and field and their components will overlap.
  580. // - Code which tries to interpret locations should probably be designed to
  581. // ignore those that it doesn't understand, as more types of locations could
  582. // be recorded in the future.
  583. repeated Location location = 1;
  584. message Location {
  585. // Identifies which part of the FileDescriptorProto was defined at this
  586. // location.
  587. //
  588. // Each element is a field number or an index. They form a path from
  589. // the root FileDescriptorProto to the place where the definition. For
  590. // example, this path:
  591. // [ 4, 3, 2, 7, 1 ]
  592. // refers to:
  593. // file.message_type(3) // 4, 3
  594. // .field(7) // 2, 7
  595. // .name() // 1
  596. // This is because FileDescriptorProto.message_type has field number 4:
  597. // repeated DescriptorProto message_type = 4;
  598. // and DescriptorProto.field has field number 2:
  599. // repeated FieldDescriptorProto field = 2;
  600. // and FieldDescriptorProto.name has field number 1:
  601. // optional string name = 1;
  602. //
  603. // Thus, the above path gives the location of a field name. If we removed
  604. // the last element:
  605. // [ 4, 3, 2, 7 ]
  606. // this path refers to the whole field declaration (from the beginning
  607. // of the label to the terminating semicolon).
  608. repeated int32 path = 1 [packed=true];
  609. // Always has exactly three or four elements: start line, start column,
  610. // end line (optional, otherwise assumed same as start line), end column.
  611. // These are packed into a single field for efficiency. Note that line
  612. // and column numbers are zero-based -- typically you will want to add
  613. // 1 to each before displaying to a user.
  614. repeated int32 span = 2 [packed=true];
  615. // If this SourceCodeInfo represents a complete declaration, these are any
  616. // comments appearing before and after the declaration which appear to be
  617. // attached to the declaration.
  618. //
  619. // A series of line comments appearing on consecutive lines, with no other
  620. // tokens appearing on those lines, will be treated as a single comment.
  621. //
  622. // leading_detached_comments will keep paragraphs of comments that appear
  623. // before (but not connected to) the current element. Each paragraph,
  624. // separated by empty lines, will be one comment element in the repeated
  625. // field.
  626. //
  627. // Only the comment content is provided; comment markers (e.g. //) are
  628. // stripped out. For block comments, leading whitespace and an asterisk
  629. // will be stripped from the beginning of each line other than the first.
  630. // Newlines are included in the output.
  631. //
  632. // Examples:
  633. //
  634. // optional int32 foo = 1; // Comment attached to foo.
  635. // // Comment attached to bar.
  636. // optional int32 bar = 2;
  637. //
  638. // optional string baz = 3;
  639. // // Comment attached to baz.
  640. // // Another line attached to baz.
  641. //
  642. // // Comment attached to qux.
  643. // //
  644. // // Another line attached to qux.
  645. // optional double qux = 4;
  646. //
  647. // // Detached comment for corge. This is not leading or trailing comments
  648. // // to qux or corge because there are blank lines separating it from
  649. // // both.
  650. //
  651. // // Detached comment for corge paragraph 2.
  652. //
  653. // optional string corge = 5;
  654. // /* Block comment attached
  655. // * to corge. Leading asterisks
  656. // * will be removed. */
  657. // /* Block comment attached to
  658. // * grault. */
  659. // optional int32 grault = 6;
  660. //
  661. // // ignored detached comments.
  662. optional string leading_comments = 3;
  663. optional string trailing_comments = 4;
  664. repeated string leading_detached_comments = 6;
  665. }
  666. }
  667. // Describes the relationship between generated code and its original source
  668. // file. A GeneratedCodeInfo message is associated with only one generated
  669. // source file, but may contain references to different source .proto files.
  670. message GeneratedCodeInfo {
  671. // An Annotation connects some span of text in generated code to an element
  672. // of its generating .proto file.
  673. repeated Annotation annotation = 1;
  674. message Annotation {
  675. // Identifies the element in the original source .proto file. This field
  676. // is formatted the same as SourceCodeInfo.Location.path.
  677. repeated int32 path = 1 [packed=true];
  678. // Identifies the filesystem path to the original source .proto.
  679. optional string source_file = 2;
  680. // Identifies the starting offset in bytes in the generated code
  681. // that relates to the identified object.
  682. optional int32 begin = 3;
  683. // Identifies the ending offset in bytes in the generated code that
  684. // relates to the identified offset. The end offset should be one past
  685. // the last relevant byte (so the length of the text = end - begin).
  686. optional int32 end = 4;
  687. }
  688. }