protoc-gen-twirp_ruby 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1280 @@
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
+ syntax = "proto2";
40
+
41
+ package google.protobuf;
42
+
43
+ option go_package = "google.golang.org/protobuf/types/descriptorpb";
44
+ option java_package = "com.google.protobuf";
45
+ option java_outer_classname = "DescriptorProtos";
46
+ option csharp_namespace = "Google.Protobuf.Reflection";
47
+ option objc_class_prefix = "GPB";
48
+ option cc_enable_arenas = true;
49
+
50
+ // descriptor.proto must be optimized for speed because reflection-based
51
+ // algorithms don't work during bootstrapping.
52
+ option optimize_for = SPEED;
53
+
54
+ // The protocol compiler can output a FileDescriptorSet containing the .proto
55
+ // files it parses.
56
+ message FileDescriptorSet {
57
+ repeated FileDescriptorProto file = 1;
58
+ }
59
+
60
+ // The full set of known editions.
61
+ enum Edition {
62
+ // A placeholder for an unknown edition value.
63
+ EDITION_UNKNOWN = 0;
64
+
65
+ // A placeholder edition for specifying default behaviors *before* a feature
66
+ // was first introduced. This is effectively an "infinite past".
67
+ EDITION_LEGACY = 900;
68
+
69
+ // Legacy syntax "editions". These pre-date editions, but behave much like
70
+ // distinct editions. These can't be used to specify the edition of proto
71
+ // files, but feature definitions must supply proto2/proto3 defaults for
72
+ // backwards compatibility.
73
+ EDITION_PROTO2 = 998;
74
+ EDITION_PROTO3 = 999;
75
+
76
+ // Editions that have been released. The specific values are arbitrary and
77
+ // should not be depended on, but they will always be time-ordered for easy
78
+ // comparison.
79
+ EDITION_2023 = 1000;
80
+ EDITION_2024 = 1001;
81
+
82
+ // Placeholder editions for testing feature resolution. These should not be
83
+ // used or relyed on outside of tests.
84
+ EDITION_1_TEST_ONLY = 1;
85
+ EDITION_2_TEST_ONLY = 2;
86
+ EDITION_99997_TEST_ONLY = 99997;
87
+ EDITION_99998_TEST_ONLY = 99998;
88
+ EDITION_99999_TEST_ONLY = 99999;
89
+
90
+ // Placeholder for specifying unbounded edition support. This should only
91
+ // ever be used by plugins that can expect to never require any changes to
92
+ // support a new edition.
93
+ EDITION_MAX = 0x7FFFFFFF;
94
+ }
95
+
96
+ // Describes a complete .proto file.
97
+ message FileDescriptorProto {
98
+ optional string name = 1; // file name, relative to root of source tree
99
+ optional string package = 2; // e.g. "foo", "foo.bar", etc.
100
+
101
+ // Names of files imported by this file.
102
+ repeated string dependency = 3;
103
+ // Indexes of the public imported files in the dependency list above.
104
+ repeated int32 public_dependency = 10;
105
+ // Indexes of the weak imported files in the dependency list.
106
+ // For Google-internal migration only. Do not use.
107
+ repeated int32 weak_dependency = 11;
108
+
109
+ // All top-level definitions in this file.
110
+ repeated DescriptorProto message_type = 4;
111
+ repeated EnumDescriptorProto enum_type = 5;
112
+ repeated ServiceDescriptorProto service = 6;
113
+ repeated FieldDescriptorProto extension = 7;
114
+
115
+ optional FileOptions options = 8;
116
+
117
+ // This field contains optional information about the original source code.
118
+ // You may safely remove this entire field without harming runtime
119
+ // functionality of the descriptors -- the information is needed only by
120
+ // development tools.
121
+ optional SourceCodeInfo source_code_info = 9;
122
+
123
+ // The syntax of the proto file.
124
+ // The supported values are "proto2", "proto3", and "editions".
125
+ //
126
+ // If `edition` is present, this value must be "editions".
127
+ optional string syntax = 12;
128
+
129
+ // The edition of the proto file.
130
+ optional Edition edition = 14;
131
+ }
132
+
133
+ // Describes a message type.
134
+ message DescriptorProto {
135
+ optional string name = 1;
136
+
137
+ repeated FieldDescriptorProto field = 2;
138
+ repeated FieldDescriptorProto extension = 6;
139
+
140
+ repeated DescriptorProto nested_type = 3;
141
+ repeated EnumDescriptorProto enum_type = 4;
142
+
143
+ message ExtensionRange {
144
+ optional int32 start = 1; // Inclusive.
145
+ optional int32 end = 2; // Exclusive.
146
+
147
+ optional ExtensionRangeOptions options = 3;
148
+ }
149
+ repeated ExtensionRange extension_range = 5;
150
+
151
+ repeated OneofDescriptorProto oneof_decl = 8;
152
+
153
+ optional MessageOptions options = 7;
154
+
155
+ // Range of reserved tag numbers. Reserved tag numbers may not be used by
156
+ // fields or extension ranges in the same message. Reserved ranges may
157
+ // not overlap.
158
+ message ReservedRange {
159
+ optional int32 start = 1; // Inclusive.
160
+ optional int32 end = 2; // Exclusive.
161
+ }
162
+ repeated ReservedRange reserved_range = 9;
163
+ // Reserved field names, which may not be used by fields in the same message.
164
+ // A given name may only be reserved once.
165
+ repeated string reserved_name = 10;
166
+ }
167
+
168
+ message ExtensionRangeOptions {
169
+ // The parser stores options it doesn't recognize here. See above.
170
+ repeated UninterpretedOption uninterpreted_option = 999;
171
+
172
+ message Declaration {
173
+ // The extension number declared within the extension range.
174
+ optional int32 number = 1;
175
+
176
+ // The fully-qualified name of the extension field. There must be a leading
177
+ // dot in front of the full name.
178
+ optional string full_name = 2;
179
+
180
+ // The fully-qualified type name of the extension field. Unlike
181
+ // Metadata.type, Declaration.type must have a leading dot for messages
182
+ // and enums.
183
+ optional string type = 3;
184
+
185
+ // If true, indicates that the number is reserved in the extension range,
186
+ // and any extension field with the number will fail to compile. Set this
187
+ // when a declared extension field is deleted.
188
+ optional bool reserved = 5;
189
+
190
+ // If true, indicates that the extension must be defined as repeated.
191
+ // Otherwise the extension must be defined as optional.
192
+ optional bool repeated = 6;
193
+
194
+ reserved 4; // removed is_repeated
195
+ }
196
+
197
+ // For external users: DO NOT USE. We are in the process of open sourcing
198
+ // extension declaration and executing internal cleanups before it can be
199
+ // used externally.
200
+ repeated Declaration declaration = 2 [retention = RETENTION_SOURCE];
201
+
202
+ // Any features defined in the specific edition.
203
+ optional FeatureSet features = 50;
204
+
205
+ // The verification state of the extension range.
206
+ enum VerificationState {
207
+ // All the extensions of the range must be declared.
208
+ DECLARATION = 0;
209
+ UNVERIFIED = 1;
210
+ }
211
+
212
+ // The verification state of the range.
213
+ // TODO: flip the default to DECLARATION once all empty ranges
214
+ // are marked as UNVERIFIED.
215
+ optional VerificationState verification = 3
216
+ [default = UNVERIFIED, retention = RETENTION_SOURCE];
217
+
218
+ // Clients can define custom options in extensions of this message. See above.
219
+ extensions 1000 to max;
220
+ }
221
+
222
+ // Describes a field within a message.
223
+ message FieldDescriptorProto {
224
+ enum Type {
225
+ // 0 is reserved for errors.
226
+ // Order is weird for historical reasons.
227
+ TYPE_DOUBLE = 1;
228
+ TYPE_FLOAT = 2;
229
+ // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
230
+ // negative values are likely.
231
+ TYPE_INT64 = 3;
232
+ TYPE_UINT64 = 4;
233
+ // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
234
+ // negative values are likely.
235
+ TYPE_INT32 = 5;
236
+ TYPE_FIXED64 = 6;
237
+ TYPE_FIXED32 = 7;
238
+ TYPE_BOOL = 8;
239
+ TYPE_STRING = 9;
240
+ // Tag-delimited aggregate.
241
+ // Group type is deprecated and not supported after google.protobuf. However, Proto3
242
+ // implementations should still be able to parse the group wire format and
243
+ // treat group fields as unknown fields. In Editions, the group wire format
244
+ // can be enabled via the `message_encoding` feature.
245
+ TYPE_GROUP = 10;
246
+ TYPE_MESSAGE = 11; // Length-delimited aggregate.
247
+
248
+ // New in version 2.
249
+ TYPE_BYTES = 12;
250
+ TYPE_UINT32 = 13;
251
+ TYPE_ENUM = 14;
252
+ TYPE_SFIXED32 = 15;
253
+ TYPE_SFIXED64 = 16;
254
+ TYPE_SINT32 = 17; // Uses ZigZag encoding.
255
+ TYPE_SINT64 = 18; // Uses ZigZag encoding.
256
+ }
257
+
258
+ enum Label {
259
+ // 0 is reserved for errors
260
+ LABEL_OPTIONAL = 1;
261
+ LABEL_REPEATED = 3;
262
+ // The required label is only allowed in google.protobuf. In proto3 and Editions
263
+ // it's explicitly prohibited. In Editions, the `field_presence` feature
264
+ // can be used to get this behavior.
265
+ LABEL_REQUIRED = 2;
266
+ }
267
+
268
+ optional string name = 1;
269
+ optional int32 number = 3;
270
+ optional Label label = 4;
271
+
272
+ // If type_name is set, this need not be set. If both this and type_name
273
+ // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
274
+ optional Type type = 5;
275
+
276
+ // For message and enum types, this is the name of the type. If the name
277
+ // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
278
+ // rules are used to find the type (i.e. first the nested types within this
279
+ // message are searched, then within the parent, on up to the root
280
+ // namespace).
281
+ optional string type_name = 6;
282
+
283
+ // For extensions, this is the name of the type being extended. It is
284
+ // resolved in the same manner as type_name.
285
+ optional string extendee = 2;
286
+
287
+ // For numeric types, contains the original text representation of the value.
288
+ // For booleans, "true" or "false".
289
+ // For strings, contains the default text contents (not escaped in any way).
290
+ // For bytes, contains the C escaped value. All bytes >= 128 are escaped.
291
+ optional string default_value = 7;
292
+
293
+ // If set, gives the index of a oneof in the containing type's oneof_decl
294
+ // list. This field is a member of that oneof.
295
+ optional int32 oneof_index = 9;
296
+
297
+ // JSON name of this field. The value is set by protocol compiler. If the
298
+ // user has set a "json_name" option on this field, that option's value
299
+ // will be used. Otherwise, it's deduced from the field's name by converting
300
+ // it to camelCase.
301
+ optional string json_name = 10;
302
+
303
+ optional FieldOptions options = 8;
304
+
305
+ // If true, this is a proto3 "optional". When a proto3 field is optional, it
306
+ // tracks presence regardless of field type.
307
+ //
308
+ // When proto3_optional is true, this field must belong to a oneof to signal
309
+ // to old proto3 clients that presence is tracked for this field. This oneof
310
+ // is known as a "synthetic" oneof, and this field must be its sole member
311
+ // (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs
312
+ // exist in the descriptor only, and do not generate any API. Synthetic oneofs
313
+ // must be ordered after all "real" oneofs.
314
+ //
315
+ // For message fields, proto3_optional doesn't create any semantic change,
316
+ // since non-repeated message fields always track presence. However it still
317
+ // indicates the semantic detail of whether the user wrote "optional" or not.
318
+ // This can be useful for round-tripping the .proto file. For consistency we
319
+ // give message fields a synthetic oneof also, even though it is not required
320
+ // to track presence. This is especially important because the parser can't
321
+ // tell if a field is a message or an enum, so it must always create a
322
+ // synthetic oneof.
323
+ //
324
+ // Proto2 optional fields do not set this flag, because they already indicate
325
+ // optional with `LABEL_OPTIONAL`.
326
+ optional bool proto3_optional = 17;
327
+ }
328
+
329
+ // Describes a oneof.
330
+ message OneofDescriptorProto {
331
+ optional string name = 1;
332
+ optional OneofOptions options = 2;
333
+ }
334
+
335
+ // Describes an enum type.
336
+ message EnumDescriptorProto {
337
+ optional string name = 1;
338
+
339
+ repeated EnumValueDescriptorProto value = 2;
340
+
341
+ optional EnumOptions options = 3;
342
+
343
+ // Range of reserved numeric values. Reserved values may not be used by
344
+ // entries in the same enum. Reserved ranges may not overlap.
345
+ //
346
+ // Note that this is distinct from DescriptorProto.ReservedRange in that it
347
+ // is inclusive such that it can appropriately represent the entire int32
348
+ // domain.
349
+ message EnumReservedRange {
350
+ optional int32 start = 1; // Inclusive.
351
+ optional int32 end = 2; // Inclusive.
352
+ }
353
+
354
+ // Range of reserved numeric values. Reserved numeric values may not be used
355
+ // by enum values in the same enum declaration. Reserved ranges may not
356
+ // overlap.
357
+ repeated EnumReservedRange reserved_range = 4;
358
+
359
+ // Reserved enum value names, which may not be reused. A given name may only
360
+ // be reserved once.
361
+ repeated string reserved_name = 5;
362
+ }
363
+
364
+ // Describes a value within an enum.
365
+ message EnumValueDescriptorProto {
366
+ optional string name = 1;
367
+ optional int32 number = 2;
368
+
369
+ optional EnumValueOptions options = 3;
370
+ }
371
+
372
+ // Describes a service.
373
+ message ServiceDescriptorProto {
374
+ optional string name = 1;
375
+ repeated MethodDescriptorProto method = 2;
376
+
377
+ optional ServiceOptions options = 3;
378
+ }
379
+
380
+ // Describes a method of a service.
381
+ message MethodDescriptorProto {
382
+ optional string name = 1;
383
+
384
+ // Input and output type names. These are resolved in the same way as
385
+ // FieldDescriptorProto.type_name, but must refer to a message type.
386
+ optional string input_type = 2;
387
+ optional string output_type = 3;
388
+
389
+ optional MethodOptions options = 4;
390
+
391
+ // Identifies if client streams multiple client messages
392
+ optional bool client_streaming = 5 [default = false];
393
+ // Identifies if server streams multiple server messages
394
+ optional bool server_streaming = 6 [default = false];
395
+ }
396
+
397
+ // ===================================================================
398
+ // Options
399
+
400
+ // Each of the definitions above may have "options" attached. These are
401
+ // just annotations which may cause code to be generated slightly differently
402
+ // or may contain hints for code that manipulates protocol messages.
403
+ //
404
+ // Clients may define custom options as extensions of the *Options messages.
405
+ // These extensions may not yet be known at parsing time, so the parser cannot
406
+ // store the values in them. Instead it stores them in a field in the *Options
407
+ // message called uninterpreted_option. This field must have the same name
408
+ // across all *Options messages. We then use this field to populate the
409
+ // extensions when we build a descriptor, at which point all protos have been
410
+ // parsed and so all extensions are known.
411
+ //
412
+ // Extension numbers for custom options may be chosen as follows:
413
+ // * For options which will only be used within a single application or
414
+ // organization, or for experimental options, use field numbers 50000
415
+ // through 99999. It is up to you to ensure that you do not use the
416
+ // same number for multiple options.
417
+ // * For options which will be published and used publicly by multiple
418
+ // independent entities, e-mail protobuf-global-extension-registry@google.com
419
+ // to reserve extension numbers. Simply provide your project name (e.g.
420
+ // Objective-C plugin) and your project website (if available) -- there's no
421
+ // need to explain how you intend to use them. Usually you only need one
422
+ // extension number. You can declare multiple options with only one extension
423
+ // number by putting them in a sub-message. See the Custom Options section of
424
+ // the docs for examples:
425
+ // https://developers.google.com/protocol-buffers/docs/proto#options
426
+ // If this turns out to be popular, a web service will be set up
427
+ // to automatically assign option numbers.
428
+
429
+ message FileOptions {
430
+
431
+ // Sets the Java package where classes generated from this .proto will be
432
+ // placed. By default, the proto package is used, but this is often
433
+ // inappropriate because proto packages do not normally start with backwards
434
+ // domain names.
435
+ optional string java_package = 1;
436
+
437
+ // Controls the name of the wrapper Java class generated for the .proto file.
438
+ // That class will always contain the .proto file's getDescriptor() method as
439
+ // well as any top-level extensions defined in the .proto file.
440
+ // If java_multiple_files is disabled, then all the other classes from the
441
+ // .proto file will be nested inside the single wrapper outer class.
442
+ optional string java_outer_classname = 8;
443
+
444
+ // If enabled, then the Java code generator will generate a separate .java
445
+ // file for each top-level message, enum, and service defined in the .proto
446
+ // file. Thus, these types will *not* be nested inside the wrapper class
447
+ // named by java_outer_classname. However, the wrapper class will still be
448
+ // generated to contain the file's getDescriptor() method as well as any
449
+ // top-level extensions defined in the file.
450
+ optional bool java_multiple_files = 10 [default = false];
451
+
452
+ // This option does nothing.
453
+ optional bool java_generate_equals_and_hash = 20 [deprecated=true];
454
+
455
+ // A proto2 file can set this to true to opt in to UTF-8 checking for Java,
456
+ // which will throw an exception if invalid UTF-8 is parsed from the wire or
457
+ // assigned to a string field.
458
+ //
459
+ // TODO: clarify exactly what kinds of field types this option
460
+ // applies to, and update these docs accordingly.
461
+ //
462
+ // Proto3 files already perform these checks. Setting the option explicitly to
463
+ // false has no effect: it cannot be used to opt proto3 files out of UTF-8
464
+ // checks.
465
+ optional bool java_string_check_utf8 = 27 [default = false];
466
+
467
+ // Generated classes can be optimized for speed or code size.
468
+ enum OptimizeMode {
469
+ SPEED = 1; // Generate complete code for parsing, serialization,
470
+ // etc.
471
+ CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
472
+ LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
473
+ }
474
+ optional OptimizeMode optimize_for = 9 [default = SPEED];
475
+
476
+ // Sets the Go package where structs generated from this .proto will be
477
+ // placed. If omitted, the Go package will be derived from the following:
478
+ // - The basename of the package import path, if provided.
479
+ // - Otherwise, the package statement in the .proto file, if present.
480
+ // - Otherwise, the basename of the .proto file, without extension.
481
+ optional string go_package = 11;
482
+
483
+ // Should generic services be generated in each language? "Generic" services
484
+ // are not specific to any particular RPC system. They are generated by the
485
+ // main code generators in each language (without additional plugins).
486
+ // Generic services were the only kind of service generation supported by
487
+ // early versions of google.protobuf.
488
+ //
489
+ // Generic services are now considered deprecated in favor of using plugins
490
+ // that generate code specific to your particular RPC system. Therefore,
491
+ // these default to false. Old code which depends on generic services should
492
+ // explicitly set them to true.
493
+ optional bool cc_generic_services = 16 [default = false];
494
+ optional bool java_generic_services = 17 [default = false];
495
+ optional bool py_generic_services = 18 [default = false];
496
+ reserved 42; // removed php_generic_services
497
+
498
+ // Is this file deprecated?
499
+ // Depending on the target platform, this can emit Deprecated annotations
500
+ // for everything in the file, or it will be completely ignored; in the very
501
+ // least, this is a formalization for deprecating files.
502
+ optional bool deprecated = 23 [default = false];
503
+
504
+ // Enables the use of arenas for the proto messages in this file. This applies
505
+ // only to generated classes for C++.
506
+ optional bool cc_enable_arenas = 31 [default = true];
507
+
508
+ // Sets the objective c class prefix which is prepended to all objective c
509
+ // generated classes from this .proto. There is no default.
510
+ optional string objc_class_prefix = 36;
511
+
512
+ // Namespace for generated classes; defaults to the package.
513
+ optional string csharp_namespace = 37;
514
+
515
+ // By default Swift generators will take the proto package and CamelCase it
516
+ // replacing '.' with underscore and use that to prefix the types/symbols
517
+ // defined. When this options is provided, they will use this value instead
518
+ // to prefix the types/symbols defined.
519
+ optional string swift_prefix = 39;
520
+
521
+ // Sets the php class prefix which is prepended to all php generated classes
522
+ // from this .proto. Default is empty.
523
+ optional string php_class_prefix = 40;
524
+
525
+ // Use this option to change the namespace of php generated classes. Default
526
+ // is empty. When this option is empty, the package name will be used for
527
+ // determining the namespace.
528
+ optional string php_namespace = 41;
529
+
530
+ // Use this option to change the namespace of php generated metadata classes.
531
+ // Default is empty. When this option is empty, the proto file name will be
532
+ // used for determining the namespace.
533
+ optional string php_metadata_namespace = 44;
534
+
535
+ // Use this option to change the package of ruby generated classes. Default
536
+ // is empty. When this option is not set, the package name will be used for
537
+ // determining the ruby package.
538
+ optional string ruby_package = 45;
539
+
540
+ // Any features defined in the specific edition.
541
+ optional FeatureSet features = 50;
542
+
543
+ // The parser stores options it doesn't recognize here.
544
+ // See the documentation for the "Options" section above.
545
+ repeated UninterpretedOption uninterpreted_option = 999;
546
+
547
+ // Clients can define custom options in extensions of this message.
548
+ // See the documentation for the "Options" section above.
549
+ extensions 1000 to max;
550
+
551
+ reserved 38;
552
+ }
553
+
554
+ message MessageOptions {
555
+ // Set true to use the old proto1 MessageSet wire format for extensions.
556
+ // This is provided for backwards-compatibility with the MessageSet wire
557
+ // format. You should not use this for any other reason: It's less
558
+ // efficient, has fewer features, and is more complicated.
559
+ //
560
+ // The message must be defined exactly as follows:
561
+ // message Foo {
562
+ // option message_set_wire_format = true;
563
+ // extensions 4 to max;
564
+ // }
565
+ // Note that the message cannot have any defined fields; MessageSets only
566
+ // have extensions.
567
+ //
568
+ // All extensions of your type must be singular messages; e.g. they cannot
569
+ // be int32s, enums, or repeated messages.
570
+ //
571
+ // Because this is an option, the above two restrictions are not enforced by
572
+ // the protocol compiler.
573
+ optional bool message_set_wire_format = 1 [default = false];
574
+
575
+ // Disables the generation of the standard "descriptor()" accessor, which can
576
+ // conflict with a field of the same name. This is meant to make migration
577
+ // from proto1 easier; new code should avoid fields named "descriptor".
578
+ optional bool no_standard_descriptor_accessor = 2 [default = false];
579
+
580
+ // Is this message deprecated?
581
+ // Depending on the target platform, this can emit Deprecated annotations
582
+ // for the message, or it will be completely ignored; in the very least,
583
+ // this is a formalization for deprecating messages.
584
+ optional bool deprecated = 3 [default = false];
585
+
586
+ reserved 4, 5, 6;
587
+
588
+ // Whether the message is an automatically generated map entry type for the
589
+ // maps field.
590
+ //
591
+ // For maps fields:
592
+ // map<KeyType, ValueType> map_field = 1;
593
+ // The parsed descriptor looks like:
594
+ // message MapFieldEntry {
595
+ // option map_entry = true;
596
+ // optional KeyType key = 1;
597
+ // optional ValueType value = 2;
598
+ // }
599
+ // repeated MapFieldEntry map_field = 1;
600
+ //
601
+ // Implementations may choose not to generate the map_entry=true message, but
602
+ // use a native map in the target language to hold the keys and values.
603
+ // The reflection APIs in such implementations still need to work as
604
+ // if the field is a repeated message field.
605
+ //
606
+ // NOTE: Do not set the option in .proto files. Always use the maps syntax
607
+ // instead. The option should only be implicitly set by the proto compiler
608
+ // parser.
609
+ optional bool map_entry = 7;
610
+
611
+ reserved 8; // javalite_serializable
612
+ reserved 9; // javanano_as_lite
613
+
614
+ // Enable the legacy handling of JSON field name conflicts. This lowercases
615
+ // and strips underscored from the fields before comparison in proto3 only.
616
+ // The new behavior takes `json_name` into account and applies to proto2 as
617
+ // well.
618
+ //
619
+ // This should only be used as a temporary measure against broken builds due
620
+ // to the change in behavior for JSON field name conflicts.
621
+ //
622
+ // TODO This is legacy behavior we plan to remove once downstream
623
+ // teams have had time to migrate.
624
+ optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true];
625
+
626
+ // Any features defined in the specific edition.
627
+ optional FeatureSet features = 12;
628
+
629
+ // The parser stores options it doesn't recognize here. See above.
630
+ repeated UninterpretedOption uninterpreted_option = 999;
631
+
632
+ // Clients can define custom options in extensions of this message. See above.
633
+ extensions 1000 to max;
634
+ }
635
+
636
+ message FieldOptions {
637
+ // The ctype option instructs the C++ code generator to use a different
638
+ // representation of the field than it normally would. See the specific
639
+ // options below. This option is only implemented to support use of
640
+ // [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of
641
+ // type "bytes" in the open source release -- sorry, we'll try to include
642
+ // other types in a future version!
643
+ optional CType ctype = 1 [default = STRING];
644
+ enum CType {
645
+ // Default mode.
646
+ STRING = 0;
647
+
648
+ // The option [ctype=CORD] may be applied to a non-repeated field of type
649
+ // "bytes". It indicates that in C++, the data should be stored in a Cord
650
+ // instead of a string. For very large strings, this may reduce memory
651
+ // fragmentation. It may also allow better performance when parsing from a
652
+ // Cord, or when parsing with aliasing enabled, as the parsed Cord may then
653
+ // alias the original buffer.
654
+ CORD = 1;
655
+
656
+ STRING_PIECE = 2;
657
+ }
658
+ // The packed option can be enabled for repeated primitive fields to enable
659
+ // a more efficient representation on the wire. Rather than repeatedly
660
+ // writing the tag and type for each element, the entire array is encoded as
661
+ // a single length-delimited blob. In proto3, only explicit setting it to
662
+ // false will avoid using packed encoding. This option is prohibited in
663
+ // Editions, but the `repeated_field_encoding` feature can be used to control
664
+ // the behavior.
665
+ optional bool packed = 2;
666
+
667
+ // The jstype option determines the JavaScript type used for values of the
668
+ // field. The option is permitted only for 64 bit integral and fixed types
669
+ // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING
670
+ // is represented as JavaScript string, which avoids loss of precision that
671
+ // can happen when a large value is converted to a floating point JavaScript.
672
+ // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to
673
+ // use the JavaScript "number" type. The behavior of the default option
674
+ // JS_NORMAL is implementation dependent.
675
+ //
676
+ // This option is an enum to permit additional types to be added, e.g.
677
+ // goog.math.Integer.
678
+ optional JSType jstype = 6 [default = JS_NORMAL];
679
+ enum JSType {
680
+ // Use the default type.
681
+ JS_NORMAL = 0;
682
+
683
+ // Use JavaScript strings.
684
+ JS_STRING = 1;
685
+
686
+ // Use JavaScript numbers.
687
+ JS_NUMBER = 2;
688
+ }
689
+
690
+ // Should this field be parsed lazily? Lazy applies only to message-type
691
+ // fields. It means that when the outer message is initially parsed, the
692
+ // inner message's contents will not be parsed but instead stored in encoded
693
+ // form. The inner message will actually be parsed when it is first accessed.
694
+ //
695
+ // This is only a hint. Implementations are free to choose whether to use
696
+ // eager or lazy parsing regardless of the value of this option. However,
697
+ // setting this option true suggests that the protocol author believes that
698
+ // using lazy parsing on this field is worth the additional bookkeeping
699
+ // overhead typically needed to implement it.
700
+ //
701
+ // This option does not affect the public interface of any generated code;
702
+ // all method signatures remain the same. Furthermore, thread-safety of the
703
+ // interface is not affected by this option; const methods remain safe to
704
+ // call from multiple threads concurrently, while non-const methods continue
705
+ // to require exclusive access.
706
+ //
707
+ // Note that lazy message fields are still eagerly verified to check
708
+ // ill-formed wireformat or missing required fields. Calling IsInitialized()
709
+ // on the outer message would fail if the inner message has missing required
710
+ // fields. Failed verification would result in parsing failure (except when
711
+ // uninitialized messages are acceptable).
712
+ optional bool lazy = 5 [default = false];
713
+
714
+ // unverified_lazy does no correctness checks on the byte stream. This should
715
+ // only be used where lazy with verification is prohibitive for performance
716
+ // reasons.
717
+ optional bool unverified_lazy = 15 [default = false];
718
+
719
+ // Is this field deprecated?
720
+ // Depending on the target platform, this can emit Deprecated annotations
721
+ // for accessors, or it will be completely ignored; in the very least, this
722
+ // is a formalization for deprecating fields.
723
+ optional bool deprecated = 3 [default = false];
724
+
725
+ // For Google-internal migration only. Do not use.
726
+ optional bool weak = 10 [default = false];
727
+
728
+ // Indicate that the field value should not be printed out when using debug
729
+ // formats, e.g. when the field contains sensitive credentials.
730
+ optional bool debug_redact = 16 [default = false];
731
+
732
+ // If set to RETENTION_SOURCE, the option will be omitted from the binary.
733
+ // Note: as of January 2023, support for this is in progress and does not yet
734
+ // have an effect (b/264593489).
735
+ enum OptionRetention {
736
+ RETENTION_UNKNOWN = 0;
737
+ RETENTION_RUNTIME = 1;
738
+ RETENTION_SOURCE = 2;
739
+ }
740
+
741
+ optional OptionRetention retention = 17;
742
+
743
+ // This indicates the types of entities that the field may apply to when used
744
+ // as an option. If it is unset, then the field may be freely used as an
745
+ // option on any kind of entity. Note: as of January 2023, support for this is
746
+ // in progress and does not yet have an effect (b/264593489).
747
+ enum OptionTargetType {
748
+ TARGET_TYPE_UNKNOWN = 0;
749
+ TARGET_TYPE_FILE = 1;
750
+ TARGET_TYPE_EXTENSION_RANGE = 2;
751
+ TARGET_TYPE_MESSAGE = 3;
752
+ TARGET_TYPE_FIELD = 4;
753
+ TARGET_TYPE_ONEOF = 5;
754
+ TARGET_TYPE_ENUM = 6;
755
+ TARGET_TYPE_ENUM_ENTRY = 7;
756
+ TARGET_TYPE_SERVICE = 8;
757
+ TARGET_TYPE_METHOD = 9;
758
+ }
759
+
760
+ repeated OptionTargetType targets = 19;
761
+
762
+ message EditionDefault {
763
+ optional Edition edition = 3;
764
+ optional string value = 2; // Textproto value.
765
+ }
766
+ repeated EditionDefault edition_defaults = 20;
767
+
768
+ // Any features defined in the specific edition.
769
+ optional FeatureSet features = 21;
770
+
771
+ // Information about the support window of a feature.
772
+ message FeatureSupport {
773
+ // The edition that this feature was first available in. In editions
774
+ // earlier than this one, the default assigned to EDITION_LEGACY will be
775
+ // used, and proto files will not be able to override it.
776
+ optional Edition edition_introduced = 1;
777
+
778
+ // The edition this feature becomes deprecated in. Using this after this
779
+ // edition may trigger warnings.
780
+ optional Edition edition_deprecated = 2;
781
+
782
+ // The deprecation warning text if this feature is used after the edition it
783
+ // was marked deprecated in.
784
+ optional string deprecation_warning = 3;
785
+
786
+ // The edition this feature is no longer available in. In editions after
787
+ // this one, the last default assigned will be used, and proto files will
788
+ // not be able to override it.
789
+ optional Edition edition_removed = 4;
790
+ }
791
+ optional FeatureSupport feature_support = 22;
792
+
793
+ // The parser stores options it doesn't recognize here. See above.
794
+ repeated UninterpretedOption uninterpreted_option = 999;
795
+
796
+ // Clients can define custom options in extensions of this message. See above.
797
+ extensions 1000 to max;
798
+
799
+ reserved 4; // removed jtype
800
+ reserved 18; // reserve target, target_obsolete_do_not_use
801
+ }
802
+
803
+ message OneofOptions {
804
+ // Any features defined in the specific edition.
805
+ optional FeatureSet features = 1;
806
+
807
+ // The parser stores options it doesn't recognize here. See above.
808
+ repeated UninterpretedOption uninterpreted_option = 999;
809
+
810
+ // Clients can define custom options in extensions of this message. See above.
811
+ extensions 1000 to max;
812
+ }
813
+
814
+ message EnumOptions {
815
+
816
+ // Set this option to true to allow mapping different tag names to the same
817
+ // value.
818
+ optional bool allow_alias = 2;
819
+
820
+ // Is this enum deprecated?
821
+ // Depending on the target platform, this can emit Deprecated annotations
822
+ // for the enum, or it will be completely ignored; in the very least, this
823
+ // is a formalization for deprecating enums.
824
+ optional bool deprecated = 3 [default = false];
825
+
826
+ reserved 5; // javanano_as_lite
827
+
828
+ // Enable the legacy handling of JSON field name conflicts. This lowercases
829
+ // and strips underscored from the fields before comparison in proto3 only.
830
+ // The new behavior takes `json_name` into account and applies to proto2 as
831
+ // well.
832
+ // TODO Remove this legacy behavior once downstream teams have
833
+ // had time to migrate.
834
+ optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true];
835
+
836
+ // Any features defined in the specific edition.
837
+ optional FeatureSet features = 7;
838
+
839
+ // The parser stores options it doesn't recognize here. See above.
840
+ repeated UninterpretedOption uninterpreted_option = 999;
841
+
842
+ // Clients can define custom options in extensions of this message. See above.
843
+ extensions 1000 to max;
844
+ }
845
+
846
+ message EnumValueOptions {
847
+ // Is this enum value deprecated?
848
+ // Depending on the target platform, this can emit Deprecated annotations
849
+ // for the enum value, or it will be completely ignored; in the very least,
850
+ // this is a formalization for deprecating enum values.
851
+ optional bool deprecated = 1 [default = false];
852
+
853
+ // Any features defined in the specific edition.
854
+ optional FeatureSet features = 2;
855
+
856
+ // Indicate that fields annotated with this enum value should not be printed
857
+ // out when using debug formats, e.g. when the field contains sensitive
858
+ // credentials.
859
+ optional bool debug_redact = 3 [default = false];
860
+
861
+ // The parser stores options it doesn't recognize here. See above.
862
+ repeated UninterpretedOption uninterpreted_option = 999;
863
+
864
+ // Clients can define custom options in extensions of this message. See above.
865
+ extensions 1000 to max;
866
+ }
867
+
868
+ message ServiceOptions {
869
+
870
+ // Any features defined in the specific edition.
871
+ optional FeatureSet features = 34;
872
+
873
+ // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
874
+ // framework. We apologize for hoarding these numbers to ourselves, but
875
+ // we were already using them long before we decided to release Protocol
876
+ // Buffers.
877
+
878
+ // Is this service deprecated?
879
+ // Depending on the target platform, this can emit Deprecated annotations
880
+ // for the service, or it will be completely ignored; in the very least,
881
+ // this is a formalization for deprecating services.
882
+ optional bool deprecated = 33 [default = false];
883
+
884
+ // The parser stores options it doesn't recognize here. See above.
885
+ repeated UninterpretedOption uninterpreted_option = 999;
886
+
887
+ // Clients can define custom options in extensions of this message. See above.
888
+ extensions 1000 to max;
889
+ }
890
+
891
+ message MethodOptions {
892
+
893
+ // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
894
+ // framework. We apologize for hoarding these numbers to ourselves, but
895
+ // we were already using them long before we decided to release Protocol
896
+ // Buffers.
897
+
898
+ // Is this method deprecated?
899
+ // Depending on the target platform, this can emit Deprecated annotations
900
+ // for the method, or it will be completely ignored; in the very least,
901
+ // this is a formalization for deprecating methods.
902
+ optional bool deprecated = 33 [default = false];
903
+
904
+ // Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
905
+ // or neither? HTTP based RPC implementation may choose GET verb for safe
906
+ // methods, and PUT verb for idempotent methods instead of the default POST.
907
+ enum IdempotencyLevel {
908
+ IDEMPOTENCY_UNKNOWN = 0;
909
+ NO_SIDE_EFFECTS = 1; // implies idempotent
910
+ IDEMPOTENT = 2; // idempotent, but may have side effects
911
+ }
912
+ optional IdempotencyLevel idempotency_level = 34
913
+ [default = IDEMPOTENCY_UNKNOWN];
914
+
915
+ // Any features defined in the specific edition.
916
+ optional FeatureSet features = 35;
917
+
918
+ // The parser stores options it doesn't recognize here. See above.
919
+ repeated UninterpretedOption uninterpreted_option = 999;
920
+
921
+ // Clients can define custom options in extensions of this message. See above.
922
+ extensions 1000 to max;
923
+ }
924
+
925
+ // A message representing a option the parser does not recognize. This only
926
+ // appears in options protos created by the compiler::Parser class.
927
+ // DescriptorPool resolves these when building Descriptor objects. Therefore,
928
+ // options protos in descriptor objects (e.g. returned by Descriptor::options(),
929
+ // or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
930
+ // in them.
931
+ message UninterpretedOption {
932
+ // The name of the uninterpreted option. Each string represents a segment in
933
+ // a dot-separated name. is_extension is true iff a segment represents an
934
+ // extension (denoted with parentheses in options specs in .proto files).
935
+ // E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents
936
+ // "foo.(bar.baz).moo".
937
+ message NamePart {
938
+ required string name_part = 1;
939
+ required bool is_extension = 2;
940
+ }
941
+ repeated NamePart name = 2;
942
+
943
+ // The value of the uninterpreted option, in whatever type the tokenizer
944
+ // identified it as during parsing. Exactly one of these should be set.
945
+ optional string identifier_value = 3;
946
+ optional uint64 positive_int_value = 4;
947
+ optional int64 negative_int_value = 5;
948
+ optional double double_value = 6;
949
+ optional bytes string_value = 7;
950
+ optional string aggregate_value = 8;
951
+ }
952
+
953
+ // ===================================================================
954
+ // Features
955
+
956
+ // TODO Enums in C++ gencode (and potentially other languages) are
957
+ // not well scoped. This means that each of the feature enums below can clash
958
+ // with each other. The short names we've chosen maximize call-site
959
+ // readability, but leave us very open to this scenario. A future feature will
960
+ // be designed and implemented to handle this, hopefully before we ever hit a
961
+ // conflict here.
962
+ message FeatureSet {
963
+ enum FieldPresence {
964
+ FIELD_PRESENCE_UNKNOWN = 0;
965
+ EXPLICIT = 1;
966
+ IMPLICIT = 2;
967
+ LEGACY_REQUIRED = 3;
968
+ }
969
+ optional FieldPresence field_presence = 1 [
970
+ retention = RETENTION_RUNTIME,
971
+ targets = TARGET_TYPE_FIELD,
972
+ targets = TARGET_TYPE_FILE,
973
+ // TODO Enable this in google3 once protoc rolls out.
974
+ feature_support = {
975
+ edition_introduced: EDITION_2023,
976
+ },
977
+ edition_defaults = { edition: EDITION_PROTO2, value: "EXPLICIT" },
978
+ edition_defaults = { edition: EDITION_PROTO3, value: "IMPLICIT" },
979
+ edition_defaults = { edition: EDITION_2023, value: "EXPLICIT" }
980
+ ];
981
+
982
+ enum EnumType {
983
+ ENUM_TYPE_UNKNOWN = 0;
984
+ OPEN = 1;
985
+ CLOSED = 2;
986
+ }
987
+ optional EnumType enum_type = 2 [
988
+ retention = RETENTION_RUNTIME,
989
+ targets = TARGET_TYPE_ENUM,
990
+ targets = TARGET_TYPE_FILE,
991
+ // TODO Enable this in google3 once protoc rolls out.
992
+ feature_support = {
993
+ edition_introduced: EDITION_2023,
994
+ },
995
+ edition_defaults = { edition: EDITION_PROTO2, value: "CLOSED" },
996
+ edition_defaults = { edition: EDITION_PROTO3, value: "OPEN" }
997
+ ];
998
+
999
+ enum RepeatedFieldEncoding {
1000
+ REPEATED_FIELD_ENCODING_UNKNOWN = 0;
1001
+ PACKED = 1;
1002
+ EXPANDED = 2;
1003
+ }
1004
+ optional RepeatedFieldEncoding repeated_field_encoding = 3 [
1005
+ retention = RETENTION_RUNTIME,
1006
+ targets = TARGET_TYPE_FIELD,
1007
+ targets = TARGET_TYPE_FILE,
1008
+ // TODO Enable this in google3 once protoc rolls out.
1009
+ feature_support = {
1010
+ edition_introduced: EDITION_2023,
1011
+ },
1012
+ edition_defaults = { edition: EDITION_PROTO2, value: "EXPANDED" },
1013
+ edition_defaults = { edition: EDITION_PROTO3, value: "PACKED" }
1014
+ ];
1015
+
1016
+ enum Utf8Validation {
1017
+ UTF8_VALIDATION_UNKNOWN = 0;
1018
+ VERIFY = 2;
1019
+ NONE = 3;
1020
+ }
1021
+ optional Utf8Validation utf8_validation = 4 [
1022
+ retention = RETENTION_RUNTIME,
1023
+ targets = TARGET_TYPE_FIELD,
1024
+ targets = TARGET_TYPE_FILE,
1025
+ // TODO Enable this in google3 once protoc rolls out.
1026
+ feature_support = {
1027
+ edition_introduced: EDITION_2023,
1028
+ },
1029
+ edition_defaults = { edition: EDITION_PROTO2, value: "NONE" },
1030
+ edition_defaults = { edition: EDITION_PROTO3, value: "VERIFY" }
1031
+ ];
1032
+
1033
+ enum MessageEncoding {
1034
+ MESSAGE_ENCODING_UNKNOWN = 0;
1035
+ LENGTH_PREFIXED = 1;
1036
+ DELIMITED = 2;
1037
+ }
1038
+ optional MessageEncoding message_encoding = 5 [
1039
+ retention = RETENTION_RUNTIME,
1040
+ targets = TARGET_TYPE_FIELD,
1041
+ targets = TARGET_TYPE_FILE,
1042
+ // TODO Enable this in google3 once protoc rolls out.
1043
+ feature_support = {
1044
+ edition_introduced: EDITION_2023,
1045
+ },
1046
+ edition_defaults = { edition: EDITION_PROTO2, value: "LENGTH_PREFIXED" }
1047
+ ];
1048
+
1049
+ enum JsonFormat {
1050
+ JSON_FORMAT_UNKNOWN = 0;
1051
+ ALLOW = 1;
1052
+ LEGACY_BEST_EFFORT = 2;
1053
+ }
1054
+ optional JsonFormat json_format = 6 [
1055
+ retention = RETENTION_RUNTIME,
1056
+ targets = TARGET_TYPE_MESSAGE,
1057
+ targets = TARGET_TYPE_ENUM,
1058
+ targets = TARGET_TYPE_FILE,
1059
+ // TODO Enable this in google3 once protoc rolls out.
1060
+ feature_support = {
1061
+ edition_introduced: EDITION_2023,
1062
+ },
1063
+ edition_defaults = { edition: EDITION_PROTO2, value: "LEGACY_BEST_EFFORT" },
1064
+ edition_defaults = { edition: EDITION_PROTO3, value: "ALLOW" }
1065
+ ];
1066
+
1067
+ reserved 999;
1068
+
1069
+ extensions 1000; // for Protobuf C++
1070
+ extensions 1001; // for Protobuf Java
1071
+ extensions 1002; // for Protobuf Go
1072
+
1073
+ extensions 9990; // for deprecated Java Proto1
1074
+
1075
+ extensions 9995 to 9999; // For internal testing
1076
+ extensions 10000; // for https://github.com/bufbuild/protobuf-es
1077
+ }
1078
+
1079
+ // A compiled specification for the defaults of a set of features. These
1080
+ // messages are generated from FeatureSet extensions and can be used to seed
1081
+ // feature resolution. The resolution with this object becomes a simple search
1082
+ // for the closest matching edition, followed by proto merges.
1083
+ message FeatureSetDefaults {
1084
+ // A map from every known edition with a unique set of defaults to its
1085
+ // defaults. Not all editions may be contained here. For a given edition,
1086
+ // the defaults at the closest matching edition ordered at or before it should
1087
+ // be used. This field must be in strict ascending order by edition.
1088
+ message FeatureSetEditionDefault {
1089
+ optional Edition edition = 3;
1090
+
1091
+ // Defaults of features that can be overridden in this edition.
1092
+ optional FeatureSet overridable_features = 4;
1093
+
1094
+ // Defaults of features that can't be overridden in this edition.
1095
+ optional FeatureSet fixed_features = 5;
1096
+ }
1097
+ repeated FeatureSetEditionDefault defaults = 1;
1098
+
1099
+ // The minimum supported edition (inclusive) when this was constructed.
1100
+ // Editions before this will not have defaults.
1101
+ optional Edition minimum_edition = 4;
1102
+
1103
+ // The maximum known edition (inclusive) when this was constructed. Editions
1104
+ // after this will not have reliable defaults.
1105
+ optional Edition maximum_edition = 5;
1106
+ }
1107
+
1108
+ // ===================================================================
1109
+ // Optional source code info
1110
+
1111
+ // Encapsulates information about the original source file from which a
1112
+ // FileDescriptorProto was generated.
1113
+ message SourceCodeInfo {
1114
+ // A Location identifies a piece of source code in a .proto file which
1115
+ // corresponds to a particular definition. This information is intended
1116
+ // to be useful to IDEs, code indexers, documentation generators, and similar
1117
+ // tools.
1118
+ //
1119
+ // For example, say we have a file like:
1120
+ // message Foo {
1121
+ // optional string foo = 1;
1122
+ // }
1123
+ // Let's look at just the field definition:
1124
+ // optional string foo = 1;
1125
+ // ^ ^^ ^^ ^ ^^^
1126
+ // a bc de f ghi
1127
+ // We have the following locations:
1128
+ // span path represents
1129
+ // [a,i) [ 4, 0, 2, 0 ] The whole field definition.
1130
+ // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
1131
+ // [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
1132
+ // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
1133
+ // [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
1134
+ //
1135
+ // Notes:
1136
+ // - A location may refer to a repeated field itself (i.e. not to any
1137
+ // particular index within it). This is used whenever a set of elements are
1138
+ // logically enclosed in a single code segment. For example, an entire
1139
+ // extend block (possibly containing multiple extension definitions) will
1140
+ // have an outer location whose path refers to the "extensions" repeated
1141
+ // field without an index.
1142
+ // - Multiple locations may have the same path. This happens when a single
1143
+ // logical declaration is spread out across multiple places. The most
1144
+ // obvious example is the "extend" block again -- there may be multiple
1145
+ // extend blocks in the same scope, each of which will have the same path.
1146
+ // - A location's span is not always a subset of its parent's span. For
1147
+ // example, the "extendee" of an extension declaration appears at the
1148
+ // beginning of the "extend" block and is shared by all extensions within
1149
+ // the block.
1150
+ // - Just because a location's span is a subset of some other location's span
1151
+ // does not mean that it is a descendant. For example, a "group" defines
1152
+ // both a type and a field in a single declaration. Thus, the locations
1153
+ // corresponding to the type and field and their components will overlap.
1154
+ // - Code which tries to interpret locations should probably be designed to
1155
+ // ignore those that it doesn't understand, as more types of locations could
1156
+ // be recorded in the future.
1157
+ repeated Location location = 1;
1158
+ message Location {
1159
+ // Identifies which part of the FileDescriptorProto was defined at this
1160
+ // location.
1161
+ //
1162
+ // Each element is a field number or an index. They form a path from
1163
+ // the root FileDescriptorProto to the place where the definition appears.
1164
+ // For example, this path:
1165
+ // [ 4, 3, 2, 7, 1 ]
1166
+ // refers to:
1167
+ // file.message_type(3) // 4, 3
1168
+ // .field(7) // 2, 7
1169
+ // .name() // 1
1170
+ // This is because FileDescriptorProto.message_type has field number 4:
1171
+ // repeated DescriptorProto message_type = 4;
1172
+ // and DescriptorProto.field has field number 2:
1173
+ // repeated FieldDescriptorProto field = 2;
1174
+ // and FieldDescriptorProto.name has field number 1:
1175
+ // optional string name = 1;
1176
+ //
1177
+ // Thus, the above path gives the location of a field name. If we removed
1178
+ // the last element:
1179
+ // [ 4, 3, 2, 7 ]
1180
+ // this path refers to the whole field declaration (from the beginning
1181
+ // of the label to the terminating semicolon).
1182
+ repeated int32 path = 1 [packed = true];
1183
+
1184
+ // Always has exactly three or four elements: start line, start column,
1185
+ // end line (optional, otherwise assumed same as start line), end column.
1186
+ // These are packed into a single field for efficiency. Note that line
1187
+ // and column numbers are zero-based -- typically you will want to add
1188
+ // 1 to each before displaying to a user.
1189
+ repeated int32 span = 2 [packed = true];
1190
+
1191
+ // If this SourceCodeInfo represents a complete declaration, these are any
1192
+ // comments appearing before and after the declaration which appear to be
1193
+ // attached to the declaration.
1194
+ //
1195
+ // A series of line comments appearing on consecutive lines, with no other
1196
+ // tokens appearing on those lines, will be treated as a single comment.
1197
+ //
1198
+ // leading_detached_comments will keep paragraphs of comments that appear
1199
+ // before (but not connected to) the current element. Each paragraph,
1200
+ // separated by empty lines, will be one comment element in the repeated
1201
+ // field.
1202
+ //
1203
+ // Only the comment content is provided; comment markers (e.g. //) are
1204
+ // stripped out. For block comments, leading whitespace and an asterisk
1205
+ // will be stripped from the beginning of each line other than the first.
1206
+ // Newlines are included in the output.
1207
+ //
1208
+ // Examples:
1209
+ //
1210
+ // optional int32 foo = 1; // Comment attached to foo.
1211
+ // // Comment attached to bar.
1212
+ // optional int32 bar = 2;
1213
+ //
1214
+ // optional string baz = 3;
1215
+ // // Comment attached to baz.
1216
+ // // Another line attached to baz.
1217
+ //
1218
+ // // Comment attached to moo.
1219
+ // //
1220
+ // // Another line attached to moo.
1221
+ // optional double moo = 4;
1222
+ //
1223
+ // // Detached comment for corge. This is not leading or trailing comments
1224
+ // // to moo or corge because there are blank lines separating it from
1225
+ // // both.
1226
+ //
1227
+ // // Detached comment for corge paragraph 2.
1228
+ //
1229
+ // optional string corge = 5;
1230
+ // /* Block comment attached
1231
+ // * to corge. Leading asterisks
1232
+ // * will be removed. */
1233
+ // /* Block comment attached to
1234
+ // * grault. */
1235
+ // optional int32 grault = 6;
1236
+ //
1237
+ // // ignored detached comments.
1238
+ optional string leading_comments = 3;
1239
+ optional string trailing_comments = 4;
1240
+ repeated string leading_detached_comments = 6;
1241
+ }
1242
+ }
1243
+
1244
+ // Describes the relationship between generated code and its original source
1245
+ // file. A GeneratedCodeInfo message is associated with only one generated
1246
+ // source file, but may contain references to different source .proto files.
1247
+ message GeneratedCodeInfo {
1248
+ // An Annotation connects some span of text in generated code to an element
1249
+ // of its generating .proto file.
1250
+ repeated Annotation annotation = 1;
1251
+ message Annotation {
1252
+ // Identifies the element in the original source .proto file. This field
1253
+ // is formatted the same as SourceCodeInfo.Location.path.
1254
+ repeated int32 path = 1 [packed = true];
1255
+
1256
+ // Identifies the filesystem path to the original source .proto.
1257
+ optional string source_file = 2;
1258
+
1259
+ // Identifies the starting offset in bytes in the generated code
1260
+ // that relates to the identified object.
1261
+ optional int32 begin = 3;
1262
+
1263
+ // Identifies the ending offset in bytes in the generated code that
1264
+ // relates to the identified object. The end offset should be one past
1265
+ // the last relevant byte (so the length of the text = end - begin).
1266
+ optional int32 end = 4;
1267
+
1268
+ // Represents the identified object's effect on the element in the original
1269
+ // .proto file.
1270
+ enum Semantic {
1271
+ // There is no effect or the effect is indescribable.
1272
+ NONE = 0;
1273
+ // The element is set or otherwise mutated.
1274
+ SET = 1;
1275
+ // An alias to the element is returned.
1276
+ ALIAS = 2;
1277
+ }
1278
+ optional Semantic semantic = 5;
1279
+ }
1280
+ }