summaryrefslogtreecommitdiff
path: root/vendor/google.golang.org/protobuf/proto
diff options
context:
space:
mode:
authordependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>2020-05-21 09:08:47 +0000
committerDaniel J Walsh <dwalsh@redhat.com>2020-05-21 07:35:42 -0400
commitcdd1f2bbaf99f5fae8f5c08a25bccdf478cd9ada (patch)
treedb1c0b9dfc258c40779d38875e71240f93544d22 /vendor/google.golang.org/protobuf/proto
parent8db7b9ea219ef06c50919dcfabdfdca5676e1456 (diff)
downloadpodman-cdd1f2bbaf99f5fae8f5c08a25bccdf478cd9ada.tar.gz
podman-cdd1f2bbaf99f5fae8f5c08a25bccdf478cd9ada.tar.bz2
podman-cdd1f2bbaf99f5fae8f5c08a25bccdf478cd9ada.zip
Bump github.com/onsi/gomega from 1.10.0 to 1.10.1
Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.10.0 to 1.10.1. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.10.0...v1.10.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/google.golang.org/protobuf/proto')
-rw-r--r--vendor/google.golang.org/protobuf/proto/checkinit.go71
-rw-r--r--vendor/google.golang.org/protobuf/proto/decode.go270
-rw-r--r--vendor/google.golang.org/protobuf/proto/decode_gen.go603
-rw-r--r--vendor/google.golang.org/protobuf/proto/doc.go94
-rw-r--r--vendor/google.golang.org/protobuf/proto/encode.go343
-rw-r--r--vendor/google.golang.org/protobuf/proto/encode_gen.go97
-rw-r--r--vendor/google.golang.org/protobuf/proto/equal.go154
-rw-r--r--vendor/google.golang.org/protobuf/proto/extension.go92
-rw-r--r--vendor/google.golang.org/protobuf/proto/merge.go139
-rw-r--r--vendor/google.golang.org/protobuf/proto/messageset.go88
-rw-r--r--vendor/google.golang.org/protobuf/proto/proto.go34
-rw-r--r--vendor/google.golang.org/protobuf/proto/proto_methods.go19
-rw-r--r--vendor/google.golang.org/protobuf/proto/proto_reflect.go19
-rw-r--r--vendor/google.golang.org/protobuf/proto/reset.go43
-rw-r--r--vendor/google.golang.org/protobuf/proto/size.go94
-rw-r--r--vendor/google.golang.org/protobuf/proto/size_gen.go55
-rw-r--r--vendor/google.golang.org/protobuf/proto/wrappers.go29
17 files changed, 2244 insertions, 0 deletions
diff --git a/vendor/google.golang.org/protobuf/proto/checkinit.go b/vendor/google.golang.org/protobuf/proto/checkinit.go
new file mode 100644
index 000000000..3e9a6a2f6
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/checkinit.go
@@ -0,0 +1,71 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+import (
+ "google.golang.org/protobuf/internal/errors"
+ "google.golang.org/protobuf/reflect/protoreflect"
+ "google.golang.org/protobuf/runtime/protoiface"
+)
+
+// CheckInitialized returns an error if any required fields in m are not set.
+func CheckInitialized(m Message) error {
+ // Treat a nil message interface as an "untyped" empty message,
+ // which we assume to have no required fields.
+ if m == nil {
+ return nil
+ }
+
+ return checkInitialized(m.ProtoReflect())
+}
+
+// CheckInitialized returns an error if any required fields in m are not set.
+func checkInitialized(m protoreflect.Message) error {
+ if methods := protoMethods(m); methods != nil && methods.CheckInitialized != nil {
+ _, err := methods.CheckInitialized(protoiface.CheckInitializedInput{
+ Message: m,
+ })
+ return err
+ }
+ return checkInitializedSlow(m)
+}
+
+func checkInitializedSlow(m protoreflect.Message) error {
+ md := m.Descriptor()
+ fds := md.Fields()
+ for i, nums := 0, md.RequiredNumbers(); i < nums.Len(); i++ {
+ fd := fds.ByNumber(nums.Get(i))
+ if !m.Has(fd) {
+ return errors.RequiredNotSet(string(fd.FullName()))
+ }
+ }
+ var err error
+ m.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
+ switch {
+ case fd.IsList():
+ if fd.Message() == nil {
+ return true
+ }
+ for i, list := 0, v.List(); i < list.Len() && err == nil; i++ {
+ err = checkInitialized(list.Get(i).Message())
+ }
+ case fd.IsMap():
+ if fd.MapValue().Message() == nil {
+ return true
+ }
+ v.Map().Range(func(key protoreflect.MapKey, v protoreflect.Value) bool {
+ err = checkInitialized(v.Message())
+ return err == nil
+ })
+ default:
+ if fd.Message() == nil {
+ return true
+ }
+ err = checkInitialized(v.Message())
+ }
+ return err == nil
+ })
+ return err
+}
diff --git a/vendor/google.golang.org/protobuf/proto/decode.go b/vendor/google.golang.org/protobuf/proto/decode.go
new file mode 100644
index 000000000..128214760
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/decode.go
@@ -0,0 +1,270 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+import (
+ "google.golang.org/protobuf/encoding/protowire"
+ "google.golang.org/protobuf/internal/encoding/messageset"
+ "google.golang.org/protobuf/internal/errors"
+ "google.golang.org/protobuf/internal/flags"
+ "google.golang.org/protobuf/internal/pragma"
+ "google.golang.org/protobuf/reflect/protoreflect"
+ "google.golang.org/protobuf/reflect/protoregistry"
+ "google.golang.org/protobuf/runtime/protoiface"
+)
+
+// UnmarshalOptions configures the unmarshaler.
+//
+// Example usage:
+// err := UnmarshalOptions{DiscardUnknown: true}.Unmarshal(b, m)
+type UnmarshalOptions struct {
+ pragma.NoUnkeyedLiterals
+
+ // Merge merges the input into the destination message.
+ // The default behavior is to always reset the message before unmarshaling,
+ // unless Merge is specified.
+ Merge bool
+
+ // AllowPartial accepts input for messages that will result in missing
+ // required fields. If AllowPartial is false (the default), Unmarshal will
+ // return an error if there are any missing required fields.
+ AllowPartial bool
+
+ // If DiscardUnknown is set, unknown fields are ignored.
+ DiscardUnknown bool
+
+ // Resolver is used for looking up types when unmarshaling extension fields.
+ // If nil, this defaults to using protoregistry.GlobalTypes.
+ Resolver interface {
+ FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error)
+ FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error)
+ }
+}
+
+// Unmarshal parses the wire-format message in b and places the result in m.
+func Unmarshal(b []byte, m Message) error {
+ _, err := UnmarshalOptions{}.unmarshal(b, m.ProtoReflect())
+ return err
+}
+
+// Unmarshal parses the wire-format message in b and places the result in m.
+func (o UnmarshalOptions) Unmarshal(b []byte, m Message) error {
+ _, err := o.unmarshal(b, m.ProtoReflect())
+ return err
+}
+
+// UnmarshalState parses a wire-format message and places the result in m.
+//
+// This method permits fine-grained control over the unmarshaler.
+// Most users should use Unmarshal instead.
+func (o UnmarshalOptions) UnmarshalState(in protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) {
+ return o.unmarshal(in.Buf, in.Message)
+}
+
+func (o UnmarshalOptions) unmarshal(b []byte, m protoreflect.Message) (out protoiface.UnmarshalOutput, err error) {
+ if o.Resolver == nil {
+ o.Resolver = protoregistry.GlobalTypes
+ }
+ if !o.Merge {
+ Reset(m.Interface()) // TODO
+ }
+ allowPartial := o.AllowPartial
+ o.Merge = true
+ o.AllowPartial = true
+ methods := protoMethods(m)
+ if methods != nil && methods.Unmarshal != nil &&
+ !(o.DiscardUnknown && methods.Flags&protoiface.SupportUnmarshalDiscardUnknown == 0) {
+ in := protoiface.UnmarshalInput{
+ Message: m,
+ Buf: b,
+ Resolver: o.Resolver,
+ }
+ if o.DiscardUnknown {
+ in.Flags |= protoiface.UnmarshalDiscardUnknown
+ }
+ out, err = methods.Unmarshal(in)
+ } else {
+ err = o.unmarshalMessageSlow(b, m)
+ }
+ if err != nil {
+ return out, err
+ }
+ if allowPartial || (out.Flags&protoiface.UnmarshalInitialized != 0) {
+ return out, nil
+ }
+ return out, checkInitialized(m)
+}
+
+func (o UnmarshalOptions) unmarshalMessage(b []byte, m protoreflect.Message) error {
+ _, err := o.unmarshal(b, m)
+ return err
+}
+
+func (o UnmarshalOptions) unmarshalMessageSlow(b []byte, m protoreflect.Message) error {
+ md := m.Descriptor()
+ if messageset.IsMessageSet(md) {
+ return unmarshalMessageSet(b, m, o)
+ }
+ fields := md.Fields()
+ for len(b) > 0 {
+ // Parse the tag (field number and wire type).
+ num, wtyp, tagLen := protowire.ConsumeTag(b)
+ if tagLen < 0 {
+ return protowire.ParseError(tagLen)
+ }
+ if num > protowire.MaxValidNumber {
+ return errors.New("invalid field number")
+ }
+
+ // Find the field descriptor for this field number.
+ fd := fields.ByNumber(num)
+ if fd == nil && md.ExtensionRanges().Has(num) {
+ extType, err := o.Resolver.FindExtensionByNumber(md.FullName(), num)
+ if err != nil && err != protoregistry.NotFound {
+ return errors.New("%v: unable to resolve extension %v: %v", md.FullName(), num, err)
+ }
+ if extType != nil {
+ fd = extType.TypeDescriptor()
+ }
+ }
+ var err error
+ if fd == nil {
+ err = errUnknown
+ } else if flags.ProtoLegacy {
+ if fd.IsWeak() && fd.Message().IsPlaceholder() {
+ err = errUnknown // weak referent is not linked in
+ }
+ }
+
+ // Parse the field value.
+ var valLen int
+ switch {
+ case err != nil:
+ case fd.IsList():
+ valLen, err = o.unmarshalList(b[tagLen:], wtyp, m.Mutable(fd).List(), fd)
+ case fd.IsMap():
+ valLen, err = o.unmarshalMap(b[tagLen:], wtyp, m.Mutable(fd).Map(), fd)
+ default:
+ valLen, err = o.unmarshalSingular(b[tagLen:], wtyp, m, fd)
+ }
+ if err != nil {
+ if err != errUnknown {
+ return err
+ }
+ valLen = protowire.ConsumeFieldValue(num, wtyp, b[tagLen:])
+ if valLen < 0 {
+ return protowire.ParseError(valLen)
+ }
+ if !o.DiscardUnknown {
+ m.SetUnknown(append(m.GetUnknown(), b[:tagLen+valLen]...))
+ }
+ }
+ b = b[tagLen+valLen:]
+ }
+ return nil
+}
+
+func (o UnmarshalOptions) unmarshalSingular(b []byte, wtyp protowire.Type, m protoreflect.Message, fd protoreflect.FieldDescriptor) (n int, err error) {
+ v, n, err := o.unmarshalScalar(b, wtyp, fd)
+ if err != nil {
+ return 0, err
+ }
+ switch fd.Kind() {
+ case protoreflect.GroupKind, protoreflect.MessageKind:
+ m2 := m.Mutable(fd).Message()
+ if err := o.unmarshalMessage(v.Bytes(), m2); err != nil {
+ return n, err
+ }
+ default:
+ // Non-message scalars replace the previous value.
+ m.Set(fd, v)
+ }
+ return n, nil
+}
+
+func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv protoreflect.Map, fd protoreflect.FieldDescriptor) (n int, err error) {
+ if wtyp != protowire.BytesType {
+ return 0, errUnknown
+ }
+ b, n = protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ var (
+ keyField = fd.MapKey()
+ valField = fd.MapValue()
+ key protoreflect.Value
+ val protoreflect.Value
+ haveKey bool
+ haveVal bool
+ )
+ switch valField.Kind() {
+ case protoreflect.GroupKind, protoreflect.MessageKind:
+ val = mapv.NewValue()
+ }
+ // Map entries are represented as a two-element message with fields
+ // containing the key and value.
+ for len(b) > 0 {
+ num, wtyp, n := protowire.ConsumeTag(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ if num > protowire.MaxValidNumber {
+ return 0, errors.New("invalid field number")
+ }
+ b = b[n:]
+ err = errUnknown
+ switch num {
+ case 1:
+ key, n, err = o.unmarshalScalar(b, wtyp, keyField)
+ if err != nil {
+ break
+ }
+ haveKey = true
+ case 2:
+ var v protoreflect.Value
+ v, n, err = o.unmarshalScalar(b, wtyp, valField)
+ if err != nil {
+ break
+ }
+ switch valField.Kind() {
+ case protoreflect.GroupKind, protoreflect.MessageKind:
+ if err := o.unmarshalMessage(v.Bytes(), val.Message()); err != nil {
+ return 0, err
+ }
+ default:
+ val = v
+ }
+ haveVal = true
+ }
+ if err == errUnknown {
+ n = protowire.ConsumeFieldValue(num, wtyp, b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ } else if err != nil {
+ return 0, err
+ }
+ b = b[n:]
+ }
+ // Every map entry should have entries for key and value, but this is not strictly required.
+ if !haveKey {
+ key = keyField.Default()
+ }
+ if !haveVal {
+ switch valField.Kind() {
+ case protoreflect.GroupKind, protoreflect.MessageKind:
+ default:
+ val = valField.Default()
+ }
+ }
+ mapv.Set(key.MapKey(), val)
+ return n, nil
+}
+
+// errUnknown is used internally to indicate fields which should be added
+// to the unknown field set of a message. It is never returned from an exported
+// function.
+var errUnknown = errors.New("BUG: internal error (unknown)")
diff --git a/vendor/google.golang.org/protobuf/proto/decode_gen.go b/vendor/google.golang.org/protobuf/proto/decode_gen.go
new file mode 100644
index 000000000..d6dc904dc
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/decode_gen.go
@@ -0,0 +1,603 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Code generated by generate-types. DO NOT EDIT.
+
+package proto
+
+import (
+ "math"
+ "unicode/utf8"
+
+ "google.golang.org/protobuf/encoding/protowire"
+ "google.golang.org/protobuf/internal/errors"
+ "google.golang.org/protobuf/internal/strs"
+ "google.golang.org/protobuf/reflect/protoreflect"
+)
+
+// unmarshalScalar decodes a value of the given kind.
+//
+// Message values are decoded into a []byte which aliases the input data.
+func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd protoreflect.FieldDescriptor) (val protoreflect.Value, n int, err error) {
+ switch fd.Kind() {
+ case protoreflect.BoolKind:
+ if wtyp != protowire.VarintType {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfBool(protowire.DecodeBool(v)), n, nil
+ case protoreflect.EnumKind:
+ if wtyp != protowire.VarintType {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)), n, nil
+ case protoreflect.Int32Kind:
+ if wtyp != protowire.VarintType {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfInt32(int32(v)), n, nil
+ case protoreflect.Sint32Kind:
+ if wtyp != protowire.VarintType {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))), n, nil
+ case protoreflect.Uint32Kind:
+ if wtyp != protowire.VarintType {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfUint32(uint32(v)), n, nil
+ case protoreflect.Int64Kind:
+ if wtyp != protowire.VarintType {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfInt64(int64(v)), n, nil
+ case protoreflect.Sint64Kind:
+ if wtyp != protowire.VarintType {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)), n, nil
+ case protoreflect.Uint64Kind:
+ if wtyp != protowire.VarintType {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfUint64(v), n, nil
+ case protoreflect.Sfixed32Kind:
+ if wtyp != protowire.Fixed32Type {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeFixed32(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfInt32(int32(v)), n, nil
+ case protoreflect.Fixed32Kind:
+ if wtyp != protowire.Fixed32Type {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeFixed32(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfUint32(uint32(v)), n, nil
+ case protoreflect.FloatKind:
+ if wtyp != protowire.Fixed32Type {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeFixed32(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))), n, nil
+ case protoreflect.Sfixed64Kind:
+ if wtyp != protowire.Fixed64Type {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeFixed64(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfInt64(int64(v)), n, nil
+ case protoreflect.Fixed64Kind:
+ if wtyp != protowire.Fixed64Type {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeFixed64(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfUint64(v), n, nil
+ case protoreflect.DoubleKind:
+ if wtyp != protowire.Fixed64Type {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeFixed64(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfFloat64(math.Float64frombits(v)), n, nil
+ case protoreflect.StringKind:
+ if wtyp != protowire.BytesType {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
+ return protoreflect.Value{}, 0, errors.InvalidUTF8(string(fd.FullName()))
+ }
+ return protoreflect.ValueOfString(string(v)), n, nil
+ case protoreflect.BytesKind:
+ if wtyp != protowire.BytesType {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfBytes(append(emptyBuf[:], v...)), n, nil
+ case protoreflect.MessageKind:
+ if wtyp != protowire.BytesType {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfBytes(v), n, nil
+ case protoreflect.GroupKind:
+ if wtyp != protowire.StartGroupType {
+ return val, 0, errUnknown
+ }
+ v, n := protowire.ConsumeGroup(fd.Number(), b)
+ if n < 0 {
+ return val, 0, protowire.ParseError(n)
+ }
+ return protoreflect.ValueOfBytes(v), n, nil
+ default:
+ return val, 0, errUnknown
+ }
+}
+
+func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list protoreflect.List, fd protoreflect.FieldDescriptor) (n int, err error) {
+ switch fd.Kind() {
+ case protoreflect.BoolKind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeVarint(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.VarintType {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
+ return n, nil
+ case protoreflect.EnumKind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeVarint(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.VarintType {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
+ return n, nil
+ case protoreflect.Int32Kind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeVarint(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfInt32(int32(v)))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.VarintType {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfInt32(int32(v)))
+ return n, nil
+ case protoreflect.Sint32Kind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeVarint(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.VarintType {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
+ return n, nil
+ case protoreflect.Uint32Kind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeVarint(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfUint32(uint32(v)))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.VarintType {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfUint32(uint32(v)))
+ return n, nil
+ case protoreflect.Int64Kind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeVarint(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfInt64(int64(v)))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.VarintType {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfInt64(int64(v)))
+ return n, nil
+ case protoreflect.Sint64Kind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeVarint(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.VarintType {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
+ return n, nil
+ case protoreflect.Uint64Kind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeVarint(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfUint64(v))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.VarintType {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeVarint(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfUint64(v))
+ return n, nil
+ case protoreflect.Sfixed32Kind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeFixed32(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfInt32(int32(v)))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.Fixed32Type {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeFixed32(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfInt32(int32(v)))
+ return n, nil
+ case protoreflect.Fixed32Kind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeFixed32(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfUint32(uint32(v)))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.Fixed32Type {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeFixed32(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfUint32(uint32(v)))
+ return n, nil
+ case protoreflect.FloatKind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeFixed32(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.Fixed32Type {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeFixed32(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
+ return n, nil
+ case protoreflect.Sfixed64Kind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeFixed64(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfInt64(int64(v)))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.Fixed64Type {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeFixed64(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfInt64(int64(v)))
+ return n, nil
+ case protoreflect.Fixed64Kind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeFixed64(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfUint64(v))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.Fixed64Type {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeFixed64(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfUint64(v))
+ return n, nil
+ case protoreflect.DoubleKind:
+ if wtyp == protowire.BytesType {
+ buf, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ for len(buf) > 0 {
+ v, n := protowire.ConsumeFixed64(buf)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ buf = buf[n:]
+ list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
+ }
+ return n, nil
+ }
+ if wtyp != protowire.Fixed64Type {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeFixed64(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
+ return n, nil
+ case protoreflect.StringKind:
+ if wtyp != protowire.BytesType {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
+ return 0, errors.InvalidUTF8(string(fd.FullName()))
+ }
+ list.Append(protoreflect.ValueOfString(string(v)))
+ return n, nil
+ case protoreflect.BytesKind:
+ if wtyp != protowire.BytesType {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ list.Append(protoreflect.ValueOfBytes(append(emptyBuf[:], v...)))
+ return n, nil
+ case protoreflect.MessageKind:
+ if wtyp != protowire.BytesType {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeBytes(b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ m := list.NewElement()
+ if err := o.unmarshalMessage(v, m.Message()); err != nil {
+ return 0, err
+ }
+ list.Append(m)
+ return n, nil
+ case protoreflect.GroupKind:
+ if wtyp != protowire.StartGroupType {
+ return 0, errUnknown
+ }
+ v, n := protowire.ConsumeGroup(fd.Number(), b)
+ if n < 0 {
+ return 0, protowire.ParseError(n)
+ }
+ m := list.NewElement()
+ if err := o.unmarshalMessage(v, m.Message()); err != nil {
+ return 0, err
+ }
+ list.Append(m)
+ return n, nil
+ default:
+ return 0, errUnknown
+ }
+}
+
+// We append to an empty array rather than a nil []byte to get non-nil zero-length byte slices.
+var emptyBuf [0]byte
diff --git a/vendor/google.golang.org/protobuf/proto/doc.go b/vendor/google.golang.org/protobuf/proto/doc.go
new file mode 100644
index 000000000..c52d8c4ab
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/doc.go
@@ -0,0 +1,94 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package proto provides functions operating on protocol buffer messages.
+//
+// For documentation on protocol buffers in general, see:
+//
+// https://developers.google.com/protocol-buffers
+//
+// For a tutorial on using protocol buffers with Go, see:
+//
+// https://developers.google.com/protocol-buffers/docs/gotutorial
+//
+// For a guide to generated Go protocol buffer code, see:
+//
+// https://developers.google.com/protocol-buffers/docs/reference/go-generated
+//
+//
+// Binary serialization
+//
+// This package contains functions to convert to and from the wire format,
+// an efficient binary serialization of protocol buffers.
+//
+// • Size reports the size of a message in the wire format.
+//
+// • Marshal converts a message to the wire format.
+// The MarshalOptions type provides more control over wire marshaling.
+//
+// • Unmarshal converts a message from the wire format.
+// The UnmarshalOptions type provides more control over wire unmarshaling.
+//
+//
+// Basic message operations
+//
+// • Clone makes a deep copy of a message.
+//
+// • Merge merges the content of a message into another.
+//
+// • Equal compares two messages. For more control over comparisons
+// and detailed reporting of differences, see package
+// "google.golang.org/protobuf/testing/protocmp".
+//
+// • Reset clears the content of a message.
+//
+// • CheckInitialized reports whether all required fields in a message are set.
+//
+//
+// Optional scalar constructors
+//
+// The API for some generated messages represents optional scalar fields
+// as pointers to a value. For example, an optional string field has the
+// Go type *string.
+//
+// • Bool, Int32, Int64, Uint32, Uint64, Float32, Float64, and String
+// take a value and return a pointer to a new instance of it,
+// to simplify construction of optional field values.
+//
+// Generated enum types usually have an Enum method which performs the
+// same operation.
+//
+// Optional scalar fields are only supported in proto2.
+//
+//
+// Extension accessors
+//
+// • HasExtension, GetExtension, SetExtension, and ClearExtension
+// access extension field values in a protocol buffer message.
+//
+// Extension fields are only supported in proto2.
+//
+//
+// Related packages
+//
+// • Package "google.golang.org/protobuf/encoding/protojson" converts messages to
+// and from JSON.
+//
+// • Package "google.golang.org/protobuf/encoding/prototext" converts messages to
+// and from the text format.
+//
+// • Package "google.golang.org/protobuf/reflect/protoreflect" provides a
+// reflection interface for protocol buffer data types.
+//
+// • Package "google.golang.org/protobuf/testing/protocmp" provides features
+// to compare protocol buffer messages with the "github.com/google/go-cmp/cmp"
+// package.
+//
+// • Package "google.golang.org/protobuf/types/dynamicpb" provides a dynamic
+// message type, suitable for working with messages where the protocol buffer
+// type is only known at runtime.
+//
+// This module contains additional packages for more specialized use cases.
+// Consult the individual package documentation for details.
+package proto
diff --git a/vendor/google.golang.org/protobuf/proto/encode.go b/vendor/google.golang.org/protobuf/proto/encode.go
new file mode 100644
index 000000000..456bfda47
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/encode.go
@@ -0,0 +1,343 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+import (
+ "sort"
+
+ "google.golang.org/protobuf/encoding/protowire"
+ "google.golang.org/protobuf/internal/encoding/messageset"
+ "google.golang.org/protobuf/internal/fieldsort"
+ "google.golang.org/protobuf/internal/mapsort"
+ "google.golang.org/protobuf/internal/pragma"
+ "google.golang.org/protobuf/reflect/protoreflect"
+ "google.golang.org/protobuf/runtime/protoiface"
+)
+
+// MarshalOptions configures the marshaler.
+//
+// Example usage:
+// b, err := MarshalOptions{Deterministic: true}.Marshal(m)
+type MarshalOptions struct {
+ pragma.NoUnkeyedLiterals
+
+ // AllowPartial allows messages that have missing required fields to marshal
+ // without returning an error. If AllowPartial is false (the default),
+ // Marshal will return an error if there are any missing required fields.
+ AllowPartial bool
+
+ // Deterministic controls whether the same message will always be
+ // serialized to the same bytes within the same binary.
+ //
+ // Setting this option guarantees that repeated serialization of
+ // the same message will return the same bytes, and that different
+ // processes of the same binary (which may be executing on different
+ // machines) will serialize equal messages to the same bytes.
+ // It has no effect on the resulting size of the encoded message compared
+ // to a non-deterministic marshal.
+ //
+ // Note that the deterministic serialization is NOT canonical across
+ // languages. It is not guaranteed to remain stable over time. It is
+ // unstable across different builds with schema changes due to unknown
+ // fields. Users who need canonical serialization (e.g., persistent
+ // storage in a canonical form, fingerprinting, etc.) must define
+ // their own canonicalization specification and implement their own
+ // serializer rather than relying on this API.
+ //
+ // If deterministic serialization is requested, map entries will be
+ // sorted by keys in lexographical order. This is an implementation
+ // detail and subject to change.
+ Deterministic bool
+
+ // UseCachedSize indicates that the result of a previous Size call
+ // may be reused.
+ //
+ // Setting this option asserts that:
+ //
+ // 1. Size has previously been called on this message with identical
+ // options (except for UseCachedSize itself).
+ //
+ // 2. The message and all its submessages have not changed in any
+ // way since the Size call.
+ //
+ // If either of these invariants is violated,
+ // the results are undefined and may include panics or corrupted output.
+ //
+ // Implementations MAY take this option into account to provide
+ // better performance, but there is no guarantee that they will do so.
+ // There is absolutely no guarantee that Size followed by Marshal with
+ // UseCachedSize set will perform equivalently to Marshal alone.
+ UseCachedSize bool
+}
+
+// Marshal returns the wire-format encoding of m.
+func Marshal(m Message) ([]byte, error) {
+ // Treat nil message interface as an empty message; nothing to output.
+ if m == nil {
+ return nil, nil
+ }
+
+ out, err := MarshalOptions{}.marshal(nil, m.ProtoReflect())
+ if len(out.Buf) == 0 && err == nil {
+ out.Buf = emptyBytesForMessage(m)
+ }
+ return out.Buf, err
+}
+
+// Marshal returns the wire-format encoding of m.
+func (o MarshalOptions) Marshal(m Message) ([]byte, error) {
+ // Treat nil message interface as an empty message; nothing to output.
+ if m == nil {
+ return nil, nil
+ }
+
+ out, err := o.marshal(nil, m.ProtoReflect())
+ if len(out.Buf) == 0 && err == nil {
+ out.Buf = emptyBytesForMessage(m)
+ }
+ return out.Buf, err
+}
+
+// emptyBytesForMessage returns a nil buffer if and only if m is invalid,
+// otherwise it returns a non-nil empty buffer.
+//
+// This is to assist the edge-case where user-code does the following:
+// m1.OptionalBytes, _ = proto.Marshal(m2)
+// where they expect the proto2 "optional_bytes" field to be populated
+// if any only if m2 is a valid message.
+func emptyBytesForMessage(m Message) []byte {
+ if m == nil || !m.ProtoReflect().IsValid() {
+ return nil
+ }
+ return emptyBuf[:]
+}
+
+// MarshalAppend appends the wire-format encoding of m to b,
+// returning the result.
+func (o MarshalOptions) MarshalAppend(b []byte, m Message) ([]byte, error) {
+ // Treat nil message interface as an empty message; nothing to append.
+ if m == nil {
+ return b, nil
+ }
+
+ out, err := o.marshal(b, m.ProtoReflect())
+ return out.Buf, err
+}
+
+// MarshalState returns the wire-format encoding of a message.
+//
+// This method permits fine-grained control over the marshaler.
+// Most users should use Marshal instead.
+func (o MarshalOptions) MarshalState(in protoiface.MarshalInput) (protoiface.MarshalOutput, error) {
+ return o.marshal(in.Buf, in.Message)
+}
+
+func (o MarshalOptions) marshal(b []byte, m protoreflect.Message) (out protoiface.MarshalOutput, err error) {
+ allowPartial := o.AllowPartial
+ o.AllowPartial = true
+ if methods := protoMethods(m); methods != nil && methods.Marshal != nil &&
+ !(o.Deterministic && methods.Flags&protoiface.SupportMarshalDeterministic == 0) {
+ in := protoiface.MarshalInput{
+ Message: m,
+ Buf: b,
+ }
+ if o.Deterministic {
+ in.Flags |= protoiface.MarshalDeterministic
+ }
+ if o.UseCachedSize {
+ in.Flags |= protoiface.MarshalUseCachedSize
+ }
+ if methods.Size != nil {
+ sout := methods.Size(protoiface.SizeInput{
+ Message: m,
+ Flags: in.Flags,
+ })
+ if cap(b) < len(b)+sout.Size {
+ in.Buf = make([]byte, len(b), growcap(cap(b), len(b)+sout.Size))
+ copy(in.Buf, b)
+ }
+ in.Flags |= protoiface.MarshalUseCachedSize
+ }
+ out, err = methods.Marshal(in)
+ } else {
+ out.Buf, err = o.marshalMessageSlow(b, m)
+ }
+ if err != nil {
+ return out, err
+ }
+ if allowPartial {
+ return out, nil
+ }
+ return out, checkInitialized(m)
+}
+
+func (o MarshalOptions) marshalMessage(b []byte, m protoreflect.Message) ([]byte, error) {
+ out, err := o.marshal(b, m)
+ return out.Buf, err
+}
+
+// growcap scales up the capacity of a slice.
+//
+// Given a slice with a current capacity of oldcap and a desired
+// capacity of wantcap, growcap returns a new capacity >= wantcap.
+//
+// The algorithm is mostly identical to the one used by append as of Go 1.14.
+func growcap(oldcap, wantcap int) (newcap int) {
+ if wantcap > oldcap*2 {
+ newcap = wantcap
+ } else if oldcap < 1024 {
+ // The Go 1.14 runtime takes this case when len(s) < 1024,
+ // not when cap(s) < 1024. The difference doesn't seem
+ // significant here.
+ newcap = oldcap * 2
+ } else {
+ newcap = oldcap
+ for 0 < newcap && newcap < wantcap {
+ newcap += newcap / 4
+ }
+ if newcap <= 0 {
+ newcap = wantcap
+ }
+ }
+ return newcap
+}
+
+func (o MarshalOptions) marshalMessageSlow(b []byte, m protoreflect.Message) ([]byte, error) {
+ if messageset.IsMessageSet(m.Descriptor()) {
+ return marshalMessageSet(b, m, o)
+ }
+ // There are many choices for what order we visit fields in. The default one here
+ // is chosen for reasonable efficiency and simplicity given the protoreflect API.
+ // It is not deterministic, since Message.Range does not return fields in any
+ // defined order.
+ //
+ // When using deterministic serialization, we sort the known fields.
+ var err error
+ o.rangeFields(m, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
+ b, err = o.marshalField(b, fd, v)
+ return err == nil
+ })
+ if err != nil {
+ return b, err
+ }
+ b = append(b, m.GetUnknown()...)
+ return b, nil
+}
+
+// rangeFields visits fields in a defined order when deterministic serialization is enabled.
+func (o MarshalOptions) rangeFields(m protoreflect.Message, f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
+ if !o.Deterministic {
+ m.Range(f)
+ return
+ }
+ var fds []protoreflect.FieldDescriptor
+ m.Range(func(fd protoreflect.FieldDescriptor, _ protoreflect.Value) bool {
+ fds = append(fds, fd)
+ return true
+ })
+ sort.Slice(fds, func(a, b int) bool {
+ return fieldsort.Less(fds[a], fds[b])
+ })
+ for _, fd := range fds {
+ if !f(fd, m.Get(fd)) {
+ break
+ }
+ }
+}
+
+func (o MarshalOptions) marshalField(b []byte, fd protoreflect.FieldDescriptor, value protoreflect.Value) ([]byte, error) {
+ switch {
+ case fd.IsList():
+ return o.marshalList(b, fd, value.List())
+ case fd.IsMap():
+ return o.marshalMap(b, fd, value.Map())
+ default:
+ b = protowire.AppendTag(b, fd.Number(), wireTypes[fd.Kind()])
+ return o.marshalSingular(b, fd, value)
+ }
+}
+
+func (o MarshalOptions) marshalList(b []byte, fd protoreflect.FieldDescriptor, list protoreflect.List) ([]byte, error) {
+ if fd.IsPacked() && list.Len() > 0 {
+ b = protowire.AppendTag(b, fd.Number(), protowire.BytesType)
+ b, pos := appendSpeculativeLength(b)
+ for i, llen := 0, list.Len(); i < llen; i++ {
+ var err error
+ b, err = o.marshalSingular(b, fd, list.Get(i))
+ if err != nil {
+ return b, err
+ }
+ }
+ b = finishSpeculativeLength(b, pos)
+ return b, nil
+ }
+
+ kind := fd.Kind()
+ for i, llen := 0, list.Len(); i < llen; i++ {
+ var err error
+ b = protowire.AppendTag(b, fd.Number(), wireTypes[kind])
+ b, err = o.marshalSingular(b, fd, list.Get(i))
+ if err != nil {
+ return b, err
+ }
+ }
+ return b, nil
+}
+
+func (o MarshalOptions) marshalMap(b []byte, fd protoreflect.FieldDescriptor, mapv protoreflect.Map) ([]byte, error) {
+ keyf := fd.MapKey()
+ valf := fd.MapValue()
+ var err error
+ o.rangeMap(mapv, keyf.Kind(), func(key protoreflect.MapKey, value protoreflect.Value) bool {
+ b = protowire.AppendTag(b, fd.Number(), protowire.BytesType)
+ var pos int
+ b, pos = appendSpeculativeLength(b)
+
+ b, err = o.marshalField(b, keyf, key.Value())
+ if err != nil {
+ return false
+ }
+ b, err = o.marshalField(b, valf, value)
+ if err != nil {
+ return false
+ }
+ b = finishSpeculativeLength(b, pos)
+ return true
+ })
+ return b, err
+}
+
+func (o MarshalOptions) rangeMap(mapv protoreflect.Map, kind protoreflect.Kind, f func(protoreflect.MapKey, protoreflect.Value) bool) {
+ if !o.Deterministic {
+ mapv.Range(f)
+ return
+ }
+ mapsort.Range(mapv, kind, f)
+}
+
+// When encoding length-prefixed fields, we speculatively set aside some number of bytes
+// for the length, encode the data, and then encode the length (shifting the data if necessary
+// to make room).
+const speculativeLength = 1
+
+func appendSpeculativeLength(b []byte) ([]byte, int) {
+ pos := len(b)
+ b = append(b, "\x00\x00\x00\x00"[:speculativeLength]...)
+ return b, pos
+}
+
+func finishSpeculativeLength(b []byte, pos int) []byte {
+ mlen := len(b) - pos - speculativeLength
+ msiz := protowire.SizeVarint(uint64(mlen))
+ if msiz != speculativeLength {
+ for i := 0; i < msiz-speculativeLength; i++ {
+ b = append(b, 0)
+ }
+ copy(b[pos+msiz:], b[pos+speculativeLength:])
+ b = b[:pos+msiz+mlen]
+ }
+ protowire.AppendVarint(b[:pos], uint64(mlen))
+ return b
+}
diff --git a/vendor/google.golang.org/protobuf/proto/encode_gen.go b/vendor/google.golang.org/protobuf/proto/encode_gen.go
new file mode 100644
index 000000000..185dacfb4
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/encode_gen.go
@@ -0,0 +1,97 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Code generated by generate-types. DO NOT EDIT.
+
+package proto
+
+import (
+ "math"
+ "unicode/utf8"
+
+ "google.golang.org/protobuf/encoding/protowire"
+ "google.golang.org/protobuf/internal/errors"
+ "google.golang.org/protobuf/internal/strs"
+ "google.golang.org/protobuf/reflect/protoreflect"
+)
+
+var wireTypes = map[protoreflect.Kind]protowire.Type{
+ protoreflect.BoolKind: protowire.VarintType,
+ protoreflect.EnumKind: protowire.VarintType,
+ protoreflect.Int32Kind: protowire.VarintType,
+ protoreflect.Sint32Kind: protowire.VarintType,
+ protoreflect.Uint32Kind: protowire.VarintType,
+ protoreflect.Int64Kind: protowire.VarintType,
+ protoreflect.Sint64Kind: protowire.VarintType,
+ protoreflect.Uint64Kind: protowire.VarintType,
+ protoreflect.Sfixed32Kind: protowire.Fixed32Type,
+ protoreflect.Fixed32Kind: protowire.Fixed32Type,
+ protoreflect.FloatKind: protowire.Fixed32Type,
+ protoreflect.Sfixed64Kind: protowire.Fixed64Type,
+ protoreflect.Fixed64Kind: protowire.Fixed64Type,
+ protoreflect.DoubleKind: protowire.Fixed64Type,
+ protoreflect.StringKind: protowire.BytesType,
+ protoreflect.BytesKind: protowire.BytesType,
+ protoreflect.MessageKind: protowire.BytesType,
+ protoreflect.GroupKind: protowire.StartGroupType,
+}
+
+func (o MarshalOptions) marshalSingular(b []byte, fd protoreflect.FieldDescriptor, v protoreflect.Value) ([]byte, error) {
+ switch fd.Kind() {
+ case protoreflect.BoolKind:
+ b = protowire.AppendVarint(b, protowire.EncodeBool(v.Bool()))
+ case protoreflect.EnumKind:
+ b = protowire.AppendVarint(b, uint64(v.Enum()))
+ case protoreflect.Int32Kind:
+ b = protowire.AppendVarint(b, uint64(int32(v.Int())))
+ case protoreflect.Sint32Kind:
+ b = protowire.AppendVarint(b, protowire.EncodeZigZag(int64(int32(v.Int()))))
+ case protoreflect.Uint32Kind:
+ b = protowire.AppendVarint(b, uint64(uint32(v.Uint())))
+ case protoreflect.Int64Kind:
+ b = protowire.AppendVarint(b, uint64(v.Int()))
+ case protoreflect.Sint64Kind:
+ b = protowire.AppendVarint(b, protowire.EncodeZigZag(v.Int()))
+ case protoreflect.Uint64Kind:
+ b = protowire.AppendVarint(b, v.Uint())
+ case protoreflect.Sfixed32Kind:
+ b = protowire.AppendFixed32(b, uint32(v.Int()))
+ case protoreflect.Fixed32Kind:
+ b = protowire.AppendFixed32(b, uint32(v.Uint()))
+ case protoreflect.FloatKind:
+ b = protowire.AppendFixed32(b, math.Float32bits(float32(v.Float())))
+ case protoreflect.Sfixed64Kind:
+ b = protowire.AppendFixed64(b, uint64(v.Int()))
+ case protoreflect.Fixed64Kind:
+ b = protowire.AppendFixed64(b, v.Uint())
+ case protoreflect.DoubleKind:
+ b = protowire.AppendFixed64(b, math.Float64bits(v.Float()))
+ case protoreflect.StringKind:
+ if strs.EnforceUTF8(fd) && !utf8.ValidString(v.String()) {
+ return b, errors.InvalidUTF8(string(fd.FullName()))
+ }
+ b = protowire.AppendString(b, v.String())
+ case protoreflect.BytesKind:
+ b = protowire.AppendBytes(b, v.Bytes())
+ case protoreflect.MessageKind:
+ var pos int
+ var err error
+ b, pos = appendSpeculativeLength(b)
+ b, err = o.marshalMessage(b, v.Message())
+ if err != nil {
+ return b, err
+ }
+ b = finishSpeculativeLength(b, pos)
+ case protoreflect.GroupKind:
+ var err error
+ b, err = o.marshalMessage(b, v.Message())
+ if err != nil {
+ return b, err
+ }
+ b = protowire.AppendVarint(b, protowire.EncodeTag(fd.Number(), protowire.EndGroupType))
+ default:
+ return b, errors.New("invalid kind %v", fd.Kind())
+ }
+ return b, nil
+}
diff --git a/vendor/google.golang.org/protobuf/proto/equal.go b/vendor/google.golang.org/protobuf/proto/equal.go
new file mode 100644
index 000000000..10902bd85
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/equal.go
@@ -0,0 +1,154 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+import (
+ "bytes"
+ "math"
+ "reflect"
+
+ "google.golang.org/protobuf/encoding/protowire"
+ pref "google.golang.org/protobuf/reflect/protoreflect"
+)
+
+// Equal reports whether two messages are equal.
+// If two messages marshal to the same bytes under deterministic serialization,
+// then Equal is guaranteed to report true.
+//
+// Two messages are equal if they belong to the same message descriptor,
+// have the same set of populated known and extension field values,
+// and the same set of unknown fields values. If either of the top-level
+// messages are invalid, then Equal reports true only if both are invalid.
+//
+// Scalar values are compared with the equivalent of the == operator in Go,
+// except bytes values which are compared using bytes.Equal and
+// floating point values which specially treat NaNs as equal.
+// Message values are compared by recursively calling Equal.
+// Lists are equal if each element value is also equal.
+// Maps are equal if they have the same set of keys, where the pair of values
+// for each key is also equal.
+func Equal(x, y Message) bool {
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ mx := x.ProtoReflect()
+ my := y.ProtoReflect()
+ if mx.IsValid() != my.IsValid() {
+ return false
+ }
+ return equalMessage(mx, my)
+}
+
+// equalMessage compares two messages.
+func equalMessage(mx, my pref.Message) bool {
+ if mx.Descriptor() != my.Descriptor() {
+ return false
+ }
+
+ nx := 0
+ equal := true
+ mx.Range(func(fd pref.FieldDescriptor, vx pref.Value) bool {
+ nx++
+ vy := my.Get(fd)
+ equal = my.Has(fd) && equalField(fd, vx, vy)
+ return equal
+ })
+ if !equal {
+ return false
+ }
+ ny := 0
+ my.Range(func(fd pref.FieldDescriptor, vx pref.Value) bool {
+ ny++
+ return true
+ })
+ if nx != ny {
+ return false
+ }
+
+ return equalUnknown(mx.GetUnknown(), my.GetUnknown())
+}
+
+// equalField compares two fields.
+func equalField(fd pref.FieldDescriptor, x, y pref.Value) bool {
+ switch {
+ case fd.IsList():
+ return equalList(fd, x.List(), y.List())
+ case fd.IsMap():
+ return equalMap(fd, x.Map(), y.Map())
+ default:
+ return equalValue(fd, x, y)
+ }
+}
+
+// equalMap compares two maps.
+func equalMap(fd pref.FieldDescriptor, x, y pref.Map) bool {
+ if x.Len() != y.Len() {
+ return false
+ }
+ equal := true
+ x.Range(func(k pref.MapKey, vx pref.Value) bool {
+ vy := y.Get(k)
+ equal = y.Has(k) && equalValue(fd.MapValue(), vx, vy)
+ return equal
+ })
+ return equal
+}
+
+// equalList compares two lists.
+func equalList(fd pref.FieldDescriptor, x, y pref.List) bool {
+ if x.Len() != y.Len() {
+ return false
+ }
+ for i := x.Len() - 1; i >= 0; i-- {
+ if !equalValue(fd, x.Get(i), y.Get(i)) {
+ return false
+ }
+ }
+ return true
+}
+
+// equalValue compares two singular values.
+func equalValue(fd pref.FieldDescriptor, x, y pref.Value) bool {
+ switch {
+ case fd.Message() != nil:
+ return equalMessage(x.Message(), y.Message())
+ case fd.Kind() == pref.BytesKind:
+ return bytes.Equal(x.Bytes(), y.Bytes())
+ case fd.Kind() == pref.FloatKind, fd.Kind() == pref.DoubleKind:
+ fx := x.Float()
+ fy := y.Float()
+ if math.IsNaN(fx) || math.IsNaN(fy) {
+ return math.IsNaN(fx) && math.IsNaN(fy)
+ }
+ return fx == fy
+ default:
+ return x.Interface() == y.Interface()
+ }
+}
+
+// equalUnknown compares unknown fields by direct comparison on the raw bytes
+// of each individual field number.
+func equalUnknown(x, y pref.RawFields) bool {
+ if len(x) != len(y) {
+ return false
+ }
+ if bytes.Equal([]byte(x), []byte(y)) {
+ return true
+ }
+
+ mx := make(map[pref.FieldNumber]pref.RawFields)
+ my := make(map[pref.FieldNumber]pref.RawFields)
+ for len(x) > 0 {
+ fnum, _, n := protowire.ConsumeField(x)
+ mx[fnum] = append(mx[fnum], x[:n]...)
+ x = x[n:]
+ }
+ for len(y) > 0 {
+ fnum, _, n := protowire.ConsumeField(y)
+ my[fnum] = append(my[fnum], y[:n]...)
+ y = y[n:]
+ }
+ return reflect.DeepEqual(mx, my)
+}
diff --git a/vendor/google.golang.org/protobuf/proto/extension.go b/vendor/google.golang.org/protobuf/proto/extension.go
new file mode 100644
index 000000000..5f293cda8
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/extension.go
@@ -0,0 +1,92 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+import (
+ "google.golang.org/protobuf/reflect/protoreflect"
+)
+
+// HasExtension reports whether an extension field is populated.
+// It returns false if m is invalid or if xt does not extend m.
+func HasExtension(m Message, xt protoreflect.ExtensionType) bool {
+ // Treat nil message interface as an empty message; no populated fields.
+ if m == nil {
+ return false
+ }
+
+ // As a special-case, we reports invalid or mismatching descriptors
+ // as always not being populated (since they aren't).
+ if xt == nil || m.ProtoReflect().Descriptor() != xt.TypeDescriptor().ContainingMessage() {
+ return false
+ }
+
+ return m.ProtoReflect().Has(xt.TypeDescriptor())
+}
+
+// ClearExtension clears an extension field such that subsequent
+// HasExtension calls return false.
+// It panics if m is invalid or if xt does not extend m.
+func ClearExtension(m Message, xt protoreflect.ExtensionType) {
+ m.ProtoReflect().Clear(xt.TypeDescriptor())
+}
+
+// GetExtension retrieves the value for an extension field.
+// If the field is unpopulated, it returns the default value for
+// scalars and an immutable, empty value for lists or messages.
+// It panics if xt does not extend m.
+func GetExtension(m Message, xt protoreflect.ExtensionType) interface{} {
+ // Treat nil message interface as an empty message; return the default.
+ if m == nil {
+ return xt.InterfaceOf(xt.Zero())
+ }
+
+ return xt.InterfaceOf(m.ProtoReflect().Get(xt.TypeDescriptor()))
+}
+
+// SetExtension stores the value of an extension field.
+// It panics if m is invalid, xt does not extend m, or if type of v
+// is invalid for the specified extension field.
+func SetExtension(m Message, xt protoreflect.ExtensionType, v interface{}) {
+ xd := xt.TypeDescriptor()
+ pv := xt.ValueOf(v)
+
+ // Specially treat an invalid list, map, or message as clear.
+ isValid := true
+ switch {
+ case xd.IsList():
+ isValid = pv.List().IsValid()
+ case xd.IsMap():
+ isValid = pv.Map().IsValid()
+ case xd.Message() != nil:
+ isValid = pv.Message().IsValid()
+ }
+ if !isValid {
+ m.ProtoReflect().Clear(xd)
+ return
+ }
+
+ m.ProtoReflect().Set(xd, pv)
+}
+
+// RangeExtensions iterates over every populated extension field in m in an
+// undefined order, calling f for each extension type and value encountered.
+// It returns immediately if f returns false.
+// While iterating, mutating operations may only be performed
+// on the current extension field.
+func RangeExtensions(m Message, f func(protoreflect.ExtensionType, interface{}) bool) {
+ // Treat nil message interface as an empty message; nothing to range over.
+ if m == nil {
+ return
+ }
+
+ m.ProtoReflect().Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
+ if fd.IsExtension() {
+ xt := fd.(protoreflect.ExtensionTypeDescriptor).Type()
+ vi := xt.InterfaceOf(v)
+ return f(xt, vi)
+ }
+ return true
+ })
+}
diff --git a/vendor/google.golang.org/protobuf/proto/merge.go b/vendor/google.golang.org/protobuf/proto/merge.go
new file mode 100644
index 000000000..d761ab331
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/merge.go
@@ -0,0 +1,139 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+import (
+ "fmt"
+
+ "google.golang.org/protobuf/reflect/protoreflect"
+ "google.golang.org/protobuf/runtime/protoiface"
+)
+
+// Merge merges src into dst, which must be a message with the same descriptor.
+//
+// Populated scalar fields in src are copied to dst, while populated
+// singular messages in src are merged into dst by recursively calling Merge.
+// The elements of every list field in src is appended to the corresponded
+// list fields in dst. The entries of every map field in src is copied into
+// the corresponding map field in dst, possibly replacing existing entries.
+// The unknown fields of src are appended to the unknown fields of dst.
+//
+// It is semantically equivalent to unmarshaling the encoded form of src
+// into dst with the UnmarshalOptions.Merge option specified.
+func Merge(dst, src Message) {
+ // TODO: Should nil src be treated as semantically equivalent to a
+ // untyped, read-only, empty message? What about a nil dst?
+
+ dstMsg, srcMsg := dst.ProtoReflect(), src.ProtoReflect()
+ if dstMsg.Descriptor() != srcMsg.Descriptor() {
+ if got, want := dstMsg.Descriptor().FullName(), srcMsg.Descriptor().FullName(); got != want {
+ panic(fmt.Sprintf("descriptor mismatch: %v != %v", got, want))
+ }
+ panic("descriptor mismatch")
+ }
+ mergeOptions{}.mergeMessage(dstMsg, srcMsg)
+}
+
+// Clone returns a deep copy of m.
+// If the top-level message is invalid, it returns an invalid message as well.
+func Clone(m Message) Message {
+ // NOTE: Most usages of Clone assume the following properties:
+ // t := reflect.TypeOf(m)
+ // t == reflect.TypeOf(m.ProtoReflect().New().Interface())
+ // t == reflect.TypeOf(m.ProtoReflect().Type().Zero().Interface())
+ //
+ // Embedding protobuf messages breaks this since the parent type will have
+ // a forwarded ProtoReflect method, but the Interface method will return
+ // the underlying embedded message type.
+ if m == nil {
+ return nil
+ }
+ src := m.ProtoReflect()
+ if !src.IsValid() {
+ return src.Type().Zero().Interface()
+ }
+ dst := src.New()
+ mergeOptions{}.mergeMessage(dst, src)
+ return dst.Interface()
+}
+
+// mergeOptions provides a namespace for merge functions, and can be
+// exported in the future if we add user-visible merge options.
+type mergeOptions struct{}
+
+func (o mergeOptions) mergeMessage(dst, src protoreflect.Message) {
+ methods := protoMethods(dst)
+ if methods != nil && methods.Merge != nil {
+ in := protoiface.MergeInput{
+ Destination: dst,
+ Source: src,
+ }
+ out := methods.Merge(in)
+ if out.Flags&protoiface.MergeComplete != 0 {
+ return
+ }
+ }
+
+ if !dst.IsValid() {
+ panic(fmt.Sprintf("cannot merge into invalid %v message", dst.Descriptor().FullName()))
+ }
+
+ src.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
+ switch {
+ case fd.IsList():
+ o.mergeList(dst.Mutable(fd).List(), v.List(), fd)
+ case fd.IsMap():
+ o.mergeMap(dst.Mutable(fd).Map(), v.Map(), fd.MapValue())
+ case fd.Message() != nil:
+ o.mergeMessage(dst.Mutable(fd).Message(), v.Message())
+ case fd.Kind() == protoreflect.BytesKind:
+ dst.Set(fd, o.cloneBytes(v))
+ default:
+ dst.Set(fd, v)
+ }
+ return true
+ })
+
+ if len(src.GetUnknown()) > 0 {
+ dst.SetUnknown(append(dst.GetUnknown(), src.GetUnknown()...))
+ }
+}
+
+func (o mergeOptions) mergeList(dst, src protoreflect.List, fd protoreflect.FieldDescriptor) {
+ // Merge semantics appends to the end of the existing list.
+ for i, n := 0, src.Len(); i < n; i++ {
+ switch v := src.Get(i); {
+ case fd.Message() != nil:
+ dstv := dst.NewElement()
+ o.mergeMessage(dstv.Message(), v.Message())
+ dst.Append(dstv)
+ case fd.Kind() == protoreflect.BytesKind:
+ dst.Append(o.cloneBytes(v))
+ default:
+ dst.Append(v)
+ }
+ }
+}
+
+func (o mergeOptions) mergeMap(dst, src protoreflect.Map, fd protoreflect.FieldDescriptor) {
+ // Merge semantics replaces, rather than merges into existing entries.
+ src.Range(func(k protoreflect.MapKey, v protoreflect.Value) bool {
+ switch {
+ case fd.Message() != nil:
+ dstv := dst.NewValue()
+ o.mergeMessage(dstv.Message(), v.Message())
+ dst.Set(k, dstv)
+ case fd.Kind() == protoreflect.BytesKind:
+ dst.Set(k, o.cloneBytes(v))
+ default:
+ dst.Set(k, v)
+ }
+ return true
+ })
+}
+
+func (o mergeOptions) cloneBytes(v protoreflect.Value) protoreflect.Value {
+ return protoreflect.ValueOfBytes(append([]byte{}, v.Bytes()...))
+}
diff --git a/vendor/google.golang.org/protobuf/proto/messageset.go b/vendor/google.golang.org/protobuf/proto/messageset.go
new file mode 100644
index 000000000..b6b3de591
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/messageset.go
@@ -0,0 +1,88 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+import (
+ "google.golang.org/protobuf/encoding/protowire"
+ "google.golang.org/protobuf/internal/encoding/messageset"
+ "google.golang.org/protobuf/internal/errors"
+ "google.golang.org/protobuf/internal/flags"
+ "google.golang.org/protobuf/reflect/protoreflect"
+ "google.golang.org/protobuf/reflect/protoregistry"
+)
+
+func sizeMessageSet(m protoreflect.Message) (size int) {
+ m.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
+ size += messageset.SizeField(fd.Number())
+ size += protowire.SizeTag(messageset.FieldMessage)
+ size += protowire.SizeBytes(sizeMessage(v.Message()))
+ return true
+ })
+ size += messageset.SizeUnknown(m.GetUnknown())
+ return size
+}
+
+func marshalMessageSet(b []byte, m protoreflect.Message, o MarshalOptions) ([]byte, error) {
+ if !flags.ProtoLegacy {
+ return b, errors.New("no support for message_set_wire_format")
+ }
+ var err error
+ o.rangeFields(m, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
+ b, err = marshalMessageSetField(b, fd, v, o)
+ return err == nil
+ })
+ if err != nil {
+ return b, err
+ }
+ return messageset.AppendUnknown(b, m.GetUnknown())
+}
+
+func marshalMessageSetField(b []byte, fd protoreflect.FieldDescriptor, value protoreflect.Value, o MarshalOptions) ([]byte, error) {
+ b = messageset.AppendFieldStart(b, fd.Number())
+ b = protowire.AppendTag(b, messageset.FieldMessage, protowire.BytesType)
+ b = protowire.AppendVarint(b, uint64(o.Size(value.Message().Interface())))
+ b, err := o.marshalMessage(b, value.Message())
+ if err != nil {
+ return b, err
+ }
+ b = messageset.AppendFieldEnd(b)
+ return b, nil
+}
+
+func unmarshalMessageSet(b []byte, m protoreflect.Message, o UnmarshalOptions) error {
+ if !flags.ProtoLegacy {
+ return errors.New("no support for message_set_wire_format")
+ }
+ return messageset.Unmarshal(b, false, func(num protowire.Number, v []byte) error {
+ err := unmarshalMessageSetField(m, num, v, o)
+ if err == errUnknown {
+ unknown := m.GetUnknown()
+ unknown = protowire.AppendTag(unknown, num, protowire.BytesType)
+ unknown = protowire.AppendBytes(unknown, v)
+ m.SetUnknown(unknown)
+ return nil
+ }
+ return err
+ })
+}
+
+func unmarshalMessageSetField(m protoreflect.Message, num protowire.Number, v []byte, o UnmarshalOptions) error {
+ md := m.Descriptor()
+ if !md.ExtensionRanges().Has(num) {
+ return errUnknown
+ }
+ xt, err := o.Resolver.FindExtensionByNumber(md.FullName(), num)
+ if err == protoregistry.NotFound {
+ return errUnknown
+ }
+ if err != nil {
+ return errors.New("%v: unable to resolve extension %v: %v", md.FullName(), num, err)
+ }
+ xd := xt.TypeDescriptor()
+ if err := o.unmarshalMessage(v, m.Mutable(xd).Message()); err != nil {
+ return err
+ }
+ return nil
+}
diff --git a/vendor/google.golang.org/protobuf/proto/proto.go b/vendor/google.golang.org/protobuf/proto/proto.go
new file mode 100644
index 000000000..ca14b09c3
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/proto.go
@@ -0,0 +1,34 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+import (
+ "google.golang.org/protobuf/internal/errors"
+ "google.golang.org/protobuf/reflect/protoreflect"
+)
+
+// Message is the top-level interface that all messages must implement.
+// It provides access to a reflective view of a message.
+// Any implementation of this interface may be used with all functions in the
+// protobuf module that accept a Message, except where otherwise specified.
+//
+// This is the v2 interface definition for protobuf messages.
+// The v1 interface definition is "github.com/golang/protobuf/proto".Message.
+//
+// To convert a v1 message to a v2 message,
+// use "github.com/golang/protobuf/proto".MessageV2.
+// To convert a v2 message to a v1 message,
+// use "github.com/golang/protobuf/proto".MessageV1.
+type Message = protoreflect.ProtoMessage
+
+// Error matches all errors produced by packages in the protobuf module.
+//
+// That is, errors.Is(err, Error) reports whether an error is produced
+// by this module.
+var Error error
+
+func init() {
+ Error = errors.Error
+}
diff --git a/vendor/google.golang.org/protobuf/proto/proto_methods.go b/vendor/google.golang.org/protobuf/proto/proto_methods.go
new file mode 100644
index 000000000..d8dd604f6
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/proto_methods.go
@@ -0,0 +1,19 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// The protoreflect build tag disables use of fast-path methods.
+// +build !protoreflect
+
+package proto
+
+import (
+ "google.golang.org/protobuf/reflect/protoreflect"
+ "google.golang.org/protobuf/runtime/protoiface"
+)
+
+const hasProtoMethods = true
+
+func protoMethods(m protoreflect.Message) *protoiface.Methods {
+ return m.ProtoMethods()
+}
diff --git a/vendor/google.golang.org/protobuf/proto/proto_reflect.go b/vendor/google.golang.org/protobuf/proto/proto_reflect.go
new file mode 100644
index 000000000..b103d4320
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/proto_reflect.go
@@ -0,0 +1,19 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// The protoreflect build tag disables use of fast-path methods.
+// +build protoreflect
+
+package proto
+
+import (
+ "google.golang.org/protobuf/reflect/protoreflect"
+ "google.golang.org/protobuf/runtime/protoiface"
+)
+
+const hasProtoMethods = false
+
+func protoMethods(m protoreflect.Message) *protoiface.Methods {
+ return nil
+}
diff --git a/vendor/google.golang.org/protobuf/proto/reset.go b/vendor/google.golang.org/protobuf/proto/reset.go
new file mode 100644
index 000000000..3d7f89436
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/reset.go
@@ -0,0 +1,43 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+import (
+ "fmt"
+
+ "google.golang.org/protobuf/reflect/protoreflect"
+)
+
+// Reset clears every field in the message.
+// The resulting message shares no observable memory with its previous state
+// other than the memory for the message itself.
+func Reset(m Message) {
+ if mr, ok := m.(interface{ Reset() }); ok && hasProtoMethods {
+ mr.Reset()
+ return
+ }
+ resetMessage(m.ProtoReflect())
+}
+
+func resetMessage(m protoreflect.Message) {
+ if !m.IsValid() {
+ panic(fmt.Sprintf("cannot reset invalid %v message", m.Descriptor().FullName()))
+ }
+
+ // Clear all known fields.
+ fds := m.Descriptor().Fields()
+ for i := 0; i < fds.Len(); i++ {
+ m.Clear(fds.Get(i))
+ }
+
+ // Clear extension fields.
+ m.Range(func(fd protoreflect.FieldDescriptor, _ protoreflect.Value) bool {
+ m.Clear(fd)
+ return true
+ })
+
+ // Clear unknown fields.
+ m.SetUnknown(nil)
+}
diff --git a/vendor/google.golang.org/protobuf/proto/size.go b/vendor/google.golang.org/protobuf/proto/size.go
new file mode 100644
index 000000000..11ba84146
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/size.go
@@ -0,0 +1,94 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+import (
+ "google.golang.org/protobuf/encoding/protowire"
+ "google.golang.org/protobuf/internal/encoding/messageset"
+ "google.golang.org/protobuf/reflect/protoreflect"
+ "google.golang.org/protobuf/runtime/protoiface"
+)
+
+// Size returns the size in bytes of the wire-format encoding of m.
+func Size(m Message) int {
+ return MarshalOptions{}.Size(m)
+}
+
+// Size returns the size in bytes of the wire-format encoding of m.
+func (o MarshalOptions) Size(m Message) int {
+ // Treat a nil message interface as an empty message; nothing to output.
+ if m == nil {
+ return 0
+ }
+
+ return sizeMessage(m.ProtoReflect())
+}
+
+func sizeMessage(m protoreflect.Message) (size int) {
+ methods := protoMethods(m)
+ if methods != nil && methods.Size != nil {
+ out := methods.Size(protoiface.SizeInput{
+ Message: m,
+ })
+ return out.Size
+ }
+ if methods != nil && methods.Marshal != nil {
+ // This is not efficient, but we don't have any choice.
+ // This case is mainly used for legacy types with a Marshal method.
+ out, _ := methods.Marshal(protoiface.MarshalInput{
+ Message: m,
+ })
+ return len(out.Buf)
+ }
+ return sizeMessageSlow(m)
+}
+
+func sizeMessageSlow(m protoreflect.Message) (size int) {
+ if messageset.IsMessageSet(m.Descriptor()) {
+ return sizeMessageSet(m)
+ }
+ m.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
+ size += sizeField(fd, v)
+ return true
+ })
+ size += len(m.GetUnknown())
+ return size
+}
+
+func sizeField(fd protoreflect.FieldDescriptor, value protoreflect.Value) (size int) {
+ num := fd.Number()
+ switch {
+ case fd.IsList():
+ return sizeList(num, fd, value.List())
+ case fd.IsMap():
+ return sizeMap(num, fd, value.Map())
+ default:
+ return protowire.SizeTag(num) + sizeSingular(num, fd.Kind(), value)
+ }
+}
+
+func sizeList(num protowire.Number, fd protoreflect.FieldDescriptor, list protoreflect.List) (size int) {
+ if fd.IsPacked() && list.Len() > 0 {
+ content := 0
+ for i, llen := 0, list.Len(); i < llen; i++ {
+ content += sizeSingular(num, fd.Kind(), list.Get(i))
+ }
+ return protowire.SizeTag(num) + protowire.SizeBytes(content)
+ }
+
+ for i, llen := 0, list.Len(); i < llen; i++ {
+ size += protowire.SizeTag(num) + sizeSingular(num, fd.Kind(), list.Get(i))
+ }
+ return size
+}
+
+func sizeMap(num protowire.Number, fd protoreflect.FieldDescriptor, mapv protoreflect.Map) (size int) {
+ mapv.Range(func(key protoreflect.MapKey, value protoreflect.Value) bool {
+ size += protowire.SizeTag(num)
+ size += protowire.SizeBytes(sizeField(fd.MapKey(), key.Value()) + sizeField(fd.MapValue(), value))
+ return true
+ })
+ return size
+}
diff --git a/vendor/google.golang.org/protobuf/proto/size_gen.go b/vendor/google.golang.org/protobuf/proto/size_gen.go
new file mode 100644
index 000000000..1118460f6
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/size_gen.go
@@ -0,0 +1,55 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Code generated by generate-types. DO NOT EDIT.
+
+package proto
+
+import (
+ "google.golang.org/protobuf/encoding/protowire"
+ "google.golang.org/protobuf/reflect/protoreflect"
+)
+
+func sizeSingular(num protowire.Number, kind protoreflect.Kind, v protoreflect.Value) int {
+ switch kind {
+ case protoreflect.BoolKind:
+ return protowire.SizeVarint(protowire.EncodeBool(v.Bool()))
+ case protoreflect.EnumKind:
+ return protowire.SizeVarint(uint64(v.Enum()))
+ case protoreflect.Int32Kind:
+ return protowire.SizeVarint(uint64(int32(v.Int())))
+ case protoreflect.Sint32Kind:
+ return protowire.SizeVarint(protowire.EncodeZigZag(int64(int32(v.Int()))))
+ case protoreflect.Uint32Kind:
+ return protowire.SizeVarint(uint64(uint32(v.Uint())))
+ case protoreflect.Int64Kind:
+ return protowire.SizeVarint(uint64(v.Int()))
+ case protoreflect.Sint64Kind:
+ return protowire.SizeVarint(protowire.EncodeZigZag(v.Int()))
+ case protoreflect.Uint64Kind:
+ return protowire.SizeVarint(v.Uint())
+ case protoreflect.Sfixed32Kind:
+ return protowire.SizeFixed32()
+ case protoreflect.Fixed32Kind:
+ return protowire.SizeFixed32()
+ case protoreflect.FloatKind:
+ return protowire.SizeFixed32()
+ case protoreflect.Sfixed64Kind:
+ return protowire.SizeFixed64()
+ case protoreflect.Fixed64Kind:
+ return protowire.SizeFixed64()
+ case protoreflect.DoubleKind:
+ return protowire.SizeFixed64()
+ case protoreflect.StringKind:
+ return protowire.SizeBytes(len(v.String()))
+ case protoreflect.BytesKind:
+ return protowire.SizeBytes(len(v.Bytes()))
+ case protoreflect.MessageKind:
+ return protowire.SizeBytes(sizeMessage(v.Message()))
+ case protoreflect.GroupKind:
+ return protowire.SizeGroup(num, sizeMessage(v.Message()))
+ default:
+ return 0
+ }
+}
diff --git a/vendor/google.golang.org/protobuf/proto/wrappers.go b/vendor/google.golang.org/protobuf/proto/wrappers.go
new file mode 100644
index 000000000..653b12c3a
--- /dev/null
+++ b/vendor/google.golang.org/protobuf/proto/wrappers.go
@@ -0,0 +1,29 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+// Bool stores v in a new bool value and returns a pointer to it.
+func Bool(v bool) *bool { return &v }
+
+// Int32 stores v in a new int32 value and returns a pointer to it.
+func Int32(v int32) *int32 { return &v }
+
+// Int64 stores v in a new int64 value and returns a pointer to it.
+func Int64(v int64) *int64 { return &v }
+
+// Float32 stores v in a new float32 value and returns a pointer to it.
+func Float32(v float32) *float32 { return &v }
+
+// Float64 stores v in a new float64 value and returns a pointer to it.
+func Float64(v float64) *float64 { return &v }
+
+// Uint32 stores v in a new uint32 value and returns a pointer to it.
+func Uint32(v uint32) *uint32 { return &v }
+
+// Uint64 stores v in a new uint64 value and returns a pointer to it.
+func Uint64(v uint64) *uint64 { return &v }
+
+// String stores v in a new string value and returns a pointer to it.
+func String(v string) *string { return &v }