mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-21 00:06:37 +00:00
Security fix - containerd to 1.7.27
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
6
vendor/google.golang.org/protobuf/internal/impl/api_export.go
generated
vendored
6
vendor/google.golang.org/protobuf/internal/impl/api_export.go
generated
vendored
@ -22,13 +22,13 @@ type Export struct{}
|
||||
|
||||
// NewError formats a string according to the format specifier and arguments and
|
||||
// returns an error that has a "proto" prefix.
|
||||
func (Export) NewError(f string, x ...interface{}) error {
|
||||
func (Export) NewError(f string, x ...any) error {
|
||||
return errors.New(f, x...)
|
||||
}
|
||||
|
||||
// enum is any enum type generated by protoc-gen-go
|
||||
// and must be a named int32 type.
|
||||
type enum = interface{}
|
||||
type enum = any
|
||||
|
||||
// EnumOf returns the protoreflect.Enum interface over e.
|
||||
// It returns nil if e is nil.
|
||||
@ -81,7 +81,7 @@ func (Export) EnumStringOf(ed protoreflect.EnumDescriptor, n protoreflect.EnumNu
|
||||
|
||||
// message is any message type generated by protoc-gen-go
|
||||
// and must be a pointer to a named struct type.
|
||||
type message = interface{}
|
||||
type message = any
|
||||
|
||||
// legacyMessageWrapper wraps a v2 message as a v1 message.
|
||||
type legacyMessageWrapper struct{ m protoreflect.ProtoMessage }
|
||||
|
2
vendor/google.golang.org/protobuf/internal/impl/checkinit.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/impl/checkinit.go
generated
vendored
@ -68,7 +68,7 @@ func (mi *MessageInfo) isInitExtensions(ext *map[int32]ExtensionField) error {
|
||||
}
|
||||
for _, x := range *ext {
|
||||
ei := getExtensionFieldInfo(x.Type())
|
||||
if ei.funcs.isInit == nil {
|
||||
if ei.funcs.isInit == nil || x.isUnexpandedLazy() {
|
||||
continue
|
||||
}
|
||||
v := x.Value()
|
||||
|
33
vendor/google.golang.org/protobuf/internal/impl/codec_extension.go
generated
vendored
33
vendor/google.golang.org/protobuf/internal/impl/codec_extension.go
generated
vendored
@ -67,7 +67,6 @@ type lazyExtensionValue struct {
|
||||
xi *extensionFieldInfo
|
||||
value protoreflect.Value
|
||||
b []byte
|
||||
fn func() protoreflect.Value
|
||||
}
|
||||
|
||||
type ExtensionField struct {
|
||||
@ -99,6 +98,28 @@ func (f *ExtensionField) canLazy(xt protoreflect.ExtensionType) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// isUnexpandedLazy returns true if the ExensionField is lazy and not
|
||||
// yet expanded, which means it's present and already checked for
|
||||
// initialized required fields.
|
||||
func (f *ExtensionField) isUnexpandedLazy() bool {
|
||||
return f.lazy != nil && atomic.LoadUint32(&f.lazy.atomicOnce) == 0
|
||||
}
|
||||
|
||||
// lazyBuffer retrieves the buffer for a lazy extension if it's not yet expanded.
|
||||
//
|
||||
// The returned buffer has to be kept over whatever operation we're planning,
|
||||
// as re-retrieving it will fail after the message is lazily decoded.
|
||||
func (f *ExtensionField) lazyBuffer() []byte {
|
||||
// This function might be in the critical path, so check the atomic without
|
||||
// taking a look first, then only take the lock if needed.
|
||||
if !f.isUnexpandedLazy() {
|
||||
return nil
|
||||
}
|
||||
f.lazy.mu.Lock()
|
||||
defer f.lazy.mu.Unlock()
|
||||
return f.lazy.b
|
||||
}
|
||||
|
||||
func (f *ExtensionField) lazyInit() {
|
||||
f.lazy.mu.Lock()
|
||||
defer f.lazy.mu.Unlock()
|
||||
@ -136,10 +157,9 @@ func (f *ExtensionField) lazyInit() {
|
||||
}
|
||||
f.lazy.value = val
|
||||
} else {
|
||||
f.lazy.value = f.lazy.fn()
|
||||
panic("No support for lazy fns for ExtensionField")
|
||||
}
|
||||
f.lazy.xi = nil
|
||||
f.lazy.fn = nil
|
||||
f.lazy.b = nil
|
||||
atomic.StoreUint32(&f.lazy.atomicOnce, 1)
|
||||
}
|
||||
@ -152,13 +172,6 @@ func (f *ExtensionField) Set(t protoreflect.ExtensionType, v protoreflect.Value)
|
||||
f.lazy = nil
|
||||
}
|
||||
|
||||
// SetLazy sets the type and a value that is to be lazily evaluated upon first use.
|
||||
// This must not be called concurrently.
|
||||
func (f *ExtensionField) SetLazy(t protoreflect.ExtensionType, fn func() protoreflect.Value) {
|
||||
f.typ = t
|
||||
f.lazy = &lazyExtensionValue{fn: fn}
|
||||
}
|
||||
|
||||
// Value returns the value of the extension field.
|
||||
// This may be called concurrently.
|
||||
func (f *ExtensionField) Value() protoreflect.Value {
|
||||
|
67
vendor/google.golang.org/protobuf/internal/impl/codec_field.go
generated
vendored
67
vendor/google.golang.org/protobuf/internal/impl/codec_field.go
generated
vendored
@ -65,6 +65,9 @@ func (mi *MessageInfo) initOneofFieldCoders(od protoreflect.OneofDescriptor, si
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
if cf.funcs.isInit == nil {
|
||||
out.initialized = true
|
||||
}
|
||||
vi.Set(vw)
|
||||
return out, nil
|
||||
}
|
||||
@ -233,9 +236,15 @@ func sizeMessageInfo(p pointer, f *coderFieldInfo, opts marshalOptions) int {
|
||||
}
|
||||
|
||||
func appendMessageInfo(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
|
||||
calculatedSize := f.mi.sizePointer(p.Elem(), opts)
|
||||
b = protowire.AppendVarint(b, f.wiretag)
|
||||
b = protowire.AppendVarint(b, uint64(f.mi.sizePointer(p.Elem(), opts)))
|
||||
return f.mi.marshalAppendPointer(b, p.Elem(), opts)
|
||||
b = protowire.AppendVarint(b, uint64(calculatedSize))
|
||||
before := len(b)
|
||||
b, err := f.mi.marshalAppendPointer(b, p.Elem(), opts)
|
||||
if measuredSize := len(b) - before; calculatedSize != measuredSize && err == nil {
|
||||
return nil, errors.MismatchedSizeCalculation(calculatedSize, measuredSize)
|
||||
}
|
||||
return b, err
|
||||
}
|
||||
|
||||
func consumeMessageInfo(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
@ -262,14 +271,21 @@ func isInitMessageInfo(p pointer, f *coderFieldInfo) error {
|
||||
return f.mi.checkInitializedPointer(p.Elem())
|
||||
}
|
||||
|
||||
func sizeMessage(m proto.Message, tagsize int, _ marshalOptions) int {
|
||||
return protowire.SizeBytes(proto.Size(m)) + tagsize
|
||||
func sizeMessage(m proto.Message, tagsize int, opts marshalOptions) int {
|
||||
return protowire.SizeBytes(opts.Options().Size(m)) + tagsize
|
||||
}
|
||||
|
||||
func appendMessage(b []byte, m proto.Message, wiretag uint64, opts marshalOptions) ([]byte, error) {
|
||||
mopts := opts.Options()
|
||||
calculatedSize := mopts.Size(m)
|
||||
b = protowire.AppendVarint(b, wiretag)
|
||||
b = protowire.AppendVarint(b, uint64(proto.Size(m)))
|
||||
return opts.Options().MarshalAppend(b, m)
|
||||
b = protowire.AppendVarint(b, uint64(calculatedSize))
|
||||
before := len(b)
|
||||
b, err := mopts.MarshalAppend(b, m)
|
||||
if measuredSize := len(b) - before; calculatedSize != measuredSize && err == nil {
|
||||
return nil, errors.MismatchedSizeCalculation(calculatedSize, measuredSize)
|
||||
}
|
||||
return b, err
|
||||
}
|
||||
|
||||
func consumeMessage(b []byte, m proto.Message, wtyp protowire.Type, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
@ -405,8 +421,8 @@ func consumeGroupType(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInf
|
||||
return f.mi.unmarshalPointer(b, p.Elem(), f.num, opts)
|
||||
}
|
||||
|
||||
func sizeGroup(m proto.Message, tagsize int, _ marshalOptions) int {
|
||||
return 2*tagsize + proto.Size(m)
|
||||
func sizeGroup(m proto.Message, tagsize int, opts marshalOptions) int {
|
||||
return 2*tagsize + opts.Options().Size(m)
|
||||
}
|
||||
|
||||
func appendGroup(b []byte, m proto.Message, wiretag uint64, opts marshalOptions) ([]byte, error) {
|
||||
@ -482,10 +498,14 @@ func appendMessageSliceInfo(b []byte, p pointer, f *coderFieldInfo, opts marshal
|
||||
b = protowire.AppendVarint(b, f.wiretag)
|
||||
siz := f.mi.sizePointer(v, opts)
|
||||
b = protowire.AppendVarint(b, uint64(siz))
|
||||
before := len(b)
|
||||
b, err = f.mi.marshalAppendPointer(b, v, opts)
|
||||
if err != nil {
|
||||
return b, err
|
||||
}
|
||||
if measuredSize := len(b) - before; siz != measuredSize {
|
||||
return nil, errors.MismatchedSizeCalculation(siz, measuredSize)
|
||||
}
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
@ -520,28 +540,34 @@ func isInitMessageSliceInfo(p pointer, f *coderFieldInfo) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func sizeMessageSlice(p pointer, goType reflect.Type, tagsize int, _ marshalOptions) int {
|
||||
func sizeMessageSlice(p pointer, goType reflect.Type, tagsize int, opts marshalOptions) int {
|
||||
mopts := opts.Options()
|
||||
s := p.PointerSlice()
|
||||
n := 0
|
||||
for _, v := range s {
|
||||
m := asMessage(v.AsValueOf(goType.Elem()))
|
||||
n += protowire.SizeBytes(proto.Size(m)) + tagsize
|
||||
n += protowire.SizeBytes(mopts.Size(m)) + tagsize
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func appendMessageSlice(b []byte, p pointer, wiretag uint64, goType reflect.Type, opts marshalOptions) ([]byte, error) {
|
||||
mopts := opts.Options()
|
||||
s := p.PointerSlice()
|
||||
var err error
|
||||
for _, v := range s {
|
||||
m := asMessage(v.AsValueOf(goType.Elem()))
|
||||
b = protowire.AppendVarint(b, wiretag)
|
||||
siz := proto.Size(m)
|
||||
siz := mopts.Size(m)
|
||||
b = protowire.AppendVarint(b, uint64(siz))
|
||||
b, err = opts.Options().MarshalAppend(b, m)
|
||||
before := len(b)
|
||||
b, err = mopts.MarshalAppend(b, m)
|
||||
if err != nil {
|
||||
return b, err
|
||||
}
|
||||
if measuredSize := len(b) - before; siz != measuredSize {
|
||||
return nil, errors.MismatchedSizeCalculation(siz, measuredSize)
|
||||
}
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
@ -582,11 +608,12 @@ func isInitMessageSlice(p pointer, goType reflect.Type) error {
|
||||
// Slices of messages
|
||||
|
||||
func sizeMessageSliceValue(listv protoreflect.Value, tagsize int, opts marshalOptions) int {
|
||||
mopts := opts.Options()
|
||||
list := listv.List()
|
||||
n := 0
|
||||
for i, llen := 0, list.Len(); i < llen; i++ {
|
||||
m := list.Get(i).Message().Interface()
|
||||
n += protowire.SizeBytes(proto.Size(m)) + tagsize
|
||||
n += protowire.SizeBytes(mopts.Size(m)) + tagsize
|
||||
}
|
||||
return n
|
||||
}
|
||||
@ -597,13 +624,17 @@ func appendMessageSliceValue(b []byte, listv protoreflect.Value, wiretag uint64,
|
||||
for i, llen := 0, list.Len(); i < llen; i++ {
|
||||
m := list.Get(i).Message().Interface()
|
||||
b = protowire.AppendVarint(b, wiretag)
|
||||
siz := proto.Size(m)
|
||||
siz := mopts.Size(m)
|
||||
b = protowire.AppendVarint(b, uint64(siz))
|
||||
before := len(b)
|
||||
var err error
|
||||
b, err = mopts.MarshalAppend(b, m)
|
||||
if err != nil {
|
||||
return b, err
|
||||
}
|
||||
if measuredSize := len(b) - before; siz != measuredSize {
|
||||
return nil, errors.MismatchedSizeCalculation(siz, measuredSize)
|
||||
}
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
@ -651,11 +682,12 @@ var coderMessageSliceValue = valueCoderFuncs{
|
||||
}
|
||||
|
||||
func sizeGroupSliceValue(listv protoreflect.Value, tagsize int, opts marshalOptions) int {
|
||||
mopts := opts.Options()
|
||||
list := listv.List()
|
||||
n := 0
|
||||
for i, llen := 0, list.Len(); i < llen; i++ {
|
||||
m := list.Get(i).Message().Interface()
|
||||
n += 2*tagsize + proto.Size(m)
|
||||
n += 2*tagsize + mopts.Size(m)
|
||||
}
|
||||
return n
|
||||
}
|
||||
@ -738,12 +770,13 @@ func makeGroupSliceFieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type)
|
||||
}
|
||||
}
|
||||
|
||||
func sizeGroupSlice(p pointer, messageType reflect.Type, tagsize int, _ marshalOptions) int {
|
||||
func sizeGroupSlice(p pointer, messageType reflect.Type, tagsize int, opts marshalOptions) int {
|
||||
mopts := opts.Options()
|
||||
s := p.PointerSlice()
|
||||
n := 0
|
||||
for _, v := range s {
|
||||
m := asMessage(v.AsValueOf(messageType.Elem()))
|
||||
n += 2*tagsize + proto.Size(m)
|
||||
n += 2*tagsize + mopts.Size(m)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
15
vendor/google.golang.org/protobuf/internal/impl/codec_map.go
generated
vendored
15
vendor/google.golang.org/protobuf/internal/impl/codec_map.go
generated
vendored
@ -9,6 +9,7 @@ import (
|
||||
"sort"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
@ -240,11 +241,16 @@ func appendMapItem(b []byte, keyrv, valrv reflect.Value, mapi *mapInfo, f *coder
|
||||
size += mapi.keyFuncs.size(key.Value(), mapKeyTagSize, opts)
|
||||
size += mapi.valFuncs.size(val, mapValTagSize, opts)
|
||||
b = protowire.AppendVarint(b, uint64(size))
|
||||
before := len(b)
|
||||
b, err := mapi.keyFuncs.marshal(b, key.Value(), mapi.keyWiretag, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mapi.valFuncs.marshal(b, val, mapi.valWiretag, opts)
|
||||
b, err = mapi.valFuncs.marshal(b, val, mapi.valWiretag, opts)
|
||||
if measuredSize := len(b) - before; size != measuredSize && err == nil {
|
||||
return nil, errors.MismatchedSizeCalculation(size, measuredSize)
|
||||
}
|
||||
return b, err
|
||||
} else {
|
||||
key := mapi.conv.keyConv.PBValueOf(keyrv).MapKey()
|
||||
val := pointerOfValue(valrv)
|
||||
@ -259,7 +265,12 @@ func appendMapItem(b []byte, keyrv, valrv reflect.Value, mapi *mapInfo, f *coder
|
||||
}
|
||||
b = protowire.AppendVarint(b, mapi.valWiretag)
|
||||
b = protowire.AppendVarint(b, uint64(valSize))
|
||||
return f.mi.marshalAppendPointer(b, val, opts)
|
||||
before := len(b)
|
||||
b, err = f.mi.marshalAppendPointer(b, val, opts)
|
||||
if measuredSize := len(b) - before; valSize != measuredSize && err == nil {
|
||||
return nil, errors.MismatchedSizeCalculation(valSize, measuredSize)
|
||||
}
|
||||
return b, err
|
||||
}
|
||||
}
|
||||
|
||||
|
3
vendor/google.golang.org/protobuf/internal/impl/codec_message.go
generated
vendored
3
vendor/google.golang.org/protobuf/internal/impl/codec_message.go
generated
vendored
@ -189,6 +189,9 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
if mi.methods.Merge == nil {
|
||||
mi.methods.Merge = mi.merge
|
||||
}
|
||||
if mi.methods.Equal == nil {
|
||||
mi.methods.Equal = equal
|
||||
}
|
||||
}
|
||||
|
||||
// getUnknownBytes returns a *[]byte for the unknown fields.
|
||||
|
22
vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go
generated
vendored
22
vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go
generated
vendored
@ -26,6 +26,15 @@ func sizeMessageSet(mi *MessageInfo, p pointer, opts marshalOptions) (size int)
|
||||
}
|
||||
num, _ := protowire.DecodeTag(xi.wiretag)
|
||||
size += messageset.SizeField(num)
|
||||
if fullyLazyExtensions(opts) {
|
||||
// Don't expand the extension, instead use the buffer to calculate size
|
||||
if lb := x.lazyBuffer(); lb != nil {
|
||||
// We got hold of the buffer, so it's still lazy.
|
||||
// Don't count the tag size in the extension buffer, it's already added.
|
||||
size += protowire.SizeTag(messageset.FieldMessage) + len(lb) - xi.tagsize
|
||||
continue
|
||||
}
|
||||
}
|
||||
size += xi.funcs.size(x.Value(), protowire.SizeTag(messageset.FieldMessage), opts)
|
||||
}
|
||||
|
||||
@ -85,6 +94,19 @@ func marshalMessageSetField(mi *MessageInfo, b []byte, x ExtensionField, opts ma
|
||||
xi := getExtensionFieldInfo(x.Type())
|
||||
num, _ := protowire.DecodeTag(xi.wiretag)
|
||||
b = messageset.AppendFieldStart(b, num)
|
||||
|
||||
if fullyLazyExtensions(opts) {
|
||||
// Don't expand the extension if it's still in wire format, instead use the buffer content.
|
||||
if lb := x.lazyBuffer(); lb != nil {
|
||||
// The tag inside the lazy buffer is a different tag (the extension
|
||||
// number), but what we need here is the tag for FieldMessage:
|
||||
b = protowire.AppendVarint(b, protowire.EncodeTag(messageset.FieldMessage, protowire.BytesType))
|
||||
b = append(b, lb[xi.tagsize:]...)
|
||||
b = messageset.AppendFieldEnd(b)
|
||||
return b, nil
|
||||
}
|
||||
}
|
||||
|
||||
b, err := xi.funcs.marshal(b, x.Value(), protowire.EncodeTag(messageset.FieldMessage, protowire.BytesType), opts)
|
||||
if err != nil {
|
||||
return b, err
|
||||
|
210
vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go
generated
vendored
210
vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go
generated
vendored
@ -1,210 +0,0 @@
|
||||
// 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.
|
||||
|
||||
//go:build purego || appengine
|
||||
// +build purego appengine
|
||||
|
||||
package impl
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
)
|
||||
|
||||
func sizeEnum(p pointer, f *coderFieldInfo, _ marshalOptions) (size int) {
|
||||
v := p.v.Elem().Int()
|
||||
return f.tagsize + protowire.SizeVarint(uint64(v))
|
||||
}
|
||||
|
||||
func appendEnum(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
|
||||
v := p.v.Elem().Int()
|
||||
b = protowire.AppendVarint(b, f.wiretag)
|
||||
b = protowire.AppendVarint(b, uint64(v))
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func consumeEnum(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, _ unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
if wtyp != protowire.VarintType {
|
||||
return out, errUnknown
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
p.v.Elem().SetInt(int64(v))
|
||||
out.n = n
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func mergeEnum(dst, src pointer, _ *coderFieldInfo, _ mergeOptions) {
|
||||
dst.v.Elem().Set(src.v.Elem())
|
||||
}
|
||||
|
||||
var coderEnum = pointerCoderFuncs{
|
||||
size: sizeEnum,
|
||||
marshal: appendEnum,
|
||||
unmarshal: consumeEnum,
|
||||
merge: mergeEnum,
|
||||
}
|
||||
|
||||
func sizeEnumNoZero(p pointer, f *coderFieldInfo, opts marshalOptions) (size int) {
|
||||
if p.v.Elem().Int() == 0 {
|
||||
return 0
|
||||
}
|
||||
return sizeEnum(p, f, opts)
|
||||
}
|
||||
|
||||
func appendEnumNoZero(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
|
||||
if p.v.Elem().Int() == 0 {
|
||||
return b, nil
|
||||
}
|
||||
return appendEnum(b, p, f, opts)
|
||||
}
|
||||
|
||||
func mergeEnumNoZero(dst, src pointer, _ *coderFieldInfo, _ mergeOptions) {
|
||||
if src.v.Elem().Int() != 0 {
|
||||
dst.v.Elem().Set(src.v.Elem())
|
||||
}
|
||||
}
|
||||
|
||||
var coderEnumNoZero = pointerCoderFuncs{
|
||||
size: sizeEnumNoZero,
|
||||
marshal: appendEnumNoZero,
|
||||
unmarshal: consumeEnum,
|
||||
merge: mergeEnumNoZero,
|
||||
}
|
||||
|
||||
func sizeEnumPtr(p pointer, f *coderFieldInfo, opts marshalOptions) (size int) {
|
||||
return sizeEnum(pointer{p.v.Elem()}, f, opts)
|
||||
}
|
||||
|
||||
func appendEnumPtr(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
|
||||
return appendEnum(b, pointer{p.v.Elem()}, f, opts)
|
||||
}
|
||||
|
||||
func consumeEnumPtr(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
if wtyp != protowire.VarintType {
|
||||
return out, errUnknown
|
||||
}
|
||||
if p.v.Elem().IsNil() {
|
||||
p.v.Elem().Set(reflect.New(p.v.Elem().Type().Elem()))
|
||||
}
|
||||
return consumeEnum(b, pointer{p.v.Elem()}, wtyp, f, opts)
|
||||
}
|
||||
|
||||
func mergeEnumPtr(dst, src pointer, _ *coderFieldInfo, _ mergeOptions) {
|
||||
if !src.v.Elem().IsNil() {
|
||||
v := reflect.New(dst.v.Type().Elem().Elem())
|
||||
v.Elem().Set(src.v.Elem().Elem())
|
||||
dst.v.Elem().Set(v)
|
||||
}
|
||||
}
|
||||
|
||||
var coderEnumPtr = pointerCoderFuncs{
|
||||
size: sizeEnumPtr,
|
||||
marshal: appendEnumPtr,
|
||||
unmarshal: consumeEnumPtr,
|
||||
merge: mergeEnumPtr,
|
||||
}
|
||||
|
||||
func sizeEnumSlice(p pointer, f *coderFieldInfo, opts marshalOptions) (size int) {
|
||||
s := p.v.Elem()
|
||||
for i, llen := 0, s.Len(); i < llen; i++ {
|
||||
size += protowire.SizeVarint(uint64(s.Index(i).Int())) + f.tagsize
|
||||
}
|
||||
return size
|
||||
}
|
||||
|
||||
func appendEnumSlice(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
|
||||
s := p.v.Elem()
|
||||
for i, llen := 0, s.Len(); i < llen; i++ {
|
||||
b = protowire.AppendVarint(b, f.wiretag)
|
||||
b = protowire.AppendVarint(b, uint64(s.Index(i).Int()))
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func consumeEnumSlice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
s := p.v.Elem()
|
||||
if wtyp == protowire.BytesType {
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
for len(b) > 0 {
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
rv := reflect.New(s.Type().Elem()).Elem()
|
||||
rv.SetInt(int64(v))
|
||||
s.Set(reflect.Append(s, rv))
|
||||
b = b[n:]
|
||||
}
|
||||
out.n = n
|
||||
return out, nil
|
||||
}
|
||||
if wtyp != protowire.VarintType {
|
||||
return out, errUnknown
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
rv := reflect.New(s.Type().Elem()).Elem()
|
||||
rv.SetInt(int64(v))
|
||||
s.Set(reflect.Append(s, rv))
|
||||
out.n = n
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func mergeEnumSlice(dst, src pointer, _ *coderFieldInfo, _ mergeOptions) {
|
||||
dst.v.Elem().Set(reflect.AppendSlice(dst.v.Elem(), src.v.Elem()))
|
||||
}
|
||||
|
||||
var coderEnumSlice = pointerCoderFuncs{
|
||||
size: sizeEnumSlice,
|
||||
marshal: appendEnumSlice,
|
||||
unmarshal: consumeEnumSlice,
|
||||
merge: mergeEnumSlice,
|
||||
}
|
||||
|
||||
func sizeEnumPackedSlice(p pointer, f *coderFieldInfo, opts marshalOptions) (size int) {
|
||||
s := p.v.Elem()
|
||||
llen := s.Len()
|
||||
if llen == 0 {
|
||||
return 0
|
||||
}
|
||||
n := 0
|
||||
for i := 0; i < llen; i++ {
|
||||
n += protowire.SizeVarint(uint64(s.Index(i).Int()))
|
||||
}
|
||||
return f.tagsize + protowire.SizeBytes(n)
|
||||
}
|
||||
|
||||
func appendEnumPackedSlice(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
|
||||
s := p.v.Elem()
|
||||
llen := s.Len()
|
||||
if llen == 0 {
|
||||
return b, nil
|
||||
}
|
||||
b = protowire.AppendVarint(b, f.wiretag)
|
||||
n := 0
|
||||
for i := 0; i < llen; i++ {
|
||||
n += protowire.SizeVarint(uint64(s.Index(i).Int()))
|
||||
}
|
||||
b = protowire.AppendVarint(b, uint64(n))
|
||||
for i := 0; i < llen; i++ {
|
||||
b = protowire.AppendVarint(b, uint64(s.Index(i).Int()))
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
var coderEnumPackedSlice = pointerCoderFuncs{
|
||||
size: sizeEnumPackedSlice,
|
||||
marshal: appendEnumPackedSlice,
|
||||
unmarshal: consumeEnumSlice,
|
||||
merge: mergeEnumSlice,
|
||||
}
|
3
vendor/google.golang.org/protobuf/internal/impl/codec_unsafe.go
generated
vendored
3
vendor/google.golang.org/protobuf/internal/impl/codec_unsafe.go
generated
vendored
@ -2,9 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !purego && !appengine
|
||||
// +build !purego,!appengine
|
||||
|
||||
package impl
|
||||
|
||||
// When using unsafe pointers, we can just treat enum values as int32s.
|
||||
|
4
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
4
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
@ -14,7 +14,7 @@ import (
|
||||
// unwrapper unwraps the value to the underlying value.
|
||||
// This is implemented by List and Map.
|
||||
type unwrapper interface {
|
||||
protoUnwrap() interface{}
|
||||
protoUnwrap() any
|
||||
}
|
||||
|
||||
// A Converter coverts to/from Go reflect.Value types and protobuf protoreflect.Value types.
|
||||
@ -322,7 +322,7 @@ func (c *stringConverter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
return protoreflect.ValueOfString(v.Convert(stringType).String())
|
||||
}
|
||||
func (c *stringConverter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
// pref.Value.String never panics, so we go through an interface
|
||||
// protoreflect.Value.String never panics, so we go through an interface
|
||||
// conversion here to check the type.
|
||||
s := v.Interface().(string)
|
||||
if c.goType.Kind() == reflect.Slice && s == "" {
|
||||
|
2
vendor/google.golang.org/protobuf/internal/impl/convert_list.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/impl/convert_list.go
generated
vendored
@ -136,6 +136,6 @@ func (ls *listReflect) NewElement() protoreflect.Value {
|
||||
func (ls *listReflect) IsValid() bool {
|
||||
return !ls.v.IsNil()
|
||||
}
|
||||
func (ls *listReflect) protoUnwrap() interface{} {
|
||||
func (ls *listReflect) protoUnwrap() any {
|
||||
return ls.v.Interface()
|
||||
}
|
||||
|
2
vendor/google.golang.org/protobuf/internal/impl/convert_map.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/impl/convert_map.go
generated
vendored
@ -116,6 +116,6 @@ func (ms *mapReflect) NewValue() protoreflect.Value {
|
||||
func (ms *mapReflect) IsValid() bool {
|
||||
return !ms.v.IsNil()
|
||||
}
|
||||
func (ms *mapReflect) protoUnwrap() interface{} {
|
||||
func (ms *mapReflect) protoUnwrap() any {
|
||||
return ms.v.Interface()
|
||||
}
|
||||
|
50
vendor/google.golang.org/protobuf/internal/impl/encode.go
generated
vendored
50
vendor/google.golang.org/protobuf/internal/impl/encode.go
generated
vendored
@ -10,7 +10,7 @@ import (
|
||||
"sync/atomic"
|
||||
|
||||
"google.golang.org/protobuf/internal/flags"
|
||||
proto "google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
@ -49,8 +49,11 @@ func (mi *MessageInfo) sizePointer(p pointer, opts marshalOptions) (size int) {
|
||||
return 0
|
||||
}
|
||||
if opts.UseCachedSize() && mi.sizecacheOffset.IsValid() {
|
||||
if size := atomic.LoadInt32(p.Apply(mi.sizecacheOffset).Int32()); size >= 0 {
|
||||
return int(size)
|
||||
// The size cache contains the size + 1, to allow the
|
||||
// zero value to be invalid, while also allowing for a
|
||||
// 0 size to be cached.
|
||||
if size := atomic.LoadInt32(p.Apply(mi.sizecacheOffset).Int32()); size > 0 {
|
||||
return int(size - 1)
|
||||
}
|
||||
}
|
||||
return mi.sizePointerSlow(p, opts)
|
||||
@ -60,7 +63,7 @@ func (mi *MessageInfo) sizePointerSlow(p pointer, opts marshalOptions) (size int
|
||||
if flags.ProtoLegacy && mi.isMessageSet {
|
||||
size = sizeMessageSet(mi, p, opts)
|
||||
if mi.sizecacheOffset.IsValid() {
|
||||
atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), int32(size))
|
||||
atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), int32(size+1))
|
||||
}
|
||||
return size
|
||||
}
|
||||
@ -84,13 +87,16 @@ func (mi *MessageInfo) sizePointerSlow(p pointer, opts marshalOptions) (size int
|
||||
}
|
||||
}
|
||||
if mi.sizecacheOffset.IsValid() {
|
||||
if size > math.MaxInt32 {
|
||||
if size > (math.MaxInt32 - 1) {
|
||||
// The size is too large for the int32 sizecache field.
|
||||
// We will need to recompute the size when encoding;
|
||||
// unfortunately expensive, but better than invalid output.
|
||||
atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), -1)
|
||||
atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), 0)
|
||||
} else {
|
||||
atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), int32(size))
|
||||
// The size cache contains the size + 1, to allow the
|
||||
// zero value to be invalid, while also allowing for a
|
||||
// 0 size to be cached.
|
||||
atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), int32(size+1))
|
||||
}
|
||||
}
|
||||
return size
|
||||
@ -149,6 +155,14 @@ func (mi *MessageInfo) marshalAppendPointer(b []byte, p pointer, opts marshalOpt
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// fullyLazyExtensions returns true if we should attempt to keep extensions lazy over size and marshal.
|
||||
func fullyLazyExtensions(opts marshalOptions) bool {
|
||||
// When deterministic marshaling is requested, force an unmarshal for lazy
|
||||
// extensions to produce a deterministic result, instead of passing through
|
||||
// bytes lazily that may or may not match what Go Protobuf would produce.
|
||||
return opts.flags&piface.MarshalDeterministic == 0
|
||||
}
|
||||
|
||||
func (mi *MessageInfo) sizeExtensions(ext *map[int32]ExtensionField, opts marshalOptions) (n int) {
|
||||
if ext == nil {
|
||||
return 0
|
||||
@ -158,6 +172,14 @@ func (mi *MessageInfo) sizeExtensions(ext *map[int32]ExtensionField, opts marsha
|
||||
if xi.funcs.size == nil {
|
||||
continue
|
||||
}
|
||||
if fullyLazyExtensions(opts) {
|
||||
// Don't expand the extension, instead use the buffer to calculate size
|
||||
if lb := x.lazyBuffer(); lb != nil {
|
||||
// We got hold of the buffer, so it's still lazy.
|
||||
n += len(lb)
|
||||
continue
|
||||
}
|
||||
}
|
||||
n += xi.funcs.size(x.Value(), xi.tagsize, opts)
|
||||
}
|
||||
return n
|
||||
@ -176,6 +198,13 @@ func (mi *MessageInfo) appendExtensions(b []byte, ext *map[int32]ExtensionField,
|
||||
var err error
|
||||
for _, x := range *ext {
|
||||
xi := getExtensionFieldInfo(x.Type())
|
||||
if fullyLazyExtensions(opts) {
|
||||
// Don't expand the extension if it's still in wire format, instead use the buffer content.
|
||||
if lb := x.lazyBuffer(); lb != nil {
|
||||
b = append(b, lb...)
|
||||
continue
|
||||
}
|
||||
}
|
||||
b, err = xi.funcs.marshal(b, x.Value(), xi.wiretag, opts)
|
||||
}
|
||||
return b, err
|
||||
@ -191,6 +220,13 @@ func (mi *MessageInfo) appendExtensions(b []byte, ext *map[int32]ExtensionField,
|
||||
for _, k := range keys {
|
||||
x := (*ext)[int32(k)]
|
||||
xi := getExtensionFieldInfo(x.Type())
|
||||
if fullyLazyExtensions(opts) {
|
||||
// Don't expand the extension if it's still in wire format, instead use the buffer content.
|
||||
if lb := x.lazyBuffer(); lb != nil {
|
||||
b = append(b, lb...)
|
||||
continue
|
||||
}
|
||||
}
|
||||
b, err = xi.funcs.marshal(b, x.Value(), xi.wiretag, opts)
|
||||
if err != nil {
|
||||
return b, err
|
||||
|
224
vendor/google.golang.org/protobuf/internal/impl/equal.go
generated
vendored
Normal file
224
vendor/google.golang.org/protobuf/internal/impl/equal.go
generated
vendored
Normal file
@ -0,0 +1,224 @@
|
||||
// Copyright 2024 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 impl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
func equal(in protoiface.EqualInput) protoiface.EqualOutput {
|
||||
return protoiface.EqualOutput{Equal: equalMessage(in.MessageA, in.MessageB)}
|
||||
}
|
||||
|
||||
// equalMessage is a fast-path variant of protoreflect.equalMessage.
|
||||
// It takes advantage of the internal messageState type to avoid
|
||||
// unnecessary allocations, type assertions.
|
||||
func equalMessage(mx, my protoreflect.Message) bool {
|
||||
if mx == nil || my == nil {
|
||||
return mx == my
|
||||
}
|
||||
if mx.Descriptor() != my.Descriptor() {
|
||||
return false
|
||||
}
|
||||
|
||||
msx, ok := mx.(*messageState)
|
||||
if !ok {
|
||||
return protoreflect.ValueOfMessage(mx).Equal(protoreflect.ValueOfMessage(my))
|
||||
}
|
||||
msy, ok := my.(*messageState)
|
||||
if !ok {
|
||||
return protoreflect.ValueOfMessage(mx).Equal(protoreflect.ValueOfMessage(my))
|
||||
}
|
||||
|
||||
mi := msx.messageInfo()
|
||||
miy := msy.messageInfo()
|
||||
if mi != miy {
|
||||
return protoreflect.ValueOfMessage(mx).Equal(protoreflect.ValueOfMessage(my))
|
||||
}
|
||||
mi.init()
|
||||
// Compares regular fields
|
||||
// Modified Message.Range code that compares two messages of the same type
|
||||
// while going over the fields.
|
||||
for _, ri := range mi.rangeInfos {
|
||||
var fd protoreflect.FieldDescriptor
|
||||
var vx, vy protoreflect.Value
|
||||
|
||||
switch ri := ri.(type) {
|
||||
case *fieldInfo:
|
||||
hx := ri.has(msx.pointer())
|
||||
hy := ri.has(msy.pointer())
|
||||
if hx != hy {
|
||||
return false
|
||||
}
|
||||
if !hx {
|
||||
continue
|
||||
}
|
||||
fd = ri.fieldDesc
|
||||
vx = ri.get(msx.pointer())
|
||||
vy = ri.get(msy.pointer())
|
||||
case *oneofInfo:
|
||||
fnx := ri.which(msx.pointer())
|
||||
fny := ri.which(msy.pointer())
|
||||
if fnx != fny {
|
||||
return false
|
||||
}
|
||||
if fnx <= 0 {
|
||||
continue
|
||||
}
|
||||
fi := mi.fields[fnx]
|
||||
fd = fi.fieldDesc
|
||||
vx = fi.get(msx.pointer())
|
||||
vy = fi.get(msy.pointer())
|
||||
}
|
||||
|
||||
if !equalValue(fd, vx, vy) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Compare extensions.
|
||||
// This is more complicated because mx or my could have empty/nil extension maps,
|
||||
// however some populated extension map values are equal to nil extension maps.
|
||||
emx := mi.extensionMap(msx.pointer())
|
||||
emy := mi.extensionMap(msy.pointer())
|
||||
if emx != nil {
|
||||
for k, x := range *emx {
|
||||
xd := x.Type().TypeDescriptor()
|
||||
xv := x.Value()
|
||||
var y ExtensionField
|
||||
ok := false
|
||||
if emy != nil {
|
||||
y, ok = (*emy)[k]
|
||||
}
|
||||
// We need to treat empty lists as equal to nil values
|
||||
if emy == nil || !ok {
|
||||
if xd.IsList() && xv.List().Len() == 0 {
|
||||
continue
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if !equalValue(xd, xv, y.Value()) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
if emy != nil {
|
||||
// emy may have extensions emx does not have, need to check them as well
|
||||
for k, y := range *emy {
|
||||
if emx != nil {
|
||||
// emx has the field, so we already checked it
|
||||
if _, ok := (*emx)[k]; ok {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// Empty lists are equal to nil
|
||||
if y.Type().TypeDescriptor().IsList() && y.Value().List().Len() == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// Cant be equal if the extension is populated
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return equalUnknown(mx.GetUnknown(), my.GetUnknown())
|
||||
}
|
||||
|
||||
func equalValue(fd protoreflect.FieldDescriptor, vx, vy protoreflect.Value) bool {
|
||||
// slow path
|
||||
if fd.Kind() != protoreflect.MessageKind {
|
||||
return vx.Equal(vy)
|
||||
}
|
||||
|
||||
// fast path special cases
|
||||
if fd.IsMap() {
|
||||
if fd.MapValue().Kind() == protoreflect.MessageKind {
|
||||
return equalMessageMap(vx.Map(), vy.Map())
|
||||
}
|
||||
return vx.Equal(vy)
|
||||
}
|
||||
|
||||
if fd.IsList() {
|
||||
return equalMessageList(vx.List(), vy.List())
|
||||
}
|
||||
|
||||
return equalMessage(vx.Message(), vy.Message())
|
||||
}
|
||||
|
||||
// Mostly copied from protoreflect.equalMap.
|
||||
// This variant only works for messages as map types.
|
||||
// All other map types should be handled via Value.Equal.
|
||||
func equalMessageMap(mx, my protoreflect.Map) bool {
|
||||
if mx.Len() != my.Len() {
|
||||
return false
|
||||
}
|
||||
equal := true
|
||||
mx.Range(func(k protoreflect.MapKey, vx protoreflect.Value) bool {
|
||||
if !my.Has(k) {
|
||||
equal = false
|
||||
return false
|
||||
}
|
||||
vy := my.Get(k)
|
||||
equal = equalMessage(vx.Message(), vy.Message())
|
||||
return equal
|
||||
})
|
||||
return equal
|
||||
}
|
||||
|
||||
// Mostly copied from protoreflect.equalList.
|
||||
// The only change is the usage of equalImpl instead of protoreflect.equalValue.
|
||||
func equalMessageList(lx, ly protoreflect.List) bool {
|
||||
if lx.Len() != ly.Len() {
|
||||
return false
|
||||
}
|
||||
for i := 0; i < lx.Len(); i++ {
|
||||
// We only operate on messages here since equalImpl will not call us in any other case.
|
||||
if !equalMessage(lx.Get(i).Message(), ly.Get(i).Message()) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// equalUnknown compares unknown fields by direct comparison on the raw bytes
|
||||
// of each individual field number.
|
||||
// Copied from protoreflect.equalUnknown.
|
||||
func equalUnknown(x, y protoreflect.RawFields) bool {
|
||||
if len(x) != len(y) {
|
||||
return false
|
||||
}
|
||||
if bytes.Equal([]byte(x), []byte(y)) {
|
||||
return true
|
||||
}
|
||||
|
||||
mx := make(map[protoreflect.FieldNumber]protoreflect.RawFields)
|
||||
my := make(map[protoreflect.FieldNumber]protoreflect.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:]
|
||||
}
|
||||
if len(mx) != len(my) {
|
||||
return false
|
||||
}
|
||||
|
||||
for k, v1 := range mx {
|
||||
if v2, ok := my[k]; !ok || !bytes.Equal([]byte(v1), []byte(v2)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
8
vendor/google.golang.org/protobuf/internal/impl/extension.go
generated
vendored
8
vendor/google.golang.org/protobuf/internal/impl/extension.go
generated
vendored
@ -53,7 +53,7 @@ type ExtensionInfo struct {
|
||||
// type returned by InterfaceOf may not be identical.
|
||||
//
|
||||
// Deprecated: Use InterfaceOf(xt.Zero()) instead.
|
||||
ExtensionType interface{}
|
||||
ExtensionType any
|
||||
|
||||
// Field is the field number of the extension.
|
||||
//
|
||||
@ -95,16 +95,16 @@ func (xi *ExtensionInfo) New() protoreflect.Value {
|
||||
func (xi *ExtensionInfo) Zero() protoreflect.Value {
|
||||
return xi.lazyInit().Zero()
|
||||
}
|
||||
func (xi *ExtensionInfo) ValueOf(v interface{}) protoreflect.Value {
|
||||
func (xi *ExtensionInfo) ValueOf(v any) protoreflect.Value {
|
||||
return xi.lazyInit().PBValueOf(reflect.ValueOf(v))
|
||||
}
|
||||
func (xi *ExtensionInfo) InterfaceOf(v protoreflect.Value) interface{} {
|
||||
func (xi *ExtensionInfo) InterfaceOf(v protoreflect.Value) any {
|
||||
return xi.lazyInit().GoValueOf(v).Interface()
|
||||
}
|
||||
func (xi *ExtensionInfo) IsValidValue(v protoreflect.Value) bool {
|
||||
return xi.lazyInit().IsValidPB(v)
|
||||
}
|
||||
func (xi *ExtensionInfo) IsValidInterface(v interface{}) bool {
|
||||
func (xi *ExtensionInfo) IsValidInterface(v any) bool {
|
||||
return xi.lazyInit().IsValidGo(reflect.ValueOf(v))
|
||||
}
|
||||
func (xi *ExtensionInfo) TypeDescriptor() protoreflect.ExtensionTypeDescriptor {
|
||||
|
3
vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go
generated
vendored
3
vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go
generated
vendored
@ -97,7 +97,7 @@ func (e *legacyEnumWrapper) Number() protoreflect.EnumNumber {
|
||||
func (e *legacyEnumWrapper) ProtoReflect() protoreflect.Enum {
|
||||
return e
|
||||
}
|
||||
func (e *legacyEnumWrapper) protoUnwrap() interface{} {
|
||||
func (e *legacyEnumWrapper) protoUnwrap() any {
|
||||
v := reflect.New(e.goTyp).Elem()
|
||||
v.SetInt(int64(e.num))
|
||||
return v.Interface()
|
||||
@ -167,6 +167,7 @@ func aberrantLoadEnumDesc(t reflect.Type) protoreflect.EnumDescriptor {
|
||||
ed := &filedesc.Enum{L2: new(filedesc.EnumL2)}
|
||||
ed.L0.FullName = AberrantDeriveFullName(t) // e.g., github_com.user.repo.MyEnum
|
||||
ed.L0.ParentFile = filedesc.SurrogateProto3
|
||||
ed.L1.EditionFeatures = ed.L0.ParentFile.L1.EditionFeatures
|
||||
ed.L2.Values.List = append(ed.L2.Values.List, filedesc.EnumValue{})
|
||||
|
||||
// TODO: Use the presence of a UnmarshalJSON method to determine proto2?
|
||||
|
3
vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
generated
vendored
3
vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
generated
vendored
@ -118,7 +118,7 @@ func (xi *ExtensionInfo) initFromLegacy() {
|
||||
xd.L1.Number = protoreflect.FieldNumber(xi.Field)
|
||||
xd.L1.Cardinality = fd.L1.Cardinality
|
||||
xd.L1.Kind = fd.L1.Kind
|
||||
xd.L2.IsPacked = fd.L1.IsPacked
|
||||
xd.L1.EditionFeatures = fd.L1.EditionFeatures
|
||||
xd.L2.Default = fd.L1.Default
|
||||
xd.L1.Extendee = Export{}.MessageDescriptorOf(xi.ExtendedType)
|
||||
xd.L2.Enum = ed
|
||||
@ -160,6 +160,7 @@ func (x placeholderExtension) HasPresence() bool
|
||||
func (x placeholderExtension) HasOptionalKeyword() bool { return false }
|
||||
func (x placeholderExtension) IsExtension() bool { return true }
|
||||
func (x placeholderExtension) IsWeak() bool { return false }
|
||||
func (x placeholderExtension) IsLazy() bool { return false }
|
||||
func (x placeholderExtension) IsPacked() bool { return false }
|
||||
func (x placeholderExtension) IsList() bool { return false }
|
||||
func (x placeholderExtension) IsMap() bool { return false }
|
||||
|
4
vendor/google.golang.org/protobuf/internal/impl/legacy_file.go
generated
vendored
4
vendor/google.golang.org/protobuf/internal/impl/legacy_file.go
generated
vendored
@ -7,7 +7,7 @@ package impl
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/internal/filedesc"
|
||||
@ -51,7 +51,7 @@ func legacyLoadFileDesc(b []byte) protoreflect.FileDescriptor {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
b2, err := ioutil.ReadAll(zr)
|
||||
b2, err := io.ReadAll(zr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
14
vendor/google.golang.org/protobuf/internal/impl/legacy_message.go
generated
vendored
14
vendor/google.golang.org/protobuf/internal/impl/legacy_message.go
generated
vendored
@ -204,6 +204,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName
|
||||
}
|
||||
}
|
||||
|
||||
md.L1.EditionFeatures = md.L0.ParentFile.L1.EditionFeatures
|
||||
// Obtain a list of oneof wrapper types.
|
||||
var oneofWrappers []reflect.Type
|
||||
methods := make([]reflect.Method, 0, 2)
|
||||
@ -215,7 +216,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName
|
||||
}
|
||||
for _, fn := range methods {
|
||||
for _, v := range fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))}) {
|
||||
if vs, ok := v.Interface().([]interface{}); ok {
|
||||
if vs, ok := v.Interface().([]any); ok {
|
||||
for _, v := range vs {
|
||||
oneofWrappers = append(oneofWrappers, reflect.TypeOf(v))
|
||||
}
|
||||
@ -250,6 +251,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName
|
||||
od := &md.L2.Oneofs.List[n]
|
||||
od.L0.FullName = md.FullName().Append(protoreflect.Name(tag))
|
||||
od.L0.ParentFile = md.L0.ParentFile
|
||||
od.L1.EditionFeatures = md.L1.EditionFeatures
|
||||
od.L0.Parent = md
|
||||
od.L0.Index = n
|
||||
|
||||
@ -260,6 +262,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName
|
||||
aberrantAppendField(md, f.Type, tag, "", "")
|
||||
fd := &md.L2.Fields.List[len(md.L2.Fields.List)-1]
|
||||
fd.L1.ContainingOneof = od
|
||||
fd.L1.EditionFeatures = od.L1.EditionFeatures
|
||||
od.L1.Fields.List = append(od.L1.Fields.List, fd)
|
||||
}
|
||||
}
|
||||
@ -307,14 +310,14 @@ func aberrantAppendField(md *filedesc.Message, goType reflect.Type, tag, tagKey,
|
||||
fd.L0.Parent = md
|
||||
fd.L0.Index = n
|
||||
|
||||
if fd.L1.IsWeak || fd.L1.HasPacked {
|
||||
if fd.L1.IsWeak || fd.L1.EditionFeatures.IsPacked {
|
||||
fd.L1.Options = func() protoreflect.ProtoMessage {
|
||||
opts := descopts.Field.ProtoReflect().New()
|
||||
if fd.L1.IsWeak {
|
||||
opts.Set(opts.Descriptor().Fields().ByName("weak"), protoreflect.ValueOfBool(true))
|
||||
}
|
||||
if fd.L1.HasPacked {
|
||||
opts.Set(opts.Descriptor().Fields().ByName("packed"), protoreflect.ValueOfBool(fd.L1.IsPacked))
|
||||
if fd.L1.EditionFeatures.IsPacked {
|
||||
opts.Set(opts.Descriptor().Fields().ByName("packed"), protoreflect.ValueOfBool(fd.L1.EditionFeatures.IsPacked))
|
||||
}
|
||||
return opts.Interface()
|
||||
}
|
||||
@ -344,6 +347,7 @@ func aberrantAppendField(md *filedesc.Message, goType reflect.Type, tag, tagKey,
|
||||
md2.L0.ParentFile = md.L0.ParentFile
|
||||
md2.L0.Parent = md
|
||||
md2.L0.Index = n
|
||||
md2.L1.EditionFeatures = md.L1.EditionFeatures
|
||||
|
||||
md2.L1.IsMapEntry = true
|
||||
md2.L2.Options = func() protoreflect.ProtoMessage {
|
||||
@ -563,6 +567,6 @@ func (m aberrantMessage) IsValid() bool {
|
||||
func (m aberrantMessage) ProtoMethods() *protoiface.Methods {
|
||||
return aberrantProtoMethods
|
||||
}
|
||||
func (m aberrantMessage) protoUnwrap() interface{} {
|
||||
func (m aberrantMessage) protoUnwrap() any {
|
||||
return m.v.Interface()
|
||||
}
|
||||
|
12
vendor/google.golang.org/protobuf/internal/impl/message.go
generated
vendored
12
vendor/google.golang.org/protobuf/internal/impl/message.go
generated
vendored
@ -30,12 +30,12 @@ type MessageInfo struct {
|
||||
// Desc is the underlying message descriptor type and must be populated.
|
||||
Desc protoreflect.MessageDescriptor
|
||||
|
||||
// Exporter must be provided in a purego environment in order to provide
|
||||
// access to unexported fields.
|
||||
// Deprecated: Exporter will be removed the next time we bump
|
||||
// protoimpl.GenVersion. See https://github.com/golang/protobuf/issues/1640
|
||||
Exporter exporter
|
||||
|
||||
// OneofWrappers is list of pointers to oneof wrapper struct types.
|
||||
OneofWrappers []interface{}
|
||||
OneofWrappers []any
|
||||
|
||||
initMu sync.Mutex // protects all unexported fields
|
||||
initDone uint32
|
||||
@ -47,7 +47,7 @@ type MessageInfo struct {
|
||||
// exporter is a function that returns a reference to the ith field of v,
|
||||
// where v is a pointer to a struct. It returns nil if it does not support
|
||||
// exporting the requested field (e.g., already exported).
|
||||
type exporter func(v interface{}, i int) interface{}
|
||||
type exporter func(v any, i int) any
|
||||
|
||||
// getMessageInfo returns the MessageInfo for any message type that
|
||||
// is generated by our implementation of protoc-gen-go (for v2 and on).
|
||||
@ -201,7 +201,7 @@ fieldLoop:
|
||||
}
|
||||
for _, fn := range methods {
|
||||
for _, v := range fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))}) {
|
||||
if vs, ok := v.Interface().([]interface{}); ok {
|
||||
if vs, ok := v.Interface().([]any); ok {
|
||||
oneofWrappers = vs
|
||||
}
|
||||
}
|
||||
@ -256,7 +256,7 @@ func (mi *MessageInfo) Message(i int) protoreflect.MessageType {
|
||||
|
||||
type mapEntryType struct {
|
||||
desc protoreflect.MessageDescriptor
|
||||
valType interface{} // zero value of enum or message type
|
||||
valType any // zero value of enum or message type
|
||||
}
|
||||
|
||||
func (mt mapEntryType) New() protoreflect.Message {
|
||||
|
45
vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
generated
vendored
45
vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
generated
vendored
@ -20,7 +20,7 @@ type reflectMessageInfo struct {
|
||||
// fieldTypes contains the zero value of an enum or message field.
|
||||
// For lists, it contains the element type.
|
||||
// For maps, it contains the entry value type.
|
||||
fieldTypes map[protoreflect.FieldNumber]interface{}
|
||||
fieldTypes map[protoreflect.FieldNumber]any
|
||||
|
||||
// denseFields is a subset of fields where:
|
||||
// 0 < fieldDesc.Number() < len(denseFields)
|
||||
@ -28,7 +28,7 @@ type reflectMessageInfo struct {
|
||||
denseFields []*fieldInfo
|
||||
|
||||
// rangeInfos is a list of all fields (not belonging to a oneof) and oneofs.
|
||||
rangeInfos []interface{} // either *fieldInfo or *oneofInfo
|
||||
rangeInfos []any // either *fieldInfo or *oneofInfo
|
||||
|
||||
getUnknown func(pointer) protoreflect.RawFields
|
||||
setUnknown func(pointer, protoreflect.RawFields)
|
||||
@ -224,7 +224,7 @@ func (mi *MessageInfo) makeFieldTypes(si structInfo) {
|
||||
}
|
||||
if ft != nil {
|
||||
if mi.fieldTypes == nil {
|
||||
mi.fieldTypes = make(map[protoreflect.FieldNumber]interface{})
|
||||
mi.fieldTypes = make(map[protoreflect.FieldNumber]any)
|
||||
}
|
||||
mi.fieldTypes[fd.Number()] = reflect.Zero(ft).Interface()
|
||||
}
|
||||
@ -247,39 +247,39 @@ func (m *extensionMap) Range(f func(protoreflect.FieldDescriptor, protoreflect.V
|
||||
}
|
||||
}
|
||||
}
|
||||
func (m *extensionMap) Has(xt protoreflect.ExtensionType) (ok bool) {
|
||||
func (m *extensionMap) Has(xd protoreflect.ExtensionTypeDescriptor) (ok bool) {
|
||||
if m == nil {
|
||||
return false
|
||||
}
|
||||
xd := xt.TypeDescriptor()
|
||||
x, ok := (*m)[int32(xd.Number())]
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
if x.isUnexpandedLazy() {
|
||||
// Avoid calling x.Value(), which triggers a lazy unmarshal.
|
||||
return true
|
||||
}
|
||||
switch {
|
||||
case xd.IsList():
|
||||
return x.Value().List().Len() > 0
|
||||
case xd.IsMap():
|
||||
return x.Value().Map().Len() > 0
|
||||
case xd.Message() != nil:
|
||||
return x.Value().Message().IsValid()
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (m *extensionMap) Clear(xt protoreflect.ExtensionType) {
|
||||
delete(*m, int32(xt.TypeDescriptor().Number()))
|
||||
func (m *extensionMap) Clear(xd protoreflect.ExtensionTypeDescriptor) {
|
||||
delete(*m, int32(xd.Number()))
|
||||
}
|
||||
func (m *extensionMap) Get(xt protoreflect.ExtensionType) protoreflect.Value {
|
||||
xd := xt.TypeDescriptor()
|
||||
func (m *extensionMap) Get(xd protoreflect.ExtensionTypeDescriptor) protoreflect.Value {
|
||||
if m != nil {
|
||||
if x, ok := (*m)[int32(xd.Number())]; ok {
|
||||
return x.Value()
|
||||
}
|
||||
}
|
||||
return xt.Zero()
|
||||
return xd.Type().Zero()
|
||||
}
|
||||
func (m *extensionMap) Set(xt protoreflect.ExtensionType, v protoreflect.Value) {
|
||||
xd := xt.TypeDescriptor()
|
||||
func (m *extensionMap) Set(xd protoreflect.ExtensionTypeDescriptor, v protoreflect.Value) {
|
||||
xt := xd.Type()
|
||||
isValid := true
|
||||
switch {
|
||||
case !xt.IsValidValue(v):
|
||||
@ -292,7 +292,7 @@ func (m *extensionMap) Set(xt protoreflect.ExtensionType, v protoreflect.Value)
|
||||
isValid = v.Message().IsValid()
|
||||
}
|
||||
if !isValid {
|
||||
panic(fmt.Sprintf("%v: assigning invalid value", xt.TypeDescriptor().FullName()))
|
||||
panic(fmt.Sprintf("%v: assigning invalid value", xd.FullName()))
|
||||
}
|
||||
|
||||
if *m == nil {
|
||||
@ -302,16 +302,15 @@ func (m *extensionMap) Set(xt protoreflect.ExtensionType, v protoreflect.Value)
|
||||
x.Set(xt, v)
|
||||
(*m)[int32(xd.Number())] = x
|
||||
}
|
||||
func (m *extensionMap) Mutable(xt protoreflect.ExtensionType) protoreflect.Value {
|
||||
xd := xt.TypeDescriptor()
|
||||
func (m *extensionMap) Mutable(xd protoreflect.ExtensionTypeDescriptor) protoreflect.Value {
|
||||
if xd.Kind() != protoreflect.MessageKind && xd.Kind() != protoreflect.GroupKind && !xd.IsList() && !xd.IsMap() {
|
||||
panic("invalid Mutable on field with non-composite type")
|
||||
}
|
||||
if x, ok := (*m)[int32(xd.Number())]; ok {
|
||||
return x.Value()
|
||||
}
|
||||
v := xt.New()
|
||||
m.Set(xt, v)
|
||||
v := xd.Type().New()
|
||||
m.Set(xd, v)
|
||||
return v
|
||||
}
|
||||
|
||||
@ -394,7 +393,7 @@ var (
|
||||
// MessageOf returns a reflective view over a message. The input must be a
|
||||
// pointer to a named Go struct. If the provided type has a ProtoReflect method,
|
||||
// it must be implemented by calling this method.
|
||||
func (mi *MessageInfo) MessageOf(m interface{}) protoreflect.Message {
|
||||
func (mi *MessageInfo) MessageOf(m any) protoreflect.Message {
|
||||
if reflect.TypeOf(m) != mi.GoReflectType {
|
||||
panic(fmt.Sprintf("type mismatch: got %T, want %v", m, mi.GoReflectType))
|
||||
}
|
||||
@ -422,13 +421,13 @@ func (m *messageIfaceWrapper) Reset() {
|
||||
func (m *messageIfaceWrapper) ProtoReflect() protoreflect.Message {
|
||||
return (*messageReflectWrapper)(m)
|
||||
}
|
||||
func (m *messageIfaceWrapper) protoUnwrap() interface{} {
|
||||
func (m *messageIfaceWrapper) protoUnwrap() any {
|
||||
return m.p.AsIfaceOf(m.mi.GoReflectType.Elem())
|
||||
}
|
||||
|
||||
// checkField verifies that the provided field descriptor is valid.
|
||||
// Exactly one of the returned values is populated.
|
||||
func (mi *MessageInfo) checkField(fd protoreflect.FieldDescriptor) (*fieldInfo, protoreflect.ExtensionType) {
|
||||
func (mi *MessageInfo) checkField(fd protoreflect.FieldDescriptor) (*fieldInfo, protoreflect.ExtensionTypeDescriptor) {
|
||||
var fi *fieldInfo
|
||||
if n := fd.Number(); 0 < n && int(n) < len(mi.denseFields) {
|
||||
fi = mi.denseFields[n]
|
||||
@ -457,7 +456,7 @@ func (mi *MessageInfo) checkField(fd protoreflect.FieldDescriptor) (*fieldInfo,
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("extension %v does not implement protoreflect.ExtensionTypeDescriptor", fd.FullName()))
|
||||
}
|
||||
return nil, xtd.Type()
|
||||
return nil, xtd
|
||||
}
|
||||
panic(fmt.Sprintf("field %v is invalid", fd.FullName()))
|
||||
}
|
||||
|
146
vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go
generated
vendored
146
vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go
generated
vendored
@ -23,12 +23,13 @@ func (m *messageState) New() protoreflect.Message {
|
||||
func (m *messageState) Interface() protoreflect.ProtoMessage {
|
||||
return m.protoUnwrap().(protoreflect.ProtoMessage)
|
||||
}
|
||||
func (m *messageState) protoUnwrap() interface{} {
|
||||
func (m *messageState) protoUnwrap() any {
|
||||
return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
|
||||
}
|
||||
func (m *messageState) ProtoMethods() *protoiface.Methods {
|
||||
m.messageInfo().init()
|
||||
return &m.messageInfo().methods
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
return &mi.methods
|
||||
}
|
||||
|
||||
// ProtoMessageInfo is a pseudo-internal API for allowing the v1 code
|
||||
@ -41,8 +42,9 @@ func (m *messageState) ProtoMessageInfo() *MessageInfo {
|
||||
}
|
||||
|
||||
func (m *messageState) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
||||
m.messageInfo().init()
|
||||
for _, ri := range m.messageInfo().rangeInfos {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
for _, ri := range mi.rangeInfos {
|
||||
switch ri := ri.(type) {
|
||||
case *fieldInfo:
|
||||
if ri.has(m.pointer()) {
|
||||
@ -52,77 +54,86 @@ func (m *messageState) Range(f func(protoreflect.FieldDescriptor, protoreflect.V
|
||||
}
|
||||
case *oneofInfo:
|
||||
if n := ri.which(m.pointer()); n > 0 {
|
||||
fi := m.messageInfo().fields[n]
|
||||
fi := mi.fields[n]
|
||||
if !f(fi.fieldDesc, fi.get(m.pointer())) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m.messageInfo().extensionMap(m.pointer()).Range(f)
|
||||
mi.extensionMap(m.pointer()).Range(f)
|
||||
}
|
||||
func (m *messageState) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.has(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Has(xt)
|
||||
return mi.extensionMap(m.pointer()).Has(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageState) Clear(fd protoreflect.FieldDescriptor) {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
fi.clear(m.pointer())
|
||||
} else {
|
||||
m.messageInfo().extensionMap(m.pointer()).Clear(xt)
|
||||
mi.extensionMap(m.pointer()).Clear(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageState) Get(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.get(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Get(xt)
|
||||
return mi.extensionMap(m.pointer()).Get(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageState) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
fi.set(m.pointer(), v)
|
||||
} else {
|
||||
m.messageInfo().extensionMap(m.pointer()).Set(xt, v)
|
||||
mi.extensionMap(m.pointer()).Set(xd, v)
|
||||
}
|
||||
}
|
||||
func (m *messageState) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.mutable(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Mutable(xt)
|
||||
return mi.extensionMap(m.pointer()).Mutable(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageState) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.newField()
|
||||
} else {
|
||||
return xt.New()
|
||||
return xd.Type().New()
|
||||
}
|
||||
}
|
||||
func (m *messageState) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||
m.messageInfo().init()
|
||||
if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if oi := mi.oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
return od.Fields().ByNumber(oi.which(m.pointer()))
|
||||
}
|
||||
panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m *messageState) GetUnknown() protoreflect.RawFields {
|
||||
m.messageInfo().init()
|
||||
return m.messageInfo().getUnknown(m.pointer())
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
return mi.getUnknown(m.pointer())
|
||||
}
|
||||
func (m *messageState) SetUnknown(b protoreflect.RawFields) {
|
||||
m.messageInfo().init()
|
||||
m.messageInfo().setUnknown(m.pointer(), b)
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
mi.setUnknown(m.pointer(), b)
|
||||
}
|
||||
func (m *messageState) IsValid() bool {
|
||||
return !m.pointer().IsNil()
|
||||
@ -143,12 +154,13 @@ func (m *messageReflectWrapper) Interface() protoreflect.ProtoMessage {
|
||||
}
|
||||
return (*messageIfaceWrapper)(m)
|
||||
}
|
||||
func (m *messageReflectWrapper) protoUnwrap() interface{} {
|
||||
func (m *messageReflectWrapper) protoUnwrap() any {
|
||||
return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
|
||||
}
|
||||
func (m *messageReflectWrapper) ProtoMethods() *protoiface.Methods {
|
||||
m.messageInfo().init()
|
||||
return &m.messageInfo().methods
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
return &mi.methods
|
||||
}
|
||||
|
||||
// ProtoMessageInfo is a pseudo-internal API for allowing the v1 code
|
||||
@ -161,8 +173,9 @@ func (m *messageReflectWrapper) ProtoMessageInfo() *MessageInfo {
|
||||
}
|
||||
|
||||
func (m *messageReflectWrapper) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
||||
m.messageInfo().init()
|
||||
for _, ri := range m.messageInfo().rangeInfos {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
for _, ri := range mi.rangeInfos {
|
||||
switch ri := ri.(type) {
|
||||
case *fieldInfo:
|
||||
if ri.has(m.pointer()) {
|
||||
@ -172,77 +185,86 @@ func (m *messageReflectWrapper) Range(f func(protoreflect.FieldDescriptor, proto
|
||||
}
|
||||
case *oneofInfo:
|
||||
if n := ri.which(m.pointer()); n > 0 {
|
||||
fi := m.messageInfo().fields[n]
|
||||
fi := mi.fields[n]
|
||||
if !f(fi.fieldDesc, fi.get(m.pointer())) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m.messageInfo().extensionMap(m.pointer()).Range(f)
|
||||
mi.extensionMap(m.pointer()).Range(f)
|
||||
}
|
||||
func (m *messageReflectWrapper) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.has(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Has(xt)
|
||||
return mi.extensionMap(m.pointer()).Has(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) Clear(fd protoreflect.FieldDescriptor) {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
fi.clear(m.pointer())
|
||||
} else {
|
||||
m.messageInfo().extensionMap(m.pointer()).Clear(xt)
|
||||
mi.extensionMap(m.pointer()).Clear(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) Get(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.get(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Get(xt)
|
||||
return mi.extensionMap(m.pointer()).Get(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
fi.set(m.pointer(), v)
|
||||
} else {
|
||||
m.messageInfo().extensionMap(m.pointer()).Set(xt, v)
|
||||
mi.extensionMap(m.pointer()).Set(xd, v)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.mutable(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Mutable(xt)
|
||||
return mi.extensionMap(m.pointer()).Mutable(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.newField()
|
||||
} else {
|
||||
return xt.New()
|
||||
return xd.Type().New()
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||
m.messageInfo().init()
|
||||
if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if oi := mi.oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
return od.Fields().ByNumber(oi.which(m.pointer()))
|
||||
}
|
||||
panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m *messageReflectWrapper) GetUnknown() protoreflect.RawFields {
|
||||
m.messageInfo().init()
|
||||
return m.messageInfo().getUnknown(m.pointer())
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
return mi.getUnknown(m.pointer())
|
||||
}
|
||||
func (m *messageReflectWrapper) SetUnknown(b protoreflect.RawFields) {
|
||||
m.messageInfo().init()
|
||||
m.messageInfo().setUnknown(m.pointer(), b)
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
mi.setUnknown(m.pointer(), b)
|
||||
}
|
||||
func (m *messageReflectWrapper) IsValid() bool {
|
||||
return !m.pointer().IsNil()
|
||||
|
215
vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go
generated
vendored
215
vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go
generated
vendored
@ -1,215 +0,0 @@
|
||||
// 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.
|
||||
|
||||
//go:build purego || appengine
|
||||
// +build purego appengine
|
||||
|
||||
package impl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const UnsafeEnabled = false
|
||||
|
||||
// Pointer is an opaque pointer type.
|
||||
type Pointer interface{}
|
||||
|
||||
// offset represents the offset to a struct field, accessible from a pointer.
|
||||
// The offset is the field index into a struct.
|
||||
type offset struct {
|
||||
index int
|
||||
export exporter
|
||||
}
|
||||
|
||||
// offsetOf returns a field offset for the struct field.
|
||||
func offsetOf(f reflect.StructField, x exporter) offset {
|
||||
if len(f.Index) != 1 {
|
||||
panic("embedded structs are not supported")
|
||||
}
|
||||
if f.PkgPath == "" {
|
||||
return offset{index: f.Index[0]} // field is already exported
|
||||
}
|
||||
if x == nil {
|
||||
panic("exporter must be provided for unexported field")
|
||||
}
|
||||
return offset{index: f.Index[0], export: x}
|
||||
}
|
||||
|
||||
// IsValid reports whether the offset is valid.
|
||||
func (f offset) IsValid() bool { return f.index >= 0 }
|
||||
|
||||
// invalidOffset is an invalid field offset.
|
||||
var invalidOffset = offset{index: -1}
|
||||
|
||||
// zeroOffset is a noop when calling pointer.Apply.
|
||||
var zeroOffset = offset{index: 0}
|
||||
|
||||
// pointer is an abstract representation of a pointer to a struct or field.
|
||||
type pointer struct{ v reflect.Value }
|
||||
|
||||
// pointerOf returns p as a pointer.
|
||||
func pointerOf(p Pointer) pointer {
|
||||
return pointerOfIface(p)
|
||||
}
|
||||
|
||||
// pointerOfValue returns v as a pointer.
|
||||
func pointerOfValue(v reflect.Value) pointer {
|
||||
return pointer{v: v}
|
||||
}
|
||||
|
||||
// pointerOfIface returns the pointer portion of an interface.
|
||||
func pointerOfIface(v interface{}) pointer {
|
||||
return pointer{v: reflect.ValueOf(v)}
|
||||
}
|
||||
|
||||
// IsNil reports whether the pointer is nil.
|
||||
func (p pointer) IsNil() bool {
|
||||
return p.v.IsNil()
|
||||
}
|
||||
|
||||
// Apply adds an offset to the pointer to derive a new pointer
|
||||
// to a specified field. The current pointer must be pointing at a struct.
|
||||
func (p pointer) Apply(f offset) pointer {
|
||||
if f.export != nil {
|
||||
if v := reflect.ValueOf(f.export(p.v.Interface(), f.index)); v.IsValid() {
|
||||
return pointer{v: v}
|
||||
}
|
||||
}
|
||||
return pointer{v: p.v.Elem().Field(f.index).Addr()}
|
||||
}
|
||||
|
||||
// AsValueOf treats p as a pointer to an object of type t and returns the value.
|
||||
// It is equivalent to reflect.ValueOf(p.AsIfaceOf(t))
|
||||
func (p pointer) AsValueOf(t reflect.Type) reflect.Value {
|
||||
if got := p.v.Type().Elem(); got != t {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", got, t))
|
||||
}
|
||||
return p.v
|
||||
}
|
||||
|
||||
// AsIfaceOf treats p as a pointer to an object of type t and returns the value.
|
||||
// It is equivalent to p.AsValueOf(t).Interface()
|
||||
func (p pointer) AsIfaceOf(t reflect.Type) interface{} {
|
||||
return p.AsValueOf(t).Interface()
|
||||
}
|
||||
|
||||
func (p pointer) Bool() *bool { return p.v.Interface().(*bool) }
|
||||
func (p pointer) BoolPtr() **bool { return p.v.Interface().(**bool) }
|
||||
func (p pointer) BoolSlice() *[]bool { return p.v.Interface().(*[]bool) }
|
||||
func (p pointer) Int32() *int32 { return p.v.Interface().(*int32) }
|
||||
func (p pointer) Int32Ptr() **int32 { return p.v.Interface().(**int32) }
|
||||
func (p pointer) Int32Slice() *[]int32 { return p.v.Interface().(*[]int32) }
|
||||
func (p pointer) Int64() *int64 { return p.v.Interface().(*int64) }
|
||||
func (p pointer) Int64Ptr() **int64 { return p.v.Interface().(**int64) }
|
||||
func (p pointer) Int64Slice() *[]int64 { return p.v.Interface().(*[]int64) }
|
||||
func (p pointer) Uint32() *uint32 { return p.v.Interface().(*uint32) }
|
||||
func (p pointer) Uint32Ptr() **uint32 { return p.v.Interface().(**uint32) }
|
||||
func (p pointer) Uint32Slice() *[]uint32 { return p.v.Interface().(*[]uint32) }
|
||||
func (p pointer) Uint64() *uint64 { return p.v.Interface().(*uint64) }
|
||||
func (p pointer) Uint64Ptr() **uint64 { return p.v.Interface().(**uint64) }
|
||||
func (p pointer) Uint64Slice() *[]uint64 { return p.v.Interface().(*[]uint64) }
|
||||
func (p pointer) Float32() *float32 { return p.v.Interface().(*float32) }
|
||||
func (p pointer) Float32Ptr() **float32 { return p.v.Interface().(**float32) }
|
||||
func (p pointer) Float32Slice() *[]float32 { return p.v.Interface().(*[]float32) }
|
||||
func (p pointer) Float64() *float64 { return p.v.Interface().(*float64) }
|
||||
func (p pointer) Float64Ptr() **float64 { return p.v.Interface().(**float64) }
|
||||
func (p pointer) Float64Slice() *[]float64 { return p.v.Interface().(*[]float64) }
|
||||
func (p pointer) String() *string { return p.v.Interface().(*string) }
|
||||
func (p pointer) StringPtr() **string { return p.v.Interface().(**string) }
|
||||
func (p pointer) StringSlice() *[]string { return p.v.Interface().(*[]string) }
|
||||
func (p pointer) Bytes() *[]byte { return p.v.Interface().(*[]byte) }
|
||||
func (p pointer) BytesPtr() **[]byte { return p.v.Interface().(**[]byte) }
|
||||
func (p pointer) BytesSlice() *[][]byte { return p.v.Interface().(*[][]byte) }
|
||||
func (p pointer) WeakFields() *weakFields { return (*weakFields)(p.v.Interface().(*WeakFields)) }
|
||||
func (p pointer) Extensions() *map[int32]ExtensionField {
|
||||
return p.v.Interface().(*map[int32]ExtensionField)
|
||||
}
|
||||
|
||||
func (p pointer) Elem() pointer {
|
||||
return pointer{v: p.v.Elem()}
|
||||
}
|
||||
|
||||
// PointerSlice copies []*T from p as a new []pointer.
|
||||
// This behavior differs from the implementation in pointer_unsafe.go.
|
||||
func (p pointer) PointerSlice() []pointer {
|
||||
// TODO: reconsider this
|
||||
if p.v.IsNil() {
|
||||
return nil
|
||||
}
|
||||
n := p.v.Elem().Len()
|
||||
s := make([]pointer, n)
|
||||
for i := 0; i < n; i++ {
|
||||
s[i] = pointer{v: p.v.Elem().Index(i)}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// AppendPointerSlice appends v to p, which must be a []*T.
|
||||
func (p pointer) AppendPointerSlice(v pointer) {
|
||||
sp := p.v.Elem()
|
||||
sp.Set(reflect.Append(sp, v.v))
|
||||
}
|
||||
|
||||
// SetPointer sets *p to v.
|
||||
func (p pointer) SetPointer(v pointer) {
|
||||
p.v.Elem().Set(v.v)
|
||||
}
|
||||
|
||||
func growSlice(p pointer, addCap int) {
|
||||
// TODO: Once we only support Go 1.20 and newer, use reflect.Grow.
|
||||
in := p.v.Elem()
|
||||
out := reflect.MakeSlice(in.Type(), in.Len(), in.Len()+addCap)
|
||||
reflect.Copy(out, in)
|
||||
p.v.Elem().Set(out)
|
||||
}
|
||||
|
||||
func (p pointer) growBoolSlice(addCap int) {
|
||||
growSlice(p, addCap)
|
||||
}
|
||||
|
||||
func (p pointer) growInt32Slice(addCap int) {
|
||||
growSlice(p, addCap)
|
||||
}
|
||||
|
||||
func (p pointer) growUint32Slice(addCap int) {
|
||||
growSlice(p, addCap)
|
||||
}
|
||||
|
||||
func (p pointer) growInt64Slice(addCap int) {
|
||||
growSlice(p, addCap)
|
||||
}
|
||||
|
||||
func (p pointer) growUint64Slice(addCap int) {
|
||||
growSlice(p, addCap)
|
||||
}
|
||||
|
||||
func (p pointer) growFloat64Slice(addCap int) {
|
||||
growSlice(p, addCap)
|
||||
}
|
||||
|
||||
func (p pointer) growFloat32Slice(addCap int) {
|
||||
growSlice(p, addCap)
|
||||
}
|
||||
|
||||
func (Export) MessageStateOf(p Pointer) *messageState { panic("not supported") }
|
||||
func (ms *messageState) pointer() pointer { panic("not supported") }
|
||||
func (ms *messageState) messageInfo() *MessageInfo { panic("not supported") }
|
||||
func (ms *messageState) LoadMessageInfo() *MessageInfo { panic("not supported") }
|
||||
func (ms *messageState) StoreMessageInfo(mi *MessageInfo) { panic("not supported") }
|
||||
|
||||
type atomicNilMessage struct {
|
||||
once sync.Once
|
||||
m messageReflectWrapper
|
||||
}
|
||||
|
||||
func (m *atomicNilMessage) Init(mi *MessageInfo) *messageReflectWrapper {
|
||||
m.once.Do(func() {
|
||||
m.m.p = pointerOfIface(reflect.Zero(mi.GoReflectType).Interface())
|
||||
m.m.mi = mi
|
||||
})
|
||||
return &m.m
|
||||
}
|
7
vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
generated
vendored
7
vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
generated
vendored
@ -2,9 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !purego && !appengine
|
||||
// +build !purego,!appengine
|
||||
|
||||
package impl
|
||||
|
||||
import (
|
||||
@ -50,7 +47,7 @@ func pointerOfValue(v reflect.Value) pointer {
|
||||
}
|
||||
|
||||
// pointerOfIface returns the pointer portion of an interface.
|
||||
func pointerOfIface(v interface{}) pointer {
|
||||
func pointerOfIface(v any) pointer {
|
||||
type ifaceHeader struct {
|
||||
Type unsafe.Pointer
|
||||
Data unsafe.Pointer
|
||||
@ -80,7 +77,7 @@ func (p pointer) AsValueOf(t reflect.Type) reflect.Value {
|
||||
|
||||
// AsIfaceOf treats p as a pointer to an object of type t and returns the value.
|
||||
// It is equivalent to p.AsValueOf(t).Interface()
|
||||
func (p pointer) AsIfaceOf(t reflect.Type) interface{} {
|
||||
func (p pointer) AsIfaceOf(t reflect.Type) any {
|
||||
// TODO: Use tricky unsafe magic to directly create ifaceHeader.
|
||||
return p.AsValueOf(t).Interface()
|
||||
}
|
||||
|
Reference in New Issue
Block a user