descriptor.proto 37 KB

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