Documentation
¶
Overview ¶
Package mainactor applies the @MainActor isolation sidecar (internal/mainactor) to the purego generator's metadata model so the idiomatic emitter can wrap main-thread-bound calls in purego.Main.
Two steps, mirroring how Apple actually models isolation:
- ApplyAdjacent stamps the facts a framework's own sidecar carries: whole classes that are @MainActor, individually-isolated selectors, and the `nonisolated` opt-outs.
- Propagate then pushes class-level isolation DOWN the Objective-C class hierarchy across all frameworks, because Apple isolates a small root set (NSView, NSWindow, …) and every subclass inherits it implicitly. This is what makes MKMapView / PDFView / SCNView main-thread-bound even though their own frameworks declare no @MainActor classes.
The file format and discovery convention are identical to the appledocs sidecar; only the mutated fields differ.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
func Apply(iso *rootactor.Isolation, framework *meta.FrameworkMeta)
Apply stamps iso's directly-stated isolation onto framework in place: whole-class flags, per-selector isolation, and `nonisolated` exemptions.
func ApplyAdjacent ¶
func ApplyAdjacent(metaPath string, framework *meta.FrameworkMeta) error
ApplyAdjacent looks for a mainactor.json sidecar next to metaPath and applies its directly-stated facts to framework. A missing sidecar is not an error. Hierarchy propagation is a separate, cross-framework pass (see Propagate).
func Propagate ¶
func Propagate(frameworks []*meta.FrameworkMeta)
Propagate pushes class-level @MainActor isolation down the class hierarchy across all loaded frameworks, then stamps the affected instance methods so the emitter (which keys off Method.IsMainThreadRequired) wraps them. Call once after every framework's sidecar has been applied.
Types ¶
This section is empty.