callframe

package
v0.0.0-...-9578a16 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package callframe provides a way to create Godot-compatible callframes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Align

func Align(size uintptr, alignment uintptr) uintptr

Align a size to the next multiple of alignment (rounding up).

Types

type Args

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

Array of arguments.

func (Args) Uintptr

func (array Args) Uintptr() uintptr

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 Nil

type Nil struct{}

Nil implements [Any].

func (Nil) Uintptr

func (Nil) Uintptr() uintptr

Uintptr always returns 0.

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]) 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