callframe

package
v0.0.0-...-e9402f6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr struct {
	// contains filtered or unexported fields
}
var Nil Addr

Nil implements [Any].

func (Addr) Addr

func (addr Addr) Addr() Addr

func (Addr) Pointer

func (addr Addr) Pointer() *[16]uint32

func (Addr) Uintptr

func (addr Addr) Uintptr() uintptr

func (Addr) UnsafePointer

func (addr Addr) UnsafePointer() unsafe.Pointer

type Args

type Args struct {
	// contains filtered or unexported fields
}

Array of arguments.

func (Args) Index

func (array Args) Index(i int) Addr

func (Args) Len

func (array Args) Len() int

func (Args) Uintptr

func (array Args) Uintptr() uintptr

func (Args) UnsafePointer

func (array Args) UnsafePointer() unsafe.Pointer

type Frame

type Frame struct {
	// contains filtered or unexported fields
}

Frame can be used to reduce the number of allocations required to pass pointers across API boundaries. Since dynamic function calls and CGO always cause pointers to escape, a frame enables a block of memory to be used to copy in const value arguments. The frame is cached using sync.Pool and recycled across calls. Suitable for use when the function being called is only borrowing the pointer for the lifetime of the call. A frame has a fixed size, if it runs out of space, arguments will be allocated onto the Go heap as usual.

func New

func New() *Frame

New returns either a new Frame, or a recycled frame.

func (*Frame) Array

func (frame *Frame) Array(i int) Args

Array returns a pointer to array of arguments offset by i.

func (*Frame) Free

func (frame *Frame) Free()

Free recycles the Frame. Do not reuse the frame after calling this method.

type Ptr

type Ptr[T comparable] struct {
	// contains filtered or unexported fields
}

Ptr that does not escape as an allocation to the heap, T must be a value type that does not contain any pointers. The value must not be used after the frame has been freed.

func Arg

func Arg[T comparable](frame *Frame, arg T) Ptr[T]

Arg adds a new argument to the call frame.

func Ret

func Ret[T comparable](frame *Frame) Ptr[T]

Ret prepares an expected return value that will be available after the call has been made.

func (Ptr[T]) Addr

func (ptr Ptr[T]) Addr() Addr

Mut pointer.

func (Ptr[T]) Get

func (ptr Ptr[T]) Get() T

Get returns the value of the pointer.

func (Ptr[T]) Uintptr

func (ptr Ptr[T]) Uintptr() uintptr

Uintptr returns the uintptr value of the pointer. Useful for passing to C code.

func (Ptr[T]) UnsafePointer

func (ptr Ptr[T]) UnsafePointer() unsafe.Pointer

UnsafePoiner returns the unsafe.Pointer value of the pointer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL