Update module prometheus/client_golang to v1.7.0 (#589)
Update module prometheus/client_golang to v1.7.0 Reviewed-on: https://kolaente.dev/vikunja/api/pulls/589
This commit is contained in:
2
vendor/google.golang.org/protobuf/internal/descfmt/stringer.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/descfmt/stringer.go
generated
vendored
@ -106,7 +106,7 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string {
|
||||
var descriptorAccessors = map[reflect.Type][]string{
|
||||
reflect.TypeOf((*pref.FileDescriptor)(nil)).Elem(): {"Path", "Package", "Imports", "Messages", "Enums", "Extensions", "Services"},
|
||||
reflect.TypeOf((*pref.MessageDescriptor)(nil)).Elem(): {"IsMapEntry", "Fields", "Oneofs", "ReservedNames", "ReservedRanges", "RequiredNumbers", "ExtensionRanges", "Messages", "Enums", "Extensions"},
|
||||
reflect.TypeOf((*pref.FieldDescriptor)(nil)).Elem(): {"Number", "Cardinality", "Kind", "HasJSONName", "JSONName", "IsPacked", "IsExtension", "IsWeak", "IsList", "IsMap", "MapKey", "MapValue", "HasDefault", "Default", "ContainingOneof", "ContainingMessage", "Message", "Enum"},
|
||||
reflect.TypeOf((*pref.FieldDescriptor)(nil)).Elem(): {"Number", "Cardinality", "Kind", "HasJSONName", "JSONName", "HasPresence", "IsExtension", "IsPacked", "IsWeak", "IsList", "IsMap", "MapKey", "MapValue", "HasDefault", "Default", "ContainingOneof", "ContainingMessage", "Message", "Enum"},
|
||||
reflect.TypeOf((*pref.OneofDescriptor)(nil)).Elem(): {"Fields"}, // not directly used; must keep in sync with formatDescOpt
|
||||
reflect.TypeOf((*pref.EnumDescriptor)(nil)).Elem(): {"Values", "ReservedNames", "ReservedRanges"},
|
||||
reflect.TypeOf((*pref.EnumValueDescriptor)(nil)).Elem(): {"Number"},
|
||||
|
21
vendor/google.golang.org/protobuf/internal/fieldnum/descriptor_gen.go
generated
vendored
21
vendor/google.golang.org/protobuf/internal/fieldnum/descriptor_gen.go
generated
vendored
@ -61,16 +61,17 @@ const (
|
||||
|
||||
// Field numbers for google.protobuf.FieldDescriptorProto.
|
||||
const (
|
||||
FieldDescriptorProto_Name = 1 // optional string
|
||||
FieldDescriptorProto_Number = 3 // optional int32
|
||||
FieldDescriptorProto_Label = 4 // optional google.protobuf.FieldDescriptorProto.Label
|
||||
FieldDescriptorProto_Type = 5 // optional google.protobuf.FieldDescriptorProto.Type
|
||||
FieldDescriptorProto_TypeName = 6 // optional string
|
||||
FieldDescriptorProto_Extendee = 2 // optional string
|
||||
FieldDescriptorProto_DefaultValue = 7 // optional string
|
||||
FieldDescriptorProto_OneofIndex = 9 // optional int32
|
||||
FieldDescriptorProto_JsonName = 10 // optional string
|
||||
FieldDescriptorProto_Options = 8 // optional google.protobuf.FieldOptions
|
||||
FieldDescriptorProto_Name = 1 // optional string
|
||||
FieldDescriptorProto_Number = 3 // optional int32
|
||||
FieldDescriptorProto_Label = 4 // optional google.protobuf.FieldDescriptorProto.Label
|
||||
FieldDescriptorProto_Type = 5 // optional google.protobuf.FieldDescriptorProto.Type
|
||||
FieldDescriptorProto_TypeName = 6 // optional string
|
||||
FieldDescriptorProto_Extendee = 2 // optional string
|
||||
FieldDescriptorProto_DefaultValue = 7 // optional string
|
||||
FieldDescriptorProto_OneofIndex = 9 // optional int32
|
||||
FieldDescriptorProto_JsonName = 10 // optional string
|
||||
FieldDescriptorProto_Options = 8 // optional google.protobuf.FieldOptions
|
||||
FieldDescriptorProto_Proto3Optional = 17 // optional bool
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.OneofDescriptorProto.
|
||||
|
4
vendor/google.golang.org/protobuf/internal/fieldsort/fieldsort.go
generated
vendored
4
vendor/google.golang.org/protobuf/internal/fieldsort/fieldsort.go
generated
vendored
@ -30,9 +30,9 @@ func Less(a, b protoreflect.FieldDescriptor) bool {
|
||||
return a.Number() < b.Number()
|
||||
}
|
||||
return oa.Index() < ob.Index()
|
||||
case oa != nil:
|
||||
case oa != nil && !oa.IsSynthetic():
|
||||
return false
|
||||
case ob != nil:
|
||||
case ob != nil && !ob.IsSynthetic():
|
||||
return true
|
||||
default:
|
||||
return a.Number() < b.Number()
|
||||
|
69
vendor/google.golang.org/protobuf/internal/filedesc/desc.go
generated
vendored
69
vendor/google.golang.org/protobuf/internal/filedesc/desc.go
generated
vendored
@ -77,7 +77,7 @@ func (fd *File) Enums() pref.EnumDescriptors { return &fd.L1.Enums }
|
||||
func (fd *File) Messages() pref.MessageDescriptors { return &fd.L1.Messages }
|
||||
func (fd *File) Extensions() pref.ExtensionDescriptors { return &fd.L1.Extensions }
|
||||
func (fd *File) Services() pref.ServiceDescriptors { return &fd.L1.Services }
|
||||
func (fd *File) SourceLocations() pref.SourceLocations { return &fd.L2.Locations }
|
||||
func (fd *File) SourceLocations() pref.SourceLocations { return &fd.lazyInit().Locations }
|
||||
func (fd *File) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, fd) }
|
||||
func (fd *File) ProtoType(pref.FileDescriptor) {}
|
||||
func (fd *File) ProtoInternal(pragma.DoNotImplement) {}
|
||||
@ -202,20 +202,21 @@ type (
|
||||
L1 FieldL1
|
||||
}
|
||||
FieldL1 struct {
|
||||
Options func() pref.ProtoMessage
|
||||
Number pref.FieldNumber
|
||||
Cardinality pref.Cardinality // must be consistent with Message.RequiredNumbers
|
||||
Kind pref.Kind
|
||||
JSONName jsonName
|
||||
IsWeak bool // promoted from google.protobuf.FieldOptions
|
||||
HasPacked bool // promoted from google.protobuf.FieldOptions
|
||||
IsPacked bool // promoted from google.protobuf.FieldOptions
|
||||
HasEnforceUTF8 bool // promoted from google.protobuf.FieldOptions
|
||||
EnforceUTF8 bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
ContainingOneof pref.OneofDescriptor // must be consistent with Message.Oneofs.Fields
|
||||
Enum pref.EnumDescriptor
|
||||
Message pref.MessageDescriptor
|
||||
Options func() pref.ProtoMessage
|
||||
Number pref.FieldNumber
|
||||
Cardinality pref.Cardinality // must be consistent with Message.RequiredNumbers
|
||||
Kind pref.Kind
|
||||
JSONName jsonName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsWeak bool // promoted from google.protobuf.FieldOptions
|
||||
HasPacked bool // promoted from google.protobuf.FieldOptions
|
||||
IsPacked bool // promoted from google.protobuf.FieldOptions
|
||||
HasEnforceUTF8 bool // promoted from google.protobuf.FieldOptions
|
||||
EnforceUTF8 bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
ContainingOneof pref.OneofDescriptor // must be consistent with Message.Oneofs.Fields
|
||||
Enum pref.EnumDescriptor
|
||||
Message pref.MessageDescriptor
|
||||
}
|
||||
|
||||
Oneof struct {
|
||||
@ -277,6 +278,12 @@ func (fd *Field) Cardinality() pref.Cardinality { return fd.L1.Cardinality }
|
||||
func (fd *Field) Kind() pref.Kind { return fd.L1.Kind }
|
||||
func (fd *Field) HasJSONName() bool { return fd.L1.JSONName.has }
|
||||
func (fd *Field) JSONName() string { return fd.L1.JSONName.get(fd) }
|
||||
func (fd *Field) HasPresence() bool {
|
||||
return fd.L1.Cardinality != pref.Repeated && (fd.L0.ParentFile.L1.Syntax == pref.Proto2 || fd.L1.Message != nil || fd.L1.ContainingOneof != nil)
|
||||
}
|
||||
func (fd *Field) HasOptionalKeyword() bool {
|
||||
return (fd.L0.ParentFile.L1.Syntax == pref.Proto2 && fd.L1.Cardinality == pref.Optional && fd.L1.ContainingOneof == nil) || fd.L1.IsProto3Optional
|
||||
}
|
||||
func (fd *Field) IsPacked() bool {
|
||||
if !fd.L1.HasPacked && fd.L0.ParentFile.L1.Syntax != pref.Proto2 && fd.L1.Cardinality == pref.Repeated {
|
||||
switch fd.L1.Kind {
|
||||
@ -338,6 +345,9 @@ func (fd *Field) EnforceUTF8() bool {
|
||||
return fd.L0.ParentFile.L1.Syntax == pref.Proto3
|
||||
}
|
||||
|
||||
func (od *Oneof) IsSynthetic() bool {
|
||||
return od.L0.ParentFile.L1.Syntax == pref.Proto3 && len(od.L1.Fields.List) == 1 && od.L1.Fields.List[0].HasOptionalKeyword()
|
||||
}
|
||||
func (od *Oneof) Options() pref.ProtoMessage {
|
||||
if f := od.L1.Options; f != nil {
|
||||
return f()
|
||||
@ -361,12 +371,13 @@ type (
|
||||
Kind pref.Kind
|
||||
}
|
||||
ExtensionL2 struct {
|
||||
Options func() pref.ProtoMessage
|
||||
JSONName jsonName
|
||||
IsPacked bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
Enum pref.EnumDescriptor
|
||||
Message pref.MessageDescriptor
|
||||
Options func() pref.ProtoMessage
|
||||
JSONName jsonName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsPacked bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
Enum pref.EnumDescriptor
|
||||
Message pref.MessageDescriptor
|
||||
}
|
||||
)
|
||||
|
||||
@ -376,11 +387,15 @@ func (xd *Extension) Options() pref.ProtoMessage {
|
||||
}
|
||||
return descopts.Field
|
||||
}
|
||||
func (xd *Extension) Number() pref.FieldNumber { return xd.L1.Number }
|
||||
func (xd *Extension) Cardinality() pref.Cardinality { return xd.L1.Cardinality }
|
||||
func (xd *Extension) Kind() pref.Kind { return xd.L1.Kind }
|
||||
func (xd *Extension) HasJSONName() bool { return xd.lazyInit().JSONName.has }
|
||||
func (xd *Extension) JSONName() string { return xd.lazyInit().JSONName.get(xd) }
|
||||
func (xd *Extension) Number() pref.FieldNumber { return xd.L1.Number }
|
||||
func (xd *Extension) Cardinality() pref.Cardinality { return xd.L1.Cardinality }
|
||||
func (xd *Extension) Kind() pref.Kind { return xd.L1.Kind }
|
||||
func (xd *Extension) HasJSONName() bool { return xd.lazyInit().JSONName.has }
|
||||
func (xd *Extension) JSONName() string { return xd.lazyInit().JSONName.get(xd) }
|
||||
func (xd *Extension) HasPresence() bool { return xd.L1.Cardinality != pref.Repeated }
|
||||
func (xd *Extension) HasOptionalKeyword() bool {
|
||||
return (xd.L0.ParentFile.L1.Syntax == pref.Proto2 && xd.L1.Cardinality == pref.Optional) || xd.lazyInit().IsProto3Optional
|
||||
}
|
||||
func (xd *Extension) IsPacked() bool { return xd.lazyInit().IsPacked }
|
||||
func (xd *Extension) IsExtension() bool { return true }
|
||||
func (xd *Extension) IsWeak() bool { return false }
|
||||
@ -592,7 +607,7 @@ func (dv *defaultValue) get(fd pref.FieldDescriptor) pref.Value {
|
||||
// TODO: Avoid panic if we're running with the race detector
|
||||
// and instead spawn a goroutine that periodically resets
|
||||
// this value back to the original to induce a race.
|
||||
panic("detected mutation on the default bytes")
|
||||
panic(fmt.Sprintf("detected mutation on the default bytes for %v", fd.FullName()))
|
||||
}
|
||||
return dv.val
|
||||
}
|
||||
|
9
vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
generated
vendored
9
vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
generated
vendored
@ -441,6 +441,8 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Des
|
||||
panic("oneof type already set")
|
||||
}
|
||||
fd.L1.ContainingOneof = od
|
||||
case fieldnum.FieldDescriptorProto_Proto3Optional:
|
||||
fd.L1.IsProto3Optional = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
@ -537,6 +539,13 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch typ {
|
||||
case protowire.VarintType:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldDescriptorProto_Proto3Optional:
|
||||
xd.L2.IsProto3Optional = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
|
40
vendor/google.golang.org/protobuf/internal/impl/codec_gen.go
generated
vendored
40
vendor/google.golang.org/protobuf/internal/impl/codec_gen.go
generated
vendored
@ -5078,6 +5078,46 @@ var coderStringPtr = pointerCoderFuncs{
|
||||
merge: mergeStringPtr,
|
||||
}
|
||||
|
||||
// appendStringPtrValidateUTF8 wire encodes a *string pointer as a String.
|
||||
// It panics if the pointer is nil.
|
||||
func appendStringPtrValidateUTF8(b []byte, p pointer, f *coderFieldInfo, _ marshalOptions) ([]byte, error) {
|
||||
v := **p.StringPtr()
|
||||
b = protowire.AppendVarint(b, f.wiretag)
|
||||
b = protowire.AppendString(b, v)
|
||||
if !utf8.ValidString(v) {
|
||||
return b, errInvalidUTF8{}
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// consumeStringPtrValidateUTF8 wire decodes a *string pointer as a String.
|
||||
func consumeStringPtrValidateUTF8(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, _ unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
if wtyp != protowire.BytesType {
|
||||
return out, errUnknown
|
||||
}
|
||||
v, n := protowire.ConsumeString(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
}
|
||||
if !utf8.ValidString(v) {
|
||||
return out, errInvalidUTF8{}
|
||||
}
|
||||
vp := p.StringPtr()
|
||||
if *vp == nil {
|
||||
*vp = new(string)
|
||||
}
|
||||
**vp = v
|
||||
out.n = n
|
||||
return out, nil
|
||||
}
|
||||
|
||||
var coderStringPtrValidateUTF8 = pointerCoderFuncs{
|
||||
size: sizeStringPtr,
|
||||
marshal: appendStringPtrValidateUTF8,
|
||||
unmarshal: consumeStringPtrValidateUTF8,
|
||||
merge: mergeStringPtr,
|
||||
}
|
||||
|
||||
// sizeStringSlice returns the size of wire encoding a []string pointer as a repeated String.
|
||||
func sizeStringSlice(p pointer, f *coderFieldInfo, _ marshalOptions) (size int) {
|
||||
s := *p.StringSlice()
|
||||
|
20
vendor/google.golang.org/protobuf/internal/impl/codec_message.go
generated
vendored
20
vendor/google.golang.org/protobuf/internal/impl/codec_message.go
generated
vendored
@ -53,11 +53,13 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
|
||||
mi.coderFields = make(map[protowire.Number]*coderFieldInfo)
|
||||
fields := mi.Desc.Fields()
|
||||
preallocFields := make([]coderFieldInfo, fields.Len())
|
||||
for i := 0; i < fields.Len(); i++ {
|
||||
fd := fields.Get(i)
|
||||
|
||||
fs := si.fieldsByNumber[fd.Number()]
|
||||
if fd.ContainingOneof() != nil {
|
||||
isOneof := fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic()
|
||||
if isOneof {
|
||||
fs = si.oneofsByName[fd.ContainingOneof().Name()]
|
||||
}
|
||||
ft := fs.Type
|
||||
@ -71,7 +73,7 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
var funcs pointerCoderFuncs
|
||||
var childMessage *MessageInfo
|
||||
switch {
|
||||
case fd.ContainingOneof() != nil:
|
||||
case isOneof:
|
||||
fieldOffset = offsetOf(fs, mi.Exporter)
|
||||
case fd.IsWeak():
|
||||
fieldOffset = si.weakOffset
|
||||
@ -80,7 +82,8 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
fieldOffset = offsetOf(fs, mi.Exporter)
|
||||
childMessage, funcs = fieldCoder(fd, ft)
|
||||
}
|
||||
cf := &coderFieldInfo{
|
||||
cf := &preallocFields[i]
|
||||
*cf = coderFieldInfo{
|
||||
num: fd.Number(),
|
||||
offset: fieldOffset,
|
||||
wiretag: wiretag,
|
||||
@ -89,17 +92,16 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
funcs: funcs,
|
||||
mi: childMessage,
|
||||
validation: newFieldValidationInfo(mi, si, fd, ft),
|
||||
isPointer: (fd.Cardinality() == pref.Repeated ||
|
||||
fd.Kind() == pref.MessageKind ||
|
||||
fd.Kind() == pref.GroupKind ||
|
||||
fd.Syntax() != pref.Proto3),
|
||||
isPointer: fd.Cardinality() == pref.Repeated || fd.HasPresence(),
|
||||
isRequired: fd.Cardinality() == pref.Required,
|
||||
}
|
||||
mi.orderedCoderFields = append(mi.orderedCoderFields, cf)
|
||||
mi.coderFields[cf.num] = cf
|
||||
}
|
||||
for i, oneofs := 0, mi.Desc.Oneofs(); i < oneofs.Len(); i++ {
|
||||
mi.initOneofFieldCoders(oneofs.Get(i), si)
|
||||
if od := oneofs.Get(i); !od.IsSynthetic() {
|
||||
mi.initOneofFieldCoders(od, si)
|
||||
}
|
||||
}
|
||||
if messageset.IsMessageSet(mi.Desc) {
|
||||
if !mi.extensionOffset.IsValid() {
|
||||
@ -123,7 +125,7 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
}
|
||||
mi.denseCoderFields = make([]*coderFieldInfo, maxDense+1)
|
||||
for _, cf := range mi.orderedCoderFields {
|
||||
if int(cf.num) > len(mi.denseCoderFields) {
|
||||
if int(cf.num) >= len(mi.denseCoderFields) {
|
||||
break
|
||||
}
|
||||
mi.denseCoderFields[cf.num] = cf
|
||||
|
3
vendor/google.golang.org/protobuf/internal/impl/codec_tables.go
generated
vendored
3
vendor/google.golang.org/protobuf/internal/impl/codec_tables.go
generated
vendored
@ -338,6 +338,9 @@ func fieldCoder(fd pref.FieldDescriptor, ft reflect.Type) (*MessageInfo, pointer
|
||||
return nil, coderDoublePtr
|
||||
}
|
||||
case pref.StringKind:
|
||||
if ft.Kind() == reflect.String && strs.EnforceUTF8(fd) {
|
||||
return nil, coderStringPtrValidateUTF8
|
||||
}
|
||||
if ft.Kind() == reflect.String {
|
||||
return nil, coderStringPtr
|
||||
}
|
||||
|
22
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
22
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
@ -162,7 +162,7 @@ func (c *boolConverter) IsValidPB(v pref.Value) bool {
|
||||
return ok
|
||||
}
|
||||
func (c *boolConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *boolConverter) New() pref.Value { return c.def }
|
||||
func (c *boolConverter) Zero() pref.Value { return c.def }
|
||||
@ -186,7 +186,7 @@ func (c *int32Converter) IsValidPB(v pref.Value) bool {
|
||||
return ok
|
||||
}
|
||||
func (c *int32Converter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *int32Converter) New() pref.Value { return c.def }
|
||||
func (c *int32Converter) Zero() pref.Value { return c.def }
|
||||
@ -210,7 +210,7 @@ func (c *int64Converter) IsValidPB(v pref.Value) bool {
|
||||
return ok
|
||||
}
|
||||
func (c *int64Converter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *int64Converter) New() pref.Value { return c.def }
|
||||
func (c *int64Converter) Zero() pref.Value { return c.def }
|
||||
@ -234,7 +234,7 @@ func (c *uint32Converter) IsValidPB(v pref.Value) bool {
|
||||
return ok
|
||||
}
|
||||
func (c *uint32Converter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *uint32Converter) New() pref.Value { return c.def }
|
||||
func (c *uint32Converter) Zero() pref.Value { return c.def }
|
||||
@ -258,7 +258,7 @@ func (c *uint64Converter) IsValidPB(v pref.Value) bool {
|
||||
return ok
|
||||
}
|
||||
func (c *uint64Converter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *uint64Converter) New() pref.Value { return c.def }
|
||||
func (c *uint64Converter) Zero() pref.Value { return c.def }
|
||||
@ -282,7 +282,7 @@ func (c *float32Converter) IsValidPB(v pref.Value) bool {
|
||||
return ok
|
||||
}
|
||||
func (c *float32Converter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *float32Converter) New() pref.Value { return c.def }
|
||||
func (c *float32Converter) Zero() pref.Value { return c.def }
|
||||
@ -306,7 +306,7 @@ func (c *float64Converter) IsValidPB(v pref.Value) bool {
|
||||
return ok
|
||||
}
|
||||
func (c *float64Converter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *float64Converter) New() pref.Value { return c.def }
|
||||
func (c *float64Converter) Zero() pref.Value { return c.def }
|
||||
@ -336,7 +336,7 @@ func (c *stringConverter) IsValidPB(v pref.Value) bool {
|
||||
return ok
|
||||
}
|
||||
func (c *stringConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *stringConverter) New() pref.Value { return c.def }
|
||||
func (c *stringConverter) Zero() pref.Value { return c.def }
|
||||
@ -363,7 +363,7 @@ func (c *bytesConverter) IsValidPB(v pref.Value) bool {
|
||||
return ok
|
||||
}
|
||||
func (c *bytesConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *bytesConverter) New() pref.Value { return c.def }
|
||||
func (c *bytesConverter) Zero() pref.Value { return c.def }
|
||||
@ -400,7 +400,7 @@ func (c *enumConverter) IsValidPB(v pref.Value) bool {
|
||||
}
|
||||
|
||||
func (c *enumConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
|
||||
func (c *enumConverter) New() pref.Value {
|
||||
@ -455,7 +455,7 @@ func (c *messageConverter) IsValidPB(v pref.Value) bool {
|
||||
}
|
||||
|
||||
func (c *messageConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
|
||||
func (c *messageConverter) New() pref.Value {
|
||||
|
10
vendor/google.golang.org/protobuf/internal/impl/convert_list.go
generated
vendored
10
vendor/google.golang.org/protobuf/internal/impl/convert_list.go
generated
vendored
@ -22,7 +22,7 @@ func newListConverter(t reflect.Type, fd pref.FieldDescriptor) Converter {
|
||||
}
|
||||
|
||||
type listConverter struct {
|
||||
goType reflect.Type
|
||||
goType reflect.Type // []T
|
||||
c Converter
|
||||
}
|
||||
|
||||
@ -48,11 +48,11 @@ func (c *listConverter) IsValidPB(v pref.Value) bool {
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return list.v.Type().Elem() == c.goType && list.IsValid()
|
||||
return list.v.Type().Elem() == c.goType
|
||||
}
|
||||
|
||||
func (c *listConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
|
||||
func (c *listConverter) New() pref.Value {
|
||||
@ -64,7 +64,7 @@ func (c *listConverter) Zero() pref.Value {
|
||||
}
|
||||
|
||||
type listPtrConverter struct {
|
||||
goType reflect.Type
|
||||
goType reflect.Type // *[]T
|
||||
c Converter
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ func (c *listPtrConverter) IsValidPB(v pref.Value) bool {
|
||||
}
|
||||
|
||||
func (c *listPtrConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
|
||||
func (c *listPtrConverter) New() pref.Value {
|
||||
|
6
vendor/google.golang.org/protobuf/internal/impl/convert_map.go
generated
vendored
6
vendor/google.golang.org/protobuf/internal/impl/convert_map.go
generated
vendored
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
type mapConverter struct {
|
||||
goType reflect.Type
|
||||
goType reflect.Type // map[K]V
|
||||
keyConv, valConv Converter
|
||||
}
|
||||
|
||||
@ -43,11 +43,11 @@ func (c *mapConverter) IsValidPB(v pref.Value) bool {
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return mapv.v.Type() == c.goType && mapv.IsValid()
|
||||
return mapv.v.Type() == c.goType
|
||||
}
|
||||
|
||||
func (c *mapConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.Type() == c.goType
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
|
||||
func (c *mapConverter) New() pref.Value {
|
||||
|
12
vendor/google.golang.org/protobuf/internal/impl/legacy_export.go
generated
vendored
12
vendor/google.golang.org/protobuf/internal/impl/legacy_export.go
generated
vendored
@ -7,14 +7,12 @@ package impl
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"hash/crc32"
|
||||
"math"
|
||||
"reflect"
|
||||
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
@ -92,13 +90,3 @@ func (Export) CompressGZIP(in []byte) (out []byte) {
|
||||
out = append(out, gzipFooter[:]...)
|
||||
return out
|
||||
}
|
||||
|
||||
// WeakNil returns a typed nil pointer to a concrete message.
|
||||
// It panics if the message is not linked into the binary.
|
||||
func (Export) WeakNil(s pref.FullName) piface.MessageV1 {
|
||||
mt, err := protoregistry.GlobalTypes.FindMessageByName(s)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("weak message %v is not linked in", s))
|
||||
}
|
||||
return mt.Zero().Interface().(piface.MessageV1)
|
||||
}
|
||||
|
2
vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
generated
vendored
@ -155,6 +155,8 @@ func (x placeholderExtension) Cardinality() pref.Cardinality { retu
|
||||
func (x placeholderExtension) Kind() pref.Kind { return 0 }
|
||||
func (x placeholderExtension) HasJSONName() bool { return false }
|
||||
func (x placeholderExtension) JSONName() string { return "" }
|
||||
func (x placeholderExtension) HasPresence() bool { return false }
|
||||
func (x placeholderExtension) HasOptionalKeyword() bool { return false }
|
||||
func (x placeholderExtension) IsExtension() bool { return true }
|
||||
func (x placeholderExtension) IsWeak() bool { return false }
|
||||
func (x placeholderExtension) IsPacked() bool { return false }
|
||||
|
3
vendor/google.golang.org/protobuf/internal/impl/message.go
generated
vendored
3
vendor/google.golang.org/protobuf/internal/impl/message.go
generated
vendored
@ -15,7 +15,6 @@ import (
|
||||
"google.golang.org/protobuf/internal/genname"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
// MessageInfo provides protobuf related functionality for a given Go type
|
||||
@ -109,7 +108,7 @@ func (mi *MessageInfo) getPointer(m pref.Message) (p pointer, ok bool) {
|
||||
|
||||
type (
|
||||
SizeCache = int32
|
||||
WeakFields = map[int32]piface.MessageV1
|
||||
WeakFields = map[int32]protoreflect.ProtoMessage
|
||||
UnknownFields = []byte
|
||||
ExtensionFields = map[int32]ExtensionField
|
||||
)
|
||||
|
40
vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
generated
vendored
40
vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
generated
vendored
@ -53,7 +53,7 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) {
|
||||
fs := si.fieldsByNumber[fd.Number()]
|
||||
var fi fieldInfo
|
||||
switch {
|
||||
case fd.ContainingOneof() != nil:
|
||||
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
|
||||
fi = fieldInfoForOneof(fd, si.oneofsByName[fd.ContainingOneof().Name()], mi.Exporter, si.oneofWrappersByNumber[fd.Number()])
|
||||
case fd.IsMap():
|
||||
fi = fieldInfoForMap(fd, fs, mi.Exporter)
|
||||
@ -72,7 +72,7 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) {
|
||||
mi.oneofs = map[pref.Name]*oneofInfo{}
|
||||
for i := 0; i < md.Oneofs().Len(); i++ {
|
||||
od := md.Oneofs().Get(i)
|
||||
mi.oneofs[od.Name()] = makeOneofInfo(od, si.oneofsByName[od.Name()], mi.Exporter, si.oneofWrappersByType)
|
||||
mi.oneofs[od.Name()] = makeOneofInfo(od, si, mi.Exporter)
|
||||
}
|
||||
|
||||
mi.denseFields = make([]*fieldInfo, fds.Len()*2)
|
||||
@ -84,7 +84,7 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) {
|
||||
|
||||
for i := 0; i < fds.Len(); {
|
||||
fd := fds.Get(i)
|
||||
if od := fd.ContainingOneof(); od != nil {
|
||||
if od := fd.ContainingOneof(); od != nil && !od.IsSynthetic() {
|
||||
mi.rangeInfos = append(mi.rangeInfos, mi.oneofs[od.Name()])
|
||||
i += od.Fields().Len()
|
||||
} else {
|
||||
@ -170,6 +170,8 @@ func (m *extensionMap) Has(xt pref.ExtensionType) (ok bool) {
|
||||
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
|
||||
}
|
||||
@ -186,15 +188,28 @@ func (m *extensionMap) Get(xt pref.ExtensionType) pref.Value {
|
||||
return xt.Zero()
|
||||
}
|
||||
func (m *extensionMap) Set(xt pref.ExtensionType, v pref.Value) {
|
||||
if !xt.IsValidValue(v) {
|
||||
xd := xt.TypeDescriptor()
|
||||
isValid := true
|
||||
switch {
|
||||
case !xt.IsValidValue(v):
|
||||
isValid = false
|
||||
case xd.IsList():
|
||||
isValid = v.List().IsValid()
|
||||
case xd.IsMap():
|
||||
isValid = v.Map().IsValid()
|
||||
case xd.Message() != nil:
|
||||
isValid = v.Message().IsValid()
|
||||
}
|
||||
if !isValid {
|
||||
panic(fmt.Sprintf("%v: assigning invalid value", xt.TypeDescriptor().FullName()))
|
||||
}
|
||||
|
||||
if *m == nil {
|
||||
*m = make(map[int32]ExtensionField)
|
||||
}
|
||||
var x ExtensionField
|
||||
x.Set(xt, v)
|
||||
(*m)[int32(xt.TypeDescriptor().Number())] = x
|
||||
(*m)[int32(xd.Number())] = x
|
||||
}
|
||||
func (m *extensionMap) Mutable(xt pref.ExtensionType) pref.Value {
|
||||
xd := xt.TypeDescriptor()
|
||||
@ -323,24 +338,27 @@ func (mi *MessageInfo) checkField(fd pref.FieldDescriptor) (*fieldInfo, pref.Ext
|
||||
}
|
||||
if fi != nil {
|
||||
if fi.fieldDesc != fd {
|
||||
panic("mismatching field descriptor")
|
||||
if got, want := fd.FullName(), fi.fieldDesc.FullName(); got != want {
|
||||
panic(fmt.Sprintf("mismatching field: got %v, want %v", got, want))
|
||||
}
|
||||
panic(fmt.Sprintf("mismatching field: %v", fd.FullName()))
|
||||
}
|
||||
return fi, nil
|
||||
}
|
||||
|
||||
if fd.IsExtension() {
|
||||
if fd.ContainingMessage().FullName() != mi.Desc.FullName() {
|
||||
if got, want := fd.ContainingMessage().FullName(), mi.Desc.FullName(); got != want {
|
||||
// TODO: Should this be exact containing message descriptor match?
|
||||
panic("mismatching containing message")
|
||||
panic(fmt.Sprintf("extension %v has mismatching containing message: got %v, want %v", fd.FullName(), got, want))
|
||||
}
|
||||
if !mi.Desc.ExtensionRanges().Has(fd.Number()) {
|
||||
panic("invalid extension field")
|
||||
panic(fmt.Sprintf("extension %v extends %v outside the extension range", fd.FullName(), mi.Desc.FullName()))
|
||||
}
|
||||
xtd, ok := fd.(pref.ExtensionTypeDescriptor)
|
||||
if !ok {
|
||||
panic("extension descriptor does not implement ExtensionTypeDescriptor")
|
||||
panic(fmt.Sprintf("extension %v does not implement protoreflect.ExtensionTypeDescriptor", fd.FullName()))
|
||||
}
|
||||
return nil, xtd.Type()
|
||||
}
|
||||
panic("invalid field descriptor")
|
||||
panic(fmt.Sprintf("field %v is invalid", fd.FullName()))
|
||||
}
|
||||
|
64
vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go
generated
vendored
64
vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go
generated
vendored
@ -31,13 +31,13 @@ type fieldInfo struct {
|
||||
func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x exporter, ot reflect.Type) fieldInfo {
|
||||
ft := fs.Type
|
||||
if ft.Kind() != reflect.Interface {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want interface kind", ft))
|
||||
panic(fmt.Sprintf("field %v has invalid type: got %v, want interface kind", fd.FullName(), ft))
|
||||
}
|
||||
if ot.Kind() != reflect.Struct {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want struct kind", ot))
|
||||
panic(fmt.Sprintf("field %v has invalid type: got %v, want struct kind", fd.FullName(), ot))
|
||||
}
|
||||
if !reflect.PtrTo(ot).Implements(ft) {
|
||||
panic(fmt.Sprintf("invalid type: %v does not implement %v", ot, ft))
|
||||
panic(fmt.Sprintf("field %v has invalid type: %v does not implement %v", fd.FullName(), ot, ft))
|
||||
}
|
||||
conv := NewConverter(ot.Field(0).Type, fd)
|
||||
isMessage := fd.Message() != nil
|
||||
@ -90,7 +90,7 @@ func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x export
|
||||
},
|
||||
mutable: func(p pointer) pref.Value {
|
||||
if !isMessage {
|
||||
panic("invalid Mutable on field with non-composite type")
|
||||
panic(fmt.Sprintf("field %v with invalid Mutable call on field with non-composite type", fd.FullName()))
|
||||
}
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
if rv.IsNil() || rv.Elem().Type().Elem() != ot || rv.Elem().IsNil() {
|
||||
@ -114,7 +114,7 @@ func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x export
|
||||
func fieldInfoForMap(fd pref.FieldDescriptor, fs reflect.StructField, x exporter) fieldInfo {
|
||||
ft := fs.Type
|
||||
if ft.Kind() != reflect.Map {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want map kind", ft))
|
||||
panic(fmt.Sprintf("field %v has invalid type: got %v, want map kind", fd.FullName(), ft))
|
||||
}
|
||||
conv := NewConverter(ft, fd)
|
||||
|
||||
@ -147,7 +147,7 @@ func fieldInfoForMap(fd pref.FieldDescriptor, fs reflect.StructField, x exporter
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
pv := conv.GoValueOf(v)
|
||||
if pv.IsNil() {
|
||||
panic(fmt.Sprintf("invalid value: setting map field to read-only value"))
|
||||
panic(fmt.Sprintf("map field %v cannot be set with read-only value", fd.FullName()))
|
||||
}
|
||||
rv.Set(pv)
|
||||
},
|
||||
@ -167,7 +167,7 @@ func fieldInfoForMap(fd pref.FieldDescriptor, fs reflect.StructField, x exporter
|
||||
func fieldInfoForList(fd pref.FieldDescriptor, fs reflect.StructField, x exporter) fieldInfo {
|
||||
ft := fs.Type
|
||||
if ft.Kind() != reflect.Slice {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want slice kind", ft))
|
||||
panic(fmt.Sprintf("field %v has invalid type: got %v, want slice kind", fd.FullName(), ft))
|
||||
}
|
||||
conv := NewConverter(reflect.PtrTo(ft), fd)
|
||||
|
||||
@ -200,7 +200,7 @@ func fieldInfoForList(fd pref.FieldDescriptor, fs reflect.StructField, x exporte
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
pv := conv.GoValueOf(v)
|
||||
if pv.IsNil() {
|
||||
panic(fmt.Sprintf("invalid value: setting repeated field to read-only value"))
|
||||
panic(fmt.Sprintf("list field %v cannot be set with read-only value", fd.FullName()))
|
||||
}
|
||||
rv.Set(pv.Elem())
|
||||
},
|
||||
@ -221,11 +221,11 @@ var (
|
||||
|
||||
func fieldInfoForScalar(fd pref.FieldDescriptor, fs reflect.StructField, x exporter) fieldInfo {
|
||||
ft := fs.Type
|
||||
nullable := fd.Syntax() == pref.Proto2
|
||||
nullable := fd.HasPresence()
|
||||
isBytes := ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8
|
||||
if nullable {
|
||||
if ft.Kind() != reflect.Ptr && ft.Kind() != reflect.Slice {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want pointer", ft))
|
||||
panic(fmt.Sprintf("field %v has invalid type: got %v, want pointer", fd.FullName(), ft))
|
||||
}
|
||||
if ft.Kind() == reflect.Ptr {
|
||||
ft = ft.Elem()
|
||||
@ -257,7 +257,7 @@ func fieldInfoForScalar(fd pref.FieldDescriptor, fs reflect.StructField, x expor
|
||||
case reflect.String, reflect.Slice:
|
||||
return rv.Len() > 0
|
||||
default:
|
||||
panic(fmt.Sprintf("invalid type: %v", rv.Type())) // should never happen
|
||||
panic(fmt.Sprintf("field %v has invalid type: %v", fd.FullName(), rv.Type())) // should never happen
|
||||
}
|
||||
},
|
||||
clear: func(p pointer) {
|
||||
@ -290,9 +290,9 @@ func fieldInfoForScalar(fd pref.FieldDescriptor, fs reflect.StructField, x expor
|
||||
rv.Set(conv.GoValueOf(v))
|
||||
if isBytes && rv.Len() == 0 {
|
||||
if nullable {
|
||||
rv.Set(emptyBytes) // preserve presence in proto2
|
||||
rv.Set(emptyBytes) // preserve presence
|
||||
} else {
|
||||
rv.Set(nilBytes) // do not preserve presence in proto3
|
||||
rv.Set(nilBytes) // do not preserve presence
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -314,7 +314,7 @@ func fieldInfoForWeakMessage(fd pref.FieldDescriptor, weakOffset offset) fieldIn
|
||||
messageName := fd.Message().FullName()
|
||||
messageType, _ = preg.GlobalTypes.FindMessageByName(messageName)
|
||||
if messageType == nil {
|
||||
panic(fmt.Sprintf("weak message %v is not linked in", messageName))
|
||||
panic(fmt.Sprintf("weak message %v for field %v is not linked in", messageName, fd.FullName()))
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -347,7 +347,10 @@ func fieldInfoForWeakMessage(fd pref.FieldDescriptor, weakOffset offset) fieldIn
|
||||
lazyInit()
|
||||
m := v.Message()
|
||||
if m.Descriptor() != messageType.Descriptor() {
|
||||
panic("mismatching message descriptor")
|
||||
if got, want := m.Descriptor().FullName(), messageType.Descriptor().FullName(); got != want {
|
||||
panic(fmt.Sprintf("field %v has mismatching message descriptor: got %v, want %v", fd.FullName(), got, want))
|
||||
}
|
||||
panic(fmt.Sprintf("field %v has mismatching message descriptor: %v", fd.FullName(), m.Descriptor().FullName()))
|
||||
}
|
||||
p.Apply(weakOffset).WeakFields().set(num, m.Interface())
|
||||
},
|
||||
@ -402,7 +405,7 @@ func fieldInfoForMessage(fd pref.FieldDescriptor, fs reflect.StructField, x expo
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
rv.Set(conv.GoValueOf(v))
|
||||
if rv.IsNil() {
|
||||
panic("invalid nil pointer")
|
||||
panic(fmt.Sprintf("field %v has invalid nil pointer", fd.FullName()))
|
||||
}
|
||||
},
|
||||
mutable: func(p pointer) pref.Value {
|
||||
@ -426,11 +429,25 @@ type oneofInfo struct {
|
||||
which func(pointer) pref.FieldNumber
|
||||
}
|
||||
|
||||
func makeOneofInfo(od pref.OneofDescriptor, fs reflect.StructField, x exporter, wrappersByType map[reflect.Type]pref.FieldNumber) *oneofInfo {
|
||||
fieldOffset := offsetOf(fs, x)
|
||||
return &oneofInfo{
|
||||
oneofDesc: od,
|
||||
which: func(p pointer) pref.FieldNumber {
|
||||
func makeOneofInfo(od pref.OneofDescriptor, si structInfo, x exporter) *oneofInfo {
|
||||
oi := &oneofInfo{oneofDesc: od}
|
||||
if od.IsSynthetic() {
|
||||
fs := si.fieldsByNumber[od.Fields().Get(0).Number()]
|
||||
fieldOffset := offsetOf(fs, x)
|
||||
oi.which = func(p pointer) pref.FieldNumber {
|
||||
if p.IsNil() {
|
||||
return 0
|
||||
}
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
if rv.IsNil() { // valid on either *T or []byte
|
||||
return 0
|
||||
}
|
||||
return od.Fields().Get(0).Number()
|
||||
}
|
||||
} else {
|
||||
fs := si.oneofsByName[od.Name()]
|
||||
fieldOffset := offsetOf(fs, x)
|
||||
oi.which = func(p pointer) pref.FieldNumber {
|
||||
if p.IsNil() {
|
||||
return 0
|
||||
}
|
||||
@ -442,7 +459,8 @@ func makeOneofInfo(od pref.OneofDescriptor, fs reflect.StructField, x exporter,
|
||||
if rv.IsNil() {
|
||||
return 0
|
||||
}
|
||||
return wrappersByType[rv.Type().Elem()]
|
||||
},
|
||||
return si.oneofWrappersByType[rv.Type().Elem()]
|
||||
}
|
||||
}
|
||||
return oi
|
||||
}
|
||||
|
4
vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go
generated
vendored
4
vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go
generated
vendored
@ -114,7 +114,7 @@ func (m *messageState) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.
|
||||
if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
return od.Fields().ByNumber(oi.which(m.pointer()))
|
||||
}
|
||||
panic("invalid oneof descriptor")
|
||||
panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m *messageState) GetUnknown() protoreflect.RawFields {
|
||||
m.messageInfo().init()
|
||||
@ -234,7 +234,7 @@ func (m *messageReflectWrapper) WhichOneof(od protoreflect.OneofDescriptor) prot
|
||||
if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
return od.Fields().ByNumber(oi.which(m.pointer()))
|
||||
}
|
||||
panic("invalid oneof descriptor")
|
||||
panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m *messageReflectWrapper) GetUnknown() protoreflect.RawFields {
|
||||
m.messageInfo().init()
|
||||
|
6
vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
generated
vendored
6
vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
generated
vendored
@ -148,7 +148,11 @@ func (ms *messageState) pointer() pointer {
|
||||
return pointer{p: unsafe.Pointer(ms)}
|
||||
}
|
||||
func (ms *messageState) messageInfo() *MessageInfo {
|
||||
return ms.LoadMessageInfo()
|
||||
mi := ms.LoadMessageInfo()
|
||||
if mi == nil {
|
||||
panic("invalid nil message info; this suggests memory corruption due to a race or shallow copy on the message struct")
|
||||
}
|
||||
return mi
|
||||
}
|
||||
func (ms *messageState) LoadMessageInfo() *MessageInfo {
|
||||
return (*MessageInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&ms.atomicMessageInfo))))
|
||||
|
2
vendor/google.golang.org/protobuf/internal/impl/validate.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/impl/validate.go
generated
vendored
@ -108,7 +108,7 @@ const (
|
||||
func newFieldValidationInfo(mi *MessageInfo, si structInfo, fd pref.FieldDescriptor, ft reflect.Type) validationInfo {
|
||||
var vi validationInfo
|
||||
switch {
|
||||
case fd.ContainingOneof() != nil:
|
||||
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
|
||||
switch fd.Kind() {
|
||||
case pref.MessageKind:
|
||||
vi.typ = validationTypeMessage
|
||||
|
64
vendor/google.golang.org/protobuf/internal/impl/weak.go
generated
vendored
64
vendor/google.golang.org/protobuf/internal/impl/weak.go
generated
vendored
@ -5,9 +5,10 @@
|
||||
package impl
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"fmt"
|
||||
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// weakFields adds methods to the exported WeakFields type for internal use.
|
||||
@ -16,31 +17,58 @@ import (
|
||||
// defined directly on it.
|
||||
type weakFields WeakFields
|
||||
|
||||
func (w *weakFields) get(num pref.FieldNumber) (_ pref.ProtoMessage, ok bool) {
|
||||
if *w == nil {
|
||||
return nil, false
|
||||
}
|
||||
m, ok := (*w)[int32(num)]
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
// As a legacy quirk, consider a typed nil to be unset.
|
||||
//
|
||||
// TODO: Consider fixing the generated set methods to clear the field
|
||||
// when provided with a typed nil.
|
||||
if v := reflect.ValueOf(m); v.Kind() == reflect.Ptr && v.IsNil() {
|
||||
return nil, false
|
||||
}
|
||||
return Export{}.ProtoMessageV2Of(m), true
|
||||
func (w weakFields) get(num pref.FieldNumber) (pref.ProtoMessage, bool) {
|
||||
m, ok := w[int32(num)]
|
||||
return m, ok
|
||||
}
|
||||
|
||||
func (w *weakFields) set(num pref.FieldNumber, m pref.ProtoMessage) {
|
||||
if *w == nil {
|
||||
*w = make(weakFields)
|
||||
}
|
||||
(*w)[int32(num)] = Export{}.ProtoMessageV1Of(m)
|
||||
(*w)[int32(num)] = m
|
||||
}
|
||||
|
||||
func (w *weakFields) clear(num pref.FieldNumber) {
|
||||
delete(*w, int32(num))
|
||||
}
|
||||
|
||||
func (Export) HasWeak(w WeakFields, num pref.FieldNumber) bool {
|
||||
_, ok := w[int32(num)]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (Export) ClearWeak(w *WeakFields, num pref.FieldNumber) {
|
||||
delete(*w, int32(num))
|
||||
}
|
||||
|
||||
func (Export) GetWeak(w WeakFields, num pref.FieldNumber, name pref.FullName) pref.ProtoMessage {
|
||||
if m, ok := w[int32(num)]; ok {
|
||||
return m
|
||||
}
|
||||
mt, _ := protoregistry.GlobalTypes.FindMessageByName(name)
|
||||
if mt == nil {
|
||||
panic(fmt.Sprintf("message %v for weak field is not linked in", name))
|
||||
}
|
||||
return mt.Zero().Interface()
|
||||
}
|
||||
|
||||
func (Export) SetWeak(w *WeakFields, num pref.FieldNumber, name pref.FullName, m pref.ProtoMessage) {
|
||||
if m != nil {
|
||||
mt, _ := protoregistry.GlobalTypes.FindMessageByName(name)
|
||||
if mt == nil {
|
||||
panic(fmt.Sprintf("message %v for weak field is not linked in", name))
|
||||
}
|
||||
if mt != m.ProtoReflect().Type() {
|
||||
panic(fmt.Sprintf("invalid message type for weak field: got %T, want %T", m, mt.Zero().Interface()))
|
||||
}
|
||||
}
|
||||
if m == nil || !m.ProtoReflect().IsValid() {
|
||||
delete(*w, int32(num))
|
||||
return
|
||||
}
|
||||
if *w == nil {
|
||||
*w = make(weakFields)
|
||||
}
|
||||
(*w)[int32(num)] = m
|
||||
}
|
||||
|
2
vendor/google.golang.org/protobuf/internal/version/version.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/version/version.go
generated
vendored
@ -52,7 +52,7 @@ import (
|
||||
// 10. Send out the CL for review and submit it.
|
||||
const (
|
||||
Major = 1
|
||||
Minor = 21
|
||||
Minor = 23
|
||||
Patch = 0
|
||||
PreRelease = ""
|
||||
)
|
||||
|
Reference in New Issue
Block a user