core

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

package core implements core functionality for the generated files this core lib is imported by the generated code

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteSlice

func ByteSlice(name []string) **byte

ByteSlice creates a pointer to a byte slice of C strings This function was copied from purego

func CString

func CString(name string) *byte

CString converts a go string to *byte that can be passed to C code. This function was copied from purego

func GFree

func GFree(ptr uintptr)

GFree frees memory allocated by GLib allocation APIs.

func GFreeNullable

func GFreeNullable(ptr uintptr)

GFreeNullable frees a nullable GLib-allocated pointer.

func GStrdup

func GStrdup(s string) uintptr

GStrdup allocates a C-owned copy of a Go string using g_strdup. The returned pointer must be freed with g_free by the receiver or callee.

func GStrdupNullable

func GStrdupNullable(s *string) uintptr

GStrdupNullable is like GStrdup but accepts a nullable *string.

func GetPaths

func GetPaths(name string) []string

GetPaths gets all shared object files from a library name and panics if no matching library can be found. TODO: Hardcode a library shared object with linker -X flag. This is useful for packaging.

func GoString

func GoString(c uintptr) string

GoString copies a char* to a Go string. This function was copied from purego

func GoStringSlice

func GoStringSlice(c uintptr) []string

GoStringSlice gets a string slice from a char** array This function was copied from purego

func LazyRegister

func LazyRegister(target any, library, symbol string, optional bool) bool

LazyRegister publishes a generated function's native symbol on its first call. Required-library failures panic; optional-library failures return false.

func LibraryAvailable

func LibraryAvailable(library string) bool

LibraryAvailable reports whether an optional library can be opened. The open result, including failure, is shared with LazyRegister.

func NullableStringToPtr

func NullableStringToPtr(s *string) (uintptr, []byte)

NullableStringToPtr converts a nullable Go string to a C string pointer. The caller must call runtime.KeepAlive(backing) after the C call completes.

func PtrToNullableString

func PtrToNullableString(ptr uintptr) *string

PtrToNullableString converts a nullable char* to a Go *string.

func PuregoSafeRegister

func PuregoSafeRegister(fptr interface{}, libs []uintptr, name string)

func SetPackageName

func SetPackageName(libName, pkgName string)

SetPackageName registers a pkg-config package name for a library. This is used by the code generator to set package names from GIR files. It won't override existing entries to preserve defaults.

func SetSharedLibraries

func SetSharedLibraries(libName string, sharedLibs []string)

SetSharedLibraries registers shared library names for a library. This is used by the code generator to set library names from GIR files. It won't override existing entries to preserve defaults.

func TryGetPaths

func TryGetPaths(name string) []string

TryGetPaths is like GetPaths but returns an empty slice instead of panicking. Use this for optional libraries that may not be installed.

Types

type LazyResolver

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

LazyResolver safely caches library opens and symbol publication. It is safe for concurrent use. Its injected dependencies make resolution deterministic in tests.

func NewLazyResolver

func NewLazyResolver(paths LibraryPathResolver, opener LibraryOpener, resolve SymbolResolver) *LazyResolver

NewLazyResolver constructs an isolated lazy resolver. All dependencies must be non-nil.

func (*LazyResolver) Register

func (r *LazyResolver) Register(target any, library, symbol string) error

Register resolves and publishes symbol into target once. Library and symbol failures are cached as well as successful resolutions.

func (*LazyResolver) RegisterOptional

func (r *LazyResolver) RegisterOptional(target any, library, symbol string) bool

RegisterOptional is Register for optional libraries. It reports whether the symbol was published and caches an unavailable-library failure.

type LibraryOpener

type LibraryOpener func(path string) (uintptr, error)

LibraryOpener opens a shared library path and returns its handle.

type LibraryPathResolver

type LibraryPathResolver func(library string) ([]string, error)

LibraryPathResolver returns the candidate paths for a named library.

type SymbolResolver

type SymbolResolver func(target any, libraries []uintptr, symbol string) error

SymbolResolver resolves and publishes a symbol into target using library handles.

Source Files

  • core.go
  • fastcall.go

Jump to

Keyboard shortcuts

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