fix xsrf and added nonce
This commit is contained in:
parent
6476ebc781
commit
809627b538
208 changed files with 7166 additions and 4278 deletions
BIN
vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb
generated
vendored
BIN
vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb
generated
vendored
Binary file not shown.
2
vendor/google.golang.org/protobuf/internal/editionssupport/editions.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/editionssupport/editions.go
generated
vendored
|
|
@ -9,7 +9,7 @@ import "google.golang.org/protobuf/types/descriptorpb"
|
|||
|
||||
const (
|
||||
Minimum = descriptorpb.Edition_EDITION_PROTO2
|
||||
Maximum = descriptorpb.Edition_EDITION_2023
|
||||
Maximum = descriptorpb.Edition_EDITION_2024
|
||||
|
||||
// MaximumKnown is the maximum edition that is known to Go Protobuf, but not
|
||||
// declared as supported. In other words: end users cannot use it, but
|
||||
|
|
|
|||
8
vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go
generated
vendored
8
vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go
generated
vendored
|
|
@ -26,7 +26,7 @@ var byteType = reflect.TypeOf(byte(0))
|
|||
// The type is the underlying field type (e.g., a repeated field may be
|
||||
// represented by []T, but the Go type passed in is just T).
|
||||
// A list of enum value descriptors must be provided for enum fields.
|
||||
// This does not populate the Enum or Message (except for weak message).
|
||||
// This does not populate the Enum or Message.
|
||||
//
|
||||
// This function is a best effort attempt; parsing errors are ignored.
|
||||
func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescriptors) protoreflect.FieldDescriptor {
|
||||
|
|
@ -109,9 +109,6 @@ func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescri
|
|||
}
|
||||
case s == "packed":
|
||||
f.L1.EditionFeatures.IsPacked = true
|
||||
case strings.HasPrefix(s, "weak="):
|
||||
f.L1.IsWeak = true
|
||||
f.L1.Message = filedesc.PlaceholderMessage(protoreflect.FullName(s[len("weak="):]))
|
||||
case strings.HasPrefix(s, "def="):
|
||||
// The default tag is special in that everything afterwards is the
|
||||
// default regardless of the presence of commas.
|
||||
|
|
@ -183,9 +180,6 @@ func Marshal(fd protoreflect.FieldDescriptor, enumName string) string {
|
|||
// the exact same semantics from the previous generator.
|
||||
tag = append(tag, "json="+jsonName)
|
||||
}
|
||||
if fd.IsWeak() {
|
||||
tag = append(tag, "weak="+string(fd.Message().FullName()))
|
||||
}
|
||||
// The previous implementation does not tag extension fields as proto3,
|
||||
// even when the field is defined in a proto3 file. Match that behavior
|
||||
// for consistency.
|
||||
|
|
|
|||
61
vendor/google.golang.org/protobuf/internal/filedesc/desc.go
generated
vendored
61
vendor/google.golang.org/protobuf/internal/filedesc/desc.go
generated
vendored
|
|
@ -19,7 +19,6 @@ import (
|
|||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// Edition is an Enum for proto2.Edition
|
||||
|
|
@ -73,9 +72,10 @@ type (
|
|||
EditionFeatures EditionFeatures
|
||||
}
|
||||
FileL2 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
Imports FileImports
|
||||
Locations SourceLocations
|
||||
Options func() protoreflect.ProtoMessage
|
||||
Imports FileImports
|
||||
OptionImports func() protoreflect.FileImports
|
||||
Locations SourceLocations
|
||||
}
|
||||
|
||||
// EditionFeatures is a frequently-instantiated struct, so please take care
|
||||
|
|
@ -127,12 +127,9 @@ func (fd *File) ParentFile() protoreflect.FileDescriptor { return fd }
|
|||
func (fd *File) Parent() protoreflect.Descriptor { return nil }
|
||||
func (fd *File) Index() int { return 0 }
|
||||
func (fd *File) Syntax() protoreflect.Syntax { return fd.L1.Syntax }
|
||||
|
||||
// Not exported and just used to reconstruct the original FileDescriptor proto
|
||||
func (fd *File) Edition() int32 { return int32(fd.L1.Edition) }
|
||||
func (fd *File) Name() protoreflect.Name { return fd.L1.Package.Name() }
|
||||
func (fd *File) FullName() protoreflect.FullName { return fd.L1.Package }
|
||||
func (fd *File) IsPlaceholder() bool { return false }
|
||||
func (fd *File) Name() protoreflect.Name { return fd.L1.Package.Name() }
|
||||
func (fd *File) FullName() protoreflect.FullName { return fd.L1.Package }
|
||||
func (fd *File) IsPlaceholder() bool { return false }
|
||||
func (fd *File) Options() protoreflect.ProtoMessage {
|
||||
if f := fd.lazyInit().Options; f != nil {
|
||||
return f()
|
||||
|
|
@ -151,6 +148,16 @@ func (fd *File) Format(s fmt.State, r rune) { descfmt.FormatD
|
|||
func (fd *File) ProtoType(protoreflect.FileDescriptor) {}
|
||||
func (fd *File) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
// The next two are not part of the FileDescriptor interface. They are just used to reconstruct
|
||||
// the original FileDescriptor proto.
|
||||
func (fd *File) Edition() int32 { return int32(fd.L1.Edition) }
|
||||
func (fd *File) OptionImports() protoreflect.FileImports {
|
||||
if f := fd.lazyInit().OptionImports; f != nil {
|
||||
return f()
|
||||
}
|
||||
return emptyFiles
|
||||
}
|
||||
|
||||
func (fd *File) lazyInit() *FileL2 {
|
||||
if atomic.LoadUint32(&fd.once) == 0 {
|
||||
fd.lazyInitOnce()
|
||||
|
|
@ -183,9 +190,9 @@ type (
|
|||
L2 *EnumL2 // protected by fileDesc.once
|
||||
}
|
||||
EnumL1 struct {
|
||||
eagerValues bool // controls whether EnumL2.Values is already populated
|
||||
|
||||
EditionFeatures EditionFeatures
|
||||
Visibility int32
|
||||
eagerValues bool // controls whether EnumL2.Values is already populated
|
||||
}
|
||||
EnumL2 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
|
|
@ -220,6 +227,11 @@ func (ed *Enum) ReservedNames() protoreflect.Names { return &ed.lazyInit()
|
|||
func (ed *Enum) ReservedRanges() protoreflect.EnumRanges { return &ed.lazyInit().ReservedRanges }
|
||||
func (ed *Enum) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, ed) }
|
||||
func (ed *Enum) ProtoType(protoreflect.EnumDescriptor) {}
|
||||
|
||||
// This is not part of the EnumDescriptor interface. It is just used to reconstruct
|
||||
// the original FileDescriptor proto.
|
||||
func (ed *Enum) Visibility() int32 { return ed.L1.Visibility }
|
||||
|
||||
func (ed *Enum) lazyInit() *EnumL2 {
|
||||
ed.L0.ParentFile.lazyInit() // implicitly initializes L2
|
||||
return ed.L2
|
||||
|
|
@ -245,13 +257,13 @@ type (
|
|||
L2 *MessageL2 // protected by fileDesc.once
|
||||
}
|
||||
MessageL1 struct {
|
||||
Enums Enums
|
||||
Messages Messages
|
||||
Extensions Extensions
|
||||
IsMapEntry bool // promoted from google.protobuf.MessageOptions
|
||||
IsMessageSet bool // promoted from google.protobuf.MessageOptions
|
||||
|
||||
Enums Enums
|
||||
Messages Messages
|
||||
Extensions Extensions
|
||||
EditionFeatures EditionFeatures
|
||||
Visibility int32
|
||||
IsMapEntry bool // promoted from google.protobuf.MessageOptions
|
||||
IsMessageSet bool // promoted from google.protobuf.MessageOptions
|
||||
}
|
||||
MessageL2 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
|
|
@ -275,7 +287,6 @@ type (
|
|||
Kind protoreflect.Kind
|
||||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsWeak bool // promoted from google.protobuf.FieldOptions
|
||||
IsLazy bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
ContainingOneof protoreflect.OneofDescriptor // must be consistent with Message.Oneofs.Fields
|
||||
|
|
@ -321,6 +332,11 @@ func (md *Message) Messages() protoreflect.MessageDescriptors { return &md.L
|
|||
func (md *Message) Extensions() protoreflect.ExtensionDescriptors { return &md.L1.Extensions }
|
||||
func (md *Message) ProtoType(protoreflect.MessageDescriptor) {}
|
||||
func (md *Message) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, md) }
|
||||
|
||||
// This is not part of the MessageDescriptor interface. It is just used to reconstruct
|
||||
// the original FileDescriptor proto.
|
||||
func (md *Message) Visibility() int32 { return md.L1.Visibility }
|
||||
|
||||
func (md *Message) lazyInit() *MessageL2 {
|
||||
md.L0.ParentFile.lazyInit() // implicitly initializes L2
|
||||
return md.L2
|
||||
|
|
@ -369,7 +385,7 @@ func (fd *Field) IsPacked() bool {
|
|||
return fd.L1.EditionFeatures.IsPacked
|
||||
}
|
||||
func (fd *Field) IsExtension() bool { return false }
|
||||
func (fd *Field) IsWeak() bool { return fd.L1.IsWeak }
|
||||
func (fd *Field) IsWeak() bool { return false }
|
||||
func (fd *Field) IsLazy() bool { return fd.L1.IsLazy }
|
||||
func (fd *Field) IsList() bool { return fd.Cardinality() == protoreflect.Repeated && !fd.IsMap() }
|
||||
func (fd *Field) IsMap() bool { return fd.Message() != nil && fd.Message().IsMapEntry() }
|
||||
|
|
@ -396,11 +412,6 @@ func (fd *Field) Enum() protoreflect.EnumDescriptor {
|
|||
return fd.L1.Enum
|
||||
}
|
||||
func (fd *Field) Message() protoreflect.MessageDescriptor {
|
||||
if fd.L1.IsWeak {
|
||||
if d, _ := protoregistry.GlobalFiles.FindDescriptorByName(fd.L1.Message.FullName()); d != nil {
|
||||
return d.(protoreflect.MessageDescriptor)
|
||||
}
|
||||
}
|
||||
return fd.L1.Message
|
||||
}
|
||||
func (fd *Field) IsMapEntry() bool {
|
||||
|
|
|
|||
14
vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go
generated
vendored
14
vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go
generated
vendored
|
|
@ -284,6 +284,13 @@ func (ed *Enum) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd protorefl
|
|||
case genid.EnumDescriptorProto_Value_field_number:
|
||||
numValues++
|
||||
}
|
||||
case protowire.VarintType:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.EnumDescriptorProto_Visibility_field_number:
|
||||
ed.L1.Visibility = int32(v)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
|
|
@ -365,6 +372,13 @@ func (md *Message) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd protor
|
|||
md.unmarshalSeedOptions(v)
|
||||
}
|
||||
prevField = num
|
||||
case protowire.VarintType:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.DescriptorProto_Visibility_field_number:
|
||||
md.L1.Visibility = int32(v)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
|
|
|
|||
29
vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
generated
vendored
29
vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
generated
vendored
|
|
@ -32,11 +32,6 @@ func (file *File) resolveMessages() {
|
|||
for j := range md.L2.Fields.List {
|
||||
fd := &md.L2.Fields.List[j]
|
||||
|
||||
// Weak fields are resolved upon actual use.
|
||||
if fd.L1.IsWeak {
|
||||
continue
|
||||
}
|
||||
|
||||
// Resolve message field dependency.
|
||||
switch fd.L1.Kind {
|
||||
case protoreflect.EnumKind:
|
||||
|
|
@ -139,6 +134,7 @@ func (fd *File) unmarshalFull(b []byte) {
|
|||
|
||||
var enumIdx, messageIdx, extensionIdx, serviceIdx int
|
||||
var rawOptions []byte
|
||||
var optionImports []string
|
||||
fd.L2 = new(FileL2)
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
|
|
@ -150,8 +146,6 @@ func (fd *File) unmarshalFull(b []byte) {
|
|||
switch num {
|
||||
case genid.FileDescriptorProto_PublicDependency_field_number:
|
||||
fd.L2.Imports[v].IsPublic = true
|
||||
case genid.FileDescriptorProto_WeakDependency_field_number:
|
||||
fd.L2.Imports[v].IsWeak = true
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
|
|
@ -164,6 +158,8 @@ func (fd *File) unmarshalFull(b []byte) {
|
|||
imp = PlaceholderFile(path)
|
||||
}
|
||||
fd.L2.Imports = append(fd.L2.Imports, protoreflect.FileImport{FileDescriptor: imp})
|
||||
case genid.FileDescriptorProto_OptionDependency_field_number:
|
||||
optionImports = append(optionImports, sb.MakeString(v))
|
||||
case genid.FileDescriptorProto_EnumType_field_number:
|
||||
fd.L1.Enums.List[enumIdx].unmarshalFull(v, sb)
|
||||
enumIdx++
|
||||
|
|
@ -185,6 +181,23 @@ func (fd *File) unmarshalFull(b []byte) {
|
|||
}
|
||||
}
|
||||
fd.L2.Options = fd.builder.optionsUnmarshaler(&descopts.File, rawOptions)
|
||||
if len(optionImports) > 0 {
|
||||
var imps FileImports
|
||||
var once sync.Once
|
||||
fd.L2.OptionImports = func() protoreflect.FileImports {
|
||||
once.Do(func() {
|
||||
imps = make(FileImports, len(optionImports))
|
||||
for i, path := range optionImports {
|
||||
imp, _ := fd.builder.FileRegistry.FindFileByPath(path)
|
||||
if imp == nil {
|
||||
imp = PlaceholderFile(path)
|
||||
}
|
||||
imps[i] = protoreflect.FileImport{FileDescriptor: imp}
|
||||
}
|
||||
})
|
||||
return &imps
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (ed *Enum) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
|
|
@ -502,8 +515,6 @@ func (fd *Field) unmarshalOptions(b []byte) {
|
|||
switch num {
|
||||
case genid.FieldOptions_Packed_field_number:
|
||||
fd.L1.EditionFeatures.IsPacked = protowire.DecodeBool(v)
|
||||
case genid.FieldOptions_Weak_field_number:
|
||||
fd.L1.IsWeak = protowire.DecodeBool(v)
|
||||
case genid.FieldOptions_Lazy_field_number:
|
||||
fd.L1.IsLazy = protowire.DecodeBool(v)
|
||||
case FieldOptions_EnforceUTF8:
|
||||
|
|
|
|||
18
vendor/google.golang.org/protobuf/internal/filedesc/editions.go
generated
vendored
18
vendor/google.golang.org/protobuf/internal/filedesc/editions.go
generated
vendored
|
|
@ -13,8 +13,10 @@ import (
|
|||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
var defaultsCache = make(map[Edition]EditionFeatures)
|
||||
var defaultsKeys = []Edition{}
|
||||
var (
|
||||
defaultsCache = make(map[Edition]EditionFeatures)
|
||||
defaultsKeys = []Edition{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
unmarshalEditionDefaults(editiondefaults.Defaults)
|
||||
|
|
@ -41,7 +43,7 @@ func unmarshalGoFeature(b []byte, parent EditionFeatures) EditionFeatures {
|
|||
b = b[m:]
|
||||
parent.StripEnumPrefix = int(v)
|
||||
default:
|
||||
panic(fmt.Sprintf("unkown field number %d while unmarshalling GoFeatures", num))
|
||||
panic(fmt.Sprintf("unknown field number %d while unmarshalling GoFeatures", num))
|
||||
}
|
||||
}
|
||||
return parent
|
||||
|
|
@ -69,8 +71,14 @@ func unmarshalFeatureSet(b []byte, parent EditionFeatures) EditionFeatures {
|
|||
parent.IsDelimitedEncoded = v == genid.FeatureSet_DELIMITED_enum_value
|
||||
case genid.FeatureSet_JsonFormat_field_number:
|
||||
parent.IsJSONCompliant = v == genid.FeatureSet_ALLOW_enum_value
|
||||
case genid.FeatureSet_EnforceNamingStyle_field_number:
|
||||
// EnforceNamingStyle is enforced in protoc, languages other than C++
|
||||
// are not supposed to do anything with this feature.
|
||||
case genid.FeatureSet_DefaultSymbolVisibility_field_number:
|
||||
// DefaultSymbolVisibility is enforced in protoc, runtimes should not
|
||||
// inspect this value.
|
||||
default:
|
||||
panic(fmt.Sprintf("unkown field number %d while unmarshalling FeatureSet", num))
|
||||
panic(fmt.Sprintf("unknown field number %d while unmarshalling FeatureSet", num))
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
|
|
@ -144,7 +152,7 @@ func unmarshalEditionDefaults(b []byte) {
|
|||
_, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
default:
|
||||
panic(fmt.Sprintf("unkown field number %d while unmarshalling EditionDefault", num))
|
||||
panic(fmt.Sprintf("unknown field number %d while unmarshalling EditionDefault", num))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
33
vendor/google.golang.org/protobuf/internal/filedesc/presence.go
generated
vendored
Normal file
33
vendor/google.golang.org/protobuf/internal/filedesc/presence.go
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2025 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 filedesc
|
||||
|
||||
import "google.golang.org/protobuf/reflect/protoreflect"
|
||||
|
||||
// UsePresenceForField reports whether the presence bitmap should be used for
|
||||
// the specified field.
|
||||
func UsePresenceForField(fd protoreflect.FieldDescriptor) (usePresence, canBeLazy bool) {
|
||||
switch {
|
||||
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
|
||||
// Oneof fields never use the presence bitmap.
|
||||
//
|
||||
// Synthetic oneofs are an exception: Those are used to implement proto3
|
||||
// optional fields and hence should follow non-oneof field semantics.
|
||||
return false, false
|
||||
|
||||
case fd.IsMap():
|
||||
// Map-typed fields never use the presence bitmap.
|
||||
return false, false
|
||||
|
||||
case fd.Kind() == protoreflect.MessageKind || fd.Kind() == protoreflect.GroupKind:
|
||||
// Lazy fields always use the presence bitmap (only messages can be lazy).
|
||||
isLazy := fd.(interface{ IsLazy() bool }).IsLazy()
|
||||
return isLazy, isLazy
|
||||
|
||||
default:
|
||||
// If the field has presence, use the presence bitmap.
|
||||
return fd.HasPresence(), false
|
||||
}
|
||||
}
|
||||
2
vendor/google.golang.org/protobuf/internal/filetype/build.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/filetype/build.go
generated
vendored
|
|
@ -63,7 +63,7 @@ type Builder struct {
|
|||
// message declarations in "flattened ordering".
|
||||
//
|
||||
// Dependencies are Go types for enums or messages referenced by
|
||||
// message fields (excluding weak fields), for parent extended messages of
|
||||
// message fields, for parent extended messages of
|
||||
// extension fields, for enums or messages referenced by extension fields,
|
||||
// and for input and output messages referenced by service methods.
|
||||
// Dependencies must come after declarations, but the ordering of
|
||||
|
|
|
|||
7
vendor/google.golang.org/protobuf/internal/flags/flags.go
generated
vendored
7
vendor/google.golang.org/protobuf/internal/flags/flags.go
generated
vendored
|
|
@ -6,7 +6,7 @@
|
|||
package flags
|
||||
|
||||
// ProtoLegacy specifies whether to enable support for legacy functionality
|
||||
// such as MessageSets, weak fields, and various other obscure behavior
|
||||
// such as MessageSets, and various other obscure behavior
|
||||
// that is necessary to maintain backwards compatibility with proto1 or
|
||||
// the pre-release variants of proto2 and proto3.
|
||||
//
|
||||
|
|
@ -22,8 +22,3 @@ const ProtoLegacy = protoLegacy
|
|||
// extension fields at unmarshal time, but defers creating the message
|
||||
// structure until the extension is first accessed.
|
||||
const LazyUnmarshalExtensions = ProtoLegacy
|
||||
|
||||
// ProtoLegacyWeak specifies whether to enable support for weak fields.
|
||||
// This flag was split out of ProtoLegacy in preparation for removing
|
||||
// support for weak fields (independent of the other protolegacy features).
|
||||
const ProtoLegacyWeak = ProtoLegacy
|
||||
|
|
|
|||
6
vendor/google.golang.org/protobuf/internal/genid/api_gen.go
generated
vendored
6
vendor/google.golang.org/protobuf/internal/genid/api_gen.go
generated
vendored
|
|
@ -27,6 +27,7 @@ const (
|
|||
Api_SourceContext_field_name protoreflect.Name = "source_context"
|
||||
Api_Mixins_field_name protoreflect.Name = "mixins"
|
||||
Api_Syntax_field_name protoreflect.Name = "syntax"
|
||||
Api_Edition_field_name protoreflect.Name = "edition"
|
||||
|
||||
Api_Name_field_fullname protoreflect.FullName = "google.protobuf.Api.name"
|
||||
Api_Methods_field_fullname protoreflect.FullName = "google.protobuf.Api.methods"
|
||||
|
|
@ -35,6 +36,7 @@ const (
|
|||
Api_SourceContext_field_fullname protoreflect.FullName = "google.protobuf.Api.source_context"
|
||||
Api_Mixins_field_fullname protoreflect.FullName = "google.protobuf.Api.mixins"
|
||||
Api_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Api.syntax"
|
||||
Api_Edition_field_fullname protoreflect.FullName = "google.protobuf.Api.edition"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Api.
|
||||
|
|
@ -46,6 +48,7 @@ const (
|
|||
Api_SourceContext_field_number protoreflect.FieldNumber = 5
|
||||
Api_Mixins_field_number protoreflect.FieldNumber = 6
|
||||
Api_Syntax_field_number protoreflect.FieldNumber = 7
|
||||
Api_Edition_field_number protoreflect.FieldNumber = 8
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Method.
|
||||
|
|
@ -63,6 +66,7 @@ const (
|
|||
Method_ResponseStreaming_field_name protoreflect.Name = "response_streaming"
|
||||
Method_Options_field_name protoreflect.Name = "options"
|
||||
Method_Syntax_field_name protoreflect.Name = "syntax"
|
||||
Method_Edition_field_name protoreflect.Name = "edition"
|
||||
|
||||
Method_Name_field_fullname protoreflect.FullName = "google.protobuf.Method.name"
|
||||
Method_RequestTypeUrl_field_fullname protoreflect.FullName = "google.protobuf.Method.request_type_url"
|
||||
|
|
@ -71,6 +75,7 @@ const (
|
|||
Method_ResponseStreaming_field_fullname protoreflect.FullName = "google.protobuf.Method.response_streaming"
|
||||
Method_Options_field_fullname protoreflect.FullName = "google.protobuf.Method.options"
|
||||
Method_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Method.syntax"
|
||||
Method_Edition_field_fullname protoreflect.FullName = "google.protobuf.Method.edition"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Method.
|
||||
|
|
@ -82,6 +87,7 @@ const (
|
|||
Method_ResponseStreaming_field_number protoreflect.FieldNumber = 5
|
||||
Method_Options_field_number protoreflect.FieldNumber = 6
|
||||
Method_Syntax_field_number protoreflect.FieldNumber = 7
|
||||
Method_Edition_field_number protoreflect.FieldNumber = 8
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Mixin.
|
||||
|
|
|
|||
98
vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go
generated
vendored
98
vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go
generated
vendored
|
|
@ -34,6 +34,19 @@ const (
|
|||
Edition_EDITION_MAX_enum_value = 2147483647
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.SymbolVisibility.
|
||||
const (
|
||||
SymbolVisibility_enum_fullname = "google.protobuf.SymbolVisibility"
|
||||
SymbolVisibility_enum_name = "SymbolVisibility"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.SymbolVisibility.
|
||||
const (
|
||||
SymbolVisibility_VISIBILITY_UNSET_enum_value = 0
|
||||
SymbolVisibility_VISIBILITY_LOCAL_enum_value = 1
|
||||
SymbolVisibility_VISIBILITY_EXPORT_enum_value = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FileDescriptorSet.
|
||||
const (
|
||||
FileDescriptorSet_message_name protoreflect.Name = "FileDescriptorSet"
|
||||
|
|
@ -65,6 +78,7 @@ const (
|
|||
FileDescriptorProto_Dependency_field_name protoreflect.Name = "dependency"
|
||||
FileDescriptorProto_PublicDependency_field_name protoreflect.Name = "public_dependency"
|
||||
FileDescriptorProto_WeakDependency_field_name protoreflect.Name = "weak_dependency"
|
||||
FileDescriptorProto_OptionDependency_field_name protoreflect.Name = "option_dependency"
|
||||
FileDescriptorProto_MessageType_field_name protoreflect.Name = "message_type"
|
||||
FileDescriptorProto_EnumType_field_name protoreflect.Name = "enum_type"
|
||||
FileDescriptorProto_Service_field_name protoreflect.Name = "service"
|
||||
|
|
@ -79,6 +93,7 @@ const (
|
|||
FileDescriptorProto_Dependency_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.dependency"
|
||||
FileDescriptorProto_PublicDependency_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.public_dependency"
|
||||
FileDescriptorProto_WeakDependency_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.weak_dependency"
|
||||
FileDescriptorProto_OptionDependency_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.option_dependency"
|
||||
FileDescriptorProto_MessageType_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.message_type"
|
||||
FileDescriptorProto_EnumType_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.enum_type"
|
||||
FileDescriptorProto_Service_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.service"
|
||||
|
|
@ -96,6 +111,7 @@ const (
|
|||
FileDescriptorProto_Dependency_field_number protoreflect.FieldNumber = 3
|
||||
FileDescriptorProto_PublicDependency_field_number protoreflect.FieldNumber = 10
|
||||
FileDescriptorProto_WeakDependency_field_number protoreflect.FieldNumber = 11
|
||||
FileDescriptorProto_OptionDependency_field_number protoreflect.FieldNumber = 15
|
||||
FileDescriptorProto_MessageType_field_number protoreflect.FieldNumber = 4
|
||||
FileDescriptorProto_EnumType_field_number protoreflect.FieldNumber = 5
|
||||
FileDescriptorProto_Service_field_number protoreflect.FieldNumber = 6
|
||||
|
|
@ -124,6 +140,7 @@ const (
|
|||
DescriptorProto_Options_field_name protoreflect.Name = "options"
|
||||
DescriptorProto_ReservedRange_field_name protoreflect.Name = "reserved_range"
|
||||
DescriptorProto_ReservedName_field_name protoreflect.Name = "reserved_name"
|
||||
DescriptorProto_Visibility_field_name protoreflect.Name = "visibility"
|
||||
|
||||
DescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.name"
|
||||
DescriptorProto_Field_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.field"
|
||||
|
|
@ -135,6 +152,7 @@ const (
|
|||
DescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.options"
|
||||
DescriptorProto_ReservedRange_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.reserved_range"
|
||||
DescriptorProto_ReservedName_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.reserved_name"
|
||||
DescriptorProto_Visibility_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.visibility"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.DescriptorProto.
|
||||
|
|
@ -149,6 +167,7 @@ const (
|
|||
DescriptorProto_Options_field_number protoreflect.FieldNumber = 7
|
||||
DescriptorProto_ReservedRange_field_number protoreflect.FieldNumber = 9
|
||||
DescriptorProto_ReservedName_field_number protoreflect.FieldNumber = 10
|
||||
DescriptorProto_Visibility_field_number protoreflect.FieldNumber = 11
|
||||
)
|
||||
|
||||
// Names for google.protobuf.DescriptorProto.ExtensionRange.
|
||||
|
|
@ -388,12 +407,14 @@ const (
|
|||
EnumDescriptorProto_Options_field_name protoreflect.Name = "options"
|
||||
EnumDescriptorProto_ReservedRange_field_name protoreflect.Name = "reserved_range"
|
||||
EnumDescriptorProto_ReservedName_field_name protoreflect.Name = "reserved_name"
|
||||
EnumDescriptorProto_Visibility_field_name protoreflect.Name = "visibility"
|
||||
|
||||
EnumDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.name"
|
||||
EnumDescriptorProto_Value_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.value"
|
||||
EnumDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.options"
|
||||
EnumDescriptorProto_ReservedRange_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.reserved_range"
|
||||
EnumDescriptorProto_ReservedName_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.reserved_name"
|
||||
EnumDescriptorProto_Visibility_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.visibility"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumDescriptorProto.
|
||||
|
|
@ -403,6 +424,7 @@ const (
|
|||
EnumDescriptorProto_Options_field_number protoreflect.FieldNumber = 3
|
||||
EnumDescriptorProto_ReservedRange_field_number protoreflect.FieldNumber = 4
|
||||
EnumDescriptorProto_ReservedName_field_number protoreflect.FieldNumber = 5
|
||||
EnumDescriptorProto_Visibility_field_number protoreflect.FieldNumber = 6
|
||||
)
|
||||
|
||||
// Names for google.protobuf.EnumDescriptorProto.EnumReservedRange.
|
||||
|
|
@ -1008,29 +1030,35 @@ const (
|
|||
|
||||
// Field names for google.protobuf.FeatureSet.
|
||||
const (
|
||||
FeatureSet_FieldPresence_field_name protoreflect.Name = "field_presence"
|
||||
FeatureSet_EnumType_field_name protoreflect.Name = "enum_type"
|
||||
FeatureSet_RepeatedFieldEncoding_field_name protoreflect.Name = "repeated_field_encoding"
|
||||
FeatureSet_Utf8Validation_field_name protoreflect.Name = "utf8_validation"
|
||||
FeatureSet_MessageEncoding_field_name protoreflect.Name = "message_encoding"
|
||||
FeatureSet_JsonFormat_field_name protoreflect.Name = "json_format"
|
||||
FeatureSet_FieldPresence_field_name protoreflect.Name = "field_presence"
|
||||
FeatureSet_EnumType_field_name protoreflect.Name = "enum_type"
|
||||
FeatureSet_RepeatedFieldEncoding_field_name protoreflect.Name = "repeated_field_encoding"
|
||||
FeatureSet_Utf8Validation_field_name protoreflect.Name = "utf8_validation"
|
||||
FeatureSet_MessageEncoding_field_name protoreflect.Name = "message_encoding"
|
||||
FeatureSet_JsonFormat_field_name protoreflect.Name = "json_format"
|
||||
FeatureSet_EnforceNamingStyle_field_name protoreflect.Name = "enforce_naming_style"
|
||||
FeatureSet_DefaultSymbolVisibility_field_name protoreflect.Name = "default_symbol_visibility"
|
||||
|
||||
FeatureSet_FieldPresence_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.field_presence"
|
||||
FeatureSet_EnumType_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.enum_type"
|
||||
FeatureSet_RepeatedFieldEncoding_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.repeated_field_encoding"
|
||||
FeatureSet_Utf8Validation_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.utf8_validation"
|
||||
FeatureSet_MessageEncoding_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.message_encoding"
|
||||
FeatureSet_JsonFormat_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.json_format"
|
||||
FeatureSet_FieldPresence_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.field_presence"
|
||||
FeatureSet_EnumType_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.enum_type"
|
||||
FeatureSet_RepeatedFieldEncoding_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.repeated_field_encoding"
|
||||
FeatureSet_Utf8Validation_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.utf8_validation"
|
||||
FeatureSet_MessageEncoding_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.message_encoding"
|
||||
FeatureSet_JsonFormat_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.json_format"
|
||||
FeatureSet_EnforceNamingStyle_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.enforce_naming_style"
|
||||
FeatureSet_DefaultSymbolVisibility_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.default_symbol_visibility"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FeatureSet.
|
||||
const (
|
||||
FeatureSet_FieldPresence_field_number protoreflect.FieldNumber = 1
|
||||
FeatureSet_EnumType_field_number protoreflect.FieldNumber = 2
|
||||
FeatureSet_RepeatedFieldEncoding_field_number protoreflect.FieldNumber = 3
|
||||
FeatureSet_Utf8Validation_field_number protoreflect.FieldNumber = 4
|
||||
FeatureSet_MessageEncoding_field_number protoreflect.FieldNumber = 5
|
||||
FeatureSet_JsonFormat_field_number protoreflect.FieldNumber = 6
|
||||
FeatureSet_FieldPresence_field_number protoreflect.FieldNumber = 1
|
||||
FeatureSet_EnumType_field_number protoreflect.FieldNumber = 2
|
||||
FeatureSet_RepeatedFieldEncoding_field_number protoreflect.FieldNumber = 3
|
||||
FeatureSet_Utf8Validation_field_number protoreflect.FieldNumber = 4
|
||||
FeatureSet_MessageEncoding_field_number protoreflect.FieldNumber = 5
|
||||
FeatureSet_JsonFormat_field_number protoreflect.FieldNumber = 6
|
||||
FeatureSet_EnforceNamingStyle_field_number protoreflect.FieldNumber = 7
|
||||
FeatureSet_DefaultSymbolVisibility_field_number protoreflect.FieldNumber = 8
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.FieldPresence.
|
||||
|
|
@ -1112,6 +1140,40 @@ const (
|
|||
FeatureSet_LEGACY_BEST_EFFORT_enum_value = 2
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.EnforceNamingStyle.
|
||||
const (
|
||||
FeatureSet_EnforceNamingStyle_enum_fullname = "google.protobuf.FeatureSet.EnforceNamingStyle"
|
||||
FeatureSet_EnforceNamingStyle_enum_name = "EnforceNamingStyle"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.EnforceNamingStyle.
|
||||
const (
|
||||
FeatureSet_ENFORCE_NAMING_STYLE_UNKNOWN_enum_value = 0
|
||||
FeatureSet_STYLE2024_enum_value = 1
|
||||
FeatureSet_STYLE_LEGACY_enum_value = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FeatureSet.VisibilityFeature.
|
||||
const (
|
||||
FeatureSet_VisibilityFeature_message_name protoreflect.Name = "VisibilityFeature"
|
||||
FeatureSet_VisibilityFeature_message_fullname protoreflect.FullName = "google.protobuf.FeatureSet.VisibilityFeature"
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility.
|
||||
const (
|
||||
FeatureSet_VisibilityFeature_DefaultSymbolVisibility_enum_fullname = "google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility"
|
||||
FeatureSet_VisibilityFeature_DefaultSymbolVisibility_enum_name = "DefaultSymbolVisibility"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility.
|
||||
const (
|
||||
FeatureSet_VisibilityFeature_DEFAULT_SYMBOL_VISIBILITY_UNKNOWN_enum_value = 0
|
||||
FeatureSet_VisibilityFeature_EXPORT_ALL_enum_value = 1
|
||||
FeatureSet_VisibilityFeature_EXPORT_TOP_LEVEL_enum_value = 2
|
||||
FeatureSet_VisibilityFeature_LOCAL_ALL_enum_value = 3
|
||||
FeatureSet_VisibilityFeature_STRICT_enum_value = 4
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FeatureSetDefaults.
|
||||
const (
|
||||
FeatureSetDefaults_message_name protoreflect.Name = "FeatureSetDefaults"
|
||||
|
|
|
|||
5
vendor/google.golang.org/protobuf/internal/genid/goname.go
generated
vendored
5
vendor/google.golang.org/protobuf/internal/genid/goname.go
generated
vendored
|
|
@ -11,15 +11,10 @@ const (
|
|||
SizeCache_goname = "sizeCache"
|
||||
SizeCacheA_goname = "XXX_sizecache"
|
||||
|
||||
WeakFields_goname = "weakFields"
|
||||
WeakFieldsA_goname = "XXX_weak"
|
||||
|
||||
UnknownFields_goname = "unknownFields"
|
||||
UnknownFieldsA_goname = "XXX_unrecognized"
|
||||
|
||||
ExtensionFields_goname = "extensionFields"
|
||||
ExtensionFieldsA_goname = "XXX_InternalExtensions"
|
||||
ExtensionFieldsB_goname = "XXX_extensions"
|
||||
|
||||
WeakFieldPrefix_goname = "XXX_weak_"
|
||||
)
|
||||
|
|
|
|||
75
vendor/google.golang.org/protobuf/internal/impl/codec_field.go
generated
vendored
75
vendor/google.golang.org/protobuf/internal/impl/codec_field.go
generated
vendored
|
|
@ -5,15 +5,12 @@
|
|||
package impl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
|
|
@ -121,78 +118,6 @@ func (mi *MessageInfo) initOneofFieldCoders(od protoreflect.OneofDescriptor, si
|
|||
}
|
||||
}
|
||||
|
||||
func makeWeakMessageFieldCoder(fd protoreflect.FieldDescriptor) pointerCoderFuncs {
|
||||
var once sync.Once
|
||||
var messageType protoreflect.MessageType
|
||||
lazyInit := func() {
|
||||
once.Do(func() {
|
||||
messageName := fd.Message().FullName()
|
||||
messageType, _ = protoregistry.GlobalTypes.FindMessageByName(messageName)
|
||||
})
|
||||
}
|
||||
|
||||
return pointerCoderFuncs{
|
||||
size: func(p pointer, f *coderFieldInfo, opts marshalOptions) int {
|
||||
m, ok := p.WeakFields().get(f.num)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
lazyInit()
|
||||
if messageType == nil {
|
||||
panic(fmt.Sprintf("weak message %v is not linked in", fd.Message().FullName()))
|
||||
}
|
||||
return sizeMessage(m, f.tagsize, opts)
|
||||
},
|
||||
marshal: func(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
|
||||
m, ok := p.WeakFields().get(f.num)
|
||||
if !ok {
|
||||
return b, nil
|
||||
}
|
||||
lazyInit()
|
||||
if messageType == nil {
|
||||
panic(fmt.Sprintf("weak message %v is not linked in", fd.Message().FullName()))
|
||||
}
|
||||
return appendMessage(b, m, f.wiretag, opts)
|
||||
},
|
||||
unmarshal: func(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (unmarshalOutput, error) {
|
||||
fs := p.WeakFields()
|
||||
m, ok := fs.get(f.num)
|
||||
if !ok {
|
||||
lazyInit()
|
||||
if messageType == nil {
|
||||
return unmarshalOutput{}, errUnknown
|
||||
}
|
||||
m = messageType.New().Interface()
|
||||
fs.set(f.num, m)
|
||||
}
|
||||
return consumeMessage(b, m, wtyp, opts)
|
||||
},
|
||||
isInit: func(p pointer, f *coderFieldInfo) error {
|
||||
m, ok := p.WeakFields().get(f.num)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return proto.CheckInitialized(m)
|
||||
},
|
||||
merge: func(dst, src pointer, f *coderFieldInfo, opts mergeOptions) {
|
||||
sm, ok := src.WeakFields().get(f.num)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
dm, ok := dst.WeakFields().get(f.num)
|
||||
if !ok {
|
||||
lazyInit()
|
||||
if messageType == nil {
|
||||
panic(fmt.Sprintf("weak message %v is not linked in", fd.Message().FullName()))
|
||||
}
|
||||
dm = messageType.New().Interface()
|
||||
dst.WeakFields().set(f.num, dm)
|
||||
}
|
||||
opts.Merge(dm, sm)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func makeMessageFieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) pointerCoderFuncs {
|
||||
if mi := getMessageInfo(ft); mi != nil {
|
||||
funcs := pointerCoderFuncs{
|
||||
|
|
|
|||
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
|
|
@ -119,9 +119,6 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
|||
}
|
||||
case isOneof:
|
||||
fieldOffset = offsetOf(fs)
|
||||
case fd.IsWeak():
|
||||
fieldOffset = si.weakOffset
|
||||
funcs = makeWeakMessageFieldCoder(fd)
|
||||
default:
|
||||
fieldOffset = offsetOf(fs)
|
||||
childMessage, funcs = fieldCoder(fd, ft)
|
||||
|
|
|
|||
6
vendor/google.golang.org/protobuf/internal/impl/codec_message_opaque.go
generated
vendored
6
vendor/google.golang.org/protobuf/internal/impl/codec_message_opaque.go
generated
vendored
|
|
@ -11,6 +11,7 @@ import (
|
|||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/filedesc"
|
||||
"google.golang.org/protobuf/internal/order"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
|
|
@ -46,9 +47,6 @@ func (mi *MessageInfo) makeOpaqueCoderMethods(t reflect.Type, si opaqueStructInf
|
|||
switch {
|
||||
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
|
||||
fieldOffset = offsetOf(fs)
|
||||
case fd.IsWeak():
|
||||
fieldOffset = si.weakOffset
|
||||
funcs = makeWeakMessageFieldCoder(fd)
|
||||
case fd.Message() != nil && !fd.IsMap():
|
||||
fieldOffset = offsetOf(fs)
|
||||
if fd.IsList() {
|
||||
|
|
@ -83,7 +81,7 @@ func (mi *MessageInfo) makeOpaqueCoderMethods(t reflect.Type, si opaqueStructInf
|
|||
// permit us to skip over definitely-unset fields at marshal time.
|
||||
|
||||
var hasPresence bool
|
||||
hasPresence, cf.isLazy = usePresenceForField(si, fd)
|
||||
hasPresence, cf.isLazy = filedesc.UsePresenceForField(fd)
|
||||
|
||||
if hasPresence {
|
||||
cf.presenceIndex, mi.presenceSize = presenceIndex(mi.Desc, fd)
|
||||
|
|
|
|||
2
vendor/google.golang.org/protobuf/internal/impl/lazy.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/impl/lazy.go
generated
vendored
|
|
@ -131,7 +131,7 @@ func (mi *MessageInfo) skipField(b []byte, f *coderFieldInfo, wtyp protowire.Typ
|
|||
fmi := f.validation.mi
|
||||
if fmi == nil {
|
||||
fd := mi.Desc.Fields().ByNumber(f.num)
|
||||
if fd == nil || !fd.IsWeak() {
|
||||
if fd == nil {
|
||||
return out, ValidationUnknown
|
||||
}
|
||||
messageName := fd.Message().FullName()
|
||||
|
|
|
|||
5
vendor/google.golang.org/protobuf/internal/impl/legacy_message.go
generated
vendored
5
vendor/google.golang.org/protobuf/internal/impl/legacy_message.go
generated
vendored
|
|
@ -310,12 +310,9 @@ func aberrantAppendField(md *filedesc.Message, goType reflect.Type, tag, tagKey,
|
|||
fd.L0.Parent = md
|
||||
fd.L0.Index = n
|
||||
|
||||
if fd.L1.IsWeak || fd.L1.EditionFeatures.IsPacked {
|
||||
if 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.EditionFeatures.IsPacked {
|
||||
opts.Set(opts.Descriptor().Fields().ByName("packed"), protoreflect.ValueOfBool(fd.L1.EditionFeatures.IsPacked))
|
||||
}
|
||||
|
|
|
|||
13
vendor/google.golang.org/protobuf/internal/impl/message.go
generated
vendored
13
vendor/google.golang.org/protobuf/internal/impl/message.go
generated
vendored
|
|
@ -14,7 +14,6 @@ import (
|
|||
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// MessageInfo provides protobuf related functionality for a given Go type
|
||||
|
|
@ -120,7 +119,6 @@ type (
|
|||
|
||||
var (
|
||||
sizecacheType = reflect.TypeOf(SizeCache(0))
|
||||
weakFieldsType = reflect.TypeOf(WeakFields(nil))
|
||||
unknownFieldsAType = reflect.TypeOf(unknownFieldsA(nil))
|
||||
unknownFieldsBType = reflect.TypeOf(unknownFieldsB(nil))
|
||||
extensionFieldsType = reflect.TypeOf(ExtensionFields(nil))
|
||||
|
|
@ -129,8 +127,6 @@ var (
|
|||
type structInfo struct {
|
||||
sizecacheOffset offset
|
||||
sizecacheType reflect.Type
|
||||
weakOffset offset
|
||||
weakType reflect.Type
|
||||
unknownOffset offset
|
||||
unknownType reflect.Type
|
||||
extensionOffset offset
|
||||
|
|
@ -148,7 +144,6 @@ type structInfo struct {
|
|||
func (mi *MessageInfo) makeStructInfo(t reflect.Type) structInfo {
|
||||
si := structInfo{
|
||||
sizecacheOffset: invalidOffset,
|
||||
weakOffset: invalidOffset,
|
||||
unknownOffset: invalidOffset,
|
||||
extensionOffset: invalidOffset,
|
||||
lazyOffset: invalidOffset,
|
||||
|
|
@ -168,11 +163,6 @@ fieldLoop:
|
|||
si.sizecacheOffset = offsetOf(f)
|
||||
si.sizecacheType = f.Type
|
||||
}
|
||||
case genid.WeakFields_goname, genid.WeakFieldsA_goname:
|
||||
if f.Type == weakFieldsType {
|
||||
si.weakOffset = offsetOf(f)
|
||||
si.weakType = f.Type
|
||||
}
|
||||
case genid.UnknownFields_goname, genid.UnknownFieldsA_goname:
|
||||
if f.Type == unknownFieldsAType || f.Type == unknownFieldsBType {
|
||||
si.unknownOffset = offsetOf(f)
|
||||
|
|
@ -256,9 +246,6 @@ func (mi *MessageInfo) Message(i int) protoreflect.MessageType {
|
|||
mi.init()
|
||||
fd := mi.Desc.Fields().Get(i)
|
||||
switch {
|
||||
case fd.IsWeak():
|
||||
mt, _ := protoregistry.GlobalTypes.FindMessageByName(fd.Message().FullName())
|
||||
return mt
|
||||
case fd.IsMap():
|
||||
return mapEntryType{fd.Message(), mi.fieldTypes[fd.Number()]}
|
||||
default:
|
||||
|
|
|
|||
50
vendor/google.golang.org/protobuf/internal/impl/message_opaque.go
generated
vendored
50
vendor/google.golang.org/protobuf/internal/impl/message_opaque.go
generated
vendored
|
|
@ -11,6 +11,7 @@ import (
|
|||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
"google.golang.org/protobuf/internal/filedesc"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
|
|
@ -53,12 +54,9 @@ func opaqueInitHook(mi *MessageInfo) bool {
|
|||
fd := fds.Get(i)
|
||||
fs := si.fieldsByNumber[fd.Number()]
|
||||
var fi fieldInfo
|
||||
usePresence, _ := usePresenceForField(si, fd)
|
||||
usePresence, _ := filedesc.UsePresenceForField(fd)
|
||||
|
||||
switch {
|
||||
case fd.IsWeak():
|
||||
// Weak fields are no different for opaque.
|
||||
fi = fieldInfoForWeakMessage(fd, si.weakOffset)
|
||||
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
|
||||
// Oneofs are no different for opaque.
|
||||
fi = fieldInfoForOneof(fd, si.oneofsByName[fd.ContainingOneof().Name()], mi.Exporter, si.oneofWrappersByNumber[fd.Number()])
|
||||
|
|
@ -346,17 +344,15 @@ func (mi *MessageInfo) fieldInfoForMessageListOpaqueNoPresence(si opaqueStructIn
|
|||
if p.IsNil() {
|
||||
return false
|
||||
}
|
||||
sp := p.Apply(fieldOffset).AtomicGetPointer()
|
||||
if sp.IsNil() {
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
if rv.IsNil() {
|
||||
return false
|
||||
}
|
||||
rv := sp.AsValueOf(fs.Type.Elem())
|
||||
return rv.Elem().Len() > 0
|
||||
},
|
||||
clear: func(p pointer) {
|
||||
sp := p.Apply(fieldOffset).AtomicGetPointer()
|
||||
if !sp.IsNil() {
|
||||
rv := sp.AsValueOf(fs.Type.Elem())
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
if !rv.IsNil() {
|
||||
rv.Elem().Set(reflect.Zero(rv.Type().Elem()))
|
||||
}
|
||||
},
|
||||
|
|
@ -364,11 +360,10 @@ func (mi *MessageInfo) fieldInfoForMessageListOpaqueNoPresence(si opaqueStructIn
|
|||
if p.IsNil() {
|
||||
return conv.Zero()
|
||||
}
|
||||
sp := p.Apply(fieldOffset).AtomicGetPointer()
|
||||
if sp.IsNil() {
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
if rv.IsNil() {
|
||||
return conv.Zero()
|
||||
}
|
||||
rv := sp.AsValueOf(fs.Type.Elem())
|
||||
if rv.Elem().Len() == 0 {
|
||||
return conv.Zero()
|
||||
}
|
||||
|
|
@ -601,32 +596,3 @@ func (mi *MessageInfo) clearPresent(p pointer, index uint32) {
|
|||
func (mi *MessageInfo) present(p pointer, index uint32) bool {
|
||||
return p.Apply(mi.presenceOffset).PresenceInfo().Present(index)
|
||||
}
|
||||
|
||||
// usePresenceForField implements the somewhat intricate logic of when
|
||||
// the presence bitmap is used for a field. The main logic is that a
|
||||
// field that is optional or that can be lazy will use the presence
|
||||
// bit, but for proto2, also maps have a presence bit. It also records
|
||||
// if the field can ever be lazy, which is true if we have a
|
||||
// lazyOffset and the field is a message or a slice of messages. A
|
||||
// field that is lazy will always need a presence bit. Oneofs are not
|
||||
// lazy and do not use presence, unless they are a synthetic oneof,
|
||||
// which is a proto3 optional field. For proto3 optionals, we use the
|
||||
// presence and they can also be lazy when applicable (a message).
|
||||
func usePresenceForField(si opaqueStructInfo, fd protoreflect.FieldDescriptor) (usePresence, canBeLazy bool) {
|
||||
hasLazyField := fd.(interface{ IsLazy() bool }).IsLazy()
|
||||
|
||||
// Non-oneof scalar fields with explicit field presence use the presence array.
|
||||
usesPresenceArray := fd.HasPresence() && fd.Message() == nil && (fd.ContainingOneof() == nil || fd.ContainingOneof().IsSynthetic())
|
||||
switch {
|
||||
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
|
||||
return false, false
|
||||
case fd.IsWeak():
|
||||
return false, false
|
||||
case fd.IsMap():
|
||||
return false, false
|
||||
case fd.Kind() == protoreflect.MessageKind || fd.Kind() == protoreflect.GroupKind:
|
||||
return hasLazyField, hasLazyField
|
||||
default:
|
||||
return usesPresenceArray || (hasLazyField && fd.HasPresence()), false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
5
vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
generated
vendored
5
vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
generated
vendored
|
|
@ -72,8 +72,6 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) {
|
|||
fi = fieldInfoForMap(fd, fs, mi.Exporter)
|
||||
case fd.IsList():
|
||||
fi = fieldInfoForList(fd, fs, mi.Exporter)
|
||||
case fd.IsWeak():
|
||||
fi = fieldInfoForWeakMessage(fd, si.weakOffset)
|
||||
case fd.Message() != nil:
|
||||
fi = fieldInfoForMessage(fd, fs, mi.Exporter)
|
||||
default:
|
||||
|
|
@ -219,9 +217,6 @@ func (mi *MessageInfo) makeFieldTypes(si structInfo) {
|
|||
}
|
||||
case fd.Message() != nil:
|
||||
ft = fs.Type
|
||||
if fd.IsWeak() {
|
||||
ft = nil
|
||||
}
|
||||
isMessage = true
|
||||
}
|
||||
if isMessage && ft != nil && ft.Kind() != reflect.Ptr {
|
||||
|
|
|
|||
76
vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go
generated
vendored
76
vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go
generated
vendored
|
|
@ -8,11 +8,8 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/internal/flags"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
type fieldInfo struct {
|
||||
|
|
@ -332,79 +329,6 @@ func fieldInfoForScalar(fd protoreflect.FieldDescriptor, fs reflect.StructField,
|
|||
}
|
||||
}
|
||||
|
||||
func fieldInfoForWeakMessage(fd protoreflect.FieldDescriptor, weakOffset offset) fieldInfo {
|
||||
if !flags.ProtoLegacyWeak {
|
||||
panic("no support for proto1 weak fields")
|
||||
}
|
||||
|
||||
var once sync.Once
|
||||
var messageType protoreflect.MessageType
|
||||
lazyInit := func() {
|
||||
once.Do(func() {
|
||||
messageName := fd.Message().FullName()
|
||||
messageType, _ = protoregistry.GlobalTypes.FindMessageByName(messageName)
|
||||
if messageType == nil {
|
||||
panic(fmt.Sprintf("weak message %v for field %v is not linked in", messageName, fd.FullName()))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
num := fd.Number()
|
||||
return fieldInfo{
|
||||
fieldDesc: fd,
|
||||
has: func(p pointer) bool {
|
||||
if p.IsNil() {
|
||||
return false
|
||||
}
|
||||
_, ok := p.Apply(weakOffset).WeakFields().get(num)
|
||||
return ok
|
||||
},
|
||||
clear: func(p pointer) {
|
||||
p.Apply(weakOffset).WeakFields().clear(num)
|
||||
},
|
||||
get: func(p pointer) protoreflect.Value {
|
||||
lazyInit()
|
||||
if p.IsNil() {
|
||||
return protoreflect.ValueOfMessage(messageType.Zero())
|
||||
}
|
||||
m, ok := p.Apply(weakOffset).WeakFields().get(num)
|
||||
if !ok {
|
||||
return protoreflect.ValueOfMessage(messageType.Zero())
|
||||
}
|
||||
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
||||
},
|
||||
set: func(p pointer, v protoreflect.Value) {
|
||||
lazyInit()
|
||||
m := v.Message()
|
||||
if m.Descriptor() != messageType.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())
|
||||
},
|
||||
mutable: func(p pointer) protoreflect.Value {
|
||||
lazyInit()
|
||||
fs := p.Apply(weakOffset).WeakFields()
|
||||
m, ok := fs.get(num)
|
||||
if !ok {
|
||||
m = messageType.New().Interface()
|
||||
fs.set(num, m)
|
||||
}
|
||||
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
||||
},
|
||||
newMessage: func() protoreflect.Message {
|
||||
lazyInit()
|
||||
return messageType.New()
|
||||
},
|
||||
newField: func() protoreflect.Value {
|
||||
lazyInit()
|
||||
return protoreflect.ValueOfMessage(messageType.New())
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func fieldInfoForMessage(fd protoreflect.FieldDescriptor, fs reflect.StructField, x exporter) fieldInfo {
|
||||
ft := fs.Type
|
||||
conv := NewConverter(ft, fd)
|
||||
|
|
|
|||
1
vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
generated
vendored
1
vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
generated
vendored
|
|
@ -111,7 +111,6 @@ func (p pointer) StringSlice() *[]string { return (*[]string)(p.p
|
|||
func (p pointer) Bytes() *[]byte { return (*[]byte)(p.p) }
|
||||
func (p pointer) BytesPtr() **[]byte { return (**[]byte)(p.p) }
|
||||
func (p pointer) BytesSlice() *[][]byte { return (*[][]byte)(p.p) }
|
||||
func (p pointer) WeakFields() *weakFields { return (*weakFields)(p.p) }
|
||||
func (p pointer) Extensions() *map[int32]ExtensionField { return (*map[int32]ExtensionField)(p.p) }
|
||||
func (p pointer) LazyInfoPtr() **protolazy.XXX_lazyUnmarshalInfo {
|
||||
return (**protolazy.XXX_lazyUnmarshalInfo)(p.p)
|
||||
|
|
|
|||
3
vendor/google.golang.org/protobuf/internal/impl/presence.go
generated
vendored
3
vendor/google.golang.org/protobuf/internal/impl/presence.go
generated
vendored
|
|
@ -32,9 +32,6 @@ func (p presence) toElem(num uint32) (ret *uint32) {
|
|||
|
||||
// Present checks for the presence of a specific field number in a presence set.
|
||||
func (p presence) Present(num uint32) bool {
|
||||
if p.P == nil {
|
||||
return false
|
||||
}
|
||||
return Export{}.Present(p.toElem(num), num)
|
||||
}
|
||||
|
||||
|
|
|
|||
24
vendor/google.golang.org/protobuf/internal/impl/validate.go
generated
vendored
24
vendor/google.golang.org/protobuf/internal/impl/validate.go
generated
vendored
|
|
@ -211,9 +211,7 @@ func newValidationInfo(fd protoreflect.FieldDescriptor, ft reflect.Type) validat
|
|||
switch fd.Kind() {
|
||||
case protoreflect.MessageKind:
|
||||
vi.typ = validationTypeMessage
|
||||
if !fd.IsWeak() {
|
||||
vi.mi = getMessageInfo(ft)
|
||||
}
|
||||
vi.mi = getMessageInfo(ft)
|
||||
case protoreflect.GroupKind:
|
||||
vi.typ = validationTypeGroup
|
||||
vi.mi = getMessageInfo(ft)
|
||||
|
|
@ -320,26 +318,6 @@ State:
|
|||
}
|
||||
if f != nil {
|
||||
vi = f.validation
|
||||
if vi.typ == validationTypeMessage && vi.mi == nil {
|
||||
// Probable weak field.
|
||||
//
|
||||
// TODO: Consider storing the results of this lookup somewhere
|
||||
// rather than recomputing it on every validation.
|
||||
fd := st.mi.Desc.Fields().ByNumber(num)
|
||||
if fd == nil || !fd.IsWeak() {
|
||||
break
|
||||
}
|
||||
messageName := fd.Message().FullName()
|
||||
messageType, err := protoregistry.GlobalTypes.FindMessageByName(messageName)
|
||||
switch err {
|
||||
case nil:
|
||||
vi.mi, _ = messageType.(*MessageInfo)
|
||||
case protoregistry.NotFound:
|
||||
vi.typ = validationTypeBytes
|
||||
default:
|
||||
return out, ValidationUnknown
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
// Possible extension field.
|
||||
|
|
|
|||
74
vendor/google.golang.org/protobuf/internal/impl/weak.go
generated
vendored
74
vendor/google.golang.org/protobuf/internal/impl/weak.go
generated
vendored
|
|
@ -1,74 +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.
|
||||
|
||||
package impl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// weakFields adds methods to the exported WeakFields type for internal use.
|
||||
//
|
||||
// The exported type is an alias to an unnamed type, so methods can't be
|
||||
// defined directly on it.
|
||||
type weakFields WeakFields
|
||||
|
||||
func (w weakFields) get(num protoreflect.FieldNumber) (protoreflect.ProtoMessage, bool) {
|
||||
m, ok := w[int32(num)]
|
||||
return m, ok
|
||||
}
|
||||
|
||||
func (w *weakFields) set(num protoreflect.FieldNumber, m protoreflect.ProtoMessage) {
|
||||
if *w == nil {
|
||||
*w = make(weakFields)
|
||||
}
|
||||
(*w)[int32(num)] = m
|
||||
}
|
||||
|
||||
func (w *weakFields) clear(num protoreflect.FieldNumber) {
|
||||
delete(*w, int32(num))
|
||||
}
|
||||
|
||||
func (Export) HasWeak(w WeakFields, num protoreflect.FieldNumber) bool {
|
||||
_, ok := w[int32(num)]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (Export) ClearWeak(w *WeakFields, num protoreflect.FieldNumber) {
|
||||
delete(*w, int32(num))
|
||||
}
|
||||
|
||||
func (Export) GetWeak(w WeakFields, num protoreflect.FieldNumber, name protoreflect.FullName) protoreflect.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 protoreflect.FieldNumber, name protoreflect.FullName, m protoreflect.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,8 +2,6 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build go1.21
|
||||
|
||||
package strs
|
||||
|
||||
import (
|
||||
94
vendor/google.golang.org/protobuf/internal/strs/strings_unsafe_go120.go
generated
vendored
94
vendor/google.golang.org/protobuf/internal/strs/strings_unsafe_go120.go
generated
vendored
|
|
@ -1,94 +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 !go1.21
|
||||
|
||||
package strs
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
type (
|
||||
stringHeader struct {
|
||||
Data unsafe.Pointer
|
||||
Len int
|
||||
}
|
||||
sliceHeader struct {
|
||||
Data unsafe.Pointer
|
||||
Len int
|
||||
Cap int
|
||||
}
|
||||
)
|
||||
|
||||
// UnsafeString returns an unsafe string reference of b.
|
||||
// The caller must treat the input slice as immutable.
|
||||
//
|
||||
// WARNING: Use carefully. The returned result must not leak to the end user
|
||||
// unless the input slice is provably immutable.
|
||||
func UnsafeString(b []byte) (s string) {
|
||||
src := (*sliceHeader)(unsafe.Pointer(&b))
|
||||
dst := (*stringHeader)(unsafe.Pointer(&s))
|
||||
dst.Data = src.Data
|
||||
dst.Len = src.Len
|
||||
return s
|
||||
}
|
||||
|
||||
// UnsafeBytes returns an unsafe bytes slice reference of s.
|
||||
// The caller must treat returned slice as immutable.
|
||||
//
|
||||
// WARNING: Use carefully. The returned result must not leak to the end user.
|
||||
func UnsafeBytes(s string) (b []byte) {
|
||||
src := (*stringHeader)(unsafe.Pointer(&s))
|
||||
dst := (*sliceHeader)(unsafe.Pointer(&b))
|
||||
dst.Data = src.Data
|
||||
dst.Len = src.Len
|
||||
dst.Cap = src.Len
|
||||
return b
|
||||
}
|
||||
|
||||
// Builder builds a set of strings with shared lifetime.
|
||||
// This differs from strings.Builder, which is for building a single string.
|
||||
type Builder struct {
|
||||
buf []byte
|
||||
}
|
||||
|
||||
// AppendFullName is equivalent to protoreflect.FullName.Append,
|
||||
// but optimized for large batches where each name has a shared lifetime.
|
||||
func (sb *Builder) AppendFullName(prefix protoreflect.FullName, name protoreflect.Name) protoreflect.FullName {
|
||||
n := len(prefix) + len(".") + len(name)
|
||||
if len(prefix) == 0 {
|
||||
n -= len(".")
|
||||
}
|
||||
sb.grow(n)
|
||||
sb.buf = append(sb.buf, prefix...)
|
||||
sb.buf = append(sb.buf, '.')
|
||||
sb.buf = append(sb.buf, name...)
|
||||
return protoreflect.FullName(sb.last(n))
|
||||
}
|
||||
|
||||
// MakeString is equivalent to string(b), but optimized for large batches
|
||||
// with a shared lifetime.
|
||||
func (sb *Builder) MakeString(b []byte) string {
|
||||
sb.grow(len(b))
|
||||
sb.buf = append(sb.buf, b...)
|
||||
return sb.last(len(b))
|
||||
}
|
||||
|
||||
func (sb *Builder) grow(n int) {
|
||||
if cap(sb.buf)-len(sb.buf) >= n {
|
||||
return
|
||||
}
|
||||
|
||||
// Unlike strings.Builder, we do not need to copy over the contents
|
||||
// of the old buffer since our builder provides no API for
|
||||
// retrieving previously created strings.
|
||||
sb.buf = make([]byte, 0, 2*(cap(sb.buf)+n))
|
||||
}
|
||||
|
||||
func (sb *Builder) last(n int) string {
|
||||
return UnsafeString(sb.buf[len(sb.buf)-n:])
|
||||
}
|
||||
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 (
|
|||
const (
|
||||
Major = 1
|
||||
Minor = 36
|
||||
Patch = 3
|
||||
Patch = 10
|
||||
PreRelease = ""
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue