Skip to content

Commit 330754c

Browse files
committed
Sync up the protos with googleprotobuf/protobuf
Syncing at 6935eae45c99926a000ecbef0be20dfd3d159e71.
1 parent e6dbb68 commit 330754c

10 files changed

+90
-378
lines changed

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ TEST_PROTOS= \
103103
Protos/google/protobuf/unittest_lite_imports_nonlite.proto \
104104
Protos/google/protobuf/unittest_mset.proto \
105105
Protos/google/protobuf/unittest_mset_wire_format.proto \
106-
Protos/google/protobuf/unittest_no_arena.proto \
107-
Protos/google/protobuf/unittest_no_arena_import.proto \
108-
Protos/google/protobuf/unittest_no_arena_lite.proto \
109106
Protos/google/protobuf/unittest_no_field_presence.proto \
110107
Protos/google/protobuf/unittest_no_generic_services.proto \
111108
Protos/google/protobuf/unittest_optimize_for.proto \

Protos/google/protobuf/descriptor.proto

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,21 @@ message FieldDescriptorProto {
217217
// If true, this is a proto3 "optional". When a proto3 field is optional, it
218218
// tracks presence regardless of field type.
219219
//
220-
// For message fields this doesn't create any semantic change, since
221-
// non-repeated message fields always track presence. However it still
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
222229
// indicates the semantic detail of whether the user wrote "optional" or not.
223-
// This can be useful for round-tripping the .proto file.
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.
224235
//
225236
// Proto2 optional fields do not set this flag, because they already indicate
226237
// optional with `LABEL_OPTIONAL`.

Protos/google/protobuf/map_lite_unittest.proto

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -30,55 +30,52 @@
3030

3131
syntax = "proto2";
3232

33-
option cc_enable_arenas = true;
34-
option optimize_for = LITE_RUNTIME;
33+
package protobuf_unittest;
3534

3635
import "google/protobuf/unittest_lite.proto";
37-
import "google/protobuf/unittest_no_arena_lite.proto";
3836

39-
package protobuf_unittest;
37+
option cc_enable_arenas = true;
38+
option optimize_for = LITE_RUNTIME;
4039

4140
message TestMapLite {
42-
map<int32 , int32 > map_int32_int32 = 1;
43-
map<int64 , int64 > map_int64_int64 = 2;
44-
map<uint32 , uint32 > map_uint32_uint32 = 3;
45-
map<uint64 , uint64 > map_uint64_uint64 = 4;
46-
map<sint32 , sint32 > map_sint32_sint32 = 5;
47-
map<sint64 , sint64 > map_sint64_sint64 = 6;
48-
map<fixed32 , fixed32 > map_fixed32_fixed32 = 7;
49-
map<fixed64 , fixed64 > map_fixed64_fixed64 = 8;
41+
map<int32, int32> map_int32_int32 = 1;
42+
map<int64, int64> map_int64_int64 = 2;
43+
map<uint32, uint32> map_uint32_uint32 = 3;
44+
map<uint64, uint64> map_uint64_uint64 = 4;
45+
map<sint32, sint32> map_sint32_sint32 = 5;
46+
map<sint64, sint64> map_sint64_sint64 = 6;
47+
map<fixed32, fixed32> map_fixed32_fixed32 = 7;
48+
map<fixed64, fixed64> map_fixed64_fixed64 = 8;
5049
map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
5150
map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
52-
map<int32 , float > map_int32_float = 11;
53-
map<int32 , double > map_int32_double = 12;
54-
map<bool , bool > map_bool_bool = 13;
55-
map<string , string > map_string_string = 14;
56-
map<int32 , bytes > map_int32_bytes = 15;
57-
map<int32 , MapEnumLite> map_int32_enum = 16;
58-
map<int32 , ForeignMessageLite> map_int32_foreign_message = 17;
51+
map<int32, float> map_int32_float = 11;
52+
map<int32, double> map_int32_double = 12;
53+
map<bool, bool> map_bool_bool = 13;
54+
map<string, string> map_string_string = 14;
55+
map<int32, bytes> map_int32_bytes = 15;
56+
map<int32, MapEnumLite> map_int32_enum = 16;
57+
map<int32, ForeignMessageLite> map_int32_foreign_message = 17;
5958
map<int32, int32> teboring = 18;
6059
}
6160

6261
message TestArenaMapLite {
63-
map<int32 , int32 > map_int32_int32 = 1;
64-
map<int64 , int64 > map_int64_int64 = 2;
65-
map<uint32 , uint32 > map_uint32_uint32 = 3;
66-
map<uint64 , uint64 > map_uint64_uint64 = 4;
67-
map<sint32 , sint32 > map_sint32_sint32 = 5;
68-
map<sint64 , sint64 > map_sint64_sint64 = 6;
69-
map<fixed32 , fixed32 > map_fixed32_fixed32 = 7;
70-
map<fixed64 , fixed64 > map_fixed64_fixed64 = 8;
62+
map<int32, int32> map_int32_int32 = 1;
63+
map<int64, int64> map_int64_int64 = 2;
64+
map<uint32, uint32> map_uint32_uint32 = 3;
65+
map<uint64, uint64> map_uint64_uint64 = 4;
66+
map<sint32, sint32> map_sint32_sint32 = 5;
67+
map<sint64, sint64> map_sint64_sint64 = 6;
68+
map<fixed32, fixed32> map_fixed32_fixed32 = 7;
69+
map<fixed64, fixed64> map_fixed64_fixed64 = 8;
7170
map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
7271
map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
73-
map<int32 , float > map_int32_float = 11;
74-
map<int32 , double > map_int32_double = 12;
75-
map<bool , bool > map_bool_bool = 13;
76-
map<string , string > map_string_string = 14;
77-
map<int32 , bytes > map_int32_bytes = 15;
78-
map<int32 , MapEnumLite> map_int32_enum = 16;
79-
map<int32 , ForeignMessageArenaLite> map_int32_foreign_message = 17;
80-
map<int32, .protobuf_unittest_no_arena.ForeignMessageLite>
81-
map_int32_foreign_message_no_arena = 18;
72+
map<int32, float> map_int32_float = 11;
73+
map<int32, double> map_int32_double = 12;
74+
map<bool, bool> map_bool_bool = 13;
75+
map<string, string> map_string_string = 14;
76+
map<int32, bytes> map_int32_bytes = 15;
77+
map<int32, MapEnumLite> map_int32_enum = 16;
78+
map<int32, ForeignMessageArenaLite> map_int32_foreign_message = 17;
8279
}
8380

8481
// Test embedded message with required fields
@@ -107,9 +104,9 @@ enum Proto2MapEnumLite {
107104
}
108105

109106
enum Proto2MapEnumPlusExtraLite {
110-
E_PROTO2_MAP_ENUM_FOO_LITE = 0;
111-
E_PROTO2_MAP_ENUM_BAR_LITE = 1;
112-
E_PROTO2_MAP_ENUM_BAZ_LITE = 2;
107+
E_PROTO2_MAP_ENUM_FOO_LITE = 0;
108+
E_PROTO2_MAP_ENUM_BAR_LITE = 1;
109+
E_PROTO2_MAP_ENUM_BAZ_LITE = 2;
113110
E_PROTO2_MAP_ENUM_EXTRA_LITE = 3;
114111
}
115112

Protos/google/protobuf/map_unittest.proto

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ syntax = "proto3";
3333
option cc_enable_arenas = true;
3434

3535
import "google/protobuf/unittest.proto";
36-
import "google/protobuf/unittest_no_arena.proto";
3736

3837
// We don't put this in a package within proto2 because we need to make sure
3938
// that the generated code doesn't depend on being in the proto2 namespace.
@@ -42,25 +41,25 @@ package protobuf_unittest;
4241

4342
// Tests maps.
4443
message TestMap {
45-
map<int32 , int32 > map_int32_int32 = 1;
46-
map<int64 , int64 > map_int64_int64 = 2;
47-
map<uint32 , uint32 > map_uint32_uint32 = 3;
48-
map<uint64 , uint64 > map_uint64_uint64 = 4;
49-
map<sint32 , sint32 > map_sint32_sint32 = 5;
50-
map<sint64 , sint64 > map_sint64_sint64 = 6;
51-
map<fixed32 , fixed32 > map_fixed32_fixed32 = 7;
52-
map<fixed64 , fixed64 > map_fixed64_fixed64 = 8;
44+
map<int32, int32> map_int32_int32 = 1;
45+
map<int64, int64> map_int64_int64 = 2;
46+
map<uint32, uint32> map_uint32_uint32 = 3;
47+
map<uint64, uint64> map_uint64_uint64 = 4;
48+
map<sint32, sint32> map_sint32_sint32 = 5;
49+
map<sint64, sint64> map_sint64_sint64 = 6;
50+
map<fixed32, fixed32> map_fixed32_fixed32 = 7;
51+
map<fixed64, fixed64> map_fixed64_fixed64 = 8;
5352
map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
5453
map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
55-
map<int32 , float > map_int32_float = 11;
56-
map<int32 , double > map_int32_double = 12;
57-
map<bool , bool > map_bool_bool = 13;
58-
map<string , string > map_string_string = 14;
59-
map<int32 , bytes > map_int32_bytes = 15;
60-
map<int32 , MapEnum > map_int32_enum = 16;
61-
map<int32 , ForeignMessage> map_int32_foreign_message = 17;
62-
map<string , ForeignMessage> map_string_foreign_message = 18;
63-
map<int32 , TestAllTypes> map_int32_all_types = 19;
54+
map<int32, float> map_int32_float = 11;
55+
map<int32, double> map_int32_double = 12;
56+
map<bool, bool> map_bool_bool = 13;
57+
map<string, string> map_string_string = 14;
58+
map<int32, bytes> map_int32_bytes = 15;
59+
map<int32, MapEnum> map_int32_enum = 16;
60+
map<int32, ForeignMessage> map_int32_foreign_message = 17;
61+
map<string, ForeignMessage> map_string_foreign_message = 18;
62+
map<int32, TestAllTypes> map_int32_all_types = 19;
6463
}
6564

6665
message TestMapSubmessage {
@@ -90,33 +89,29 @@ message TestRequiredMessageMap {
9089
}
9190

9291
message TestArenaMap {
93-
map<int32 , int32 > map_int32_int32 = 1;
94-
map<int64 , int64 > map_int64_int64 = 2;
95-
map<uint32 , uint32 > map_uint32_uint32 = 3;
96-
map<uint64 , uint64 > map_uint64_uint64 = 4;
97-
map<sint32 , sint32 > map_sint32_sint32 = 5;
98-
map<sint64 , sint64 > map_sint64_sint64 = 6;
99-
map<fixed32 , fixed32 > map_fixed32_fixed32 = 7;
100-
map<fixed64 , fixed64 > map_fixed64_fixed64 = 8;
92+
map<int32, int32> map_int32_int32 = 1;
93+
map<int64, int64> map_int64_int64 = 2;
94+
map<uint32, uint32> map_uint32_uint32 = 3;
95+
map<uint64, uint64> map_uint64_uint64 = 4;
96+
map<sint32, sint32> map_sint32_sint32 = 5;
97+
map<sint64, sint64> map_sint64_sint64 = 6;
98+
map<fixed32, fixed32> map_fixed32_fixed32 = 7;
99+
map<fixed64, fixed64> map_fixed64_fixed64 = 8;
101100
map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
102101
map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
103-
map<int32 , float > map_int32_float = 11;
104-
map<int32 , double > map_int32_double = 12;
105-
map<bool , bool > map_bool_bool = 13;
106-
map<string , string > map_string_string = 14;
107-
map<int32 , bytes > map_int32_bytes = 15;
108-
map<int32 , MapEnum > map_int32_enum = 16;
109-
map<int32 , ForeignMessage> map_int32_foreign_message = 17;
110-
map<int32, .protobuf_unittest_no_arena.ForeignMessage>
111-
map_int32_foreign_message_no_arena = 18;
102+
map<int32, float> map_int32_float = 11;
103+
map<int32, double> map_int32_double = 12;
104+
map<bool, bool> map_bool_bool = 13;
105+
map<string, string> map_string_string = 14;
106+
map<int32, bytes> map_int32_bytes = 15;
107+
map<int32, MapEnum> map_int32_enum = 16;
108+
map<int32, ForeignMessage> map_int32_foreign_message = 17;
112109
}
113110

114111
// Previously, message containing enum called Type cannot be used as value of
115112
// map field.
116113
message MessageContainingEnumCalledType {
117-
enum Type {
118-
TYPE_FOO = 0;
119-
}
114+
enum Type { TYPE_FOO = 0; }
120115
map<string, MessageContainingEnumCalledType> type = 1;
121116
}
122117

Protos/google/protobuf/unittest_arena.proto

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
syntax = "proto2";
3232

33-
import "google/protobuf/unittest_no_arena_import.proto";
34-
3533
package proto2_arena_unittest;
3634

3735
option cc_enable_arenas = true;
@@ -41,6 +39,5 @@ message NestedMessage {
4139
}
4240

4341
message ArenaMessage {
44-
repeated NestedMessage repeated_nested_message = 1;
45-
repeated ImportNoArenaNestedMessage repeated_import_no_arena_message = 2;
46-
};
42+
repeated NestedMessage repeated_nested_message = 1;
43+
}

Protos/google/protobuf/unittest_lite.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ package protobuf_unittest;
3838

3939
import "google/protobuf/unittest_import_lite.proto";
4040

41-
option cc_enable_arenas = false;
41+
option cc_enable_arenas = true;
4242
option optimize_for = LITE_RUNTIME;
4343
option java_package = "com.google.protobuf";
4444

0 commit comments

Comments
 (0)