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