reflect.valueInterface
This commit is contained in:
@@ -747,36 +747,36 @@ func (v Value) Interface() (i any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func valueInterface(v Value, safe bool) any {
|
func valueInterface(v Value, safe bool) any {
|
||||||
/*
|
if v.flag == 0 {
|
||||||
if v.flag == 0 {
|
panic(&ValueError{"reflect.Value.Interface", Invalid})
|
||||||
panic(&ValueError{"reflect.Value.Interface", Invalid})
|
}
|
||||||
}
|
if safe && v.flag&flagRO != 0 {
|
||||||
if safe && v.flag&flagRO != 0 {
|
// Do not allow access to unexported values via Interface,
|
||||||
// Do not allow access to unexported values via Interface,
|
// because they might be pointers that should not be
|
||||||
// because they might be pointers that should not be
|
// writable or methods or function that should not be callable.
|
||||||
// writable or methods or function that should not be callable.
|
panic("reflect.Value.Interface: cannot return value obtained from unexported field or method")
|
||||||
panic("reflect.Value.Interface: cannot return value obtained from unexported field or method")
|
}
|
||||||
}
|
if v.flag&flagMethod != 0 {
|
||||||
if v.flag&flagMethod != 0 {
|
v = makeMethodValue("Interface", v)
|
||||||
v = makeMethodValue("Interface", v)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if v.kind() == Interface {
|
if v.kind() == Interface {
|
||||||
// Special case: return the element inside the interface.
|
/* TODO(xsw):
|
||||||
// Empty interface has one layout, all interfaces with
|
// Special case: return the element inside the interface.
|
||||||
// methods have a second layout.
|
// Empty interface has one layout, all interfaces with
|
||||||
if v.NumMethod() == 0 {
|
// methods have a second layout.
|
||||||
return *(*any)(v.ptr)
|
if v.NumMethod() == 0 {
|
||||||
}
|
return *(*any)(v.ptr)
|
||||||
return *(*interface {
|
|
||||||
M()
|
|
||||||
})(v.ptr)
|
|
||||||
}
|
}
|
||||||
|
return *(*interface {
|
||||||
|
M()
|
||||||
|
})(v.ptr)
|
||||||
|
*/
|
||||||
|
panic("todo: reflect.valueInterface")
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: pass safe to packEface so we don't need to copy if safe==true?
|
// TODO: pass safe to packEface so we don't need to copy if safe==true?
|
||||||
return packEface(v)
|
return packEface(v)
|
||||||
*/
|
|
||||||
panic("todo: reflect.valueInterface")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// InterfaceData returns a pair of unspecified uintptr values.
|
// InterfaceData returns a pair of unspecified uintptr values.
|
||||||
|
|||||||
Reference in New Issue
Block a user