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