cl: _testcgo/any
This commit is contained in:
@@ -30,9 +30,37 @@ var (
|
||||
TyAny = &InterfaceType{}
|
||||
)
|
||||
|
||||
func MakeAnyInt(typ *Type, data uintptr) Interface {
|
||||
return Interface{
|
||||
tab: &itab{inter: TyAny, _type: typ, hash: 0, fun: [1]uintptr{0}},
|
||||
data: unsafe.Pointer(data),
|
||||
}
|
||||
}
|
||||
|
||||
func MakeAny(typ *Type, data unsafe.Pointer) Interface {
|
||||
return Interface{
|
||||
tab: &itab{inter: TyAny, _type: typ, hash: 0, fun: [1]uintptr{0}},
|
||||
data: data,
|
||||
}
|
||||
}
|
||||
|
||||
func MakeInterface(inter *InterfaceType, typ *Type, data unsafe.Pointer) Interface {
|
||||
return Interface{
|
||||
tab: &itab{inter: inter, _type: typ, hash: 0, fun: [1]uintptr{0}},
|
||||
data: data,
|
||||
}
|
||||
}
|
||||
|
||||
func I2Int(v Interface, t *Type) uintptr {
|
||||
if v.tab._type == t {
|
||||
return uintptr(v.data)
|
||||
}
|
||||
panic("I2Int: type mismatch")
|
||||
}
|
||||
|
||||
func CheckI2Int(v Interface, t *Type) (uintptr, bool) {
|
||||
if v.tab._type == t {
|
||||
return uintptr(v.data), true
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user