Documentation
¶
Index ¶
- func EmitAsync(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, ...) error
- func EmitBlockEnum(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, ...) error
- func EmitCollections(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, ...) error
- func EmitConstructors(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, ...) error
- func EmitDelegates(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, ...) error
- func EmitMainThread(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, ...) error
- func EmitProperties(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, ...) error
- func EmitTypeAliases(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, ...) error
- type NameTracker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmitAsync ¶
func EmitAsync(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, m *typemap.Mapper, knownClasses map[string]bool, nt *NameTracker) error
ErgonomicAsync emits sync-blocking wrappers for AsyncCompletion-tagged methods.
Each generated function:
- Removes the trailing block argument
- Creates a buffered channel of one result struct
- Passes a Go closure as the completion handler
- Selects on the channel or ctx.Done()
- Returns (blockDataValues..., error)
func EmitBlockEnum ¶
func EmitBlockEnum(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, m *typemap.Mapper, knownClasses map[string]bool, nt *NameTracker) error
ErgonomicBlockEnum emits ergonomic wrappers for BlockEnumeration-tagged methods.
The generated function accepts a Go callback (fn) with the enumeration arguments (excluding the BOOL *stop parameter). Returning false from fn sets *stop = YES, which causes ObjC to stop the enumeration:
func EnumerateObjects[T objc.Object](ctx context.Context, o *raw.NSArray[T],
fn func(obj T, idx uint64) bool)
For non-generic classes, the Go callback uses the detected element type directly.
func EmitCollections ¶
func EmitCollections(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, m *typemap.Mapper, knownClasses map[string]bool, nt *NameTracker) error
ErgonomicCollections emits package-level functions that bridge CollectionReturn and CollectionParam methods to idiomatic Go slices / maps via the shared package helpers.
CollectionReturn methods return an NSArray/NSSet/NSDictionary — the ergonomic wrapper converts the result to a typed Go slice ([]T). CollectionParam methods accept NS collection args — the ergonomic wrapper accepts a Go slice and converts it before calling the raw method.
func EmitConstructors ¶
func EmitConstructors(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, m *typemap.Mapper, knownClasses map[string]bool, nt *NameTracker) error
ErgonomicConstructors emits package-level ergonomic wrappers for BoolNSError and NSErrorOut methods. BoolNSError wrappers drop the redundant bool return; NSErrorOut wrappers are pass-through aliases with the ergonomic package-level function shape.
func EmitDelegates ¶
func EmitDelegates(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, m *typemap.Mapper, knownClasses map[string]bool, nt *NameTracker) error
ErgonomicDelegates emits Go delegate interfaces and the Set<Class>Delegate bridge functions for every class that has a delegate/dataSource property backed by a DelegateProtocol-tagged protocol.
Output per framework:
- <fw>_delegates_generated.go — Go interfaces + SetXxxDelegate functions
func EmitMainThread ¶
func EmitMainThread(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, m *typemap.Mapper, knownClasses map[string]bool, nt *NameTracker) error
ErgonomicMainThread emits package-level wrappers for MainThreadRequired-tagged methods.
Each generated function dispatches the raw method call through objc.RunOnMainThread. Return values are captured via a closure variable that is readable after RunOnMainThread returns (it blocks until the closure completes):
func UpdateUI(ctx context.Context, o *raw.NSView) {
objc.RunOnMainThread(func() { o.UpdateUI(ctx) })
}
func EmitProperties ¶
func EmitProperties(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, m *typemap.Mapper, knownClasses map[string]bool, nt *NameTracker) error
ErgonomicProperties emits context-free package-level getter/setter function pairs for each non-readonly property on every class (PropertyPair pattern).
Generated shape:
func AlphaValue(o *raw.NSView) float64 func SetAlphaValue(o *raw.NSView, v float64)
Properties are simple synchronous reads/writes and rarely need tracing at the OTel level. Context-free wrappers inject context.Background() internally so callers don't need to thread a context through property access chains. Complex methods (blocks, async, NSError) remain in other ergonomic emitters where a real context matters.
func EmitTypeAliases ¶
func EmitTypeAliases(w io.Writer, pkgName, rawImportPath string, framework *meta.FrameworkMeta, m *typemap.Mapper, knownClasses map[string]bool) error
ErgonomicTypeAliases emits Go type aliases that strip the "NS" prefix from ObjC class names so consumers can write foundation.String instead of raw.NSString (matching DarwinKit's package-scoped naming convention).
Generated shape (non-generic):
type String = raw.NSString type URL = raw.NSURL
Generated shape (generic):
type Array[T objc.Object] = raw.NSArray[T]
Only classes whose stripped name (a) differs from the original, (b) is unique within the framework, and (c) does not shadow a Go predeclared identifier are emitted. The aliases are purely additive — the raw types remain accessible via the "raw" import alias.
Types ¶
type NameTracker ¶
type NameTracker struct {
// contains filtered or unexported fields
}
NameTracker tracks package-level function names claimed by any ergonomic emitter for the current framework. All emitters share one instance per framework so cross-emitter collisions are caught before code is emitted.
Previously each emitter maintained its own per-file `seen` map. When two emitters produced a function with the same name (e.g. constructors and properties both emitting "ScrollDirection") the second file failed to compile. This type serialises all claims into a single registry.
func NewNameTracker ¶
func NewNameTracker() *NameTracker
NewNameTracker returns a NameTracker ready for use.
func (*NameTracker) Claim ¶
func (nt *NameTracker) Claim(name, emitter string) bool
Claim reserves name for the named emitter. Returns true when the claim succeeds (name was unclaimed). Returns false when already claimed by any emitter, including the caller itself.