mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
rebase: bump google.golang.org/protobuf from 1.34.2 to 1.35.1
Bumps google.golang.org/protobuf from 1.34.2 to 1.35.1. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
mergify[bot]
parent
5a65f9e615
commit
d581e820f3
11
vendor/google.golang.org/protobuf/internal/impl/codec_extension.go
generated
vendored
11
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 {
|
||||
@ -158,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)
|
||||
}
|
||||
@ -174,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 {
|
||||
|
3
vendor/google.golang.org/protobuf/internal/impl/codec_field.go
generated
vendored
3
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
|
||||
}
|
||||
|
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.
|
||||
|
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.
|
||||
|
2
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
@ -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/encode.go
generated
vendored
2
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"
|
||||
)
|
||||
|
||||
|
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
|
||||
}
|
1
vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
generated
vendored
1
vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
generated
vendored
@ -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/message.go
generated
vendored
4
vendor/google.golang.org/protobuf/internal/impl/message.go
generated
vendored
@ -30,8 +30,8 @@ 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.
|
||||
|
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 any
|
||||
|
||||
// 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 any) 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) any {
|
||||
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
|
||||
}
|
3
vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
generated
vendored
3
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 (
|
||||
|
Reference in New Issue
Block a user