OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 22 matching lines...) Expand all Loading... |
33 // Sanjay Ghemawat, Jeff Dean, and others. | 33 // Sanjay Ghemawat, Jeff Dean, and others. |
34 // | 34 // |
35 // The messages in this file describe the definitions found in .proto files. | 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 | 36 // A valid .proto file can be translated directly to a FileDescriptorProto |
37 // without any other information (e.g. without reading its imports). | 37 // without any other information (e.g. without reading its imports). |
38 | 38 |
39 | 39 |
40 syntax = "proto2"; | 40 syntax = "proto2"; |
41 | 41 |
42 package google.protobuf; | 42 package google.protobuf; |
43 option go_package = "descriptor"; | 43 option go_package = "github.com/golang/protobuf/protoc-gen-go/descriptor;descrip
tor"; |
44 option java_package = "com.google.protobuf"; | 44 option java_package = "com.google.protobuf"; |
45 option java_outer_classname = "DescriptorProtos"; | 45 option java_outer_classname = "DescriptorProtos"; |
46 option csharp_namespace = "Google.Protobuf.Reflection"; | 46 option csharp_namespace = "Google.Protobuf.Reflection"; |
47 option objc_class_prefix = "GPB"; | 47 option objc_class_prefix = "GPB"; |
48 | 48 |
49 // descriptor.proto must be optimized for speed because reflection-based | 49 // descriptor.proto must be optimized for speed because reflection-based |
50 // algorithms don't work during bootstrapping. | 50 // algorithms don't work during bootstrapping. |
51 option optimize_for = SPEED; | 51 option optimize_for = SPEED; |
52 | 52 |
53 // The protocol compiler can output a FileDescriptorSet containing the .proto | 53 // The protocol compiler can output a FileDescriptorSet containing the .proto |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 TYPE_SFIXED64 = 16; | 150 TYPE_SFIXED64 = 16; |
151 TYPE_SINT32 = 17; // Uses ZigZag encoding. | 151 TYPE_SINT32 = 17; // Uses ZigZag encoding. |
152 TYPE_SINT64 = 18; // Uses ZigZag encoding. | 152 TYPE_SINT64 = 18; // Uses ZigZag encoding. |
153 }; | 153 }; |
154 | 154 |
155 enum Label { | 155 enum Label { |
156 // 0 is reserved for errors | 156 // 0 is reserved for errors |
157 LABEL_OPTIONAL = 1; | 157 LABEL_OPTIONAL = 1; |
158 LABEL_REQUIRED = 2; | 158 LABEL_REQUIRED = 2; |
159 LABEL_REPEATED = 3; | 159 LABEL_REPEATED = 3; |
160 // TODO(sanjay): Should we add LABEL_MAP? | |
161 }; | 160 }; |
162 | 161 |
163 optional string name = 1; | 162 optional string name = 1; |
164 optional int32 number = 3; | 163 optional int32 number = 3; |
165 optional Label label = 4; | 164 optional Label label = 4; |
166 | 165 |
167 // If type_name is set, this need not be set. If both this and type_name | 166 // If type_name is set, this need not be set. If both this and type_name |
168 // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. | 167 // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. |
169 optional Type type = 5; | 168 optional Type type = 5; |
170 | 169 |
(...skipping 24 matching lines...) Expand all Loading... |
195 // will be used. Otherwise, it's deduced from the field's name by converting | 194 // will be used. Otherwise, it's deduced from the field's name by converting |
196 // it to camelCase. | 195 // it to camelCase. |
197 optional string json_name = 10; | 196 optional string json_name = 10; |
198 | 197 |
199 optional FieldOptions options = 8; | 198 optional FieldOptions options = 8; |
200 } | 199 } |
201 | 200 |
202 // Describes a oneof. | 201 // Describes a oneof. |
203 message OneofDescriptorProto { | 202 message OneofDescriptorProto { |
204 optional string name = 1; | 203 optional string name = 1; |
| 204 optional OneofOptions options = 2; |
205 } | 205 } |
206 | 206 |
207 // Describes an enum type. | 207 // Describes an enum type. |
208 message EnumDescriptorProto { | 208 message EnumDescriptorProto { |
209 optional string name = 1; | 209 optional string name = 1; |
210 | 210 |
211 repeated EnumValueDescriptorProto value = 2; | 211 repeated EnumValueDescriptorProto value = 2; |
212 | 212 |
213 optional EnumOptions options = 3; | 213 optional EnumOptions options = 3; |
214 } | 214 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 optional string java_outer_classname = 8; | 297 optional string java_outer_classname = 8; |
298 | 298 |
299 // If set true, then the Java code generator will generate a separate .java | 299 // If set true, then the Java code generator will generate a separate .java |
300 // file for each top-level message, enum, and service defined in the .proto | 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 outer class | 301 // file. Thus, these types will *not* be nested inside the outer class |
302 // named by java_outer_classname. However, the outer class will still be | 302 // named by java_outer_classname. However, the outer class will still be |
303 // generated to contain the file's getDescriptor() method as well as any | 303 // generated to contain the file's getDescriptor() method as well as any |
304 // top-level extensions defined in the file. | 304 // top-level extensions defined in the file. |
305 optional bool java_multiple_files = 10 [default=false]; | 305 optional bool java_multiple_files = 10 [default=false]; |
306 | 306 |
307 // If set true, then the Java code generator will generate equals() and | 307 // This option does nothing. |
308 // hashCode() methods for all messages defined in the .proto file. | 308 optional bool java_generate_equals_and_hash = 20 [deprecated=true]; |
309 // This increases generated code size, potentially substantially for large | |
310 // protos, which may harm a memory-constrained application. | |
311 // - In the full runtime this is a speed optimization, as the | |
312 // AbstractMessage base class includes reflection-based implementations of | |
313 // these methods. | |
314 // - In the lite runtime, setting this option changes the semantics of | |
315 // equals() and hashCode() to more closely match those of the full runtime; | |
316 // the generated methods compute their results based on field values rather | |
317 // than object identity. (Implementations should not assume that hashcodes | |
318 // will be consistent across runtimes or versions of the protocol compiler.) | |
319 optional bool java_generate_equals_and_hash = 20 [default=false]; | |
320 | 309 |
321 // If set true, then the Java2 code generator will generate code that | 310 // If set true, then the Java2 code generator will generate code that |
322 // throws an exception whenever an attempt is made to assign a non-UTF-8 | 311 // throws an exception whenever an attempt is made to assign a non-UTF-8 |
323 // byte sequence to a string field. | 312 // byte sequence to a string field. |
324 // Message reflection will do the same. | 313 // Message reflection will do the same. |
325 // However, an extension field still accepts non-UTF-8 byte sequences. | 314 // However, an extension field still accepts non-UTF-8 byte sequences. |
326 // This option has no effect on when used with the lite runtime. | 315 // This option has no effect on when used with the lite runtime. |
327 optional bool java_string_check_utf8 = 27 [default=false]; | 316 optional bool java_string_check_utf8 = 27 [default=false]; |
328 | 317 |
329 | 318 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 optional bool cc_enable_arenas = 31 [default=false]; | 359 optional bool cc_enable_arenas = 31 [default=false]; |
371 | 360 |
372 | 361 |
373 // Sets the objective c class prefix which is prepended to all objective c | 362 // Sets the objective c class prefix which is prepended to all objective c |
374 // generated classes from this .proto. There is no default. | 363 // generated classes from this .proto. There is no default. |
375 optional string objc_class_prefix = 36; | 364 optional string objc_class_prefix = 36; |
376 | 365 |
377 // Namespace for generated classes; defaults to the package. | 366 // Namespace for generated classes; defaults to the package. |
378 optional string csharp_namespace = 37; | 367 optional string csharp_namespace = 37; |
379 | 368 |
| 369 // By default Swift generators will take the proto package and CamelCase it |
| 370 // replacing '.' with underscore and use that to prefix the types/symbols |
| 371 // defined. When this options is provided, they will use this value instead |
| 372 // to prefix the types/symbols defined. |
| 373 optional string swift_prefix = 39; |
| 374 |
380 // The parser stores options it doesn't recognize here. See above. | 375 // The parser stores options it doesn't recognize here. See above. |
381 repeated UninterpretedOption uninterpreted_option = 999; | 376 repeated UninterpretedOption uninterpreted_option = 999; |
382 | 377 |
383 // Clients can define custom options in extensions of this message. See above. | 378 // Clients can define custom options in extensions of this message. See above. |
384 extensions 1000 to max; | 379 extensions 1000 to max; |
385 | 380 |
386 reserved 38; | 381 reserved 38; |
387 } | 382 } |
388 | 383 |
389 message MessageOptions { | 384 message MessageOptions { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 // Implementations may choose not to generate the map_entry=true message, but | 429 // Implementations may choose not to generate the map_entry=true message, but |
435 // use a native map in the target language to hold the keys and values. | 430 // use a native map in the target language to hold the keys and values. |
436 // The reflection APIs in such implementions still need to work as | 431 // The reflection APIs in such implementions still need to work as |
437 // if the field is a repeated message field. | 432 // if the field is a repeated message field. |
438 // | 433 // |
439 // NOTE: Do not set the option in .proto files. Always use the maps syntax | 434 // NOTE: Do not set the option in .proto files. Always use the maps syntax |
440 // instead. The option should only be implicitly set by the proto compiler | 435 // instead. The option should only be implicitly set by the proto compiler |
441 // parser. | 436 // parser. |
442 optional bool map_entry = 7; | 437 optional bool map_entry = 7; |
443 | 438 |
| 439 reserved 8; // javalite_serializable |
| 440 |
| 441 |
444 // The parser stores options it doesn't recognize here. See above. | 442 // The parser stores options it doesn't recognize here. See above. |
445 repeated UninterpretedOption uninterpreted_option = 999; | 443 repeated UninterpretedOption uninterpreted_option = 999; |
446 | 444 |
447 // Clients can define custom options in extensions of this message. See above. | 445 // Clients can define custom options in extensions of this message. See above. |
448 extensions 1000 to max; | 446 extensions 1000 to max; |
449 } | 447 } |
450 | 448 |
451 message FieldOptions { | 449 message FieldOptions { |
452 // The ctype option instructs the C++ code generator to use a different | 450 // The ctype option instructs the C++ code generator to use a different |
453 // representation of the field than it normally would. See the specific | 451 // representation of the field than it normally would. See the specific |
454 // options below. This option is not yet implemented in the open source | 452 // options below. This option is not yet implemented in the open source |
455 // release -- sorry, we'll try to include it in a future version! | 453 // release -- sorry, we'll try to include it in a future version! |
456 optional CType ctype = 1 [default = STRING]; | 454 optional CType ctype = 1 [default = STRING]; |
457 enum CType { | 455 enum CType { |
458 // Default mode. | 456 // Default mode. |
459 STRING = 0; | 457 STRING = 0; |
460 | 458 |
461 CORD = 1; | 459 CORD = 1; |
462 | 460 |
463 STRING_PIECE = 2; | 461 STRING_PIECE = 2; |
464 } | 462 } |
465 // The packed option can be enabled for repeated primitive fields to enable | 463 // The packed option can be enabled for repeated primitive fields to enable |
466 // a more efficient representation on the wire. Rather than repeatedly | 464 // a more efficient representation on the wire. Rather than repeatedly |
467 // writing the tag and type for each element, the entire array is encoded as | 465 // writing the tag and type for each element, the entire array is encoded as |
468 // a single length-delimited blob. In proto3, only explicit setting it to | 466 // a single length-delimited blob. In proto3, only explicit setting it to |
469 // false will avoid using packed encoding. | 467 // false will avoid using packed encoding. |
470 optional bool packed = 2; | 468 optional bool packed = 2; |
471 | 469 |
472 | |
473 // The jstype option determines the JavaScript type used for values of the | 470 // The jstype option determines the JavaScript type used for values of the |
474 // field. The option is permitted only for 64 bit integral and fixed types | 471 // field. The option is permitted only for 64 bit integral and fixed types |
475 // (int64, uint64, sint64, fixed64, sfixed64). By default these types are | 472 // (int64, uint64, sint64, fixed64, sfixed64). By default these types are |
476 // represented as JavaScript strings. This avoids loss of precision that can | 473 // represented as JavaScript strings. This avoids loss of precision that can |
477 // happen when a large value is converted to a floating point JavaScript | 474 // happen when a large value is converted to a floating point JavaScript |
478 // numbers. Specifying JS_NUMBER for the jstype causes the generated | 475 // numbers. Specifying JS_NUMBER for the jstype causes the generated |
479 // JavaScript code to use the JavaScript "number" type instead of strings. | 476 // JavaScript code to use the JavaScript "number" type instead of strings. |
480 // This option is an enum to permit additional types to be added, | 477 // This option is an enum to permit additional types to be added, |
481 // e.g. goog.math.Integer. | 478 // e.g. goog.math.Integer. |
482 optional JSType jstype = 6 [default = JS_NORMAL]; | 479 optional JSType jstype = 6 [default = JS_NORMAL]; |
(...skipping 20 matching lines...) Expand all Loading... |
503 // overhead typically needed to implement it. | 500 // overhead typically needed to implement it. |
504 // | 501 // |
505 // This option does not affect the public interface of any generated code; | 502 // This option does not affect the public interface of any generated code; |
506 // all method signatures remain the same. Furthermore, thread-safety of the | 503 // all method signatures remain the same. Furthermore, thread-safety of the |
507 // interface is not affected by this option; const methods remain safe to | 504 // interface is not affected by this option; const methods remain safe to |
508 // call from multiple threads concurrently, while non-const methods continue | 505 // call from multiple threads concurrently, while non-const methods continue |
509 // to require exclusive access. | 506 // to require exclusive access. |
510 // | 507 // |
511 // | 508 // |
512 // Note that implementations may choose not to check required fields within | 509 // Note that implementations may choose not to check required fields within |
513 // a lazy sub-message. That is, calling IsInitialized() on the outher message | 510 // a lazy sub-message. That is, calling IsInitialized() on the outer message |
514 // may return true even if the inner message has missing required fields. | 511 // may return true even if the inner message has missing required fields. |
515 // This is necessary because otherwise the inner message would have to be | 512 // This is necessary because otherwise the inner message would have to be |
516 // parsed in order to perform the check, defeating the purpose of lazy | 513 // parsed in order to perform the check, defeating the purpose of lazy |
517 // parsing. An implementation which chooses not to check required fields | 514 // parsing. An implementation which chooses not to check required fields |
518 // must be consistent about it. That is, for any particular sub-message, the | 515 // must be consistent about it. That is, for any particular sub-message, the |
519 // implementation must either *always* check its required fields, or *never* | 516 // implementation must either *always* check its required fields, or *never* |
520 // check its required fields, regardless of whether or not the message has | 517 // check its required fields, regardless of whether or not the message has |
521 // been parsed. | 518 // been parsed. |
522 optional bool lazy = 5 [default=false]; | 519 optional bool lazy = 5 [default=false]; |
523 | 520 |
524 // Is this field deprecated? | 521 // Is this field deprecated? |
525 // Depending on the target platform, this can emit Deprecated annotations | 522 // Depending on the target platform, this can emit Deprecated annotations |
526 // for accessors, or it will be completely ignored; in the very least, this | 523 // for accessors, or it will be completely ignored; in the very least, this |
527 // is a formalization for deprecating fields. | 524 // is a formalization for deprecating fields. |
528 optional bool deprecated = 3 [default=false]; | 525 optional bool deprecated = 3 [default=false]; |
529 | 526 |
530 // For Google-internal migration only. Do not use. | 527 // For Google-internal migration only. Do not use. |
531 optional bool weak = 10 [default=false]; | 528 optional bool weak = 10 [default=false]; |
532 | 529 |
533 | 530 |
534 // The parser stores options it doesn't recognize here. See above. | 531 // The parser stores options it doesn't recognize here. See above. |
535 repeated UninterpretedOption uninterpreted_option = 999; | 532 repeated UninterpretedOption uninterpreted_option = 999; |
536 | 533 |
537 // Clients can define custom options in extensions of this message. See above. | 534 // Clients can define custom options in extensions of this message. See above. |
538 extensions 1000 to max; | 535 extensions 1000 to max; |
| 536 |
| 537 reserved 4; // removed jtype |
| 538 } |
| 539 |
| 540 message OneofOptions { |
| 541 // The parser stores options it doesn't recognize here. See above. |
| 542 repeated UninterpretedOption uninterpreted_option = 999; |
| 543 |
| 544 // Clients can define custom options in extensions of this message. See above. |
| 545 extensions 1000 to max; |
539 } | 546 } |
540 | 547 |
541 message EnumOptions { | 548 message EnumOptions { |
542 | 549 |
543 // Set this option to true to allow mapping different tag names to the same | 550 // Set this option to true to allow mapping different tag names to the same |
544 // value. | 551 // value. |
545 optional bool allow_alias = 2; | 552 optional bool allow_alias = 2; |
546 | 553 |
547 // Is this enum deprecated? | 554 // Is this enum deprecated? |
548 // Depending on the target platform, this can emit Deprecated annotations | 555 // Depending on the target platform, this can emit Deprecated annotations |
549 // for the enum, or it will be completely ignored; in the very least, this | 556 // for the enum, or it will be completely ignored; in the very least, this |
550 // is a formalization for deprecating enums. | 557 // is a formalization for deprecating enums. |
551 optional bool deprecated = 3 [default=false]; | 558 optional bool deprecated = 3 [default=false]; |
552 | 559 |
| 560 |
553 // The parser stores options it doesn't recognize here. See above. | 561 // The parser stores options it doesn't recognize here. See above. |
554 repeated UninterpretedOption uninterpreted_option = 999; | 562 repeated UninterpretedOption uninterpreted_option = 999; |
555 | 563 |
556 // Clients can define custom options in extensions of this message. See above. | 564 // Clients can define custom options in extensions of this message. See above. |
557 extensions 1000 to max; | 565 extensions 1000 to max; |
558 } | 566 } |
559 | 567 |
560 message EnumValueOptions { | 568 message EnumValueOptions { |
561 // Is this enum value deprecated? | 569 // Is this enum value deprecated? |
562 // Depending on the target platform, this can emit Deprecated annotations | 570 // Depending on the target platform, this can emit Deprecated annotations |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 // framework. We apologize for hoarding these numbers to ourselves, but | 605 // framework. We apologize for hoarding these numbers to ourselves, but |
598 // we were already using them long before we decided to release Protocol | 606 // we were already using them long before we decided to release Protocol |
599 // Buffers. | 607 // Buffers. |
600 | 608 |
601 // Is this method deprecated? | 609 // Is this method deprecated? |
602 // Depending on the target platform, this can emit Deprecated annotations | 610 // Depending on the target platform, this can emit Deprecated annotations |
603 // for the method, or it will be completely ignored; in the very least, | 611 // for the method, or it will be completely ignored; in the very least, |
604 // this is a formalization for deprecating methods. | 612 // this is a formalization for deprecating methods. |
605 optional bool deprecated = 33 [default=false]; | 613 optional bool deprecated = 33 [default=false]; |
606 | 614 |
| 615 // Is this method side-effect-free (or safe in HTTP parlance), or idempotent, |
| 616 // or neither? HTTP based RPC implementation may choose GET verb for safe |
| 617 // methods, and PUT verb for idempotent methods instead of the default POST. |
| 618 enum IdempotencyLevel { |
| 619 IDEMPOTENCY_UNKNOWN = 0; |
| 620 NO_SIDE_EFFECTS = 1; // implies idempotent |
| 621 IDEMPOTENT = 2; // idempotent, but may have side effects |
| 622 } |
| 623 optional IdempotencyLevel idempotency_level = |
| 624 34 [default=IDEMPOTENCY_UNKNOWN]; |
| 625 |
607 // The parser stores options it doesn't recognize here. See above. | 626 // The parser stores options it doesn't recognize here. See above. |
608 repeated UninterpretedOption uninterpreted_option = 999; | 627 repeated UninterpretedOption uninterpreted_option = 999; |
609 | 628 |
610 // Clients can define custom options in extensions of this message. See above. | 629 // Clients can define custom options in extensions of this message. See above. |
611 extensions 1000 to max; | 630 extensions 1000 to max; |
612 } | 631 } |
613 | 632 |
614 | 633 |
615 // A message representing a option the parser does not recognize. This only | 634 // A message representing a option the parser does not recognize. This only |
616 // appears in options protos created by the compiler::Parser class. | 635 // appears in options protos created by the compiler::Parser class. |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 // Identifies the starting offset in bytes in the generated code | 813 // Identifies the starting offset in bytes in the generated code |
795 // that relates to the identified object. | 814 // that relates to the identified object. |
796 optional int32 begin = 3; | 815 optional int32 begin = 3; |
797 | 816 |
798 // Identifies the ending offset in bytes in the generated code that | 817 // Identifies the ending offset in bytes in the generated code that |
799 // relates to the identified offset. The end offset should be one past | 818 // relates to the identified offset. The end offset should be one past |
800 // the last relevant byte (so the length of the text = end - begin). | 819 // the last relevant byte (so the length of the text = end - begin). |
801 optional int32 end = 4; | 820 optional int32 end = 4; |
802 } | 821 } |
803 } | 822 } |
OLD | NEW |