pipeline

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateBindings

func GenerateBindings(cfg BindingsConfig) error

GenerateBindings generates all framework and library packages from the registry.

func GenerateIdiomatic

func GenerateIdiomatic(cfg IdiomaticConfig) error

GenerateIdiomatic writes the opinionated idiomatic layer to cfg.OutDir. For each targeted framework it emits one *_generated.go wrapper file per ObjC class, bundling raw alloc+init calls into Go constructors and improving async, collection, and error-handling ergonomics.

func SortByDependency

func SortByDependency(reg *Registry) []*meta.FrameworkMeta

SortByDependency returns frameworks in topological order (dependencies first).

Types

type BindingsConfig

type BindingsConfig struct {
	Registry         *Registry
	FrameworksOutDir string // e.g. ./purego-frameworks
	LibrariesOutDir  string // e.g. ./purego-libraries
	Verbose          bool

	// DiagnosticsSink, when non-nil, receives every type-degradation
	// diagnostic recorded by the per-framework type mappers (unsafe.Pointer
	// fallbacks and cycle-forced objc.ID substitutions). The CLI uses this
	// to enforce a committed diagnostics baseline.
	DiagnosticsSink *[]string

	// Manifest, when non-nil, receives one parity entry per emitted construct
	// (keyed on its ObjC/C name), so the raw output can serve as the oracle the
	// idiomatic emitter's coverage is checked against. It never affects the
	// emitted bytes.
	Manifest *emitmanifest.Recorder
}

BindingsConfig controls the bindings generation pass.

type IdiomaticConfig

type IdiomaticConfig struct {
	// Registry is the combined metadata for all frameworks.
	Registry *Registry
	// OutDir is the root output directory. Each framework writes to OutDir/<pkgname>/.
	// Canonical value: <repo-root>/bindings
	OutDir string
	// Frameworks is an optional filter; empty means all frameworks.
	Frameworks []string
	// Verbose enables diagnostic output.
	Verbose bool

	// Manifest, when non-nil, receives one parity entry per emitted construct so
	// the idiomatic layer's coverage can be checked against the raw oracle. It
	// never affects the emitted bytes.
	Manifest *emitmanifest.Recorder
}

IdiomaticConfig controls generation of the opinionated idiomatic layer.

type Registry

type Registry struct {
	Frameworks        []*meta.FrameworkMeta
	ClassNameIndex    map[string]bool
	GenericClasses    map[string]bool
	GenericParamIndex map[string][]string
	OwnerIndex        map[string]string // className → framework name
	ProtocolIndex     map[string]string // protocol name → owning framework
	EnumIndex         map[string]string // enum name → owning framework
	EnumGoTypeIndex   map[string]string // enum name → underlying Go type
	TypedefIndex      map[string]string // typedef name → target ObjC qualType
	TypedefOwnerIndex map[string]string
	StructIndex       map[string]string // struct name → owning framework
	// LocalStructs maps framework name → exported Go names of field-bearing
	// structs it declares locally (see typemap.Mapper.LocalStructs).
	LocalStructs map[string]map[string]bool
	CFTypeIndex  map[string]string // CF opaque typedef → owning framework
	// NonRefcountedHandles is the subset of CFTypeIndex opaque handles that are NOT
	// reference-counted — a plain C handle (e.g. AudioComponent, AudioQueueRef) with
	// its own dispose function and no CFTypeID. Detected by the ABSENCE of a
	// <Type>GetTypeID function. objc_retain/objc_release on such a pointer crashes,
	// so the emitter wraps them with obj.WrapUnmanaged (no retain, no finalizer)
	// rather than obj.Wrap.
	NonRefcountedHandles map[string]bool
	ClassIndex           map[string]meta.Class
	// EmittableStructs is the set of value-struct Go names the idiomatic layer
	// emits a definition for (computed lazily once during idiomatic generation).
	EmittableStructs map[string]bool
	// UnavailableClasses is the set of ObjC class names that have IsUnavailable=true.
	// The mapper degrades references to these classes to objc.ID.
	UnavailableClasses map[string]bool
	// UnavailableEnumBaseTypes maps unavailable enum names → underlying Go type.
	// The mapper degrades references to these enums to their base integer type.
	UnavailableEnumBaseTypes map[string]string
	// BlockedImports[src][dst]=true means src must not import dst (cycle break).
	BlockedImports map[string]map[string]bool
	// IdiomaticConfigIndex maps framework name → its parsed idiomatic.json
	// sidecar (curated renames, delegate selection, error typedefs). Frameworks
	// without a sidecar are absent; lookups yield nil, which every idioconf
	// helper accepts.
	IdiomaticConfigIndex map[string]*idioconf.File
	// ModulePrefix is the Go module path prefix for framework packages.
	// e.g. "github.com/deploymenttheory/go-bindings-macosplatform/purego-frameworks"
	ModulePrefix string
	// LibraryModulePrefix is the module path prefix for C library packages.
	LibraryModulePrefix string
}

Registry holds combined metadata from all loaded frameworks. It is the single source of truth for cross-framework type resolution.

func LoadAll

func LoadAll(paths []string, modulePrefix, libraryModulePrefix string) (*Registry, error)

LoadAll reads .gometa.json files from the given paths (files or directories) and builds a Registry. Directories are scanned one level deep; arm64 files are preferred when multiple arch variants exist.

Jump to

Keyboard shortcuts

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