descriptor.proto 35 KB

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