mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-04-05 14:17:36 +03:00
Update deps
This commit is contained in:
parent
7a4b2ac7ea
commit
2dd6c8e996
104 changed files with 5055 additions and 1906 deletions
183
vendor/google.golang.org/protobuf/internal/descfmt/stringer.go
generated
vendored
183
vendor/google.golang.org/protobuf/internal/descfmt/stringer.go
generated
vendored
|
@ -83,7 +83,13 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string {
|
|||
case protoreflect.FileImports:
|
||||
for i := 0; i < vs.Len(); i++ {
|
||||
var rs records
|
||||
rs.Append(reflect.ValueOf(vs.Get(i)), "Path", "Package", "IsPublic", "IsWeak")
|
||||
rv := reflect.ValueOf(vs.Get(i))
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Path"), "Path"},
|
||||
{rv.MethodByName("Package"), "Package"},
|
||||
{rv.MethodByName("IsPublic"), "IsPublic"},
|
||||
{rv.MethodByName("IsWeak"), "IsWeak"},
|
||||
}...)
|
||||
ss = append(ss, "{"+rs.Join()+"}")
|
||||
}
|
||||
return start + joinStrings(ss, allowMulti) + end
|
||||
|
@ -92,34 +98,26 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string {
|
|||
for i := 0; i < vs.Len(); i++ {
|
||||
m := reflect.ValueOf(vs).MethodByName("Get")
|
||||
v := m.Call([]reflect.Value{reflect.ValueOf(i)})[0].Interface()
|
||||
ss = append(ss, formatDescOpt(v.(protoreflect.Descriptor), false, allowMulti && !isEnumValue))
|
||||
ss = append(ss, formatDescOpt(v.(protoreflect.Descriptor), false, allowMulti && !isEnumValue, nil))
|
||||
}
|
||||
return start + joinStrings(ss, allowMulti && isEnumValue) + end
|
||||
}
|
||||
}
|
||||
|
||||
// descriptorAccessors is a list of accessors to print for each descriptor.
|
||||
//
|
||||
// Do not print all accessors since some contain redundant information,
|
||||
// while others are pointers that we do not want to follow since the descriptor
|
||||
// is actually a cyclic graph.
|
||||
//
|
||||
// Using a list allows us to print the accessors in a sensible order.
|
||||
var descriptorAccessors = map[reflect.Type][]string{
|
||||
reflect.TypeOf((*protoreflect.FileDescriptor)(nil)).Elem(): {"Path", "Package", "Imports", "Messages", "Enums", "Extensions", "Services"},
|
||||
reflect.TypeOf((*protoreflect.MessageDescriptor)(nil)).Elem(): {"IsMapEntry", "Fields", "Oneofs", "ReservedNames", "ReservedRanges", "RequiredNumbers", "ExtensionRanges", "Messages", "Enums", "Extensions"},
|
||||
reflect.TypeOf((*protoreflect.FieldDescriptor)(nil)).Elem(): {"Number", "Cardinality", "Kind", "HasJSONName", "JSONName", "HasPresence", "IsExtension", "IsPacked", "IsWeak", "IsList", "IsMap", "MapKey", "MapValue", "HasDefault", "Default", "ContainingOneof", "ContainingMessage", "Message", "Enum"},
|
||||
reflect.TypeOf((*protoreflect.OneofDescriptor)(nil)).Elem(): {"Fields"}, // not directly used; must keep in sync with formatDescOpt
|
||||
reflect.TypeOf((*protoreflect.EnumDescriptor)(nil)).Elem(): {"Values", "ReservedNames", "ReservedRanges"},
|
||||
reflect.TypeOf((*protoreflect.EnumValueDescriptor)(nil)).Elem(): {"Number"},
|
||||
reflect.TypeOf((*protoreflect.ServiceDescriptor)(nil)).Elem(): {"Methods"},
|
||||
reflect.TypeOf((*protoreflect.MethodDescriptor)(nil)).Elem(): {"Input", "Output", "IsStreamingClient", "IsStreamingServer"},
|
||||
type methodAndName struct {
|
||||
method reflect.Value
|
||||
name string
|
||||
}
|
||||
|
||||
func FormatDesc(s fmt.State, r rune, t protoreflect.Descriptor) {
|
||||
io.WriteString(s, formatDescOpt(t, true, r == 'v' && (s.Flag('+') || s.Flag('#'))))
|
||||
io.WriteString(s, formatDescOpt(t, true, r == 'v' && (s.Flag('+') || s.Flag('#')), nil))
|
||||
}
|
||||
func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool) string {
|
||||
|
||||
func InternalFormatDescOptForTesting(t protoreflect.Descriptor, isRoot, allowMulti bool, record func(string)) string {
|
||||
return formatDescOpt(t, isRoot, allowMulti, record)
|
||||
}
|
||||
|
||||
func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool, record func(string)) string {
|
||||
rv := reflect.ValueOf(t)
|
||||
rt := rv.MethodByName("ProtoType").Type().In(0)
|
||||
|
||||
|
@ -129,26 +127,60 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool) string {
|
|||
}
|
||||
|
||||
_, isFile := t.(protoreflect.FileDescriptor)
|
||||
rs := records{allowMulti: allowMulti}
|
||||
rs := records{
|
||||
allowMulti: allowMulti,
|
||||
record: record,
|
||||
}
|
||||
if t.IsPlaceholder() {
|
||||
if isFile {
|
||||
rs.Append(rv, "Path", "Package", "IsPlaceholder")
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Path"), "Path"},
|
||||
{rv.MethodByName("Package"), "Package"},
|
||||
{rv.MethodByName("IsPlaceholder"), "IsPlaceholder"},
|
||||
}...)
|
||||
} else {
|
||||
rs.Append(rv, "FullName", "IsPlaceholder")
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("FullName"), "FullName"},
|
||||
{rv.MethodByName("IsPlaceholder"), "IsPlaceholder"},
|
||||
}...)
|
||||
}
|
||||
} else {
|
||||
switch {
|
||||
case isFile:
|
||||
rs.Append(rv, "Syntax")
|
||||
rs.Append(rv, methodAndName{rv.MethodByName("Syntax"), "Syntax"})
|
||||
case isRoot:
|
||||
rs.Append(rv, "Syntax", "FullName")
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Syntax"), "Syntax"},
|
||||
{rv.MethodByName("FullName"), "FullName"},
|
||||
}...)
|
||||
default:
|
||||
rs.Append(rv, "Name")
|
||||
rs.Append(rv, methodAndName{rv.MethodByName("Name"), "Name"})
|
||||
}
|
||||
switch t := t.(type) {
|
||||
case protoreflect.FieldDescriptor:
|
||||
for _, s := range descriptorAccessors[rt] {
|
||||
switch s {
|
||||
accessors := []methodAndName{
|
||||
{rv.MethodByName("Number"), "Number"},
|
||||
{rv.MethodByName("Cardinality"), "Cardinality"},
|
||||
{rv.MethodByName("Kind"), "Kind"},
|
||||
{rv.MethodByName("HasJSONName"), "HasJSONName"},
|
||||
{rv.MethodByName("JSONName"), "JSONName"},
|
||||
{rv.MethodByName("HasPresence"), "HasPresence"},
|
||||
{rv.MethodByName("IsExtension"), "IsExtension"},
|
||||
{rv.MethodByName("IsPacked"), "IsPacked"},
|
||||
{rv.MethodByName("IsWeak"), "IsWeak"},
|
||||
{rv.MethodByName("IsList"), "IsList"},
|
||||
{rv.MethodByName("IsMap"), "IsMap"},
|
||||
{rv.MethodByName("MapKey"), "MapKey"},
|
||||
{rv.MethodByName("MapValue"), "MapValue"},
|
||||
{rv.MethodByName("HasDefault"), "HasDefault"},
|
||||
{rv.MethodByName("Default"), "Default"},
|
||||
{rv.MethodByName("ContainingOneof"), "ContainingOneof"},
|
||||
{rv.MethodByName("ContainingMessage"), "ContainingMessage"},
|
||||
{rv.MethodByName("Message"), "Message"},
|
||||
{rv.MethodByName("Enum"), "Enum"},
|
||||
}
|
||||
for _, s := range accessors {
|
||||
switch s.name {
|
||||
case "MapKey":
|
||||
if k := t.MapKey(); k != nil {
|
||||
rs.recs = append(rs.recs, [2]string{"MapKey", k.Kind().String()})
|
||||
|
@ -157,20 +189,20 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool) string {
|
|||
if v := t.MapValue(); v != nil {
|
||||
switch v.Kind() {
|
||||
case protoreflect.EnumKind:
|
||||
rs.recs = append(rs.recs, [2]string{"MapValue", string(v.Enum().FullName())})
|
||||
rs.AppendRecs("MapValue", [2]string{"MapValue", string(v.Enum().FullName())})
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
rs.recs = append(rs.recs, [2]string{"MapValue", string(v.Message().FullName())})
|
||||
rs.AppendRecs("MapValue", [2]string{"MapValue", string(v.Message().FullName())})
|
||||
default:
|
||||
rs.recs = append(rs.recs, [2]string{"MapValue", v.Kind().String()})
|
||||
rs.AppendRecs("MapValue", [2]string{"MapValue", v.Kind().String()})
|
||||
}
|
||||
}
|
||||
case "ContainingOneof":
|
||||
if od := t.ContainingOneof(); od != nil {
|
||||
rs.recs = append(rs.recs, [2]string{"Oneof", string(od.Name())})
|
||||
rs.AppendRecs("ContainingOneof", [2]string{"Oneof", string(od.Name())})
|
||||
}
|
||||
case "ContainingMessage":
|
||||
if t.IsExtension() {
|
||||
rs.recs = append(rs.recs, [2]string{"Extendee", string(t.ContainingMessage().FullName())})
|
||||
rs.AppendRecs("ContainingMessage", [2]string{"Extendee", string(t.ContainingMessage().FullName())})
|
||||
}
|
||||
case "Message":
|
||||
if !t.IsMap() {
|
||||
|
@ -187,13 +219,61 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool) string {
|
|||
ss = append(ss, string(fs.Get(i).Name()))
|
||||
}
|
||||
if len(ss) > 0 {
|
||||
rs.recs = append(rs.recs, [2]string{"Fields", "[" + joinStrings(ss, false) + "]"})
|
||||
rs.AppendRecs("Fields", [2]string{"Fields", "[" + joinStrings(ss, false) + "]"})
|
||||
}
|
||||
default:
|
||||
rs.Append(rv, descriptorAccessors[rt]...)
|
||||
|
||||
case protoreflect.FileDescriptor:
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Path"), "Path"},
|
||||
{rv.MethodByName("Package"), "Package"},
|
||||
{rv.MethodByName("Imports"), "Imports"},
|
||||
{rv.MethodByName("Messages"), "Messages"},
|
||||
{rv.MethodByName("Enums"), "Enums"},
|
||||
{rv.MethodByName("Extensions"), "Extensions"},
|
||||
{rv.MethodByName("Services"), "Services"},
|
||||
}...)
|
||||
|
||||
case protoreflect.MessageDescriptor:
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("IsMapEntry"), "IsMapEntry"},
|
||||
{rv.MethodByName("Fields"), "Fields"},
|
||||
{rv.MethodByName("Oneofs"), "Oneofs"},
|
||||
{rv.MethodByName("ReservedNames"), "ReservedNames"},
|
||||
{rv.MethodByName("ReservedRanges"), "ReservedRanges"},
|
||||
{rv.MethodByName("RequiredNumbers"), "RequiredNumbers"},
|
||||
{rv.MethodByName("ExtensionRanges"), "ExtensionRanges"},
|
||||
{rv.MethodByName("Messages"), "Messages"},
|
||||
{rv.MethodByName("Enums"), "Enums"},
|
||||
{rv.MethodByName("Extensions"), "Extensions"},
|
||||
}...)
|
||||
|
||||
case protoreflect.EnumDescriptor:
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Values"), "Values"},
|
||||
{rv.MethodByName("ReservedNames"), "ReservedNames"},
|
||||
{rv.MethodByName("ReservedRanges"), "ReservedRanges"},
|
||||
}...)
|
||||
|
||||
case protoreflect.EnumValueDescriptor:
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Number"), "Number"},
|
||||
}...)
|
||||
|
||||
case protoreflect.ServiceDescriptor:
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Methods"), "Methods"},
|
||||
}...)
|
||||
|
||||
case protoreflect.MethodDescriptor:
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Input"), "Input"},
|
||||
{rv.MethodByName("Output"), "Output"},
|
||||
{rv.MethodByName("IsStreamingClient"), "IsStreamingClient"},
|
||||
{rv.MethodByName("IsStreamingServer"), "IsStreamingServer"},
|
||||
}...)
|
||||
}
|
||||
if rv.MethodByName("GoType").IsValid() {
|
||||
rs.Append(rv, "GoType")
|
||||
if m := rv.MethodByName("GoType"); m.IsValid() {
|
||||
rs.Append(rv, methodAndName{m, "GoType"})
|
||||
}
|
||||
}
|
||||
return start + rs.Join() + end
|
||||
|
@ -202,19 +282,34 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool) string {
|
|||
type records struct {
|
||||
recs [][2]string
|
||||
allowMulti bool
|
||||
|
||||
// record is a function that will be called for every Append() or
|
||||
// AppendRecs() call, to be used for testing with the
|
||||
// InternalFormatDescOptForTesting function.
|
||||
record func(string)
|
||||
}
|
||||
|
||||
func (rs *records) Append(v reflect.Value, accessors ...string) {
|
||||
func (rs *records) AppendRecs(fieldName string, newRecs [2]string) {
|
||||
if rs.record != nil {
|
||||
rs.record(fieldName)
|
||||
}
|
||||
rs.recs = append(rs.recs, newRecs)
|
||||
}
|
||||
|
||||
func (rs *records) Append(v reflect.Value, accessors ...methodAndName) {
|
||||
for _, a := range accessors {
|
||||
if rs.record != nil {
|
||||
rs.record(a.name)
|
||||
}
|
||||
var rv reflect.Value
|
||||
if m := v.MethodByName(a); m.IsValid() {
|
||||
rv = m.Call(nil)[0]
|
||||
if a.method.IsValid() {
|
||||
rv = a.method.Call(nil)[0]
|
||||
}
|
||||
if v.Kind() == reflect.Struct && !rv.IsValid() {
|
||||
rv = v.FieldByName(a)
|
||||
rv = v.FieldByName(a.name)
|
||||
}
|
||||
if !rv.IsValid() {
|
||||
panic(fmt.Sprintf("unknown accessor: %v.%s", v.Type(), a))
|
||||
panic(fmt.Sprintf("unknown accessor: %v.%s", v.Type(), a.name))
|
||||
}
|
||||
if _, ok := rv.Interface().(protoreflect.Value); ok {
|
||||
rv = rv.MethodByName("Interface").Call(nil)[0]
|
||||
|
@ -261,7 +356,7 @@ func (rs *records) Append(v reflect.Value, accessors ...string) {
|
|||
default:
|
||||
s = fmt.Sprint(v)
|
||||
}
|
||||
rs.recs = append(rs.recs, [2]string{a, s})
|
||||
rs.recs = append(rs.recs, [2]string{a.name, s})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue