mirror of
https://github.com/mudler/luet.git
synced 2025-09-15 14:48:55 +00:00
Use goreleaser to build and release (#244)
Instead of using gox on one side and an action to release, we can merge them together with goreleaser which will build for extra targets (arm, mips if needed in the future) and it also takes care of creating checksums, a source archive, and a changelog and creating a release with all the artifacts. All binaries should respect the old naming convention, so any scripts out there should still work. Signed-off-by: Itxaka <igarcia@suse.com>
This commit is contained in:
19
vendor/google.golang.org/protobuf/internal/filedesc/build.go
generated
vendored
19
vendor/google.golang.org/protobuf/internal/filedesc/build.go
generated
vendored
@@ -3,11 +3,14 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package filedesc provides functionality for constructing descriptors.
|
||||
//
|
||||
// The types in this package implement interfaces in the protoreflect package
|
||||
// related to protobuf descripriptors.
|
||||
package filedesc
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/fieldnum"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||
@@ -126,24 +129,24 @@ func (db *Builder) unmarshalCounts(b []byte, isFile bool) {
|
||||
b = b[m:]
|
||||
if isFile {
|
||||
switch num {
|
||||
case fieldnum.FileDescriptorProto_EnumType:
|
||||
case genid.FileDescriptorProto_EnumType_field_number:
|
||||
db.NumEnums++
|
||||
case fieldnum.FileDescriptorProto_MessageType:
|
||||
case genid.FileDescriptorProto_MessageType_field_number:
|
||||
db.unmarshalCounts(v, false)
|
||||
db.NumMessages++
|
||||
case fieldnum.FileDescriptorProto_Extension:
|
||||
case genid.FileDescriptorProto_Extension_field_number:
|
||||
db.NumExtensions++
|
||||
case fieldnum.FileDescriptorProto_Service:
|
||||
case genid.FileDescriptorProto_Service_field_number:
|
||||
db.NumServices++
|
||||
}
|
||||
} else {
|
||||
switch num {
|
||||
case fieldnum.DescriptorProto_EnumType:
|
||||
case genid.DescriptorProto_EnumType_field_number:
|
||||
db.NumEnums++
|
||||
case fieldnum.DescriptorProto_NestedType:
|
||||
case genid.DescriptorProto_NestedType_field_number:
|
||||
db.unmarshalCounts(v, false)
|
||||
db.NumMessages++
|
||||
case fieldnum.DescriptorProto_Extension:
|
||||
case genid.DescriptorProto_Extension_field_number:
|
||||
db.NumExtensions++
|
||||
}
|
||||
}
|
||||
|
82
vendor/google.golang.org/protobuf/internal/filedesc/desc.go
generated
vendored
82
vendor/google.golang.org/protobuf/internal/filedesc/desc.go
generated
vendored
@@ -13,6 +13,8 @@ import (
|
||||
"google.golang.org/protobuf/internal/descfmt"
|
||||
"google.golang.org/protobuf/internal/descopts"
|
||||
"google.golang.org/protobuf/internal/encoding/defval"
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
@@ -98,15 +100,6 @@ func (fd *File) lazyInitOnce() {
|
||||
fd.mu.Unlock()
|
||||
}
|
||||
|
||||
// ProtoLegacyRawDesc is a pseudo-internal API for allowing the v1 code
|
||||
// to be able to retrieve the raw descriptor.
|
||||
//
|
||||
// WARNING: This method is exempt from the compatibility promise and may be
|
||||
// removed in the future without warning.
|
||||
func (fd *File) ProtoLegacyRawDesc() []byte {
|
||||
return fd.builder.RawDescriptor
|
||||
}
|
||||
|
||||
// GoPackagePath is a pseudo-internal API for determining the Go package path
|
||||
// that this file descriptor is declared in.
|
||||
//
|
||||
@@ -206,7 +199,7 @@ type (
|
||||
Number pref.FieldNumber
|
||||
Cardinality pref.Cardinality // must be consistent with Message.RequiredNumbers
|
||||
Kind pref.Kind
|
||||
JSONName jsonName
|
||||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsWeak bool // promoted from google.protobuf.FieldOptions
|
||||
HasPacked bool // promoted from google.protobuf.FieldOptions
|
||||
@@ -276,8 +269,9 @@ func (fd *Field) Options() pref.ProtoMessage {
|
||||
func (fd *Field) Number() pref.FieldNumber { return fd.L1.Number }
|
||||
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) HasJSONName() bool { return fd.L1.StringName.hasJSON }
|
||||
func (fd *Field) JSONName() string { return fd.L1.StringName.getJSON(fd) }
|
||||
func (fd *Field) TextName() string { return fd.L1.StringName.getText(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)
|
||||
}
|
||||
@@ -302,13 +296,13 @@ func (fd *Field) MapKey() pref.FieldDescriptor {
|
||||
if !fd.IsMap() {
|
||||
return nil
|
||||
}
|
||||
return fd.Message().Fields().ByNumber(1)
|
||||
return fd.Message().Fields().ByNumber(genid.MapEntry_Key_field_number)
|
||||
}
|
||||
func (fd *Field) MapValue() pref.FieldDescriptor {
|
||||
if !fd.IsMap() {
|
||||
return nil
|
||||
}
|
||||
return fd.Message().Fields().ByNumber(2)
|
||||
return fd.Message().Fields().ByNumber(genid.MapEntry_Value_field_number)
|
||||
}
|
||||
func (fd *Field) HasDefault() bool { return fd.L1.Default.has }
|
||||
func (fd *Field) Default() pref.Value { return fd.L1.Default.get(fd) }
|
||||
@@ -372,7 +366,7 @@ type (
|
||||
}
|
||||
ExtensionL2 struct {
|
||||
Options func() pref.ProtoMessage
|
||||
JSONName jsonName
|
||||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsPacked bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
@@ -390,8 +384,9 @@ func (xd *Extension) Options() pref.ProtoMessage {
|
||||
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) HasJSONName() bool { return xd.lazyInit().StringName.hasJSON }
|
||||
func (xd *Extension) JSONName() string { return xd.lazyInit().StringName.getJSON(xd) }
|
||||
func (xd *Extension) TextName() string { return xd.lazyInit().StringName.getText(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
|
||||
@@ -505,27 +500,50 @@ func (d *Base) Syntax() pref.Syntax { return d.L0.ParentFile.Syn
|
||||
func (d *Base) IsPlaceholder() bool { return false }
|
||||
func (d *Base) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
type jsonName struct {
|
||||
has bool
|
||||
once sync.Once
|
||||
name string
|
||||
type stringName struct {
|
||||
hasJSON bool
|
||||
once sync.Once
|
||||
nameJSON string
|
||||
nameText string
|
||||
}
|
||||
|
||||
// Init initializes the name. It is exported for use by other internal packages.
|
||||
func (js *jsonName) Init(s string) {
|
||||
js.has = true
|
||||
js.name = s
|
||||
// InitJSON initializes the name. It is exported for use by other internal packages.
|
||||
func (s *stringName) InitJSON(name string) {
|
||||
s.hasJSON = true
|
||||
s.nameJSON = name
|
||||
}
|
||||
|
||||
func (js *jsonName) get(fd pref.FieldDescriptor) string {
|
||||
if !js.has {
|
||||
js.once.Do(func() {
|
||||
js.name = strs.JSONCamelCase(string(fd.Name()))
|
||||
})
|
||||
}
|
||||
return js.name
|
||||
func (s *stringName) lazyInit(fd pref.FieldDescriptor) *stringName {
|
||||
s.once.Do(func() {
|
||||
if fd.IsExtension() {
|
||||
// For extensions, JSON and text are formatted the same way.
|
||||
var name string
|
||||
if messageset.IsMessageSetExtension(fd) {
|
||||
name = string("[" + fd.FullName().Parent() + "]")
|
||||
} else {
|
||||
name = string("[" + fd.FullName() + "]")
|
||||
}
|
||||
s.nameJSON = name
|
||||
s.nameText = name
|
||||
} else {
|
||||
// Format the JSON name.
|
||||
if !s.hasJSON {
|
||||
s.nameJSON = strs.JSONCamelCase(string(fd.Name()))
|
||||
}
|
||||
|
||||
// Format the text name.
|
||||
s.nameText = string(fd.Name())
|
||||
if fd.Kind() == pref.GroupKind {
|
||||
s.nameText = string(fd.Message().Name())
|
||||
}
|
||||
}
|
||||
})
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *stringName) getJSON(fd pref.FieldDescriptor) string { return s.lazyInit(fd).nameJSON }
|
||||
func (s *stringName) getText(fd pref.FieldDescriptor) string { return s.lazyInit(fd).nameText }
|
||||
|
||||
func DefaultValue(v pref.Value, ev pref.EnumValueDescriptor) defaultValue {
|
||||
dv := defaultValue{has: v.IsValid(), val: v, enum: ev}
|
||||
if b, ok := v.Interface().([]byte); ok {
|
||||
|
62
vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go
generated
vendored
62
vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go
generated
vendored
@@ -8,7 +8,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/fieldnum"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
@@ -107,7 +107,7 @@ func (fd *File) unmarshalSeed(b []byte) {
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FileDescriptorProto_Syntax:
|
||||
case genid.FileDescriptorProto_Syntax_field_number:
|
||||
switch string(v) {
|
||||
case "proto2":
|
||||
fd.L1.Syntax = pref.Proto2
|
||||
@@ -116,36 +116,36 @@ func (fd *File) unmarshalSeed(b []byte) {
|
||||
default:
|
||||
panic("invalid syntax")
|
||||
}
|
||||
case fieldnum.FileDescriptorProto_Name:
|
||||
case genid.FileDescriptorProto_Name_field_number:
|
||||
fd.L1.Path = sb.MakeString(v)
|
||||
case fieldnum.FileDescriptorProto_Package:
|
||||
case genid.FileDescriptorProto_Package_field_number:
|
||||
fd.L1.Package = pref.FullName(sb.MakeString(v))
|
||||
case fieldnum.FileDescriptorProto_EnumType:
|
||||
if prevField != fieldnum.FileDescriptorProto_EnumType {
|
||||
case genid.FileDescriptorProto_EnumType_field_number:
|
||||
if prevField != genid.FileDescriptorProto_EnumType_field_number {
|
||||
if numEnums > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
posEnums = len(b0) - len(b) - n - m
|
||||
}
|
||||
numEnums++
|
||||
case fieldnum.FileDescriptorProto_MessageType:
|
||||
if prevField != fieldnum.FileDescriptorProto_MessageType {
|
||||
case genid.FileDescriptorProto_MessageType_field_number:
|
||||
if prevField != genid.FileDescriptorProto_MessageType_field_number {
|
||||
if numMessages > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
posMessages = len(b0) - len(b) - n - m
|
||||
}
|
||||
numMessages++
|
||||
case fieldnum.FileDescriptorProto_Extension:
|
||||
if prevField != fieldnum.FileDescriptorProto_Extension {
|
||||
case genid.FileDescriptorProto_Extension_field_number:
|
||||
if prevField != genid.FileDescriptorProto_Extension_field_number {
|
||||
if numExtensions > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
posExtensions = len(b0) - len(b) - n - m
|
||||
}
|
||||
numExtensions++
|
||||
case fieldnum.FileDescriptorProto_Service:
|
||||
if prevField != fieldnum.FileDescriptorProto_Service {
|
||||
case genid.FileDescriptorProto_Service_field_number:
|
||||
if prevField != genid.FileDescriptorProto_Service_field_number {
|
||||
if numServices > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
@@ -233,9 +233,9 @@ func (ed *Enum) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.Desc
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.EnumDescriptorProto_Name:
|
||||
case genid.EnumDescriptorProto_Name_field_number:
|
||||
ed.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case fieldnum.EnumDescriptorProto_Value:
|
||||
case genid.EnumDescriptorProto_Value_field_number:
|
||||
numValues++
|
||||
}
|
||||
default:
|
||||
@@ -260,7 +260,7 @@ func (ed *Enum) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.Desc
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.EnumDescriptorProto_Value:
|
||||
case genid.EnumDescriptorProto_Value_field_number:
|
||||
ed.L2.Values.List[i].unmarshalFull(v, sb, pf, ed, i)
|
||||
i++
|
||||
}
|
||||
@@ -288,33 +288,33 @@ func (md *Message) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.D
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.DescriptorProto_Name:
|
||||
case genid.DescriptorProto_Name_field_number:
|
||||
md.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case fieldnum.DescriptorProto_EnumType:
|
||||
if prevField != fieldnum.DescriptorProto_EnumType {
|
||||
case genid.DescriptorProto_EnumType_field_number:
|
||||
if prevField != genid.DescriptorProto_EnumType_field_number {
|
||||
if numEnums > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
posEnums = len(b0) - len(b) - n - m
|
||||
}
|
||||
numEnums++
|
||||
case fieldnum.DescriptorProto_NestedType:
|
||||
if prevField != fieldnum.DescriptorProto_NestedType {
|
||||
case genid.DescriptorProto_NestedType_field_number:
|
||||
if prevField != genid.DescriptorProto_NestedType_field_number {
|
||||
if numMessages > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
posMessages = len(b0) - len(b) - n - m
|
||||
}
|
||||
numMessages++
|
||||
case fieldnum.DescriptorProto_Extension:
|
||||
if prevField != fieldnum.DescriptorProto_Extension {
|
||||
case genid.DescriptorProto_Extension_field_number:
|
||||
if prevField != genid.DescriptorProto_Extension_field_number {
|
||||
if numExtensions > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
posExtensions = len(b0) - len(b) - n - m
|
||||
}
|
||||
numExtensions++
|
||||
case fieldnum.DescriptorProto_Options:
|
||||
case genid.DescriptorProto_Options_field_number:
|
||||
md.unmarshalSeedOptions(v)
|
||||
}
|
||||
prevField = num
|
||||
@@ -375,9 +375,9 @@ func (md *Message) unmarshalSeedOptions(b []byte) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.MessageOptions_MapEntry:
|
||||
case genid.MessageOptions_MapEntry_field_number:
|
||||
md.L1.IsMapEntry = protowire.DecodeBool(v)
|
||||
case fieldnum.MessageOptions_MessageSetWireFormat:
|
||||
case genid.MessageOptions_MessageSetWireFormat_field_number:
|
||||
md.L1.IsMessageSet = protowire.DecodeBool(v)
|
||||
}
|
||||
default:
|
||||
@@ -400,20 +400,20 @@ func (xd *Extension) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldDescriptorProto_Number:
|
||||
case genid.FieldDescriptorProto_Number_field_number:
|
||||
xd.L1.Number = pref.FieldNumber(v)
|
||||
case fieldnum.FieldDescriptorProto_Label:
|
||||
case genid.FieldDescriptorProto_Label_field_number:
|
||||
xd.L1.Cardinality = pref.Cardinality(v)
|
||||
case fieldnum.FieldDescriptorProto_Type:
|
||||
case genid.FieldDescriptorProto_Type_field_number:
|
||||
xd.L1.Kind = pref.Kind(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldDescriptorProto_Name:
|
||||
case genid.FieldDescriptorProto_Name_field_number:
|
||||
xd.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case fieldnum.FieldDescriptorProto_Extendee:
|
||||
case genid.FieldDescriptorProto_Extendee_field_number:
|
||||
xd.L1.Extendee = PlaceholderMessage(makeFullName(sb, v))
|
||||
}
|
||||
default:
|
||||
@@ -436,7 +436,7 @@ func (sd *Service) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.D
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.ServiceDescriptorProto_Name:
|
||||
case genid.ServiceDescriptorProto_Name_field_number:
|
||||
sd.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
}
|
||||
default:
|
||||
|
128
vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
generated
vendored
128
vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
generated
vendored
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/descopts"
|
||||
"google.golang.org/protobuf/internal/fieldnum"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/proto"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
@@ -143,35 +143,35 @@ func (fd *File) unmarshalFull(b []byte) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FileDescriptorProto_PublicDependency:
|
||||
case genid.FileDescriptorProto_PublicDependency_field_number:
|
||||
fd.L2.Imports[v].IsPublic = true
|
||||
case fieldnum.FileDescriptorProto_WeakDependency:
|
||||
case genid.FileDescriptorProto_WeakDependency_field_number:
|
||||
fd.L2.Imports[v].IsWeak = true
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FileDescriptorProto_Dependency:
|
||||
case genid.FileDescriptorProto_Dependency_field_number:
|
||||
path := sb.MakeString(v)
|
||||
imp, _ := fd.builder.FileRegistry.FindFileByPath(path)
|
||||
if imp == nil {
|
||||
imp = PlaceholderFile(path)
|
||||
}
|
||||
fd.L2.Imports = append(fd.L2.Imports, pref.FileImport{FileDescriptor: imp})
|
||||
case fieldnum.FileDescriptorProto_EnumType:
|
||||
case genid.FileDescriptorProto_EnumType_field_number:
|
||||
fd.L1.Enums.List[enumIdx].unmarshalFull(v, sb)
|
||||
enumIdx++
|
||||
case fieldnum.FileDescriptorProto_MessageType:
|
||||
case genid.FileDescriptorProto_MessageType_field_number:
|
||||
fd.L1.Messages.List[messageIdx].unmarshalFull(v, sb)
|
||||
messageIdx++
|
||||
case fieldnum.FileDescriptorProto_Extension:
|
||||
case genid.FileDescriptorProto_Extension_field_number:
|
||||
fd.L1.Extensions.List[extensionIdx].unmarshalFull(v, sb)
|
||||
extensionIdx++
|
||||
case fieldnum.FileDescriptorProto_Service:
|
||||
case genid.FileDescriptorProto_Service_field_number:
|
||||
fd.L1.Services.List[serviceIdx].unmarshalFull(v, sb)
|
||||
serviceIdx++
|
||||
case fieldnum.FileDescriptorProto_Options:
|
||||
case genid.FileDescriptorProto_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
@@ -196,13 +196,13 @@ func (ed *Enum) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.EnumDescriptorProto_Value:
|
||||
case genid.EnumDescriptorProto_Value_field_number:
|
||||
rawValues = append(rawValues, v)
|
||||
case fieldnum.EnumDescriptorProto_ReservedName:
|
||||
case genid.EnumDescriptorProto_ReservedName_field_number:
|
||||
ed.L2.ReservedNames.List = append(ed.L2.ReservedNames.List, pref.Name(sb.MakeString(v)))
|
||||
case fieldnum.EnumDescriptorProto_ReservedRange:
|
||||
case genid.EnumDescriptorProto_ReservedRange_field_number:
|
||||
ed.L2.ReservedRanges.List = append(ed.L2.ReservedRanges.List, unmarshalEnumReservedRange(v))
|
||||
case fieldnum.EnumDescriptorProto_Options:
|
||||
case genid.EnumDescriptorProto_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
@@ -228,9 +228,9 @@ func unmarshalEnumReservedRange(b []byte) (r [2]pref.EnumNumber) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.EnumDescriptorProto_EnumReservedRange_Start:
|
||||
case genid.EnumDescriptorProto_EnumReservedRange_Start_field_number:
|
||||
r[0] = pref.EnumNumber(v)
|
||||
case fieldnum.EnumDescriptorProto_EnumReservedRange_End:
|
||||
case genid.EnumDescriptorProto_EnumReservedRange_End_field_number:
|
||||
r[1] = pref.EnumNumber(v)
|
||||
}
|
||||
default:
|
||||
@@ -255,17 +255,17 @@ func (vd *EnumValue) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.EnumValueDescriptorProto_Number:
|
||||
case genid.EnumValueDescriptorProto_Number_field_number:
|
||||
vd.L1.Number = pref.EnumNumber(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.EnumValueDescriptorProto_Name:
|
||||
case genid.EnumValueDescriptorProto_Name_field_number:
|
||||
// NOTE: Enum values are in the same scope as the enum parent.
|
||||
vd.L0.FullName = appendFullName(sb, pd.Parent().FullName(), v)
|
||||
case fieldnum.EnumValueDescriptorProto_Options:
|
||||
case genid.EnumValueDescriptorProto_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
@@ -289,29 +289,29 @@ func (md *Message) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.DescriptorProto_Field:
|
||||
case genid.DescriptorProto_Field_field_number:
|
||||
rawFields = append(rawFields, v)
|
||||
case fieldnum.DescriptorProto_OneofDecl:
|
||||
case genid.DescriptorProto_OneofDecl_field_number:
|
||||
rawOneofs = append(rawOneofs, v)
|
||||
case fieldnum.DescriptorProto_ReservedName:
|
||||
case genid.DescriptorProto_ReservedName_field_number:
|
||||
md.L2.ReservedNames.List = append(md.L2.ReservedNames.List, pref.Name(sb.MakeString(v)))
|
||||
case fieldnum.DescriptorProto_ReservedRange:
|
||||
case genid.DescriptorProto_ReservedRange_field_number:
|
||||
md.L2.ReservedRanges.List = append(md.L2.ReservedRanges.List, unmarshalMessageReservedRange(v))
|
||||
case fieldnum.DescriptorProto_ExtensionRange:
|
||||
case genid.DescriptorProto_ExtensionRange_field_number:
|
||||
r, rawOptions := unmarshalMessageExtensionRange(v)
|
||||
opts := md.L0.ParentFile.builder.optionsUnmarshaler(&descopts.ExtensionRange, rawOptions)
|
||||
md.L2.ExtensionRanges.List = append(md.L2.ExtensionRanges.List, r)
|
||||
md.L2.ExtensionRangeOptions = append(md.L2.ExtensionRangeOptions, opts)
|
||||
case fieldnum.DescriptorProto_EnumType:
|
||||
case genid.DescriptorProto_EnumType_field_number:
|
||||
md.L1.Enums.List[enumIdx].unmarshalFull(v, sb)
|
||||
enumIdx++
|
||||
case fieldnum.DescriptorProto_NestedType:
|
||||
case genid.DescriptorProto_NestedType_field_number:
|
||||
md.L1.Messages.List[messageIdx].unmarshalFull(v, sb)
|
||||
messageIdx++
|
||||
case fieldnum.DescriptorProto_Extension:
|
||||
case genid.DescriptorProto_Extension_field_number:
|
||||
md.L1.Extensions.List[extensionIdx].unmarshalFull(v, sb)
|
||||
extensionIdx++
|
||||
case fieldnum.DescriptorProto_Options:
|
||||
case genid.DescriptorProto_Options_field_number:
|
||||
md.unmarshalOptions(v)
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
@@ -347,9 +347,9 @@ func (md *Message) unmarshalOptions(b []byte) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.MessageOptions_MapEntry:
|
||||
case genid.MessageOptions_MapEntry_field_number:
|
||||
md.L1.IsMapEntry = protowire.DecodeBool(v)
|
||||
case fieldnum.MessageOptions_MessageSetWireFormat:
|
||||
case genid.MessageOptions_MessageSetWireFormat_field_number:
|
||||
md.L1.IsMessageSet = protowire.DecodeBool(v)
|
||||
}
|
||||
default:
|
||||
@@ -368,9 +368,9 @@ func unmarshalMessageReservedRange(b []byte) (r [2]pref.FieldNumber) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.DescriptorProto_ReservedRange_Start:
|
||||
case genid.DescriptorProto_ReservedRange_Start_field_number:
|
||||
r[0] = pref.FieldNumber(v)
|
||||
case fieldnum.DescriptorProto_ReservedRange_End:
|
||||
case genid.DescriptorProto_ReservedRange_End_field_number:
|
||||
r[1] = pref.FieldNumber(v)
|
||||
}
|
||||
default:
|
||||
@@ -390,16 +390,16 @@ func unmarshalMessageExtensionRange(b []byte) (r [2]pref.FieldNumber, rawOptions
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.DescriptorProto_ExtensionRange_Start:
|
||||
case genid.DescriptorProto_ExtensionRange_Start_field_number:
|
||||
r[0] = pref.FieldNumber(v)
|
||||
case fieldnum.DescriptorProto_ExtensionRange_End:
|
||||
case genid.DescriptorProto_ExtensionRange_End_field_number:
|
||||
r[1] = pref.FieldNumber(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.DescriptorProto_ExtensionRange_Options:
|
||||
case genid.DescriptorProto_ExtensionRange_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
@@ -425,13 +425,13 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Des
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldDescriptorProto_Number:
|
||||
case genid.FieldDescriptorProto_Number_field_number:
|
||||
fd.L1.Number = pref.FieldNumber(v)
|
||||
case fieldnum.FieldDescriptorProto_Label:
|
||||
case genid.FieldDescriptorProto_Label_field_number:
|
||||
fd.L1.Cardinality = pref.Cardinality(v)
|
||||
case fieldnum.FieldDescriptorProto_Type:
|
||||
case genid.FieldDescriptorProto_Type_field_number:
|
||||
fd.L1.Kind = pref.Kind(v)
|
||||
case fieldnum.FieldDescriptorProto_OneofIndex:
|
||||
case genid.FieldDescriptorProto_OneofIndex_field_number:
|
||||
// In Message.unmarshalFull, we allocate slices for both
|
||||
// the field and oneof descriptors before unmarshaling either
|
||||
// of them. This ensures pointers to slice elements are stable.
|
||||
@@ -441,22 +441,22 @@ 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:
|
||||
case genid.FieldDescriptorProto_Proto3Optional_field_number:
|
||||
fd.L1.IsProto3Optional = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldDescriptorProto_Name:
|
||||
case genid.FieldDescriptorProto_Name_field_number:
|
||||
fd.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case fieldnum.FieldDescriptorProto_JsonName:
|
||||
fd.L1.JSONName.Init(sb.MakeString(v))
|
||||
case fieldnum.FieldDescriptorProto_DefaultValue:
|
||||
case genid.FieldDescriptorProto_JsonName_field_number:
|
||||
fd.L1.StringName.InitJSON(sb.MakeString(v))
|
||||
case genid.FieldDescriptorProto_DefaultValue_field_number:
|
||||
fd.L1.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveMessages
|
||||
case fieldnum.FieldDescriptorProto_TypeName:
|
||||
case genid.FieldDescriptorProto_TypeName_field_number:
|
||||
rawTypeName = v
|
||||
case fieldnum.FieldDescriptorProto_Options:
|
||||
case genid.FieldDescriptorProto_Options_field_number:
|
||||
fd.unmarshalOptions(v)
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
@@ -488,10 +488,10 @@ func (fd *Field) unmarshalOptions(b []byte) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldOptions_Packed:
|
||||
case genid.FieldOptions_Packed_field_number:
|
||||
fd.L1.HasPacked = true
|
||||
fd.L1.IsPacked = protowire.DecodeBool(v)
|
||||
case fieldnum.FieldOptions_Weak:
|
||||
case genid.FieldOptions_Weak_field_number:
|
||||
fd.L1.IsWeak = protowire.DecodeBool(v)
|
||||
case FieldOptions_EnforceUTF8:
|
||||
fd.L1.HasEnforceUTF8 = true
|
||||
@@ -518,9 +518,9 @@ func (od *Oneof) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Des
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.OneofDescriptorProto_Name:
|
||||
case genid.OneofDescriptorProto_Name_field_number:
|
||||
od.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case fieldnum.OneofDescriptorProto_Options:
|
||||
case genid.OneofDescriptorProto_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
@@ -543,20 +543,20 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldDescriptorProto_Proto3Optional:
|
||||
case genid.FieldDescriptorProto_Proto3Optional_field_number:
|
||||
xd.L2.IsProto3Optional = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldDescriptorProto_JsonName:
|
||||
xd.L2.JSONName.Init(sb.MakeString(v))
|
||||
case fieldnum.FieldDescriptorProto_DefaultValue:
|
||||
case genid.FieldDescriptorProto_JsonName_field_number:
|
||||
xd.L2.StringName.InitJSON(sb.MakeString(v))
|
||||
case genid.FieldDescriptorProto_DefaultValue_field_number:
|
||||
xd.L2.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveExtensions
|
||||
case fieldnum.FieldDescriptorProto_TypeName:
|
||||
case genid.FieldDescriptorProto_TypeName_field_number:
|
||||
rawTypeName = v
|
||||
case fieldnum.FieldDescriptorProto_Options:
|
||||
case genid.FieldDescriptorProto_Options_field_number:
|
||||
xd.unmarshalOptions(v)
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
@@ -586,7 +586,7 @@ func (xd *Extension) unmarshalOptions(b []byte) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldOptions_Packed:
|
||||
case genid.FieldOptions_Packed_field_number:
|
||||
xd.L2.IsPacked = protowire.DecodeBool(v)
|
||||
}
|
||||
default:
|
||||
@@ -608,9 +608,9 @@ func (sd *Service) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.ServiceDescriptorProto_Method:
|
||||
case genid.ServiceDescriptorProto_Method_field_number:
|
||||
rawMethods = append(rawMethods, v)
|
||||
case fieldnum.ServiceDescriptorProto_Options:
|
||||
case genid.ServiceDescriptorProto_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
@@ -641,22 +641,22 @@ func (md *Method) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.De
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.MethodDescriptorProto_ClientStreaming:
|
||||
case genid.MethodDescriptorProto_ClientStreaming_field_number:
|
||||
md.L1.IsStreamingClient = protowire.DecodeBool(v)
|
||||
case fieldnum.MethodDescriptorProto_ServerStreaming:
|
||||
case genid.MethodDescriptorProto_ServerStreaming_field_number:
|
||||
md.L1.IsStreamingServer = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.MethodDescriptorProto_Name:
|
||||
case genid.MethodDescriptorProto_Name_field_number:
|
||||
md.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case fieldnum.MethodDescriptorProto_InputType:
|
||||
case genid.MethodDescriptorProto_InputType_field_number:
|
||||
md.L1.Input = PlaceholderMessage(makeFullName(sb, v))
|
||||
case fieldnum.MethodDescriptorProto_OutputType:
|
||||
case genid.MethodDescriptorProto_OutputType_field_number:
|
||||
md.L1.Output = PlaceholderMessage(makeFullName(sb, v))
|
||||
case fieldnum.MethodDescriptorProto_Options:
|
||||
case genid.MethodDescriptorProto_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
|
176
vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go
generated
vendored
176
vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go
generated
vendored
@@ -10,6 +10,8 @@ import (
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/descfmt"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
@@ -185,10 +187,7 @@ func (p *FieldRanges) CheckValid(isMessageSet bool) error {
|
||||
// Unlike the FieldNumber.IsValid method, it allows ranges that cover the
|
||||
// reserved number range.
|
||||
func isValidFieldNumber(n protoreflect.FieldNumber, isMessageSet bool) bool {
|
||||
if isMessageSet {
|
||||
return protowire.MinValidNumber <= n && n <= math.MaxInt32
|
||||
}
|
||||
return protowire.MinValidNumber <= n && n <= protowire.MaxValidNumber
|
||||
return protowire.MinValidNumber <= n && (n <= protowire.MaxValidNumber || isMessageSet)
|
||||
}
|
||||
|
||||
// CheckOverlap reports an error if p and q overlap.
|
||||
@@ -249,6 +248,7 @@ type OneofFields struct {
|
||||
once sync.Once
|
||||
byName map[pref.Name]pref.FieldDescriptor // protected by once
|
||||
byJSON map[string]pref.FieldDescriptor // protected by once
|
||||
byText map[string]pref.FieldDescriptor // protected by once
|
||||
byNum map[pref.FieldNumber]pref.FieldDescriptor // protected by once
|
||||
}
|
||||
|
||||
@@ -256,6 +256,7 @@ func (p *OneofFields) Len() int { return
|
||||
func (p *OneofFields) Get(i int) pref.FieldDescriptor { return p.List[i] }
|
||||
func (p *OneofFields) ByName(s pref.Name) pref.FieldDescriptor { return p.lazyInit().byName[s] }
|
||||
func (p *OneofFields) ByJSONName(s string) pref.FieldDescriptor { return p.lazyInit().byJSON[s] }
|
||||
func (p *OneofFields) ByTextName(s string) pref.FieldDescriptor { return p.lazyInit().byText[s] }
|
||||
func (p *OneofFields) ByNumber(n pref.FieldNumber) pref.FieldDescriptor { return p.lazyInit().byNum[n] }
|
||||
func (p *OneofFields) Format(s fmt.State, r rune) { descfmt.FormatList(s, r, p) }
|
||||
func (p *OneofFields) ProtoInternal(pragma.DoNotImplement) {}
|
||||
@@ -265,11 +266,13 @@ func (p *OneofFields) lazyInit() *OneofFields {
|
||||
if len(p.List) > 0 {
|
||||
p.byName = make(map[pref.Name]pref.FieldDescriptor, len(p.List))
|
||||
p.byJSON = make(map[string]pref.FieldDescriptor, len(p.List))
|
||||
p.byText = make(map[string]pref.FieldDescriptor, len(p.List))
|
||||
p.byNum = make(map[pref.FieldNumber]pref.FieldDescriptor, len(p.List))
|
||||
for _, f := range p.List {
|
||||
// Field names and numbers are guaranteed to be unique.
|
||||
p.byName[f.Name()] = f
|
||||
p.byJSON[f.JSONName()] = f
|
||||
p.byText[f.TextName()] = f
|
||||
p.byNum[f.Number()] = f
|
||||
}
|
||||
}
|
||||
@@ -278,9 +281,170 @@ func (p *OneofFields) lazyInit() *OneofFields {
|
||||
}
|
||||
|
||||
type SourceLocations struct {
|
||||
// List is a list of SourceLocations.
|
||||
// The SourceLocation.Next field does not need to be populated
|
||||
// as it will be lazily populated upon first need.
|
||||
List []pref.SourceLocation
|
||||
|
||||
// File is the parent file descriptor that these locations are relative to.
|
||||
// If non-nil, ByDescriptor verifies that the provided descriptor
|
||||
// is a child of this file descriptor.
|
||||
File pref.FileDescriptor
|
||||
|
||||
once sync.Once
|
||||
byPath map[pathKey]int
|
||||
}
|
||||
|
||||
func (p *SourceLocations) Len() int { return len(p.List) }
|
||||
func (p *SourceLocations) Get(i int) pref.SourceLocation { return p.List[i] }
|
||||
func (p *SourceLocations) Len() int { return len(p.List) }
|
||||
func (p *SourceLocations) Get(i int) pref.SourceLocation { return p.lazyInit().List[i] }
|
||||
func (p *SourceLocations) byKey(k pathKey) pref.SourceLocation {
|
||||
if i, ok := p.lazyInit().byPath[k]; ok {
|
||||
return p.List[i]
|
||||
}
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
func (p *SourceLocations) ByPath(path pref.SourcePath) pref.SourceLocation {
|
||||
return p.byKey(newPathKey(path))
|
||||
}
|
||||
func (p *SourceLocations) ByDescriptor(desc pref.Descriptor) pref.SourceLocation {
|
||||
if p.File != nil && desc != nil && p.File != desc.ParentFile() {
|
||||
return pref.SourceLocation{} // mismatching parent files
|
||||
}
|
||||
var pathArr [16]int32
|
||||
path := pathArr[:0]
|
||||
for {
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
// Reverse the path since it was constructed in reverse.
|
||||
for i, j := 0, len(path)-1; i < j; i, j = i+1, j-1 {
|
||||
path[i], path[j] = path[j], path[i]
|
||||
}
|
||||
return p.byKey(newPathKey(path))
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_MessageType_field_number))
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_NestedType_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.FieldDescriptor:
|
||||
isExtension := desc.(pref.FieldDescriptor).IsExtension()
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
if isExtension {
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_Extension_field_number))
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_Extension_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
} else {
|
||||
switch desc.(type) {
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_Field_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
}
|
||||
case pref.OneofDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_OneofDecl_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.EnumDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_EnumType_field_number))
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_EnumType_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.EnumValueDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.EnumDescriptor:
|
||||
path = append(path, int32(genid.EnumDescriptorProto_Value_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.ServiceDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_Service_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.MethodDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.ServiceDescriptor:
|
||||
path = append(path, int32(genid.ServiceDescriptorProto_Method_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
}
|
||||
}
|
||||
func (p *SourceLocations) lazyInit() *SourceLocations {
|
||||
p.once.Do(func() {
|
||||
if len(p.List) > 0 {
|
||||
// Collect all the indexes for a given path.
|
||||
pathIdxs := make(map[pathKey][]int, len(p.List))
|
||||
for i, l := range p.List {
|
||||
k := newPathKey(l.Path)
|
||||
pathIdxs[k] = append(pathIdxs[k], i)
|
||||
}
|
||||
|
||||
// Update the next index for all locations.
|
||||
p.byPath = make(map[pathKey]int, len(p.List))
|
||||
for k, idxs := range pathIdxs {
|
||||
for i := 0; i < len(idxs)-1; i++ {
|
||||
p.List[idxs[i]].Next = idxs[i+1]
|
||||
}
|
||||
p.List[idxs[len(idxs)-1]].Next = 0
|
||||
p.byPath[k] = idxs[0] // record the first location for this path
|
||||
}
|
||||
}
|
||||
})
|
||||
return p
|
||||
}
|
||||
func (p *SourceLocations) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
// pathKey is a comparable representation of protoreflect.SourcePath.
|
||||
type pathKey struct {
|
||||
arr [16]uint8 // first n-1 path segments; last element is the length
|
||||
str string // used if the path does not fit in arr
|
||||
}
|
||||
|
||||
func newPathKey(p pref.SourcePath) (k pathKey) {
|
||||
if len(p) < len(k.arr) {
|
||||
for i, ps := range p {
|
||||
if ps < 0 || math.MaxUint8 <= ps {
|
||||
return pathKey{str: p.String()}
|
||||
}
|
||||
k.arr[i] = uint8(ps)
|
||||
}
|
||||
k.arr[len(k.arr)-1] = uint8(len(p))
|
||||
return k
|
||||
}
|
||||
return pathKey{str: p.String()}
|
||||
}
|
||||
|
11
vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go
generated
vendored
11
vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go
generated
vendored
@@ -142,6 +142,7 @@ type Fields struct {
|
||||
once sync.Once
|
||||
byName map[protoreflect.Name]*Field // protected by once
|
||||
byJSON map[string]*Field // protected by once
|
||||
byText map[string]*Field // protected by once
|
||||
byNum map[protoreflect.FieldNumber]*Field // protected by once
|
||||
}
|
||||
|
||||
@@ -163,6 +164,12 @@ func (p *Fields) ByJSONName(s string) protoreflect.FieldDescriptor {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (p *Fields) ByTextName(s string) protoreflect.FieldDescriptor {
|
||||
if d := p.lazyInit().byText[s]; d != nil {
|
||||
return d
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (p *Fields) ByNumber(n protoreflect.FieldNumber) protoreflect.FieldDescriptor {
|
||||
if d := p.lazyInit().byNum[n]; d != nil {
|
||||
return d
|
||||
@@ -178,6 +185,7 @@ func (p *Fields) lazyInit() *Fields {
|
||||
if len(p.List) > 0 {
|
||||
p.byName = make(map[protoreflect.Name]*Field, len(p.List))
|
||||
p.byJSON = make(map[string]*Field, len(p.List))
|
||||
p.byText = make(map[string]*Field, len(p.List))
|
||||
p.byNum = make(map[protoreflect.FieldNumber]*Field, len(p.List))
|
||||
for i := range p.List {
|
||||
d := &p.List[i]
|
||||
@@ -187,6 +195,9 @@ func (p *Fields) lazyInit() *Fields {
|
||||
if _, ok := p.byJSON[d.JSONName()]; !ok {
|
||||
p.byJSON[d.JSONName()] = d
|
||||
}
|
||||
if _, ok := p.byText[d.TextName()]; !ok {
|
||||
p.byText[d.TextName()] = d
|
||||
}
|
||||
if _, ok := p.byNum[d.Number()]; !ok {
|
||||
p.byNum[d.Number()] = d
|
||||
}
|
||||
|
Reference in New Issue
Block a user