mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-04-07 07:07:37 +03:00
Update deps
This commit is contained in:
parent
f033bb3034
commit
5a091c6da4
1997 changed files with 368830 additions and 2045 deletions
29
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
29
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
|
@ -423,6 +423,13 @@ func (c *messageConverter) PBValueOf(v reflect.Value) pref.Value {
|
|||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
if c.isNonPointer() {
|
||||
if v.CanAddr() {
|
||||
v = v.Addr() // T => *T
|
||||
} else {
|
||||
v = reflect.Zero(reflect.PtrTo(v.Type()))
|
||||
}
|
||||
}
|
||||
if m, ok := v.Interface().(pref.ProtoMessage); ok {
|
||||
return pref.ValueOfMessage(m.ProtoReflect())
|
||||
}
|
||||
|
@ -437,6 +444,16 @@ func (c *messageConverter) GoValueOf(v pref.Value) reflect.Value {
|
|||
} else {
|
||||
rv = reflect.ValueOf(m.Interface())
|
||||
}
|
||||
if c.isNonPointer() {
|
||||
if rv.Type() != reflect.PtrTo(c.goType) {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", rv.Type(), reflect.PtrTo(c.goType)))
|
||||
}
|
||||
if !rv.IsNil() {
|
||||
rv = rv.Elem() // *T => T
|
||||
} else {
|
||||
rv = reflect.Zero(rv.Type().Elem())
|
||||
}
|
||||
}
|
||||
if rv.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", rv.Type(), c.goType))
|
||||
}
|
||||
|
@ -451,6 +468,9 @@ func (c *messageConverter) IsValidPB(v pref.Value) bool {
|
|||
} else {
|
||||
rv = reflect.ValueOf(m.Interface())
|
||||
}
|
||||
if c.isNonPointer() {
|
||||
return rv.Type() == reflect.PtrTo(c.goType)
|
||||
}
|
||||
return rv.Type() == c.goType
|
||||
}
|
||||
|
||||
|
@ -459,9 +479,18 @@ func (c *messageConverter) IsValidGo(v reflect.Value) bool {
|
|||
}
|
||||
|
||||
func (c *messageConverter) New() pref.Value {
|
||||
if c.isNonPointer() {
|
||||
return c.PBValueOf(reflect.New(c.goType).Elem())
|
||||
}
|
||||
return c.PBValueOf(reflect.New(c.goType.Elem()))
|
||||
}
|
||||
|
||||
func (c *messageConverter) Zero() pref.Value {
|
||||
return c.PBValueOf(reflect.Zero(c.goType))
|
||||
}
|
||||
|
||||
// isNonPointer reports whether the type is a non-pointer type.
|
||||
// This never occurs for generated message types.
|
||||
func (c *messageConverter) isNonPointer() bool {
|
||||
return c.goType.Kind() != reflect.Ptr
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue