Documentation ¶
Index ¶
- func Cast[T any](ptr uintptr) *T
- func CastNative[N Native, T Native](ptr *N) *T
- func CastWithOffset[T any](ptr uintptr, offset uint64) *T
- func Cstring(name string) *byte
- func Gostring(ptr *byte) string
- func GostringSized(ptr *byte, size uint64) string
- func KeepAlive[T any](x T)
- func NativeStringUnwrap(str string) reflect.StringHeader
- func NativeToUintptr[T any](x T) uintptr
- func PtrToUintptr[T any](arg *T) uintptr
- func SliceToUintptr[T any](arg []T) uintptr
- func UintptrToNative[T any](x uintptr) T
- type Native
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cast ¶
Cast is used to centralize unsafe use C of allocated pointer. We take the address and then dereference it to trick go vet from creating a possible misuse of unsafe.Pointer
func CastNative ¶
func CastWithOffset ¶
CastWithOffset is the same as cast but adding an offset to the pointer by a multiple of the size of the type pointed.
func GostringSized ¶
func KeepAlive ¶
func KeepAlive[T any](x T)
KeepAlive is a copy of runtime.KeepAlive keepAlive has 2 usages: - It forces the deallocation of the memory to take place later than expected (just like runtime.KeepAlive) - It forces the given argument x to be escaped on the heap by saving it into a global value (Go doesn't provide a standard way to do it as of today) It is implemented so that the compiler cannot optimize it.
func NativeStringUnwrap ¶
func NativeStringUnwrap(str string) reflect.StringHeader
NativeStringUnwrap cast a native string type into it's runtime value. Exported as the struct reflect.StringHeader
func NativeToUintptr ¶
NativeToUintptr is a helper used by populate WafObject values with Go values
func PtrToUintptr ¶
PtrToUintptr is a helper to centralize of usage of unsafe.Pointer do not use this function to cast interfaces
func SliceToUintptr ¶
func UintptrToNative ¶
UintToNative is a helper used retrieve Go values from an uintptr encoded value from a WafObject