idiolib

package
v0.19.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectDeclaredNames added in v0.17.0

func CollectDeclaredNames(src []byte) (map[string]bool, error)

CollectDeclaredNames parses Go source and returns the exported top-level identifiers it declares (types, consts, vars, and funcs). The library pipeline uses it to gather the names the ergonomic emitters produce so the alias re-export never collides with them.

func EmitAliases added in v0.17.0

func EmitAliases(
	w *bytes.Buffer,
	pkgName, rawImportPath, rawSrcDir string,
	skip map[string]bool,
) error

EmitAliases re-exports every exported top-level type, constant, and variable the raw C-library package declares as an idiomatic alias (`type X = raw.X`, `const X = raw.X`, `var X = raw.X`), so callers reach the library's enums, structs, protocols, and global values through the idiomatic package without importing the raw bindings. Free functions are intentionally not re-exported: the idiomatic layer surfaces them as handle methods and ergonomic wrappers.

The re-export list is read from the raw package's own emitted source (rawSrcDir) rather than re-derived from metadata, so it always matches exactly what the raw layer exports — names, dedup, and skips included. Nothing is written when the raw package has no re-exportable declarations.

func EmitAsync

func EmitAsync(w io.Writer, pkgName, rawImportPath string, framework *macosplatformmetadata.FrameworkMeta, m *typemap.Mapper, knownClasses map[string]bool) error

Async writes blocking wrappers for completion-handler methods.

For every instance method whose last block argument matches the pattern "void (^...)(NSError *)", a package-level function is emitted that blocks via a buffered channel until the handler fires or ctx is cancelled.

pkgName is the Go package name (e.g. "virtualization"); rawImportPath is the full import path of the raw framework package.

func EmitCFunctions

func EmitCFunctions(w io.Writer, pkgName, rawImportPath string, framework *macosplatformmetadata.FrameworkMeta, m *typemap.Mapper, knownClasses map[string]bool) error

EmitCFunctions writes the idiomatic wrapper layer for a C library's plain functions into <pkgName>_generated.go, transforming the already-clean raw bindings:

  • Handles-as-methods: opaque C handle typedefs (typedefs ending in _t that resolve to unsafe.Pointer and are neither enums, structs, nor function-pointer typedefs) become Go wrapper structs; a function whose first argument is such a handle becomes a method on that wrapper.
  • Prefix stripping: the common C symbol prefix (es_, xpc_, dispatch_, …) is dropped and the remainder PascalCased, so es_message_size → MessageSize.
  • Error conversion: OSStatus / kern_return_t returns become a Go error.

Functions with block / function-pointer arguments, or whose raw Go symbol is unexported (leading-underscore C symbols), are skipped — the raw binding remains available for those.

func EmitSlices

func EmitSlices(w io.Writer, pkgName, rawImportPath string, framework *macosplatformmetadata.FrameworkMeta, m *typemap.Mapper, knownClasses map[string]bool) error

Slices writes typed slice accessors for NSArray-typed properties.

For every property whose ObjC type is NSArray<ClassName *> where ClassName belongs to the same framework, two functions are emitted:

  • FooList(recv) []*raw.Foo — typed getter
  • SetFooList(recv, items) — typed setter (non-readonly properties only)

func EmitSpecs

func EmitSpecs(w io.Writer, pkgName, rawImportPath string, framework *macosplatformmetadata.FrameworkMeta, m *typemap.Mapper, knownClasses map[string]bool) error

Specs writes Spec structs and Apply functions for *Configuration classes.

For every class whose name ends in "Configuration" with ≥ 3 non-readonly properties, a plain Go struct (FooConfigurationSpec) and an Apply function are emitted. The Apply function sets non-zero fields and calls ValidateWithError when the class supports it.

The caller is responsible for creating the configuration instance (e.g. via a factory function in this package) before calling Apply.

func PackageExports added in v0.17.0

func PackageExports(dir string) (map[string]bool, error)

PackageExports returns every exported top-level identifier a package's Go files declare (types, consts, vars, and funcs). It is the idiomatic side of the library parity check.

func ReExportableExports added in v0.17.0

func ReExportableExports(rawSrcDir string) (map[string]bool, error)

ReExportableExports returns the raw package's exported type, const, and var identifiers — the constructs the alias re-export covers — as a set. It is the oracle side of the library parity check (functions are excluded: the idiomatic layer surfaces them as methods, not package-level names).

Types

This section is empty.

Directories

Path Synopsis
Package render executes the idiomatic CGo library templates.
Package render executes the idiomatic CGo library templates.
Package view holds the pure-data IR structs for the idiomatic CGo library emitter (idiolib).
Package view holds the pure-data IR structs for the idiomatic CGo library emitter (idiolib).

Jump to

Keyboard shortcuts

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