descriptor.proto 36 KB

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