From 3a37a30530810c78794074aef279eb2846932bbf Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Wed, 27 Sep 2023 17:47:15 +0200 Subject: [PATCH] Implement support for Well-Known Type Wrappers Signed-off-by: Vicent Marti --- CONTRIBUTING.md | 17 + Makefile | 44 +- README.md | 24 + cmd/protoc-gen-go-vtproto/main.go | 62 +- .../test_messages_proto3_vtproto.pb.go | 2079 ++++------------- features/clone/clone.go | 33 +- features/equal/equal.go | 48 +- features/marshal/marshalto.go | 47 +- features/size/size.go | 17 +- features/unmarshal/unmarshal.go | 19 +- generator/generatedfile.go | 53 +- generator/generator.go | 89 +- protobuf.sh | 2 +- testproto/wkt/wkt.pb.go | 341 +++ testproto/wkt/wkt.proto | 26 + testproto/wkt/wkt_test.go | 64 + testproto/wkt/wkt_vtproto.pb.go | 1190 ++++++++++ types/known/anypb/any_vtproto.pb.go | 373 +++ types/known/durationpb/duration_vtproto.pb.go | 331 +++ types/known/emptypb/empty_vtproto.pb.go | 259 ++ .../fieldmaskpb/field_mask_vtproto.pb.go | 329 +++ .../known/timestamppb/timestamp_vtproto.pb.go | 331 +++ types/known/wrapperspb/wrappers_vtproto.pb.go | 1706 ++++++++++++++ 23 files changed, 5664 insertions(+), 1820 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 testproto/wkt/wkt.pb.go create mode 100644 testproto/wkt/wkt.proto create mode 100644 testproto/wkt/wkt_test.go create mode 100644 testproto/wkt/wkt_vtproto.pb.go create mode 100644 types/known/anypb/any_vtproto.pb.go create mode 100644 types/known/durationpb/duration_vtproto.pb.go create mode 100644 types/known/emptypb/empty_vtproto.pb.go create mode 100644 types/known/fieldmaskpb/field_mask_vtproto.pb.go create mode 100644 types/known/timestamppb/timestamp_vtproto.pb.go create mode 100644 types/known/wrapperspb/wrappers_vtproto.pb.go diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..19ab648 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,17 @@ +# Contributing to vtProtobuf + +## Workflow + +For all contributors, we recommend the standard [GitHub flow](https://guides.github.com/introduction/flow/) +based on [forking and pull requests](https://guides.github.com/activities/forking/). + +For significant changes, please [create an issue](https://github.com/planetscale/vtprotobuf/issues) +to let everyone know what you're planning to work on, and to track progress and design decisions. + +## Development + +### Protobuf version upgrade + +1. Bump protobuf version in [./protobuf.sh](./protobuf.sh)) (PROTOBUF_VERSION variable). +1. Run `./protobuf.sh` to download and build protobuf. +1. Run `make genall` to regenerate proto files with a new compiler version, including well-known types. diff --git a/Makefile b/Makefile index 04f2b40..805d633 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,17 @@ export GOBIN=$(PWD)/bin export PROTOBUF_ROOT=$(PWD)/_vendor/protobuf-21.12 -.PHONY: install test gen-conformance gen-include genall +.PHONY: test gen-conformance gen-include gen-wkt genall bin/protoc-gen-go bin/protoc-gen-go-vtproto -install: - go install -tags protolegacy google.golang.org/protobuf/cmd/protoc-gen-go +protoc-gen: bin/protoc-gen-go-vtproto bin/protoc-gen-go + +bin/protoc-gen-go-vtproto: go install -tags protolegacy ./cmd/protoc-gen-go-vtproto -# go install -tags protolegacy github.com/gogo/protobuf/protoc-gen-gofast -gen-conformance: +bin/protoc-gen-go: + go install -tags protolegacy google.golang.org/protobuf/cmd/protoc-gen-go + +gen-conformance: protoc-gen $(PROTOBUF_ROOT)/src/protoc \ --proto_path=$(PROTOBUF_ROOT) \ --go_out=conformance --plugin protoc-gen-go="${GOBIN}/protoc-gen-go" \ @@ -24,7 +27,7 @@ gen-conformance: src/google/protobuf/test_messages_proto3.proto \ conformance/conformance.proto -gen-include: +gen-include: bin/protoc-gen-go $(PROTOBUF_ROOT)/src/protoc \ --proto_path=include \ --go_out=include --plugin protoc-gen-go="${GOBIN}/protoc-gen-go" \ @@ -32,7 +35,20 @@ gen-include: github.com/planetscale/vtprotobuf/vtproto/ext.proto mv include/github.com/planetscale/vtprotobuf/vtproto/*.go ./vtproto -gen-testproto: +gen-wkt: bin/protoc-gen-go-vtproto + $(PROTOBUF_ROOT)/src/protoc \ + -I$(PROTOBUF_ROOT)/src \ + --plugin protoc-gen-go-vtproto="${GOBIN}/protoc-gen-go-vtproto" \ + --go-vtproto_out=. \ + --go-vtproto_opt=module=google.golang.org/protobuf,wrap=true \ + $(PROTOBUF_ROOT)/src/google/protobuf/any.proto \ + $(PROTOBUF_ROOT)/src/google/protobuf/duration.proto \ + $(PROTOBUF_ROOT)/src/google/protobuf/empty.proto \ + $(PROTOBUF_ROOT)/src/google/protobuf/field_mask.proto \ + $(PROTOBUF_ROOT)/src/google/protobuf/timestamp.proto \ + $(PROTOBUF_ROOT)/src/google/protobuf/wrappers.proto + +gen-testproto: gen-wkt-testproto protoc-gen $(PROTOBUF_ROOT)/src/protoc \ --proto_path=testproto \ --proto_path=include \ @@ -47,9 +63,19 @@ gen-testproto: testproto/proto2/scalars.proto \ || exit 1; -genall: install gen-include gen-conformance gen-testproto +gen-wkt-testproto: protoc-gen + $(PROTOBUF_ROOT)/src/protoc \ + --proto_path=testproto \ + --proto_path=include \ + --go_out=. --plugin protoc-gen-go="${GOBIN}/protoc-gen-go" \ + --go-vtproto_out=allow-empty=true:. --plugin protoc-gen-go-vtproto="${GOBIN}/protoc-gen-go-vtproto" \ + -I$(PROTOBUF_ROOT)/src \ + testproto/wkt/wkt.proto \ + || exit 1; + +genall: gen-include gen-conformance gen-testproto gen-wkt -test: install gen-conformance +test: protoc-gen gen-conformance go test -short ./... go test -count=1 ./conformance/... GOGC="off" go test -count=1 ./testproto/pool/... diff --git a/README.md b/README.md index b68318c..2b038c8 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,30 @@ The following features can be generated: 7. (Optional) Switch your RPC framework to use the optimized helpers (see following sections) +### Well-known types + +Several changes are needed in order to use pre-generated optimized code for well-known types. + +1. `go get github.com/planetscale/vtprotobuf` +1. Imports `google.golang.org/protobuf/types/known` should be replaced with `github.com/planetscale/vtprotobuf`. +1. `protoc` should be invoked with the following options: + +``` +protoc \ + --go_opt="Mgoogle/protobuf/any.proto=github.com/planetscale/vtprotobuf/types/known/any;anypb" \ + --go_opt="Mgoogle/protobuf/duration.proto=github.com/planetscale/vtprotobuf/types/known/duration;durationpb" \ + --go_opt="Mgoogle/protobuf/empty.proto=github.com/planetscale/vtprotobuf/types/known/empty;emptypb" \ + --go_opt="Mgoogle/protobuf/field_mask.proto=github.com/planetscale/vtprotobuf/types/known/field_mask;fieldmaskpb" \ + --go_opt="Mgoogle/protobuf/timestamp.proto=github.com/planetscale/vtprotobuf/types/known/timestamp;timestamppb" \ + --go_opt="Mgoogle/protobuf/wrappers.proto=github.com/planetscale/vtprotobuf/types/known/wrappers;wrapperspb" \ + --go-vtproto_opt="Mgoogle/protobuf/any.proto=github.com/planetscale/vtprotobuf/types/known/any;anypb" \ + --go-vtproto_opt="Mgoogle/protobuf/duration.proto=github.com/planetscale/vtprotobuf/types/known/duration;durationpb" \ + --go-vtproto_opt="Mgoogle/protobuf/empty.proto=github.com/planetscale/vtprotobuf/types/known/empty;emptypb" \ + --go-vtproto_opt="Mgoogle/protobuf/field_mask.proto=github.com/planetscale/vtprotobuf/types/known/field_mask;fieldmaskpb" \ + --go-vtproto_opt="Mgoogle/protobuf/timestamp.proto=github.com/planetscale/vtprotobuf/types/known/timestamp;timestamppb" \ + --go-vtproto_opt="Mgoogle/protobuf/wrappers.proto=github.com/planetscale/vtprotobuf/types/known/wrappers;wrapperspb" +``` + ## Using the optimized code with RPC frameworks The `protoc-gen-go-vtproto` compiler does not overwrite any of the default marshalling or unmarshalling code for your ProtoBuf objects. Instead, it generates helper methods that can be called explicitly to opt-in to faster (de)serialization. diff --git a/cmd/protoc-gen-go-vtproto/main.go b/cmd/protoc-gen-go-vtproto/main.go index 08cf96a..0f0016e 100644 --- a/cmd/protoc-gen-go-vtproto/main.go +++ b/cmd/protoc-gen-go-vtproto/main.go @@ -2,7 +2,6 @@ package main import ( "flag" - "fmt" "strings" _ "github.com/planetscale/vtprotobuf/features/clone" @@ -15,64 +14,25 @@ import ( "github.com/planetscale/vtprotobuf/generator" "google.golang.org/protobuf/compiler/protogen" - "google.golang.org/protobuf/types/pluginpb" ) -type ObjectSet map[protogen.GoIdent]bool - -func (o ObjectSet) String() string { - return fmt.Sprintf("%#v", o) -} - -func (o ObjectSet) Set(s string) error { - idx := strings.LastIndexByte(s, '.') - if idx < 0 { - return fmt.Errorf("invalid object name: %q", s) - } - - ident := protogen.GoIdent{ - GoImportPath: protogen.GoImportPath(s[0:idx]), - GoName: s[idx+1:], - } - o[ident] = true - return nil -} - func main() { - var allowEmpty bool + var cfg generator.Config var features string - poolable := make(ObjectSet) var f flag.FlagSet - f.BoolVar(&allowEmpty, "allow-empty", false, "allow generation of empty files") - f.Var(poolable, "pool", "use memory pooling for this object") + f.BoolVar(&cfg.AllowEmpty, "allow-empty", false, "allow generation of empty files") + f.Var(&cfg.Poolable, "pool", "use memory pooling for this object") + f.BoolVar(&cfg.Wrap, "wrap", false, "generate wrapper types") + f.BoolVar(&cfg.WellKnownTypes, "wkt", true, "generate optimized code for well-known types") f.StringVar(&features, "features", "all", "list of features to generate (separated by '+')") protogen.Options{ParamFunc: f.Set}.Run(func(plugin *protogen.Plugin) error { - return generateAllFiles(plugin, strings.Split(features, "+"), poolable, allowEmpty) - }) -} - -var SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) - -func generateAllFiles(plugin *protogen.Plugin, featureNames []string, poolable ObjectSet, allowEmpty bool) error { - ext := &generator.Extensions{Poolable: poolable} - gen, err := generator.NewGenerator(plugin.Files, featureNames, ext) - if err != nil { - return err - } - - for _, file := range plugin.Files { - if !file.Generate { - continue + gen, err := generator.NewGenerator(plugin, strings.Split(features, "+"), &cfg) + if err != nil { + return err } - - gf := plugin.NewGeneratedFile(file.GeneratedFilenamePrefix+"_vtproto.pb.go", file.GoImportPath) - if !gen.GenerateFile(gf, file) && !allowEmpty { - gf.Skip() - } - } - - plugin.SupportedFeatures = SupportedFeatures - return nil + gen.Generate() + return nil + }) } diff --git a/conformance/internal/conformance/test_messages_proto3_vtproto.pb.go b/conformance/internal/conformance/test_messages_proto3_vtproto.pb.go index 140a5e6..0c7efe0 100644 --- a/conformance/internal/conformance/test_messages_proto3_vtproto.pb.go +++ b/conformance/internal/conformance/test_messages_proto3_vtproto.pb.go @@ -7,6 +7,11 @@ package conformance import ( binary "encoding/binary" fmt "fmt" + anypb1 "github.com/planetscale/vtprotobuf/types/known/anypb" + durationpb1 "github.com/planetscale/vtprotobuf/types/known/durationpb" + fieldmaskpb1 "github.com/planetscale/vtprotobuf/types/known/fieldmaskpb" + timestamppb1 "github.com/planetscale/vtprotobuf/types/known/timestamppb" + wrapperspb1 "github.com/planetscale/vtprotobuf/types/known/wrapperspb" proto "google.golang.org/protobuf/proto" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" @@ -71,6 +76,19 @@ func (m *TestAllTypesProto3) CloneVT() *TestAllTypesProto3 { r.OptionalStringPiece = m.OptionalStringPiece r.OptionalCord = m.OptionalCord r.RecursiveMessage = m.RecursiveMessage.CloneVT() + r.OptionalBoolWrapper = (*wrapperspb.BoolValue)((*wrapperspb1.BoolValue)(m.OptionalBoolWrapper).CloneVT()) + r.OptionalInt32Wrapper = (*wrapperspb.Int32Value)((*wrapperspb1.Int32Value)(m.OptionalInt32Wrapper).CloneVT()) + r.OptionalInt64Wrapper = (*wrapperspb.Int64Value)((*wrapperspb1.Int64Value)(m.OptionalInt64Wrapper).CloneVT()) + r.OptionalUint32Wrapper = (*wrapperspb.UInt32Value)((*wrapperspb1.UInt32Value)(m.OptionalUint32Wrapper).CloneVT()) + r.OptionalUint64Wrapper = (*wrapperspb.UInt64Value)((*wrapperspb1.UInt64Value)(m.OptionalUint64Wrapper).CloneVT()) + r.OptionalFloatWrapper = (*wrapperspb.FloatValue)((*wrapperspb1.FloatValue)(m.OptionalFloatWrapper).CloneVT()) + r.OptionalDoubleWrapper = (*wrapperspb.DoubleValue)((*wrapperspb1.DoubleValue)(m.OptionalDoubleWrapper).CloneVT()) + r.OptionalStringWrapper = (*wrapperspb.StringValue)((*wrapperspb1.StringValue)(m.OptionalStringWrapper).CloneVT()) + r.OptionalBytesWrapper = (*wrapperspb.BytesValue)((*wrapperspb1.BytesValue)(m.OptionalBytesWrapper).CloneVT()) + r.OptionalDuration = (*durationpb.Duration)((*durationpb1.Duration)(m.OptionalDuration).CloneVT()) + r.OptionalTimestamp = (*timestamppb.Timestamp)((*timestamppb1.Timestamp)(m.OptionalTimestamp).CloneVT()) + r.OptionalFieldMask = (*fieldmaskpb.FieldMask)((*fieldmaskpb1.FieldMask)(m.OptionalFieldMask).CloneVT()) + r.OptionalAny = (*anypb.Any)((*anypb1.Any)(m.OptionalAny).CloneVT()) r.OptionalNullValue = m.OptionalNullValue r.Fieldname1 = m.Fieldname1 r.FieldName2 = m.FieldName2 @@ -488,205 +506,69 @@ func (m *TestAllTypesProto3) CloneVT() *TestAllTypesProto3 { CloneVT() isTestAllTypesProto3_OneofField }).CloneVT() } - if rhs := m.OptionalBoolWrapper; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *wrapperspb.BoolValue }); ok { - r.OptionalBoolWrapper = vtpb.CloneVT() - } else { - r.OptionalBoolWrapper = proto.Clone(rhs).(*wrapperspb.BoolValue) - } - } - if rhs := m.OptionalInt32Wrapper; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *wrapperspb.Int32Value }); ok { - r.OptionalInt32Wrapper = vtpb.CloneVT() - } else { - r.OptionalInt32Wrapper = proto.Clone(rhs).(*wrapperspb.Int32Value) - } - } - if rhs := m.OptionalInt64Wrapper; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *wrapperspb.Int64Value }); ok { - r.OptionalInt64Wrapper = vtpb.CloneVT() - } else { - r.OptionalInt64Wrapper = proto.Clone(rhs).(*wrapperspb.Int64Value) - } - } - if rhs := m.OptionalUint32Wrapper; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface { - CloneVT() *wrapperspb.UInt32Value - }); ok { - r.OptionalUint32Wrapper = vtpb.CloneVT() - } else { - r.OptionalUint32Wrapper = proto.Clone(rhs).(*wrapperspb.UInt32Value) - } - } - if rhs := m.OptionalUint64Wrapper; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface { - CloneVT() *wrapperspb.UInt64Value - }); ok { - r.OptionalUint64Wrapper = vtpb.CloneVT() - } else { - r.OptionalUint64Wrapper = proto.Clone(rhs).(*wrapperspb.UInt64Value) - } - } - if rhs := m.OptionalFloatWrapper; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *wrapperspb.FloatValue }); ok { - r.OptionalFloatWrapper = vtpb.CloneVT() - } else { - r.OptionalFloatWrapper = proto.Clone(rhs).(*wrapperspb.FloatValue) - } - } - if rhs := m.OptionalDoubleWrapper; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface { - CloneVT() *wrapperspb.DoubleValue - }); ok { - r.OptionalDoubleWrapper = vtpb.CloneVT() - } else { - r.OptionalDoubleWrapper = proto.Clone(rhs).(*wrapperspb.DoubleValue) - } - } - if rhs := m.OptionalStringWrapper; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface { - CloneVT() *wrapperspb.StringValue - }); ok { - r.OptionalStringWrapper = vtpb.CloneVT() - } else { - r.OptionalStringWrapper = proto.Clone(rhs).(*wrapperspb.StringValue) - } - } - if rhs := m.OptionalBytesWrapper; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *wrapperspb.BytesValue }); ok { - r.OptionalBytesWrapper = vtpb.CloneVT() - } else { - r.OptionalBytesWrapper = proto.Clone(rhs).(*wrapperspb.BytesValue) - } - } if rhs := m.RepeatedBoolWrapper; rhs != nil { tmpContainer := make([]*wrapperspb.BoolValue, len(rhs)) for k, v := range rhs { - if vtpb, ok := interface{}(v).(interface{ CloneVT() *wrapperspb.BoolValue }); ok { - tmpContainer[k] = vtpb.CloneVT() - } else { - tmpContainer[k] = proto.Clone(v).(*wrapperspb.BoolValue) - } + tmpContainer[k] = (*wrapperspb.BoolValue)((*wrapperspb1.BoolValue)(v).CloneVT()) } r.RepeatedBoolWrapper = tmpContainer } if rhs := m.RepeatedInt32Wrapper; rhs != nil { tmpContainer := make([]*wrapperspb.Int32Value, len(rhs)) for k, v := range rhs { - if vtpb, ok := interface{}(v).(interface{ CloneVT() *wrapperspb.Int32Value }); ok { - tmpContainer[k] = vtpb.CloneVT() - } else { - tmpContainer[k] = proto.Clone(v).(*wrapperspb.Int32Value) - } + tmpContainer[k] = (*wrapperspb.Int32Value)((*wrapperspb1.Int32Value)(v).CloneVT()) } r.RepeatedInt32Wrapper = tmpContainer } if rhs := m.RepeatedInt64Wrapper; rhs != nil { tmpContainer := make([]*wrapperspb.Int64Value, len(rhs)) for k, v := range rhs { - if vtpb, ok := interface{}(v).(interface{ CloneVT() *wrapperspb.Int64Value }); ok { - tmpContainer[k] = vtpb.CloneVT() - } else { - tmpContainer[k] = proto.Clone(v).(*wrapperspb.Int64Value) - } + tmpContainer[k] = (*wrapperspb.Int64Value)((*wrapperspb1.Int64Value)(v).CloneVT()) } r.RepeatedInt64Wrapper = tmpContainer } if rhs := m.RepeatedUint32Wrapper; rhs != nil { tmpContainer := make([]*wrapperspb.UInt32Value, len(rhs)) for k, v := range rhs { - if vtpb, ok := interface{}(v).(interface { - CloneVT() *wrapperspb.UInt32Value - }); ok { - tmpContainer[k] = vtpb.CloneVT() - } else { - tmpContainer[k] = proto.Clone(v).(*wrapperspb.UInt32Value) - } + tmpContainer[k] = (*wrapperspb.UInt32Value)((*wrapperspb1.UInt32Value)(v).CloneVT()) } r.RepeatedUint32Wrapper = tmpContainer } if rhs := m.RepeatedUint64Wrapper; rhs != nil { tmpContainer := make([]*wrapperspb.UInt64Value, len(rhs)) for k, v := range rhs { - if vtpb, ok := interface{}(v).(interface { - CloneVT() *wrapperspb.UInt64Value - }); ok { - tmpContainer[k] = vtpb.CloneVT() - } else { - tmpContainer[k] = proto.Clone(v).(*wrapperspb.UInt64Value) - } + tmpContainer[k] = (*wrapperspb.UInt64Value)((*wrapperspb1.UInt64Value)(v).CloneVT()) } r.RepeatedUint64Wrapper = tmpContainer } if rhs := m.RepeatedFloatWrapper; rhs != nil { tmpContainer := make([]*wrapperspb.FloatValue, len(rhs)) for k, v := range rhs { - if vtpb, ok := interface{}(v).(interface{ CloneVT() *wrapperspb.FloatValue }); ok { - tmpContainer[k] = vtpb.CloneVT() - } else { - tmpContainer[k] = proto.Clone(v).(*wrapperspb.FloatValue) - } + tmpContainer[k] = (*wrapperspb.FloatValue)((*wrapperspb1.FloatValue)(v).CloneVT()) } r.RepeatedFloatWrapper = tmpContainer } if rhs := m.RepeatedDoubleWrapper; rhs != nil { tmpContainer := make([]*wrapperspb.DoubleValue, len(rhs)) for k, v := range rhs { - if vtpb, ok := interface{}(v).(interface { - CloneVT() *wrapperspb.DoubleValue - }); ok { - tmpContainer[k] = vtpb.CloneVT() - } else { - tmpContainer[k] = proto.Clone(v).(*wrapperspb.DoubleValue) - } + tmpContainer[k] = (*wrapperspb.DoubleValue)((*wrapperspb1.DoubleValue)(v).CloneVT()) } r.RepeatedDoubleWrapper = tmpContainer } if rhs := m.RepeatedStringWrapper; rhs != nil { tmpContainer := make([]*wrapperspb.StringValue, len(rhs)) for k, v := range rhs { - if vtpb, ok := interface{}(v).(interface { - CloneVT() *wrapperspb.StringValue - }); ok { - tmpContainer[k] = vtpb.CloneVT() - } else { - tmpContainer[k] = proto.Clone(v).(*wrapperspb.StringValue) - } + tmpContainer[k] = (*wrapperspb.StringValue)((*wrapperspb1.StringValue)(v).CloneVT()) } r.RepeatedStringWrapper = tmpContainer } if rhs := m.RepeatedBytesWrapper; rhs != nil { tmpContainer := make([]*wrapperspb.BytesValue, len(rhs)) for k, v := range rhs { - if vtpb, ok := interface{}(v).(interface{ CloneVT() *wrapperspb.BytesValue }); ok { - tmpContainer[k] = vtpb.CloneVT() - } else { - tmpContainer[k] = proto.Clone(v).(*wrapperspb.BytesValue) - } + tmpContainer[k] = (*wrapperspb.BytesValue)((*wrapperspb1.BytesValue)(v).CloneVT()) } r.RepeatedBytesWrapper = tmpContainer } - if rhs := m.OptionalDuration; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *durationpb.Duration }); ok { - r.OptionalDuration = vtpb.CloneVT() - } else { - r.OptionalDuration = proto.Clone(rhs).(*durationpb.Duration) - } - } - if rhs := m.OptionalTimestamp; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *timestamppb.Timestamp }); ok { - r.OptionalTimestamp = vtpb.CloneVT() - } else { - r.OptionalTimestamp = proto.Clone(rhs).(*timestamppb.Timestamp) - } - } - if rhs := m.OptionalFieldMask; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *fieldmaskpb.FieldMask }); ok { - r.OptionalFieldMask = vtpb.CloneVT() - } else { - r.OptionalFieldMask = proto.Clone(rhs).(*fieldmaskpb.FieldMask) - } - } if rhs := m.OptionalStruct; rhs != nil { if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *structpb.Struct }); ok { r.OptionalStruct = vtpb.CloneVT() @@ -694,13 +576,6 @@ func (m *TestAllTypesProto3) CloneVT() *TestAllTypesProto3 { r.OptionalStruct = proto.Clone(rhs).(*structpb.Struct) } } - if rhs := m.OptionalAny; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *anypb.Any }); ok { - r.OptionalAny = vtpb.CloneVT() - } else { - r.OptionalAny = proto.Clone(rhs).(*anypb.Any) - } - } if rhs := m.OptionalValue; rhs != nil { if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *structpb.Value }); ok { r.OptionalValue = vtpb.CloneVT() @@ -711,33 +586,21 @@ func (m *TestAllTypesProto3) CloneVT() *TestAllTypesProto3 { if rhs := m.RepeatedDuration; rhs != nil { tmpContainer := make([]*durationpb.Duration, len(rhs)) for k, v := range rhs { - if vtpb, ok := interface{}(v).(interface{ CloneVT() *durationpb.Duration }); ok { - tmpContainer[k] = vtpb.CloneVT() - } else { - tmpContainer[k] = proto.Clone(v).(*durationpb.Duration) - } + tmpContainer[k] = (*durationpb.Duration)((*durationpb1.Duration)(v).CloneVT()) } r.RepeatedDuration = tmpContainer } if rhs := m.RepeatedTimestamp; rhs != nil { tmpContainer := make([]*timestamppb.Timestamp, len(rhs)) for k, v := range rhs { - if vtpb, ok := interface{}(v).(interface{ CloneVT() *timestamppb.Timestamp }); ok { - tmpContainer[k] = vtpb.CloneVT() - } else { - tmpContainer[k] = proto.Clone(v).(*timestamppb.Timestamp) - } + tmpContainer[k] = (*timestamppb.Timestamp)((*timestamppb1.Timestamp)(v).CloneVT()) } r.RepeatedTimestamp = tmpContainer } if rhs := m.RepeatedFieldmask; rhs != nil { tmpContainer := make([]*fieldmaskpb.FieldMask, len(rhs)) for k, v := range rhs { - if vtpb, ok := interface{}(v).(interface{ CloneVT() *fieldmaskpb.FieldMask }); ok { - tmpContainer[k] = vtpb.CloneVT() - } else { - tmpContainer[k] = proto.Clone(v).(*fieldmaskpb.FieldMask) - } + tmpContainer[k] = (*fieldmaskpb.FieldMask)((*fieldmaskpb1.FieldMask)(v).CloneVT()) } r.RepeatedFieldmask = tmpContainer } @@ -755,11 +618,7 @@ func (m *TestAllTypesProto3) CloneVT() *TestAllTypesProto3 { if rhs := m.RepeatedAny; rhs != nil { tmpContainer := make([]*anypb.Any, len(rhs)) for k, v := range rhs { - if vtpb, ok := interface{}(v).(interface{ CloneVT() *anypb.Any }); ok { - tmpContainer[k] = vtpb.CloneVT() - } else { - tmpContainer[k] = proto.Clone(v).(*anypb.Any) - } + tmpContainer[k] = (*anypb.Any)((*anypb1.Any)(v).CloneVT()) } r.RepeatedAny = tmpContainer } @@ -1749,85 +1608,31 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { return false } } - if equal, ok := interface{}(this.OptionalBoolWrapper).(interface { - EqualVT(*wrapperspb.BoolValue) bool - }); ok { - if !equal.EqualVT(that.OptionalBoolWrapper) { - return false - } - } else if !proto.Equal(this.OptionalBoolWrapper, that.OptionalBoolWrapper) { + if !(*wrapperspb1.BoolValue)(this.OptionalBoolWrapper).EqualVT((*wrapperspb1.BoolValue)(that.OptionalBoolWrapper)) { return false } - if equal, ok := interface{}(this.OptionalInt32Wrapper).(interface { - EqualVT(*wrapperspb.Int32Value) bool - }); ok { - if !equal.EqualVT(that.OptionalInt32Wrapper) { - return false - } - } else if !proto.Equal(this.OptionalInt32Wrapper, that.OptionalInt32Wrapper) { + if !(*wrapperspb1.Int32Value)(this.OptionalInt32Wrapper).EqualVT((*wrapperspb1.Int32Value)(that.OptionalInt32Wrapper)) { return false } - if equal, ok := interface{}(this.OptionalInt64Wrapper).(interface { - EqualVT(*wrapperspb.Int64Value) bool - }); ok { - if !equal.EqualVT(that.OptionalInt64Wrapper) { - return false - } - } else if !proto.Equal(this.OptionalInt64Wrapper, that.OptionalInt64Wrapper) { + if !(*wrapperspb1.Int64Value)(this.OptionalInt64Wrapper).EqualVT((*wrapperspb1.Int64Value)(that.OptionalInt64Wrapper)) { return false } - if equal, ok := interface{}(this.OptionalUint32Wrapper).(interface { - EqualVT(*wrapperspb.UInt32Value) bool - }); ok { - if !equal.EqualVT(that.OptionalUint32Wrapper) { - return false - } - } else if !proto.Equal(this.OptionalUint32Wrapper, that.OptionalUint32Wrapper) { + if !(*wrapperspb1.UInt32Value)(this.OptionalUint32Wrapper).EqualVT((*wrapperspb1.UInt32Value)(that.OptionalUint32Wrapper)) { return false } - if equal, ok := interface{}(this.OptionalUint64Wrapper).(interface { - EqualVT(*wrapperspb.UInt64Value) bool - }); ok { - if !equal.EqualVT(that.OptionalUint64Wrapper) { - return false - } - } else if !proto.Equal(this.OptionalUint64Wrapper, that.OptionalUint64Wrapper) { + if !(*wrapperspb1.UInt64Value)(this.OptionalUint64Wrapper).EqualVT((*wrapperspb1.UInt64Value)(that.OptionalUint64Wrapper)) { return false } - if equal, ok := interface{}(this.OptionalFloatWrapper).(interface { - EqualVT(*wrapperspb.FloatValue) bool - }); ok { - if !equal.EqualVT(that.OptionalFloatWrapper) { - return false - } - } else if !proto.Equal(this.OptionalFloatWrapper, that.OptionalFloatWrapper) { + if !(*wrapperspb1.FloatValue)(this.OptionalFloatWrapper).EqualVT((*wrapperspb1.FloatValue)(that.OptionalFloatWrapper)) { return false } - if equal, ok := interface{}(this.OptionalDoubleWrapper).(interface { - EqualVT(*wrapperspb.DoubleValue) bool - }); ok { - if !equal.EqualVT(that.OptionalDoubleWrapper) { - return false - } - } else if !proto.Equal(this.OptionalDoubleWrapper, that.OptionalDoubleWrapper) { + if !(*wrapperspb1.DoubleValue)(this.OptionalDoubleWrapper).EqualVT((*wrapperspb1.DoubleValue)(that.OptionalDoubleWrapper)) { return false } - if equal, ok := interface{}(this.OptionalStringWrapper).(interface { - EqualVT(*wrapperspb.StringValue) bool - }); ok { - if !equal.EqualVT(that.OptionalStringWrapper) { - return false - } - } else if !proto.Equal(this.OptionalStringWrapper, that.OptionalStringWrapper) { + if !(*wrapperspb1.StringValue)(this.OptionalStringWrapper).EqualVT((*wrapperspb1.StringValue)(that.OptionalStringWrapper)) { return false } - if equal, ok := interface{}(this.OptionalBytesWrapper).(interface { - EqualVT(*wrapperspb.BytesValue) bool - }); ok { - if !equal.EqualVT(that.OptionalBytesWrapper) { - return false - } - } else if !proto.Equal(this.OptionalBytesWrapper, that.OptionalBytesWrapper) { + if !(*wrapperspb1.BytesValue)(this.OptionalBytesWrapper).EqualVT((*wrapperspb1.BytesValue)(that.OptionalBytesWrapper)) { return false } if len(this.RepeatedBoolWrapper) != len(that.RepeatedBoolWrapper) { @@ -1842,13 +1647,7 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { if q == nil { q = &wrapperspb.BoolValue{} } - if equal, ok := interface{}(p).(interface { - EqualVT(*wrapperspb.BoolValue) bool - }); ok { - if !equal.EqualVT(q) { - return false - } - } else if !proto.Equal(p, q) { + if !(*wrapperspb1.BoolValue)(p).EqualVT((*wrapperspb1.BoolValue)(q)) { return false } } @@ -1865,13 +1664,7 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { if q == nil { q = &wrapperspb.Int32Value{} } - if equal, ok := interface{}(p).(interface { - EqualVT(*wrapperspb.Int32Value) bool - }); ok { - if !equal.EqualVT(q) { - return false - } - } else if !proto.Equal(p, q) { + if !(*wrapperspb1.Int32Value)(p).EqualVT((*wrapperspb1.Int32Value)(q)) { return false } } @@ -1888,13 +1681,7 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { if q == nil { q = &wrapperspb.Int64Value{} } - if equal, ok := interface{}(p).(interface { - EqualVT(*wrapperspb.Int64Value) bool - }); ok { - if !equal.EqualVT(q) { - return false - } - } else if !proto.Equal(p, q) { + if !(*wrapperspb1.Int64Value)(p).EqualVT((*wrapperspb1.Int64Value)(q)) { return false } } @@ -1911,13 +1698,7 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { if q == nil { q = &wrapperspb.UInt32Value{} } - if equal, ok := interface{}(p).(interface { - EqualVT(*wrapperspb.UInt32Value) bool - }); ok { - if !equal.EqualVT(q) { - return false - } - } else if !proto.Equal(p, q) { + if !(*wrapperspb1.UInt32Value)(p).EqualVT((*wrapperspb1.UInt32Value)(q)) { return false } } @@ -1934,13 +1715,7 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { if q == nil { q = &wrapperspb.UInt64Value{} } - if equal, ok := interface{}(p).(interface { - EqualVT(*wrapperspb.UInt64Value) bool - }); ok { - if !equal.EqualVT(q) { - return false - } - } else if !proto.Equal(p, q) { + if !(*wrapperspb1.UInt64Value)(p).EqualVT((*wrapperspb1.UInt64Value)(q)) { return false } } @@ -1957,13 +1732,7 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { if q == nil { q = &wrapperspb.FloatValue{} } - if equal, ok := interface{}(p).(interface { - EqualVT(*wrapperspb.FloatValue) bool - }); ok { - if !equal.EqualVT(q) { - return false - } - } else if !proto.Equal(p, q) { + if !(*wrapperspb1.FloatValue)(p).EqualVT((*wrapperspb1.FloatValue)(q)) { return false } } @@ -1980,13 +1749,7 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { if q == nil { q = &wrapperspb.DoubleValue{} } - if equal, ok := interface{}(p).(interface { - EqualVT(*wrapperspb.DoubleValue) bool - }); ok { - if !equal.EqualVT(q) { - return false - } - } else if !proto.Equal(p, q) { + if !(*wrapperspb1.DoubleValue)(p).EqualVT((*wrapperspb1.DoubleValue)(q)) { return false } } @@ -2003,13 +1766,7 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { if q == nil { q = &wrapperspb.StringValue{} } - if equal, ok := interface{}(p).(interface { - EqualVT(*wrapperspb.StringValue) bool - }); ok { - if !equal.EqualVT(q) { - return false - } - } else if !proto.Equal(p, q) { + if !(*wrapperspb1.StringValue)(p).EqualVT((*wrapperspb1.StringValue)(q)) { return false } } @@ -2026,42 +1783,18 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { if q == nil { q = &wrapperspb.BytesValue{} } - if equal, ok := interface{}(p).(interface { - EqualVT(*wrapperspb.BytesValue) bool - }); ok { - if !equal.EqualVT(q) { - return false - } - } else if !proto.Equal(p, q) { + if !(*wrapperspb1.BytesValue)(p).EqualVT((*wrapperspb1.BytesValue)(q)) { return false } } } - if equal, ok := interface{}(this.OptionalDuration).(interface { - EqualVT(*durationpb.Duration) bool - }); ok { - if !equal.EqualVT(that.OptionalDuration) { - return false - } - } else if !proto.Equal(this.OptionalDuration, that.OptionalDuration) { + if !(*durationpb1.Duration)(this.OptionalDuration).EqualVT((*durationpb1.Duration)(that.OptionalDuration)) { return false } - if equal, ok := interface{}(this.OptionalTimestamp).(interface { - EqualVT(*timestamppb.Timestamp) bool - }); ok { - if !equal.EqualVT(that.OptionalTimestamp) { - return false - } - } else if !proto.Equal(this.OptionalTimestamp, that.OptionalTimestamp) { + if !(*timestamppb1.Timestamp)(this.OptionalTimestamp).EqualVT((*timestamppb1.Timestamp)(that.OptionalTimestamp)) { return false } - if equal, ok := interface{}(this.OptionalFieldMask).(interface { - EqualVT(*fieldmaskpb.FieldMask) bool - }); ok { - if !equal.EqualVT(that.OptionalFieldMask) { - return false - } - } else if !proto.Equal(this.OptionalFieldMask, that.OptionalFieldMask) { + if !(*fieldmaskpb1.FieldMask)(this.OptionalFieldMask).EqualVT((*fieldmaskpb1.FieldMask)(that.OptionalFieldMask)) { return false } if equal, ok := interface{}(this.OptionalStruct).(interface{ EqualVT(*structpb.Struct) bool }); ok { @@ -2071,11 +1804,7 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { } else if !proto.Equal(this.OptionalStruct, that.OptionalStruct) { return false } - if equal, ok := interface{}(this.OptionalAny).(interface{ EqualVT(*anypb.Any) bool }); ok { - if !equal.EqualVT(that.OptionalAny) { - return false - } - } else if !proto.Equal(this.OptionalAny, that.OptionalAny) { + if !(*anypb1.Any)(this.OptionalAny).EqualVT((*anypb1.Any)(that.OptionalAny)) { return false } if equal, ok := interface{}(this.OptionalValue).(interface{ EqualVT(*structpb.Value) bool }); ok { @@ -2100,13 +1829,7 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { if q == nil { q = &durationpb.Duration{} } - if equal, ok := interface{}(p).(interface { - EqualVT(*durationpb.Duration) bool - }); ok { - if !equal.EqualVT(q) { - return false - } - } else if !proto.Equal(p, q) { + if !(*durationpb1.Duration)(p).EqualVT((*durationpb1.Duration)(q)) { return false } } @@ -2123,13 +1846,7 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { if q == nil { q = ×tamppb.Timestamp{} } - if equal, ok := interface{}(p).(interface { - EqualVT(*timestamppb.Timestamp) bool - }); ok { - if !equal.EqualVT(q) { - return false - } - } else if !proto.Equal(p, q) { + if !(*timestamppb1.Timestamp)(p).EqualVT((*timestamppb1.Timestamp)(q)) { return false } } @@ -2146,13 +1863,7 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { if q == nil { q = &fieldmaskpb.FieldMask{} } - if equal, ok := interface{}(p).(interface { - EqualVT(*fieldmaskpb.FieldMask) bool - }); ok { - if !equal.EqualVT(q) { - return false - } - } else if !proto.Equal(p, q) { + if !(*fieldmaskpb1.FieldMask)(p).EqualVT((*fieldmaskpb1.FieldMask)(q)) { return false } } @@ -2169,11 +1880,7 @@ func (this *TestAllTypesProto3) EqualVT(that *TestAllTypesProto3) bool { if q == nil { q = &anypb.Any{} } - if equal, ok := interface{}(p).(interface{ EqualVT(*anypb.Any) bool }); ok { - if !equal.EqualVT(q) { - return false - } - } else if !proto.Equal(p, q) { + if !(*anypb1.Any)(p).EqualVT((*anypb1.Any)(q)) { return false } } @@ -2829,24 +2536,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } if len(m.RepeatedAny) > 0 { for iNdEx := len(m.RepeatedAny) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedAny[iNdEx]).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedAny[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*anypb1.Any)(m.RepeatedAny[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x13 i-- @@ -2855,24 +2550,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } if len(m.RepeatedFieldmask) > 0 { for iNdEx := len(m.RepeatedFieldmask) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedFieldmask[iNdEx]).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedFieldmask[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*fieldmaskpb1.FieldMask)(m.RepeatedFieldmask[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x13 i-- @@ -2881,25 +2564,13 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } if len(m.RepeatedTimestamp) > 0 { for iNdEx := len(m.RepeatedTimestamp) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedTimestamp[iNdEx]).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedTimestamp[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*timestamppb1.Timestamp)(m.RepeatedTimestamp[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } - i-- + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- dAtA[i] = 0x13 i-- dAtA[i] = 0xc2 @@ -2907,24 +2578,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } if len(m.RepeatedDuration) > 0 { for iNdEx := len(m.RepeatedDuration) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedDuration[iNdEx]).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedDuration[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*durationpb1.Duration)(m.RepeatedDuration[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x13 i-- @@ -2963,24 +2622,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { dAtA[i] = 0x92 } if m.OptionalAny != nil { - if vtmsg, ok := interface{}(m.OptionalAny).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalAny) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*anypb1.Any)(m.OptionalAny).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x13 i-- @@ -3011,72 +2658,36 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { dAtA[i] = 0x82 } if m.OptionalFieldMask != nil { - if vtmsg, ok := interface{}(m.OptionalFieldMask).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalFieldMask) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*fieldmaskpb1.FieldMask)(m.OptionalFieldMask).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x12 i-- dAtA[i] = 0xfa } if m.OptionalTimestamp != nil { - if vtmsg, ok := interface{}(m.OptionalTimestamp).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalTimestamp) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*timestamppb1.Timestamp)(m.OptionalTimestamp).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x12 i-- dAtA[i] = 0xf2 } if m.OptionalDuration != nil { - if vtmsg, ok := interface{}(m.OptionalDuration).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalDuration) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*durationpb1.Duration)(m.OptionalDuration).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x12 i-- @@ -3084,24 +2695,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } if len(m.RepeatedBytesWrapper) > 0 { for iNdEx := len(m.RepeatedBytesWrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedBytesWrapper[iNdEx]).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedBytesWrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.BytesValue)(m.RepeatedBytesWrapper[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -3110,24 +2709,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } if len(m.RepeatedStringWrapper) > 0 { for iNdEx := len(m.RepeatedStringWrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedStringWrapper[iNdEx]).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedStringWrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.StringValue)(m.RepeatedStringWrapper[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -3136,24 +2723,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } if len(m.RepeatedDoubleWrapper) > 0 { for iNdEx := len(m.RepeatedDoubleWrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedDoubleWrapper[iNdEx]).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedDoubleWrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.DoubleValue)(m.RepeatedDoubleWrapper[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -3162,24 +2737,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } if len(m.RepeatedFloatWrapper) > 0 { for iNdEx := len(m.RepeatedFloatWrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedFloatWrapper[iNdEx]).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedFloatWrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.FloatValue)(m.RepeatedFloatWrapper[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -3188,24 +2751,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } if len(m.RepeatedUint64Wrapper) > 0 { for iNdEx := len(m.RepeatedUint64Wrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedUint64Wrapper[iNdEx]).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedUint64Wrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.UInt64Value)(m.RepeatedUint64Wrapper[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -3214,24 +2765,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } if len(m.RepeatedUint32Wrapper) > 0 { for iNdEx := len(m.RepeatedUint32Wrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedUint32Wrapper[iNdEx]).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedUint32Wrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.UInt32Value)(m.RepeatedUint32Wrapper[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -3240,24 +2779,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } if len(m.RepeatedInt64Wrapper) > 0 { for iNdEx := len(m.RepeatedInt64Wrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedInt64Wrapper[iNdEx]).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedInt64Wrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.Int64Value)(m.RepeatedInt64Wrapper[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -3266,24 +2793,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } if len(m.RepeatedInt32Wrapper) > 0 { for iNdEx := len(m.RepeatedInt32Wrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedInt32Wrapper[iNdEx]).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedInt32Wrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.Int32Value)(m.RepeatedInt32Wrapper[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -3292,24 +2807,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } if len(m.RepeatedBoolWrapper) > 0 { for iNdEx := len(m.RepeatedBoolWrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedBoolWrapper[iNdEx]).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedBoolWrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.BoolValue)(m.RepeatedBoolWrapper[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -3317,216 +2820,108 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVT(dAtA []byte) (int, error) { } } if m.OptionalBytesWrapper != nil { - if vtmsg, ok := interface{}(m.OptionalBytesWrapper).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalBytesWrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.BytesValue)(m.OptionalBytesWrapper).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- dAtA[i] = 0x8a } if m.OptionalStringWrapper != nil { - if vtmsg, ok := interface{}(m.OptionalStringWrapper).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalStringWrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.StringValue)(m.OptionalStringWrapper).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- dAtA[i] = 0x82 } if m.OptionalDoubleWrapper != nil { - if vtmsg, ok := interface{}(m.OptionalDoubleWrapper).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalDoubleWrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.DoubleValue)(m.OptionalDoubleWrapper).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- dAtA[i] = 0xfa } if m.OptionalFloatWrapper != nil { - if vtmsg, ok := interface{}(m.OptionalFloatWrapper).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalFloatWrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.FloatValue)(m.OptionalFloatWrapper).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- dAtA[i] = 0xf2 } if m.OptionalUint64Wrapper != nil { - if vtmsg, ok := interface{}(m.OptionalUint64Wrapper).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalUint64Wrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.UInt64Value)(m.OptionalUint64Wrapper).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- dAtA[i] = 0xea } if m.OptionalUint32Wrapper != nil { - if vtmsg, ok := interface{}(m.OptionalUint32Wrapper).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalUint32Wrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.UInt32Value)(m.OptionalUint32Wrapper).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- dAtA[i] = 0xe2 } if m.OptionalInt64Wrapper != nil { - if vtmsg, ok := interface{}(m.OptionalInt64Wrapper).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalInt64Wrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.Int64Value)(m.OptionalInt64Wrapper).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- dAtA[i] = 0xda } if m.OptionalInt32Wrapper != nil { - if vtmsg, ok := interface{}(m.OptionalInt32Wrapper).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalInt32Wrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.Int32Value)(m.OptionalInt32Wrapper).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- dAtA[i] = 0xd2 } if m.OptionalBoolWrapper != nil { - if vtmsg, ok := interface{}(m.OptionalBoolWrapper).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalBoolWrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.BoolValue)(m.OptionalBoolWrapper).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- @@ -5335,24 +4730,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } if len(m.RepeatedAny) > 0 { for iNdEx := len(m.RepeatedAny) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedAny[iNdEx]).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedAny[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*anypb1.Any)(m.RepeatedAny[iNdEx]).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x13 i-- @@ -5361,24 +4744,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } if len(m.RepeatedFieldmask) > 0 { for iNdEx := len(m.RepeatedFieldmask) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedFieldmask[iNdEx]).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedFieldmask[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*fieldmaskpb1.FieldMask)(m.RepeatedFieldmask[iNdEx]).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x13 i-- @@ -5387,24 +4758,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } if len(m.RepeatedTimestamp) > 0 { for iNdEx := len(m.RepeatedTimestamp) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedTimestamp[iNdEx]).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedTimestamp[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*timestamppb1.Timestamp)(m.RepeatedTimestamp[iNdEx]).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x13 i-- @@ -5413,24 +4772,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } if len(m.RepeatedDuration) > 0 { for iNdEx := len(m.RepeatedDuration) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedDuration[iNdEx]).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedDuration[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*durationpb1.Duration)(m.RepeatedDuration[iNdEx]).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x13 i-- @@ -5469,24 +4816,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err dAtA[i] = 0x92 } if m.OptionalAny != nil { - if vtmsg, ok := interface{}(m.OptionalAny).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalAny) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*anypb1.Any)(m.OptionalAny).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x13 i-- @@ -5517,72 +4852,36 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err dAtA[i] = 0x82 } if m.OptionalFieldMask != nil { - if vtmsg, ok := interface{}(m.OptionalFieldMask).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalFieldMask) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*fieldmaskpb1.FieldMask)(m.OptionalFieldMask).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x12 i-- dAtA[i] = 0xfa } if m.OptionalTimestamp != nil { - if vtmsg, ok := interface{}(m.OptionalTimestamp).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalTimestamp) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*timestamppb1.Timestamp)(m.OptionalTimestamp).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x12 i-- dAtA[i] = 0xf2 } if m.OptionalDuration != nil { - if vtmsg, ok := interface{}(m.OptionalDuration).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalDuration) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*durationpb1.Duration)(m.OptionalDuration).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x12 i-- @@ -5590,24 +4889,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } if len(m.RepeatedBytesWrapper) > 0 { for iNdEx := len(m.RepeatedBytesWrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedBytesWrapper[iNdEx]).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedBytesWrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.BytesValue)(m.RepeatedBytesWrapper[iNdEx]).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -5616,24 +4903,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } if len(m.RepeatedStringWrapper) > 0 { for iNdEx := len(m.RepeatedStringWrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedStringWrapper[iNdEx]).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedStringWrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.StringValue)(m.RepeatedStringWrapper[iNdEx]).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -5642,24 +4917,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } if len(m.RepeatedDoubleWrapper) > 0 { for iNdEx := len(m.RepeatedDoubleWrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedDoubleWrapper[iNdEx]).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedDoubleWrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.DoubleValue)(m.RepeatedDoubleWrapper[iNdEx]).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -5668,24 +4931,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } if len(m.RepeatedFloatWrapper) > 0 { for iNdEx := len(m.RepeatedFloatWrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedFloatWrapper[iNdEx]).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedFloatWrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.FloatValue)(m.RepeatedFloatWrapper[iNdEx]).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -5694,24 +4945,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } if len(m.RepeatedUint64Wrapper) > 0 { for iNdEx := len(m.RepeatedUint64Wrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedUint64Wrapper[iNdEx]).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedUint64Wrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.UInt64Value)(m.RepeatedUint64Wrapper[iNdEx]).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -5720,24 +4959,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } if len(m.RepeatedUint32Wrapper) > 0 { for iNdEx := len(m.RepeatedUint32Wrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedUint32Wrapper[iNdEx]).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedUint32Wrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.UInt32Value)(m.RepeatedUint32Wrapper[iNdEx]).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -5746,24 +4973,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } if len(m.RepeatedInt64Wrapper) > 0 { for iNdEx := len(m.RepeatedInt64Wrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedInt64Wrapper[iNdEx]).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedInt64Wrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.Int64Value)(m.RepeatedInt64Wrapper[iNdEx]).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -5772,24 +4987,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } if len(m.RepeatedInt32Wrapper) > 0 { for iNdEx := len(m.RepeatedInt32Wrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedInt32Wrapper[iNdEx]).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedInt32Wrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.Int32Value)(m.RepeatedInt32Wrapper[iNdEx]).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -5798,24 +5001,12 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } if len(m.RepeatedBoolWrapper) > 0 { for iNdEx := len(m.RepeatedBoolWrapper) - 1; iNdEx >= 0; iNdEx-- { - if vtmsg, ok := interface{}(m.RepeatedBoolWrapper[iNdEx]).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.RepeatedBoolWrapper[iNdEx]) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.BoolValue)(m.RepeatedBoolWrapper[iNdEx]).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- @@ -5823,216 +5014,108 @@ func (m *TestAllTypesProto3) MarshalToSizedBufferVTStrict(dAtA []byte) (int, err } } if m.OptionalBytesWrapper != nil { - if vtmsg, ok := interface{}(m.OptionalBytesWrapper).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalBytesWrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.BytesValue)(m.OptionalBytesWrapper).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- dAtA[i] = 0x8a } if m.OptionalStringWrapper != nil { - if vtmsg, ok := interface{}(m.OptionalStringWrapper).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalStringWrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.StringValue)(m.OptionalStringWrapper).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xd i-- dAtA[i] = 0x82 - } - if m.OptionalDoubleWrapper != nil { - if vtmsg, ok := interface{}(m.OptionalDoubleWrapper).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalDoubleWrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + } + if m.OptionalDoubleWrapper != nil { + size, err := (*wrapperspb1.DoubleValue)(m.OptionalDoubleWrapper).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- dAtA[i] = 0xfa } if m.OptionalFloatWrapper != nil { - if vtmsg, ok := interface{}(m.OptionalFloatWrapper).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalFloatWrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.FloatValue)(m.OptionalFloatWrapper).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- dAtA[i] = 0xf2 } if m.OptionalUint64Wrapper != nil { - if vtmsg, ok := interface{}(m.OptionalUint64Wrapper).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalUint64Wrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.UInt64Value)(m.OptionalUint64Wrapper).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- dAtA[i] = 0xea } if m.OptionalUint32Wrapper != nil { - if vtmsg, ok := interface{}(m.OptionalUint32Wrapper).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalUint32Wrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.UInt32Value)(m.OptionalUint32Wrapper).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- dAtA[i] = 0xe2 } if m.OptionalInt64Wrapper != nil { - if vtmsg, ok := interface{}(m.OptionalInt64Wrapper).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalInt64Wrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.Int64Value)(m.OptionalInt64Wrapper).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- dAtA[i] = 0xda } if m.OptionalInt32Wrapper != nil { - if vtmsg, ok := interface{}(m.OptionalInt32Wrapper).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalInt32Wrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.Int32Value)(m.OptionalInt32Wrapper).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- dAtA[i] = 0xd2 } if m.OptionalBoolWrapper != nil { - if vtmsg, ok := interface{}(m.OptionalBoolWrapper).(interface { - MarshalToSizedBufferVTStrict([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.OptionalBoolWrapper) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) + size, err := (*wrapperspb1.BoolValue)(m.OptionalBoolWrapper).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0xc i-- @@ -8132,231 +7215,105 @@ func (m *TestAllTypesProto3) SizeVT() (n int) { n += vtmsg.SizeVT() } if m.OptionalBoolWrapper != nil { - if size, ok := interface{}(m.OptionalBoolWrapper).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.OptionalBoolWrapper) - } + l = (*wrapperspb1.BoolValue)(m.OptionalBoolWrapper).SizeVT() n += 2 + l + sov(uint64(l)) } if m.OptionalInt32Wrapper != nil { - if size, ok := interface{}(m.OptionalInt32Wrapper).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.OptionalInt32Wrapper) - } + l = (*wrapperspb1.Int32Value)(m.OptionalInt32Wrapper).SizeVT() n += 2 + l + sov(uint64(l)) } if m.OptionalInt64Wrapper != nil { - if size, ok := interface{}(m.OptionalInt64Wrapper).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.OptionalInt64Wrapper) - } + l = (*wrapperspb1.Int64Value)(m.OptionalInt64Wrapper).SizeVT() n += 2 + l + sov(uint64(l)) } if m.OptionalUint32Wrapper != nil { - if size, ok := interface{}(m.OptionalUint32Wrapper).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.OptionalUint32Wrapper) - } + l = (*wrapperspb1.UInt32Value)(m.OptionalUint32Wrapper).SizeVT() n += 2 + l + sov(uint64(l)) } if m.OptionalUint64Wrapper != nil { - if size, ok := interface{}(m.OptionalUint64Wrapper).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.OptionalUint64Wrapper) - } + l = (*wrapperspb1.UInt64Value)(m.OptionalUint64Wrapper).SizeVT() n += 2 + l + sov(uint64(l)) } if m.OptionalFloatWrapper != nil { - if size, ok := interface{}(m.OptionalFloatWrapper).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.OptionalFloatWrapper) - } + l = (*wrapperspb1.FloatValue)(m.OptionalFloatWrapper).SizeVT() n += 2 + l + sov(uint64(l)) } if m.OptionalDoubleWrapper != nil { - if size, ok := interface{}(m.OptionalDoubleWrapper).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.OptionalDoubleWrapper) - } + l = (*wrapperspb1.DoubleValue)(m.OptionalDoubleWrapper).SizeVT() n += 2 + l + sov(uint64(l)) } if m.OptionalStringWrapper != nil { - if size, ok := interface{}(m.OptionalStringWrapper).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.OptionalStringWrapper) - } + l = (*wrapperspb1.StringValue)(m.OptionalStringWrapper).SizeVT() n += 2 + l + sov(uint64(l)) } if m.OptionalBytesWrapper != nil { - if size, ok := interface{}(m.OptionalBytesWrapper).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.OptionalBytesWrapper) - } + l = (*wrapperspb1.BytesValue)(m.OptionalBytesWrapper).SizeVT() n += 2 + l + sov(uint64(l)) } if len(m.RepeatedBoolWrapper) > 0 { for _, e := range m.RepeatedBoolWrapper { - if size, ok := interface{}(e).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(e) - } + l = (*wrapperspb1.BoolValue)(e).SizeVT() n += 2 + l + sov(uint64(l)) } } if len(m.RepeatedInt32Wrapper) > 0 { for _, e := range m.RepeatedInt32Wrapper { - if size, ok := interface{}(e).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(e) - } + l = (*wrapperspb1.Int32Value)(e).SizeVT() n += 2 + l + sov(uint64(l)) } } if len(m.RepeatedInt64Wrapper) > 0 { for _, e := range m.RepeatedInt64Wrapper { - if size, ok := interface{}(e).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(e) - } + l = (*wrapperspb1.Int64Value)(e).SizeVT() n += 2 + l + sov(uint64(l)) } } if len(m.RepeatedUint32Wrapper) > 0 { for _, e := range m.RepeatedUint32Wrapper { - if size, ok := interface{}(e).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(e) - } + l = (*wrapperspb1.UInt32Value)(e).SizeVT() n += 2 + l + sov(uint64(l)) } } if len(m.RepeatedUint64Wrapper) > 0 { for _, e := range m.RepeatedUint64Wrapper { - if size, ok := interface{}(e).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(e) - } + l = (*wrapperspb1.UInt64Value)(e).SizeVT() n += 2 + l + sov(uint64(l)) } } if len(m.RepeatedFloatWrapper) > 0 { for _, e := range m.RepeatedFloatWrapper { - if size, ok := interface{}(e).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(e) - } + l = (*wrapperspb1.FloatValue)(e).SizeVT() n += 2 + l + sov(uint64(l)) } } if len(m.RepeatedDoubleWrapper) > 0 { for _, e := range m.RepeatedDoubleWrapper { - if size, ok := interface{}(e).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(e) - } + l = (*wrapperspb1.DoubleValue)(e).SizeVT() n += 2 + l + sov(uint64(l)) } } if len(m.RepeatedStringWrapper) > 0 { for _, e := range m.RepeatedStringWrapper { - if size, ok := interface{}(e).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(e) - } + l = (*wrapperspb1.StringValue)(e).SizeVT() n += 2 + l + sov(uint64(l)) } } if len(m.RepeatedBytesWrapper) > 0 { for _, e := range m.RepeatedBytesWrapper { - if size, ok := interface{}(e).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(e) - } + l = (*wrapperspb1.BytesValue)(e).SizeVT() n += 2 + l + sov(uint64(l)) } } if m.OptionalDuration != nil { - if size, ok := interface{}(m.OptionalDuration).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.OptionalDuration) - } + l = (*durationpb1.Duration)(m.OptionalDuration).SizeVT() n += 2 + l + sov(uint64(l)) } if m.OptionalTimestamp != nil { - if size, ok := interface{}(m.OptionalTimestamp).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.OptionalTimestamp) - } + l = (*timestamppb1.Timestamp)(m.OptionalTimestamp).SizeVT() n += 2 + l + sov(uint64(l)) } if m.OptionalFieldMask != nil { - if size, ok := interface{}(m.OptionalFieldMask).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.OptionalFieldMask) - } + l = (*fieldmaskpb1.FieldMask)(m.OptionalFieldMask).SizeVT() n += 2 + l + sov(uint64(l)) } if m.OptionalStruct != nil { @@ -8370,13 +7327,7 @@ func (m *TestAllTypesProto3) SizeVT() (n int) { n += 2 + l + sov(uint64(l)) } if m.OptionalAny != nil { - if size, ok := interface{}(m.OptionalAny).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.OptionalAny) - } + l = (*anypb1.Any)(m.OptionalAny).SizeVT() n += 2 + l + sov(uint64(l)) } if m.OptionalValue != nil { @@ -8393,50 +7344,26 @@ func (m *TestAllTypesProto3) SizeVT() (n int) { n += 2 + sov(uint64(m.OptionalNullValue)) } if len(m.RepeatedDuration) > 0 { - for _, e := range m.RepeatedDuration { - if size, ok := interface{}(e).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(e) - } + for _, e := range m.RepeatedDuration { + l = (*durationpb1.Duration)(e).SizeVT() n += 2 + l + sov(uint64(l)) } } if len(m.RepeatedTimestamp) > 0 { for _, e := range m.RepeatedTimestamp { - if size, ok := interface{}(e).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(e) - } + l = (*timestamppb1.Timestamp)(e).SizeVT() n += 2 + l + sov(uint64(l)) } } if len(m.RepeatedFieldmask) > 0 { for _, e := range m.RepeatedFieldmask { - if size, ok := interface{}(e).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(e) - } + l = (*fieldmaskpb1.FieldMask)(e).SizeVT() n += 2 + l + sov(uint64(l)) } } if len(m.RepeatedAny) > 0 { for _, e := range m.RepeatedAny { - if size, ok := interface{}(e).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(e) - } + l = (*anypb1.Any)(e).SizeVT() n += 2 + l + sov(uint64(l)) } } @@ -14519,16 +13446,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { if m.OptionalBoolWrapper == nil { m.OptionalBoolWrapper = &wrapperspb.BoolValue{} } - if unmarshal, ok := interface{}(m.OptionalBoolWrapper).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalBoolWrapper); err != nil { - return err - } + if err := (*wrapperspb1.BoolValue)(m.OptionalBoolWrapper).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 202: @@ -14563,16 +13482,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { if m.OptionalInt32Wrapper == nil { m.OptionalInt32Wrapper = &wrapperspb.Int32Value{} } - if unmarshal, ok := interface{}(m.OptionalInt32Wrapper).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalInt32Wrapper); err != nil { - return err - } + if err := (*wrapperspb1.Int32Value)(m.OptionalInt32Wrapper).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 203: @@ -14607,16 +13518,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { if m.OptionalInt64Wrapper == nil { m.OptionalInt64Wrapper = &wrapperspb.Int64Value{} } - if unmarshal, ok := interface{}(m.OptionalInt64Wrapper).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalInt64Wrapper); err != nil { - return err - } + if err := (*wrapperspb1.Int64Value)(m.OptionalInt64Wrapper).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 204: @@ -14651,16 +13554,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { if m.OptionalUint32Wrapper == nil { m.OptionalUint32Wrapper = &wrapperspb.UInt32Value{} } - if unmarshal, ok := interface{}(m.OptionalUint32Wrapper).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalUint32Wrapper); err != nil { - return err - } + if err := (*wrapperspb1.UInt32Value)(m.OptionalUint32Wrapper).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 205: @@ -14695,16 +13590,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { if m.OptionalUint64Wrapper == nil { m.OptionalUint64Wrapper = &wrapperspb.UInt64Value{} } - if unmarshal, ok := interface{}(m.OptionalUint64Wrapper).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalUint64Wrapper); err != nil { - return err - } + if err := (*wrapperspb1.UInt64Value)(m.OptionalUint64Wrapper).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 206: @@ -14739,16 +13626,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { if m.OptionalFloatWrapper == nil { m.OptionalFloatWrapper = &wrapperspb.FloatValue{} } - if unmarshal, ok := interface{}(m.OptionalFloatWrapper).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalFloatWrapper); err != nil { - return err - } + if err := (*wrapperspb1.FloatValue)(m.OptionalFloatWrapper).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 207: @@ -14783,16 +13662,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { if m.OptionalDoubleWrapper == nil { m.OptionalDoubleWrapper = &wrapperspb.DoubleValue{} } - if unmarshal, ok := interface{}(m.OptionalDoubleWrapper).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalDoubleWrapper); err != nil { - return err - } + if err := (*wrapperspb1.DoubleValue)(m.OptionalDoubleWrapper).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 208: @@ -14827,16 +13698,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { if m.OptionalStringWrapper == nil { m.OptionalStringWrapper = &wrapperspb.StringValue{} } - if unmarshal, ok := interface{}(m.OptionalStringWrapper).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalStringWrapper); err != nil { - return err - } + if err := (*wrapperspb1.StringValue)(m.OptionalStringWrapper).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 209: @@ -14871,16 +13734,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { if m.OptionalBytesWrapper == nil { m.OptionalBytesWrapper = &wrapperspb.BytesValue{} } - if unmarshal, ok := interface{}(m.OptionalBytesWrapper).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalBytesWrapper); err != nil { - return err - } + if err := (*wrapperspb1.BytesValue)(m.OptionalBytesWrapper).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 211: @@ -14913,16 +13768,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } m.RepeatedBoolWrapper = append(m.RepeatedBoolWrapper, &wrapperspb.BoolValue{}) - if unmarshal, ok := interface{}(m.RepeatedBoolWrapper[len(m.RepeatedBoolWrapper)-1]).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.RepeatedBoolWrapper[len(m.RepeatedBoolWrapper)-1]); err != nil { - return err - } + if err := (*wrapperspb1.BoolValue)(m.RepeatedBoolWrapper[len(m.RepeatedBoolWrapper)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 212: @@ -14955,16 +13802,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } m.RepeatedInt32Wrapper = append(m.RepeatedInt32Wrapper, &wrapperspb.Int32Value{}) - if unmarshal, ok := interface{}(m.RepeatedInt32Wrapper[len(m.RepeatedInt32Wrapper)-1]).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.RepeatedInt32Wrapper[len(m.RepeatedInt32Wrapper)-1]); err != nil { - return err - } + if err := (*wrapperspb1.Int32Value)(m.RepeatedInt32Wrapper[len(m.RepeatedInt32Wrapper)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 213: @@ -14997,16 +13836,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } m.RepeatedInt64Wrapper = append(m.RepeatedInt64Wrapper, &wrapperspb.Int64Value{}) - if unmarshal, ok := interface{}(m.RepeatedInt64Wrapper[len(m.RepeatedInt64Wrapper)-1]).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.RepeatedInt64Wrapper[len(m.RepeatedInt64Wrapper)-1]); err != nil { - return err - } + if err := (*wrapperspb1.Int64Value)(m.RepeatedInt64Wrapper[len(m.RepeatedInt64Wrapper)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 214: @@ -15039,16 +13870,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } m.RepeatedUint32Wrapper = append(m.RepeatedUint32Wrapper, &wrapperspb.UInt32Value{}) - if unmarshal, ok := interface{}(m.RepeatedUint32Wrapper[len(m.RepeatedUint32Wrapper)-1]).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.RepeatedUint32Wrapper[len(m.RepeatedUint32Wrapper)-1]); err != nil { - return err - } + if err := (*wrapperspb1.UInt32Value)(m.RepeatedUint32Wrapper[len(m.RepeatedUint32Wrapper)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 215: @@ -15081,16 +13904,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } m.RepeatedUint64Wrapper = append(m.RepeatedUint64Wrapper, &wrapperspb.UInt64Value{}) - if unmarshal, ok := interface{}(m.RepeatedUint64Wrapper[len(m.RepeatedUint64Wrapper)-1]).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.RepeatedUint64Wrapper[len(m.RepeatedUint64Wrapper)-1]); err != nil { - return err - } + if err := (*wrapperspb1.UInt64Value)(m.RepeatedUint64Wrapper[len(m.RepeatedUint64Wrapper)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 216: @@ -15123,16 +13938,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } m.RepeatedFloatWrapper = append(m.RepeatedFloatWrapper, &wrapperspb.FloatValue{}) - if unmarshal, ok := interface{}(m.RepeatedFloatWrapper[len(m.RepeatedFloatWrapper)-1]).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.RepeatedFloatWrapper[len(m.RepeatedFloatWrapper)-1]); err != nil { - return err - } + if err := (*wrapperspb1.FloatValue)(m.RepeatedFloatWrapper[len(m.RepeatedFloatWrapper)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 217: @@ -15165,16 +13972,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } m.RepeatedDoubleWrapper = append(m.RepeatedDoubleWrapper, &wrapperspb.DoubleValue{}) - if unmarshal, ok := interface{}(m.RepeatedDoubleWrapper[len(m.RepeatedDoubleWrapper)-1]).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.RepeatedDoubleWrapper[len(m.RepeatedDoubleWrapper)-1]); err != nil { - return err - } + if err := (*wrapperspb1.DoubleValue)(m.RepeatedDoubleWrapper[len(m.RepeatedDoubleWrapper)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 218: @@ -15207,16 +14006,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } m.RepeatedStringWrapper = append(m.RepeatedStringWrapper, &wrapperspb.StringValue{}) - if unmarshal, ok := interface{}(m.RepeatedStringWrapper[len(m.RepeatedStringWrapper)-1]).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.RepeatedStringWrapper[len(m.RepeatedStringWrapper)-1]); err != nil { - return err - } + if err := (*wrapperspb1.StringValue)(m.RepeatedStringWrapper[len(m.RepeatedStringWrapper)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 219: @@ -15249,16 +14040,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } m.RepeatedBytesWrapper = append(m.RepeatedBytesWrapper, &wrapperspb.BytesValue{}) - if unmarshal, ok := interface{}(m.RepeatedBytesWrapper[len(m.RepeatedBytesWrapper)-1]).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.RepeatedBytesWrapper[len(m.RepeatedBytesWrapper)-1]); err != nil { - return err - } + if err := (*wrapperspb1.BytesValue)(m.RepeatedBytesWrapper[len(m.RepeatedBytesWrapper)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 301: @@ -15293,16 +14076,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { if m.OptionalDuration == nil { m.OptionalDuration = &durationpb.Duration{} } - if unmarshal, ok := interface{}(m.OptionalDuration).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalDuration); err != nil { - return err - } + if err := (*durationpb1.Duration)(m.OptionalDuration).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 302: @@ -15337,16 +14112,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { if m.OptionalTimestamp == nil { m.OptionalTimestamp = ×tamppb.Timestamp{} } - if unmarshal, ok := interface{}(m.OptionalTimestamp).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalTimestamp); err != nil { - return err - } + if err := (*timestamppb1.Timestamp)(m.OptionalTimestamp).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 303: @@ -15381,16 +14148,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { if m.OptionalFieldMask == nil { m.OptionalFieldMask = &fieldmaskpb.FieldMask{} } - if unmarshal, ok := interface{}(m.OptionalFieldMask).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalFieldMask); err != nil { - return err - } + if err := (*fieldmaskpb1.FieldMask)(m.OptionalFieldMask).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 304: @@ -15469,16 +14228,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { if m.OptionalAny == nil { m.OptionalAny = &anypb.Any{} } - if unmarshal, ok := interface{}(m.OptionalAny).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalAny); err != nil { - return err - } + if err := (*anypb1.Any)(m.OptionalAny).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 306: @@ -15574,16 +14325,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } m.RepeatedDuration = append(m.RepeatedDuration, &durationpb.Duration{}) - if unmarshal, ok := interface{}(m.RepeatedDuration[len(m.RepeatedDuration)-1]).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.RepeatedDuration[len(m.RepeatedDuration)-1]); err != nil { - return err - } + if err := (*durationpb1.Duration)(m.RepeatedDuration[len(m.RepeatedDuration)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 312: @@ -15616,16 +14359,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } m.RepeatedTimestamp = append(m.RepeatedTimestamp, ×tamppb.Timestamp{}) - if unmarshal, ok := interface{}(m.RepeatedTimestamp[len(m.RepeatedTimestamp)-1]).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.RepeatedTimestamp[len(m.RepeatedTimestamp)-1]); err != nil { - return err - } + if err := (*timestamppb1.Timestamp)(m.RepeatedTimestamp[len(m.RepeatedTimestamp)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 313: @@ -15658,16 +14393,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } m.RepeatedFieldmask = append(m.RepeatedFieldmask, &fieldmaskpb.FieldMask{}) - if unmarshal, ok := interface{}(m.RepeatedFieldmask[len(m.RepeatedFieldmask)-1]).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.RepeatedFieldmask[len(m.RepeatedFieldmask)-1]); err != nil { - return err - } + if err := (*fieldmaskpb1.FieldMask)(m.RepeatedFieldmask[len(m.RepeatedFieldmask)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 315: @@ -15700,16 +14427,8 @@ func (m *TestAllTypesProto3) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } m.RepeatedAny = append(m.RepeatedAny, &anypb.Any{}) - if unmarshal, ok := interface{}(m.RepeatedAny[len(m.RepeatedAny)-1]).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.RepeatedAny[len(m.RepeatedAny)-1]); err != nil { - return err - } + if err := (*anypb1.Any)(m.RepeatedAny[len(m.RepeatedAny)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 316: diff --git a/features/clone/clone.go b/features/clone/clone.go index 3afd0d8..f521030 100644 --- a/features/clone/clone.go +++ b/features/clone/clone.go @@ -66,9 +66,12 @@ func (p *clone) cloneOneofField(lhsBase, rhsBase string, oneof *protogen.Oneof) func (p *clone) cloneFieldSingular(lhs, rhs string, kind protoreflect.Kind, message *protogen.Message) { switch { case kind == protoreflect.MessageKind, kind == protoreflect.GroupKind: - if p.IsLocalMessage(message) { + switch { + case p.IsLocalMessage(message): p.P(lhs, ` = `, rhs, `.`, cloneName, `()`) - } else { + case p.IsWellKnownType(message): + p.P(lhs, ` = (*`, message.GoIdent, `)((*`, p.WellKnownTypeMap(message), `)(`, rhs, `).`, cloneName, `())`) + default: // rhs is a concrete type, we need to first convert it to an interface in order to use an interface // type assertion. p.P(`if vtpb, ok := interface{}(`, rhs, `).(interface{ `, cloneName, `() *`, message.GoIdent, ` }); ok {`) @@ -148,10 +151,13 @@ func (p *clone) generateCloneMethodsForMessage(proto3 bool, message *protogen.Me p.body(!proto3, ccTypeName, message, true) p.P(`}`) p.P() - p.P(`func (m *`, ccTypeName, `) `, cloneMessageName, `() `, protoPkg.Ident("Message"), ` {`) - p.P(`return m.`, cloneName, `()`) - p.P(`}`) - p.P() + + if !p.Wrapper() { + p.P(`func (m *`, ccTypeName, `) `, cloneMessageName, `() `, protoPkg.Ident("Message"), ` {`) + p.P(`return m.`, cloneName, `()`) + p.P(`}`) + p.P() + } } // body generates the code for the actual cloning logic of a structure containing the given fields. @@ -189,9 +195,16 @@ func (p *clone) body(allFieldsNullable bool, ccTypeName string, message *protoge } // Shortcut: for types where we know that an optimized clone method exists, we can call it directly as it is // nil-safe. - if field.Desc.Cardinality() != protoreflect.Repeated && field.Message != nil && p.IsLocalMessage(field.Message) { - p.P(`r.`, field.GoName, ` = m.`, field.GoName, `.`, cloneName, `()`) - continue + if field.Desc.Cardinality() != protoreflect.Repeated { + switch { + case p.IsLocalMessage(field.Message): + p.P(`r.`, field.GoName, ` = m.`, field.GoName, `.`, cloneName, `()`) + continue + + case p.IsWellKnownType(field.Message): + p.P(`r.`, field.GoName, ` = (*`, field.Message.GoIdent, `)((*`, p.WellKnownTypeMap(field.Message), `)(m.`, field.GoName, `).`, cloneName, `())`) + continue + } } refFields = append(refFields, field) } @@ -201,7 +214,7 @@ func (p *clone) body(allFieldsNullable bool, ccTypeName string, message *protoge p.cloneField("r", "m", allFieldsNullable, field) } - if cloneUnknownFields { + if cloneUnknownFields && !p.Wrapper() { // Clone unknown fields, if any p.P(`if len(m.unknownFields) > 0 {`) p.P(`r.unknownFields = make([]byte, len(m.unknownFields))`) diff --git a/features/equal/equal.go b/features/equal/equal.go index 303f4bc..03cbe02 100644 --- a/features/equal/equal.go +++ b/features/equal/equal.go @@ -53,7 +53,7 @@ func (p *equal) message(proto3 bool, message *protogen.Message) { p.once = true - ccTypeName := message.GoIdent + ccTypeName := message.GoIdent.GoName p.P(`func (this *`, ccTypeName, `) `, equalName, `(that *`, ccTypeName, `) bool {`) p.P(`if this == that {`) @@ -102,17 +102,23 @@ func (p *equal) message(proto3 bool, message *protogen.Message) { } } - p.P(`return string(this.unknownFields) == string(that.unknownFields)`) + if p.Wrapper() { + p.P(`return true`) + } else { + p.P(`return string(this.unknownFields) == string(that.unknownFields)`) + } p.P(`}`) p.P() - p.P(`func (this *`, ccTypeName, `) `, equalMessageName, `(thatMsg `, protoPkg.Ident("Message"), `) bool {`) - p.P(`that, ok := thatMsg.(*`, ccTypeName, `)`) - p.P(`if !ok {`) - p.P(`return false`) - p.P(`}`) - p.P(`return this.`, equalName, `(that)`) - p.P(`}`) + if !p.Wrapper() { + p.P(`func (this *`, ccTypeName, `) `, equalMessageName, `(thatMsg `, protoPkg.Ident("Message"), `) bool {`) + p.P(`that, ok := thatMsg.(*`, ccTypeName, `)`) + p.P(`if !ok {`) + p.P(`return false`) + p.P(`}`) + p.P(`return this.`, equalName, `(that)`) + p.P(`}`) + } for _, field := range message.Fields { oneof := field.Oneof != nil && !field.Oneof.Desc.IsSynthetic() @@ -242,19 +248,25 @@ func (p *equal) compareCall(lhs, rhs string, msg *protogen.Message, nullable boo p.P(`}`) lhs, rhs = "p", "q" } - if msg != nil && msg.Desc != nil && msg.Desc.ParentFile() != nil && p.IsLocalMessage(msg) { + switch { + case p.IsLocalMessage(msg): p.P(`if !`, lhs, `.`, equalName, `(`, rhs, `) {`) p.P(` return false`) p.P(`}`) - return + case p.IsWellKnownType(msg): + wkt := p.WellKnownTypeMap(msg) + p.P(`if !(*`, wkt, `)(`, lhs, `).`, equalName, `((*`, wkt, `)(`, rhs, `)) {`) + p.P(` return false`) + p.P(`}`) + default: + p.P(`if equal, ok := interface{}(`, lhs, `).(interface { `, equalName, `(*`, p.QualifiedGoIdent(msg.GoIdent), `) bool }); ok {`) + p.P(` if !equal.`, equalName, `(`, rhs, `) {`) + p.P(` return false`) + p.P(` }`) + p.P(`} else if !`, p.Ident("google.golang.org/protobuf/proto", "Equal"), `(`, lhs, `, `, rhs, `) {`) + p.P(` return false`) + p.P(`}`) } - p.P(`if equal, ok := interface{}(`, lhs, `).(interface { `, equalName, `(*`, p.QualifiedGoIdent(msg.GoIdent), `) bool }); ok {`) - p.P(` if !equal.`, equalName, `(`, rhs, `) {`) - p.P(` return false`) - p.P(` }`) - p.P(`} else if !`, p.Ident("google.golang.org/protobuf/proto", "Equal"), `(`, lhs, `, `, rhs, `) {`) - p.P(` return false`) - p.P(`}`) } func isScalar(kind protoreflect.Kind) bool { diff --git a/features/marshal/marshalto.go b/features/marshal/marshalto.go index 245f3a5..c24e927 100644 --- a/features/marshal/marshalto.go +++ b/features/marshal/marshalto.go @@ -580,7 +580,7 @@ func (p *marshal) message(message *protogen.Message) { p.once = true var numGen counter - ccTypeName := message.GoIdent + ccTypeName := message.GoIdent.GoName p.P(`func (m *`, ccTypeName, `) `, p.methodMarshal(), `() (dAtA []byte, err error) {`) p.P(`if m == nil {`) @@ -608,10 +608,13 @@ func (p *marshal) message(message *protogen.Message) { p.P(`_ = i`) p.P(`var l int`) p.P(`_ = l`) - p.P(`if m.unknownFields != nil {`) - p.P(`i -= len(m.unknownFields)`) - p.P(`copy(dAtA[i:], m.unknownFields)`) - p.P(`}`) + + if !p.Wrapper() { + p.P(`if m.unknownFields != nil {`) + p.P(`i -= len(m.unknownFields)`) + p.P(`copy(dAtA[i:], m.unknownFields)`) + p.P(`}`) + } sort.Slice(message.Fields, func(i, j int) bool { return message.Fields[i].Desc.Number() < message.Fields[j].Desc.Number() @@ -676,7 +679,7 @@ func (p *marshal) message(message *protogen.Message) { if field.Oneof == nil || field.Oneof.Desc.IsSynthetic() { continue } - ccTypeName := field.GoIdent + ccTypeName := field.GoIdent.GoName p.P(`func (m *`, ccTypeName, `) `, p.methodMarshalTo(), `(dAtA []byte) (int, error) {`) p.P(`size := m.SizeVT()`) p.P(`return m.`, p.methodMarshalToSizedBuffer(), `(dAtA[:size])`) @@ -696,18 +699,7 @@ func (p *marshal) reverseListRange(expression ...string) string { return exp + `[iNdEx]` } -func (p *marshal) marshalBackward(varName string, varInt bool, message *protogen.Message) { - local := p.IsLocalMessage(message) - - if local { - p.P(`size, err := `, varName, `.`, p.methodMarshalToSizedBuffer(), `(dAtA[:i])`) - } else { - p.P(`if vtmsg, ok := interface{}(`, varName, `).(interface{`) - p.P(p.methodMarshalToSizedBuffer(), `([]byte) (int, error)`) - p.P(`}); ok{`) - p.P(`size, err := vtmsg.`, p.methodMarshalToSizedBuffer(), `(dAtA[:i])`) - } - +func (p *marshal) marshalBackwardSize(varInt bool) { p.P(`if err != nil {`) p.P(`return 0, err`) p.P(`}`) @@ -716,7 +708,24 @@ func (p *marshal) marshalBackward(varName string, varInt bool, message *protogen p.encodeVarint(`size`) } - if !local { +} + +func (p *marshal) marshalBackward(varName string, varInt bool, message *protogen.Message) { + switch { + case p.IsWellKnownType(message): + p.P(`size, err := (*`, p.WellKnownTypeMap(message), `)(`, varName, `).`, p.methodMarshalToSizedBuffer(), `(dAtA[:i])`) + p.marshalBackwardSize(varInt) + + case p.IsLocalMessage(message): + p.P(`size, err := `, varName, `.`, p.methodMarshalToSizedBuffer(), `(dAtA[:i])`) + p.marshalBackwardSize(varInt) + + default: + p.P(`if vtmsg, ok := interface{}(`, varName, `).(interface{`) + p.P(p.methodMarshalToSizedBuffer(), `([]byte) (int, error)`) + p.P(`}); ok{`) + p.P(`size, err := vtmsg.`, p.methodMarshalToSizedBuffer(), `(dAtA[:i])`) + p.marshalBackwardSize(varInt) p.P(`} else {`) p.P(`encoded, err := `, p.Ident(generator.ProtoPkg, "Marshal"), `(`, varName, `)`) p.P(`if err != nil {`) diff --git a/features/size/size.go b/features/size/size.go index 21fa307..2fda5d5 100644 --- a/features/size/size.go +++ b/features/size/size.go @@ -56,11 +56,14 @@ func (p *size) GenerateHelpers() { } func (p *size) messageSize(varName, sizeName string, message *protogen.Message) { - local := p.IsLocalMessage(message) - - if local { + switch { + case p.IsLocalMessage(message): p.P(`l = `, varName, `.`, sizeName, `()`) - } else { + + case p.IsWellKnownType(message): + p.P(`l = (*`, p.WellKnownTypeMap(message), `)(`, varName, `).`, sizeName, `()`) + + default: p.P(`if size, ok := interface{}(`, varName, `).(interface{`) p.P(sizeName, `() int`) p.P(`}); ok{`) @@ -287,7 +290,7 @@ func (p *size) message(message *protogen.Message) { p.once = true sizeName := "SizeVT" - ccTypeName := message.GoIdent + ccTypeName := message.GoIdent.GoName p.P(`func (m *`, ccTypeName, `) `, sizeName, `() (n int) {`) p.P(`if m == nil {`) @@ -310,7 +313,9 @@ func (p *size) message(message *protogen.Message) { } } } - p.P(`n+=len(m.unknownFields)`) + if !p.Wrapper() { + p.P(`n+=len(m.unknownFields)`) + } p.P(`return n`) p.P(`}`) p.P() diff --git a/features/unmarshal/unmarshal.go b/features/unmarshal/unmarshal.go index dca73aa..2e3e748 100644 --- a/features/unmarshal/unmarshal.go +++ b/features/unmarshal/unmarshal.go @@ -132,13 +132,18 @@ func (p *unmarshal) GenerateHelpers() { } func (p *unmarshal) decodeMessage(varName, buf string, message *protogen.Message) { - local := p.IsLocalMessage(message) - - if local { + switch { + case p.IsLocalMessage(message): p.P(`if err := `, varName, `.UnmarshalVT(`, buf, `); err != nil {`) p.P(`return err`) p.P(`}`) - } else { + + case p.IsWellKnownType(message): + p.P(`if err := (*`, p.WellKnownTypeMap(message), `)(`, varName, `).UnmarshalVT(`, buf, `); err != nil {`) + p.P(`return err`) + p.P(`}`) + + default: p.P(`if unmarshal, ok := interface{}(`, varName, `).(interface{`) p.P(`UnmarshalVT([]byte) error`) p.P(`}); ok{`) @@ -827,7 +832,7 @@ func (p *unmarshal) message(proto3 bool, message *protogen.Message) { } p.once = true - ccTypeName := message.GoIdent + ccTypeName := message.GoIdent.GoName required := message.Desc.RequiredNumbers() p.P(`func (m *`, ccTypeName, `) UnmarshalVT(dAtA []byte) error {`) @@ -879,7 +884,9 @@ func (p *unmarshal) message(proto3 bool, message *protogen.Message) { p.P(`iNdEx += skippy`) p.P(`} else {`) } - p.P(`m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...)`) + if !p.Wrapper() { + p.P(`m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...)`) + } p.P(`iNdEx += skippy`) if message.Desc.ExtensionRanges().Len() > 0 { p.P(`}`) diff --git a/generator/generatedfile.go b/generator/generatedfile.go index f85cd37..792ef04 100644 --- a/generator/generatedfile.go +++ b/generator/generatedfile.go @@ -16,8 +16,8 @@ import ( type GeneratedFile struct { *protogen.GeneratedFile - Ext *Extensions - LocalPackages map[string]bool + Config *Config + LocalPackages map[protoreflect.FullName]bool helpers map[string]bool } @@ -38,7 +38,7 @@ func (b *GeneratedFile) ShouldPool(message *protogen.Message) bool { if message == nil { return false } - if b.Ext.Poolable[message.GoIdent] { + if b.Config.Poolable[message.GoIdent] { return true } ext := proto.GetExtension(message.Desc.Options(), vtproto.E_Mempool) @@ -50,9 +50,9 @@ func (b *GeneratedFile) ShouldPool(message *protogen.Message) bool { func (b *GeneratedFile) Alloc(vname string, message *protogen.Message) { if b.ShouldPool(message) { - b.P(vname, " := ", message.GoIdent, `FromVTPool()`) + b.P(vname, " := ", message.GoIdent.GoName, `FromVTPool()`) } else { - b.P(vname, " := new(", message.GoIdent, `)`) + b.P(vname, " := new(", message.GoIdent.GoName, `)`) } } @@ -100,6 +100,47 @@ func (p *GeneratedFile) FieldGoType(field *protogen.Field) (goType string, point } func (p *GeneratedFile) IsLocalMessage(message *protogen.Message) bool { - pkg := string(message.Desc.ParentFile().Package()) + if message == nil { + return false + } + pkg := message.Desc.ParentFile().Package() return p.LocalPackages[pkg] } + +const vtWellKnownPackage = protogen.GoImportPath("github.com/planetscale/vtprotobuf/types/known/") + +var wellKnownTypes = map[protoreflect.FullName]protogen.GoIdent{ + "google.protobuf.Any": {GoName: "Any", GoImportPath: vtWellKnownPackage + "anypb"}, + "google.protobuf.Duration": {GoName: "Duration", GoImportPath: vtWellKnownPackage + "durationpb"}, + "google.protobuf.Empty": {GoName: "Empty", GoImportPath: vtWellKnownPackage + "emptypb"}, + "google.protobuf.FieldMask": {GoName: "FieldMask", GoImportPath: vtWellKnownPackage + "fieldmaskpb"}, + "google.protobuf.Timestamp": {GoName: "Timestamp", GoImportPath: vtWellKnownPackage + "timestamppb"}, + "google.protobuf.DoubleValue": {GoName: "DoubleValue", GoImportPath: vtWellKnownPackage + "wrapperspb"}, + "google.protobuf.FloatValue": {GoName: "FloatValue", GoImportPath: vtWellKnownPackage + "wrapperspb"}, + "google.protobuf.Int64Value": {GoName: "Int64Value", GoImportPath: vtWellKnownPackage + "wrapperspb"}, + "google.protobuf.UInt64Value": {GoName: "UInt64Value", GoImportPath: vtWellKnownPackage + "wrapperspb"}, + "google.protobuf.Int32Value": {GoName: "Int32Value", GoImportPath: vtWellKnownPackage + "wrapperspb"}, + "google.protobuf.UInt32Value": {GoName: "UInt32Value", GoImportPath: vtWellKnownPackage + "wrapperspb"}, + "google.protobuf.BoolValue": {GoName: "BoolValue", GoImportPath: vtWellKnownPackage + "wrapperspb"}, + "google.protobuf.StringValue": {GoName: "StringValue", GoImportPath: vtWellKnownPackage + "wrapperspb"}, + "google.protobuf.BytesValue": {GoName: "BytesValue", GoImportPath: vtWellKnownPackage + "wrapperspb"}, +} + +func (p *GeneratedFile) IsWellKnownType(message *protogen.Message) bool { + if message == nil || !p.Config.WellKnownTypes { + return false + } + _, ok := wellKnownTypes[message.Desc.FullName()] + return ok +} + +func (p *GeneratedFile) WellKnownTypeMap(message *protogen.Message) protogen.GoIdent { + if message == nil || !p.Config.WellKnownTypes { + return protogen.GoIdent{} + } + return wellKnownTypes[message.Desc.FullName()] +} + +func (p *GeneratedFile) Wrapper() bool { + return p.Config.Wrap +} diff --git a/generator/generator.go b/generator/generator.go index 8eb2e16..3e520d4 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -5,10 +5,14 @@ package generator import ( + "fmt" "runtime/debug" + "strings" "google.golang.org/protobuf/compiler/protogen" + "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/runtime/protoimpl" + "google.golang.org/protobuf/types/pluginpb" ) type featureHelpers struct { @@ -16,42 +20,91 @@ type featureHelpers struct { feature int } -type Extensions struct { - Poolable map[protogen.GoIdent]bool +type ObjectSet map[protogen.GoIdent]bool + +func (o *ObjectSet) String() string { + return fmt.Sprintf("%#v", *o) +} + +func (o *ObjectSet) Set(s string) error { + idx := strings.LastIndexByte(s, '.') + if idx < 0 { + return fmt.Errorf("invalid object name: %q", s) + } + + ident := protogen.GoIdent{ + GoImportPath: protogen.GoImportPath(s[0:idx]), + GoName: s[idx+1:], + } + + if o == nil { + *o = make(ObjectSet) + } + (*o)[ident] = true + return nil +} + +type Config struct { + Poolable ObjectSet + Wrap bool + WellKnownTypes bool + AllowEmpty bool } type Generator struct { - seen map[featureHelpers]bool - ext *Extensions + plugin *protogen.Plugin + cfg *Config features []Feature - local map[string]bool + seen map[featureHelpers]bool + local map[protoreflect.FullName]bool } -func NewGenerator(allFiles []*protogen.File, featureNames []string, ext *Extensions) (*Generator, error) { +const SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) + +func NewGenerator(plugin *protogen.Plugin, featureNames []string, cfg *Config) (*Generator, error) { + plugin.SupportedFeatures = SupportedFeatures + features, err := findFeatures(featureNames) if err != nil { return nil, err } - local := make(map[string]bool) - for _, f := range allFiles { + local := make(map[protoreflect.FullName]bool) + for _, f := range plugin.Files { if f.Generate { - local[string(f.Desc.Package())] = true + local[f.Desc.Package()] = true } } return &Generator{ - seen: make(map[featureHelpers]bool), - ext: ext, + plugin: plugin, + cfg: cfg, features: features, + seen: make(map[featureHelpers]bool), local: local, }, nil } -func (gen *Generator) GenerateFile(gf *protogen.GeneratedFile, file *protogen.File) bool { +func (gen *Generator) Generate() { + for _, file := range gen.plugin.Files { + if !file.Generate { + continue + } + + var importPath protogen.GoImportPath + if !gen.cfg.Wrap { + importPath = file.GoImportPath + } + + gf := gen.plugin.NewGeneratedFile(file.GeneratedFilenamePrefix+"_vtproto.pb.go", importPath) + gen.generateFile(gf, file) + } +} + +func (gen *Generator) generateFile(gf *protogen.GeneratedFile, file *protogen.File) { p := &GeneratedFile{ GeneratedFile: gf, - Ext: gen.ext, + Config: gen.cfg, LocalPackages: gen.local, helpers: make(map[string]bool), } @@ -74,6 +127,12 @@ func (gen *Generator) GenerateFile(gf *protogen.GeneratedFile, file *protogen.Fi p.P(")") p.P() + if p.Wrapper() { + for _, msg := range file.Messages { + p.P(`type `, msg.GoIdent.GoName, ` `, msg.GoIdent) + } + } + var generated bool for fidx, feat := range gen.features { featGenerator := feat(p) @@ -91,5 +150,7 @@ func (gen *Generator) GenerateFile(gf *protogen.GeneratedFile, file *protogen.Fi } } - return generated + if !generated && !gen.cfg.AllowEmpty { + gf.Skip() + } } diff --git a/protobuf.sh b/protobuf.sh index 5f843f7..88f7fae 100755 --- a/protobuf.sh +++ b/protobuf.sh @@ -6,7 +6,7 @@ PROTOBUF_VERSION=21.12 ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) PROTOBUF_PATH="${ROOT}/_vendor/protobuf-${PROTOBUF_VERSION}" -if [ -f "$PROTOBUF_PATH/protoc" ]; then +if [ -f "$PROTOBUF_PATH/src/protoc" ]; then echo "protoc found in $PROTOBUF_PATH" exit 0 fi diff --git a/testproto/wkt/wkt.pb.go b/testproto/wkt/wkt.pb.go new file mode 100644 index 0000000..a20fd0e --- /dev/null +++ b/testproto/wkt/wkt.pb.go @@ -0,0 +1,341 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.21.12 +// source: wkt/wkt.proto + +package wkt + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + durationpb "google.golang.org/protobuf/types/known/durationpb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type MessageWithWKT struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Any *anypb.Any `protobuf:"bytes,1,opt,name=any,proto3" json:"any,omitempty"` + Duration *durationpb.Duration `protobuf:"bytes,2,opt,name=duration,proto3" json:"duration,omitempty"` + Empty *emptypb.Empty `protobuf:"bytes,3,opt,name=empty,proto3" json:"empty,omitempty"` + FieldMask *fieldmaskpb.FieldMask `protobuf:"bytes,4,opt,name=field_mask,json=fieldMask,proto3" json:"field_mask,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + DoubleValue *wrapperspb.DoubleValue `protobuf:"bytes,6,opt,name=double_value,json=doubleValue,proto3" json:"double_value,omitempty"` + FloatValue *wrapperspb.FloatValue `protobuf:"bytes,7,opt,name=float_value,json=floatValue,proto3" json:"float_value,omitempty"` + Int64Value *wrapperspb.Int64Value `protobuf:"bytes,8,opt,name=int64_value,json=int64Value,proto3" json:"int64_value,omitempty"` + Uint64Value *wrapperspb.UInt64Value `protobuf:"bytes,9,opt,name=uint64_value,json=uint64Value,proto3" json:"uint64_value,omitempty"` + Int32Value *wrapperspb.Int32Value `protobuf:"bytes,10,opt,name=int32_value,json=int32Value,proto3" json:"int32_value,omitempty"` + Uint32Value *wrapperspb.UInt32Value `protobuf:"bytes,11,opt,name=uint32_value,json=uint32Value,proto3" json:"uint32_value,omitempty"` + BoolValue *wrapperspb.BoolValue `protobuf:"bytes,12,opt,name=bool_value,json=boolValue,proto3" json:"bool_value,omitempty"` + StringValue *wrapperspb.StringValue `protobuf:"bytes,13,opt,name=string_value,json=stringValue,proto3" json:"string_value,omitempty"` + BytesValue *wrapperspb.BytesValue `protobuf:"bytes,14,opt,name=bytes_value,json=bytesValue,proto3" json:"bytes_value,omitempty"` +} + +func (x *MessageWithWKT) Reset() { + *x = MessageWithWKT{} + if protoimpl.UnsafeEnabled { + mi := &file_wkt_wkt_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MessageWithWKT) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MessageWithWKT) ProtoMessage() {} + +func (x *MessageWithWKT) ProtoReflect() protoreflect.Message { + mi := &file_wkt_wkt_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MessageWithWKT.ProtoReflect.Descriptor instead. +func (*MessageWithWKT) Descriptor() ([]byte, []int) { + return file_wkt_wkt_proto_rawDescGZIP(), []int{0} +} + +func (x *MessageWithWKT) GetAny() *anypb.Any { + if x != nil { + return x.Any + } + return nil +} + +func (x *MessageWithWKT) GetDuration() *durationpb.Duration { + if x != nil { + return x.Duration + } + return nil +} + +func (x *MessageWithWKT) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +func (x *MessageWithWKT) GetFieldMask() *fieldmaskpb.FieldMask { + if x != nil { + return x.FieldMask + } + return nil +} + +func (x *MessageWithWKT) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +func (x *MessageWithWKT) GetDoubleValue() *wrapperspb.DoubleValue { + if x != nil { + return x.DoubleValue + } + return nil +} + +func (x *MessageWithWKT) GetFloatValue() *wrapperspb.FloatValue { + if x != nil { + return x.FloatValue + } + return nil +} + +func (x *MessageWithWKT) GetInt64Value() *wrapperspb.Int64Value { + if x != nil { + return x.Int64Value + } + return nil +} + +func (x *MessageWithWKT) GetUint64Value() *wrapperspb.UInt64Value { + if x != nil { + return x.Uint64Value + } + return nil +} + +func (x *MessageWithWKT) GetInt32Value() *wrapperspb.Int32Value { + if x != nil { + return x.Int32Value + } + return nil +} + +func (x *MessageWithWKT) GetUint32Value() *wrapperspb.UInt32Value { + if x != nil { + return x.Uint32Value + } + return nil +} + +func (x *MessageWithWKT) GetBoolValue() *wrapperspb.BoolValue { + if x != nil { + return x.BoolValue + } + return nil +} + +func (x *MessageWithWKT) GetStringValue() *wrapperspb.StringValue { + if x != nil { + return x.StringValue + } + return nil +} + +func (x *MessageWithWKT) GetBytesValue() *wrapperspb.BytesValue { + if x != nil { + return x.BytesValue + } + return nil +} + +var File_wkt_wkt_proto protoreflect.FileDescriptor + +var file_wkt_wkt_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x77, 0x6b, 0x74, 0x2f, 0x77, 0x6b, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, + 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, + 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, + 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc9, 0x06, 0x0a, 0x0e, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x57, 0x4b, 0x54, 0x12, 0x26, 0x0a, + 0x03, 0x61, 0x6e, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, + 0x52, 0x03, 0x61, 0x6e, 0x79, 0x12, 0x35, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x05, + 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x52, 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x39, 0x0a, 0x0a, 0x66, 0x69, + 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, + 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, + 0x3f, 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x12, 0x3c, 0x0a, 0x0b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x52, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3c, + 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3f, 0x0a, 0x0c, + 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x09, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x52, 0x0b, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3c, 0x0a, + 0x0b, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x0a, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3f, 0x0a, 0x0c, 0x75, + 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x0b, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x39, 0x0a, 0x0a, + 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x09, 0x62, 0x6f, + 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3f, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0b, 0x73, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x62, 0x79, 0x74, 0x65, + 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x42, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x62, 0x79, 0x74, 0x65, + 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x0f, 0x5a, 0x0d, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2f, 0x77, 0x6b, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_wkt_wkt_proto_rawDescOnce sync.Once + file_wkt_wkt_proto_rawDescData = file_wkt_wkt_proto_rawDesc +) + +func file_wkt_wkt_proto_rawDescGZIP() []byte { + file_wkt_wkt_proto_rawDescOnce.Do(func() { + file_wkt_wkt_proto_rawDescData = protoimpl.X.CompressGZIP(file_wkt_wkt_proto_rawDescData) + }) + return file_wkt_wkt_proto_rawDescData +} + +var file_wkt_wkt_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_wkt_wkt_proto_goTypes = []interface{}{ + (*MessageWithWKT)(nil), // 0: MessageWithWKT + (*anypb.Any)(nil), // 1: google.protobuf.Any + (*durationpb.Duration)(nil), // 2: google.protobuf.Duration + (*emptypb.Empty)(nil), // 3: google.protobuf.Empty + (*fieldmaskpb.FieldMask)(nil), // 4: google.protobuf.FieldMask + (*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp + (*wrapperspb.DoubleValue)(nil), // 6: google.protobuf.DoubleValue + (*wrapperspb.FloatValue)(nil), // 7: google.protobuf.FloatValue + (*wrapperspb.Int64Value)(nil), // 8: google.protobuf.Int64Value + (*wrapperspb.UInt64Value)(nil), // 9: google.protobuf.UInt64Value + (*wrapperspb.Int32Value)(nil), // 10: google.protobuf.Int32Value + (*wrapperspb.UInt32Value)(nil), // 11: google.protobuf.UInt32Value + (*wrapperspb.BoolValue)(nil), // 12: google.protobuf.BoolValue + (*wrapperspb.StringValue)(nil), // 13: google.protobuf.StringValue + (*wrapperspb.BytesValue)(nil), // 14: google.protobuf.BytesValue +} +var file_wkt_wkt_proto_depIdxs = []int32{ + 1, // 0: MessageWithWKT.any:type_name -> google.protobuf.Any + 2, // 1: MessageWithWKT.duration:type_name -> google.protobuf.Duration + 3, // 2: MessageWithWKT.empty:type_name -> google.protobuf.Empty + 4, // 3: MessageWithWKT.field_mask:type_name -> google.protobuf.FieldMask + 5, // 4: MessageWithWKT.timestamp:type_name -> google.protobuf.Timestamp + 6, // 5: MessageWithWKT.double_value:type_name -> google.protobuf.DoubleValue + 7, // 6: MessageWithWKT.float_value:type_name -> google.protobuf.FloatValue + 8, // 7: MessageWithWKT.int64_value:type_name -> google.protobuf.Int64Value + 9, // 8: MessageWithWKT.uint64_value:type_name -> google.protobuf.UInt64Value + 10, // 9: MessageWithWKT.int32_value:type_name -> google.protobuf.Int32Value + 11, // 10: MessageWithWKT.uint32_value:type_name -> google.protobuf.UInt32Value + 12, // 11: MessageWithWKT.bool_value:type_name -> google.protobuf.BoolValue + 13, // 12: MessageWithWKT.string_value:type_name -> google.protobuf.StringValue + 14, // 13: MessageWithWKT.bytes_value:type_name -> google.protobuf.BytesValue + 14, // [14:14] is the sub-list for method output_type + 14, // [14:14] is the sub-list for method input_type + 14, // [14:14] is the sub-list for extension type_name + 14, // [14:14] is the sub-list for extension extendee + 0, // [0:14] is the sub-list for field type_name +} + +func init() { file_wkt_wkt_proto_init() } +func file_wkt_wkt_proto_init() { + if File_wkt_wkt_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_wkt_wkt_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MessageWithWKT); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_wkt_wkt_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_wkt_wkt_proto_goTypes, + DependencyIndexes: file_wkt_wkt_proto_depIdxs, + MessageInfos: file_wkt_wkt_proto_msgTypes, + }.Build() + File_wkt_wkt_proto = out.File + file_wkt_wkt_proto_rawDesc = nil + file_wkt_wkt_proto_goTypes = nil + file_wkt_wkt_proto_depIdxs = nil +} diff --git a/testproto/wkt/wkt.proto b/testproto/wkt/wkt.proto new file mode 100644 index 0000000..c3f3270 --- /dev/null +++ b/testproto/wkt/wkt.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +option go_package = "testproto/wkt"; + +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +message MessageWithWKT { + google.protobuf.Any any = 1; + google.protobuf.Duration duration = 2; + google.protobuf.Empty empty = 3; + google.protobuf.FieldMask field_mask = 4; + google.protobuf.Timestamp timestamp = 5; + google.protobuf.DoubleValue double_value = 6; + google.protobuf.FloatValue float_value = 7; + google.protobuf.Int64Value int64_value = 8; + google.protobuf.UInt64Value uint64_value = 9; + google.protobuf.Int32Value int32_value = 10; + google.protobuf.UInt32Value uint32_value = 11; + google.protobuf.BoolValue bool_value = 12; + google.protobuf.StringValue string_value = 13; + google.protobuf.BytesValue bytes_value = 14; +} diff --git a/testproto/wkt/wkt_test.go b/testproto/wkt/wkt_test.go new file mode 100644 index 0000000..ad60480 --- /dev/null +++ b/testproto/wkt/wkt_test.go @@ -0,0 +1,64 @@ +package wkt + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/durationpb" + "google.golang.org/protobuf/types/known/emptypb" + "google.golang.org/protobuf/types/known/fieldmaskpb" + "google.golang.org/protobuf/types/known/timestamppb" + "google.golang.org/protobuf/types/known/wrapperspb" +) + +func TestWellKnownTypes(t *testing.T) { + dur := durationpb.New(4*time.Hour + 2*time.Second) + + anyVal, err := anypb.New(dur) + require.NoError(t, err) + + fieldMask, err := fieldmaskpb.New(dur, "seconds") + require.NoError(t, err) + + m := &MessageWithWKT{ + Any: anyVal, + Duration: dur, + Empty: &emptypb.Empty{}, + FieldMask: fieldMask, + Timestamp: timestamppb.Now(), + DoubleValue: wrapperspb.Double(123456789.123456789), + FloatValue: wrapperspb.Float(123456789.123456789), + Int64Value: wrapperspb.Int64(123456789), + Uint64Value: wrapperspb.UInt64(123456789), + Int32Value: wrapperspb.Int32(123456789), + Uint32Value: wrapperspb.UInt32(123456789), + BoolValue: wrapperspb.Bool(true), + StringValue: wrapperspb.String("String marshalling and unmarshalling test"), + BytesValue: wrapperspb.Bytes([]byte("Bytes marshalling and unmarshalling test")), + } + + golangBytes, err := proto.Marshal(m) + require.NoError(t, err) + + vtProtoBytes, err := m.MarshalVT() + require.NoError(t, err) + + require.NotEmpty(t, golangBytes) + require.NotEmpty(t, vtProtoBytes) + assert.Equal(t, golangBytes, vtProtoBytes) + + var ( + golangMsg = &MessageWithWKT{} + vtProtoMsg = &MessageWithWKT{} + ) + + require.NoError(t, proto.Unmarshal(golangBytes, golangMsg)) + require.NoError(t, vtProtoMsg.UnmarshalVT(vtProtoBytes)) + + assert.Equal(t, golangMsg.String(), vtProtoMsg.String()) +} diff --git a/testproto/wkt/wkt_vtproto.pb.go b/testproto/wkt/wkt_vtproto.pb.go new file mode 100644 index 0000000..1c422de --- /dev/null +++ b/testproto/wkt/wkt_vtproto.pb.go @@ -0,0 +1,1190 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: (devel) +// source: wkt/wkt.proto + +package wkt + +import ( + fmt "fmt" + anypb1 "github.com/planetscale/vtprotobuf/types/known/anypb" + durationpb1 "github.com/planetscale/vtprotobuf/types/known/durationpb" + emptypb1 "github.com/planetscale/vtprotobuf/types/known/emptypb" + fieldmaskpb1 "github.com/planetscale/vtprotobuf/types/known/fieldmaskpb" + timestamppb1 "github.com/planetscale/vtprotobuf/types/known/timestamppb" + wrapperspb1 "github.com/planetscale/vtprotobuf/types/known/wrapperspb" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + durationpb "google.golang.org/protobuf/types/known/durationpb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" + io "io" + bits "math/bits" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *MessageWithWKT) CloneVT() *MessageWithWKT { + if m == nil { + return (*MessageWithWKT)(nil) + } + r := new(MessageWithWKT) + r.Any = (*anypb.Any)((*anypb1.Any)(m.Any).CloneVT()) + r.Duration = (*durationpb.Duration)((*durationpb1.Duration)(m.Duration).CloneVT()) + r.Empty = (*emptypb.Empty)((*emptypb1.Empty)(m.Empty).CloneVT()) + r.FieldMask = (*fieldmaskpb.FieldMask)((*fieldmaskpb1.FieldMask)(m.FieldMask).CloneVT()) + r.Timestamp = (*timestamppb.Timestamp)((*timestamppb1.Timestamp)(m.Timestamp).CloneVT()) + r.DoubleValue = (*wrapperspb.DoubleValue)((*wrapperspb1.DoubleValue)(m.DoubleValue).CloneVT()) + r.FloatValue = (*wrapperspb.FloatValue)((*wrapperspb1.FloatValue)(m.FloatValue).CloneVT()) + r.Int64Value = (*wrapperspb.Int64Value)((*wrapperspb1.Int64Value)(m.Int64Value).CloneVT()) + r.Uint64Value = (*wrapperspb.UInt64Value)((*wrapperspb1.UInt64Value)(m.Uint64Value).CloneVT()) + r.Int32Value = (*wrapperspb.Int32Value)((*wrapperspb1.Int32Value)(m.Int32Value).CloneVT()) + r.Uint32Value = (*wrapperspb.UInt32Value)((*wrapperspb1.UInt32Value)(m.Uint32Value).CloneVT()) + r.BoolValue = (*wrapperspb.BoolValue)((*wrapperspb1.BoolValue)(m.BoolValue).CloneVT()) + r.StringValue = (*wrapperspb.StringValue)((*wrapperspb1.StringValue)(m.StringValue).CloneVT()) + r.BytesValue = (*wrapperspb.BytesValue)((*wrapperspb1.BytesValue)(m.BytesValue).CloneVT()) + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *MessageWithWKT) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *MessageWithWKT) EqualVT(that *MessageWithWKT) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !(*anypb1.Any)(this.Any).EqualVT((*anypb1.Any)(that.Any)) { + return false + } + if !(*durationpb1.Duration)(this.Duration).EqualVT((*durationpb1.Duration)(that.Duration)) { + return false + } + if !(*emptypb1.Empty)(this.Empty).EqualVT((*emptypb1.Empty)(that.Empty)) { + return false + } + if !(*fieldmaskpb1.FieldMask)(this.FieldMask).EqualVT((*fieldmaskpb1.FieldMask)(that.FieldMask)) { + return false + } + if !(*timestamppb1.Timestamp)(this.Timestamp).EqualVT((*timestamppb1.Timestamp)(that.Timestamp)) { + return false + } + if !(*wrapperspb1.DoubleValue)(this.DoubleValue).EqualVT((*wrapperspb1.DoubleValue)(that.DoubleValue)) { + return false + } + if !(*wrapperspb1.FloatValue)(this.FloatValue).EqualVT((*wrapperspb1.FloatValue)(that.FloatValue)) { + return false + } + if !(*wrapperspb1.Int64Value)(this.Int64Value).EqualVT((*wrapperspb1.Int64Value)(that.Int64Value)) { + return false + } + if !(*wrapperspb1.UInt64Value)(this.Uint64Value).EqualVT((*wrapperspb1.UInt64Value)(that.Uint64Value)) { + return false + } + if !(*wrapperspb1.Int32Value)(this.Int32Value).EqualVT((*wrapperspb1.Int32Value)(that.Int32Value)) { + return false + } + if !(*wrapperspb1.UInt32Value)(this.Uint32Value).EqualVT((*wrapperspb1.UInt32Value)(that.Uint32Value)) { + return false + } + if !(*wrapperspb1.BoolValue)(this.BoolValue).EqualVT((*wrapperspb1.BoolValue)(that.BoolValue)) { + return false + } + if !(*wrapperspb1.StringValue)(this.StringValue).EqualVT((*wrapperspb1.StringValue)(that.StringValue)) { + return false + } + if !(*wrapperspb1.BytesValue)(this.BytesValue).EqualVT((*wrapperspb1.BytesValue)(that.BytesValue)) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *MessageWithWKT) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*MessageWithWKT) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *MessageWithWKT) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MessageWithWKT) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *MessageWithWKT) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.BytesValue != nil { + size, err := (*wrapperspb1.BytesValue)(m.BytesValue).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x72 + } + if m.StringValue != nil { + size, err := (*wrapperspb1.StringValue)(m.StringValue).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x6a + } + if m.BoolValue != nil { + size, err := (*wrapperspb1.BoolValue)(m.BoolValue).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x62 + } + if m.Uint32Value != nil { + size, err := (*wrapperspb1.UInt32Value)(m.Uint32Value).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x5a + } + if m.Int32Value != nil { + size, err := (*wrapperspb1.Int32Value)(m.Int32Value).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x52 + } + if m.Uint64Value != nil { + size, err := (*wrapperspb1.UInt64Value)(m.Uint64Value).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x4a + } + if m.Int64Value != nil { + size, err := (*wrapperspb1.Int64Value)(m.Int64Value).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x42 + } + if m.FloatValue != nil { + size, err := (*wrapperspb1.FloatValue)(m.FloatValue).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x3a + } + if m.DoubleValue != nil { + size, err := (*wrapperspb1.DoubleValue)(m.DoubleValue).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x32 + } + if m.Timestamp != nil { + size, err := (*timestamppb1.Timestamp)(m.Timestamp).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + if m.FieldMask != nil { + size, err := (*fieldmaskpb1.FieldMask)(m.FieldMask).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if m.Empty != nil { + size, err := (*emptypb1.Empty)(m.Empty).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if m.Duration != nil { + size, err := (*durationpb1.Duration)(m.Duration).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.Any != nil { + size, err := (*anypb1.Any)(m.Any).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarint(dAtA []byte, offset int, v uint64) int { + offset -= sov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MessageWithWKT) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MessageWithWKT) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *MessageWithWKT) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.BytesValue != nil { + size, err := (*wrapperspb1.BytesValue)(m.BytesValue).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x72 + } + if m.StringValue != nil { + size, err := (*wrapperspb1.StringValue)(m.StringValue).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x6a + } + if m.BoolValue != nil { + size, err := (*wrapperspb1.BoolValue)(m.BoolValue).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x62 + } + if m.Uint32Value != nil { + size, err := (*wrapperspb1.UInt32Value)(m.Uint32Value).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x5a + } + if m.Int32Value != nil { + size, err := (*wrapperspb1.Int32Value)(m.Int32Value).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x52 + } + if m.Uint64Value != nil { + size, err := (*wrapperspb1.UInt64Value)(m.Uint64Value).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x4a + } + if m.Int64Value != nil { + size, err := (*wrapperspb1.Int64Value)(m.Int64Value).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x42 + } + if m.FloatValue != nil { + size, err := (*wrapperspb1.FloatValue)(m.FloatValue).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x3a + } + if m.DoubleValue != nil { + size, err := (*wrapperspb1.DoubleValue)(m.DoubleValue).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x32 + } + if m.Timestamp != nil { + size, err := (*timestamppb1.Timestamp)(m.Timestamp).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + if m.FieldMask != nil { + size, err := (*fieldmaskpb1.FieldMask)(m.FieldMask).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if m.Empty != nil { + size, err := (*emptypb1.Empty)(m.Empty).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if m.Duration != nil { + size, err := (*durationpb1.Duration)(m.Duration).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.Any != nil { + size, err := (*anypb1.Any)(m.Any).MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MessageWithWKT) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Any != nil { + l = (*anypb1.Any)(m.Any).SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.Duration != nil { + l = (*durationpb1.Duration)(m.Duration).SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.Empty != nil { + l = (*emptypb1.Empty)(m.Empty).SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.FieldMask != nil { + l = (*fieldmaskpb1.FieldMask)(m.FieldMask).SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.Timestamp != nil { + l = (*timestamppb1.Timestamp)(m.Timestamp).SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.DoubleValue != nil { + l = (*wrapperspb1.DoubleValue)(m.DoubleValue).SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.FloatValue != nil { + l = (*wrapperspb1.FloatValue)(m.FloatValue).SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.Int64Value != nil { + l = (*wrapperspb1.Int64Value)(m.Int64Value).SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.Uint64Value != nil { + l = (*wrapperspb1.UInt64Value)(m.Uint64Value).SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.Int32Value != nil { + l = (*wrapperspb1.Int32Value)(m.Int32Value).SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.Uint32Value != nil { + l = (*wrapperspb1.UInt32Value)(m.Uint32Value).SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.BoolValue != nil { + l = (*wrapperspb1.BoolValue)(m.BoolValue).SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.StringValue != nil { + l = (*wrapperspb1.StringValue)(m.StringValue).SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.BytesValue != nil { + l = (*wrapperspb1.BytesValue)(m.BytesValue).SizeVT() + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func sov(x uint64) (n int) { + return (bits.Len64(x|1) + 6) / 7 +} +func soz(x uint64) (n int) { + return sov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MessageWithWKT) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MessageWithWKT: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MessageWithWKT: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Any", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Any == nil { + m.Any = &anypb.Any{} + } + if err := (*anypb1.Any)(m.Any).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Duration == nil { + m.Duration = &durationpb.Duration{} + } + if err := (*durationpb1.Duration)(m.Duration).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Empty", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Empty == nil { + m.Empty = &emptypb.Empty{} + } + if err := (*emptypb1.Empty)(m.Empty).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FieldMask", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.FieldMask == nil { + m.FieldMask = &fieldmaskpb.FieldMask{} + } + if err := (*fieldmaskpb1.FieldMask)(m.FieldMask).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Timestamp == nil { + m.Timestamp = ×tamppb.Timestamp{} + } + if err := (*timestamppb1.Timestamp)(m.Timestamp).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DoubleValue", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DoubleValue == nil { + m.DoubleValue = &wrapperspb.DoubleValue{} + } + if err := (*wrapperspb1.DoubleValue)(m.DoubleValue).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FloatValue", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.FloatValue == nil { + m.FloatValue = &wrapperspb.FloatValue{} + } + if err := (*wrapperspb1.FloatValue)(m.FloatValue).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Int64Value", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Int64Value == nil { + m.Int64Value = &wrapperspb.Int64Value{} + } + if err := (*wrapperspb1.Int64Value)(m.Int64Value).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uint64Value", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Uint64Value == nil { + m.Uint64Value = &wrapperspb.UInt64Value{} + } + if err := (*wrapperspb1.UInt64Value)(m.Uint64Value).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Int32Value", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Int32Value == nil { + m.Int32Value = &wrapperspb.Int32Value{} + } + if err := (*wrapperspb1.Int32Value)(m.Int32Value).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uint32Value", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Uint32Value == nil { + m.Uint32Value = &wrapperspb.UInt32Value{} + } + if err := (*wrapperspb1.UInt32Value)(m.Uint32Value).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BoolValue", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.BoolValue == nil { + m.BoolValue = &wrapperspb.BoolValue{} + } + if err := (*wrapperspb1.BoolValue)(m.BoolValue).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StringValue", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.StringValue == nil { + m.StringValue = &wrapperspb.StringValue{} + } + if err := (*wrapperspb1.StringValue)(m.StringValue).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BytesValue", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.BytesValue == nil { + m.BytesValue = &wrapperspb.BytesValue{} + } + if err := (*wrapperspb1.BytesValue)(m.BytesValue).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func skip(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLength + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroup + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLength + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLength = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflow = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group") +) diff --git a/types/known/anypb/any_vtproto.pb.go b/types/known/anypb/any_vtproto.pb.go new file mode 100644 index 0000000..6328f82 --- /dev/null +++ b/types/known/anypb/any_vtproto.pb.go @@ -0,0 +1,373 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: (devel) +// source: google/protobuf/any.proto + +package anypb + +import ( + fmt "fmt" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + io "io" + bits "math/bits" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Any anypb.Any + +func (m *Any) CloneVT() *Any { + if m == nil { + return (*Any)(nil) + } + r := new(Any) + r.TypeUrl = m.TypeUrl + if rhs := m.Value; rhs != nil { + tmpBytes := make([]byte, len(rhs)) + copy(tmpBytes, rhs) + r.Value = tmpBytes + } + return r +} + +func (this *Any) EqualVT(that *Any) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.TypeUrl != that.TypeUrl { + return false + } + if string(this.Value) != string(that.Value) { + return false + } + return true +} + +func (m *Any) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Any) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Any) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarint(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if len(m.TypeUrl) > 0 { + i -= len(m.TypeUrl) + copy(dAtA[i:], m.TypeUrl) + i = encodeVarint(dAtA, i, uint64(len(m.TypeUrl))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarint(dAtA []byte, offset int, v uint64) int { + offset -= sov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Any) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Any) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *Any) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarint(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if len(m.TypeUrl) > 0 { + i -= len(m.TypeUrl) + copy(dAtA[i:], m.TypeUrl) + i = encodeVarint(dAtA, i, uint64(len(m.TypeUrl))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Any) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TypeUrl) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + return n +} + +func sov(x uint64) (n int) { + return (bits.Len64(x|1) + 6) / 7 +} +func soz(x uint64) (n int) { + return sov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Any) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Any: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Any: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TypeUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TypeUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func skip(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLength + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroup + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLength + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLength = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflow = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group") +) diff --git a/types/known/durationpb/duration_vtproto.pb.go b/types/known/durationpb/duration_vtproto.pb.go new file mode 100644 index 0000000..abbe887 --- /dev/null +++ b/types/known/durationpb/duration_vtproto.pb.go @@ -0,0 +1,331 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: (devel) +// source: google/protobuf/duration.proto + +package durationpb + +import ( + fmt "fmt" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + durationpb "google.golang.org/protobuf/types/known/durationpb" + io "io" + bits "math/bits" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Duration durationpb.Duration + +func (m *Duration) CloneVT() *Duration { + if m == nil { + return (*Duration)(nil) + } + r := new(Duration) + r.Seconds = m.Seconds + r.Nanos = m.Nanos + return r +} + +func (this *Duration) EqualVT(that *Duration) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Seconds != that.Seconds { + return false + } + if this.Nanos != that.Nanos { + return false + } + return true +} + +func (m *Duration) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Duration) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Duration) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Nanos != 0 { + i = encodeVarint(dAtA, i, uint64(m.Nanos)) + i-- + dAtA[i] = 0x10 + } + if m.Seconds != 0 { + i = encodeVarint(dAtA, i, uint64(m.Seconds)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarint(dAtA []byte, offset int, v uint64) int { + offset -= sov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Duration) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Duration) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *Duration) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Nanos != 0 { + i = encodeVarint(dAtA, i, uint64(m.Nanos)) + i-- + dAtA[i] = 0x10 + } + if m.Seconds != 0 { + i = encodeVarint(dAtA, i, uint64(m.Seconds)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Duration) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Seconds != 0 { + n += 1 + sov(uint64(m.Seconds)) + } + if m.Nanos != 0 { + n += 1 + sov(uint64(m.Nanos)) + } + return n +} + +func sov(x uint64) (n int) { + return (bits.Len64(x|1) + 6) / 7 +} +func soz(x uint64) (n int) { + return sov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Duration) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Duration: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Duration: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Seconds", wireType) + } + m.Seconds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Seconds |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Nanos", wireType) + } + m.Nanos = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Nanos |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func skip(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLength + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroup + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLength + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLength = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflow = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group") +) diff --git a/types/known/emptypb/empty_vtproto.pb.go b/types/known/emptypb/empty_vtproto.pb.go new file mode 100644 index 0000000..33043a6 --- /dev/null +++ b/types/known/emptypb/empty_vtproto.pb.go @@ -0,0 +1,259 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: (devel) +// source: google/protobuf/empty.proto + +package emptypb + +import ( + fmt "fmt" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + io "io" + bits "math/bits" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Empty emptypb.Empty + +func (m *Empty) CloneVT() *Empty { + if m == nil { + return (*Empty)(nil) + } + r := new(Empty) + return r +} + +func (this *Empty) EqualVT(that *Empty) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + return true +} + +func (m *Empty) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Empty) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Empty) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarint(dAtA []byte, offset int, v uint64) int { + offset -= sov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Empty) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Empty) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *Empty) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *Empty) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sov(x uint64) (n int) { + return (bits.Len64(x|1) + 6) / 7 +} +func soz(x uint64) (n int) { + return sov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Empty) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Empty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Empty: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func skip(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLength + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroup + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLength + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLength = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflow = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group") +) diff --git a/types/known/fieldmaskpb/field_mask_vtproto.pb.go b/types/known/fieldmaskpb/field_mask_vtproto.pb.go new file mode 100644 index 0000000..e466fe4 --- /dev/null +++ b/types/known/fieldmaskpb/field_mask_vtproto.pb.go @@ -0,0 +1,329 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: (devel) +// source: google/protobuf/field_mask.proto + +package fieldmaskpb + +import ( + fmt "fmt" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" + io "io" + bits "math/bits" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type FieldMask fieldmaskpb.FieldMask + +func (m *FieldMask) CloneVT() *FieldMask { + if m == nil { + return (*FieldMask)(nil) + } + r := new(FieldMask) + if rhs := m.Paths; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.Paths = tmpContainer + } + return r +} + +func (this *FieldMask) EqualVT(that *FieldMask) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Paths) != len(that.Paths) { + return false + } + for i, vx := range this.Paths { + vy := that.Paths[i] + if vx != vy { + return false + } + } + return true +} + +func (m *FieldMask) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FieldMask) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *FieldMask) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Paths) > 0 { + for iNdEx := len(m.Paths) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Paths[iNdEx]) + copy(dAtA[i:], m.Paths[iNdEx]) + i = encodeVarint(dAtA, i, uint64(len(m.Paths[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarint(dAtA []byte, offset int, v uint64) int { + offset -= sov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *FieldMask) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FieldMask) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *FieldMask) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Paths) > 0 { + for iNdEx := len(m.Paths) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Paths[iNdEx]) + copy(dAtA[i:], m.Paths[iNdEx]) + i = encodeVarint(dAtA, i, uint64(len(m.Paths[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *FieldMask) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Paths) > 0 { + for _, s := range m.Paths { + l = len(s) + n += 1 + l + sov(uint64(l)) + } + } + return n +} + +func sov(x uint64) (n int) { + return (bits.Len64(x|1) + 6) / 7 +} +func soz(x uint64) (n int) { + return sov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *FieldMask) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FieldMask: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FieldMask: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Paths", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Paths = append(m.Paths, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func skip(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLength + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroup + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLength + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLength = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflow = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group") +) diff --git a/types/known/timestamppb/timestamp_vtproto.pb.go b/types/known/timestamppb/timestamp_vtproto.pb.go new file mode 100644 index 0000000..8bb048a --- /dev/null +++ b/types/known/timestamppb/timestamp_vtproto.pb.go @@ -0,0 +1,331 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: (devel) +// source: google/protobuf/timestamp.proto + +package timestamppb + +import ( + fmt "fmt" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + io "io" + bits "math/bits" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Timestamp timestamppb.Timestamp + +func (m *Timestamp) CloneVT() *Timestamp { + if m == nil { + return (*Timestamp)(nil) + } + r := new(Timestamp) + r.Seconds = m.Seconds + r.Nanos = m.Nanos + return r +} + +func (this *Timestamp) EqualVT(that *Timestamp) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Seconds != that.Seconds { + return false + } + if this.Nanos != that.Nanos { + return false + } + return true +} + +func (m *Timestamp) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Timestamp) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Timestamp) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Nanos != 0 { + i = encodeVarint(dAtA, i, uint64(m.Nanos)) + i-- + dAtA[i] = 0x10 + } + if m.Seconds != 0 { + i = encodeVarint(dAtA, i, uint64(m.Seconds)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarint(dAtA []byte, offset int, v uint64) int { + offset -= sov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Timestamp) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Timestamp) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *Timestamp) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Nanos != 0 { + i = encodeVarint(dAtA, i, uint64(m.Nanos)) + i-- + dAtA[i] = 0x10 + } + if m.Seconds != 0 { + i = encodeVarint(dAtA, i, uint64(m.Seconds)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Timestamp) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Seconds != 0 { + n += 1 + sov(uint64(m.Seconds)) + } + if m.Nanos != 0 { + n += 1 + sov(uint64(m.Nanos)) + } + return n +} + +func sov(x uint64) (n int) { + return (bits.Len64(x|1) + 6) / 7 +} +func soz(x uint64) (n int) { + return sov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Timestamp) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Timestamp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Timestamp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Seconds", wireType) + } + m.Seconds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Seconds |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Nanos", wireType) + } + m.Nanos = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Nanos |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func skip(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLength + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroup + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLength + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLength = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflow = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group") +) diff --git a/types/known/wrapperspb/wrappers_vtproto.pb.go b/types/known/wrapperspb/wrappers_vtproto.pb.go new file mode 100644 index 0000000..ac889d5 --- /dev/null +++ b/types/known/wrapperspb/wrappers_vtproto.pb.go @@ -0,0 +1,1706 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: (devel) +// source: google/protobuf/wrappers.proto + +package wrapperspb + +import ( + binary "encoding/binary" + fmt "fmt" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" + io "io" + math "math" + bits "math/bits" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type DoubleValue wrapperspb.DoubleValue +type FloatValue wrapperspb.FloatValue +type Int64Value wrapperspb.Int64Value +type UInt64Value wrapperspb.UInt64Value +type Int32Value wrapperspb.Int32Value +type UInt32Value wrapperspb.UInt32Value +type BoolValue wrapperspb.BoolValue +type StringValue wrapperspb.StringValue +type BytesValue wrapperspb.BytesValue + +func (m *DoubleValue) CloneVT() *DoubleValue { + if m == nil { + return (*DoubleValue)(nil) + } + r := new(DoubleValue) + r.Value = m.Value + return r +} + +func (m *FloatValue) CloneVT() *FloatValue { + if m == nil { + return (*FloatValue)(nil) + } + r := new(FloatValue) + r.Value = m.Value + return r +} + +func (m *Int64Value) CloneVT() *Int64Value { + if m == nil { + return (*Int64Value)(nil) + } + r := new(Int64Value) + r.Value = m.Value + return r +} + +func (m *UInt64Value) CloneVT() *UInt64Value { + if m == nil { + return (*UInt64Value)(nil) + } + r := new(UInt64Value) + r.Value = m.Value + return r +} + +func (m *Int32Value) CloneVT() *Int32Value { + if m == nil { + return (*Int32Value)(nil) + } + r := new(Int32Value) + r.Value = m.Value + return r +} + +func (m *UInt32Value) CloneVT() *UInt32Value { + if m == nil { + return (*UInt32Value)(nil) + } + r := new(UInt32Value) + r.Value = m.Value + return r +} + +func (m *BoolValue) CloneVT() *BoolValue { + if m == nil { + return (*BoolValue)(nil) + } + r := new(BoolValue) + r.Value = m.Value + return r +} + +func (m *StringValue) CloneVT() *StringValue { + if m == nil { + return (*StringValue)(nil) + } + r := new(StringValue) + r.Value = m.Value + return r +} + +func (m *BytesValue) CloneVT() *BytesValue { + if m == nil { + return (*BytesValue)(nil) + } + r := new(BytesValue) + if rhs := m.Value; rhs != nil { + tmpBytes := make([]byte, len(rhs)) + copy(tmpBytes, rhs) + r.Value = tmpBytes + } + return r +} + +func (this *DoubleValue) EqualVT(that *DoubleValue) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Value != that.Value { + return false + } + return true +} + +func (this *FloatValue) EqualVT(that *FloatValue) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Value != that.Value { + return false + } + return true +} + +func (this *Int64Value) EqualVT(that *Int64Value) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Value != that.Value { + return false + } + return true +} + +func (this *UInt64Value) EqualVT(that *UInt64Value) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Value != that.Value { + return false + } + return true +} + +func (this *Int32Value) EqualVT(that *Int32Value) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Value != that.Value { + return false + } + return true +} + +func (this *UInt32Value) EqualVT(that *UInt32Value) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Value != that.Value { + return false + } + return true +} + +func (this *BoolValue) EqualVT(that *BoolValue) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Value != that.Value { + return false + } + return true +} + +func (this *StringValue) EqualVT(that *StringValue) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Value != that.Value { + return false + } + return true +} + +func (this *BytesValue) EqualVT(that *BytesValue) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if string(this.Value) != string(that.Value) { + return false + } + return true +} + +func (m *DoubleValue) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DoubleValue) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DoubleValue) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) + i-- + dAtA[i] = 0x9 + } + return len(dAtA) - i, nil +} + +func (m *FloatValue) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FloatValue) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *FloatValue) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != 0 { + i -= 4 + binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Value)))) + i-- + dAtA[i] = 0xd + } + return len(dAtA) - i, nil +} + +func (m *Int64Value) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Int64Value) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Int64Value) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != 0 { + i = encodeVarint(dAtA, i, uint64(m.Value)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *UInt64Value) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UInt64Value) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *UInt64Value) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != 0 { + i = encodeVarint(dAtA, i, uint64(m.Value)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Int32Value) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Int32Value) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Int32Value) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != 0 { + i = encodeVarint(dAtA, i, uint64(m.Value)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *UInt32Value) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UInt32Value) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *UInt32Value) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != 0 { + i = encodeVarint(dAtA, i, uint64(m.Value)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BoolValue) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BoolValue) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *BoolValue) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value { + i-- + if m.Value { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *StringValue) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StringValue) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *StringValue) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarint(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *BytesValue) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BytesValue) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *BytesValue) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarint(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarint(dAtA []byte, offset int, v uint64) int { + offset -= sov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *DoubleValue) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DoubleValue) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *DoubleValue) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) + i-- + dAtA[i] = 0x9 + } + return len(dAtA) - i, nil +} + +func (m *FloatValue) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FloatValue) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *FloatValue) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != 0 { + i -= 4 + binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Value)))) + i-- + dAtA[i] = 0xd + } + return len(dAtA) - i, nil +} + +func (m *Int64Value) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Int64Value) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *Int64Value) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != 0 { + i = encodeVarint(dAtA, i, uint64(m.Value)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *UInt64Value) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UInt64Value) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *UInt64Value) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != 0 { + i = encodeVarint(dAtA, i, uint64(m.Value)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Int32Value) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Int32Value) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *Int32Value) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != 0 { + i = encodeVarint(dAtA, i, uint64(m.Value)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *UInt32Value) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UInt32Value) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *UInt32Value) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != 0 { + i = encodeVarint(dAtA, i, uint64(m.Value)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BoolValue) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BoolValue) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *BoolValue) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value { + i-- + if m.Value { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *StringValue) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StringValue) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *StringValue) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarint(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *BytesValue) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BytesValue) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *BytesValue) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarint(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DoubleValue) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 9 + } + return n +} + +func (m *FloatValue) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 5 + } + return n +} + +func (m *Int64Value) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 1 + sov(uint64(m.Value)) + } + return n +} + +func (m *UInt64Value) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 1 + sov(uint64(m.Value)) + } + return n +} + +func (m *Int32Value) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 1 + sov(uint64(m.Value)) + } + return n +} + +func (m *UInt32Value) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 1 + sov(uint64(m.Value)) + } + return n +} + +func (m *BoolValue) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value { + n += 2 + } + return n +} + +func (m *StringValue) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Value) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + return n +} + +func (m *BytesValue) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Value) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + return n +} + +func sov(x uint64) (n int) { + return (bits.Len64(x|1) + 6) / 7 +} +func soz(x uint64) (n int) { + return sov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *DoubleValue) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DoubleValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DoubleValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.Value = float64(math.Float64frombits(v)) + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FloatValue) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FloatValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FloatValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + v = uint32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.Value = float32(math.Float32frombits(v)) + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Int64Value) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Int64Value: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Int64Value: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + m.Value = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Value |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UInt64Value) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UInt64Value: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UInt64Value: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + m.Value = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Value |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Int32Value) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Int32Value: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Int32Value: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + m.Value = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Value |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UInt32Value) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UInt32Value: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UInt32Value: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + m.Value = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Value |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BoolValue) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: BoolValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BoolValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Value = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StringValue) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StringValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StringValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BytesValue) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: BytesValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BytesValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func skip(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLength + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroup + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLength + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLength = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflow = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group") +)