From 0ca988a254f991240804bf9821f3450d87ccbb1b Mon Sep 17 00:00:00 2001 From: jmarais Date: Sun, 1 Sep 2019 13:10:31 +0200 Subject: [PATCH] merged in golang/protobuf commit 8d0c54c1246661d9a51ca0ba455d22116d485eaa - protoc-gen-go: generate XXX_OneofWrappers instead of XXX_OneofFuncs (#613) --- .../conformance_proto/conformance.pb.go | 281 +-------- gogoproto/gogo.pb.go | 2 +- .../jsonpb_test_proto/more_test_objects.pb.go | 2 +- jsonpb/jsonpb_test_proto/test_objects.pb.go | 111 +--- proto/lib.go | 20 +- proto/properties.go | 66 +- proto/proto3_proto/proto3.pb.go | 52 +- proto/table_marshal.go | 13 +- proto/table_unmarshal.go | 22 +- proto/test_proto/test.pb.go | 471 +------------- protoc-gen-gogo/descriptor/descriptor.pb.go | 2 +- protoc-gen-gogo/generator/generator.go | 482 +-------------- protoc-gen-gogo/plugin/plugin.pb.go | 2 +- .../testdata/deprecated/deprecated.pb.go | 52 +- .../extension_base/extension_base.pb.go | 2 +- .../extension_extra/extension_extra.pb.go | 2 +- .../extension_user/extension_user.pb.go | 2 +- protoc-gen-gogo/testdata/grpc/grpc.pb.go | 2 +- .../testdata/grpc/grpc_empty.pb.go | 2 +- .../testdata/import_public/a.pb.go | 2 +- .../testdata/import_public/b.pb.go | 2 +- .../import_public/importing/importing.pb.go | 2 +- .../testdata/import_public/sub/a.pb.go | 126 +--- .../testdata/import_public/sub/b.pb.go | 2 +- protoc-gen-gogo/testdata/imports/fmt/m.pb.go | 2 +- .../testdata/imports/test_a_1/m1.pb.go | 2 +- .../testdata/imports/test_a_1/m2.pb.go | 2 +- .../testdata/imports/test_a_2/m3.pb.go | 2 +- .../testdata/imports/test_a_2/m4.pb.go | 2 +- .../testdata/imports/test_b_1/m1.pb.go | 2 +- .../testdata/imports/test_b_1/m2.pb.go | 2 +- .../testdata/imports/test_import_a1m1.pb.go | 2 +- .../testdata/imports/test_import_a1m2.pb.go | 2 +- .../testdata/imports/test_import_all.pb.go | 2 +- protoc-gen-gogo/testdata/my_test/test.pb.go | 184 +----- protoc-gen-gogo/testdata/proto3/proto3.pb.go | 2 +- test/asymetric-issue125/asym.pb.go | 2 +- test/cachedsize/cachedsize.pb.go | 2 +- test/casttype/combos/both/casttype.pb.go | 2 +- test/casttype/combos/marshaler/casttype.pb.go | 2 +- test/casttype/combos/neither/casttype.pb.go | 2 +- .../combos/unmarshaler/casttype.pb.go | 2 +- test/castvalue/castvalue.pb.go | 2 +- test/castvalue/combos/both/castvalue.pb.go | 2 +- .../combos/marshaler/castvalue.pb.go | 2 +- .../combos/unmarshaler/castvalue.pb.go | 2 +- test/combos/both/thetest.pb.go | 2 +- test/combos/marshaler/thetest.pb.go | 2 +- test/combos/unmarshaler/thetest.pb.go | 2 +- test/custombytesnonstruct/proto.pb.go | 2 +- test/data/data.pb.go | 2 +- test/deterministic/deterministic.pb.go | 2 +- test/empty-issue70/empty.pb.go | 2 +- test/enumcustomname/enumcustomname.pb.go | 2 +- test/enumdecl/enumdecl.pb.go | 2 +- test/enumdecl_all/enumdeclall.pb.go | 2 +- test/enumprefix/enumprefix.pb.go | 2 +- test/enumstringer/enumstringer.pb.go | 2 +- test/example/example.pb.go | 2 +- test/filedotname/file.dot.pb.go | 2 +- test/fuzztests/fuzz.pb.go | 2 +- test/group/group.pb.go | 2 +- test/importcustom-issue389/imported/a.pb.go | 2 +- test/importcustom-issue389/importing/c.pb.go | 2 +- test/importdedup/proto.pb.go | 2 +- test/importdedup/subpkg/subproto.pb.go | 2 +- test/importduplicate/importduplicate.pb.go | 2 +- test/importduplicate/proto/proto.pb.go | 2 +- test/importduplicate/sortkeys/sortable.pb.go | 2 +- test/indeximport-issue72/index/index.pb.go | 2 +- test/indeximport-issue72/indeximport.pb.go | 2 +- test/int64support/object.pb.go | 2 +- test/issue260/issue260.pb.go | 2 +- test/issue261/issue261.pb.go | 2 +- test/issue262/timefail.pb.go | 2 +- test/issue312/events/events.pb.go | 2 +- test/issue312/issue312.pb.go | 2 +- test/issue322/issue322.pb.go | 51 +- test/issue330/issue330.pb.go | 2 +- test/issue34/proto.pb.go | 2 +- test/issue411/issue411.pb.go | 2 +- test/issue42order/issue42.pb.go | 2 +- test/issue435/issue435.pb.go | 2 +- test/issue438/issue438.pb.go | 2 +- test/issue444/issue444.pb.go | 2 +- test/issue449/issue449.pb.go | 2 +- test/issue498/issue498.pb.go | 2 +- test/issue503/issue503.pb.go | 2 +- test/issue530/issue530.pb.go | 2 +- test/issue8/proto.pb.go | 2 +- test/mapdefaults/combos/both/map.pb.go | 2 +- test/mapdefaults/combos/marshaler/map.pb.go | 2 +- test/mapdefaults/combos/neither/map.pb.go | 2 +- test/mapdefaults/combos/unmarshaler/map.pb.go | 2 +- test/mapsproto2/combos/both/mapsproto2.pb.go | 2 +- .../combos/marshaler/mapsproto2.pb.go | 2 +- .../combos/neither/mapsproto2.pb.go | 2 +- .../combos/unmarshaler/mapsproto2.pb.go | 2 +- test/merge/merge.pb.go | 2 +- test/moredefaults/md.pb.go | 2 +- test/nopackage/nopackage.pb.go | 2 +- test/oneof/combos/both/one.pb.go | 490 +-------------- test/oneof/combos/marshaler/one.pb.go | 490 +-------------- test/oneof/combos/neither/one.pb.go | 490 +-------------- test/oneof/combos/unmarshaler/one.pb.go | 490 +-------------- test/oneof3/combos/both/one.pb.go | 257 +------- test/oneof3/combos/marshaler/one.pb.go | 257 +------- test/oneof3/combos/neither/one.pb.go | 257 +------- test/oneof3/combos/unmarshaler/one.pb.go | 257 +------- test/oneofembed/oneofembed.pb.go | 72 +-- test/packed/packed.pb.go | 2 +- test/proto3extension/proto3ext.pb.go | 2 +- test/protosize/protosize.pb.go | 2 +- test/required/requiredexample.pb.go | 2 +- test/sizeunderscore/sizeunderscore.pb.go | 2 +- test/stdtypes/stdtypes.pb.go | 346 +---------- test/tags/tags.pb.go | 2 +- test/theproto3/combos/both/theproto3.pb.go | 2 +- .../combos/marshaler/theproto3.pb.go | 2 +- test/theproto3/combos/neither/theproto3.pb.go | 2 +- .../combos/unmarshaler/theproto3.pb.go | 2 +- test/thetest.pb.go | 2 +- test/typedecl/typedecl.pb.go | 2 +- test/typedecl_all/typedeclall.pb.go | 2 +- test/types/combos/both/types.pb.go | 580 +----------------- test/types/combos/marshaler/types.pb.go | 580 +----------------- test/types/combos/neither/types.pb.go | 580 +----------------- test/types/combos/unmarshaler/types.pb.go | 580 +----------------- test/unmarshalmerge/unmarshalmerge.pb.go | 2 +- test/unrecognized/unrecognized.pb.go | 2 +- .../unrecognizedgroup/unrecognizedgroup.pb.go | 2 +- test/xxxfields/xxxfields.pb.go | 2 +- types/any.pb.go | 2 +- types/api.pb.go | 2 +- types/duration.pb.go | 2 +- types/empty.pb.go | 2 +- types/field_mask.pb.go | 2 +- types/source_context.pb.go | 2 +- types/struct.pb.go | 131 +--- types/timestamp.pb.go | 2 +- types/type.pb.go | 2 +- types/wrappers.pb.go | 2 +- vanity/test/fast/gogovanity.pb.go | 2 +- vanity/test/fast/proto3.pb.go | 2 +- vanity/test/fast/vanity.pb.go | 2 +- vanity/test/faster/gogovanity.pb.go | 2 +- vanity/test/faster/proto3.pb.go | 2 +- vanity/test/faster/vanity.pb.go | 2 +- vanity/test/slick/gogovanity.pb.go | 2 +- vanity/test/slick/proto3.pb.go | 2 +- vanity/test/slick/vanity.pb.go | 2 +- 151 files changed, 343 insertions(+), 7691 deletions(-) diff --git a/conformance/internal/conformance_proto/conformance.pb.go b/conformance/internal/conformance_proto/conformance.pb.go index 1e32a72eb1..7c7804823d 100644 --- a/conformance/internal/conformance_proto/conformance.pb.go +++ b/conformance/internal/conformance_proto/conformance.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type WireFormat int32 @@ -194,72 +194,14 @@ func (m *ConformanceRequest) GetRequestedOutputFormat() WireFormat { return WireFormat_UNSPECIFIED } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*ConformanceRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _ConformanceRequest_OneofMarshaler, _ConformanceRequest_OneofUnmarshaler, _ConformanceRequest_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*ConformanceRequest) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*ConformanceRequest_ProtobufPayload)(nil), (*ConformanceRequest_JsonPayload)(nil), } } -func _ConformanceRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*ConformanceRequest) - // payload - switch x := m.Payload.(type) { - case *ConformanceRequest_ProtobufPayload: - _ = b.EncodeVarint(1<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.ProtobufPayload) - case *ConformanceRequest_JsonPayload: - _ = b.EncodeVarint(2<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.JsonPayload) - case nil: - default: - return fmt.Errorf("ConformanceRequest.Payload has unexpected type %T", x) - } - return nil -} - -func _ConformanceRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*ConformanceRequest) - switch tag { - case 1: // payload.protobuf_payload - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.Payload = &ConformanceRequest_ProtobufPayload{x} - return true, err - case 2: // payload.json_payload - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Payload = &ConformanceRequest_JsonPayload{x} - return true, err - default: - return false, nil - } -} - -func _ConformanceRequest_OneofSizer(msg proto.Message) (n int) { - m := msg.(*ConformanceRequest) - // payload - switch x := m.Payload.(type) { - case *ConformanceRequest_ProtobufPayload: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.ProtobufPayload))) - n += len(x.ProtobufPayload) - case *ConformanceRequest_JsonPayload: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.JsonPayload))) - n += len(x.JsonPayload) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - // Represents a single test case's output. type ConformanceResponse struct { // Types that are valid to be assigned to Result: @@ -378,9 +320,9 @@ func (m *ConformanceResponse) GetSkipped() string { return "" } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*ConformanceResponse) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _ConformanceResponse_OneofMarshaler, _ConformanceResponse_OneofUnmarshaler, _ConformanceResponse_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*ConformanceResponse) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*ConformanceResponse_ParseError)(nil), (*ConformanceResponse_SerializeError)(nil), (*ConformanceResponse_RuntimeError)(nil), @@ -390,120 +332,6 @@ func (*ConformanceResponse) XXX_OneofFuncs() (func(msg proto.Message, b *proto.B } } -func _ConformanceResponse_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*ConformanceResponse) - // result - switch x := m.Result.(type) { - case *ConformanceResponse_ParseError: - _ = b.EncodeVarint(1<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.ParseError) - case *ConformanceResponse_SerializeError: - _ = b.EncodeVarint(6<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.SerializeError) - case *ConformanceResponse_RuntimeError: - _ = b.EncodeVarint(2<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.RuntimeError) - case *ConformanceResponse_ProtobufPayload: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.ProtobufPayload) - case *ConformanceResponse_JsonPayload: - _ = b.EncodeVarint(4<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.JsonPayload) - case *ConformanceResponse_Skipped: - _ = b.EncodeVarint(5<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Skipped) - case nil: - default: - return fmt.Errorf("ConformanceResponse.Result has unexpected type %T", x) - } - return nil -} - -func _ConformanceResponse_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*ConformanceResponse) - switch tag { - case 1: // result.parse_error - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Result = &ConformanceResponse_ParseError{x} - return true, err - case 6: // result.serialize_error - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Result = &ConformanceResponse_SerializeError{x} - return true, err - case 2: // result.runtime_error - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Result = &ConformanceResponse_RuntimeError{x} - return true, err - case 3: // result.protobuf_payload - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.Result = &ConformanceResponse_ProtobufPayload{x} - return true, err - case 4: // result.json_payload - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Result = &ConformanceResponse_JsonPayload{x} - return true, err - case 5: // result.skipped - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Result = &ConformanceResponse_Skipped{x} - return true, err - default: - return false, nil - } -} - -func _ConformanceResponse_OneofSizer(msg proto.Message) (n int) { - m := msg.(*ConformanceResponse) - // result - switch x := m.Result.(type) { - case *ConformanceResponse_ParseError: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.ParseError))) - n += len(x.ParseError) - case *ConformanceResponse_SerializeError: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.SerializeError))) - n += len(x.SerializeError) - case *ConformanceResponse_RuntimeError: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.RuntimeError))) - n += len(x.RuntimeError) - case *ConformanceResponse_ProtobufPayload: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.ProtobufPayload))) - n += len(x.ProtobufPayload) - case *ConformanceResponse_JsonPayload: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.JsonPayload))) - n += len(x.JsonPayload) - case *ConformanceResponse_Skipped: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Skipped))) - n += len(x.Skipped) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - // This proto includes every type of field in both singular and repeated // forms. type TestAllTypes struct { @@ -1436,9 +1264,9 @@ func (m *TestAllTypes) GetFIELDName12() int32 { return 0 } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*TestAllTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _TestAllTypes_OneofMarshaler, _TestAllTypes_OneofUnmarshaler, _TestAllTypes_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*TestAllTypes) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*TestAllTypes_OneofUint32)(nil), (*TestAllTypes_OneofNestedMessage)(nil), (*TestAllTypes_OneofString)(nil), @@ -1446,95 +1274,6 @@ func (*TestAllTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) } } -func _TestAllTypes_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*TestAllTypes) - // oneof_field - switch x := m.OneofField.(type) { - case *TestAllTypes_OneofUint32: - _ = b.EncodeVarint(111<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.OneofUint32)) - case *TestAllTypes_OneofNestedMessage: - _ = b.EncodeVarint(112<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.OneofNestedMessage); err != nil { - return err - } - case *TestAllTypes_OneofString: - _ = b.EncodeVarint(113<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.OneofString) - case *TestAllTypes_OneofBytes: - _ = b.EncodeVarint(114<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.OneofBytes) - case nil: - default: - return fmt.Errorf("TestAllTypes.OneofField has unexpected type %T", x) - } - return nil -} - -func _TestAllTypes_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*TestAllTypes) - switch tag { - case 111: // oneof_field.oneof_uint32 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.OneofField = &TestAllTypes_OneofUint32{uint32(x)} - return true, err - case 112: // oneof_field.oneof_nested_message - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(TestAllTypes_NestedMessage) - err := b.DecodeMessage(msg) - m.OneofField = &TestAllTypes_OneofNestedMessage{msg} - return true, err - case 113: // oneof_field.oneof_string - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.OneofField = &TestAllTypes_OneofString{x} - return true, err - case 114: // oneof_field.oneof_bytes - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.OneofField = &TestAllTypes_OneofBytes{x} - return true, err - default: - return false, nil - } -} - -func _TestAllTypes_OneofSizer(msg proto.Message) (n int) { - m := msg.(*TestAllTypes) - // oneof_field - switch x := m.OneofField.(type) { - case *TestAllTypes_OneofUint32: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.OneofUint32)) - case *TestAllTypes_OneofNestedMessage: - s := proto.Size(x.OneofNestedMessage) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *TestAllTypes_OneofString: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.OneofString))) - n += len(x.OneofString) - case *TestAllTypes_OneofBytes: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.OneofBytes))) - n += len(x.OneofBytes) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type TestAllTypes_NestedMessage struct { A int32 `protobuf:"varint,1,opt,name=a,proto3" json:"a,omitempty"` Corecursive *TestAllTypes `protobuf:"bytes,2,opt,name=corecursive,proto3" json:"corecursive,omitempty"` diff --git a/gogoproto/gogo.pb.go b/gogoproto/gogo.pb.go index e352808b90..1e91766aee 100644 --- a/gogoproto/gogo.pb.go +++ b/gogoproto/gogo.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package var E_GoprotoEnumPrefix = &proto.ExtensionDesc{ ExtendedType: (*descriptor.EnumOptions)(nil), diff --git a/jsonpb/jsonpb_test_proto/more_test_objects.pb.go b/jsonpb/jsonpb_test_proto/more_test_objects.pb.go index 50275c41e2..9b7abfc6b4 100644 --- a/jsonpb/jsonpb_test_proto/more_test_objects.pb.go +++ b/jsonpb/jsonpb_test_proto/more_test_objects.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Numeral int32 diff --git a/jsonpb/jsonpb_test_proto/test_objects.pb.go b/jsonpb/jsonpb_test_proto/test_objects.pb.go index 7efcab8457..409f95a5e3 100644 --- a/jsonpb/jsonpb_test_proto/test_objects.pb.go +++ b/jsonpb/jsonpb_test_proto/test_objects.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Widget_Color int32 @@ -683,9 +683,9 @@ func (m *MsgWithOneof) GetMsgWithRequired() *MsgWithRequired { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*MsgWithOneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _MsgWithOneof_OneofMarshaler, _MsgWithOneof_OneofUnmarshaler, _MsgWithOneof_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*MsgWithOneof) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*MsgWithOneof_Title)(nil), (*MsgWithOneof_Salary)(nil), (*MsgWithOneof_Country)(nil), @@ -694,109 +694,6 @@ func (*MsgWithOneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) } } -func _MsgWithOneof_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*MsgWithOneof) - // union - switch x := m.Union.(type) { - case *MsgWithOneof_Title: - _ = b.EncodeVarint(1<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Title) - case *MsgWithOneof_Salary: - _ = b.EncodeVarint(2<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Salary)) - case *MsgWithOneof_Country: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Country) - case *MsgWithOneof_HomeAddress: - _ = b.EncodeVarint(4<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.HomeAddress) - case *MsgWithOneof_MsgWithRequired: - _ = b.EncodeVarint(5<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.MsgWithRequired); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("MsgWithOneof.Union has unexpected type %T", x) - } - return nil -} - -func _MsgWithOneof_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*MsgWithOneof) - switch tag { - case 1: // union.title - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Union = &MsgWithOneof_Title{x} - return true, err - case 2: // union.salary - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &MsgWithOneof_Salary{int64(x)} - return true, err - case 3: // union.Country - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Union = &MsgWithOneof_Country{x} - return true, err - case 4: // union.home_address - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Union = &MsgWithOneof_HomeAddress{x} - return true, err - case 5: // union.msg_with_required - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(MsgWithRequired) - err := b.DecodeMessage(msg) - m.Union = &MsgWithOneof_MsgWithRequired{msg} - return true, err - default: - return false, nil - } -} - -func _MsgWithOneof_OneofSizer(msg proto.Message) (n int) { - m := msg.(*MsgWithOneof) - // union - switch x := m.Union.(type) { - case *MsgWithOneof_Title: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Title))) - n += len(x.Title) - case *MsgWithOneof_Salary: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Salary)) - case *MsgWithOneof_Country: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Country))) - n += len(x.Country) - case *MsgWithOneof_HomeAddress: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.HomeAddress))) - n += len(x.HomeAddress) - case *MsgWithOneof_MsgWithRequired: - s := proto.Size(x.MsgWithRequired) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type Real struct { Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/proto/lib.go b/proto/lib.go index d17f802092..80db1c155b 100644 --- a/proto/lib.go +++ b/proto/lib.go @@ -948,13 +948,19 @@ func isProto3Zero(v reflect.Value) bool { return false } -// ProtoPackageIsVersion2 is referenced from generated protocol buffer files -// to assert that that code is compatible with this version of the proto package. -const GoGoProtoPackageIsVersion2 = true - -// ProtoPackageIsVersion1 is referenced from generated protocol buffer files -// to assert that that code is compatible with this version of the proto package. -const GoGoProtoPackageIsVersion1 = true +const ( + // ProtoPackageIsVersion3 is referenced from generated protocol buffer files + // to assert that that code is compatible with this version of the proto package. + GoGoProtoPackageIsVersion3 = true + + // ProtoPackageIsVersion2 is referenced from generated protocol buffer files + // to assert that that code is compatible with this version of the proto package. + GoGoProtoPackageIsVersion2 = true + + // ProtoPackageIsVersion1 is referenced from generated protocol buffer files + // to assert that that code is compatible with this version of the proto package. + GoGoProtoPackageIsVersion1 = true +) // InternalMessageInfo is a type used internally by generated .pb.go files. // This type is not intended to be used by non-generated code. diff --git a/proto/properties.go b/proto/properties.go index c9e5fa0207..62c55624a8 100644 --- a/proto/properties.go +++ b/proto/properties.go @@ -400,6 +400,15 @@ func GetProperties(t reflect.Type) *StructProperties { return sprop } +type ( + oneofFuncsIface interface { + XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) + } + oneofWrappersIface interface { + XXX_OneofWrappers() []interface{} + } +) + // getPropertiesLocked requires that propertiesMu is held. func getPropertiesLocked(t reflect.Type) *StructProperties { if prop, ok := propertiesMap[t]; ok { @@ -441,37 +450,40 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { // Re-order prop.order. sort.Sort(prop) - type oneofMessage interface { - XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) - } - if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok { + if isOneofMessage { var oots []interface{} - _, _, _, oots = om.XXX_OneofFuncs() - - // Interpret oneof metadata. - prop.OneofTypes = make(map[string]*OneofProperties) - for _, oot := range oots { - oop := &OneofProperties{ - Type: reflect.ValueOf(oot).Type(), // *T - Prop: new(Properties), - } - sft := oop.Type.Elem().Field(0) - oop.Prop.Name = sft.Name - oop.Prop.Parse(sft.Tag.Get("protobuf")) - // There will be exactly one interface field that - // this new value is assignable to. - for i := 0; i < t.NumField(); i++ { - f := t.Field(i) - if f.Type.Kind() != reflect.Interface { - continue + switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { + case oneofFuncsIface: + _, _, _, oots = m.XXX_OneofFuncs() + case oneofWrappersIface: + oots = m.XXX_OneofWrappers() + } + if len(oots) > 0 { + // Interpret oneof metadata. + prop.OneofTypes = make(map[string]*OneofProperties) + for _, oot := range oots { + oop := &OneofProperties{ + Type: reflect.ValueOf(oot).Type(), // *T + Prop: new(Properties), } - if !oop.Type.AssignableTo(f.Type) { - continue + sft := oop.Type.Elem().Field(0) + oop.Prop.Name = sft.Name + oop.Prop.Parse(sft.Tag.Get("protobuf")) + // There will be exactly one interface field that + // this new value is assignable to. + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + if f.Type.Kind() != reflect.Interface { + continue + } + if !oop.Type.AssignableTo(f.Type) { + continue + } + oop.Field = i + break } - oop.Field = i - break + prop.OneofTypes[oop.Prop.OrigName] = oop } - prop.OneofTypes[oop.Prop.OrigName] = oop } } diff --git a/proto/proto3_proto/proto3.pb.go b/proto/proto3_proto/proto3.pb.go index 973c726fee..f2dc6f9580 100644 --- a/proto/proto3_proto/proto3.pb.go +++ b/proto/proto3_proto/proto3.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Message_Humour int32 @@ -484,57 +484,13 @@ func (m *TestUTF8) GetMapValue() map[int64]string { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*TestUTF8) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _TestUTF8_OneofMarshaler, _TestUTF8_OneofUnmarshaler, _TestUTF8_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*TestUTF8) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*TestUTF8_Field)(nil), } } -func _TestUTF8_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*TestUTF8) - // oneof - switch x := m.Oneof.(type) { - case *TestUTF8_Field: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field) - case nil: - default: - return fmt.Errorf("TestUTF8.Oneof has unexpected type %T", x) - } - return nil -} - -func _TestUTF8_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*TestUTF8) - switch tag { - case 3: // oneof.field - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Oneof = &TestUTF8_Field{x} - return true, err - default: - return false, nil - } -} - -func _TestUTF8_OneofSizer(msg proto.Message) (n int) { - m := msg.(*TestUTF8) - // oneof - switch x := m.Oneof.(type) { - case *TestUTF8_Field: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field))) - n += len(x.Field) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterEnum("proto3_proto.Message_Humour", Message_Humour_name, Message_Humour_value) proto.RegisterType((*Message)(nil), "proto3_proto.Message") diff --git a/proto/table_marshal.go b/proto/table_marshal.go index 9b1538d055..db9927a0c7 100644 --- a/proto/table_marshal.go +++ b/proto/table_marshal.go @@ -389,8 +389,13 @@ func (u *marshalInfo) computeMarshalInfo() { // get oneof implementers var oneofImplementers []interface{} // gogo: isOneofMessage is needed for embedded oneof messages, without a marshaler and unmarshaler - if m, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok && isOneofMessage { - _, _, _, oneofImplementers = m.XXX_OneofFuncs() + if isOneofMessage { + switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { + case oneofFuncsIface: + _, _, _, oneofImplementers = m.XXX_OneofFuncs() + case oneofWrappersIface: + oneofImplementers = m.XXX_OneofWrappers() + } } // normal fields @@ -519,10 +524,6 @@ func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofI } } -type oneofMessage interface { - XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) -} - // wiretype returns the wire encoding of the type. func wiretype(encoding string) uint64 { switch encoding { diff --git a/proto/table_unmarshal.go b/proto/table_unmarshal.go index bb2622f28c..937229386a 100644 --- a/proto/table_unmarshal.go +++ b/proto/table_unmarshal.go @@ -371,15 +371,18 @@ func (u *unmarshalInfo) computeUnmarshalInfo() { } // Find any types associated with oneof fields. - // TODO: XXX_OneofFuncs returns more info than we need. Get rid of some of it? - fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("XXX_OneofFuncs") // gogo: len(oneofFields) > 0 is needed for embedded oneof messages, without a marshaler and unmarshaler - if fn.IsValid() && len(oneofFields) > 0 { - res := fn.Call(nil)[3] // last return value from XXX_OneofFuncs: []interface{} - for i := res.Len() - 1; i >= 0; i-- { - v := res.Index(i) // interface{} - tptr := reflect.ValueOf(v.Interface()).Type() // *Msg_X - typ := tptr.Elem() // Msg_X + if len(oneofFields) > 0 { + var oneofImplementers []interface{} + switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { + case oneofFuncsIface: + _, _, _, oneofImplementers = m.XXX_OneofFuncs() + case oneofWrappersIface: + oneofImplementers = m.XXX_OneofWrappers() + } + for _, v := range oneofImplementers { + tptr := reflect.TypeOf(v) // *Msg_X + typ := tptr.Elem() // Msg_X f := typ.Field(0) // oneof implementers have one field baseUnmarshal := fieldUnmarshaler(&f) @@ -407,11 +410,12 @@ func (u *unmarshalInfo) computeUnmarshalInfo() { u.setTag(fieldNum, of.field, unmarshal, 0, name) } } + } } // Get extension ranges, if any. - fn = reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray") + fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray") if fn.IsValid() { if !u.extensions.IsValid() && !u.oldExtensions.IsValid() && !u.bytesExtensions.IsValid() { panic("a message with extensions, but no extensions field in " + t.Name()) diff --git a/proto/test_proto/test.pb.go b/proto/test_proto/test.pb.go index b3fa22604d..de2dc47d8c 100644 --- a/proto/test_proto/test.pb.go +++ b/proto/test_proto/test.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type FOO int32 @@ -3323,9 +3323,9 @@ func (m *Oneof) GetValue() int32 { return 0 } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*Oneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _Oneof_OneofMarshaler, _Oneof_OneofUnmarshaler, _Oneof_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Oneof) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*Oneof_F_Bool)(nil), (*Oneof_F_Int32)(nil), (*Oneof_F_Int64)(nil), @@ -3347,298 +3347,6 @@ func (*Oneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, } } -func _Oneof_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*Oneof) - // union - switch x := m.Union.(type) { - case *Oneof_F_Bool: - t := uint64(0) - if x.F_Bool { - t = 1 - } - _ = b.EncodeVarint(1<<3 | proto.WireVarint) - _ = b.EncodeVarint(t) - case *Oneof_F_Int32: - _ = b.EncodeVarint(2<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.F_Int32)) - case *Oneof_F_Int64: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.F_Int64)) - case *Oneof_F_Fixed32: - _ = b.EncodeVarint(4<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.F_Fixed32)) - case *Oneof_F_Fixed64: - _ = b.EncodeVarint(5<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.F_Fixed64)) - case *Oneof_F_Uint32: - _ = b.EncodeVarint(6<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.F_Uint32)) - case *Oneof_F_Uint64: - _ = b.EncodeVarint(7<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.F_Uint64)) - case *Oneof_F_Float: - _ = b.EncodeVarint(8<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.F_Float))) - case *Oneof_F_Double: - _ = b.EncodeVarint(9<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.F_Double)) - case *Oneof_F_String: - _ = b.EncodeVarint(10<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.F_String) - case *Oneof_F_Bytes: - _ = b.EncodeVarint(11<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.F_Bytes) - case *Oneof_F_Sint32: - _ = b.EncodeVarint(12<<3 | proto.WireVarint) - _ = b.EncodeZigzag32(uint64(x.F_Sint32)) - case *Oneof_F_Sint64: - _ = b.EncodeVarint(13<<3 | proto.WireVarint) - _ = b.EncodeZigzag64(uint64(x.F_Sint64)) - case *Oneof_F_Enum: - _ = b.EncodeVarint(14<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.F_Enum)) - case *Oneof_F_Message: - _ = b.EncodeVarint(15<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.F_Message); err != nil { - return err - } - case *Oneof_FGroup: - _ = b.EncodeVarint(16<<3 | proto.WireStartGroup) - if err := b.Marshal(x.FGroup); err != nil { - return err - } - _ = b.EncodeVarint(16<<3 | proto.WireEndGroup) - case *Oneof_F_Largest_Tag: - _ = b.EncodeVarint(536870911<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.F_Largest_Tag)) - case nil: - default: - return fmt.Errorf("Oneof.Union has unexpected type %T", x) - } - // tormato - switch x := m.Tormato.(type) { - case *Oneof_Value: - _ = b.EncodeVarint(100<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Value)) - case nil: - default: - return fmt.Errorf("Oneof.Tormato has unexpected type %T", x) - } - return nil -} - -func _Oneof_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*Oneof) - switch tag { - case 1: // union.F_Bool - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &Oneof_F_Bool{x != 0} - return true, err - case 2: // union.F_Int32 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &Oneof_F_Int32{int32(x)} - return true, err - case 3: // union.F_Int64 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &Oneof_F_Int64{int64(x)} - return true, err - case 4: // union.F_Fixed32 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.Union = &Oneof_F_Fixed32{uint32(x)} - return true, err - case 5: // union.F_Fixed64 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.Union = &Oneof_F_Fixed64{x} - return true, err - case 6: // union.F_Uint32 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &Oneof_F_Uint32{uint32(x)} - return true, err - case 7: // union.F_Uint64 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &Oneof_F_Uint64{x} - return true, err - case 8: // union.F_Float - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.Union = &Oneof_F_Float{math.Float32frombits(uint32(x))} - return true, err - case 9: // union.F_Double - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.Union = &Oneof_F_Double{math.Float64frombits(x)} - return true, err - case 10: // union.F_String - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Union = &Oneof_F_String{x} - return true, err - case 11: // union.F_Bytes - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.Union = &Oneof_F_Bytes{x} - return true, err - case 12: // union.F_Sint32 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag32() - m.Union = &Oneof_F_Sint32{int32(x)} - return true, err - case 13: // union.F_Sint64 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag64() - m.Union = &Oneof_F_Sint64{int64(x)} - return true, err - case 14: // union.F_Enum - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &Oneof_F_Enum{MyMessage_Color(x)} - return true, err - case 15: // union.F_Message - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(GoTestField) - err := b.DecodeMessage(msg) - m.Union = &Oneof_F_Message{msg} - return true, err - case 16: // union.f_group - if wire != proto.WireStartGroup { - return true, proto.ErrInternalBadWireType - } - msg := new(Oneof_F_Group) - err := b.DecodeGroup(msg) - m.Union = &Oneof_FGroup{msg} - return true, err - case 536870911: // union.F_Largest_Tag - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &Oneof_F_Largest_Tag{int32(x)} - return true, err - case 100: // tormato.value - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Tormato = &Oneof_Value{int32(x)} - return true, err - default: - return false, nil - } -} - -func _Oneof_OneofSizer(msg proto.Message) (n int) { - m := msg.(*Oneof) - // union - switch x := m.Union.(type) { - case *Oneof_F_Bool: - n += 1 // tag and wire - n += 1 - case *Oneof_F_Int32: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.F_Int32)) - case *Oneof_F_Int64: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.F_Int64)) - case *Oneof_F_Fixed32: - n += 1 // tag and wire - n += 4 - case *Oneof_F_Fixed64: - n += 1 // tag and wire - n += 8 - case *Oneof_F_Uint32: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.F_Uint32)) - case *Oneof_F_Uint64: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.F_Uint64)) - case *Oneof_F_Float: - n += 1 // tag and wire - n += 4 - case *Oneof_F_Double: - n += 1 // tag and wire - n += 8 - case *Oneof_F_String: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.F_String))) - n += len(x.F_String) - case *Oneof_F_Bytes: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.F_Bytes))) - n += len(x.F_Bytes) - case *Oneof_F_Sint32: - n += 1 // tag and wire - n += proto.SizeVarint(uint64((uint32(x.F_Sint32) << 1) ^ uint32((int32(x.F_Sint32) >> 31)))) - case *Oneof_F_Sint64: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(uint64(x.F_Sint64<<1) ^ uint64((int64(x.F_Sint64) >> 63)))) - case *Oneof_F_Enum: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.F_Enum)) - case *Oneof_F_Message: - s := proto.Size(x.F_Message) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *Oneof_FGroup: - n += 2 // tag and wire - n += proto.Size(x.FGroup) - n += 2 // tag and wire - case *Oneof_F_Largest_Tag: - n += 5 // tag and wire - n += proto.SizeVarint(uint64(x.F_Largest_Tag)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - // tormato - switch x := m.Tormato.(type) { - case *Oneof_Value: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.Value)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type Oneof_F_Group struct { X *int32 `protobuf:"varint,17,opt,name=x" json:"x,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -3804,9 +3512,9 @@ func (m *Communique) GetMsg() *Strings { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*Communique) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _Communique_OneofMarshaler, _Communique_OneofUnmarshaler, _Communique_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Communique) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*Communique_Number)(nil), (*Communique_Name)(nil), (*Communique_Data)(nil), @@ -3816,121 +3524,6 @@ func (*Communique) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) er } } -func _Communique_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*Communique) - // union - switch x := m.Union.(type) { - case *Communique_Number: - _ = b.EncodeVarint(5<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Number)) - case *Communique_Name: - _ = b.EncodeVarint(6<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Name) - case *Communique_Data: - _ = b.EncodeVarint(7<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Data) - case *Communique_TempC: - _ = b.EncodeVarint(8<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.TempC)) - case *Communique_Col: - _ = b.EncodeVarint(9<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Col)) - case *Communique_Msg: - _ = b.EncodeVarint(10<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.Msg); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("Communique.Union has unexpected type %T", x) - } - return nil -} - -func _Communique_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*Communique) - switch tag { - case 5: // union.number - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &Communique_Number{int32(x)} - return true, err - case 6: // union.name - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Union = &Communique_Name{x} - return true, err - case 7: // union.data - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.Union = &Communique_Data{x} - return true, err - case 8: // union.temp_c - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.Union = &Communique_TempC{math.Float64frombits(x)} - return true, err - case 9: // union.col - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &Communique_Col{MyMessage_Color(x)} - return true, err - case 10: // union.msg - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Strings) - err := b.DecodeMessage(msg) - m.Union = &Communique_Msg{msg} - return true, err - default: - return false, nil - } -} - -func _Communique_OneofSizer(msg proto.Message) (n int) { - m := msg.(*Communique) - // union - switch x := m.Union.(type) { - case *Communique_Number: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Number)) - case *Communique_Name: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Name))) - n += len(x.Name) - case *Communique_Data: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Data))) - n += len(x.Data) - case *Communique_TempC: - n += 1 // tag and wire - n += 8 - case *Communique_Col: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Col)) - case *Communique_Msg: - s := proto.Size(x.Msg) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type TestUTF8 struct { Scalar *string `protobuf:"bytes,1,opt,name=scalar" json:"scalar,omitempty"` Vector []string `protobuf:"bytes,2,rep,name=vector" json:"vector,omitempty"` @@ -4020,57 +3613,13 @@ func (m *TestUTF8) GetMapValue() map[int64]string { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*TestUTF8) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _TestUTF8_OneofMarshaler, _TestUTF8_OneofUnmarshaler, _TestUTF8_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*TestUTF8) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*TestUTF8_Field)(nil), } } -func _TestUTF8_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*TestUTF8) - // oneof - switch x := m.Oneof.(type) { - case *TestUTF8_Field: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field) - case nil: - default: - return fmt.Errorf("TestUTF8.Oneof has unexpected type %T", x) - } - return nil -} - -func _TestUTF8_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*TestUTF8) - switch tag { - case 3: // oneof.field - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Oneof = &TestUTF8_Field{x} - return true, err - default: - return false, nil - } -} - -func _TestUTF8_OneofSizer(msg proto.Message) (n int) { - m := msg.(*TestUTF8) - // oneof - switch x := m.Oneof.(type) { - case *TestUTF8_Field: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field))) - n += len(x.Field) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - var E_Greeting = &proto.ExtensionDesc{ ExtendedType: (*MyMessage)(nil), ExtensionType: ([]string)(nil), diff --git a/protoc-gen-gogo/descriptor/descriptor.pb.go b/protoc-gen-gogo/descriptor/descriptor.pb.go index cacfa39235..d1307d9223 100644 --- a/protoc-gen-gogo/descriptor/descriptor.pb.go +++ b/protoc-gen-gogo/descriptor/descriptor.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type FieldDescriptorProto_Type int32 diff --git a/protoc-gen-gogo/generator/generator.go b/protoc-gen-gogo/generator/generator.go index 49693fdf58..dd260f142c 100644 --- a/protoc-gen-gogo/generator/generator.go +++ b/protoc-gen-gogo/generator/generator.go @@ -73,7 +73,7 @@ import ( // It is incremented whenever an incompatibility between the generated code and // proto package is introduced; the generated code references // a constant, proto.ProtoPackageIsVersionN (where N is generatedCodeVersion). -const generatedCodeVersion = 2 +const generatedCodeVersion = 3 // A Plugin provides functionality to add to the output during Go code generation, // such as to produce RPC stubs. @@ -2233,391 +2233,14 @@ type oneofSubField struct { getterDef string // Default for getters, e.g. "nil", `""` or "Default_MessageType_FieldName" protoDef string // Default value as defined in the proto file, e.g "yoshi" or "5" deprecated string // Deprecation comment, if any. - wireType string // gogo. We can set this on creation, instead of using a function -} - -// wireTypeName returns a textual wire type, needed for oneof sub fields in generated code. -func (f *oneofSubField) wireTypeName() string { - return f.wireType } // typedNil prints a nil casted to the pointer to this field. -// - for XXX_OneofFuncs +// - for XXX_OneofWrappers func (f *oneofSubField) typedNil(g *Generator) { g.P("(*", f.oneofTypeName, ")(nil),") } -// marshalCase prints the case matching this oneof subfield in the marshalling code. -func (f *oneofSubField) marshalCase(g *Generator, mc *msgCtx) { - // if field.OneofIndex == nil || int(*field.OneofIndex) != oi { - // continue - // } - g.P("case *", f.oneofTypeName, ":") - var pre, post string - val := "x." + f.goName // overridden for TYPE_BOOL - canFail := false // only TYPE_MESSAGE and TYPE_GROUP can fail - switch f.protoType { - case descriptor.FieldDescriptorProto_TYPE_DOUBLE: - pre = "b.EncodeFixed64(" + g.Pkg["math"] + ".Float64bits(" - post = "))" - case descriptor.FieldDescriptorProto_TYPE_FLOAT: - pre = "b.EncodeFixed32(uint64(" + g.Pkg["math"] + ".Float32bits(" - post = ")))" - case descriptor.FieldDescriptorProto_TYPE_INT64, - descriptor.FieldDescriptorProto_TYPE_UINT64: - pre, post = "b.EncodeVarint(uint64(", "))" - case descriptor.FieldDescriptorProto_TYPE_INT32, - descriptor.FieldDescriptorProto_TYPE_UINT32, - descriptor.FieldDescriptorProto_TYPE_ENUM: - pre, post = "b.EncodeVarint(uint64(", "))" - case descriptor.FieldDescriptorProto_TYPE_FIXED64, - descriptor.FieldDescriptorProto_TYPE_SFIXED64: - pre, post = "b.EncodeFixed64(uint64(", "))" - case descriptor.FieldDescriptorProto_TYPE_FIXED32, - descriptor.FieldDescriptorProto_TYPE_SFIXED32: - pre, post = "b.EncodeFixed32(uint64(", "))" - case descriptor.FieldDescriptorProto_TYPE_BOOL: - // bool needs special handling. - g.P("t := uint64(0)") - g.P("if ", val, " { t = 1 }") - val = "t" - pre, post = "b.EncodeVarint(", ")" - case descriptor.FieldDescriptorProto_TYPE_STRING: - pre, post = "b.EncodeStringBytes(", ")" - case descriptor.FieldDescriptorProto_TYPE_GROUP: - pre, post = "b.Marshal(", ")" - canFail = true - case descriptor.FieldDescriptorProto_TYPE_MESSAGE: - pre, post = "b.EncodeMessage(", ")" - canFail = true - case descriptor.FieldDescriptorProto_TYPE_BYTES: - pre, post = "b.EncodeRawBytes(", ")" - case descriptor.FieldDescriptorProto_TYPE_SINT32: - pre, post = "b.EncodeZigzag32(uint64(", "))" - case descriptor.FieldDescriptorProto_TYPE_SINT64: - pre, post = "b.EncodeZigzag64(uint64(", "))" - default: - g.Fail("unhandled oneof field type ", f.protoType.String()) - } - g.P("_ = b.EncodeVarint(", f.fieldNumber, "<<3|", g.Pkg["proto"], ".", f.wireTypeName(), ")") - if f.protoType == descriptor.FieldDescriptorProto_TYPE_BYTES && gogoproto.IsCustomType(f.protoField) { - g.P(`dAtA, err := `, val, `.Marshal()`) - g.P(`if err != nil {`) - g.In() - g.P(`return err`) - g.Out() - g.P(`}`) - val = "dAtA" - } else if gogoproto.IsStdType(f.protoField) { - pkg := g.useTypes() - ptr := "" - fnname := "" - if gogoproto.IsNullable(f.protoField) { - ptr = "*" - } - if gogoproto.IsStdTime(f.protoField) { - fnname = "Time" - } else if gogoproto.IsStdDuration(f.protoField) { - fnname = "Duration" - } else if gogoproto.IsStdDouble(f.protoField) { - fnname = "Double" - } else if gogoproto.IsStdFloat(f.protoField) { - fnname = "Float" - } else if gogoproto.IsStdInt64(f.protoField) { - fnname = "Int64" - } else if gogoproto.IsStdUInt64(f.protoField) { - fnname = "UInt64" - } else if gogoproto.IsStdInt32(f.protoField) { - fnname = "Int32" - } else if gogoproto.IsStdUInt32(f.protoField) { - fnname = "UInt32" - } else if gogoproto.IsStdBool(f.protoField) { - fnname = "Bool" - } else if gogoproto.IsStdString(f.protoField) { - fnname = "String" - } else if gogoproto.IsStdBytes(f.protoField) { - fnname = "Bytes" - } else { - panic("internal error") - } - g.P(`dAtA, err := `, pkg, `.Std`, fnname, `Marshal(`, ptr, val, `)`) - g.P(`if err != nil {`) - g.In() - g.P(`return err`) - g.Out() - g.P(`}`) - val = "dAtA" - pre, post = "b.EncodeRawBytes(", ")" - } - if !canFail { - g.P("_ = ", pre, val, post) - } else { - g.P("if err := ", pre, val, post, "; err != nil {") - g.In() - g.P("return err") - g.Out() - g.P("}") - } - if f.protoType == descriptor.FieldDescriptorProto_TYPE_GROUP { - g.P("_ = b.EncodeVarint(", f.fieldNumber, "<<3|", g.Pkg["proto"], ".WireEndGroup)") - } -} - -// unmarshalCase prints the case matching this oneof subfield in the unmarshalling code. -func (f *oneofSubField) unmarshalCase(g *Generator, origOneofName string, oneofName string, mc *msgCtx) { - // if field.OneofIndex == nil { - // continue - // } - g.P("case ", f.fieldNumber, ": // ", origOneofName, ".", f.getProtoName()) - g.P("if wire != ", g.Pkg["proto"], ".", f.wireTypeName(), " {") - g.P("return true, ", g.Pkg["proto"], ".ErrInternalBadWireType") - g.P("}") - lhs := "x, err" // overridden for TYPE_MESSAGE and TYPE_GROUP - var dec, cast, cast2 string - switch f.protoType { - case descriptor.FieldDescriptorProto_TYPE_DOUBLE: - dec, cast = "b.DecodeFixed64()", g.Pkg["math"]+".Float64frombits" - case descriptor.FieldDescriptorProto_TYPE_FLOAT: - dec, cast, cast2 = "b.DecodeFixed32()", "uint32", g.Pkg["math"]+".Float32frombits" - case descriptor.FieldDescriptorProto_TYPE_INT64: - dec, cast = "b.DecodeVarint()", "int64" - case descriptor.FieldDescriptorProto_TYPE_UINT64: - dec = "b.DecodeVarint()" - case descriptor.FieldDescriptorProto_TYPE_INT32: - dec, cast = "b.DecodeVarint()", "int32" - case descriptor.FieldDescriptorProto_TYPE_FIXED64: - dec = "b.DecodeFixed64()" - case descriptor.FieldDescriptorProto_TYPE_FIXED32: - dec, cast = "b.DecodeFixed32()", "uint32" - case descriptor.FieldDescriptorProto_TYPE_BOOL: - dec = "b.DecodeVarint()" - // handled specially below - case descriptor.FieldDescriptorProto_TYPE_STRING: - dec = "b.DecodeStringBytes()" - case descriptor.FieldDescriptorProto_TYPE_GROUP: - g.P("msg := new(", f.goType[1:], ")") // drop star - lhs = "err" - dec = "b.DecodeGroup(msg)" - // handled specially below - case descriptor.FieldDescriptorProto_TYPE_MESSAGE: - if gogoproto.IsStdType(f.protoField) { - dec = "b.DecodeRawBytes(true)" - } else { - g.P("msg := new(", f.goType[1:], ")") // drop star - lhs = "err" - dec = "b.DecodeMessage(msg)" - } - // handled specially below - case descriptor.FieldDescriptorProto_TYPE_BYTES: - dec = "b.DecodeRawBytes(true)" - case descriptor.FieldDescriptorProto_TYPE_UINT32: - dec, cast = "b.DecodeVarint()", "uint32" - case descriptor.FieldDescriptorProto_TYPE_ENUM: - dec, cast = "b.DecodeVarint()", f.goType - case descriptor.FieldDescriptorProto_TYPE_SFIXED32: - dec, cast = "b.DecodeFixed32()", "int32" - case descriptor.FieldDescriptorProto_TYPE_SFIXED64: - dec, cast = "b.DecodeFixed64()", "int64" - case descriptor.FieldDescriptorProto_TYPE_SINT32: - dec, cast = "b.DecodeZigzag32()", "int32" - case descriptor.FieldDescriptorProto_TYPE_SINT64: - dec, cast = "b.DecodeZigzag64()", "int64" - default: - g.Fail("unhandled oneof field type ", f.protoType.String()) - } - g.P(lhs, " := ", dec) - val := "x" - if f.protoType == descriptor.FieldDescriptorProto_TYPE_BYTES && gogoproto.IsCustomType(f.protoField) { - g.P(`if err != nil {`) - g.In() - g.P(`return true, err`) - g.Out() - g.P(`}`) - _, ctyp, err := GetCustomType(f.protoField) - if err != nil { - panic(err) - } - g.P(`var cc `, ctyp) - g.P(`c := &cc`) - g.P(`err = c.Unmarshal(`, val, `)`) - val = "*c" - } else if gogoproto.IsStdType(f.protoField) { - var stdtype string - var fnname string - if gogoproto.IsStdTime(f.protoField) { - stdtype = "time.Time" - fnname = "Time" - } else if gogoproto.IsStdDuration(f.protoField) { - stdtype = "time.Duration" - fnname = "Duration" - } else if gogoproto.IsStdDouble(f.protoField) { - stdtype = "float64" - fnname = "Double" - } else if gogoproto.IsStdFloat(f.protoField) { - stdtype = "float32" - fnname = "Float" - } else if gogoproto.IsStdInt64(f.protoField) { - stdtype = "int64" - fnname = "Int64" - } else if gogoproto.IsStdUInt64(f.protoField) { - stdtype = "uint64" - fnname = "UInt64" - } else if gogoproto.IsStdInt32(f.protoField) { - stdtype = "int32" - fnname = "Int32" - } else if gogoproto.IsStdUInt32(f.protoField) { - stdtype = "uint32" - fnname = "UInt32" - } else if gogoproto.IsStdBool(f.protoField) { - stdtype = "bool" - fnname = "Bool" - } else if gogoproto.IsStdString(f.protoField) { - stdtype = "string" - fnname = "String" - } else if gogoproto.IsStdBytes(f.protoField) { - stdtype = "[]byte" - fnname = "Bytes" - } else { - panic("internal error") - } - - pkg := g.useTypes() - g.P(`if err != nil {`) - g.In() - g.P(`return true, err`) - g.Out() - g.P(`}`) - g.P(`c := new(`, stdtype, `)`) - g.P(`if err2 := `, pkg, `.Std`, fnname, `Unmarshal(c, `, val, `); err2 != nil {`) - g.In() - g.P(`return true, err`) - g.Out() - g.P(`}`) - val = "c" - } - if cast != "" { - val = cast + "(" + val + ")" - } - if cast2 != "" { - val = cast2 + "(" + val + ")" - } - switch f.protoType { - case descriptor.FieldDescriptorProto_TYPE_BOOL: - val += " != 0" - case descriptor.FieldDescriptorProto_TYPE_GROUP, - descriptor.FieldDescriptorProto_TYPE_MESSAGE: - if !gogoproto.IsStdType(f.protoField) { - val = "msg" - } - } - if gogoproto.IsCastType(f.protoField) { - _, typ, err := getCastType(f.protoField) - if err != nil { - g.Fail(err.Error()) - } - val = typ + "(" + val + ")" - } - g.P("m.", oneofName, " = &", f.oneofTypeName, "{", val, "}") - g.P("return true, err") -} - -// sizerCase prints the case matching this oneof subfield in the sizer code. -func (f *oneofSubField) sizerCase(g *Generator) { - // if field.OneofIndex == nil || int(*field.OneofIndex) != oi { - // continue - // } - g.P("case *", f.oneofTypeName, ":") - val := "x." + f.goName - var varint, fixed string - switch f.protoType { - case descriptor.FieldDescriptorProto_TYPE_DOUBLE: - fixed = "8" - case descriptor.FieldDescriptorProto_TYPE_FLOAT: - fixed = "4" - case descriptor.FieldDescriptorProto_TYPE_INT64, - descriptor.FieldDescriptorProto_TYPE_UINT64, - descriptor.FieldDescriptorProto_TYPE_INT32, - descriptor.FieldDescriptorProto_TYPE_UINT32, - descriptor.FieldDescriptorProto_TYPE_ENUM: - varint = val - case descriptor.FieldDescriptorProto_TYPE_FIXED64, - descriptor.FieldDescriptorProto_TYPE_SFIXED64: - fixed = "8" - case descriptor.FieldDescriptorProto_TYPE_FIXED32, - descriptor.FieldDescriptorProto_TYPE_SFIXED32: - fixed = "4" - case descriptor.FieldDescriptorProto_TYPE_BOOL: - fixed = "1" - case descriptor.FieldDescriptorProto_TYPE_STRING: - fixed = "len(" + val + ")" - varint = fixed - case descriptor.FieldDescriptorProto_TYPE_GROUP: - fixed = g.Pkg["proto"] + ".Size(" + val + ")" - case descriptor.FieldDescriptorProto_TYPE_MESSAGE: - if gogoproto.IsStdType(f.protoField) { - pkg := g.useTypes() - if gogoproto.IsNullable(f.protoField) { - val = "*" + val - } - if gogoproto.IsStdTime(f.protoField) { - g.P("s := ", pkg, ".SizeOfStdTime(", val, ")") - } else if gogoproto.IsStdDuration(f.protoField) { - g.P("s := ", pkg, ".SizeOfStdDuration(", val, ")") - } else if gogoproto.IsStdDouble(f.protoField) { - g.P("s := ", pkg, ".SizeOfStdDouble(", val, ")") - } else if gogoproto.IsStdFloat(f.protoField) { - g.P("s := ", pkg, ".SizeOfStdFloat(", val, ")") - } else if gogoproto.IsStdInt64(f.protoField) { - g.P("s := ", pkg, ".SizeOfStdInt64(", val, ")") - } else if gogoproto.IsStdUInt64(f.protoField) { - g.P("s := ", pkg, ".SizeOfStdUInt64(", val, ")") - } else if gogoproto.IsStdInt32(f.protoField) { - g.P("s := ", pkg, ".SizeOfStdInt32(", val, ")") - } else if gogoproto.IsStdUInt32(f.protoField) { - g.P("s := ", pkg, ".SizeOfStdUInt32(", val, ")") - } else if gogoproto.IsStdBool(f.protoField) { - g.P("s := ", pkg, ".SizeOfStdBool(", val, ")") - } else if gogoproto.IsStdString(f.protoField) { - g.P("s := ", pkg, ".SizeOfStdString(", val, ")") - } else if gogoproto.IsStdBytes(f.protoField) { - g.P("s := ", pkg, ".SizeOfStdBytes(", val, ")") - } else { - panic("internal error") - } - } else { - g.P("s := ", g.Pkg["proto"], ".Size(", val, ")") - } - fixed = "s" - varint = fixed - case descriptor.FieldDescriptorProto_TYPE_BYTES: - if gogoproto.IsCustomType(f.protoField) { - fixed = val + ".Size()" - } else { - fixed = "len(" + val + ")" - } - varint = fixed - case descriptor.FieldDescriptorProto_TYPE_SINT32: - varint = "(uint32(" + val + ") << 1) ^ uint32((int32(" + val + ") >> 31))" - case descriptor.FieldDescriptorProto_TYPE_SINT64: - varint = "uint64(" + val + " << 1) ^ uint64((int64(" + val + ") >> 63))" - default: - g.Fail("unhandled oneof field type ", f.protoType.String()) - } - // Tag and wire varint is known statically, - // so don't generate code for that part of the size computation. - tagAndWireSize := proto.SizeVarint(uint64(f.fieldNumber << 3)) // wire doesn't affect varint size - g.P("n += ", tagAndWireSize, " // tag and wire") - if varint != "" { - g.P("n += ", g.Pkg["proto"], ".SizeVarint(uint64(", varint, "))") - } - if fixed != "" { - g.P("n += ", fixed) - } - if f.protoType == descriptor.FieldDescriptorProto_TYPE_GROUP { - g.P("n += ", tagAndWireSize, " // tag and wire") - } -} - // getProtoDef returns the default value explicitly stated in the proto file, e.g "yoshi" or "5". func (f *oneofSubField) getProtoDef() string { return f.protoDef @@ -2896,17 +2519,11 @@ func (g *Generator) generateOneofFuncs(mc *msgCtx, topLevelFields []topLevelFiel if len(ofields) == 0 { return } - enc := "_" + mc.goName + "_OneofMarshaler" - dec := "_" + mc.goName + "_OneofUnmarshaler" - size := "_" + mc.goName + "_OneofSizer" - encSig := "(msg " + g.Pkg["proto"] + ".Message, b *" + g.Pkg["proto"] + ".Buffer) error" - decSig := "(msg " + g.Pkg["proto"] + ".Message, tag, wire int, b *" + g.Pkg["proto"] + ".Buffer) (bool, error)" - sizeSig := "(msg " + g.Pkg["proto"] + ".Message) (n int)" // OneofFuncs - g.P("// XXX_OneofFuncs is for the internal use of the proto package.") - g.P("func (*", mc.goName, ") XXX_OneofFuncs() (func", encSig, ", func", decSig, ", func", sizeSig, ", []interface{}) {") - g.P("return ", enc, ", ", dec, ", ", size, ", []interface{}{") + g.P("// XXX_OneofWrappers is for the internal use of the proto package.") + g.P("func (*", mc.goName, ") XXX_OneofWrappers() []interface{} {") + g.P("return []interface{}{") for _, of := range ofields { for _, sf := range of.subFields { sf.typedNil(g) @@ -2915,56 +2532,6 @@ func (g *Generator) generateOneofFuncs(mc *msgCtx, topLevelFields []topLevelFiel g.P("}") g.P("}") g.P() - - // marshaler - g.P("func ", enc, encSig, " {") - g.P("m := msg.(*", mc.goName, ")") - for _, of := range ofields { - g.P("// ", of.getProtoName()) - g.P("switch x := m.", of.goName, ".(type) {") - for _, sf := range of.subFields { - sf.marshalCase(g, mc) - } - g.P("case nil:") - g.P("default: return ", g.Pkg["fmt"], `.Errorf("`, mc.goName, ".", of.goName, ` has unexpected type %T", x)`) - g.P("}") - } - g.P("return nil") - g.P("}") - g.P() - - // unmarshaler - g.P("func ", dec, decSig, " {") - g.P("m := msg.(*", mc.goName, ")") - g.P("switch tag {") - for _, of := range ofields { - for _, sf := range of.subFields { - sf.unmarshalCase(g, of.getProtoName(), of.goName, mc) - } - } - g.P("default: return false, nil") - g.P("}") - g.P("}") - g.P() - - // sizer - g.P("func ", size, sizeSig, " {") - g.P("m := msg.(*", mc.goName, ")") - for _, of := range ofields { - g.P("// ", of.getProtoName()) - g.P("switch x := m.", of.goName, ".(type) {") - for _, sf := range of.subFields { - // also fills in field.wire - sf.sizerCase(g) - } - g.P("case nil:") - g.P("default:") - g.P("panic(", g.Pkg["fmt"], ".Sprintf(\"proto: unexpected type %T in oneof\", x))") - g.P("}") - } - g.P("return n") - g.P("}") - g.P() } func (g *Generator) generateOneofDecls(mc *msgCtx, topLevelFields []topLevelField) { @@ -3383,7 +2950,6 @@ func (g *Generator) generateMessage(message *Descriptor) { protoDef: field.GetDefaultValue(), oneofTypeName: tname, deprecated: fieldDeprecated, - wireType: wireTypeName(field), } oneofField.subFields = append(oneofField.subFields, &sf) @@ -3824,44 +3390,6 @@ func IsScalar(field *descriptor.FieldDescriptorProto) bool { } } -func wireTypeName(field *descriptor.FieldDescriptorProto) string { - switch *field.Type { - case descriptor.FieldDescriptorProto_TYPE_DOUBLE: - return "WireFixed64" - case descriptor.FieldDescriptorProto_TYPE_FLOAT: - return "WireFixed32" - case descriptor.FieldDescriptorProto_TYPE_INT64, - descriptor.FieldDescriptorProto_TYPE_UINT64: - return "WireVarint" - case descriptor.FieldDescriptorProto_TYPE_INT32, - descriptor.FieldDescriptorProto_TYPE_UINT32, - descriptor.FieldDescriptorProto_TYPE_ENUM: - return "WireVarint" - case descriptor.FieldDescriptorProto_TYPE_FIXED64, - descriptor.FieldDescriptorProto_TYPE_SFIXED64: - return "WireFixed64" - case descriptor.FieldDescriptorProto_TYPE_FIXED32, - descriptor.FieldDescriptorProto_TYPE_SFIXED32: - return "WireFixed32" - case descriptor.FieldDescriptorProto_TYPE_BOOL: - return "WireVarint" - case descriptor.FieldDescriptorProto_TYPE_STRING: - return "WireBytes" - case descriptor.FieldDescriptorProto_TYPE_GROUP: - return "WireStartGroup" - case descriptor.FieldDescriptorProto_TYPE_MESSAGE: - return "WireBytes" - case descriptor.FieldDescriptorProto_TYPE_BYTES: - return "WireBytes" - case descriptor.FieldDescriptorProto_TYPE_SINT32: - return "WireVarint" - case descriptor.FieldDescriptorProto_TYPE_SINT64: - return "WireVarint" - default: - return "WireVarint" - } -} - // badToUnderscore is the mapping function used to generate Go names from package names, // which can be dotted in the input .proto file. It replaces non-identifier characters such as // dot or dash with underscore. diff --git a/protoc-gen-gogo/plugin/plugin.pb.go b/protoc-gen-gogo/plugin/plugin.pb.go index 131d05ffe8..8c9cb58b0d 100644 --- a/protoc-gen-gogo/plugin/plugin.pb.go +++ b/protoc-gen-gogo/plugin/plugin.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // The version number of protocol compiler. type Version struct { diff --git a/protoc-gen-gogo/testdata/deprecated/deprecated.pb.go b/protoc-gen-gogo/testdata/deprecated/deprecated.pb.go index e6afb49d56..43b97b19ab 100644 --- a/protoc-gen-gogo/testdata/deprecated/deprecated.pb.go +++ b/protoc-gen-gogo/testdata/deprecated/deprecated.pb.go @@ -24,7 +24,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // DeprecatedEnum contains deprecated values. type DeprecatedEnum int32 // Deprecated: Do not use. @@ -153,57 +153,13 @@ func (m *DeprecatedResponse) GetDeprecatedOneofField() string { return "" } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*DeprecatedResponse) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _DeprecatedResponse_OneofMarshaler, _DeprecatedResponse_OneofUnmarshaler, _DeprecatedResponse_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*DeprecatedResponse) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*DeprecatedResponse_DeprecatedOneofField)(nil), } } -func _DeprecatedResponse_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*DeprecatedResponse) - // deprecated_oneof - switch x := m.DeprecatedOneof.(type) { - case *DeprecatedResponse_DeprecatedOneofField: - _ = b.EncodeVarint(2<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.DeprecatedOneofField) - case nil: - default: - return fmt.Errorf("DeprecatedResponse.DeprecatedOneof has unexpected type %T", x) - } - return nil -} - -func _DeprecatedResponse_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*DeprecatedResponse) - switch tag { - case 2: // deprecated_oneof.deprecated_oneof_field - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.DeprecatedOneof = &DeprecatedResponse_DeprecatedOneofField{x} - return true, err - default: - return false, nil - } -} - -func _DeprecatedResponse_OneofSizer(msg proto.Message) (n int) { - m := msg.(*DeprecatedResponse) - // deprecated_oneof - switch x := m.DeprecatedOneof.(type) { - case *DeprecatedResponse_DeprecatedOneofField: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.DeprecatedOneofField))) - n += len(x.DeprecatedOneofField) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterEnum("deprecated.DeprecatedEnum", DeprecatedEnum_name, DeprecatedEnum_value) proto.RegisterType((*DeprecatedRequest)(nil), "deprecated.DeprecatedRequest") diff --git a/protoc-gen-gogo/testdata/extension_base/extension_base.pb.go b/protoc-gen-gogo/testdata/extension_base/extension_base.pb.go index 7f223a3dfa..6fa4ac1ed3 100644 --- a/protoc-gen-gogo/testdata/extension_base/extension_base.pb.go +++ b/protoc-gen-gogo/testdata/extension_base/extension_base.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type BaseMessage struct { Height *int32 `protobuf:"varint,1,opt,name=height" json:"height,omitempty"` diff --git a/protoc-gen-gogo/testdata/extension_extra/extension_extra.pb.go b/protoc-gen-gogo/testdata/extension_extra/extension_extra.pb.go index 639b3d9690..be243f26c0 100644 --- a/protoc-gen-gogo/testdata/extension_extra/extension_extra.pb.go +++ b/protoc-gen-gogo/testdata/extension_extra/extension_extra.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type ExtraMessage struct { Width *int32 `protobuf:"varint,1,opt,name=width" json:"width,omitempty"` diff --git a/protoc-gen-gogo/testdata/extension_user/extension_user.pb.go b/protoc-gen-gogo/testdata/extension_user/extension_user.pb.go index f8df45b11d..7a7a590f00 100644 --- a/protoc-gen-gogo/testdata/extension_user/extension_user.pb.go +++ b/protoc-gen-gogo/testdata/extension_user/extension_user.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type UserMessage struct { Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` diff --git a/protoc-gen-gogo/testdata/grpc/grpc.pb.go b/protoc-gen-gogo/testdata/grpc/grpc.pb.go index 6a8cbf8bc5..d621c2aa41 100644 --- a/protoc-gen-gogo/testdata/grpc/grpc.pb.go +++ b/protoc-gen-gogo/testdata/grpc/grpc.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type SimpleRequest struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/protoc-gen-gogo/testdata/grpc/grpc_empty.pb.go b/protoc-gen-gogo/testdata/grpc/grpc_empty.pb.go index ad1c249a22..6f1cbfc318 100644 --- a/protoc-gen-gogo/testdata/grpc/grpc_empty.pb.go +++ b/protoc-gen-gogo/testdata/grpc/grpc_empty.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package func init() { proto.RegisterFile("grpc/grpc_empty.proto", fileDescriptor_c580a37f1c90e9b1) } diff --git a/protoc-gen-gogo/testdata/import_public/a.pb.go b/protoc-gen-gogo/testdata/import_public/a.pb.go index 66d16f6e1c..878550e88f 100644 --- a/protoc-gen-gogo/testdata/import_public/a.pb.go +++ b/protoc-gen-gogo/testdata/import_public/a.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package const Default_M_DefaultField = sub.Default_M_DefaultField diff --git a/protoc-gen-gogo/testdata/import_public/b.pb.go b/protoc-gen-gogo/testdata/import_public/b.pb.go index 989c4201ae..b0923e6289 100644 --- a/protoc-gen-gogo/testdata/import_public/b.pb.go +++ b/protoc-gen-gogo/testdata/import_public/b.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Local struct { M *sub.M `protobuf:"bytes,1,opt,name=m" json:"m,omitempty"` diff --git a/protoc-gen-gogo/testdata/import_public/importing/importing.pb.go b/protoc-gen-gogo/testdata/import_public/importing/importing.pb.go index c298f96a09..6415759449 100644 --- a/protoc-gen-gogo/testdata/import_public/importing/importing.pb.go +++ b/protoc-gen-gogo/testdata/import_public/importing/importing.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type M struct { // Message type defined in a file publicly imported by a file we import. diff --git a/protoc-gen-gogo/testdata/import_public/sub/a.pb.go b/protoc-gen-gogo/testdata/import_public/sub/a.pb.go index 47901904e9..9116ac5ff7 100644 --- a/protoc-gen-gogo/testdata/import_public/sub/a.pb.go +++ b/protoc-gen-gogo/testdata/import_public/sub/a.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type E int32 @@ -227,70 +227,14 @@ func (m *M) GetDefaultField() string { return Default_M_DefaultField } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*M) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _M_OneofMarshaler, _M_OneofUnmarshaler, _M_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*M) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*M_OneofInt32)(nil), (*M_OneofInt64)(nil), } } -func _M_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*M) - // oneof_field - switch x := m.OneofField.(type) { - case *M_OneofInt32: - _ = b.EncodeVarint(2<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.OneofInt32)) - case *M_OneofInt64: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.OneofInt64)) - case nil: - default: - return fmt.Errorf("M.OneofField has unexpected type %T", x) - } - return nil -} - -func _M_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*M) - switch tag { - case 2: // oneof_field.oneof_int32 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.OneofField = &M_OneofInt32{int32(x)} - return true, err - case 3: // oneof_field.oneof_int64 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.OneofField = &M_OneofInt64{int64(x)} - return true, err - default: - return false, nil - } -} - -func _M_OneofSizer(msg proto.Message) (n int) { - m := msg.(*M) - // oneof_field - switch x := m.OneofField.(type) { - case *M_OneofInt32: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.OneofInt32)) - case *M_OneofInt64: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.OneofInt64)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type M_Grouping struct { GroupField *string `protobuf:"bytes,5,opt,name=group_field,json=groupField" json:"group_field,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -398,70 +342,14 @@ func (m *M_Submessage) GetSubmessageOneofInt64() int64 { return 0 } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*M_Submessage) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _M_Submessage_OneofMarshaler, _M_Submessage_OneofUnmarshaler, _M_Submessage_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*M_Submessage) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*M_Submessage_SubmessageOneofInt32)(nil), (*M_Submessage_SubmessageOneofInt64)(nil), } } -func _M_Submessage_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*M_Submessage) - // submessage_oneof_field - switch x := m.SubmessageOneofField.(type) { - case *M_Submessage_SubmessageOneofInt32: - _ = b.EncodeVarint(1<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.SubmessageOneofInt32)) - case *M_Submessage_SubmessageOneofInt64: - _ = b.EncodeVarint(2<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.SubmessageOneofInt64)) - case nil: - default: - return fmt.Errorf("M_Submessage.SubmessageOneofField has unexpected type %T", x) - } - return nil -} - -func _M_Submessage_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*M_Submessage) - switch tag { - case 1: // submessage_oneof_field.submessage_oneof_int32 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.SubmessageOneofField = &M_Submessage_SubmessageOneofInt32{int32(x)} - return true, err - case 2: // submessage_oneof_field.submessage_oneof_int64 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.SubmessageOneofField = &M_Submessage_SubmessageOneofInt64{int64(x)} - return true, err - default: - return false, nil - } -} - -func _M_Submessage_OneofSizer(msg proto.Message) (n int) { - m := msg.(*M_Submessage) - // submessage_oneof_field - switch x := m.SubmessageOneofField.(type) { - case *M_Submessage_SubmessageOneofInt32: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.SubmessageOneofInt32)) - case *M_Submessage_SubmessageOneofInt64: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.SubmessageOneofInt64)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - var E_ExtensionField = &proto.ExtensionDesc{ ExtendedType: (*M2)(nil), ExtensionType: (*string)(nil), diff --git a/protoc-gen-gogo/testdata/import_public/sub/b.pb.go b/protoc-gen-gogo/testdata/import_public/sub/b.pb.go index c9dbd8c0bf..ed178f929d 100644 --- a/protoc-gen-gogo/testdata/import_public/sub/b.pb.go +++ b/protoc-gen-gogo/testdata/import_public/sub/b.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type M2 struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/protoc-gen-gogo/testdata/imports/fmt/m.pb.go b/protoc-gen-gogo/testdata/imports/fmt/m.pb.go index 245cc81c1e..1f2d716548 100644 --- a/protoc-gen-gogo/testdata/imports/fmt/m.pb.go +++ b/protoc-gen-gogo/testdata/imports/fmt/m.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type M struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/protoc-gen-gogo/testdata/imports/test_a_1/m1.pb.go b/protoc-gen-gogo/testdata/imports/test_a_1/m1.pb.go index 60b390197d..f76cdedcc8 100644 --- a/protoc-gen-gogo/testdata/imports/test_a_1/m1.pb.go +++ b/protoc-gen-gogo/testdata/imports/test_a_1/m1.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type E1 int32 diff --git a/protoc-gen-gogo/testdata/imports/test_a_1/m2.pb.go b/protoc-gen-gogo/testdata/imports/test_a_1/m2.pb.go index c2604d6fc8..2f34f8046d 100644 --- a/protoc-gen-gogo/testdata/imports/test_a_1/m2.pb.go +++ b/protoc-gen-gogo/testdata/imports/test_a_1/m2.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type M2 struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/protoc-gen-gogo/testdata/imports/test_a_2/m3.pb.go b/protoc-gen-gogo/testdata/imports/test_a_2/m3.pb.go index f25c6688bb..4d5d608fc1 100644 --- a/protoc-gen-gogo/testdata/imports/test_a_2/m3.pb.go +++ b/protoc-gen-gogo/testdata/imports/test_a_2/m3.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type M3 struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/protoc-gen-gogo/testdata/imports/test_a_2/m4.pb.go b/protoc-gen-gogo/testdata/imports/test_a_2/m4.pb.go index 0fa0164e44..7046d81480 100644 --- a/protoc-gen-gogo/testdata/imports/test_a_2/m4.pb.go +++ b/protoc-gen-gogo/testdata/imports/test_a_2/m4.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type M4 struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/protoc-gen-gogo/testdata/imports/test_b_1/m1.pb.go b/protoc-gen-gogo/testdata/imports/test_b_1/m1.pb.go index 4207274ef7..a2d7978eeb 100644 --- a/protoc-gen-gogo/testdata/imports/test_b_1/m1.pb.go +++ b/protoc-gen-gogo/testdata/imports/test_b_1/m1.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type M1 struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/protoc-gen-gogo/testdata/imports/test_b_1/m2.pb.go b/protoc-gen-gogo/testdata/imports/test_b_1/m2.pb.go index 56779a6197..b3f1d6937c 100644 --- a/protoc-gen-gogo/testdata/imports/test_b_1/m2.pb.go +++ b/protoc-gen-gogo/testdata/imports/test_b_1/m2.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type M2 struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/protoc-gen-gogo/testdata/imports/test_import_a1m1.pb.go b/protoc-gen-gogo/testdata/imports/test_import_a1m1.pb.go index 960aed26ad..c39fa8eff0 100644 --- a/protoc-gen-gogo/testdata/imports/test_import_a1m1.pb.go +++ b/protoc-gen-gogo/testdata/imports/test_import_a1m1.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type A1M1 struct { F *test_a_1.M1 `protobuf:"bytes,1,opt,name=f,proto3" json:"f,omitempty"` diff --git a/protoc-gen-gogo/testdata/imports/test_import_a1m2.pb.go b/protoc-gen-gogo/testdata/imports/test_import_a1m2.pb.go index 4dd0080956..15f3824f2c 100644 --- a/protoc-gen-gogo/testdata/imports/test_import_a1m2.pb.go +++ b/protoc-gen-gogo/testdata/imports/test_import_a1m2.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type A1M2 struct { F *test_a_1.M2 `protobuf:"bytes,1,opt,name=f,proto3" json:"f,omitempty"` diff --git a/protoc-gen-gogo/testdata/imports/test_import_all.pb.go b/protoc-gen-gogo/testdata/imports/test_import_all.pb.go index 19ae861eb4..c05e0a90ed 100644 --- a/protoc-gen-gogo/testdata/imports/test_import_all.pb.go +++ b/protoc-gen-gogo/testdata/imports/test_import_all.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type All struct { Am1 *test_a_1.M1 `protobuf:"bytes,1,opt,name=am1,proto3" json:"am1,omitempty"` diff --git a/protoc-gen-gogo/testdata/my_test/test.pb.go b/protoc-gen-gogo/testdata/my_test/test.pb.go index a978e8261a..a89abd4e94 100644 --- a/protoc-gen-gogo/testdata/my_test/test.pb.go +++ b/protoc-gen-gogo/testdata/my_test/test.pb.go @@ -21,7 +21,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type HatType int32 @@ -868,9 +868,9 @@ func (m *Communique) GetSomegroup() *Communique_SomeGroup { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*Communique) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _Communique_OneofMarshaler, _Communique_OneofUnmarshaler, _Communique_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Communique) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*Communique_Number)(nil), (*Communique_Name)(nil), (*Communique_Data)(nil), @@ -884,182 +884,6 @@ func (*Communique) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) er } } -func _Communique_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*Communique) - // union - switch x := m.Union.(type) { - case *Communique_Number: - _ = b.EncodeVarint(5<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Number)) - case *Communique_Name: - _ = b.EncodeVarint(6<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Name) - case *Communique_Data: - _ = b.EncodeVarint(7<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Data) - case *Communique_TempC: - _ = b.EncodeVarint(8<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.TempC)) - case *Communique_Height: - _ = b.EncodeVarint(9<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.Height))) - case *Communique_Today: - _ = b.EncodeVarint(10<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Today)) - case *Communique_Maybe: - t := uint64(0) - if x.Maybe { - t = 1 - } - _ = b.EncodeVarint(11<<3 | proto.WireVarint) - _ = b.EncodeVarint(t) - case *Communique_Delta_: - _ = b.EncodeVarint(12<<3 | proto.WireVarint) - _ = b.EncodeZigzag32(uint64(x.Delta)) - case *Communique_Msg: - _ = b.EncodeVarint(16<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.Msg); err != nil { - return err - } - case *Communique_Somegroup: - _ = b.EncodeVarint(14<<3 | proto.WireStartGroup) - if err := b.Marshal(x.Somegroup); err != nil { - return err - } - _ = b.EncodeVarint(14<<3 | proto.WireEndGroup) - case nil: - default: - return fmt.Errorf("Communique.Union has unexpected type %T", x) - } - return nil -} - -func _Communique_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*Communique) - switch tag { - case 5: // union.number - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &Communique_Number{int32(x)} - return true, err - case 6: // union.name - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Union = &Communique_Name{x} - return true, err - case 7: // union.data - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.Union = &Communique_Data{x} - return true, err - case 8: // union.temp_c - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.Union = &Communique_TempC{math.Float64frombits(x)} - return true, err - case 9: // union.height - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.Union = &Communique_Height{math.Float32frombits(uint32(x))} - return true, err - case 10: // union.today - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &Communique_Today{Days(x)} - return true, err - case 11: // union.maybe - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &Communique_Maybe{x != 0} - return true, err - case 12: // union.delta - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag32() - m.Union = &Communique_Delta_{int32(x)} - return true, err - case 16: // union.msg - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Reply) - err := b.DecodeMessage(msg) - m.Union = &Communique_Msg{msg} - return true, err - case 14: // union.somegroup - if wire != proto.WireStartGroup { - return true, proto.ErrInternalBadWireType - } - msg := new(Communique_SomeGroup) - err := b.DecodeGroup(msg) - m.Union = &Communique_Somegroup{msg} - return true, err - default: - return false, nil - } -} - -func _Communique_OneofSizer(msg proto.Message) (n int) { - m := msg.(*Communique) - // union - switch x := m.Union.(type) { - case *Communique_Number: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Number)) - case *Communique_Name: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Name))) - n += len(x.Name) - case *Communique_Data: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Data))) - n += len(x.Data) - case *Communique_TempC: - n += 1 // tag and wire - n += 8 - case *Communique_Height: - n += 1 // tag and wire - n += 4 - case *Communique_Today: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Today)) - case *Communique_Maybe: - n += 1 // tag and wire - n += 1 - case *Communique_Delta_: - n += 1 // tag and wire - n += proto.SizeVarint(uint64((uint32(x.Delta) << 1) ^ uint32((int32(x.Delta) >> 31)))) - case *Communique_Msg: - s := proto.Size(x.Msg) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *Communique_Somegroup: - n += 1 // tag and wire - n += proto.Size(x.Somegroup) - n += 1 // tag and wire - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type Communique_SomeGroup struct { Member *string `protobuf:"bytes,15,opt,name=member" json:"member,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/protoc-gen-gogo/testdata/proto3/proto3.pb.go b/protoc-gen-gogo/testdata/proto3/proto3.pb.go index a22c8d959d..923678f142 100644 --- a/protoc-gen-gogo/testdata/proto3/proto3.pb.go +++ b/protoc-gen-gogo/testdata/proto3/proto3.pb.go @@ -18,7 +18,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Request_Flavour int32 diff --git a/test/asymetric-issue125/asym.pb.go b/test/asymetric-issue125/asym.pb.go index 5cfa6df138..22fef6aee1 100644 --- a/test/asymetric-issue125/asym.pb.go +++ b/test/asymetric-issue125/asym.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type M struct { Arr []MyType `protobuf:"bytes,1,rep,name=arr,customtype=MyType" json:"arr"` diff --git a/test/cachedsize/cachedsize.pb.go b/test/cachedsize/cachedsize.pb.go index 64bdf754b1..ad301e328e 100644 --- a/test/cachedsize/cachedsize.pb.go +++ b/test/cachedsize/cachedsize.pb.go @@ -21,7 +21,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Foo struct { Field1 *Bar `protobuf:"bytes,1,opt,name=field1" json:"field1,omitempty"` diff --git a/test/casttype/combos/both/casttype.pb.go b/test/casttype/combos/both/casttype.pb.go index d41fa4f744..a998e58240 100644 --- a/test/casttype/combos/both/casttype.pb.go +++ b/test/casttype/combos/both/casttype.pb.go @@ -31,7 +31,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Castaway struct { Int32Ptr *int32 `protobuf:"varint,1,opt,name=Int32Ptr,casttype=int32" json:"Int32Ptr,omitempty"` diff --git a/test/casttype/combos/marshaler/casttype.pb.go b/test/casttype/combos/marshaler/casttype.pb.go index 1b96e1afdb..71c0990af9 100644 --- a/test/casttype/combos/marshaler/casttype.pb.go +++ b/test/casttype/combos/marshaler/casttype.pb.go @@ -30,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Castaway struct { Int32Ptr *int32 `protobuf:"varint,1,opt,name=Int32Ptr,casttype=int32" json:"Int32Ptr,omitempty"` diff --git a/test/casttype/combos/neither/casttype.pb.go b/test/casttype/combos/neither/casttype.pb.go index 897ae9df10..52097defd4 100644 --- a/test/casttype/combos/neither/casttype.pb.go +++ b/test/casttype/combos/neither/casttype.pb.go @@ -29,7 +29,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Castaway struct { Int32Ptr *int32 `protobuf:"varint,1,opt,name=Int32Ptr,casttype=int32" json:"Int32Ptr,omitempty"` diff --git a/test/casttype/combos/unmarshaler/casttype.pb.go b/test/casttype/combos/unmarshaler/casttype.pb.go index d6f0f942e2..b5724c4979 100644 --- a/test/casttype/combos/unmarshaler/casttype.pb.go +++ b/test/casttype/combos/unmarshaler/casttype.pb.go @@ -31,7 +31,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Castaway struct { Int32Ptr *int32 `protobuf:"varint,1,opt,name=Int32Ptr,casttype=int32" json:"Int32Ptr,omitempty"` diff --git a/test/castvalue/castvalue.pb.go b/test/castvalue/castvalue.pb.go index 089f0ac050..b5706b9b03 100644 --- a/test/castvalue/castvalue.pb.go +++ b/test/castvalue/castvalue.pb.go @@ -28,7 +28,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Castaway struct { CastMapValueMessage map[int32]MyWilson `protobuf:"bytes,1,rep,name=CastMapValueMessage,castvalue=MyWilson,castvaluetype=castvalue.Wilson" json:"CastMapValueMessage" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` diff --git a/test/castvalue/combos/both/castvalue.pb.go b/test/castvalue/combos/both/castvalue.pb.go index 60768bb2e4..e1761bc2fd 100644 --- a/test/castvalue/combos/both/castvalue.pb.go +++ b/test/castvalue/combos/both/castvalue.pb.go @@ -29,7 +29,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Castaway struct { CastMapValueMessage map[int32]MyWilson `protobuf:"bytes,1,rep,name=CastMapValueMessage,castvalue=MyWilson,castvaluetype=castvalue.Wilson" json:"CastMapValueMessage" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` diff --git a/test/castvalue/combos/marshaler/castvalue.pb.go b/test/castvalue/combos/marshaler/castvalue.pb.go index f8a7688987..65c2003fb9 100644 --- a/test/castvalue/combos/marshaler/castvalue.pb.go +++ b/test/castvalue/combos/marshaler/castvalue.pb.go @@ -28,7 +28,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Castaway struct { CastMapValueMessage map[int32]MyWilson `protobuf:"bytes,1,rep,name=CastMapValueMessage,castvalue=MyWilson,castvaluetype=castvalue.Wilson" json:"CastMapValueMessage" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` diff --git a/test/castvalue/combos/unmarshaler/castvalue.pb.go b/test/castvalue/combos/unmarshaler/castvalue.pb.go index 7b69621606..c780e1b181 100644 --- a/test/castvalue/combos/unmarshaler/castvalue.pb.go +++ b/test/castvalue/combos/unmarshaler/castvalue.pb.go @@ -29,7 +29,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Castaway struct { CastMapValueMessage map[int32]MyWilson `protobuf:"bytes,1,rep,name=CastMapValueMessage,castvalue=MyWilson,castvaluetype=castvalue.Wilson" json:"CastMapValueMessage" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` diff --git a/test/combos/both/thetest.pb.go b/test/combos/both/thetest.pb.go index fc37f5bc54..08b25b5387 100644 --- a/test/combos/both/thetest.pb.go +++ b/test/combos/both/thetest.pb.go @@ -34,7 +34,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TheTestEnum int32 diff --git a/test/combos/marshaler/thetest.pb.go b/test/combos/marshaler/thetest.pb.go index 13dcf05361..ee2a83afa5 100644 --- a/test/combos/marshaler/thetest.pb.go +++ b/test/combos/marshaler/thetest.pb.go @@ -33,7 +33,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TheTestEnum int32 diff --git a/test/combos/unmarshaler/thetest.pb.go b/test/combos/unmarshaler/thetest.pb.go index 152f7dc2a6..cc6ebc9058 100644 --- a/test/combos/unmarshaler/thetest.pb.go +++ b/test/combos/unmarshaler/thetest.pb.go @@ -34,7 +34,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TheTestEnum int32 diff --git a/test/custombytesnonstruct/proto.pb.go b/test/custombytesnonstruct/proto.pb.go index dd54375b92..a643593b86 100644 --- a/test/custombytesnonstruct/proto.pb.go +++ b/test/custombytesnonstruct/proto.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Object struct { CustomField1 *CustomType `protobuf:"bytes,1,opt,name=CustomField1,customtype=CustomType" json:"CustomField1,omitempty"` diff --git a/test/data/data.pb.go b/test/data/data.pb.go index a8ce5838a0..8935639179 100644 --- a/test/data/data.pb.go +++ b/test/data/data.pb.go @@ -24,7 +24,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MyMessage struct { MyData uint32 `protobuf:"varint,1,opt,name=my_data,json=myData,proto3" json:"my_data,omitempty"` diff --git a/test/deterministic/deterministic.pb.go b/test/deterministic/deterministic.pb.go index 54872ad8f9..8416bf534e 100644 --- a/test/deterministic/deterministic.pb.go +++ b/test/deterministic/deterministic.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type OrderedMap struct { StringMap map[string]string `protobuf:"bytes,1,rep,name=StringMap,proto3" json:"StringMap,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` diff --git a/test/empty-issue70/empty.pb.go b/test/empty-issue70/empty.pb.go index 948f16bf40..d6cc771ecd 100644 --- a/test/empty-issue70/empty.pb.go +++ b/test/empty-issue70/empty.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TestRequest struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/test/enumcustomname/enumcustomname.pb.go b/test/enumcustomname/enumcustomname.pb.go index 1c3330f1e8..a9c76f7b3e 100644 --- a/test/enumcustomname/enumcustomname.pb.go +++ b/test/enumcustomname/enumcustomname.pb.go @@ -24,7 +24,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MyCustomEnum int32 diff --git a/test/enumdecl/enumdecl.pb.go b/test/enumdecl/enumdecl.pb.go index 6a5845048e..f762751eb2 100644 --- a/test/enumdecl/enumdecl.pb.go +++ b/test/enumdecl/enumdecl.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package var MyEnum_name = map[int32]string{ 0: "A", diff --git a/test/enumdecl_all/enumdeclall.pb.go b/test/enumdecl_all/enumdeclall.pb.go index 905c190eae..2f0979a6a0 100644 --- a/test/enumdecl_all/enumdeclall.pb.go +++ b/test/enumdecl_all/enumdeclall.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package var MyEnum_name = map[int32]string{ 0: "A", diff --git a/test/enumprefix/enumprefix.pb.go b/test/enumprefix/enumprefix.pb.go index 7361d7d38c..7c58aac5b1 100644 --- a/test/enumprefix/enumprefix.pb.go +++ b/test/enumprefix/enumprefix.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MyMessage struct { TheField test.TheTestEnum `protobuf:"varint,1,opt,name=TheField,enum=test.TheTestEnum" json:"TheField"` diff --git a/test/enumstringer/enumstringer.pb.go b/test/enumstringer/enumstringer.pb.go index 7f0b323208..841176d06b 100644 --- a/test/enumstringer/enumstringer.pb.go +++ b/test/enumstringer/enumstringer.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TheTestEnum int32 diff --git a/test/example/example.pb.go b/test/example/example.pb.go index f3dc8936fe..e23f67a638 100644 --- a/test/example/example.pb.go +++ b/test/example/example.pb.go @@ -30,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type A struct { Description string `protobuf:"bytes,1,opt,name=Description" json:"Description"` diff --git a/test/filedotname/file.dot.pb.go b/test/filedotname/file.dot.pb.go index c5f4f1b031..dfd2fa58b8 100644 --- a/test/filedotname/file.dot.pb.go +++ b/test/filedotname/file.dot.pb.go @@ -27,7 +27,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type M struct { A *string `protobuf:"bytes,1,opt,name=a" json:"a,omitempty"` diff --git a/test/fuzztests/fuzz.pb.go b/test/fuzztests/fuzz.pb.go index f06cce8344..d9f66affc6 100644 --- a/test/fuzztests/fuzz.pb.go +++ b/test/fuzztests/fuzz.pb.go @@ -24,7 +24,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Nil struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/test/group/group.pb.go b/test/group/group.pb.go index 6f6fa8aec0..61605aba38 100644 --- a/test/group/group.pb.go +++ b/test/group/group.pb.go @@ -26,7 +26,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Groups1 struct { G []*Groups1_G `protobuf:"group,1,rep,name=G,json=g" json:"g,omitempty"` diff --git a/test/importcustom-issue389/imported/a.pb.go b/test/importcustom-issue389/imported/a.pb.go index 5a426f5a30..f8bfb01a6e 100644 --- a/test/importcustom-issue389/imported/a.pb.go +++ b/test/importcustom-issue389/imported/a.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type A struct { F1 string `protobuf:"bytes,1,opt,name=f1,proto3" json:"f1,omitempty"` diff --git a/test/importcustom-issue389/importing/c.pb.go b/test/importcustom-issue389/importing/c.pb.go index 3398b1b028..fe6b0d29d6 100644 --- a/test/importcustom-issue389/importing/c.pb.go +++ b/test/importcustom-issue389/importing/c.pb.go @@ -24,7 +24,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type C struct { F2 *github_com_gogo_protobuf_test_importcustom_issue389_imported.B `protobuf:"bytes,1,opt,name=f2,proto3,customtype=github.com/gogo/protobuf/test/importcustom-issue389/imported.B" json:"f2,omitempty"` diff --git a/test/importdedup/proto.pb.go b/test/importdedup/proto.pb.go index 229c2a2690..592cc20a6e 100644 --- a/test/importdedup/proto.pb.go +++ b/test/importdedup/proto.pb.go @@ -21,7 +21,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Object struct { CustomField *github_com_gogo_protobuf_test_importdedup_subpkg.CustomType `protobuf:"bytes,1,opt,name=CustomField,customtype=github.com/gogo/protobuf/test/importdedup/subpkg.CustomType" json:"CustomField,omitempty"` diff --git a/test/importdedup/subpkg/subproto.pb.go b/test/importdedup/subpkg/subproto.pb.go index 6d1e775df9..e2bb8f7156 100644 --- a/test/importdedup/subpkg/subproto.pb.go +++ b/test/importdedup/subpkg/subproto.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type SubObject struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/test/importduplicate/importduplicate.pb.go b/test/importduplicate/importduplicate.pb.go index 4d82e58091..dd09d282cb 100644 --- a/test/importduplicate/importduplicate.pb.go +++ b/test/importduplicate/importduplicate.pb.go @@ -25,7 +25,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapAndSortKeys struct { Key *sortkeys.Object `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` diff --git a/test/importduplicate/proto/proto.pb.go b/test/importduplicate/proto/proto.pb.go index 9e90377af7..81203d227c 100644 --- a/test/importduplicate/proto/proto.pb.go +++ b/test/importduplicate/proto/proto.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Subject struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/test/importduplicate/sortkeys/sortable.pb.go b/test/importduplicate/sortkeys/sortable.pb.go index 1d1b48b464..2de4e0fdb1 100644 --- a/test/importduplicate/sortkeys/sortable.pb.go +++ b/test/importduplicate/sortkeys/sortable.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Object struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` diff --git a/test/indeximport-issue72/index/index.pb.go b/test/indeximport-issue72/index/index.pb.go index 217add2ff7..e3d3f01ca9 100644 --- a/test/indeximport-issue72/index/index.pb.go +++ b/test/indeximport-issue72/index/index.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type IndexQuery struct { Key *string `protobuf:"bytes,1,opt,name=Key" json:"Key,omitempty"` diff --git a/test/indeximport-issue72/indeximport.pb.go b/test/indeximport-issue72/indeximport.pb.go index b1c567934a..9083cb8976 100644 --- a/test/indeximport-issue72/indeximport.pb.go +++ b/test/indeximport-issue72/indeximport.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type IndexQueries struct { Queries []*index.IndexQuery `protobuf:"bytes,1,rep,name=Queries" json:"Queries,omitempty"` diff --git a/test/int64support/object.pb.go b/test/int64support/object.pb.go index 1fb9b264ed..9c80f6f139 100644 --- a/test/int64support/object.pb.go +++ b/test/int64support/object.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Object struct { OptionalNumber *int64 `protobuf:"varint,1,opt,name=optional_number,json=optionalNumber" json:"optional_number,omitempty"` diff --git a/test/issue260/issue260.pb.go b/test/issue260/issue260.pb.go index 023064cabd..891dadf753 100644 --- a/test/issue260/issue260.pb.go +++ b/test/issue260/issue260.pb.go @@ -25,7 +25,7 @@ var _ = time.Kitchen // 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package func (m *Dropped) Reset() { *m = Dropped{} } func (m *Dropped) String() string { return proto.CompactTextString(m) } diff --git a/test/issue261/issue261.pb.go b/test/issue261/issue261.pb.go index ccc9764eb2..38becbc0d8 100644 --- a/test/issue261/issue261.pb.go +++ b/test/issue261/issue261.pb.go @@ -28,7 +28,7 @@ var _ = time.Kitchen // 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapStdTypes struct { NullableDuration map[int32]*time.Duration `protobuf:"bytes,3,rep,name=nullableDuration,proto3,stdduration" json:"nullableDuration,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` diff --git a/test/issue262/timefail.pb.go b/test/issue262/timefail.pb.go index bfbb903b28..4abf3ff160 100644 --- a/test/issue262/timefail.pb.go +++ b/test/issue262/timefail.pb.go @@ -27,7 +27,7 @@ var _ = time.Kitchen // 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TimeFail struct { TimeTest *time.Time `protobuf:"bytes,1,opt,name=time_test,json=timeTest,proto3,stdtime" json:"time_test,omitempty"` diff --git a/test/issue312/events/events.pb.go b/test/issue312/events/events.pb.go index 67bfde8777..4471c26b94 100644 --- a/test/issue312/events/events.pb.go +++ b/test/issue312/events/events.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Subtype struct { State *issue312.TaskState `protobuf:"varint,4,opt,name=state,enum=issue312.TaskState" json:"state,omitempty"` diff --git a/test/issue312/issue312.pb.go b/test/issue312/issue312.pb.go index b8673d907a..ed4e38a78a 100644 --- a/test/issue312/issue312.pb.go +++ b/test/issue312/issue312.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TaskState int32 diff --git a/test/issue322/issue322.pb.go b/test/issue322/issue322.pb.go index 3ee5363314..76b3d48999 100644 --- a/test/issue322/issue322.pb.go +++ b/test/issue322/issue322.pb.go @@ -24,7 +24,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type OneofTest struct { // Types that are valid to be assigned to Union: @@ -98,56 +98,13 @@ func (m *OneofTest) GetI() int32 { return Default_OneofTest_I } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*OneofTest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _OneofTest_OneofMarshaler, _OneofTest_OneofUnmarshaler, _OneofTest_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*OneofTest) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*OneofTest_I)(nil), } } -func _OneofTest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*OneofTest) - // union - switch x := m.Union.(type) { - case *OneofTest_I: - _ = b.EncodeVarint(1<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.I)) - case nil: - default: - return fmt.Errorf("OneofTest.Union has unexpected type %T", x) - } - return nil -} - -func _OneofTest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*OneofTest) - switch tag { - case 1: // union.i - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Union = &OneofTest_I{int32(x)} - return true, err - default: - return false, nil - } -} - -func _OneofTest_OneofSizer(msg proto.Message) (n int) { - m := msg.(*OneofTest) - // union - switch x := m.Union.(type) { - case *OneofTest_I: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.I)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*OneofTest)(nil), "test.OneofTest") } diff --git a/test/issue330/issue330.pb.go b/test/issue330/issue330.pb.go index 05b279b71d..9114fafc3a 100644 --- a/test/issue330/issue330.pb.go +++ b/test/issue330/issue330.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Object struct { Type TypeIdentifier `protobuf:"varint,1,opt,name=type,proto3,casttype=TypeIdentifier" json:"type,omitempty"` diff --git a/test/issue34/proto.pb.go b/test/issue34/proto.pb.go index 77f71542ef..57571fa25a 100644 --- a/test/issue34/proto.pb.go +++ b/test/issue34/proto.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Foo struct { Bar []byte `protobuf:"bytes,1,opt,name=bar" json:"bar,omitempty"` diff --git a/test/issue411/issue411.pb.go b/test/issue411/issue411.pb.go index 19657bc07f..e3fc1bd804 100644 --- a/test/issue411/issue411.pb.go +++ b/test/issue411/issue411.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Span struct { TraceID TraceID `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3,customtype=TraceID" json:"trace_id"` diff --git a/test/issue42order/issue42.pb.go b/test/issue42order/issue42.pb.go index 3db27bf120..eef6d5384b 100644 --- a/test/issue42order/issue42.pb.go +++ b/test/issue42order/issue42.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type UnorderedFields struct { A *int64 `protobuf:"varint,10,opt,name=A" json:"A,omitempty"` diff --git a/test/issue435/issue435.pb.go b/test/issue435/issue435.pb.go index 4d3c7f3e62..9077c371ba 100644 --- a/test/issue435/issue435.pb.go +++ b/test/issue435/issue435.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Message struct { NonnullableOptional SubMessage `protobuf:"bytes,1,opt,name=nonnullable_optional,json=nonnullableOptional" json:"nonnullable_optional"` diff --git a/test/issue438/issue438.pb.go b/test/issue438/issue438.pb.go index c3af353292..65ac7869f6 100644 --- a/test/issue438/issue438.pb.go +++ b/test/issue438/issue438.pb.go @@ -21,7 +21,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Types struct { Any *types.Any `protobuf:"bytes,1,opt,name=any,proto3" json:"any,omitempty"` diff --git a/test/issue444/issue444.pb.go b/test/issue444/issue444.pb.go index 1f9fe30075..c15a50774b 100644 --- a/test/issue444/issue444.pb.go +++ b/test/issue444/issue444.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type SizeMe struct { Foo string `protobuf:"bytes,1,opt,name=foo,proto3" json:"foo,omitempty"` diff --git a/test/issue449/issue449.pb.go b/test/issue449/issue449.pb.go index 7fb27eb468..60b8cd3bd0 100644 --- a/test/issue449/issue449.pb.go +++ b/test/issue449/issue449.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type CodeGenMsg struct { Int64ReqPtr *int64 `protobuf:"varint,1,req,name=Int64ReqPtr" json:"Int64ReqPtr,omitempty"` diff --git a/test/issue498/issue498.pb.go b/test/issue498/issue498.pb.go index 161cf77d01..2a1d170b84 100644 --- a/test/issue498/issue498.pb.go +++ b/test/issue498/issue498.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Message struct { Uint8 *uint8 `protobuf:"varint,1,req,name=uint8,casttype=uint8" json:"uint8,omitempty"` diff --git a/test/issue503/issue503.pb.go b/test/issue503/issue503.pb.go index f91119739c..c7cdc8ccf9 100644 --- a/test/issue503/issue503.pb.go +++ b/test/issue503/issue503.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Foo struct { Num1 []int64 `protobuf:"varint,1,rep,packed,name=num1,proto3" json:"num1,omitempty"` diff --git a/test/issue530/issue530.pb.go b/test/issue530/issue530.pb.go index 4147398428..ba07be2eed 100644 --- a/test/issue530/issue530.pb.go +++ b/test/issue530/issue530.pb.go @@ -24,7 +24,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Foo5 struct { Bar1 Bar1 `protobuf:"bytes,1,opt,name=bar1" json:"bar1"` diff --git a/test/issue8/proto.pb.go b/test/issue8/proto.pb.go index 457a3ef2a9..f615e60e05 100644 --- a/test/issue8/proto.pb.go +++ b/test/issue8/proto.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Foo struct { Bar *uint64 `protobuf:"varint,1,req,name=bar" json:"bar,omitempty"` diff --git a/test/mapdefaults/combos/both/map.pb.go b/test/mapdefaults/combos/both/map.pb.go index 71319a6af6..713e34af36 100644 --- a/test/mapdefaults/combos/both/map.pb.go +++ b/test/mapdefaults/combos/both/map.pb.go @@ -29,7 +29,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapTest struct { StrStr map[string]string `protobuf:"bytes,1,rep,name=str_str,json=strStr,proto3" json:"str_str,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` diff --git a/test/mapdefaults/combos/marshaler/map.pb.go b/test/mapdefaults/combos/marshaler/map.pb.go index 8114ed35ed..0f2329b5d8 100644 --- a/test/mapdefaults/combos/marshaler/map.pb.go +++ b/test/mapdefaults/combos/marshaler/map.pb.go @@ -28,7 +28,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapTest struct { StrStr map[string]string `protobuf:"bytes,1,rep,name=str_str,json=strStr,proto3" json:"str_str,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` diff --git a/test/mapdefaults/combos/neither/map.pb.go b/test/mapdefaults/combos/neither/map.pb.go index 1a3921e69f..95566111fd 100644 --- a/test/mapdefaults/combos/neither/map.pb.go +++ b/test/mapdefaults/combos/neither/map.pb.go @@ -28,7 +28,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapTest struct { StrStr map[string]string `protobuf:"bytes,1,rep,name=str_str,json=strStr,proto3" json:"str_str,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` diff --git a/test/mapdefaults/combos/unmarshaler/map.pb.go b/test/mapdefaults/combos/unmarshaler/map.pb.go index 736f338976..c36cc5084e 100644 --- a/test/mapdefaults/combos/unmarshaler/map.pb.go +++ b/test/mapdefaults/combos/unmarshaler/map.pb.go @@ -29,7 +29,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapTest struct { StrStr map[string]string `protobuf:"bytes,1,rep,name=str_str,json=strStr,proto3" json:"str_str,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` diff --git a/test/mapsproto2/combos/both/mapsproto2.pb.go b/test/mapsproto2/combos/both/mapsproto2.pb.go index 3ca8c85484..c8429dfcad 100644 --- a/test/mapsproto2/combos/both/mapsproto2.pb.go +++ b/test/mapsproto2/combos/both/mapsproto2.pb.go @@ -33,7 +33,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapEnum int32 diff --git a/test/mapsproto2/combos/marshaler/mapsproto2.pb.go b/test/mapsproto2/combos/marshaler/mapsproto2.pb.go index 351ad2dfda..385035b470 100644 --- a/test/mapsproto2/combos/marshaler/mapsproto2.pb.go +++ b/test/mapsproto2/combos/marshaler/mapsproto2.pb.go @@ -32,7 +32,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapEnum int32 diff --git a/test/mapsproto2/combos/neither/mapsproto2.pb.go b/test/mapsproto2/combos/neither/mapsproto2.pb.go index 1b43c72fa7..f607fb21fc 100644 --- a/test/mapsproto2/combos/neither/mapsproto2.pb.go +++ b/test/mapsproto2/combos/neither/mapsproto2.pb.go @@ -31,7 +31,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapEnum int32 diff --git a/test/mapsproto2/combos/unmarshaler/mapsproto2.pb.go b/test/mapsproto2/combos/unmarshaler/mapsproto2.pb.go index 5d5b054a09..db2c8f832a 100644 --- a/test/mapsproto2/combos/unmarshaler/mapsproto2.pb.go +++ b/test/mapsproto2/combos/unmarshaler/mapsproto2.pb.go @@ -33,7 +33,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapEnum int32 diff --git a/test/merge/merge.pb.go b/test/merge/merge.pb.go index 21b5ae3bee..97234f653c 100644 --- a/test/merge/merge.pb.go +++ b/test/merge/merge.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type A struct { B B `protobuf:"bytes,1,opt,name=B,proto3" json:"B"` diff --git a/test/moredefaults/md.pb.go b/test/moredefaults/md.pb.go index 0c31e2bf95..59adfb9a7c 100644 --- a/test/moredefaults/md.pb.go +++ b/test/moredefaults/md.pb.go @@ -21,7 +21,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MoreDefaultsB struct { Field1 *string `protobuf:"bytes,1,opt,name=Field1" json:"Field1,omitempty"` diff --git a/test/nopackage/nopackage.pb.go b/test/nopackage/nopackage.pb.go index db525675a3..769fb0a81e 100644 --- a/test/nopackage/nopackage.pb.go +++ b/test/nopackage/nopackage.pb.go @@ -21,7 +21,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type M struct { F map[string]float64 `protobuf:"bytes,1,rep,name=f,proto3" json:"f,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"fixed64,2,opt,name=value,proto3"` diff --git a/test/oneof/combos/both/one.pb.go b/test/oneof/combos/both/one.pb.go index 5133662173..3dc71f9efa 100644 --- a/test/oneof/combos/both/one.pb.go +++ b/test/oneof/combos/both/one.pb.go @@ -31,7 +31,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Subby struct { Sub *string `protobuf:"bytes,1,opt,name=sub" json:"sub,omitempty"` @@ -322,9 +322,9 @@ func (m *AllTypesOneOf) GetSubMessage() *Subby { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*AllTypesOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _AllTypesOneOf_OneofMarshaler, _AllTypesOneOf_OneofUnmarshaler, _AllTypesOneOf_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*AllTypesOneOf) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*AllTypesOneOf_Field1)(nil), (*AllTypesOneOf_Field2)(nil), (*AllTypesOneOf_Field3)(nil), @@ -344,255 +344,6 @@ func (*AllTypesOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) } } -func _AllTypesOneOf_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*AllTypesOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *AllTypesOneOf_Field1: - _ = b.EncodeVarint(1<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.Field1)) - case *AllTypesOneOf_Field2: - _ = b.EncodeVarint(2<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.Field2))) - case *AllTypesOneOf_Field3: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field3)) - case *AllTypesOneOf_Field4: - _ = b.EncodeVarint(4<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field4)) - case *AllTypesOneOf_Field5: - _ = b.EncodeVarint(5<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field5)) - case *AllTypesOneOf_Field6: - _ = b.EncodeVarint(6<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field6)) - case *AllTypesOneOf_Field7: - _ = b.EncodeVarint(7<<3 | proto.WireVarint) - _ = b.EncodeZigzag32(uint64(x.Field7)) - case *AllTypesOneOf_Field8: - _ = b.EncodeVarint(8<<3 | proto.WireVarint) - _ = b.EncodeZigzag64(uint64(x.Field8)) - case *AllTypesOneOf_Field9: - _ = b.EncodeVarint(9<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field9)) - case *AllTypesOneOf_Field10: - _ = b.EncodeVarint(10<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field10)) - case *AllTypesOneOf_Field11: - _ = b.EncodeVarint(11<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field11)) - case *AllTypesOneOf_Field12: - _ = b.EncodeVarint(12<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field12)) - case *AllTypesOneOf_Field13: - t := uint64(0) - if x.Field13 { - t = 1 - } - _ = b.EncodeVarint(13<<3 | proto.WireVarint) - _ = b.EncodeVarint(t) - case *AllTypesOneOf_Field14: - _ = b.EncodeVarint(14<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field14) - case *AllTypesOneOf_Field15: - _ = b.EncodeVarint(15<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Field15) - case *AllTypesOneOf_SubMessage: - _ = b.EncodeVarint(16<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.SubMessage); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("AllTypesOneOf.TestOneof has unexpected type %T", x) - } - return nil -} - -func _AllTypesOneOf_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*AllTypesOneOf) - switch tag { - case 1: // test_oneof.Field1 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &AllTypesOneOf_Field1{math.Float64frombits(x)} - return true, err - case 2: // test_oneof.Field2 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &AllTypesOneOf_Field2{math.Float32frombits(uint32(x))} - return true, err - case 3: // test_oneof.Field3 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field3{int32(x)} - return true, err - case 4: // test_oneof.Field4 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field4{int64(x)} - return true, err - case 5: // test_oneof.Field5 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field5{uint32(x)} - return true, err - case 6: // test_oneof.Field6 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field6{x} - return true, err - case 7: // test_oneof.Field7 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag32() - m.TestOneof = &AllTypesOneOf_Field7{int32(x)} - return true, err - case 8: // test_oneof.Field8 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag64() - m.TestOneof = &AllTypesOneOf_Field8{int64(x)} - return true, err - case 9: // test_oneof.Field9 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &AllTypesOneOf_Field9{uint32(x)} - return true, err - case 10: // test_oneof.Field10 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &AllTypesOneOf_Field10{int32(x)} - return true, err - case 11: // test_oneof.Field11 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &AllTypesOneOf_Field11{x} - return true, err - case 12: // test_oneof.Field12 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &AllTypesOneOf_Field12{int64(x)} - return true, err - case 13: // test_oneof.Field13 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field13{x != 0} - return true, err - case 14: // test_oneof.Field14 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.TestOneof = &AllTypesOneOf_Field14{x} - return true, err - case 15: // test_oneof.Field15 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.TestOneof = &AllTypesOneOf_Field15{x} - return true, err - case 16: // test_oneof.sub_message - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Subby) - err := b.DecodeMessage(msg) - m.TestOneof = &AllTypesOneOf_SubMessage{msg} - return true, err - default: - return false, nil - } -} - -func _AllTypesOneOf_OneofSizer(msg proto.Message) (n int) { - m := msg.(*AllTypesOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *AllTypesOneOf_Field1: - n += 1 // tag and wire - n += 8 - case *AllTypesOneOf_Field2: - n += 1 // tag and wire - n += 4 - case *AllTypesOneOf_Field3: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field3)) - case *AllTypesOneOf_Field4: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field4)) - case *AllTypesOneOf_Field5: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field5)) - case *AllTypesOneOf_Field6: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field6)) - case *AllTypesOneOf_Field7: - n += 1 // tag and wire - n += proto.SizeVarint(uint64((uint32(x.Field7) << 1) ^ uint32((int32(x.Field7) >> 31)))) - case *AllTypesOneOf_Field8: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(uint64(x.Field8<<1) ^ uint64((int64(x.Field8) >> 63)))) - case *AllTypesOneOf_Field9: - n += 1 // tag and wire - n += 4 - case *AllTypesOneOf_Field10: - n += 1 // tag and wire - n += 4 - case *AllTypesOneOf_Field11: - n += 1 // tag and wire - n += 8 - case *AllTypesOneOf_Field12: - n += 1 // tag and wire - n += 8 - case *AllTypesOneOf_Field13: - n += 1 // tag and wire - n += 1 - case *AllTypesOneOf_Field14: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field14))) - n += len(x.Field14) - case *AllTypesOneOf_Field15: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field15))) - n += len(x.Field15) - case *AllTypesOneOf_SubMessage: - s := proto.Size(x.SubMessage) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type TwoOneofs struct { // Types that are valid to be assigned to One: // *TwoOneofs_Field1 @@ -739,9 +490,9 @@ func (m *TwoOneofs) GetSubMessage2() *Subby { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*TwoOneofs) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _TwoOneofs_OneofMarshaler, _TwoOneofs_OneofUnmarshaler, _TwoOneofs_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*TwoOneofs) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*TwoOneofs_Field1)(nil), (*TwoOneofs_Field2)(nil), (*TwoOneofs_Field3)(nil), @@ -751,133 +502,6 @@ func (*TwoOneofs) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) err } } -func _TwoOneofs_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*TwoOneofs) - // one - switch x := m.One.(type) { - case *TwoOneofs_Field1: - _ = b.EncodeVarint(1<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.Field1)) - case *TwoOneofs_Field2: - _ = b.EncodeVarint(2<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.Field2))) - case *TwoOneofs_Field3: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field3)) - case nil: - default: - return fmt.Errorf("TwoOneofs.One has unexpected type %T", x) - } - // two - switch x := m.Two.(type) { - case *TwoOneofs_Field34: - _ = b.EncodeVarint(34<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field34) - case *TwoOneofs_Field35: - _ = b.EncodeVarint(35<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Field35) - case *TwoOneofs_SubMessage2: - _ = b.EncodeVarint(36<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.SubMessage2); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("TwoOneofs.Two has unexpected type %T", x) - } - return nil -} - -func _TwoOneofs_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*TwoOneofs) - switch tag { - case 1: // one.Field1 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.One = &TwoOneofs_Field1{math.Float64frombits(x)} - return true, err - case 2: // one.Field2 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.One = &TwoOneofs_Field2{math.Float32frombits(uint32(x))} - return true, err - case 3: // one.Field3 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.One = &TwoOneofs_Field3{int32(x)} - return true, err - case 34: // two.Field34 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Two = &TwoOneofs_Field34{x} - return true, err - case 35: // two.Field35 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.Two = &TwoOneofs_Field35{x} - return true, err - case 36: // two.sub_message2 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Subby) - err := b.DecodeMessage(msg) - m.Two = &TwoOneofs_SubMessage2{msg} - return true, err - default: - return false, nil - } -} - -func _TwoOneofs_OneofSizer(msg proto.Message) (n int) { - m := msg.(*TwoOneofs) - // one - switch x := m.One.(type) { - case *TwoOneofs_Field1: - n += 1 // tag and wire - n += 8 - case *TwoOneofs_Field2: - n += 1 // tag and wire - n += 4 - case *TwoOneofs_Field3: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field3)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - // two - switch x := m.Two.(type) { - case *TwoOneofs_Field34: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field34))) - n += len(x.Field34) - case *TwoOneofs_Field35: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field35))) - n += len(x.Field35) - case *TwoOneofs_SubMessage2: - s := proto.Size(x.SubMessage2) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type CustomOneof struct { // Types that are valid to be assigned to Custom: // *CustomOneof_Stringy @@ -977,9 +601,9 @@ func (m *CustomOneof) GetMyCustomName() int64 { return 0 } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*CustomOneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _CustomOneof_OneofMarshaler, _CustomOneof_OneofUnmarshaler, _CustomOneof_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*CustomOneof) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*CustomOneof_Stringy)(nil), (*CustomOneof_CustomType)(nil), (*CustomOneof_CastType)(nil), @@ -987,100 +611,6 @@ func (*CustomOneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) e } } -func _CustomOneof_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*CustomOneof) - // custom - switch x := m.Custom.(type) { - case *CustomOneof_Stringy: - _ = b.EncodeVarint(34<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Stringy) - case *CustomOneof_CustomType: - _ = b.EncodeVarint(35<<3 | proto.WireBytes) - dAtA, err := x.CustomType.Marshal() - if err != nil { - return err - } - _ = b.EncodeRawBytes(dAtA) - case *CustomOneof_CastType: - _ = b.EncodeVarint(36<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.CastType)) - case *CustomOneof_MyCustomName: - _ = b.EncodeVarint(37<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.MyCustomName)) - case nil: - default: - return fmt.Errorf("CustomOneof.Custom has unexpected type %T", x) - } - return nil -} - -func _CustomOneof_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*CustomOneof) - switch tag { - case 34: // custom.Stringy - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Custom = &CustomOneof_Stringy{x} - return true, err - case 35: // custom.CustomType - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - var cc github_com_gogo_protobuf_test_custom.Uint128 - c := &cc - err = c.Unmarshal(x) - m.Custom = &CustomOneof_CustomType{*c} - return true, err - case 36: // custom.CastType - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Custom = &CustomOneof_CastType{github_com_gogo_protobuf_test_casttype.MyUint64Type(x)} - return true, err - case 37: // custom.CustomName - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Custom = &CustomOneof_MyCustomName{int64(x)} - return true, err - default: - return false, nil - } -} - -func _CustomOneof_OneofSizer(msg proto.Message) (n int) { - m := msg.(*CustomOneof) - // custom - switch x := m.Custom.(type) { - case *CustomOneof_Stringy: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.Stringy))) - n += len(x.Stringy) - case *CustomOneof_CustomType: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.CustomType.Size())) - n += x.CustomType.Size() - case *CustomOneof_CastType: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.CastType)) - case *CustomOneof_MyCustomName: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.MyCustomName)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*Subby)(nil), "one.Subby") proto.RegisterType((*AllTypesOneOf)(nil), "one.AllTypesOneOf") diff --git a/test/oneof/combos/marshaler/one.pb.go b/test/oneof/combos/marshaler/one.pb.go index 3e8d274fd9..54e6d5c84a 100644 --- a/test/oneof/combos/marshaler/one.pb.go +++ b/test/oneof/combos/marshaler/one.pb.go @@ -30,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Subby struct { Sub *string `protobuf:"bytes,1,opt,name=sub" json:"sub,omitempty"` @@ -321,9 +321,9 @@ func (m *AllTypesOneOf) GetSubMessage() *Subby { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*AllTypesOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _AllTypesOneOf_OneofMarshaler, _AllTypesOneOf_OneofUnmarshaler, _AllTypesOneOf_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*AllTypesOneOf) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*AllTypesOneOf_Field1)(nil), (*AllTypesOneOf_Field2)(nil), (*AllTypesOneOf_Field3)(nil), @@ -343,255 +343,6 @@ func (*AllTypesOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) } } -func _AllTypesOneOf_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*AllTypesOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *AllTypesOneOf_Field1: - _ = b.EncodeVarint(1<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.Field1)) - case *AllTypesOneOf_Field2: - _ = b.EncodeVarint(2<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.Field2))) - case *AllTypesOneOf_Field3: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field3)) - case *AllTypesOneOf_Field4: - _ = b.EncodeVarint(4<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field4)) - case *AllTypesOneOf_Field5: - _ = b.EncodeVarint(5<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field5)) - case *AllTypesOneOf_Field6: - _ = b.EncodeVarint(6<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field6)) - case *AllTypesOneOf_Field7: - _ = b.EncodeVarint(7<<3 | proto.WireVarint) - _ = b.EncodeZigzag32(uint64(x.Field7)) - case *AllTypesOneOf_Field8: - _ = b.EncodeVarint(8<<3 | proto.WireVarint) - _ = b.EncodeZigzag64(uint64(x.Field8)) - case *AllTypesOneOf_Field9: - _ = b.EncodeVarint(9<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field9)) - case *AllTypesOneOf_Field10: - _ = b.EncodeVarint(10<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field10)) - case *AllTypesOneOf_Field11: - _ = b.EncodeVarint(11<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field11)) - case *AllTypesOneOf_Field12: - _ = b.EncodeVarint(12<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field12)) - case *AllTypesOneOf_Field13: - t := uint64(0) - if x.Field13 { - t = 1 - } - _ = b.EncodeVarint(13<<3 | proto.WireVarint) - _ = b.EncodeVarint(t) - case *AllTypesOneOf_Field14: - _ = b.EncodeVarint(14<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field14) - case *AllTypesOneOf_Field15: - _ = b.EncodeVarint(15<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Field15) - case *AllTypesOneOf_SubMessage: - _ = b.EncodeVarint(16<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.SubMessage); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("AllTypesOneOf.TestOneof has unexpected type %T", x) - } - return nil -} - -func _AllTypesOneOf_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*AllTypesOneOf) - switch tag { - case 1: // test_oneof.Field1 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &AllTypesOneOf_Field1{math.Float64frombits(x)} - return true, err - case 2: // test_oneof.Field2 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &AllTypesOneOf_Field2{math.Float32frombits(uint32(x))} - return true, err - case 3: // test_oneof.Field3 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field3{int32(x)} - return true, err - case 4: // test_oneof.Field4 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field4{int64(x)} - return true, err - case 5: // test_oneof.Field5 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field5{uint32(x)} - return true, err - case 6: // test_oneof.Field6 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field6{x} - return true, err - case 7: // test_oneof.Field7 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag32() - m.TestOneof = &AllTypesOneOf_Field7{int32(x)} - return true, err - case 8: // test_oneof.Field8 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag64() - m.TestOneof = &AllTypesOneOf_Field8{int64(x)} - return true, err - case 9: // test_oneof.Field9 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &AllTypesOneOf_Field9{uint32(x)} - return true, err - case 10: // test_oneof.Field10 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &AllTypesOneOf_Field10{int32(x)} - return true, err - case 11: // test_oneof.Field11 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &AllTypesOneOf_Field11{x} - return true, err - case 12: // test_oneof.Field12 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &AllTypesOneOf_Field12{int64(x)} - return true, err - case 13: // test_oneof.Field13 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field13{x != 0} - return true, err - case 14: // test_oneof.Field14 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.TestOneof = &AllTypesOneOf_Field14{x} - return true, err - case 15: // test_oneof.Field15 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.TestOneof = &AllTypesOneOf_Field15{x} - return true, err - case 16: // test_oneof.sub_message - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Subby) - err := b.DecodeMessage(msg) - m.TestOneof = &AllTypesOneOf_SubMessage{msg} - return true, err - default: - return false, nil - } -} - -func _AllTypesOneOf_OneofSizer(msg proto.Message) (n int) { - m := msg.(*AllTypesOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *AllTypesOneOf_Field1: - n += 1 // tag and wire - n += 8 - case *AllTypesOneOf_Field2: - n += 1 // tag and wire - n += 4 - case *AllTypesOneOf_Field3: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field3)) - case *AllTypesOneOf_Field4: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field4)) - case *AllTypesOneOf_Field5: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field5)) - case *AllTypesOneOf_Field6: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field6)) - case *AllTypesOneOf_Field7: - n += 1 // tag and wire - n += proto.SizeVarint(uint64((uint32(x.Field7) << 1) ^ uint32((int32(x.Field7) >> 31)))) - case *AllTypesOneOf_Field8: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(uint64(x.Field8<<1) ^ uint64((int64(x.Field8) >> 63)))) - case *AllTypesOneOf_Field9: - n += 1 // tag and wire - n += 4 - case *AllTypesOneOf_Field10: - n += 1 // tag and wire - n += 4 - case *AllTypesOneOf_Field11: - n += 1 // tag and wire - n += 8 - case *AllTypesOneOf_Field12: - n += 1 // tag and wire - n += 8 - case *AllTypesOneOf_Field13: - n += 1 // tag and wire - n += 1 - case *AllTypesOneOf_Field14: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field14))) - n += len(x.Field14) - case *AllTypesOneOf_Field15: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field15))) - n += len(x.Field15) - case *AllTypesOneOf_SubMessage: - s := proto.Size(x.SubMessage) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type TwoOneofs struct { // Types that are valid to be assigned to One: // *TwoOneofs_Field1 @@ -738,9 +489,9 @@ func (m *TwoOneofs) GetSubMessage2() *Subby { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*TwoOneofs) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _TwoOneofs_OneofMarshaler, _TwoOneofs_OneofUnmarshaler, _TwoOneofs_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*TwoOneofs) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*TwoOneofs_Field1)(nil), (*TwoOneofs_Field2)(nil), (*TwoOneofs_Field3)(nil), @@ -750,133 +501,6 @@ func (*TwoOneofs) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) err } } -func _TwoOneofs_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*TwoOneofs) - // one - switch x := m.One.(type) { - case *TwoOneofs_Field1: - _ = b.EncodeVarint(1<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.Field1)) - case *TwoOneofs_Field2: - _ = b.EncodeVarint(2<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.Field2))) - case *TwoOneofs_Field3: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field3)) - case nil: - default: - return fmt.Errorf("TwoOneofs.One has unexpected type %T", x) - } - // two - switch x := m.Two.(type) { - case *TwoOneofs_Field34: - _ = b.EncodeVarint(34<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field34) - case *TwoOneofs_Field35: - _ = b.EncodeVarint(35<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Field35) - case *TwoOneofs_SubMessage2: - _ = b.EncodeVarint(36<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.SubMessage2); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("TwoOneofs.Two has unexpected type %T", x) - } - return nil -} - -func _TwoOneofs_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*TwoOneofs) - switch tag { - case 1: // one.Field1 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.One = &TwoOneofs_Field1{math.Float64frombits(x)} - return true, err - case 2: // one.Field2 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.One = &TwoOneofs_Field2{math.Float32frombits(uint32(x))} - return true, err - case 3: // one.Field3 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.One = &TwoOneofs_Field3{int32(x)} - return true, err - case 34: // two.Field34 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Two = &TwoOneofs_Field34{x} - return true, err - case 35: // two.Field35 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.Two = &TwoOneofs_Field35{x} - return true, err - case 36: // two.sub_message2 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Subby) - err := b.DecodeMessage(msg) - m.Two = &TwoOneofs_SubMessage2{msg} - return true, err - default: - return false, nil - } -} - -func _TwoOneofs_OneofSizer(msg proto.Message) (n int) { - m := msg.(*TwoOneofs) - // one - switch x := m.One.(type) { - case *TwoOneofs_Field1: - n += 1 // tag and wire - n += 8 - case *TwoOneofs_Field2: - n += 1 // tag and wire - n += 4 - case *TwoOneofs_Field3: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field3)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - // two - switch x := m.Two.(type) { - case *TwoOneofs_Field34: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field34))) - n += len(x.Field34) - case *TwoOneofs_Field35: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field35))) - n += len(x.Field35) - case *TwoOneofs_SubMessage2: - s := proto.Size(x.SubMessage2) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type CustomOneof struct { // Types that are valid to be assigned to Custom: // *CustomOneof_Stringy @@ -976,9 +600,9 @@ func (m *CustomOneof) GetMyCustomName() int64 { return 0 } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*CustomOneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _CustomOneof_OneofMarshaler, _CustomOneof_OneofUnmarshaler, _CustomOneof_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*CustomOneof) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*CustomOneof_Stringy)(nil), (*CustomOneof_CustomType)(nil), (*CustomOneof_CastType)(nil), @@ -986,100 +610,6 @@ func (*CustomOneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) e } } -func _CustomOneof_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*CustomOneof) - // custom - switch x := m.Custom.(type) { - case *CustomOneof_Stringy: - _ = b.EncodeVarint(34<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Stringy) - case *CustomOneof_CustomType: - _ = b.EncodeVarint(35<<3 | proto.WireBytes) - dAtA, err := x.CustomType.Marshal() - if err != nil { - return err - } - _ = b.EncodeRawBytes(dAtA) - case *CustomOneof_CastType: - _ = b.EncodeVarint(36<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.CastType)) - case *CustomOneof_MyCustomName: - _ = b.EncodeVarint(37<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.MyCustomName)) - case nil: - default: - return fmt.Errorf("CustomOneof.Custom has unexpected type %T", x) - } - return nil -} - -func _CustomOneof_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*CustomOneof) - switch tag { - case 34: // custom.Stringy - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Custom = &CustomOneof_Stringy{x} - return true, err - case 35: // custom.CustomType - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - var cc github_com_gogo_protobuf_test_custom.Uint128 - c := &cc - err = c.Unmarshal(x) - m.Custom = &CustomOneof_CustomType{*c} - return true, err - case 36: // custom.CastType - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Custom = &CustomOneof_CastType{github_com_gogo_protobuf_test_casttype.MyUint64Type(x)} - return true, err - case 37: // custom.CustomName - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Custom = &CustomOneof_MyCustomName{int64(x)} - return true, err - default: - return false, nil - } -} - -func _CustomOneof_OneofSizer(msg proto.Message) (n int) { - m := msg.(*CustomOneof) - // custom - switch x := m.Custom.(type) { - case *CustomOneof_Stringy: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.Stringy))) - n += len(x.Stringy) - case *CustomOneof_CustomType: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.CustomType.Size())) - n += x.CustomType.Size() - case *CustomOneof_CastType: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.CastType)) - case *CustomOneof_MyCustomName: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.MyCustomName)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*Subby)(nil), "one.Subby") proto.RegisterType((*AllTypesOneOf)(nil), "one.AllTypesOneOf") diff --git a/test/oneof/combos/neither/one.pb.go b/test/oneof/combos/neither/one.pb.go index 8c37e7aecd..9bbbd936f9 100644 --- a/test/oneof/combos/neither/one.pb.go +++ b/test/oneof/combos/neither/one.pb.go @@ -29,7 +29,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Subby struct { Sub *string `protobuf:"bytes,1,opt,name=sub" json:"sub,omitempty"` @@ -301,9 +301,9 @@ func (m *AllTypesOneOf) GetSubMessage() *Subby { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*AllTypesOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _AllTypesOneOf_OneofMarshaler, _AllTypesOneOf_OneofUnmarshaler, _AllTypesOneOf_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*AllTypesOneOf) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*AllTypesOneOf_Field1)(nil), (*AllTypesOneOf_Field2)(nil), (*AllTypesOneOf_Field3)(nil), @@ -323,255 +323,6 @@ func (*AllTypesOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) } } -func _AllTypesOneOf_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*AllTypesOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *AllTypesOneOf_Field1: - _ = b.EncodeVarint(1<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.Field1)) - case *AllTypesOneOf_Field2: - _ = b.EncodeVarint(2<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.Field2))) - case *AllTypesOneOf_Field3: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field3)) - case *AllTypesOneOf_Field4: - _ = b.EncodeVarint(4<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field4)) - case *AllTypesOneOf_Field5: - _ = b.EncodeVarint(5<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field5)) - case *AllTypesOneOf_Field6: - _ = b.EncodeVarint(6<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field6)) - case *AllTypesOneOf_Field7: - _ = b.EncodeVarint(7<<3 | proto.WireVarint) - _ = b.EncodeZigzag32(uint64(x.Field7)) - case *AllTypesOneOf_Field8: - _ = b.EncodeVarint(8<<3 | proto.WireVarint) - _ = b.EncodeZigzag64(uint64(x.Field8)) - case *AllTypesOneOf_Field9: - _ = b.EncodeVarint(9<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field9)) - case *AllTypesOneOf_Field10: - _ = b.EncodeVarint(10<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field10)) - case *AllTypesOneOf_Field11: - _ = b.EncodeVarint(11<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field11)) - case *AllTypesOneOf_Field12: - _ = b.EncodeVarint(12<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field12)) - case *AllTypesOneOf_Field13: - t := uint64(0) - if x.Field13 { - t = 1 - } - _ = b.EncodeVarint(13<<3 | proto.WireVarint) - _ = b.EncodeVarint(t) - case *AllTypesOneOf_Field14: - _ = b.EncodeVarint(14<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field14) - case *AllTypesOneOf_Field15: - _ = b.EncodeVarint(15<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Field15) - case *AllTypesOneOf_SubMessage: - _ = b.EncodeVarint(16<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.SubMessage); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("AllTypesOneOf.TestOneof has unexpected type %T", x) - } - return nil -} - -func _AllTypesOneOf_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*AllTypesOneOf) - switch tag { - case 1: // test_oneof.Field1 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &AllTypesOneOf_Field1{math.Float64frombits(x)} - return true, err - case 2: // test_oneof.Field2 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &AllTypesOneOf_Field2{math.Float32frombits(uint32(x))} - return true, err - case 3: // test_oneof.Field3 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field3{int32(x)} - return true, err - case 4: // test_oneof.Field4 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field4{int64(x)} - return true, err - case 5: // test_oneof.Field5 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field5{uint32(x)} - return true, err - case 6: // test_oneof.Field6 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field6{x} - return true, err - case 7: // test_oneof.Field7 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag32() - m.TestOneof = &AllTypesOneOf_Field7{int32(x)} - return true, err - case 8: // test_oneof.Field8 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag64() - m.TestOneof = &AllTypesOneOf_Field8{int64(x)} - return true, err - case 9: // test_oneof.Field9 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &AllTypesOneOf_Field9{uint32(x)} - return true, err - case 10: // test_oneof.Field10 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &AllTypesOneOf_Field10{int32(x)} - return true, err - case 11: // test_oneof.Field11 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &AllTypesOneOf_Field11{x} - return true, err - case 12: // test_oneof.Field12 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &AllTypesOneOf_Field12{int64(x)} - return true, err - case 13: // test_oneof.Field13 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field13{x != 0} - return true, err - case 14: // test_oneof.Field14 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.TestOneof = &AllTypesOneOf_Field14{x} - return true, err - case 15: // test_oneof.Field15 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.TestOneof = &AllTypesOneOf_Field15{x} - return true, err - case 16: // test_oneof.sub_message - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Subby) - err := b.DecodeMessage(msg) - m.TestOneof = &AllTypesOneOf_SubMessage{msg} - return true, err - default: - return false, nil - } -} - -func _AllTypesOneOf_OneofSizer(msg proto.Message) (n int) { - m := msg.(*AllTypesOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *AllTypesOneOf_Field1: - n += 1 // tag and wire - n += 8 - case *AllTypesOneOf_Field2: - n += 1 // tag and wire - n += 4 - case *AllTypesOneOf_Field3: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field3)) - case *AllTypesOneOf_Field4: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field4)) - case *AllTypesOneOf_Field5: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field5)) - case *AllTypesOneOf_Field6: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field6)) - case *AllTypesOneOf_Field7: - n += 1 // tag and wire - n += proto.SizeVarint(uint64((uint32(x.Field7) << 1) ^ uint32((int32(x.Field7) >> 31)))) - case *AllTypesOneOf_Field8: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(uint64(x.Field8<<1) ^ uint64((int64(x.Field8) >> 63)))) - case *AllTypesOneOf_Field9: - n += 1 // tag and wire - n += 4 - case *AllTypesOneOf_Field10: - n += 1 // tag and wire - n += 4 - case *AllTypesOneOf_Field11: - n += 1 // tag and wire - n += 8 - case *AllTypesOneOf_Field12: - n += 1 // tag and wire - n += 8 - case *AllTypesOneOf_Field13: - n += 1 // tag and wire - n += 1 - case *AllTypesOneOf_Field14: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field14))) - n += len(x.Field14) - case *AllTypesOneOf_Field15: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field15))) - n += len(x.Field15) - case *AllTypesOneOf_SubMessage: - s := proto.Size(x.SubMessage) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type TwoOneofs struct { // Types that are valid to be assigned to One: // *TwoOneofs_Field1 @@ -707,9 +458,9 @@ func (m *TwoOneofs) GetSubMessage2() *Subby { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*TwoOneofs) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _TwoOneofs_OneofMarshaler, _TwoOneofs_OneofUnmarshaler, _TwoOneofs_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*TwoOneofs) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*TwoOneofs_Field1)(nil), (*TwoOneofs_Field2)(nil), (*TwoOneofs_Field3)(nil), @@ -719,133 +470,6 @@ func (*TwoOneofs) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) err } } -func _TwoOneofs_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*TwoOneofs) - // one - switch x := m.One.(type) { - case *TwoOneofs_Field1: - _ = b.EncodeVarint(1<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.Field1)) - case *TwoOneofs_Field2: - _ = b.EncodeVarint(2<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.Field2))) - case *TwoOneofs_Field3: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field3)) - case nil: - default: - return fmt.Errorf("TwoOneofs.One has unexpected type %T", x) - } - // two - switch x := m.Two.(type) { - case *TwoOneofs_Field34: - _ = b.EncodeVarint(34<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field34) - case *TwoOneofs_Field35: - _ = b.EncodeVarint(35<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Field35) - case *TwoOneofs_SubMessage2: - _ = b.EncodeVarint(36<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.SubMessage2); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("TwoOneofs.Two has unexpected type %T", x) - } - return nil -} - -func _TwoOneofs_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*TwoOneofs) - switch tag { - case 1: // one.Field1 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.One = &TwoOneofs_Field1{math.Float64frombits(x)} - return true, err - case 2: // one.Field2 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.One = &TwoOneofs_Field2{math.Float32frombits(uint32(x))} - return true, err - case 3: // one.Field3 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.One = &TwoOneofs_Field3{int32(x)} - return true, err - case 34: // two.Field34 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Two = &TwoOneofs_Field34{x} - return true, err - case 35: // two.Field35 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.Two = &TwoOneofs_Field35{x} - return true, err - case 36: // two.sub_message2 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Subby) - err := b.DecodeMessage(msg) - m.Two = &TwoOneofs_SubMessage2{msg} - return true, err - default: - return false, nil - } -} - -func _TwoOneofs_OneofSizer(msg proto.Message) (n int) { - m := msg.(*TwoOneofs) - // one - switch x := m.One.(type) { - case *TwoOneofs_Field1: - n += 1 // tag and wire - n += 8 - case *TwoOneofs_Field2: - n += 1 // tag and wire - n += 4 - case *TwoOneofs_Field3: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field3)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - // two - switch x := m.Two.(type) { - case *TwoOneofs_Field34: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field34))) - n += len(x.Field34) - case *TwoOneofs_Field35: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field35))) - n += len(x.Field35) - case *TwoOneofs_SubMessage2: - s := proto.Size(x.SubMessage2) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type CustomOneof struct { // Types that are valid to be assigned to Custom: // *CustomOneof_Stringy @@ -935,9 +559,9 @@ func (m *CustomOneof) GetMyCustomName() int64 { return 0 } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*CustomOneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _CustomOneof_OneofMarshaler, _CustomOneof_OneofUnmarshaler, _CustomOneof_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*CustomOneof) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*CustomOneof_Stringy)(nil), (*CustomOneof_CustomType)(nil), (*CustomOneof_CastType)(nil), @@ -945,100 +569,6 @@ func (*CustomOneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) e } } -func _CustomOneof_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*CustomOneof) - // custom - switch x := m.Custom.(type) { - case *CustomOneof_Stringy: - _ = b.EncodeVarint(34<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Stringy) - case *CustomOneof_CustomType: - _ = b.EncodeVarint(35<<3 | proto.WireBytes) - dAtA, err := x.CustomType.Marshal() - if err != nil { - return err - } - _ = b.EncodeRawBytes(dAtA) - case *CustomOneof_CastType: - _ = b.EncodeVarint(36<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.CastType)) - case *CustomOneof_MyCustomName: - _ = b.EncodeVarint(37<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.MyCustomName)) - case nil: - default: - return fmt.Errorf("CustomOneof.Custom has unexpected type %T", x) - } - return nil -} - -func _CustomOneof_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*CustomOneof) - switch tag { - case 34: // custom.Stringy - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Custom = &CustomOneof_Stringy{x} - return true, err - case 35: // custom.CustomType - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - var cc github_com_gogo_protobuf_test_custom.Uint128 - c := &cc - err = c.Unmarshal(x) - m.Custom = &CustomOneof_CustomType{*c} - return true, err - case 36: // custom.CastType - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Custom = &CustomOneof_CastType{github_com_gogo_protobuf_test_casttype.MyUint64Type(x)} - return true, err - case 37: // custom.CustomName - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Custom = &CustomOneof_MyCustomName{int64(x)} - return true, err - default: - return false, nil - } -} - -func _CustomOneof_OneofSizer(msg proto.Message) (n int) { - m := msg.(*CustomOneof) - // custom - switch x := m.Custom.(type) { - case *CustomOneof_Stringy: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.Stringy))) - n += len(x.Stringy) - case *CustomOneof_CustomType: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.CustomType.Size())) - n += x.CustomType.Size() - case *CustomOneof_CastType: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.CastType)) - case *CustomOneof_MyCustomName: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.MyCustomName)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*Subby)(nil), "one.Subby") proto.RegisterType((*AllTypesOneOf)(nil), "one.AllTypesOneOf") diff --git a/test/oneof/combos/unmarshaler/one.pb.go b/test/oneof/combos/unmarshaler/one.pb.go index 346f64da33..5551c0929d 100644 --- a/test/oneof/combos/unmarshaler/one.pb.go +++ b/test/oneof/combos/unmarshaler/one.pb.go @@ -31,7 +31,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Subby struct { Sub *string `protobuf:"bytes,1,opt,name=sub" json:"sub,omitempty"` @@ -303,9 +303,9 @@ func (m *AllTypesOneOf) GetSubMessage() *Subby { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*AllTypesOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _AllTypesOneOf_OneofMarshaler, _AllTypesOneOf_OneofUnmarshaler, _AllTypesOneOf_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*AllTypesOneOf) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*AllTypesOneOf_Field1)(nil), (*AllTypesOneOf_Field2)(nil), (*AllTypesOneOf_Field3)(nil), @@ -325,255 +325,6 @@ func (*AllTypesOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) } } -func _AllTypesOneOf_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*AllTypesOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *AllTypesOneOf_Field1: - _ = b.EncodeVarint(1<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.Field1)) - case *AllTypesOneOf_Field2: - _ = b.EncodeVarint(2<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.Field2))) - case *AllTypesOneOf_Field3: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field3)) - case *AllTypesOneOf_Field4: - _ = b.EncodeVarint(4<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field4)) - case *AllTypesOneOf_Field5: - _ = b.EncodeVarint(5<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field5)) - case *AllTypesOneOf_Field6: - _ = b.EncodeVarint(6<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field6)) - case *AllTypesOneOf_Field7: - _ = b.EncodeVarint(7<<3 | proto.WireVarint) - _ = b.EncodeZigzag32(uint64(x.Field7)) - case *AllTypesOneOf_Field8: - _ = b.EncodeVarint(8<<3 | proto.WireVarint) - _ = b.EncodeZigzag64(uint64(x.Field8)) - case *AllTypesOneOf_Field9: - _ = b.EncodeVarint(9<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field9)) - case *AllTypesOneOf_Field10: - _ = b.EncodeVarint(10<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field10)) - case *AllTypesOneOf_Field11: - _ = b.EncodeVarint(11<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field11)) - case *AllTypesOneOf_Field12: - _ = b.EncodeVarint(12<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field12)) - case *AllTypesOneOf_Field13: - t := uint64(0) - if x.Field13 { - t = 1 - } - _ = b.EncodeVarint(13<<3 | proto.WireVarint) - _ = b.EncodeVarint(t) - case *AllTypesOneOf_Field14: - _ = b.EncodeVarint(14<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field14) - case *AllTypesOneOf_Field15: - _ = b.EncodeVarint(15<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Field15) - case *AllTypesOneOf_SubMessage: - _ = b.EncodeVarint(16<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.SubMessage); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("AllTypesOneOf.TestOneof has unexpected type %T", x) - } - return nil -} - -func _AllTypesOneOf_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*AllTypesOneOf) - switch tag { - case 1: // test_oneof.Field1 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &AllTypesOneOf_Field1{math.Float64frombits(x)} - return true, err - case 2: // test_oneof.Field2 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &AllTypesOneOf_Field2{math.Float32frombits(uint32(x))} - return true, err - case 3: // test_oneof.Field3 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field3{int32(x)} - return true, err - case 4: // test_oneof.Field4 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field4{int64(x)} - return true, err - case 5: // test_oneof.Field5 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field5{uint32(x)} - return true, err - case 6: // test_oneof.Field6 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field6{x} - return true, err - case 7: // test_oneof.Field7 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag32() - m.TestOneof = &AllTypesOneOf_Field7{int32(x)} - return true, err - case 8: // test_oneof.Field8 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag64() - m.TestOneof = &AllTypesOneOf_Field8{int64(x)} - return true, err - case 9: // test_oneof.Field9 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &AllTypesOneOf_Field9{uint32(x)} - return true, err - case 10: // test_oneof.Field10 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &AllTypesOneOf_Field10{int32(x)} - return true, err - case 11: // test_oneof.Field11 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &AllTypesOneOf_Field11{x} - return true, err - case 12: // test_oneof.Field12 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &AllTypesOneOf_Field12{int64(x)} - return true, err - case 13: // test_oneof.Field13 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &AllTypesOneOf_Field13{x != 0} - return true, err - case 14: // test_oneof.Field14 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.TestOneof = &AllTypesOneOf_Field14{x} - return true, err - case 15: // test_oneof.Field15 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.TestOneof = &AllTypesOneOf_Field15{x} - return true, err - case 16: // test_oneof.sub_message - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Subby) - err := b.DecodeMessage(msg) - m.TestOneof = &AllTypesOneOf_SubMessage{msg} - return true, err - default: - return false, nil - } -} - -func _AllTypesOneOf_OneofSizer(msg proto.Message) (n int) { - m := msg.(*AllTypesOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *AllTypesOneOf_Field1: - n += 1 // tag and wire - n += 8 - case *AllTypesOneOf_Field2: - n += 1 // tag and wire - n += 4 - case *AllTypesOneOf_Field3: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field3)) - case *AllTypesOneOf_Field4: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field4)) - case *AllTypesOneOf_Field5: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field5)) - case *AllTypesOneOf_Field6: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field6)) - case *AllTypesOneOf_Field7: - n += 1 // tag and wire - n += proto.SizeVarint(uint64((uint32(x.Field7) << 1) ^ uint32((int32(x.Field7) >> 31)))) - case *AllTypesOneOf_Field8: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(uint64(x.Field8<<1) ^ uint64((int64(x.Field8) >> 63)))) - case *AllTypesOneOf_Field9: - n += 1 // tag and wire - n += 4 - case *AllTypesOneOf_Field10: - n += 1 // tag and wire - n += 4 - case *AllTypesOneOf_Field11: - n += 1 // tag and wire - n += 8 - case *AllTypesOneOf_Field12: - n += 1 // tag and wire - n += 8 - case *AllTypesOneOf_Field13: - n += 1 // tag and wire - n += 1 - case *AllTypesOneOf_Field14: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field14))) - n += len(x.Field14) - case *AllTypesOneOf_Field15: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field15))) - n += len(x.Field15) - case *AllTypesOneOf_SubMessage: - s := proto.Size(x.SubMessage) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type TwoOneofs struct { // Types that are valid to be assigned to One: // *TwoOneofs_Field1 @@ -709,9 +460,9 @@ func (m *TwoOneofs) GetSubMessage2() *Subby { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*TwoOneofs) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _TwoOneofs_OneofMarshaler, _TwoOneofs_OneofUnmarshaler, _TwoOneofs_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*TwoOneofs) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*TwoOneofs_Field1)(nil), (*TwoOneofs_Field2)(nil), (*TwoOneofs_Field3)(nil), @@ -721,133 +472,6 @@ func (*TwoOneofs) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) err } } -func _TwoOneofs_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*TwoOneofs) - // one - switch x := m.One.(type) { - case *TwoOneofs_Field1: - _ = b.EncodeVarint(1<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.Field1)) - case *TwoOneofs_Field2: - _ = b.EncodeVarint(2<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.Field2))) - case *TwoOneofs_Field3: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field3)) - case nil: - default: - return fmt.Errorf("TwoOneofs.One has unexpected type %T", x) - } - // two - switch x := m.Two.(type) { - case *TwoOneofs_Field34: - _ = b.EncodeVarint(34<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field34) - case *TwoOneofs_Field35: - _ = b.EncodeVarint(35<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Field35) - case *TwoOneofs_SubMessage2: - _ = b.EncodeVarint(36<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.SubMessage2); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("TwoOneofs.Two has unexpected type %T", x) - } - return nil -} - -func _TwoOneofs_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*TwoOneofs) - switch tag { - case 1: // one.Field1 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.One = &TwoOneofs_Field1{math.Float64frombits(x)} - return true, err - case 2: // one.Field2 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.One = &TwoOneofs_Field2{math.Float32frombits(uint32(x))} - return true, err - case 3: // one.Field3 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.One = &TwoOneofs_Field3{int32(x)} - return true, err - case 34: // two.Field34 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Two = &TwoOneofs_Field34{x} - return true, err - case 35: // two.Field35 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.Two = &TwoOneofs_Field35{x} - return true, err - case 36: // two.sub_message2 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Subby) - err := b.DecodeMessage(msg) - m.Two = &TwoOneofs_SubMessage2{msg} - return true, err - default: - return false, nil - } -} - -func _TwoOneofs_OneofSizer(msg proto.Message) (n int) { - m := msg.(*TwoOneofs) - // one - switch x := m.One.(type) { - case *TwoOneofs_Field1: - n += 1 // tag and wire - n += 8 - case *TwoOneofs_Field2: - n += 1 // tag and wire - n += 4 - case *TwoOneofs_Field3: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field3)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - // two - switch x := m.Two.(type) { - case *TwoOneofs_Field34: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field34))) - n += len(x.Field34) - case *TwoOneofs_Field35: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field35))) - n += len(x.Field35) - case *TwoOneofs_SubMessage2: - s := proto.Size(x.SubMessage2) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type CustomOneof struct { // Types that are valid to be assigned to Custom: // *CustomOneof_Stringy @@ -937,9 +561,9 @@ func (m *CustomOneof) GetMyCustomName() int64 { return 0 } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*CustomOneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _CustomOneof_OneofMarshaler, _CustomOneof_OneofUnmarshaler, _CustomOneof_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*CustomOneof) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*CustomOneof_Stringy)(nil), (*CustomOneof_CustomType)(nil), (*CustomOneof_CastType)(nil), @@ -947,100 +571,6 @@ func (*CustomOneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) e } } -func _CustomOneof_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*CustomOneof) - // custom - switch x := m.Custom.(type) { - case *CustomOneof_Stringy: - _ = b.EncodeVarint(34<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Stringy) - case *CustomOneof_CustomType: - _ = b.EncodeVarint(35<<3 | proto.WireBytes) - dAtA, err := x.CustomType.Marshal() - if err != nil { - return err - } - _ = b.EncodeRawBytes(dAtA) - case *CustomOneof_CastType: - _ = b.EncodeVarint(36<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.CastType)) - case *CustomOneof_MyCustomName: - _ = b.EncodeVarint(37<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.MyCustomName)) - case nil: - default: - return fmt.Errorf("CustomOneof.Custom has unexpected type %T", x) - } - return nil -} - -func _CustomOneof_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*CustomOneof) - switch tag { - case 34: // custom.Stringy - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Custom = &CustomOneof_Stringy{x} - return true, err - case 35: // custom.CustomType - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - var cc github_com_gogo_protobuf_test_custom.Uint128 - c := &cc - err = c.Unmarshal(x) - m.Custom = &CustomOneof_CustomType{*c} - return true, err - case 36: // custom.CastType - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Custom = &CustomOneof_CastType{github_com_gogo_protobuf_test_casttype.MyUint64Type(x)} - return true, err - case 37: // custom.CustomName - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Custom = &CustomOneof_MyCustomName{int64(x)} - return true, err - default: - return false, nil - } -} - -func _CustomOneof_OneofSizer(msg proto.Message) (n int) { - m := msg.(*CustomOneof) - // custom - switch x := m.Custom.(type) { - case *CustomOneof_Stringy: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(len(x.Stringy))) - n += len(x.Stringy) - case *CustomOneof_CustomType: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.CustomType.Size())) - n += x.CustomType.Size() - case *CustomOneof_CastType: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.CastType)) - case *CustomOneof_MyCustomName: - n += 2 // tag and wire - n += proto.SizeVarint(uint64(x.MyCustomName)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*Subby)(nil), "one.Subby") proto.RegisterType((*AllTypesOneOf)(nil), "one.AllTypesOneOf") diff --git a/test/oneof3/combos/both/one.pb.go b/test/oneof3/combos/both/one.pb.go index 5b4e4ecb11..d00aebf555 100644 --- a/test/oneof3/combos/both/one.pb.go +++ b/test/oneof3/combos/both/one.pb.go @@ -29,7 +29,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Subby struct { Sub string `protobuf:"bytes,1,opt,name=sub,proto3" json:"sub,omitempty"` @@ -320,9 +320,9 @@ func (m *SampleOneOf) GetSubMessage() *Subby { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*SampleOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _SampleOneOf_OneofMarshaler, _SampleOneOf_OneofUnmarshaler, _SampleOneOf_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*SampleOneOf) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*SampleOneOf_Field1)(nil), (*SampleOneOf_Field2)(nil), (*SampleOneOf_Field3)(nil), @@ -342,255 +342,6 @@ func (*SampleOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) e } } -func _SampleOneOf_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*SampleOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *SampleOneOf_Field1: - _ = b.EncodeVarint(1<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.Field1)) - case *SampleOneOf_Field2: - _ = b.EncodeVarint(2<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.Field2))) - case *SampleOneOf_Field3: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field3)) - case *SampleOneOf_Field4: - _ = b.EncodeVarint(4<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field4)) - case *SampleOneOf_Field5: - _ = b.EncodeVarint(5<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field5)) - case *SampleOneOf_Field6: - _ = b.EncodeVarint(6<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field6)) - case *SampleOneOf_Field7: - _ = b.EncodeVarint(7<<3 | proto.WireVarint) - _ = b.EncodeZigzag32(uint64(x.Field7)) - case *SampleOneOf_Field8: - _ = b.EncodeVarint(8<<3 | proto.WireVarint) - _ = b.EncodeZigzag64(uint64(x.Field8)) - case *SampleOneOf_Field9: - _ = b.EncodeVarint(9<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field9)) - case *SampleOneOf_Field10: - _ = b.EncodeVarint(10<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field10)) - case *SampleOneOf_Field11: - _ = b.EncodeVarint(11<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field11)) - case *SampleOneOf_Field12: - _ = b.EncodeVarint(12<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field12)) - case *SampleOneOf_Field13: - t := uint64(0) - if x.Field13 { - t = 1 - } - _ = b.EncodeVarint(13<<3 | proto.WireVarint) - _ = b.EncodeVarint(t) - case *SampleOneOf_Field14: - _ = b.EncodeVarint(14<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field14) - case *SampleOneOf_Field15: - _ = b.EncodeVarint(15<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Field15) - case *SampleOneOf_SubMessage: - _ = b.EncodeVarint(16<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.SubMessage); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("SampleOneOf.TestOneof has unexpected type %T", x) - } - return nil -} - -func _SampleOneOf_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*SampleOneOf) - switch tag { - case 1: // test_oneof.Field1 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &SampleOneOf_Field1{math.Float64frombits(x)} - return true, err - case 2: // test_oneof.Field2 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &SampleOneOf_Field2{math.Float32frombits(uint32(x))} - return true, err - case 3: // test_oneof.Field3 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field3{int32(x)} - return true, err - case 4: // test_oneof.Field4 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field4{int64(x)} - return true, err - case 5: // test_oneof.Field5 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field5{uint32(x)} - return true, err - case 6: // test_oneof.Field6 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field6{x} - return true, err - case 7: // test_oneof.Field7 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag32() - m.TestOneof = &SampleOneOf_Field7{int32(x)} - return true, err - case 8: // test_oneof.Field8 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag64() - m.TestOneof = &SampleOneOf_Field8{int64(x)} - return true, err - case 9: // test_oneof.Field9 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &SampleOneOf_Field9{uint32(x)} - return true, err - case 10: // test_oneof.Field10 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &SampleOneOf_Field10{int32(x)} - return true, err - case 11: // test_oneof.Field11 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &SampleOneOf_Field11{x} - return true, err - case 12: // test_oneof.Field12 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &SampleOneOf_Field12{int64(x)} - return true, err - case 13: // test_oneof.Field13 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field13{x != 0} - return true, err - case 14: // test_oneof.Field14 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.TestOneof = &SampleOneOf_Field14{x} - return true, err - case 15: // test_oneof.Field15 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.TestOneof = &SampleOneOf_Field15{x} - return true, err - case 16: // test_oneof.sub_message - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Subby) - err := b.DecodeMessage(msg) - m.TestOneof = &SampleOneOf_SubMessage{msg} - return true, err - default: - return false, nil - } -} - -func _SampleOneOf_OneofSizer(msg proto.Message) (n int) { - m := msg.(*SampleOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *SampleOneOf_Field1: - n += 1 // tag and wire - n += 8 - case *SampleOneOf_Field2: - n += 1 // tag and wire - n += 4 - case *SampleOneOf_Field3: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field3)) - case *SampleOneOf_Field4: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field4)) - case *SampleOneOf_Field5: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field5)) - case *SampleOneOf_Field6: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field6)) - case *SampleOneOf_Field7: - n += 1 // tag and wire - n += proto.SizeVarint(uint64((uint32(x.Field7) << 1) ^ uint32((int32(x.Field7) >> 31)))) - case *SampleOneOf_Field8: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(uint64(x.Field8<<1) ^ uint64((int64(x.Field8) >> 63)))) - case *SampleOneOf_Field9: - n += 1 // tag and wire - n += 4 - case *SampleOneOf_Field10: - n += 1 // tag and wire - n += 4 - case *SampleOneOf_Field11: - n += 1 // tag and wire - n += 8 - case *SampleOneOf_Field12: - n += 1 // tag and wire - n += 8 - case *SampleOneOf_Field13: - n += 1 // tag and wire - n += 1 - case *SampleOneOf_Field14: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field14))) - n += len(x.Field14) - case *SampleOneOf_Field15: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field15))) - n += len(x.Field15) - case *SampleOneOf_SubMessage: - s := proto.Size(x.SubMessage) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*Subby)(nil), "one.Subby") proto.RegisterType((*SampleOneOf)(nil), "one.SampleOneOf") diff --git a/test/oneof3/combos/marshaler/one.pb.go b/test/oneof3/combos/marshaler/one.pb.go index f96ce96558..595da6694f 100644 --- a/test/oneof3/combos/marshaler/one.pb.go +++ b/test/oneof3/combos/marshaler/one.pb.go @@ -28,7 +28,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Subby struct { Sub string `protobuf:"bytes,1,opt,name=sub,proto3" json:"sub,omitempty"` @@ -319,9 +319,9 @@ func (m *SampleOneOf) GetSubMessage() *Subby { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*SampleOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _SampleOneOf_OneofMarshaler, _SampleOneOf_OneofUnmarshaler, _SampleOneOf_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*SampleOneOf) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*SampleOneOf_Field1)(nil), (*SampleOneOf_Field2)(nil), (*SampleOneOf_Field3)(nil), @@ -341,255 +341,6 @@ func (*SampleOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) e } } -func _SampleOneOf_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*SampleOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *SampleOneOf_Field1: - _ = b.EncodeVarint(1<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.Field1)) - case *SampleOneOf_Field2: - _ = b.EncodeVarint(2<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.Field2))) - case *SampleOneOf_Field3: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field3)) - case *SampleOneOf_Field4: - _ = b.EncodeVarint(4<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field4)) - case *SampleOneOf_Field5: - _ = b.EncodeVarint(5<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field5)) - case *SampleOneOf_Field6: - _ = b.EncodeVarint(6<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field6)) - case *SampleOneOf_Field7: - _ = b.EncodeVarint(7<<3 | proto.WireVarint) - _ = b.EncodeZigzag32(uint64(x.Field7)) - case *SampleOneOf_Field8: - _ = b.EncodeVarint(8<<3 | proto.WireVarint) - _ = b.EncodeZigzag64(uint64(x.Field8)) - case *SampleOneOf_Field9: - _ = b.EncodeVarint(9<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field9)) - case *SampleOneOf_Field10: - _ = b.EncodeVarint(10<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field10)) - case *SampleOneOf_Field11: - _ = b.EncodeVarint(11<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field11)) - case *SampleOneOf_Field12: - _ = b.EncodeVarint(12<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field12)) - case *SampleOneOf_Field13: - t := uint64(0) - if x.Field13 { - t = 1 - } - _ = b.EncodeVarint(13<<3 | proto.WireVarint) - _ = b.EncodeVarint(t) - case *SampleOneOf_Field14: - _ = b.EncodeVarint(14<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field14) - case *SampleOneOf_Field15: - _ = b.EncodeVarint(15<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Field15) - case *SampleOneOf_SubMessage: - _ = b.EncodeVarint(16<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.SubMessage); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("SampleOneOf.TestOneof has unexpected type %T", x) - } - return nil -} - -func _SampleOneOf_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*SampleOneOf) - switch tag { - case 1: // test_oneof.Field1 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &SampleOneOf_Field1{math.Float64frombits(x)} - return true, err - case 2: // test_oneof.Field2 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &SampleOneOf_Field2{math.Float32frombits(uint32(x))} - return true, err - case 3: // test_oneof.Field3 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field3{int32(x)} - return true, err - case 4: // test_oneof.Field4 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field4{int64(x)} - return true, err - case 5: // test_oneof.Field5 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field5{uint32(x)} - return true, err - case 6: // test_oneof.Field6 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field6{x} - return true, err - case 7: // test_oneof.Field7 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag32() - m.TestOneof = &SampleOneOf_Field7{int32(x)} - return true, err - case 8: // test_oneof.Field8 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag64() - m.TestOneof = &SampleOneOf_Field8{int64(x)} - return true, err - case 9: // test_oneof.Field9 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &SampleOneOf_Field9{uint32(x)} - return true, err - case 10: // test_oneof.Field10 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &SampleOneOf_Field10{int32(x)} - return true, err - case 11: // test_oneof.Field11 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &SampleOneOf_Field11{x} - return true, err - case 12: // test_oneof.Field12 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &SampleOneOf_Field12{int64(x)} - return true, err - case 13: // test_oneof.Field13 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field13{x != 0} - return true, err - case 14: // test_oneof.Field14 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.TestOneof = &SampleOneOf_Field14{x} - return true, err - case 15: // test_oneof.Field15 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.TestOneof = &SampleOneOf_Field15{x} - return true, err - case 16: // test_oneof.sub_message - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Subby) - err := b.DecodeMessage(msg) - m.TestOneof = &SampleOneOf_SubMessage{msg} - return true, err - default: - return false, nil - } -} - -func _SampleOneOf_OneofSizer(msg proto.Message) (n int) { - m := msg.(*SampleOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *SampleOneOf_Field1: - n += 1 // tag and wire - n += 8 - case *SampleOneOf_Field2: - n += 1 // tag and wire - n += 4 - case *SampleOneOf_Field3: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field3)) - case *SampleOneOf_Field4: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field4)) - case *SampleOneOf_Field5: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field5)) - case *SampleOneOf_Field6: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field6)) - case *SampleOneOf_Field7: - n += 1 // tag and wire - n += proto.SizeVarint(uint64((uint32(x.Field7) << 1) ^ uint32((int32(x.Field7) >> 31)))) - case *SampleOneOf_Field8: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(uint64(x.Field8<<1) ^ uint64((int64(x.Field8) >> 63)))) - case *SampleOneOf_Field9: - n += 1 // tag and wire - n += 4 - case *SampleOneOf_Field10: - n += 1 // tag and wire - n += 4 - case *SampleOneOf_Field11: - n += 1 // tag and wire - n += 8 - case *SampleOneOf_Field12: - n += 1 // tag and wire - n += 8 - case *SampleOneOf_Field13: - n += 1 // tag and wire - n += 1 - case *SampleOneOf_Field14: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field14))) - n += len(x.Field14) - case *SampleOneOf_Field15: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field15))) - n += len(x.Field15) - case *SampleOneOf_SubMessage: - s := proto.Size(x.SubMessage) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*Subby)(nil), "one.Subby") proto.RegisterType((*SampleOneOf)(nil), "one.SampleOneOf") diff --git a/test/oneof3/combos/neither/one.pb.go b/test/oneof3/combos/neither/one.pb.go index a767aed928..3a74364096 100644 --- a/test/oneof3/combos/neither/one.pb.go +++ b/test/oneof3/combos/neither/one.pb.go @@ -27,7 +27,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Subby struct { Sub string `protobuf:"bytes,1,opt,name=sub,proto3" json:"sub,omitempty"` @@ -299,9 +299,9 @@ func (m *SampleOneOf) GetSubMessage() *Subby { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*SampleOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _SampleOneOf_OneofMarshaler, _SampleOneOf_OneofUnmarshaler, _SampleOneOf_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*SampleOneOf) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*SampleOneOf_Field1)(nil), (*SampleOneOf_Field2)(nil), (*SampleOneOf_Field3)(nil), @@ -321,255 +321,6 @@ func (*SampleOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) e } } -func _SampleOneOf_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*SampleOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *SampleOneOf_Field1: - _ = b.EncodeVarint(1<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.Field1)) - case *SampleOneOf_Field2: - _ = b.EncodeVarint(2<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.Field2))) - case *SampleOneOf_Field3: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field3)) - case *SampleOneOf_Field4: - _ = b.EncodeVarint(4<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field4)) - case *SampleOneOf_Field5: - _ = b.EncodeVarint(5<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field5)) - case *SampleOneOf_Field6: - _ = b.EncodeVarint(6<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field6)) - case *SampleOneOf_Field7: - _ = b.EncodeVarint(7<<3 | proto.WireVarint) - _ = b.EncodeZigzag32(uint64(x.Field7)) - case *SampleOneOf_Field8: - _ = b.EncodeVarint(8<<3 | proto.WireVarint) - _ = b.EncodeZigzag64(uint64(x.Field8)) - case *SampleOneOf_Field9: - _ = b.EncodeVarint(9<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field9)) - case *SampleOneOf_Field10: - _ = b.EncodeVarint(10<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field10)) - case *SampleOneOf_Field11: - _ = b.EncodeVarint(11<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field11)) - case *SampleOneOf_Field12: - _ = b.EncodeVarint(12<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field12)) - case *SampleOneOf_Field13: - t := uint64(0) - if x.Field13 { - t = 1 - } - _ = b.EncodeVarint(13<<3 | proto.WireVarint) - _ = b.EncodeVarint(t) - case *SampleOneOf_Field14: - _ = b.EncodeVarint(14<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field14) - case *SampleOneOf_Field15: - _ = b.EncodeVarint(15<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Field15) - case *SampleOneOf_SubMessage: - _ = b.EncodeVarint(16<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.SubMessage); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("SampleOneOf.TestOneof has unexpected type %T", x) - } - return nil -} - -func _SampleOneOf_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*SampleOneOf) - switch tag { - case 1: // test_oneof.Field1 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &SampleOneOf_Field1{math.Float64frombits(x)} - return true, err - case 2: // test_oneof.Field2 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &SampleOneOf_Field2{math.Float32frombits(uint32(x))} - return true, err - case 3: // test_oneof.Field3 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field3{int32(x)} - return true, err - case 4: // test_oneof.Field4 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field4{int64(x)} - return true, err - case 5: // test_oneof.Field5 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field5{uint32(x)} - return true, err - case 6: // test_oneof.Field6 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field6{x} - return true, err - case 7: // test_oneof.Field7 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag32() - m.TestOneof = &SampleOneOf_Field7{int32(x)} - return true, err - case 8: // test_oneof.Field8 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag64() - m.TestOneof = &SampleOneOf_Field8{int64(x)} - return true, err - case 9: // test_oneof.Field9 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &SampleOneOf_Field9{uint32(x)} - return true, err - case 10: // test_oneof.Field10 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &SampleOneOf_Field10{int32(x)} - return true, err - case 11: // test_oneof.Field11 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &SampleOneOf_Field11{x} - return true, err - case 12: // test_oneof.Field12 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &SampleOneOf_Field12{int64(x)} - return true, err - case 13: // test_oneof.Field13 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field13{x != 0} - return true, err - case 14: // test_oneof.Field14 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.TestOneof = &SampleOneOf_Field14{x} - return true, err - case 15: // test_oneof.Field15 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.TestOneof = &SampleOneOf_Field15{x} - return true, err - case 16: // test_oneof.sub_message - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Subby) - err := b.DecodeMessage(msg) - m.TestOneof = &SampleOneOf_SubMessage{msg} - return true, err - default: - return false, nil - } -} - -func _SampleOneOf_OneofSizer(msg proto.Message) (n int) { - m := msg.(*SampleOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *SampleOneOf_Field1: - n += 1 // tag and wire - n += 8 - case *SampleOneOf_Field2: - n += 1 // tag and wire - n += 4 - case *SampleOneOf_Field3: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field3)) - case *SampleOneOf_Field4: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field4)) - case *SampleOneOf_Field5: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field5)) - case *SampleOneOf_Field6: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field6)) - case *SampleOneOf_Field7: - n += 1 // tag and wire - n += proto.SizeVarint(uint64((uint32(x.Field7) << 1) ^ uint32((int32(x.Field7) >> 31)))) - case *SampleOneOf_Field8: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(uint64(x.Field8<<1) ^ uint64((int64(x.Field8) >> 63)))) - case *SampleOneOf_Field9: - n += 1 // tag and wire - n += 4 - case *SampleOneOf_Field10: - n += 1 // tag and wire - n += 4 - case *SampleOneOf_Field11: - n += 1 // tag and wire - n += 8 - case *SampleOneOf_Field12: - n += 1 // tag and wire - n += 8 - case *SampleOneOf_Field13: - n += 1 // tag and wire - n += 1 - case *SampleOneOf_Field14: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field14))) - n += len(x.Field14) - case *SampleOneOf_Field15: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field15))) - n += len(x.Field15) - case *SampleOneOf_SubMessage: - s := proto.Size(x.SubMessage) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*Subby)(nil), "one.Subby") proto.RegisterType((*SampleOneOf)(nil), "one.SampleOneOf") diff --git a/test/oneof3/combos/unmarshaler/one.pb.go b/test/oneof3/combos/unmarshaler/one.pb.go index 6be9353c95..a13643e8f3 100644 --- a/test/oneof3/combos/unmarshaler/one.pb.go +++ b/test/oneof3/combos/unmarshaler/one.pb.go @@ -29,7 +29,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Subby struct { Sub string `protobuf:"bytes,1,opt,name=sub,proto3" json:"sub,omitempty"` @@ -301,9 +301,9 @@ func (m *SampleOneOf) GetSubMessage() *Subby { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*SampleOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _SampleOneOf_OneofMarshaler, _SampleOneOf_OneofUnmarshaler, _SampleOneOf_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*SampleOneOf) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*SampleOneOf_Field1)(nil), (*SampleOneOf_Field2)(nil), (*SampleOneOf_Field3)(nil), @@ -323,255 +323,6 @@ func (*SampleOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) e } } -func _SampleOneOf_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*SampleOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *SampleOneOf_Field1: - _ = b.EncodeVarint(1<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.Field1)) - case *SampleOneOf_Field2: - _ = b.EncodeVarint(2<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(math.Float32bits(x.Field2))) - case *SampleOneOf_Field3: - _ = b.EncodeVarint(3<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field3)) - case *SampleOneOf_Field4: - _ = b.EncodeVarint(4<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field4)) - case *SampleOneOf_Field5: - _ = b.EncodeVarint(5<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field5)) - case *SampleOneOf_Field6: - _ = b.EncodeVarint(6<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.Field6)) - case *SampleOneOf_Field7: - _ = b.EncodeVarint(7<<3 | proto.WireVarint) - _ = b.EncodeZigzag32(uint64(x.Field7)) - case *SampleOneOf_Field8: - _ = b.EncodeVarint(8<<3 | proto.WireVarint) - _ = b.EncodeZigzag64(uint64(x.Field8)) - case *SampleOneOf_Field9: - _ = b.EncodeVarint(9<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field9)) - case *SampleOneOf_Field10: - _ = b.EncodeVarint(10<<3 | proto.WireFixed32) - _ = b.EncodeFixed32(uint64(x.Field10)) - case *SampleOneOf_Field11: - _ = b.EncodeVarint(11<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field11)) - case *SampleOneOf_Field12: - _ = b.EncodeVarint(12<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(uint64(x.Field12)) - case *SampleOneOf_Field13: - t := uint64(0) - if x.Field13 { - t = 1 - } - _ = b.EncodeVarint(13<<3 | proto.WireVarint) - _ = b.EncodeVarint(t) - case *SampleOneOf_Field14: - _ = b.EncodeVarint(14<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.Field14) - case *SampleOneOf_Field15: - _ = b.EncodeVarint(15<<3 | proto.WireBytes) - _ = b.EncodeRawBytes(x.Field15) - case *SampleOneOf_SubMessage: - _ = b.EncodeVarint(16<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.SubMessage); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("SampleOneOf.TestOneof has unexpected type %T", x) - } - return nil -} - -func _SampleOneOf_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*SampleOneOf) - switch tag { - case 1: // test_oneof.Field1 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &SampleOneOf_Field1{math.Float64frombits(x)} - return true, err - case 2: // test_oneof.Field2 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &SampleOneOf_Field2{math.Float32frombits(uint32(x))} - return true, err - case 3: // test_oneof.Field3 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field3{int32(x)} - return true, err - case 4: // test_oneof.Field4 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field4{int64(x)} - return true, err - case 5: // test_oneof.Field5 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field5{uint32(x)} - return true, err - case 6: // test_oneof.Field6 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field6{x} - return true, err - case 7: // test_oneof.Field7 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag32() - m.TestOneof = &SampleOneOf_Field7{int32(x)} - return true, err - case 8: // test_oneof.Field8 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeZigzag64() - m.TestOneof = &SampleOneOf_Field8{int64(x)} - return true, err - case 9: // test_oneof.Field9 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &SampleOneOf_Field9{uint32(x)} - return true, err - case 10: // test_oneof.Field10 - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.TestOneof = &SampleOneOf_Field10{int32(x)} - return true, err - case 11: // test_oneof.Field11 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &SampleOneOf_Field11{x} - return true, err - case 12: // test_oneof.Field12 - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.TestOneof = &SampleOneOf_Field12{int64(x)} - return true, err - case 13: // test_oneof.Field13 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.TestOneof = &SampleOneOf_Field13{x != 0} - return true, err - case 14: // test_oneof.Field14 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.TestOneof = &SampleOneOf_Field14{x} - return true, err - case 15: // test_oneof.Field15 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.TestOneof = &SampleOneOf_Field15{x} - return true, err - case 16: // test_oneof.sub_message - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Subby) - err := b.DecodeMessage(msg) - m.TestOneof = &SampleOneOf_SubMessage{msg} - return true, err - default: - return false, nil - } -} - -func _SampleOneOf_OneofSizer(msg proto.Message) (n int) { - m := msg.(*SampleOneOf) - // test_oneof - switch x := m.TestOneof.(type) { - case *SampleOneOf_Field1: - n += 1 // tag and wire - n += 8 - case *SampleOneOf_Field2: - n += 1 // tag and wire - n += 4 - case *SampleOneOf_Field3: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field3)) - case *SampleOneOf_Field4: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field4)) - case *SampleOneOf_Field5: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field5)) - case *SampleOneOf_Field6: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.Field6)) - case *SampleOneOf_Field7: - n += 1 // tag and wire - n += proto.SizeVarint(uint64((uint32(x.Field7) << 1) ^ uint32((int32(x.Field7) >> 31)))) - case *SampleOneOf_Field8: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(uint64(x.Field8<<1) ^ uint64((int64(x.Field8) >> 63)))) - case *SampleOneOf_Field9: - n += 1 // tag and wire - n += 4 - case *SampleOneOf_Field10: - n += 1 // tag and wire - n += 4 - case *SampleOneOf_Field11: - n += 1 // tag and wire - n += 8 - case *SampleOneOf_Field12: - n += 1 // tag and wire - n += 8 - case *SampleOneOf_Field13: - n += 1 // tag and wire - n += 1 - case *SampleOneOf_Field14: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field14))) - n += len(x.Field14) - case *SampleOneOf_Field15: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.Field15))) - n += len(x.Field15) - case *SampleOneOf_SubMessage: - s := proto.Size(x.SubMessage) - n += 2 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*Subby)(nil), "one.Subby") proto.RegisterType((*SampleOneOf)(nil), "one.SampleOneOf") diff --git a/test/oneofembed/oneofembed.pb.go b/test/oneofembed/oneofembed.pb.go index 0812ba5eed..967192fcac 100644 --- a/test/oneofembed/oneofembed.pb.go +++ b/test/oneofembed/oneofembed.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Foo struct { *Bar `protobuf:"bytes,1,opt,name=bar,proto3,embedded=bar" json:"bar,omitempty"` @@ -124,78 +124,14 @@ func (m *Bar) GetB() bool { return false } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*Bar) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _Bar_OneofMarshaler, _Bar_OneofUnmarshaler, _Bar_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Bar) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*Bar_A)(nil), (*Bar_B)(nil), } } -func _Bar_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*Bar) - // pick - switch x := m.Pick.(type) { - case *Bar_A: - t := uint64(0) - if x.A { - t = 1 - } - _ = b.EncodeVarint(11<<3 | proto.WireVarint) - _ = b.EncodeVarint(t) - case *Bar_B: - t := uint64(0) - if x.B { - t = 1 - } - _ = b.EncodeVarint(12<<3 | proto.WireVarint) - _ = b.EncodeVarint(t) - case nil: - default: - return fmt.Errorf("Bar.Pick has unexpected type %T", x) - } - return nil -} - -func _Bar_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*Bar) - switch tag { - case 11: // pick.a - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Pick = &Bar_A{x != 0} - return true, err - case 12: // pick.b - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Pick = &Bar_B{x != 0} - return true, err - default: - return false, nil - } -} - -func _Bar_OneofSizer(msg proto.Message) (n int) { - m := msg.(*Bar) - // pick - switch x := m.Pick.(type) { - case *Bar_A: - n += 1 // tag and wire - n += 1 - case *Bar_B: - n += 1 // tag and wire - n += 1 - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*Foo)(nil), "proto.Foo") proto.RegisterType((*Bar)(nil), "proto.Bar") diff --git a/test/packed/packed.pb.go b/test/packed/packed.pb.go index 6cad9677ca..17ab26de6c 100644 --- a/test/packed/packed.pb.go +++ b/test/packed/packed.pb.go @@ -21,7 +21,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type NinRepNative struct { Field1 []float64 `protobuf:"fixed64,1,rep,name=Field1" json:"Field1,omitempty"` diff --git a/test/proto3extension/proto3ext.pb.go b/test/proto3extension/proto3ext.pb.go index 66150d094a..5935603ce5 100644 --- a/test/proto3extension/proto3ext.pb.go +++ b/test/proto3extension/proto3ext.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package var E_Primary = &proto.ExtensionDesc{ ExtendedType: (*descriptor.FieldOptions)(nil), diff --git a/test/protosize/protosize.pb.go b/test/protosize/protosize.pb.go index 42b95593c2..fce29a490a 100644 --- a/test/protosize/protosize.pb.go +++ b/test/protosize/protosize.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type SizeMessage struct { Size *int64 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"` diff --git a/test/required/requiredexample.pb.go b/test/required/requiredexample.pb.go index b1eb0b9ce1..280fb4a988 100644 --- a/test/required/requiredexample.pb.go +++ b/test/required/requiredexample.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type RequiredExample struct { TheRequiredString *string `protobuf:"bytes,1,req,name=theRequiredString" json:"theRequiredString,omitempty"` diff --git a/test/sizeunderscore/sizeunderscore.pb.go b/test/sizeunderscore/sizeunderscore.pb.go index ad4c4f4484..f52b349cc1 100644 --- a/test/sizeunderscore/sizeunderscore.pb.go +++ b/test/sizeunderscore/sizeunderscore.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type SizeMessage struct { Size_ *int64 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"` diff --git a/test/stdtypes/stdtypes.pb.go b/test/stdtypes/stdtypes.pb.go index f684957a58..cd51f6c8d2 100644 --- a/test/stdtypes/stdtypes.pb.go +++ b/test/stdtypes/stdtypes.pb.go @@ -28,7 +28,7 @@ var _ = time.Kitchen // 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type StdTypes struct { NullableTimestamp *time.Time `protobuf:"bytes,1,opt,name=nullableTimestamp,proto3,stdtime" json:"nullableTimestamp,omitempty"` @@ -828,9 +828,9 @@ func (m *OneofStdTypes) GetRepBytes() *[]byte { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*OneofStdTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _OneofStdTypes_OneofMarshaler, _OneofStdTypes_OneofUnmarshaler, _OneofStdTypes_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*OneofStdTypes) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*OneofStdTypes_Timestamp)(nil), (*OneofStdTypes_Duration)(nil), (*OneofStdTypes_RepDouble)(nil), @@ -845,344 +845,6 @@ func (*OneofStdTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) } } -func _OneofStdTypes_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*OneofStdTypes) - // OneOfStdTimes - switch x := m.OneOfStdTimes.(type) { - case *OneofStdTypes_Timestamp: - _ = b.EncodeVarint(1<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdTimeMarshal(*x.Timestamp) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_Duration: - _ = b.EncodeVarint(2<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdDurationMarshal(*x.Duration) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepDouble: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdDoubleMarshal(*x.RepDouble) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepFloat: - _ = b.EncodeVarint(4<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdFloatMarshal(*x.RepFloat) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepInt64: - _ = b.EncodeVarint(5<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdInt64Marshal(*x.RepInt64) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepUInt64: - _ = b.EncodeVarint(6<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdUInt64Marshal(*x.RepUInt64) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepInt32: - _ = b.EncodeVarint(7<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdInt32Marshal(*x.RepInt32) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepUInt32: - _ = b.EncodeVarint(8<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdUInt32Marshal(*x.RepUInt32) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepBool: - _ = b.EncodeVarint(9<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdBoolMarshal(*x.RepBool) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepString: - _ = b.EncodeVarint(10<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdStringMarshal(*x.RepString) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepBytes: - _ = b.EncodeVarint(11<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdBytesMarshal(*x.RepBytes) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("OneofStdTypes.OneOfStdTimes has unexpected type %T", x) - } - return nil -} - -func _OneofStdTypes_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*OneofStdTypes) - switch tag { - case 1: // OneOfStdTimes.timestamp - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(time.Time) - if err2 := github_com_gogo_protobuf_types.StdTimeUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_Timestamp{c} - return true, err - case 2: // OneOfStdTimes.duration - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(time.Duration) - if err2 := github_com_gogo_protobuf_types.StdDurationUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_Duration{c} - return true, err - case 3: // OneOfStdTimes.repDouble - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(float64) - if err2 := github_com_gogo_protobuf_types.StdDoubleUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepDouble{c} - return true, err - case 4: // OneOfStdTimes.repFloat - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(float32) - if err2 := github_com_gogo_protobuf_types.StdFloatUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepFloat{c} - return true, err - case 5: // OneOfStdTimes.repInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(int64) - if err2 := github_com_gogo_protobuf_types.StdInt64Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepInt64{c} - return true, err - case 6: // OneOfStdTimes.repUInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(uint64) - if err2 := github_com_gogo_protobuf_types.StdUInt64Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepUInt64{c} - return true, err - case 7: // OneOfStdTimes.repInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(int32) - if err2 := github_com_gogo_protobuf_types.StdInt32Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepInt32{c} - return true, err - case 8: // OneOfStdTimes.repUInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(uint32) - if err2 := github_com_gogo_protobuf_types.StdUInt32Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepUInt32{c} - return true, err - case 9: // OneOfStdTimes.repBool - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(bool) - if err2 := github_com_gogo_protobuf_types.StdBoolUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepBool{c} - return true, err - case 10: // OneOfStdTimes.repString - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(string) - if err2 := github_com_gogo_protobuf_types.StdStringUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepString{c} - return true, err - case 11: // OneOfStdTimes.repBytes - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new([]byte) - if err2 := github_com_gogo_protobuf_types.StdBytesUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepBytes{c} - return true, err - default: - return false, nil - } -} - -func _OneofStdTypes_OneofSizer(msg proto.Message) (n int) { - m := msg.(*OneofStdTypes) - // OneOfStdTimes - switch x := m.OneOfStdTimes.(type) { - case *OneofStdTypes_Timestamp: - s := github_com_gogo_protobuf_types.SizeOfStdTime(*x.Timestamp) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_Duration: - s := github_com_gogo_protobuf_types.SizeOfStdDuration(*x.Duration) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepDouble: - s := github_com_gogo_protobuf_types.SizeOfStdDouble(*x.RepDouble) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepFloat: - s := github_com_gogo_protobuf_types.SizeOfStdFloat(*x.RepFloat) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepInt64: - s := github_com_gogo_protobuf_types.SizeOfStdInt64(*x.RepInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepUInt64: - s := github_com_gogo_protobuf_types.SizeOfStdUInt64(*x.RepUInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepInt32: - s := github_com_gogo_protobuf_types.SizeOfStdInt32(*x.RepInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepUInt32: - s := github_com_gogo_protobuf_types.SizeOfStdUInt32(*x.RepUInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepBool: - s := github_com_gogo_protobuf_types.SizeOfStdBool(*x.RepBool) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepString: - s := github_com_gogo_protobuf_types.SizeOfStdString(*x.RepString) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepBytes: - s := github_com_gogo_protobuf_types.SizeOfStdBytes(*x.RepBytes) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*StdTypes)(nil), "stdtypes.StdTypes") proto.RegisterType((*RepStdTypes)(nil), "stdtypes.RepStdTypes") diff --git a/test/tags/tags.pb.go b/test/tags/tags.pb.go index ff20cd7271..60374cfd57 100644 --- a/test/tags/tags.pb.go +++ b/test/tags/tags.pb.go @@ -19,7 +19,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Outside struct { *Inside `protobuf:"bytes,1,opt,name=Inside,embedded=Inside" json:""` diff --git a/test/theproto3/combos/both/theproto3.pb.go b/test/theproto3/combos/both/theproto3.pb.go index 1b4c230faf..e044a6278a 100644 --- a/test/theproto3/combos/both/theproto3.pb.go +++ b/test/theproto3/combos/both/theproto3.pb.go @@ -33,7 +33,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapEnum int32 diff --git a/test/theproto3/combos/marshaler/theproto3.pb.go b/test/theproto3/combos/marshaler/theproto3.pb.go index 6922c5277a..4feef58779 100644 --- a/test/theproto3/combos/marshaler/theproto3.pb.go +++ b/test/theproto3/combos/marshaler/theproto3.pb.go @@ -32,7 +32,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapEnum int32 diff --git a/test/theproto3/combos/neither/theproto3.pb.go b/test/theproto3/combos/neither/theproto3.pb.go index 439efa5d6e..7dc527932a 100644 --- a/test/theproto3/combos/neither/theproto3.pb.go +++ b/test/theproto3/combos/neither/theproto3.pb.go @@ -31,7 +31,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapEnum int32 diff --git a/test/theproto3/combos/unmarshaler/theproto3.pb.go b/test/theproto3/combos/unmarshaler/theproto3.pb.go index 8adabd946f..56e6eee3d5 100644 --- a/test/theproto3/combos/unmarshaler/theproto3.pb.go +++ b/test/theproto3/combos/unmarshaler/theproto3.pb.go @@ -33,7 +33,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MapEnum int32 diff --git a/test/thetest.pb.go b/test/thetest.pb.go index 05ed0427e7..cefb597661 100644 --- a/test/thetest.pb.go +++ b/test/thetest.pb.go @@ -32,7 +32,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TheTestEnum int32 diff --git a/test/typedecl/typedecl.pb.go b/test/typedecl/typedecl.pb.go index b90d5de783..568661eeda 100644 --- a/test/typedecl/typedecl.pb.go +++ b/test/typedecl/typedecl.pb.go @@ -21,7 +21,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package func (m *Dropped) Reset() { *m = Dropped{} } func (m *Dropped) String() string { return proto.CompactTextString(m) } diff --git a/test/typedecl_all/typedeclall.pb.go b/test/typedecl_all/typedeclall.pb.go index 88c728bfaa..b140fb9649 100644 --- a/test/typedecl_all/typedeclall.pb.go +++ b/test/typedecl_all/typedeclall.pb.go @@ -21,7 +21,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package func (m *Dropped) Reset() { *m = Dropped{} } func (m *Dropped) String() string { return proto.CompactTextString(m) } diff --git a/test/types/combos/both/types.pb.go b/test/types/combos/both/types.pb.go index d24345dadc..28651a5bd4 100644 --- a/test/types/combos/both/types.pb.go +++ b/test/types/combos/both/types.pb.go @@ -26,7 +26,7 @@ var _ = time.Kitchen // 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type KnownTypes struct { Dur *types.Duration `protobuf:"bytes,1,opt,name=dur,proto3" json:"dur,omitempty"` @@ -1644,9 +1644,9 @@ func (m *OneofProtoTypes) GetRepBytes() *types.BytesValue { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*OneofProtoTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _OneofProtoTypes_OneofMarshaler, _OneofProtoTypes_OneofUnmarshaler, _OneofProtoTypes_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*OneofProtoTypes) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*OneofProtoTypes_Timestamp)(nil), (*OneofProtoTypes_Duration)(nil), (*OneofProtoTypes_RepDouble)(nil), @@ -1661,234 +1661,6 @@ func (*OneofProtoTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffe } } -func _OneofProtoTypes_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*OneofProtoTypes) - // OneOfProtoTimes - switch x := m.OneOfProtoTimes.(type) { - case *OneofProtoTypes_Timestamp: - _ = b.EncodeVarint(1<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.Timestamp); err != nil { - return err - } - case *OneofProtoTypes_Duration: - _ = b.EncodeVarint(2<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.Duration); err != nil { - return err - } - case *OneofProtoTypes_RepDouble: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepDouble); err != nil { - return err - } - case *OneofProtoTypes_RepFloat: - _ = b.EncodeVarint(4<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepFloat); err != nil { - return err - } - case *OneofProtoTypes_RepInt64: - _ = b.EncodeVarint(5<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepInt64); err != nil { - return err - } - case *OneofProtoTypes_RepUInt64: - _ = b.EncodeVarint(6<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepUInt64); err != nil { - return err - } - case *OneofProtoTypes_RepInt32: - _ = b.EncodeVarint(7<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepInt32); err != nil { - return err - } - case *OneofProtoTypes_RepUInt32: - _ = b.EncodeVarint(8<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepUInt32); err != nil { - return err - } - case *OneofProtoTypes_RepBool: - _ = b.EncodeVarint(9<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepBool); err != nil { - return err - } - case *OneofProtoTypes_RepString: - _ = b.EncodeVarint(10<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepString); err != nil { - return err - } - case *OneofProtoTypes_RepBytes: - _ = b.EncodeVarint(11<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepBytes); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("OneofProtoTypes.OneOfProtoTimes has unexpected type %T", x) - } - return nil -} - -func _OneofProtoTypes_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*OneofProtoTypes) - switch tag { - case 1: // OneOfProtoTimes.timestamp - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Timestamp) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_Timestamp{msg} - return true, err - case 2: // OneOfProtoTimes.duration - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Duration) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_Duration{msg} - return true, err - case 3: // OneOfProtoTimes.repDouble - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.DoubleValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepDouble{msg} - return true, err - case 4: // OneOfProtoTimes.repFloat - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.FloatValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepFloat{msg} - return true, err - case 5: // OneOfProtoTimes.repInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Int64Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepInt64{msg} - return true, err - case 6: // OneOfProtoTimes.repUInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.UInt64Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepUInt64{msg} - return true, err - case 7: // OneOfProtoTimes.repInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Int32Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepInt32{msg} - return true, err - case 8: // OneOfProtoTimes.repUInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.UInt32Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepUInt32{msg} - return true, err - case 9: // OneOfProtoTimes.repBool - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.BoolValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepBool{msg} - return true, err - case 10: // OneOfProtoTimes.repString - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.StringValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepString{msg} - return true, err - case 11: // OneOfProtoTimes.repBytes - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.BytesValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepBytes{msg} - return true, err - default: - return false, nil - } -} - -func _OneofProtoTypes_OneofSizer(msg proto.Message) (n int) { - m := msg.(*OneofProtoTypes) - // OneOfProtoTimes - switch x := m.OneOfProtoTimes.(type) { - case *OneofProtoTypes_Timestamp: - s := proto.Size(x.Timestamp) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_Duration: - s := proto.Size(x.Duration) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepDouble: - s := proto.Size(x.RepDouble) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepFloat: - s := proto.Size(x.RepFloat) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepInt64: - s := proto.Size(x.RepInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepUInt64: - s := proto.Size(x.RepUInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepInt32: - s := proto.Size(x.RepInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepUInt32: - s := proto.Size(x.RepUInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepBool: - s := proto.Size(x.RepBool) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepString: - s := proto.Size(x.RepString) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepBytes: - s := proto.Size(x.RepBytes) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type OneofStdTypes struct { // Types that are valid to be assigned to OneOfStdTimes: // *OneofStdTypes_Timestamp @@ -2079,9 +1851,9 @@ func (m *OneofStdTypes) GetRepBytes() *[]byte { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*OneofStdTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _OneofStdTypes_OneofMarshaler, _OneofStdTypes_OneofUnmarshaler, _OneofStdTypes_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*OneofStdTypes) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*OneofStdTypes_Timestamp)(nil), (*OneofStdTypes_Duration)(nil), (*OneofStdTypes_RepDouble)(nil), @@ -2096,344 +1868,6 @@ func (*OneofStdTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) } } -func _OneofStdTypes_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*OneofStdTypes) - // OneOfStdTimes - switch x := m.OneOfStdTimes.(type) { - case *OneofStdTypes_Timestamp: - _ = b.EncodeVarint(1<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdTimeMarshal(*x.Timestamp) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_Duration: - _ = b.EncodeVarint(2<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdDurationMarshal(*x.Duration) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepDouble: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdDoubleMarshal(*x.RepDouble) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepFloat: - _ = b.EncodeVarint(4<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdFloatMarshal(*x.RepFloat) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepInt64: - _ = b.EncodeVarint(5<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdInt64Marshal(*x.RepInt64) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepUInt64: - _ = b.EncodeVarint(6<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdUInt64Marshal(*x.RepUInt64) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepInt32: - _ = b.EncodeVarint(7<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdInt32Marshal(*x.RepInt32) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepUInt32: - _ = b.EncodeVarint(8<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdUInt32Marshal(*x.RepUInt32) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepBool: - _ = b.EncodeVarint(9<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdBoolMarshal(*x.RepBool) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepString: - _ = b.EncodeVarint(10<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdStringMarshal(*x.RepString) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepBytes: - _ = b.EncodeVarint(11<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdBytesMarshal(*x.RepBytes) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("OneofStdTypes.OneOfStdTimes has unexpected type %T", x) - } - return nil -} - -func _OneofStdTypes_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*OneofStdTypes) - switch tag { - case 1: // OneOfStdTimes.timestamp - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(time.Time) - if err2 := github_com_gogo_protobuf_types.StdTimeUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_Timestamp{c} - return true, err - case 2: // OneOfStdTimes.duration - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(time.Duration) - if err2 := github_com_gogo_protobuf_types.StdDurationUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_Duration{c} - return true, err - case 3: // OneOfStdTimes.repDouble - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(float64) - if err2 := github_com_gogo_protobuf_types.StdDoubleUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepDouble{c} - return true, err - case 4: // OneOfStdTimes.repFloat - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(float32) - if err2 := github_com_gogo_protobuf_types.StdFloatUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepFloat{c} - return true, err - case 5: // OneOfStdTimes.repInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(int64) - if err2 := github_com_gogo_protobuf_types.StdInt64Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepInt64{c} - return true, err - case 6: // OneOfStdTimes.repUInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(uint64) - if err2 := github_com_gogo_protobuf_types.StdUInt64Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepUInt64{c} - return true, err - case 7: // OneOfStdTimes.repInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(int32) - if err2 := github_com_gogo_protobuf_types.StdInt32Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepInt32{c} - return true, err - case 8: // OneOfStdTimes.repUInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(uint32) - if err2 := github_com_gogo_protobuf_types.StdUInt32Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepUInt32{c} - return true, err - case 9: // OneOfStdTimes.repBool - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(bool) - if err2 := github_com_gogo_protobuf_types.StdBoolUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepBool{c} - return true, err - case 10: // OneOfStdTimes.repString - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(string) - if err2 := github_com_gogo_protobuf_types.StdStringUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepString{c} - return true, err - case 11: // OneOfStdTimes.repBytes - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new([]byte) - if err2 := github_com_gogo_protobuf_types.StdBytesUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepBytes{c} - return true, err - default: - return false, nil - } -} - -func _OneofStdTypes_OneofSizer(msg proto.Message) (n int) { - m := msg.(*OneofStdTypes) - // OneOfStdTimes - switch x := m.OneOfStdTimes.(type) { - case *OneofStdTypes_Timestamp: - s := github_com_gogo_protobuf_types.SizeOfStdTime(*x.Timestamp) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_Duration: - s := github_com_gogo_protobuf_types.SizeOfStdDuration(*x.Duration) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepDouble: - s := github_com_gogo_protobuf_types.SizeOfStdDouble(*x.RepDouble) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepFloat: - s := github_com_gogo_protobuf_types.SizeOfStdFloat(*x.RepFloat) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepInt64: - s := github_com_gogo_protobuf_types.SizeOfStdInt64(*x.RepInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepUInt64: - s := github_com_gogo_protobuf_types.SizeOfStdUInt64(*x.RepUInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepInt32: - s := github_com_gogo_protobuf_types.SizeOfStdInt32(*x.RepInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepUInt32: - s := github_com_gogo_protobuf_types.SizeOfStdUInt32(*x.RepUInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepBool: - s := github_com_gogo_protobuf_types.SizeOfStdBool(*x.RepBool) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepString: - s := github_com_gogo_protobuf_types.SizeOfStdString(*x.RepString) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepBytes: - s := github_com_gogo_protobuf_types.SizeOfStdBytes(*x.RepBytes) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*KnownTypes)(nil), "types.KnownTypes") proto.RegisterType((*ProtoTypes)(nil), "types.ProtoTypes") diff --git a/test/types/combos/marshaler/types.pb.go b/test/types/combos/marshaler/types.pb.go index 5d965ab211..c5e2a397a0 100644 --- a/test/types/combos/marshaler/types.pb.go +++ b/test/types/combos/marshaler/types.pb.go @@ -25,7 +25,7 @@ var _ = time.Kitchen // 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type KnownTypes struct { Dur *types.Duration `protobuf:"bytes,1,opt,name=dur,proto3" json:"dur,omitempty"` @@ -1643,9 +1643,9 @@ func (m *OneofProtoTypes) GetRepBytes() *types.BytesValue { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*OneofProtoTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _OneofProtoTypes_OneofMarshaler, _OneofProtoTypes_OneofUnmarshaler, _OneofProtoTypes_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*OneofProtoTypes) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*OneofProtoTypes_Timestamp)(nil), (*OneofProtoTypes_Duration)(nil), (*OneofProtoTypes_RepDouble)(nil), @@ -1660,234 +1660,6 @@ func (*OneofProtoTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffe } } -func _OneofProtoTypes_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*OneofProtoTypes) - // OneOfProtoTimes - switch x := m.OneOfProtoTimes.(type) { - case *OneofProtoTypes_Timestamp: - _ = b.EncodeVarint(1<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.Timestamp); err != nil { - return err - } - case *OneofProtoTypes_Duration: - _ = b.EncodeVarint(2<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.Duration); err != nil { - return err - } - case *OneofProtoTypes_RepDouble: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepDouble); err != nil { - return err - } - case *OneofProtoTypes_RepFloat: - _ = b.EncodeVarint(4<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepFloat); err != nil { - return err - } - case *OneofProtoTypes_RepInt64: - _ = b.EncodeVarint(5<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepInt64); err != nil { - return err - } - case *OneofProtoTypes_RepUInt64: - _ = b.EncodeVarint(6<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepUInt64); err != nil { - return err - } - case *OneofProtoTypes_RepInt32: - _ = b.EncodeVarint(7<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepInt32); err != nil { - return err - } - case *OneofProtoTypes_RepUInt32: - _ = b.EncodeVarint(8<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepUInt32); err != nil { - return err - } - case *OneofProtoTypes_RepBool: - _ = b.EncodeVarint(9<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepBool); err != nil { - return err - } - case *OneofProtoTypes_RepString: - _ = b.EncodeVarint(10<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepString); err != nil { - return err - } - case *OneofProtoTypes_RepBytes: - _ = b.EncodeVarint(11<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepBytes); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("OneofProtoTypes.OneOfProtoTimes has unexpected type %T", x) - } - return nil -} - -func _OneofProtoTypes_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*OneofProtoTypes) - switch tag { - case 1: // OneOfProtoTimes.timestamp - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Timestamp) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_Timestamp{msg} - return true, err - case 2: // OneOfProtoTimes.duration - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Duration) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_Duration{msg} - return true, err - case 3: // OneOfProtoTimes.repDouble - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.DoubleValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepDouble{msg} - return true, err - case 4: // OneOfProtoTimes.repFloat - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.FloatValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepFloat{msg} - return true, err - case 5: // OneOfProtoTimes.repInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Int64Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepInt64{msg} - return true, err - case 6: // OneOfProtoTimes.repUInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.UInt64Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepUInt64{msg} - return true, err - case 7: // OneOfProtoTimes.repInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Int32Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepInt32{msg} - return true, err - case 8: // OneOfProtoTimes.repUInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.UInt32Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepUInt32{msg} - return true, err - case 9: // OneOfProtoTimes.repBool - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.BoolValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepBool{msg} - return true, err - case 10: // OneOfProtoTimes.repString - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.StringValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepString{msg} - return true, err - case 11: // OneOfProtoTimes.repBytes - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.BytesValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepBytes{msg} - return true, err - default: - return false, nil - } -} - -func _OneofProtoTypes_OneofSizer(msg proto.Message) (n int) { - m := msg.(*OneofProtoTypes) - // OneOfProtoTimes - switch x := m.OneOfProtoTimes.(type) { - case *OneofProtoTypes_Timestamp: - s := proto.Size(x.Timestamp) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_Duration: - s := proto.Size(x.Duration) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepDouble: - s := proto.Size(x.RepDouble) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepFloat: - s := proto.Size(x.RepFloat) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepInt64: - s := proto.Size(x.RepInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepUInt64: - s := proto.Size(x.RepUInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepInt32: - s := proto.Size(x.RepInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepUInt32: - s := proto.Size(x.RepUInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepBool: - s := proto.Size(x.RepBool) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepString: - s := proto.Size(x.RepString) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepBytes: - s := proto.Size(x.RepBytes) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type OneofStdTypes struct { // Types that are valid to be assigned to OneOfStdTimes: // *OneofStdTypes_Timestamp @@ -2078,9 +1850,9 @@ func (m *OneofStdTypes) GetRepBytes() *[]byte { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*OneofStdTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _OneofStdTypes_OneofMarshaler, _OneofStdTypes_OneofUnmarshaler, _OneofStdTypes_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*OneofStdTypes) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*OneofStdTypes_Timestamp)(nil), (*OneofStdTypes_Duration)(nil), (*OneofStdTypes_RepDouble)(nil), @@ -2095,344 +1867,6 @@ func (*OneofStdTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) } } -func _OneofStdTypes_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*OneofStdTypes) - // OneOfStdTimes - switch x := m.OneOfStdTimes.(type) { - case *OneofStdTypes_Timestamp: - _ = b.EncodeVarint(1<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdTimeMarshal(*x.Timestamp) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_Duration: - _ = b.EncodeVarint(2<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdDurationMarshal(*x.Duration) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepDouble: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdDoubleMarshal(*x.RepDouble) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepFloat: - _ = b.EncodeVarint(4<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdFloatMarshal(*x.RepFloat) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepInt64: - _ = b.EncodeVarint(5<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdInt64Marshal(*x.RepInt64) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepUInt64: - _ = b.EncodeVarint(6<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdUInt64Marshal(*x.RepUInt64) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepInt32: - _ = b.EncodeVarint(7<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdInt32Marshal(*x.RepInt32) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepUInt32: - _ = b.EncodeVarint(8<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdUInt32Marshal(*x.RepUInt32) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepBool: - _ = b.EncodeVarint(9<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdBoolMarshal(*x.RepBool) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepString: - _ = b.EncodeVarint(10<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdStringMarshal(*x.RepString) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepBytes: - _ = b.EncodeVarint(11<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdBytesMarshal(*x.RepBytes) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("OneofStdTypes.OneOfStdTimes has unexpected type %T", x) - } - return nil -} - -func _OneofStdTypes_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*OneofStdTypes) - switch tag { - case 1: // OneOfStdTimes.timestamp - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(time.Time) - if err2 := github_com_gogo_protobuf_types.StdTimeUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_Timestamp{c} - return true, err - case 2: // OneOfStdTimes.duration - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(time.Duration) - if err2 := github_com_gogo_protobuf_types.StdDurationUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_Duration{c} - return true, err - case 3: // OneOfStdTimes.repDouble - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(float64) - if err2 := github_com_gogo_protobuf_types.StdDoubleUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepDouble{c} - return true, err - case 4: // OneOfStdTimes.repFloat - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(float32) - if err2 := github_com_gogo_protobuf_types.StdFloatUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepFloat{c} - return true, err - case 5: // OneOfStdTimes.repInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(int64) - if err2 := github_com_gogo_protobuf_types.StdInt64Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepInt64{c} - return true, err - case 6: // OneOfStdTimes.repUInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(uint64) - if err2 := github_com_gogo_protobuf_types.StdUInt64Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepUInt64{c} - return true, err - case 7: // OneOfStdTimes.repInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(int32) - if err2 := github_com_gogo_protobuf_types.StdInt32Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepInt32{c} - return true, err - case 8: // OneOfStdTimes.repUInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(uint32) - if err2 := github_com_gogo_protobuf_types.StdUInt32Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepUInt32{c} - return true, err - case 9: // OneOfStdTimes.repBool - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(bool) - if err2 := github_com_gogo_protobuf_types.StdBoolUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepBool{c} - return true, err - case 10: // OneOfStdTimes.repString - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(string) - if err2 := github_com_gogo_protobuf_types.StdStringUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepString{c} - return true, err - case 11: // OneOfStdTimes.repBytes - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new([]byte) - if err2 := github_com_gogo_protobuf_types.StdBytesUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepBytes{c} - return true, err - default: - return false, nil - } -} - -func _OneofStdTypes_OneofSizer(msg proto.Message) (n int) { - m := msg.(*OneofStdTypes) - // OneOfStdTimes - switch x := m.OneOfStdTimes.(type) { - case *OneofStdTypes_Timestamp: - s := github_com_gogo_protobuf_types.SizeOfStdTime(*x.Timestamp) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_Duration: - s := github_com_gogo_protobuf_types.SizeOfStdDuration(*x.Duration) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepDouble: - s := github_com_gogo_protobuf_types.SizeOfStdDouble(*x.RepDouble) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepFloat: - s := github_com_gogo_protobuf_types.SizeOfStdFloat(*x.RepFloat) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepInt64: - s := github_com_gogo_protobuf_types.SizeOfStdInt64(*x.RepInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepUInt64: - s := github_com_gogo_protobuf_types.SizeOfStdUInt64(*x.RepUInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepInt32: - s := github_com_gogo_protobuf_types.SizeOfStdInt32(*x.RepInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepUInt32: - s := github_com_gogo_protobuf_types.SizeOfStdUInt32(*x.RepUInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepBool: - s := github_com_gogo_protobuf_types.SizeOfStdBool(*x.RepBool) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepString: - s := github_com_gogo_protobuf_types.SizeOfStdString(*x.RepString) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepBytes: - s := github_com_gogo_protobuf_types.SizeOfStdBytes(*x.RepBytes) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*KnownTypes)(nil), "types.KnownTypes") proto.RegisterType((*ProtoTypes)(nil), "types.ProtoTypes") diff --git a/test/types/combos/neither/types.pb.go b/test/types/combos/neither/types.pb.go index 1c177472e7..a023702ccd 100644 --- a/test/types/combos/neither/types.pb.go +++ b/test/types/combos/neither/types.pb.go @@ -25,7 +25,7 @@ var _ = time.Kitchen // 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type KnownTypes struct { Dur *types.Duration `protobuf:"bytes,1,opt,name=dur,proto3" json:"dur,omitempty"` @@ -1570,9 +1570,9 @@ func (m *OneofProtoTypes) GetRepBytes() *types.BytesValue { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*OneofProtoTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _OneofProtoTypes_OneofMarshaler, _OneofProtoTypes_OneofUnmarshaler, _OneofProtoTypes_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*OneofProtoTypes) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*OneofProtoTypes_Timestamp)(nil), (*OneofProtoTypes_Duration)(nil), (*OneofProtoTypes_RepDouble)(nil), @@ -1587,234 +1587,6 @@ func (*OneofProtoTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffe } } -func _OneofProtoTypes_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*OneofProtoTypes) - // OneOfProtoTimes - switch x := m.OneOfProtoTimes.(type) { - case *OneofProtoTypes_Timestamp: - _ = b.EncodeVarint(1<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.Timestamp); err != nil { - return err - } - case *OneofProtoTypes_Duration: - _ = b.EncodeVarint(2<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.Duration); err != nil { - return err - } - case *OneofProtoTypes_RepDouble: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepDouble); err != nil { - return err - } - case *OneofProtoTypes_RepFloat: - _ = b.EncodeVarint(4<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepFloat); err != nil { - return err - } - case *OneofProtoTypes_RepInt64: - _ = b.EncodeVarint(5<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepInt64); err != nil { - return err - } - case *OneofProtoTypes_RepUInt64: - _ = b.EncodeVarint(6<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepUInt64); err != nil { - return err - } - case *OneofProtoTypes_RepInt32: - _ = b.EncodeVarint(7<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepInt32); err != nil { - return err - } - case *OneofProtoTypes_RepUInt32: - _ = b.EncodeVarint(8<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepUInt32); err != nil { - return err - } - case *OneofProtoTypes_RepBool: - _ = b.EncodeVarint(9<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepBool); err != nil { - return err - } - case *OneofProtoTypes_RepString: - _ = b.EncodeVarint(10<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepString); err != nil { - return err - } - case *OneofProtoTypes_RepBytes: - _ = b.EncodeVarint(11<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepBytes); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("OneofProtoTypes.OneOfProtoTimes has unexpected type %T", x) - } - return nil -} - -func _OneofProtoTypes_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*OneofProtoTypes) - switch tag { - case 1: // OneOfProtoTimes.timestamp - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Timestamp) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_Timestamp{msg} - return true, err - case 2: // OneOfProtoTimes.duration - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Duration) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_Duration{msg} - return true, err - case 3: // OneOfProtoTimes.repDouble - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.DoubleValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepDouble{msg} - return true, err - case 4: // OneOfProtoTimes.repFloat - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.FloatValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepFloat{msg} - return true, err - case 5: // OneOfProtoTimes.repInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Int64Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepInt64{msg} - return true, err - case 6: // OneOfProtoTimes.repUInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.UInt64Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepUInt64{msg} - return true, err - case 7: // OneOfProtoTimes.repInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Int32Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepInt32{msg} - return true, err - case 8: // OneOfProtoTimes.repUInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.UInt32Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepUInt32{msg} - return true, err - case 9: // OneOfProtoTimes.repBool - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.BoolValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepBool{msg} - return true, err - case 10: // OneOfProtoTimes.repString - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.StringValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepString{msg} - return true, err - case 11: // OneOfProtoTimes.repBytes - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.BytesValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepBytes{msg} - return true, err - default: - return false, nil - } -} - -func _OneofProtoTypes_OneofSizer(msg proto.Message) (n int) { - m := msg.(*OneofProtoTypes) - // OneOfProtoTimes - switch x := m.OneOfProtoTimes.(type) { - case *OneofProtoTypes_Timestamp: - s := proto.Size(x.Timestamp) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_Duration: - s := proto.Size(x.Duration) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepDouble: - s := proto.Size(x.RepDouble) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepFloat: - s := proto.Size(x.RepFloat) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepInt64: - s := proto.Size(x.RepInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepUInt64: - s := proto.Size(x.RepUInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepInt32: - s := proto.Size(x.RepInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepUInt32: - s := proto.Size(x.RepUInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepBool: - s := proto.Size(x.RepBool) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepString: - s := proto.Size(x.RepString) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepBytes: - s := proto.Size(x.RepBytes) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type OneofStdTypes struct { // Types that are valid to be assigned to OneOfStdTimes: // *OneofStdTypes_Timestamp @@ -1995,9 +1767,9 @@ func (m *OneofStdTypes) GetRepBytes() *[]byte { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*OneofStdTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _OneofStdTypes_OneofMarshaler, _OneofStdTypes_OneofUnmarshaler, _OneofStdTypes_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*OneofStdTypes) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*OneofStdTypes_Timestamp)(nil), (*OneofStdTypes_Duration)(nil), (*OneofStdTypes_RepDouble)(nil), @@ -2012,344 +1784,6 @@ func (*OneofStdTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) } } -func _OneofStdTypes_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*OneofStdTypes) - // OneOfStdTimes - switch x := m.OneOfStdTimes.(type) { - case *OneofStdTypes_Timestamp: - _ = b.EncodeVarint(1<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdTimeMarshal(*x.Timestamp) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_Duration: - _ = b.EncodeVarint(2<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdDurationMarshal(*x.Duration) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepDouble: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdDoubleMarshal(*x.RepDouble) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepFloat: - _ = b.EncodeVarint(4<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdFloatMarshal(*x.RepFloat) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepInt64: - _ = b.EncodeVarint(5<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdInt64Marshal(*x.RepInt64) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepUInt64: - _ = b.EncodeVarint(6<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdUInt64Marshal(*x.RepUInt64) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepInt32: - _ = b.EncodeVarint(7<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdInt32Marshal(*x.RepInt32) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepUInt32: - _ = b.EncodeVarint(8<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdUInt32Marshal(*x.RepUInt32) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepBool: - _ = b.EncodeVarint(9<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdBoolMarshal(*x.RepBool) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepString: - _ = b.EncodeVarint(10<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdStringMarshal(*x.RepString) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepBytes: - _ = b.EncodeVarint(11<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdBytesMarshal(*x.RepBytes) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("OneofStdTypes.OneOfStdTimes has unexpected type %T", x) - } - return nil -} - -func _OneofStdTypes_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*OneofStdTypes) - switch tag { - case 1: // OneOfStdTimes.timestamp - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(time.Time) - if err2 := github_com_gogo_protobuf_types.StdTimeUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_Timestamp{c} - return true, err - case 2: // OneOfStdTimes.duration - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(time.Duration) - if err2 := github_com_gogo_protobuf_types.StdDurationUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_Duration{c} - return true, err - case 3: // OneOfStdTimes.repDouble - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(float64) - if err2 := github_com_gogo_protobuf_types.StdDoubleUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepDouble{c} - return true, err - case 4: // OneOfStdTimes.repFloat - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(float32) - if err2 := github_com_gogo_protobuf_types.StdFloatUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepFloat{c} - return true, err - case 5: // OneOfStdTimes.repInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(int64) - if err2 := github_com_gogo_protobuf_types.StdInt64Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepInt64{c} - return true, err - case 6: // OneOfStdTimes.repUInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(uint64) - if err2 := github_com_gogo_protobuf_types.StdUInt64Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepUInt64{c} - return true, err - case 7: // OneOfStdTimes.repInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(int32) - if err2 := github_com_gogo_protobuf_types.StdInt32Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepInt32{c} - return true, err - case 8: // OneOfStdTimes.repUInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(uint32) - if err2 := github_com_gogo_protobuf_types.StdUInt32Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepUInt32{c} - return true, err - case 9: // OneOfStdTimes.repBool - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(bool) - if err2 := github_com_gogo_protobuf_types.StdBoolUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepBool{c} - return true, err - case 10: // OneOfStdTimes.repString - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(string) - if err2 := github_com_gogo_protobuf_types.StdStringUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepString{c} - return true, err - case 11: // OneOfStdTimes.repBytes - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new([]byte) - if err2 := github_com_gogo_protobuf_types.StdBytesUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepBytes{c} - return true, err - default: - return false, nil - } -} - -func _OneofStdTypes_OneofSizer(msg proto.Message) (n int) { - m := msg.(*OneofStdTypes) - // OneOfStdTimes - switch x := m.OneOfStdTimes.(type) { - case *OneofStdTypes_Timestamp: - s := github_com_gogo_protobuf_types.SizeOfStdTime(*x.Timestamp) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_Duration: - s := github_com_gogo_protobuf_types.SizeOfStdDuration(*x.Duration) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepDouble: - s := github_com_gogo_protobuf_types.SizeOfStdDouble(*x.RepDouble) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepFloat: - s := github_com_gogo_protobuf_types.SizeOfStdFloat(*x.RepFloat) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepInt64: - s := github_com_gogo_protobuf_types.SizeOfStdInt64(*x.RepInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepUInt64: - s := github_com_gogo_protobuf_types.SizeOfStdUInt64(*x.RepUInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepInt32: - s := github_com_gogo_protobuf_types.SizeOfStdInt32(*x.RepInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepUInt32: - s := github_com_gogo_protobuf_types.SizeOfStdUInt32(*x.RepUInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepBool: - s := github_com_gogo_protobuf_types.SizeOfStdBool(*x.RepBool) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepString: - s := github_com_gogo_protobuf_types.SizeOfStdString(*x.RepString) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepBytes: - s := github_com_gogo_protobuf_types.SizeOfStdBytes(*x.RepBytes) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*KnownTypes)(nil), "types.KnownTypes") proto.RegisterType((*ProtoTypes)(nil), "types.ProtoTypes") diff --git a/test/types/combos/unmarshaler/types.pb.go b/test/types/combos/unmarshaler/types.pb.go index b59d5975c8..29583b28ea 100644 --- a/test/types/combos/unmarshaler/types.pb.go +++ b/test/types/combos/unmarshaler/types.pb.go @@ -26,7 +26,7 @@ var _ = time.Kitchen // 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type KnownTypes struct { Dur *types.Duration `protobuf:"bytes,1,opt,name=dur,proto3" json:"dur,omitempty"` @@ -1571,9 +1571,9 @@ func (m *OneofProtoTypes) GetRepBytes() *types.BytesValue { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*OneofProtoTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _OneofProtoTypes_OneofMarshaler, _OneofProtoTypes_OneofUnmarshaler, _OneofProtoTypes_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*OneofProtoTypes) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*OneofProtoTypes_Timestamp)(nil), (*OneofProtoTypes_Duration)(nil), (*OneofProtoTypes_RepDouble)(nil), @@ -1588,234 +1588,6 @@ func (*OneofProtoTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffe } } -func _OneofProtoTypes_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*OneofProtoTypes) - // OneOfProtoTimes - switch x := m.OneOfProtoTimes.(type) { - case *OneofProtoTypes_Timestamp: - _ = b.EncodeVarint(1<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.Timestamp); err != nil { - return err - } - case *OneofProtoTypes_Duration: - _ = b.EncodeVarint(2<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.Duration); err != nil { - return err - } - case *OneofProtoTypes_RepDouble: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepDouble); err != nil { - return err - } - case *OneofProtoTypes_RepFloat: - _ = b.EncodeVarint(4<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepFloat); err != nil { - return err - } - case *OneofProtoTypes_RepInt64: - _ = b.EncodeVarint(5<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepInt64); err != nil { - return err - } - case *OneofProtoTypes_RepUInt64: - _ = b.EncodeVarint(6<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepUInt64); err != nil { - return err - } - case *OneofProtoTypes_RepInt32: - _ = b.EncodeVarint(7<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepInt32); err != nil { - return err - } - case *OneofProtoTypes_RepUInt32: - _ = b.EncodeVarint(8<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepUInt32); err != nil { - return err - } - case *OneofProtoTypes_RepBool: - _ = b.EncodeVarint(9<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepBool); err != nil { - return err - } - case *OneofProtoTypes_RepString: - _ = b.EncodeVarint(10<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepString); err != nil { - return err - } - case *OneofProtoTypes_RepBytes: - _ = b.EncodeVarint(11<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.RepBytes); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("OneofProtoTypes.OneOfProtoTimes has unexpected type %T", x) - } - return nil -} - -func _OneofProtoTypes_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*OneofProtoTypes) - switch tag { - case 1: // OneOfProtoTimes.timestamp - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Timestamp) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_Timestamp{msg} - return true, err - case 2: // OneOfProtoTimes.duration - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Duration) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_Duration{msg} - return true, err - case 3: // OneOfProtoTimes.repDouble - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.DoubleValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepDouble{msg} - return true, err - case 4: // OneOfProtoTimes.repFloat - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.FloatValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepFloat{msg} - return true, err - case 5: // OneOfProtoTimes.repInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Int64Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepInt64{msg} - return true, err - case 6: // OneOfProtoTimes.repUInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.UInt64Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepUInt64{msg} - return true, err - case 7: // OneOfProtoTimes.repInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.Int32Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepInt32{msg} - return true, err - case 8: // OneOfProtoTimes.repUInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.UInt32Value) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepUInt32{msg} - return true, err - case 9: // OneOfProtoTimes.repBool - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.BoolValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepBool{msg} - return true, err - case 10: // OneOfProtoTimes.repString - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.StringValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepString{msg} - return true, err - case 11: // OneOfProtoTimes.repBytes - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(types.BytesValue) - err := b.DecodeMessage(msg) - m.OneOfProtoTimes = &OneofProtoTypes_RepBytes{msg} - return true, err - default: - return false, nil - } -} - -func _OneofProtoTypes_OneofSizer(msg proto.Message) (n int) { - m := msg.(*OneofProtoTypes) - // OneOfProtoTimes - switch x := m.OneOfProtoTimes.(type) { - case *OneofProtoTypes_Timestamp: - s := proto.Size(x.Timestamp) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_Duration: - s := proto.Size(x.Duration) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepDouble: - s := proto.Size(x.RepDouble) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepFloat: - s := proto.Size(x.RepFloat) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepInt64: - s := proto.Size(x.RepInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepUInt64: - s := proto.Size(x.RepUInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepInt32: - s := proto.Size(x.RepInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepUInt32: - s := proto.Size(x.RepUInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepBool: - s := proto.Size(x.RepBool) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepString: - s := proto.Size(x.RepString) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofProtoTypes_RepBytes: - s := proto.Size(x.RepBytes) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - type OneofStdTypes struct { // Types that are valid to be assigned to OneOfStdTimes: // *OneofStdTypes_Timestamp @@ -1996,9 +1768,9 @@ func (m *OneofStdTypes) GetRepBytes() *[]byte { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*OneofStdTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _OneofStdTypes_OneofMarshaler, _OneofStdTypes_OneofUnmarshaler, _OneofStdTypes_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*OneofStdTypes) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*OneofStdTypes_Timestamp)(nil), (*OneofStdTypes_Duration)(nil), (*OneofStdTypes_RepDouble)(nil), @@ -2013,344 +1785,6 @@ func (*OneofStdTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) } } -func _OneofStdTypes_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*OneofStdTypes) - // OneOfStdTimes - switch x := m.OneOfStdTimes.(type) { - case *OneofStdTypes_Timestamp: - _ = b.EncodeVarint(1<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdTimeMarshal(*x.Timestamp) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_Duration: - _ = b.EncodeVarint(2<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdDurationMarshal(*x.Duration) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepDouble: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdDoubleMarshal(*x.RepDouble) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepFloat: - _ = b.EncodeVarint(4<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdFloatMarshal(*x.RepFloat) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepInt64: - _ = b.EncodeVarint(5<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdInt64Marshal(*x.RepInt64) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepUInt64: - _ = b.EncodeVarint(6<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdUInt64Marshal(*x.RepUInt64) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepInt32: - _ = b.EncodeVarint(7<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdInt32Marshal(*x.RepInt32) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepUInt32: - _ = b.EncodeVarint(8<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdUInt32Marshal(*x.RepUInt32) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepBool: - _ = b.EncodeVarint(9<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdBoolMarshal(*x.RepBool) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepString: - _ = b.EncodeVarint(10<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdStringMarshal(*x.RepString) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case *OneofStdTypes_RepBytes: - _ = b.EncodeVarint(11<<3 | proto.WireBytes) - dAtA, err := github_com_gogo_protobuf_types.StdBytesMarshal(*x.RepBytes) - if err != nil { - return err - } - if err := b.EncodeRawBytes(dAtA); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("OneofStdTypes.OneOfStdTimes has unexpected type %T", x) - } - return nil -} - -func _OneofStdTypes_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*OneofStdTypes) - switch tag { - case 1: // OneOfStdTimes.timestamp - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(time.Time) - if err2 := github_com_gogo_protobuf_types.StdTimeUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_Timestamp{c} - return true, err - case 2: // OneOfStdTimes.duration - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(time.Duration) - if err2 := github_com_gogo_protobuf_types.StdDurationUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_Duration{c} - return true, err - case 3: // OneOfStdTimes.repDouble - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(float64) - if err2 := github_com_gogo_protobuf_types.StdDoubleUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepDouble{c} - return true, err - case 4: // OneOfStdTimes.repFloat - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(float32) - if err2 := github_com_gogo_protobuf_types.StdFloatUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepFloat{c} - return true, err - case 5: // OneOfStdTimes.repInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(int64) - if err2 := github_com_gogo_protobuf_types.StdInt64Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepInt64{c} - return true, err - case 6: // OneOfStdTimes.repUInt64 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(uint64) - if err2 := github_com_gogo_protobuf_types.StdUInt64Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepUInt64{c} - return true, err - case 7: // OneOfStdTimes.repInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(int32) - if err2 := github_com_gogo_protobuf_types.StdInt32Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepInt32{c} - return true, err - case 8: // OneOfStdTimes.repUInt32 - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(uint32) - if err2 := github_com_gogo_protobuf_types.StdUInt32Unmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepUInt32{c} - return true, err - case 9: // OneOfStdTimes.repBool - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(bool) - if err2 := github_com_gogo_protobuf_types.StdBoolUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepBool{c} - return true, err - case 10: // OneOfStdTimes.repString - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new(string) - if err2 := github_com_gogo_protobuf_types.StdStringUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepString{c} - return true, err - case 11: // OneOfStdTimes.repBytes - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - if err != nil { - return true, err - } - c := new([]byte) - if err2 := github_com_gogo_protobuf_types.StdBytesUnmarshal(c, x); err2 != nil { - return true, err - } - m.OneOfStdTimes = &OneofStdTypes_RepBytes{c} - return true, err - default: - return false, nil - } -} - -func _OneofStdTypes_OneofSizer(msg proto.Message) (n int) { - m := msg.(*OneofStdTypes) - // OneOfStdTimes - switch x := m.OneOfStdTimes.(type) { - case *OneofStdTypes_Timestamp: - s := github_com_gogo_protobuf_types.SizeOfStdTime(*x.Timestamp) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_Duration: - s := github_com_gogo_protobuf_types.SizeOfStdDuration(*x.Duration) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepDouble: - s := github_com_gogo_protobuf_types.SizeOfStdDouble(*x.RepDouble) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepFloat: - s := github_com_gogo_protobuf_types.SizeOfStdFloat(*x.RepFloat) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepInt64: - s := github_com_gogo_protobuf_types.SizeOfStdInt64(*x.RepInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepUInt64: - s := github_com_gogo_protobuf_types.SizeOfStdUInt64(*x.RepUInt64) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepInt32: - s := github_com_gogo_protobuf_types.SizeOfStdInt32(*x.RepInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepUInt32: - s := github_com_gogo_protobuf_types.SizeOfStdUInt32(*x.RepUInt32) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepBool: - s := github_com_gogo_protobuf_types.SizeOfStdBool(*x.RepBool) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepString: - s := github_com_gogo_protobuf_types.SizeOfStdString(*x.RepString) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *OneofStdTypes_RepBytes: - s := github_com_gogo_protobuf_types.SizeOfStdBytes(*x.RepBytes) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func init() { proto.RegisterType((*KnownTypes)(nil), "types.KnownTypes") proto.RegisterType((*ProtoTypes)(nil), "types.ProtoTypes") diff --git a/test/unmarshalmerge/unmarshalmerge.pb.go b/test/unmarshalmerge/unmarshalmerge.pb.go index 8f2c10f960..32d718fa27 100644 --- a/test/unmarshalmerge/unmarshalmerge.pb.go +++ b/test/unmarshalmerge/unmarshalmerge.pb.go @@ -25,7 +25,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Big struct { Sub *Sub `protobuf:"bytes,1,opt,name=Sub" json:"Sub,omitempty"` diff --git a/test/unrecognized/unrecognized.pb.go b/test/unrecognized/unrecognized.pb.go index 6f26e45bae..4522459c70 100644 --- a/test/unrecognized/unrecognized.pb.go +++ b/test/unrecognized/unrecognized.pb.go @@ -29,7 +29,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type A struct { Field1 *int64 `protobuf:"varint,2,opt,name=Field1" json:"Field1,omitempty"` diff --git a/test/unrecognizedgroup/unrecognizedgroup.pb.go b/test/unrecognizedgroup/unrecognizedgroup.pb.go index fae15e096b..9bb6f20c9b 100644 --- a/test/unrecognizedgroup/unrecognizedgroup.pb.go +++ b/test/unrecognizedgroup/unrecognizedgroup.pb.go @@ -29,7 +29,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type NewNoGroup struct { Field1 *int64 `protobuf:"varint,1,opt,name=Field1" json:"Field1,omitempty"` diff --git a/test/xxxfields/xxxfields.pb.go b/test/xxxfields/xxxfields.pb.go index ff96066b4b..ea6f78dc96 100644 --- a/test/xxxfields/xxxfields.pb.go +++ b/test/xxxfields/xxxfields.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type NativeWithSizeCache struct { Field1 *float64 `protobuf:"fixed64,1,opt,name=Field1" json:"Field1,omitempty"` diff --git a/types/any.pb.go b/types/any.pb.go index 4492d8205b..3074a3d8a0 100644 --- a/types/any.pb.go +++ b/types/any.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // `Any` contains an arbitrary serialized protocol buffer message along with a // URL that describes the type of the serialized message. diff --git a/types/api.pb.go b/types/api.pb.go index b09e3ffd16..61612e21a8 100644 --- a/types/api.pb.go +++ b/types/api.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Api is a light-weight descriptor for an API Interface. // diff --git a/types/duration.pb.go b/types/duration.pb.go index a8a11b81f9..32b957c2bd 100644 --- a/types/duration.pb.go +++ b/types/duration.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // A Duration represents a signed, fixed-length span of time represented // as a count of seconds and fractions of seconds at nanosecond diff --git a/types/empty.pb.go b/types/empty.pb.go index 560ed03cd9..b061be5e4b 100644 --- a/types/empty.pb.go +++ b/types/empty.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // A generic empty message that you can re-use to avoid defining duplicated // empty messages in your APIs. A typical example is to use it as the request diff --git a/types/field_mask.pb.go b/types/field_mask.pb.go index b2e5f5d8c8..61ef57e2ca 100644 --- a/types/field_mask.pb.go +++ b/types/field_mask.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // `FieldMask` represents a set of symbolic field paths, for example: // diff --git a/types/source_context.pb.go b/types/source_context.pb.go index cf01b4c071..9b0752ed50 100644 --- a/types/source_context.pb.go +++ b/types/source_context.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // `SourceContext` represents information about the source of a // protobuf element, like the file in which it is defined. diff --git a/types/struct.pb.go b/types/struct.pb.go index 03fa99c105..f0a2d36ebb 100644 --- a/types/struct.pb.go +++ b/types/struct.pb.go @@ -26,7 +26,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // `NullValue` is a singleton enumeration to represent the null value for the // `Value` type union. @@ -251,9 +251,9 @@ func (m *Value) GetListValue() *ListValue { return nil } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*Value) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _Value_OneofMarshaler, _Value_OneofUnmarshaler, _Value_OneofSizer, []interface{}{ +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Value) XXX_OneofWrappers() []interface{} { + return []interface{}{ (*Value_NullValue)(nil), (*Value_NumberValue)(nil), (*Value_StringValue)(nil), @@ -263,129 +263,6 @@ func (*Value) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, } } -func _Value_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*Value) - // kind - switch x := m.Kind.(type) { - case *Value_NullValue: - _ = b.EncodeVarint(1<<3 | proto.WireVarint) - _ = b.EncodeVarint(uint64(x.NullValue)) - case *Value_NumberValue: - _ = b.EncodeVarint(2<<3 | proto.WireFixed64) - _ = b.EncodeFixed64(math.Float64bits(x.NumberValue)) - case *Value_StringValue: - _ = b.EncodeVarint(3<<3 | proto.WireBytes) - _ = b.EncodeStringBytes(x.StringValue) - case *Value_BoolValue: - t := uint64(0) - if x.BoolValue { - t = 1 - } - _ = b.EncodeVarint(4<<3 | proto.WireVarint) - _ = b.EncodeVarint(t) - case *Value_StructValue: - _ = b.EncodeVarint(5<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.StructValue); err != nil { - return err - } - case *Value_ListValue: - _ = b.EncodeVarint(6<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.ListValue); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("Value.Kind has unexpected type %T", x) - } - return nil -} - -func _Value_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*Value) - switch tag { - case 1: // kind.null_value - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Kind = &Value_NullValue{NullValue(x)} - return true, err - case 2: // kind.number_value - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.Kind = &Value_NumberValue{math.Float64frombits(x)} - return true, err - case 3: // kind.string_value - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Kind = &Value_StringValue{x} - return true, err - case 4: // kind.bool_value - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Kind = &Value_BoolValue{x != 0} - return true, err - case 5: // kind.struct_value - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Struct) - err := b.DecodeMessage(msg) - m.Kind = &Value_StructValue{msg} - return true, err - case 6: // kind.list_value - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(ListValue) - err := b.DecodeMessage(msg) - m.Kind = &Value_ListValue{msg} - return true, err - default: - return false, nil - } -} - -func _Value_OneofSizer(msg proto.Message) (n int) { - m := msg.(*Value) - // kind - switch x := m.Kind.(type) { - case *Value_NullValue: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.NullValue)) - case *Value_NumberValue: - n += 1 // tag and wire - n += 8 - case *Value_StringValue: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.StringValue))) - n += len(x.StringValue) - case *Value_BoolValue: - n += 1 // tag and wire - n += 1 - case *Value_StructValue: - s := proto.Size(x.StructValue) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case *Value_ListValue: - s := proto.Size(x.ListValue) - n += 1 // tag and wire - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - func (*Value) XXX_MessageName() string { return "google.protobuf.Value" } diff --git a/types/timestamp.pb.go b/types/timestamp.pb.go index 928d2511a1..63975b8e57 100644 --- a/types/timestamp.pb.go +++ b/types/timestamp.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // A Timestamp represents a point in time independent of any time zone or local // calendar, encoded as a count of seconds and fractions of seconds at diff --git a/types/type.pb.go b/types/type.pb.go index e0adc52b2f..a3a4f354e9 100644 --- a/types/type.pb.go +++ b/types/type.pb.go @@ -24,7 +24,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // The syntax in which a protocol buffer element is defined. type Syntax int32 diff --git a/types/wrappers.pb.go b/types/wrappers.pb.go index fa1fd7ed3c..5628dffa40 100644 --- a/types/wrappers.pb.go +++ b/types/wrappers.pb.go @@ -24,7 +24,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Wrapper message for `double`. // diff --git a/vanity/test/fast/gogovanity.pb.go b/vanity/test/fast/gogovanity.pb.go index 05df307aef..b55a07177b 100644 --- a/vanity/test/fast/gogovanity.pb.go +++ b/vanity/test/fast/gogovanity.pb.go @@ -21,7 +21,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type B struct { String_ *string `protobuf:"bytes,1,opt,name=String" json:"String,omitempty"` diff --git a/vanity/test/fast/proto3.pb.go b/vanity/test/fast/proto3.pb.go index 2d590d7d7b..94252ac382 100644 --- a/vanity/test/fast/proto3.pb.go +++ b/vanity/test/fast/proto3.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Aproto3 struct { B string `protobuf:"bytes,1,opt,name=B,proto3" json:"B,omitempty"` diff --git a/vanity/test/fast/vanity.pb.go b/vanity/test/fast/vanity.pb.go index bedc089b9b..0bc25790d7 100644 --- a/vanity/test/fast/vanity.pb.go +++ b/vanity/test/fast/vanity.pb.go @@ -21,7 +21,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type A struct { Strings *string `protobuf:"bytes,1,opt,name=Strings" json:"Strings,omitempty"` diff --git a/vanity/test/faster/gogovanity.pb.go b/vanity/test/faster/gogovanity.pb.go index d05029e871..67a01b30b6 100644 --- a/vanity/test/faster/gogovanity.pb.go +++ b/vanity/test/faster/gogovanity.pb.go @@ -21,7 +21,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type B struct { String_ *string `protobuf:"bytes,1,opt,name=String" json:"String,omitempty"` diff --git a/vanity/test/faster/proto3.pb.go b/vanity/test/faster/proto3.pb.go index 5ec54e6792..6f6e54d810 100644 --- a/vanity/test/faster/proto3.pb.go +++ b/vanity/test/faster/proto3.pb.go @@ -20,7 +20,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Aproto3 struct { B string `protobuf:"bytes,1,opt,name=B,proto3" json:"B,omitempty"` diff --git a/vanity/test/faster/vanity.pb.go b/vanity/test/faster/vanity.pb.go index 4014132a62..ea93803c9c 100644 --- a/vanity/test/faster/vanity.pb.go +++ b/vanity/test/faster/vanity.pb.go @@ -21,7 +21,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type A struct { Strings string `protobuf:"bytes,1,opt,name=Strings" json:"Strings"` diff --git a/vanity/test/slick/gogovanity.pb.go b/vanity/test/slick/gogovanity.pb.go index a210491cb3..003aa3fd2e 100644 --- a/vanity/test/slick/gogovanity.pb.go +++ b/vanity/test/slick/gogovanity.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type B struct { String_ *string `protobuf:"bytes,1,opt,name=String" json:"String,omitempty"` diff --git a/vanity/test/slick/proto3.pb.go b/vanity/test/slick/proto3.pb.go index 3b73ff3a4d..6c5e00bea3 100644 --- a/vanity/test/slick/proto3.pb.go +++ b/vanity/test/slick/proto3.pb.go @@ -22,7 +22,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Aproto3 struct { B string `protobuf:"bytes,1,opt,name=B,proto3" json:"B,omitempty"` diff --git a/vanity/test/slick/vanity.pb.go b/vanity/test/slick/vanity.pb.go index 335d5f6e49..7c17b39094 100644 --- a/vanity/test/slick/vanity.pb.go +++ b/vanity/test/slick/vanity.pb.go @@ -23,7 +23,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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type A struct { Strings string `protobuf:"bytes,1,opt,name=Strings" json:"Strings"`