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