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