Documentation ¶
Index ¶
- func AdvancePointer(p unsafe.Pointer, shift uintptr) unsafe.Pointer
- func Alloc(memory []byte, object interface{}) error
- func ByteSliceData(slice []byte) unsafe.Pointer
- func ByteSliceFromUnsafePointer(memory unsafe.Pointer, length, capacity int) []byte
- func ByteSliceTointSlice(memory []byte, length, capacity int) []int
- func CheckObjectReferences(object interface{}) error
- func IntSliceFromUnsafePointer(memory unsafe.Pointer, length, capacity int) []int
- func IsReferenceType(object interface{}) bool
- func ObjectAddress(object reflect.Value) unsafe.Pointer
- func ObjectData(object interface{}) ([]byte, error)
- func ObjectSize(object reflect.Value) int
- func RawSliceFromUnsafePointer(memory unsafe.Pointer, length, capacity int) unsafe.Pointer
- func Use(unsafe.Pointer)
- func UseValue(value interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdvancePointer ¶ added in v0.4.0
AdvancePointer adds shift value to 'p' pointer.
func Alloc ¶
Alloc copies value's data into a byte slice performing some sanity checks. The object either must be a slice, or should be a sort of an object, which does not contain any references inside, i.e. should be placed in the memory continuously. If the object is a pointer it will be dereferenced. To alloc a pointer as is, use uintptr or unsafe.Pointer. If the object is a slice, only actual data is stored. the calling site must save object's length and capacity.
func ByteSliceData ¶
ByteSliceData returns a pointer to the data of the given byte slice
func ByteSliceFromUnsafePointer ¶
ByteSliceFromUnsafePointer returns a slice of bytes with given length and capacity. Memory pointed by the unsafe.Pointer is used for the slice.
func ByteSliceTointSlice ¶
ByteSliceTointSlice returns an int slice, which uses the same memory, that the byte slice uses.
func CheckObjectReferences ¶
func CheckObjectReferences(object interface{}) error
CheckObjectReferences checks if an object of type can be safely copied byte by byte. the object must not contain any reference types like maps, strings, and so on. slices or pointers can be at the top level only
func IntSliceFromUnsafePointer ¶ added in v0.2.0
IntSliceFromUnsafePointer returns a slice of ints with given length and capacity. Memory pointed by the unsafe.Pointer is used for the slice.
func IsReferenceType ¶
func IsReferenceType(object interface{}) bool
IsReferenceType returns true, is the object is a pointer or a slice
func ObjectAddress ¶
ObjectAddress returns the address of the given object if a slice or a pointer is passed, it will returns a pointer to the actual data
func ObjectData ¶
ObjectData returns objects underlying byte representation. The object must stored continuously in the memory, ie must not contain any references. Slices of plain objects are allowed.
func ObjectSize ¶
ObjectSize returns the size of the object. If an object is a slice, it returns the size of the entire slice If an object is a pointer, it dereferences the pointer and returns the size of the underlying object.
func RawSliceFromUnsafePointer ¶ added in v0.2.0
RawSliceFromUnsafePointer returns a pointer to the slice of ints with given length and capacity. Memory pointed by the unsafe.Pointer is used for the slice.
Types ¶
This section is empty.