package filedesc
import (
)
type FileImports []protoreflect.FileImport
func ( *FileImports) () int { return len(*) }
func ( *FileImports) ( int) protoreflect.FileImport { return (*)[] }
func ( *FileImports) ( fmt.State, rune) { descfmt.FormatList(, , ) }
func ( *FileImports) (pragma.DoNotImplement) {}
type Names struct {
List []protoreflect.Name
once sync.Once
has map[protoreflect.Name]int
}
func ( *Names) () int { return len(.List) }
func ( *Names) ( int) protoreflect.Name { return .List[] }
func ( *Names) ( protoreflect.Name) bool { return .lazyInit().has[] > 0 }
func ( *Names) ( fmt.State, rune) { descfmt.FormatList(, , ) }
func ( *Names) (pragma.DoNotImplement) {}
func ( *Names) () *Names {
.once.Do(func() {
if len(.List) > 0 {
.has = make(map[protoreflect.Name]int, len(.List))
for , := range .List {
.has[] = .has[] + 1
}
}
})
return
}
func ( *Names) () error {
for , := range .lazyInit().has {
switch {
case > 1:
return errors.New("duplicate name: %q", )
case false && !.IsValid():
return errors.New("invalid name: %q", )
}
}
return nil
}
type EnumRanges struct {
List [][2]protoreflect.EnumNumber
once sync.Once
sorted [][2]protoreflect.EnumNumber
}
func ( *EnumRanges) () int { return len(.List) }
func ( *EnumRanges) ( int) [2]protoreflect.EnumNumber { return .List[] }
func ( *EnumRanges) ( protoreflect.EnumNumber) bool {
for := .lazyInit().sorted; len() > 0; {
:= len() / 2
switch := enumRange([]); {
case < .Start():
= [:]
case > .End():
= [+1:]
default:
return true
}
}
return false
}
func ( *EnumRanges) ( fmt.State, rune) { descfmt.FormatList(, , ) }
func ( *EnumRanges) (pragma.DoNotImplement) {}
func ( *EnumRanges) () *EnumRanges {
.once.Do(func() {
.sorted = append(.sorted, .List...)
sort.Slice(.sorted, func(, int) bool {
return .sorted[][0] < .sorted[][0]
})
})
return
}
func ( *EnumRanges) () error {
var enumRange
for , := range .lazyInit().sorted {
:= enumRange()
switch {
case !(.Start() <= .End()):
return errors.New("invalid range: %v", )
case !(.End() < .Start()) && > 0:
return errors.New("overlapping ranges: %v with %v", , )
}
=
}
return nil
}
type enumRange [2]protoreflect.EnumNumber
func ( enumRange) () protoreflect.EnumNumber { return [0] }
func ( enumRange) () protoreflect.EnumNumber { return [1] }
func ( enumRange) () string {
if .Start() == .End() {
return fmt.Sprintf("%d", .Start())
}
return fmt.Sprintf("%d to %d", .Start(), .End())
}
type FieldRanges struct {
List [][2]protoreflect.FieldNumber
once sync.Once
sorted [][2]protoreflect.FieldNumber
}
func ( *FieldRanges) () int { return len(.List) }
func ( *FieldRanges) ( int) [2]protoreflect.FieldNumber { return .List[] }
func ( *FieldRanges) ( protoreflect.FieldNumber) bool {
for := .lazyInit().sorted; len() > 0; {
:= len() / 2
switch := fieldRange([]); {
case < .Start():
= [:]
case > .End():
= [+1:]
default:
return true
}
}
return false
}
func ( *FieldRanges) ( fmt.State, rune) { descfmt.FormatList(, , ) }
func ( *FieldRanges) (pragma.DoNotImplement) {}
func ( *FieldRanges) () *FieldRanges {
.once.Do(func() {
.sorted = append(.sorted, .List...)
sort.Slice(.sorted, func(, int) bool {
return .sorted[][0] < .sorted[][0]
})
})
return
}
func ( *FieldRanges) ( bool) error {
var fieldRange
for , := range .lazyInit().sorted {
:= fieldRange()
switch {
case !isValidFieldNumber(.Start(), ):
return errors.New("invalid field number: %d", .Start())
case !isValidFieldNumber(.End(), ):
return errors.New("invalid field number: %d", .End())
case !(.Start() <= .End()):
return errors.New("invalid range: %v", )
case !(.End() < .Start()) && > 0:
return errors.New("overlapping ranges: %v with %v", , )
}
=
}
return nil
}
func ( protoreflect.FieldNumber, bool) bool {
return protowire.MinValidNumber <= && ( <= protowire.MaxValidNumber || )
}
func ( *FieldRanges) ( *FieldRanges) error {
:= .lazyInit().sorted
:= .lazyInit().sorted
for , := 0, 0; < len() && < len(); {
:= fieldRange([])
:= fieldRange([])
if !(.End() < .Start() || .End() < .Start()) {
return errors.New("overlapping ranges: %v with %v", , )
}
if .Start() < .Start() {
++
} else {
++
}
}
return nil
}
type fieldRange [2]protoreflect.FieldNumber
func ( fieldRange) () protoreflect.FieldNumber { return [0] }
func ( fieldRange) () protoreflect.FieldNumber { return [1] - 1 }
func ( fieldRange) () string {
if .Start() == .End() {
return fmt.Sprintf("%d", .Start())
}
return fmt.Sprintf("%d to %d", .Start(), .End())
}
type FieldNumbers struct {
List []protoreflect.FieldNumber
once sync.Once
has map[protoreflect.FieldNumber]struct{}
}
func ( *FieldNumbers) () int { return len(.List) }
func ( *FieldNumbers) ( int) protoreflect.FieldNumber { return .List[] }
func ( *FieldNumbers) ( protoreflect.FieldNumber) bool {
.once.Do(func() {
if len(.List) > 0 {
.has = make(map[protoreflect.FieldNumber]struct{}, len(.List))
for , := range .List {
.has[] = struct{}{}
}
}
})
, := .has[]
return
}
func ( *FieldNumbers) ( fmt.State, rune) { descfmt.FormatList(, , ) }
func ( *FieldNumbers) (pragma.DoNotImplement) {}
type OneofFields struct {
List []protoreflect.FieldDescriptor
once sync.Once
byName map[protoreflect.Name]protoreflect.FieldDescriptor
byJSON map[string]protoreflect.FieldDescriptor
byText map[string]protoreflect.FieldDescriptor
byNum map[protoreflect.FieldNumber]protoreflect.FieldDescriptor
}
func ( *OneofFields) () int { return len(.List) }
func ( *OneofFields) ( int) protoreflect.FieldDescriptor { return .List[] }
func ( *OneofFields) ( protoreflect.Name) protoreflect.FieldDescriptor {
return .lazyInit().byName[]
}
func ( *OneofFields) ( string) protoreflect.FieldDescriptor {
return .lazyInit().byJSON[]
}
func ( *OneofFields) ( string) protoreflect.FieldDescriptor {
return .lazyInit().byText[]
}
func ( *OneofFields) ( protoreflect.FieldNumber) protoreflect.FieldDescriptor {
return .lazyInit().byNum[]
}
func ( *OneofFields) ( fmt.State, rune) { descfmt.FormatList(, , ) }
func ( *OneofFields) (pragma.DoNotImplement) {}
func ( *OneofFields) () *OneofFields {
.once.Do(func() {
if len(.List) > 0 {
.byName = make(map[protoreflect.Name]protoreflect.FieldDescriptor, len(.List))
.byJSON = make(map[string]protoreflect.FieldDescriptor, len(.List))
.byText = make(map[string]protoreflect.FieldDescriptor, len(.List))
.byNum = make(map[protoreflect.FieldNumber]protoreflect.FieldDescriptor, len(.List))
for , := range .List {
.byName[.Name()] =
.byJSON[.JSONName()] =
.byText[.TextName()] =
.byNum[.Number()] =
}
}
})
return
}
type SourceLocations struct {
List []protoreflect.SourceLocation
File protoreflect.FileDescriptor
once sync.Once
byPath map[pathKey]int
}
func ( *SourceLocations) () int { return len(.List) }
func ( *SourceLocations) ( int) protoreflect.SourceLocation { return .lazyInit().List[] }
func ( *SourceLocations) ( pathKey) protoreflect.SourceLocation {
if , := .lazyInit().byPath[]; {
return .List[]
}
return protoreflect.SourceLocation{}
}
func ( *SourceLocations) ( protoreflect.SourcePath) protoreflect.SourceLocation {
return .byKey(newPathKey())
}
func ( *SourceLocations) ( protoreflect.Descriptor) protoreflect.SourceLocation {
if .File != nil && != nil && .File != .ParentFile() {
return protoreflect.SourceLocation{}
}
var [16]int32
:= [:0]
for {
switch .(type) {
case protoreflect.FileDescriptor:
for , := 0, len()-1; < ; , = +1, -1 {
[], [] = [], []
}
return .byKey(newPathKey())
case protoreflect.MessageDescriptor:
= append(, int32(.Index()))
= .Parent()
switch .(type) {
case protoreflect.FileDescriptor:
= append(, int32(genid.FileDescriptorProto_MessageType_field_number))
case protoreflect.MessageDescriptor:
= append(, int32(genid.DescriptorProto_NestedType_field_number))
default:
return protoreflect.SourceLocation{}
}
case protoreflect.FieldDescriptor:
:= .(protoreflect.FieldDescriptor).IsExtension()
= append(, int32(.Index()))
= .Parent()
if {
switch .(type) {
case protoreflect.FileDescriptor:
= append(, int32(genid.FileDescriptorProto_Extension_field_number))
case protoreflect.MessageDescriptor:
= append(, int32(genid.DescriptorProto_Extension_field_number))
default:
return protoreflect.SourceLocation{}
}
} else {
switch .(type) {
case protoreflect.MessageDescriptor:
= append(, int32(genid.DescriptorProto_Field_field_number))
default:
return protoreflect.SourceLocation{}
}
}
case protoreflect.OneofDescriptor:
= append(, int32(.Index()))
= .Parent()
switch .(type) {
case protoreflect.MessageDescriptor:
= append(, int32(genid.DescriptorProto_OneofDecl_field_number))
default:
return protoreflect.SourceLocation{}
}
case protoreflect.EnumDescriptor:
= append(, int32(.Index()))
= .Parent()
switch .(type) {
case protoreflect.FileDescriptor:
= append(, int32(genid.FileDescriptorProto_EnumType_field_number))
case protoreflect.MessageDescriptor:
= append(, int32(genid.DescriptorProto_EnumType_field_number))
default:
return protoreflect.SourceLocation{}
}
case protoreflect.EnumValueDescriptor:
= append(, int32(.Index()))
= .Parent()
switch .(type) {
case protoreflect.EnumDescriptor:
= append(, int32(genid.EnumDescriptorProto_Value_field_number))
default:
return protoreflect.SourceLocation{}
}
case protoreflect.ServiceDescriptor:
= append(, int32(.Index()))
= .Parent()
switch .(type) {
case protoreflect.FileDescriptor:
= append(, int32(genid.FileDescriptorProto_Service_field_number))
default:
return protoreflect.SourceLocation{}
}
case protoreflect.MethodDescriptor:
= append(, int32(.Index()))
= .Parent()
switch .(type) {
case protoreflect.ServiceDescriptor:
= append(, int32(genid.ServiceDescriptorProto_Method_field_number))
default:
return protoreflect.SourceLocation{}
}
default:
return protoreflect.SourceLocation{}
}
}
}
func ( *SourceLocations) () *SourceLocations {
.once.Do(func() {
if len(.List) > 0 {
:= make(map[pathKey][]int, len(.List))
for , := range .List {
:= newPathKey(.Path)
[] = append([], )
}
.byPath = make(map[pathKey]int, len(.List))
for , := range {
for := 0; < len()-1; ++ {
.List[[]].Next = [+1]
}
.List[[len()-1]].Next = 0
.byPath[] = [0]
}
}
})
return
}
func ( *SourceLocations) (pragma.DoNotImplement) {}
type pathKey struct {
arr [16]uint8
str string
}
func ( protoreflect.SourcePath) ( pathKey) {
if len() < len(.arr) {
for , := range {
if < 0 || math.MaxUint8 <= {
return pathKey{str: .String()}
}
.arr[] = uint8()
}
.arr[len(.arr)-1] = uint8(len())
return
}
return pathKey{str: .String()}
}