handle

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Overview

Package handle wrap/unwrap Go pointers for C.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count() int

Count returns the total number of active handles and pinned slices.

func Dump

func Dump() string

Dump returns a string representation of all existing handles and pinned slices.

func PinSliceData

func PinSliceData[T any](vs []T) unsafe.Pointer

PinSliceData pins the content of a slice so that it can shared with C. Call unpinSliceData to release the reference to the slice data.

func Release

func Release(h Handle)

Release deletes a cgx handle.

The handle must not be used (either through Unwrap or Release) after deletion.

func UnpinSliceData

func UnpinSliceData(ptr unsafe.Pointer)

UnpinSliceData unpin the data of a slice.

func Unwrap

func Unwrap[T any](h Handle) T

Unwrap converts a handle returned by Wrap() into the original Go value.

Unwrap() must be called with the same type T used in the original Wrap() call.

Types

type Handle

type Handle uintptr

Handle to a Go object.

func Wrap

func Wrap[T comparable](v T) Handle

Wrap converts a Go value to a cgx_handle.

Handles must be unwrapped with the Unwrap() function using the same type T.

func WrapSlice

func WrapSlice[T comparable](vs []T) []Handle

WrapSlice wraps all the element of a slice.

Jump to

Keyboard shortcuts

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