internal/impl: fix legacy logic to know about the new XXX_OneofWrappers method

The XXX_OneofWrappers method is a simplified way to obtain the wrapper structs
compared the previous XXX_OneofFuncs method which returned far more information
that was strictly necessary.

Change-Id: I2670506a2a8f7e8e724846b8c4083e7995371007
Reviewed-on: https://go-review.googlesource.com/c/151679
Reviewed-by: Herbie Ong <herbie@google.com>
This commit is contained in:
Joe Tsai 2018-11-28 23:43:49 -08:00 committed by Joe Tsai
parent 71acbc7b7d
commit 25cc69d405
8 changed files with 5156 additions and 25 deletions

View File

@ -189,6 +189,12 @@ func (ms *messageDescSet) processMessage(t reflect.Type) pref.MessageDescriptor
oneofWrappers = append(oneofWrappers, reflect.TypeOf(v))
}
}
if fn, ok := t.MethodByName("XXX_OneofWrappers"); ok {
vs := fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))})[0]
for _, v := range vs.Interface().([]interface{}) {
oneofWrappers = append(oneofWrappers, reflect.TypeOf(v))
}
}
// Obtain a list of the extension ranges.
if fn, ok := t.MethodByName("ExtensionRangeArray"); ok {

View File

@ -23,11 +23,13 @@ import (
proto2_20180125 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto2.v1.0.0-20180125-92554152"
proto2_20180430 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto2.v1.1.0-20180430-b4deda09"
proto2_20180814 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto2.v1.2.0-20180814-aa810b61"
proto2_20181126 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto2.v1.2.1-20181126-8d0c54c1"
proto3_20160225 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v0.0.0-20160225-2fc053c5"
proto3_20160519 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v0.0.0-20160519-a4ab9ec5"
proto3_20180125 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v1.0.0-20180125-92554152"
proto3_20180430 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v1.1.0-20180430-b4deda09"
proto3_20180814 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v1.2.0-20180814-aa810b61"
proto3_20181126 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v1.2.1-20181126-8d0c54c1"
)
func mustLoadFileDesc(b []byte, _ []int) pref.FileDescriptor {
@ -326,6 +328,63 @@ func TestLegacyDescriptor(t *testing.T) {
want: fileDescP3_20180814.Messages().ByName("Message"),
}}...)
fileDescP2_20181126 := mustLoadFileDesc(new(proto2_20181126.Message).Descriptor())
tests = append(tests, []struct{ got, want pref.Descriptor }{{
got: legacyLoadEnumDesc(reflect.TypeOf(proto2_20181126.SiblingEnum(0))),
want: fileDescP2_20181126.Enums().ByName("SiblingEnum"),
}, {
got: legacyLoadEnumDesc(reflect.TypeOf(proto2_20181126.Message_ChildEnum(0))),
want: fileDescP2_20181126.Messages().ByName("Message").Enums().ByName("ChildEnum"),
}, {
got: legacyLoadMessageDesc(reflect.TypeOf(new(proto2_20181126.SiblingMessage))),
want: fileDescP2_20181126.Messages().ByName("SiblingMessage"),
}, {
got: legacyLoadMessageDesc(reflect.TypeOf(new(proto2_20181126.Message_ChildMessage))),
want: fileDescP2_20181126.Messages().ByName("Message").Messages().ByName("ChildMessage"),
}, {
got: legacyLoadMessageDesc(reflect.TypeOf(new(proto2_20181126.Message))),
want: fileDescP2_20181126.Messages().ByName("Message"),
}, {
got: legacyLoadMessageDesc(reflect.TypeOf(new(proto2_20181126.Message_NamedGroup))),
want: fileDescP2_20181126.Messages().ByName("Message").Messages().ByName("NamedGroup"),
}, {
got: legacyLoadMessageDesc(reflect.TypeOf(new(proto2_20181126.Message_OptionalGroup))),
want: fileDescP2_20181126.Messages().ByName("Message").Messages().ByName("OptionalGroup"),
}, {
got: legacyLoadMessageDesc(reflect.TypeOf(new(proto2_20181126.Message_RequiredGroup))),
want: fileDescP2_20181126.Messages().ByName("Message").Messages().ByName("RequiredGroup"),
}, {
got: legacyLoadMessageDesc(reflect.TypeOf(new(proto2_20181126.Message_RepeatedGroup))),
want: fileDescP2_20181126.Messages().ByName("Message").Messages().ByName("RepeatedGroup"),
}, {
got: legacyLoadMessageDesc(reflect.TypeOf(new(proto2_20181126.Message_OneofGroup))),
want: fileDescP2_20181126.Messages().ByName("Message").Messages().ByName("OneofGroup"),
}, {
got: legacyLoadMessageDesc(reflect.TypeOf(new(proto2_20181126.Message_ExtensionOptionalGroup))),
want: fileDescP2_20181126.Messages().ByName("Message").Messages().ByName("ExtensionOptionalGroup"),
}, {
got: legacyLoadMessageDesc(reflect.TypeOf(new(proto2_20181126.Message_ExtensionRepeatedGroup))),
want: fileDescP2_20181126.Messages().ByName("Message").Messages().ByName("ExtensionRepeatedGroup"),
}}...)
fileDescP3_20181126 := mustLoadFileDesc(new(proto3_20181126.Message).Descriptor())
tests = append(tests, []struct{ got, want pref.Descriptor }{{
got: legacyLoadEnumDesc(reflect.TypeOf(proto3_20181126.SiblingEnum(0))),
want: fileDescP3_20181126.Enums().ByName("SiblingEnum"),
}, {
got: legacyLoadEnumDesc(reflect.TypeOf(proto3_20181126.Message_ChildEnum(0))),
want: fileDescP3_20181126.Messages().ByName("Message").Enums().ByName("ChildEnum"),
}, {
got: legacyLoadMessageDesc(reflect.TypeOf(new(proto3_20181126.SiblingMessage))),
want: fileDescP3_20181126.Messages().ByName("SiblingMessage"),
}, {
got: legacyLoadMessageDesc(reflect.TypeOf(new(proto3_20181126.Message_ChildMessage))),
want: fileDescP3_20181126.Messages().ByName("Message").Messages().ByName("ChildMessage"),
}, {
got: legacyLoadMessageDesc(reflect.TypeOf(new(proto3_20181126.Message))),
want: fileDescP3_20181126.Messages().ByName("Message"),
}}...)
type list interface {
Len() int
pragma.DoNotImplement

View File

@ -11,11 +11,13 @@ import (
proto2_v1_0 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto2.v1.0.0-20180125-92554152"
proto2_v1_1 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto2.v1.1.0-20180430-b4deda09"
proto2_v1_2 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto2.v1.2.0-20180814-aa810b61"
proto2_v1_21 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto2.v1.2.1-20181126-8d0c54c1"
proto3_v0_0 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v0.0.0-20160225-2fc053c5"
proto3_v0_01 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v0.0.0-20160519-a4ab9ec5"
proto3_v1_0 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v1.0.0-20180125-92554152"
proto3_v1_1 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v1.1.0-20180430-b4deda09"
proto3_v1_2 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v1.2.0-20180814-aa810b61"
proto3_v1_21 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v1.2.1-20181126-8d0c54c1"
math "math"
)
@ -28,7 +30,7 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type Legacy struct {
F1 *proto2_v0_0.Message `protobuf:"bytes,1,opt,name=f1,proto3" json:"f1,omitempty"`
@ -41,6 +43,8 @@ type Legacy struct {
F8 *proto3_v1_1.Message `protobuf:"bytes,8,opt,name=f8,proto3" json:"f8,omitempty"`
F9 *proto2_v1_2.Message `protobuf:"bytes,9,opt,name=f9,proto3" json:"f9,omitempty"`
F10 *proto3_v1_2.Message `protobuf:"bytes,10,opt,name=f10,proto3" json:"f10,omitempty"`
F11 *proto2_v1_21.Message `protobuf:"bytes,11,opt,name=f11,proto3" json:"f11,omitempty"`
F12 *proto3_v1_21.Message `protobuf:"bytes,12,opt,name=f12,proto3" json:"f12,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -141,6 +145,20 @@ func (m *Legacy) GetF10() *proto3_v1_2.Message {
return nil
}
func (m *Legacy) GetF11() *proto2_v1_21.Message {
if m != nil {
return m.F11
}
return nil
}
func (m *Legacy) GetF12() *proto3_v1_21.Message {
if m != nil {
return m.F12
}
return nil
}
func init() {
proto.RegisterType((*Legacy)(nil), "google.golang.org.Legacy")
}
@ -150,28 +168,30 @@ func init() {
}
var fileDescriptor_5fbf266527ec81d8 = []byte{
// 364 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0xd2, 0x3d, 0x4f, 0xf3, 0x30,
0x14, 0x05, 0x60, 0xf5, 0xe3, 0xed, 0x0b, 0x61, 0xa2, 0x93, 0xc5, 0x84, 0x58, 0x40, 0x48, 0x71,
0xec, 0x1b, 0x3b, 0x4d, 0x2a, 0x26, 0x24, 0x36, 0x58, 0x18, 0x59, 0x90, 0x93, 0x3a, 0xa6, 0x52,
0xa8, 0x51, 0x93, 0x56, 0xe2, 0xef, 0xf2, 0x4b, 0x10, 0x37, 0x44, 0x4a, 0xf9, 0x68, 0x5d, 0xda,
0x29, 0x8a, 0xa5, 0xe7, 0x9c, 0x33, 0x5c, 0xef, 0x7c, 0x3a, 0xab, 0xf4, 0x7c, 0xa6, 0x8a, 0xa0,
0xd2, 0x65, 0xf5, 0x32, 0xb7, 0x95, 0x2d, 0x83, 0x42, 0x1b, 0x95, 0xbd, 0x7e, 0x7e, 0x28, 0x3e,
0x0e, 0x8f, 0x8d, 0xb5, 0xa6, 0xd0, 0xd4, 0xd8, 0x42, 0xcd, 0x0c, 0xb5, 0x73, 0x73, 0x72, 0xb3,
0xc6, 0xe2, 0x1f, 0xd0, 0x25, 0xa3, 0x8c, 0x32, 0x1f, 0x18, 0x8f, 0x18, 0x80, 0xf4, 0x21, 0xcf,
0x98, 0x0c, 0x33, 0x89, 0xa2, 0x4e, 0xde, 0x1c, 0x13, 0xee, 0x27,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 0x7a, 0xfc, 0x10, 0x9b, 0x69, 0xf5, 0xb4, 0x48, 0x69, 0x66, 0x9f, 0x83, 0x5a,
0xd5, 0x47, 0x9a, 0x2e, 0xf2, 0x60, 0x09, 0xc1, 0xef, 0xb7, 0x9c, 0x0e, 0xea, 0xe4, 0xf7, 0x00,
0x00, 0x00, 0xff, 0xff, 0xb8, 0x31, 0xcb, 0xb1, 0xab, 0x05, 0x00, 0x00,
// 400 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0xd3, 0xcf, 0xce, 0xd2, 0x40,
0x14, 0x05, 0xf0, 0x00, 0x82, 0x5a, 0xdc, 0xc8, 0x6a, 0xe2, 0xca, 0xb8, 0xd1, 0x98, 0x74, 0x3a,
0xf7, 0x76, 0xa6, 0x4c, 0x89, 0x2b, 0x13, 0x77, 0xba, 0x71, 0xe9, 0xc6, 0x4c, 0xcb, 0x74, 0x24,
0xa9, 0xd4, 0xd0, 0x42, 0xe2, 0xcb, 0xfa, 0x2c, 0x86, 0x5b, 0x9a, 0x14, 0xf4, 0xe3, 0x1b, 0xfe,
0xac, 0x08, 0x4d, 0x7e, 0xe7, 0x9c, 0xc5, 0xdc, 0xe0, 0xed, 0x6a, 0xdd, 0xd8, 0xcd, 0xda, 0x94,
0x51, 0x63, 0xeb, 0xe6, 0xd7, 0xa6, 0x6a, 0xaa, 0x3a, 0x2a, 0xad, 0x33, 0xf9, 0xef, 0xc3, 0x0f,
0xa7, 0x8f, 0xb3, 0x97, 0xae, 0xaa, 0x5c, 0x69, 0xb9, 0xab, 0x4a, 0xb3, 0x76, 0xbc, 0xda, 0xb8,
0x57, 0x9f, 0xce, 0x58, 0xfa, 0x87, 0x7c, 0x27, 0xb8, 0xe0, 0x22, 0x44, 0x01, 0x89, 0x40, 0x54,
0x21, 0x16, 0xb9, 0x50, 0x71, 0xae, 0x48, 0xb4, 0xc9, 0x8f, 0xc7, 0xc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xbd, 0x1a, 0x64, 0xcf, 0xa6, 0xb3, 0x0f, 0xc1, 0xa8, 0x00, 0xc1, 0x02,
0xaf, 0xe2, 0x3e, 0xde, 0xb3, 0x56, 0x03, 0x9b, 0xfa, 0x54, 0xef, 0x5f, 0x6a, 0x5f, 0x43, 0xab,
0x91, 0xbd, 0xf0, 0xe9, 0x3e, 0xd5, 0xf8, 0x71, 0xf1, 0x4d, 0xbb, 0x55, 0xf3, 0x63, 0x9b, 0xf1,
0xbc, 0xfa, 0x19, 0xb5, 0xaa, 0x3d, 0x90, 0x6c, 0x5b, 0x44, 0x3b, 0x8c, 0x1e, 0xbe, 0xa3, 0x6c,
0xd2, 0x26, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x78, 0x39, 0xb9, 0x4a, 0xb5, 0x06, 0x00, 0x00,
}

View File

@ -50,6 +50,11 @@ import "internal/testprotos/legacy/proto3.v1.1.0-20180430-b4deda09/test.proto";
// * Added "proto3" struct tag to all fields in proto3 messages
import "internal/testprotos/legacy/proto2.v1.2.0-20180814-aa810b61/test.proto";
import "internal/testprotos/legacy/proto3.v1.2.0-20180814-aa810b61/test.proto";
// Changes from 20180814 to 20181126:
// * Changed the XXX_OneofFuncs method to XXX_OneofWrappers
// * Various syntactical changes to make the output more consistent
import "internal/testprotos/legacy/proto2.v1.2.1-20181126-8d0c54c1/test.proto";
import "internal/testprotos/legacy/proto3.v1.2.1-20181126-8d0c54c1/test.proto";
message Legacy {
google.golang.org.proto2_20160225.Message f1 = 1;
@ -62,4 +67,6 @@ message Legacy {
google.golang.org.proto3_20180430.Message f8 = 8;
google.golang.org.proto2_20180814.Message f9 = 9;
google.golang.org.proto3_20180814.Message f10 = 10;
google.golang.org.proto2_20181126.Message f11 = 11;
google.golang.org.proto3_20181126.Message f12 = 12;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,333 @@
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
syntax = "proto2";
package google.golang.org.proto2_20181126;
option go_package = "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto2.v1.2.1-20181126-8d0c54c1";
enum SiblingEnum {
ALPHA = 0;
BRAVO = 10;
CHARLIE = 200;
}
message SiblingMessage {
optional string f1 = 1;
required string f2 = 2;
repeated string f3 = 3;
optional Message f4 = 4;
}
message Message {
enum ChildEnum {
ALPHA = 0;
BRAVO = 1;
CHARLIE = 2;
}
message ChildMessage {
optional string f1 = 1;
required string f2 = 2;
repeated string f3 = 3;
optional Message f4 = 4;
}
optional group NamedGroup = 1 {
optional string f1 = 1;
required string f2 = 2;
repeated string f3 = 3;
optional Message f4 = 4;
}
// Optional fields.
optional bool optional_bool = 100;
optional int32 optional_int32 = 101;
optional sint32 optional_sint32 = 102;
optional uint32 optional_uint32 = 103;
optional int64 optional_int64 = 104;
optional sint64 optional_sint64 = 105;
optional uint64 optional_uint64 = 106;
optional fixed32 optional_fixed32 = 107;
optional sfixed32 optional_sfixed32 = 108;
optional float optional_float = 109;
optional fixed64 optional_fixed64 = 110;
optional sfixed64 optional_sfixed64 = 111;
optional double optional_double = 112;
optional string optional_string = 113;
optional bytes optional_bytes = 114;
optional ChildEnum optional_child_enum = 115;
optional ChildMessage optional_child_message = 116;
optional NamedGroup optional_named_group = 117;
optional SiblingEnum optional_sibling_enum = 118;
optional SiblingMessage optional_sibling_message = 119;
optional group OptionalGroup = 120 {
optional string f1 = 1;
required string f2 = 2;
repeated string f3 = 3;
}
// Optional default fields.
optional bool defaulted_bool = 200 [default = true];
optional int32 defaulted_int32 = 201 [default = -12345];
optional sint32 defaulted_sint32 = 202 [default = -3200];
optional uint32 defaulted_uint32 = 203 [default = 3200];
optional int64 defaulted_int64 = 204 [default = -123456789];
optional sint64 defaulted_sint64 = 205 [default = -6400];
optional uint64 defaulted_uint64 = 206 [default = 6400];
optional fixed32 defaulted_fixed32 = 207 [default = 320000];
optional sfixed32 defaulted_sfixed32 = 208 [default = -320000];
optional float defaulted_float = 209 [default = 3.14159];
optional fixed64 defaulted_fixed64 = 210 [default = 640000];
optional sfixed64 defaulted_sfixed64 = 211 [default = -640000];
optional double defaulted_double = 212 [default = 3.14159265359];
optional string defaulted_string = 213 [default = "hello, \"world!\"\n"];
optional bytes defaulted_bytes = 214 [default = "dead\xde\xad\xbe\xefbeef"];
optional ChildEnum defaulted_child_enum = 215 [default = ALPHA];
optional SiblingEnum defaulted_sibling_enum = 216 [default = ALPHA];
// Required fields.
required bool required_bool = 300;
required int32 required_int32 = 301;
required sint32 required_sint32 = 302;
required uint32 required_uint32 = 303;
required int64 required_int64 = 304;
required sint64 required_sint64 = 305;
required uint64 required_uint64 = 306;
required fixed32 required_fixed32 = 307;
required sfixed32 required_sfixed32 = 308;
required float required_float = 309;
required fixed64 required_fixed64 = 310;
required sfixed64 required_sfixed64 = 311;
required double required_double = 312;
required string required_string = 313;
required bytes required_bytes = 314;
required ChildEnum required_child_enum = 315;
required ChildMessage required_child_message = 316;
required NamedGroup required_named_group = 317;
required SiblingEnum required_sibling_enum = 318;
required SiblingMessage required_sibling_message = 319;
required group RequiredGroup = 320 {
optional string f1 = 1;
required string f2 = 2;
repeated string f3 = 3;
}
// Required default fields.
required bool required_defaulted_bool = 400 [default = true];
required int32 required_defaulted_int32 = 401 [default = -12345];
required sint32 required_defaulted_sint32 = 402 [default = -3200];
required uint32 required_defaulted_uint32 = 403 [default = 3200];
required int64 required_defaulted_int64 = 404 [default = -123456789];
required sint64 required_defaulted_sint64 = 405 [default = -6400];
required uint64 required_defaulted_uint64 = 406 [default = 6400];
required fixed32 required_defaulted_fixed32 = 407 [default = 320000];
required sfixed32 required_defaulted_sfixed32 = 408 [default = -320000];
required float required_defaulted_float = 409 [default = 3.14159];
required fixed64 required_defaulted_fixed64 = 410 [default = 640000];
required sfixed64 required_defaulted_sfixed64 = 411 [default = -640000];
required double required_defaulted_double = 412 [default = 3.14159265359];
required string required_defaulted_string = 413 [default = "hello, \"world!\"\n"];
required bytes required_defaulted_bytes = 414 [default = "dead\xde\xad\xbe\xefbeef"];
required ChildEnum required_defaulted_child_enum = 415 [default = ALPHA];
required SiblingEnum required_defaulted_sibling_enum = 416 [default = ALPHA];
// Repeated fields.
repeated bool repeated_bool = 500;
repeated int32 repeated_int32 = 501;
repeated sint32 repeated_sint32 = 502;
repeated uint32 repeated_uint32 = 503;
repeated int64 repeated_int64 = 504;
repeated sint64 repeated_sint64 = 505;
repeated uint64 repeated_uint64 = 506;
repeated fixed32 repeated_fixed32 = 507;
repeated sfixed32 repeated_sfixed32 = 508;
repeated float repeated_float = 509;
repeated fixed64 repeated_fixed64 = 510;
repeated sfixed64 repeated_sfixed64 = 511;
repeated double repeated_double = 512;
repeated string repeated_string = 513;
repeated bytes repeated_bytes = 514;
repeated ChildEnum repeated_child_enum = 515;
repeated ChildMessage repeated_child_message = 516;
repeated NamedGroup repeated_named_group = 517;
repeated SiblingEnum repeated_sibling_enum = 518;
repeated SiblingMessage repeated_sibling_message = 519;
repeated group RepeatedGroup = 520 {
optional string f1 = 1;
required string f2 = 2;
repeated string f3 = 3;
}
// Map fields.
map<bool, bool> map_bool_bool = 600;
map<bool, int32> map_bool_int32 = 601;
map<bool, sint32> map_bool_sint32 = 602;
map<bool, uint32> map_bool_uint32 = 603;
map<bool, int64> map_bool_int64 = 604;
map<bool, sint64> map_bool_sint64 = 605;
map<bool, uint64> map_bool_uint64 = 606;
map<bool, fixed32> map_bool_fixed32 = 607;
map<bool, sfixed32> map_bool_sfixed32 = 608;
map<bool, float> map_bool_float = 609;
map<bool, fixed64> map_bool_fixed64 = 610;
map<bool, sfixed64> map_bool_sfixed64 = 611;
map<bool, double> map_bool_double = 612;
map<bool, string> map_bool_string = 613;
map<bool, bytes> map_bool_bytes = 614;
map<bool, ChildEnum> map_bool_child_enum = 615;
map<bool, ChildMessage> map_bool_child_message = 616;
map<bool, NamedGroup> map_bool_named_group = 617;
map<bool, SiblingEnum> map_bool_sibling_enum = 618;
map<bool, SiblingMessage> map_bool_sibling_message = 619;
map<int32, bool> map_int32_bool = 620;
map<sint32, bool> map_sint32_bool = 621;
map<uint32, bool> map_uint32_bool = 622;
map<int64, bool> map_int64_bool = 623;
map<sint64, bool> map_sint64_bool = 624;
map<uint64, bool> map_uint64_bool = 625;
map<fixed32, bool> map_fixed32_bool = 626;
map<string, bool> map_string_bool = 627;
// Oneof fields.
oneof oneof_union {
bool oneof_bool = 700;
int32 oneof_int32 = 701;
sint32 oneof_sint32 = 702;
uint32 oneof_uint32 = 703;
int64 oneof_int64 = 704;
sint64 oneof_sint64 = 705;
uint64 oneof_uint64 = 706;
fixed32 oneof_fixed32 = 707;
sfixed32 oneof_sfixed32 = 708;
float oneof_float = 709;
fixed64 oneof_fixed64 = 710;
sfixed64 oneof_sfixed64 = 711;
double oneof_double = 712;
string oneof_string = 713;
bytes oneof_bytes = 714;
ChildEnum oneof_child_enum = 715;
ChildMessage oneof_child_message = 716;
NamedGroup oneof_named_group = 717;
SiblingEnum oneof_sibling_enum = 718;
SiblingMessage oneof_sibling_message = 719;
group OneofGroup = 720 {
optional string f1 = 1;
required string f2 = 2;
repeated string f3 = 3;
}
string oneof_string1 = 721;
string oneof_string2 = 722;
string oneof_string3 = 723;
}
// Oneof default fields.
oneof oneof_defaulted_union {
bool oneof_defaulted_bool = 800 [default = true];
int32 oneof_defaulted_int32 = 801 [default = -12345];
sint32 oneof_defaulted_sint32 = 802 [default = -3200];
uint32 oneof_defaulted_uint32 = 803 [default = 3200];
int64 oneof_defaulted_int64 = 804 [default = -123456789];
sint64 oneof_defaulted_sint64 = 805 [default = -6400];
uint64 oneof_defaulted_uint64 = 806 [default = 6400];
fixed32 oneof_defaulted_fixed32 = 807 [default = 320000];
sfixed32 oneof_defaulted_sfixed32 = 808 [default = -320000];
float oneof_defaulted_float = 809 [default = 3.14159];
fixed64 oneof_defaulted_fixed64 = 810 [default = 640000];
sfixed64 oneof_defaulted_sfixed64 = 811 [default = -640000];
double oneof_defaulted_double = 812 [default = 3.14159265359];
string oneof_defaulted_string = 813 [default = "hello, \"world!\"\n"];
bytes oneof_defaulted_bytes = 814 [default = "dead\xde\xad\xbe\xefbeef"];
ChildEnum oneof_defaulted_child_enum = 815 [default = ALPHA];
SiblingEnum oneof_defaulted_sibling_enum = 816 [default = ALPHA];
}
// Extension fields.
extend Message {
// Optional fields.
optional bool extension_optional_bool = 10000;
optional int32 extension_optional_int32 = 10001;
optional sint32 extension_optional_sint32 = 10002;
optional uint32 extension_optional_uint32 = 10003;
optional int64 extension_optional_int64 = 10004;
optional sint64 extension_optional_sint64 = 10005;
optional uint64 extension_optional_uint64 = 10006;
optional fixed32 extension_optional_fixed32 = 10007;
optional sfixed32 extension_optional_sfixed32 = 10008;
optional float extension_optional_float = 10009;
optional fixed64 extension_optional_fixed64 = 10010;
optional sfixed64 extension_optional_sfixed64 = 10011;
optional double extension_optional_double = 10012;
optional string extension_optional_string = 10013;
optional bytes extension_optional_bytes = 10014;
optional ChildEnum extension_optional_child_enum = 10015;
optional ChildMessage extension_optional_child_message = 10016;
optional NamedGroup extension_optional_named_group = 10017;
optional SiblingEnum extension_optional_sibling_enum = 10018;
optional SiblingMessage extension_optional_sibling_message = 10019;
optional group ExtensionOptionalGroup = 10020 {
optional string f1 = 1;
required string f2 = 2;
repeated string f3 = 3;
}
// Optional default fields.
optional bool extension_defaulted_bool = 20000 [default = true];
optional int32 extension_defaulted_int32 = 20001 [default = -12345];
optional sint32 extension_defaulted_sint32 = 20002 [default = -3200];
optional uint32 extension_defaulted_uint32 = 20003 [default = 3200];
optional int64 extension_defaulted_int64 = 20004 [default = -123456789];
optional sint64 extension_defaulted_sint64 = 20005 [default = -6400];
optional uint64 extension_defaulted_uint64 = 20006 [default = 6400];
optional fixed32 extension_defaulted_fixed32 = 20007 [default = 320000];
optional sfixed32 extension_defaulted_sfixed32 = 20008 [default = -320000];
optional float extension_defaulted_float = 20009 [default = 3.14159];
optional fixed64 extension_defaulted_fixed64 = 20010 [default = 640000];
optional sfixed64 extension_defaulted_sfixed64 = 20011 [default = -640000];
optional double extension_defaulted_double = 20012 [default = 3.14159265359];
optional string extension_defaulted_string = 20013 [default = "hello, \"world!\"\n"];
optional bytes extension_defaulted_bytes = 20014 [default = "dead\xde\xad\xbe\xefbeef"];
optional ChildEnum extension_defaulted_child_enum = 20015 [default = ALPHA];
optional SiblingEnum extension_defaulted_sibling_enum = 20016 [default = ALPHA];
// Repeated fields.
repeated bool extension_repeated_bool = 30000;
repeated int32 extension_repeated_int32 = 30001;
repeated sint32 extension_repeated_sint32 = 30002;
repeated uint32 extension_repeated_uint32 = 30003;
repeated int64 extension_repeated_int64 = 30004;
repeated sint64 extension_repeated_sint64 = 30005;
repeated uint64 extension_repeated_uint64 = 30006;
repeated fixed32 extension_repeated_fixed32 = 30007;
repeated sfixed32 extension_repeated_sfixed32 = 30008;
repeated float extension_repeated_float = 30009;
repeated fixed64 extension_repeated_fixed64 = 30010;
repeated sfixed64 extension_repeated_sfixed64 = 30011;
repeated double extension_repeated_double = 30012;
repeated string extension_repeated_string = 30013;
repeated bytes extension_repeated_bytes = 30014;
repeated ChildEnum extension_repeated_child_enum = 30015;
repeated ChildMessage extension_repeated_child_message = 30016;
repeated NamedGroup extension_repeated_named_group = 30017;
repeated SiblingEnum extension_repeated_sibling_enum = 30018;
repeated SiblingMessage extension_repeated_sibling_message = 30019;
repeated group ExtensionRepeatedGroup = 30020 {
optional string f1 = 1;
required string f2 = 2;
repeated string f3 = 3;
}
}
extensions 10000 to max;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,136 @@
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
syntax = "proto3";
package google.golang.org.proto3_20181126;
option go_package = "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v1.2.1-20181126-8d0c54c1";
enum SiblingEnum {
ALPHA = 0;
BRAVO = 10;
CHARLIE = 200;
}
message SiblingMessage {
string f1 = 1;
repeated string f2 = 2;
Message f3 = 3;
}
message Message {
enum ChildEnum {
ALPHA = 0;
BRAVO = 1;
CHARLIE = 2;
}
message ChildMessage {
string f1 = 1;
repeated string f2 = 2;
Message f3 = 3;
}
// Optional fields.
bool optional_bool = 100;
int32 optional_int32 = 101;
sint32 optional_sint32 = 102;
uint32 optional_uint32 = 103;
int64 optional_int64 = 104;
sint64 optional_sint64 = 105;
uint64 optional_uint64 = 106;
fixed32 optional_fixed32 = 107;
sfixed32 optional_sfixed32 = 108;
float optional_float = 109;
fixed64 optional_fixed64 = 110;
sfixed64 optional_sfixed64 = 111;
double optional_double = 112;
string optional_string = 113;
bytes optional_bytes = 114;
ChildEnum optional_child_enum = 115;
ChildMessage optional_child_message = 116;
SiblingEnum optional_sibling_enum = 117;
SiblingMessage optional_sibling_message = 118;
// Repeated fields.
repeated bool repeated_bool = 200;
repeated int32 repeated_int32 = 201;
repeated sint32 repeated_sint32 = 202;
repeated uint32 repeated_uint32 = 203;
repeated int64 repeated_int64 = 204;
repeated sint64 repeated_sint64 = 205;
repeated uint64 repeated_uint64 = 206;
repeated fixed32 repeated_fixed32 = 207;
repeated sfixed32 repeated_sfixed32 = 208;
repeated float repeated_float = 209;
repeated fixed64 repeated_fixed64 = 210;
repeated sfixed64 repeated_sfixed64 = 211;
repeated double repeated_double = 212;
repeated string repeated_string = 213;
repeated bytes repeated_bytes = 214;
repeated ChildEnum repeated_child_enum = 215;
repeated ChildMessage repeated_child_message = 216;
repeated SiblingEnum repeated_sibling_enum = 217;
repeated SiblingMessage repeated_sibling_message = 218;
// Map fields.
map<bool, bool> map_bool_bool = 300;
map<bool, int32> map_bool_int32 = 301;
map<bool, sint32> map_bool_sint32 = 302;
map<bool, uint32> map_bool_uint32 = 303;
map<bool, int64> map_bool_int64 = 304;
map<bool, sint64> map_bool_sint64 = 305;
map<bool, uint64> map_bool_uint64 = 306;
map<bool, fixed32> map_bool_fixed32 = 307;
map<bool, sfixed32> map_bool_sfixed32 = 308;
map<bool, float> map_bool_float = 309;
map<bool, fixed64> map_bool_fixed64 = 310;
map<bool, sfixed64> map_bool_sfixed64 = 311;
map<bool, double> map_bool_double = 312;
map<bool, string> map_bool_string = 313;
map<bool, bytes> map_bool_bytes = 314;
map<bool, ChildEnum> map_bool_child_enum = 315;
map<bool, ChildMessage> map_bool_child_message = 316;
map<bool, SiblingEnum> map_bool_sibling_enum = 317;
map<bool, SiblingMessage> map_bool_sibling_message = 318;
map<int32, bool> map_int32_bool = 319;
map<sint32, bool> map_sint32_bool = 320;
map<uint32, bool> map_uint32_bool = 321;
map<int64, bool> map_int64_bool = 322;
map<sint64, bool> map_sint64_bool = 323;
map<uint64, bool> map_uint64_bool = 324;
map<fixed32, bool> map_fixed32_bool = 325;
map<string, bool> map_string_bool = 326;
// Oneof fields.
oneof oneof_union {
bool oneof_bool = 400;
int32 oneof_int32 = 401;
sint32 oneof_sint32 = 402;
uint32 oneof_uint32 = 403;
int64 oneof_int64 = 404;
sint64 oneof_sint64 = 405;
uint64 oneof_uint64 = 406;
fixed32 oneof_fixed32 = 407;
sfixed32 oneof_sfixed32 = 408;
float oneof_float = 409;
fixed64 oneof_fixed64 = 410;
sfixed64 oneof_sfixed64 = 411;
double oneof_double = 412;
string oneof_string = 413;
bytes oneof_bytes = 414;
ChildEnum oneof_child_enum = 415;
ChildMessage oneof_child_message = 416;
SiblingEnum oneof_sibling_enum = 417;
SiblingMessage oneof_sibling_message = 418;
string oneof_string1 = 419;
string oneof_string2 = 420;
string oneof_string3 = 421;
}
}