intern

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MPL-2.0, ISC Imports: 10 Imported by: 0

Documentation

Overview

Package intern implements value interning for Cgo sharing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Free

func Free(box *Box)

Free explicitly frees the box permanently. It must not be resurrected after this.

Types

type Box

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

Box is an opaque type holding extra data.

func Get

func Get(gobject unsafe.Pointer, take bool) *Box

Get gets the interned box for the given GObject C pointer. If the object is new or unknown, then a new box is made. If the intern box already exists for a given C pointer, then that box is weakly referenced and returned. The box will be reference-counted; the caller must use ShouldFree to unreference it.

func TryGet

func TryGet(gobject unsafe.Pointer) *Box

TryGet gets the Box associated with the GObject or nil if it's gone. The caller must not retain the Box pointer anywhere.

func (*Box) GObject

func (b *Box) GObject() unsafe.Pointer

Object returns Box's C GObject pointer.

type BoxedType

type BoxedType[T any] struct {
	// contains filtered or unexported fields
}

func RegisterType

func RegisterType[T any](ctor func(*Box) *T) BoxedType[T]

func (*BoxedType[T]) Delete

func (t *BoxedType[T]) Delete(box *Box)

func (*BoxedType[T]) Get

func (t *BoxedType[T]) Get(box *Box) *T

func (*BoxedType[T]) Set

func (t *BoxedType[T]) Set(box *Box, v *T)

Jump to

Keyboard shortcuts

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