Skip to content

Commit 041233a

Browse files
csharptestrogerk
authored and
rogerk
committed
Import of protoc 2.4.1 and associated proto changes
1 parent a14aa64 commit 041233a

File tree

6 files changed

+217
-69
lines changed

6 files changed

+217
-69
lines changed

lib/protoc.exe

31.5 KB
Binary file not shown.

protos/google/protobuf/descriptor.proto

+107-7
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ message FileDescriptorProto {
6767
repeated FieldDescriptorProto extension = 7;
6868

6969
optional FileOptions options = 8;
70+
71+
// This field contains optional information about the original source code.
72+
// You may safely remove this entire field whithout harming runtime
73+
// functionality of the descriptors -- the information is needed only by
74+
// development tools.
75+
optional SourceCodeInfo source_code_info = 9;
7076
}
7177

7278
// Describes a message type.
@@ -245,6 +251,12 @@ message FileOptions {
245251
// top-level extensions defined in the file.
246252
optional bool java_multiple_files = 10 [default=false];
247253

254+
// If set true, then the Java code generator will generate equals() and
255+
// hashCode() methods for all messages defined in the .proto file. This is
256+
// purely a speed optimization, as the AbstractMessage base class includes
257+
// reflection-based implementations of these methods.
258+
optional bool java_generate_equals_and_hash = 20 [default=false];
259+
248260
// Generated classes can be optimized for speed or code size.
249261
enum OptimizeMode {
250262
SPEED = 1; // Generate complete code for parsing, serialization,
@@ -264,13 +276,12 @@ message FileOptions {
264276
// early versions of proto2.
265277
//
266278
// Generic services are now considered deprecated in favor of using plugins
267-
// that generate code specific to your particular RPC system. If you are
268-
// using such a plugin, set these to false. In the future, we may change
269-
// the default to false, so if you explicitly want generic services, you
270-
// should explicitly set these to true.
271-
optional bool cc_generic_services = 16 [default=true];
272-
optional bool java_generic_services = 17 [default=true];
273-
optional bool py_generic_services = 18 [default=true];
279+
// that generate code specific to your particular RPC system. Therefore,
280+
// these default to false. Old code which depends on generic services should
281+
// explicitly set them to true.
282+
optional bool cc_generic_services = 16 [default=false];
283+
optional bool java_generic_services = 17 [default=false];
284+
optional bool py_generic_services = 18 [default=false];
274285

275286
// The parser stores options it doesn't recognize here. See above.
276287
repeated UninterpretedOption uninterpreted_option = 999;
@@ -430,4 +441,93 @@ message UninterpretedOption {
430441
optional int64 negative_int_value = 5;
431442
optional double double_value = 6;
432443
optional bytes string_value = 7;
444+
optional string aggregate_value = 8;
445+
}
446+
447+
// ===================================================================
448+
// Optional source code info
449+
450+
// Encapsulates information about the original source file from which a
451+
// FileDescriptorProto was generated.
452+
message SourceCodeInfo {
453+
// A Location identifies a piece of source code in a .proto file which
454+
// corresponds to a particular definition. This information is intended
455+
// to be useful to IDEs, code indexers, documentation generators, and similar
456+
// tools.
457+
//
458+
// For example, say we have a file like:
459+
// message Foo {
460+
// optional string foo = 1;
461+
// }
462+
// Let's look at just the field definition:
463+
// optional string foo = 1;
464+
// ^ ^^ ^^ ^ ^^^
465+
// a bc de f ghi
466+
// We have the following locations:
467+
// span path represents
468+
// [a,i) [ 4, 0, 2, 0 ] The whole field definition.
469+
// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
470+
// [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
471+
// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
472+
// [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
473+
//
474+
// Notes:
475+
// - A location may refer to a repeated field itself (i.e. not to any
476+
// particular index within it). This is used whenever a set of elements are
477+
// logically enclosed in a single code segment. For example, an entire
478+
// extend block (possibly containing multiple extension definitions) will
479+
// have an outer location whose path refers to the "extensions" repeated
480+
// field without an index.
481+
// - Multiple locations may have the same path. This happens when a single
482+
// logical declaration is spread out across multiple places. The most
483+
// obvious example is the "extend" block again -- there may be multiple
484+
// extend blocks in the same scope, each of which will have the same path.
485+
// - A location's span is not always a subset of its parent's span. For
486+
// example, the "extendee" of an extension declaration appears at the
487+
// beginning of the "extend" block and is shared by all extensions within
488+
// the block.
489+
// - Just because a location's span is a subset of some other location's span
490+
// does not mean that it is a descendent. For example, a "group" defines
491+
// both a type and a field in a single declaration. Thus, the locations
492+
// corresponding to the type and field and their components will overlap.
493+
// - Code which tries to interpret locations should probably be designed to
494+
// ignore those that it doesn't understand, as more types of locations could
495+
// be recorded in the future.
496+
repeated Location location = 1;
497+
message Location {
498+
// Identifies which part of the FileDescriptorProto was defined at this
499+
// location.
500+
//
501+
// Each element is a field number or an index. They form a path from
502+
// the root FileDescriptorProto to the place where the definition. For
503+
// example, this path:
504+
// [ 4, 3, 2, 7, 1 ]
505+
// refers to:
506+
// file.message_type(3) // 4, 3
507+
// .field(7) // 2, 7
508+
// .name() // 1
509+
// This is because FileDescriptorProto.message_type has field number 4:
510+
// repeated DescriptorProto message_type = 4;
511+
// and DescriptorProto.field has field number 2:
512+
// repeated FieldDescriptorProto field = 2;
513+
// and FieldDescriptorProto.name has field number 1:
514+
// optional string name = 1;
515+
//
516+
// Thus, the above path gives the location of a field name. If we removed
517+
// the last element:
518+
// [ 4, 3, 2, 7 ]
519+
// this path refers to the whole field declaration (from the beginning
520+
// of the label to the terminating semicolon).
521+
repeated int32 path = 1 [packed=true];
522+
523+
// Always has exactly three or four elements: start line, start column,
524+
// end line (optional, otherwise assumed same as start line), end column.
525+
// These are packed into a single field for efficiency. Note that line
526+
// and column numbers are zero-based -- typically you will want to add
527+
// 1 to each before displaying to a user.
528+
repeated int32 span = 2 [packed=true];
529+
530+
// TODO(kenton): Record comments appearing before and after the
531+
// declaration.
532+
}
433533
}

protos/google/protobuf/unittest.proto

+18-21
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestProto
4141
// A proto file we will use for unit testing.
4242

4343

44+
// Some generic_services option(s) added automatically.
45+
// See: http://go/proto2-generic-services-default
46+
option cc_generic_services = true; // auto-added
47+
option java_generic_services = true; // auto-added
48+
option py_generic_services = true; // auto-added
49+
4450
import "google/protobuf/unittest_import.proto";
4551

4652
// We don't put this in a package within proto2 because we need to make sure
@@ -493,6 +499,17 @@ message TestExtremeDefaultValues {
493499
optional float inf_float = 17 [default = inf];
494500
optional float neg_inf_float = 18 [default = -inf];
495501
optional float nan_float = 19 [default = nan];
502+
503+
// Tests for C++ trigraphs.
504+
// Trigraphs should be escaped in C++ generated files, but they should not be
505+
// escaped for other languages.
506+
// Note that in .proto file, "\?" is a valid way to escape ? in string
507+
// literals.
508+
optional string cpp_trigraph = 20 [default = "? \? ?? \?? \??? ??/ ?\?-"];
509+
}
510+
511+
message SparseEnumMessage {
512+
optional TestSparseEnum sparse_enum = 1;
496513
}
497514

498515
// Test String and Bytes: string is for valid UTF-8 strings
@@ -563,27 +580,6 @@ extend TestPackedExtensions {
563580
repeated ForeignEnum packed_enum_extension = 103 [packed = true];
564581
}
565582

566-
message TestUnpackedExtensions {
567-
extensions 1 to max;
568-
}
569-
570-
extend TestUnpackedExtensions {
571-
repeated int32 unpacked_int32_extension = 90;
572-
repeated int64 unpacked_int64_extension = 91;
573-
repeated uint32 unpacked_uint32_extension = 92;
574-
repeated uint64 unpacked_uint64_extension = 93;
575-
repeated sint32 unpacked_sint32_extension = 94;
576-
repeated sint64 unpacked_sint64_extension = 95;
577-
repeated fixed32 unpacked_fixed32_extension = 96;
578-
repeated fixed64 unpacked_fixed64_extension = 97;
579-
repeated sfixed32 unpacked_sfixed32_extension = 98;
580-
repeated sfixed64 unpacked_sfixed64_extension = 99;
581-
repeated float unpacked_float_extension = 100;
582-
repeated double unpacked_double_extension = 101;
583-
repeated bool unpacked_bool_extension = 102;
584-
repeated ForeignEnum unpacked_enum_extension = 103;
585-
}
586-
587583
// Used by ExtensionSetTest/DynamicExtensions. The test actually builds
588584
// a set of extensions to TestAllExtensions dynamically, based on the fields
589585
// of this message type.
@@ -625,6 +621,7 @@ message TestRepeatedScalarDifferentTagSizes {
625621
repeated uint64 repeated_uint64 = 262143;
626622
}
627623

624+
628625
// Test that RPC services work.
629626
message FooRequest {}
630627
message FooResponse {}

protos/google/protobuf/unittest_custom_options.proto

+91
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestCusto
4141
// A proto file used to test the "custom options" feature of proto2.
4242

4343

44+
// Some generic_services option(s) added automatically.
45+
// See: http://go/proto2-generic-services-default
46+
option cc_generic_services = true; // auto-added
47+
option java_generic_services = true; // auto-added
48+
option py_generic_services = true;
49+
4450
// A custom file option (defined below).
4551
option (file_opt1) = 9876543210;
4652

@@ -279,3 +285,88 @@ message VariousComplexOptions {
279285
option (complex_opt3).complexoptiontype5.plugh = 22;
280286
option (complexopt6).xyzzy = 24;
281287
}
288+
289+
// ------------------------------------------------------
290+
// Definitions for testing aggregate option parsing.
291+
// See descriptor_unittest.cc.
292+
293+
message AggregateMessageSet {
294+
option message_set_wire_format = true;
295+
extensions 4 to max;
296+
}
297+
298+
message AggregateMessageSetElement {
299+
extend AggregateMessageSet {
300+
optional AggregateMessageSetElement message_set_extension = 15447542;
301+
}
302+
optional string s = 1;
303+
}
304+
305+
// A helper type used to test aggregate option parsing
306+
message Aggregate {
307+
optional int32 i = 1;
308+
optional string s = 2;
309+
310+
// A nested object
311+
optional Aggregate sub = 3;
312+
313+
// To test the parsing of extensions inside aggregate values
314+
optional google.protobuf.FileOptions file = 4;
315+
extend google.protobuf.FileOptions {
316+
optional Aggregate nested = 15476903;
317+
}
318+
319+
// An embedded message set
320+
optional AggregateMessageSet mset = 5;
321+
}
322+
323+
// Allow Aggregate to be used as an option at all possible locations
324+
// in the .proto grammer.
325+
extend google.protobuf.FileOptions { optional Aggregate fileopt = 15478479; }
326+
extend google.protobuf.MessageOptions { optional Aggregate msgopt = 15480088; }
327+
extend google.protobuf.FieldOptions { optional Aggregate fieldopt = 15481374; }
328+
extend google.protobuf.EnumOptions { optional Aggregate enumopt = 15483218; }
329+
extend google.protobuf.EnumValueOptions { optional Aggregate enumvalopt = 15486921; }
330+
extend google.protobuf.ServiceOptions { optional Aggregate serviceopt = 15497145; }
331+
extend google.protobuf.MethodOptions { optional Aggregate methodopt = 15512713; }
332+
333+
// Try using AggregateOption at different points in the proto grammar
334+
option (fileopt) = {
335+
s: 'FileAnnotation'
336+
// Also test the handling of comments
337+
/* of both types */ i: 100
338+
339+
sub { s: 'NestedFileAnnotation' }
340+
341+
// Include a google.protobuf.FileOptions and recursively extend it with
342+
// another fileopt.
343+
file {
344+
[protobuf_unittest.fileopt] {
345+
s:'FileExtensionAnnotation'
346+
}
347+
}
348+
349+
// A message set inside an option value
350+
mset {
351+
[protobuf_unittest.AggregateMessageSetElement.message_set_extension] {
352+
s: 'EmbeddedMessageSetElement'
353+
}
354+
}
355+
};
356+
357+
message AggregateMessage {
358+
option (msgopt) = { i:101 s:'MessageAnnotation' };
359+
optional int32 fieldname = 1 [(fieldopt) = { s:'FieldAnnotation' }];
360+
}
361+
362+
service AggregateService {
363+
option (serviceopt) = { s:'ServiceAnnotation' };
364+
rpc Method (AggregateMessage) returns (AggregateMessage) {
365+
option (methodopt) = { s:'MethodAnnotation' };
366+
}
367+
}
368+
369+
enum AggregateEnum {
370+
option (enumopt) = { s:'EnumAnnotation' };
371+
VALUE = 1 [(enumvalopt) = { s:'EnumValueAnnotation' }];
372+
}

protos/google/protobuf/unittest_lite.proto

-38
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,6 @@ message TestPackedTypesLite {
178178
repeated ForeignEnumLite packed_enum = 103 [packed = true];
179179
}
180180

181-
message TestUnpackedTypesLite {
182-
repeated int32 unpacked_int32 = 90;
183-
repeated int64 unpacked_int64 = 91;
184-
repeated uint32 unpacked_uint32 = 92;
185-
repeated uint64 unpacked_uint64 = 93;
186-
repeated sint32 unpacked_sint32 = 94;
187-
repeated sint64 unpacked_sint64 = 95;
188-
repeated fixed32 unpacked_fixed32 = 96;
189-
repeated fixed64 unpacked_fixed64 = 97;
190-
repeated sfixed32 unpacked_sfixed32 = 98;
191-
repeated sfixed64 unpacked_sfixed64 = 99;
192-
repeated float unpacked_float = 100;
193-
repeated double unpacked_double = 101;
194-
repeated bool unpacked_bool = 102;
195-
repeated ForeignEnumLite unpacked_enum = 103;
196-
}
197-
198181
message TestAllExtensionsLite {
199182
extensions 1 to max;
200183
}
@@ -322,27 +305,6 @@ extend TestPackedExtensionsLite {
322305
repeated ForeignEnumLite packed_enum_extension_lite = 103 [packed = true];
323306
}
324307

325-
message TestUnpackedExtensionsLite {
326-
extensions 1 to max;
327-
}
328-
329-
extend TestUnpackedExtensionsLite {
330-
repeated int32 unpacked_int32_extension_lite = 90;
331-
repeated int64 unpacked_int64_extension_lite = 91;
332-
repeated uint32 unpacked_uint32_extension_lite = 92;
333-
repeated uint64 unpacked_uint64_extension_lite = 93;
334-
repeated sint32 unpacked_sint32_extension_lite = 94;
335-
repeated sint64 unpacked_sint64_extension_lite = 95;
336-
repeated fixed32 unpacked_fixed32_extension_lite = 96;
337-
repeated fixed64 unpacked_fixed64_extension_lite = 97;
338-
repeated sfixed32 unpacked_sfixed32_extension_lite = 98;
339-
repeated sfixed64 unpacked_sfixed64_extension_lite = 99;
340-
repeated float unpacked_float_extension_lite = 100;
341-
repeated double unpacked_double_extension_lite = 101;
342-
repeated bool unpacked_bool_extension_lite = 102;
343-
repeated ForeignEnumLite unpacked_enum_extension_lite = 103;
344-
}
345-
346308
message TestNestedExtensionLite {
347309
extend TestAllExtensionsLite {
348310
optional int32 nested_extension = 12345;

protos/google/protobuf/unittest_no_generic_services.proto

+1-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestNoGen
3838

3939
package google.protobuf.no_generic_services_test;
4040

41-
option cc_generic_services = false;
42-
option java_generic_services = false;
43-
option py_generic_services = false;
41+
// *_generic_services are false by default.
4442

4543
message TestMessage {
4644
optional int32 a = 1;

0 commit comments

Comments
 (0)