descriptor.proto 34 KB

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