本文整理匯總了Golang中reflect.Value.SetPointer方法的典型用法代碼示例。如果您正苦於以下問題:Golang Value.SetPointer方法的具體用法?Golang Value.SetPointer怎麽用?Golang Value.SetPointer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類reflect.Value
的用法示例。
在下文中一共展示了Value.SetPointer方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: luaU_FetchPointer
func luaU_FetchPointer(l Lua_State, v *reflect.Value) (ok bool) {
if ok = Lua_isthread(l, -1); ok {
v.SetPointer(unsafe.Pointer(Lua_tothread(l, -1)))
}
Lua_pop(l, 1)
return
}
示例2: setRetValue
func setRetValue(v reflect.Value, p unsafe.Pointer) {
if !v.IsValid() {
return
}
switch v = v.Elem(); v.Kind() {
case reflect.Int:
v.SetInt(int64(*((*C.int)(p))))
case reflect.Int8:
v.SetInt(int64(*(*C.int8_t)(p)))
case reflect.Int16:
v.SetInt(int64(*(*C.int16_t)(p)))
case reflect.Int32:
v.SetInt(int64(*(*C.int32_t)(p)))
case reflect.Int64:
v.SetInt(int64(*(*C.int64_t)(p)))
case reflect.Uint:
v.SetUint(uint64(*((*C.uint)(p))))
case reflect.Uint8:
v.SetUint(uint64(*(*C.uint8_t)(p)))
case reflect.Uint16:
v.SetUint(uint64(*(*C.uint16_t)(p)))
case reflect.Uint32:
v.SetUint(uint64(*(*C.uint32_t)(p)))
case reflect.Uint64:
v.SetUint(uint64(*(*C.uint64_t)(p)))
case reflect.Uintptr:
v.SetUint(uint64(*(*C.size_t)(p)))
case reflect.Float32:
v.SetFloat(float64(*(*C.float)(p)))
case reflect.Float64:
v.SetFloat(float64(*(*C.double)(p)))
case reflect.String:
v.SetString(C.GoString(*(**C.char)(p)))
case reflect.UnsafePointer:
v.SetPointer(*(*unsafe.Pointer)(p))
}
}