// issue-0027: Feature — support Obj-C blocks (^{...}) so sx code can call // APIs that take a block parameter. Required for step 4 of the Metal port // (keyboard lockstep via `[UIView animateWithDuration:animations:^{...}]`), // and broadly useful for any UIKit/AppKit API. // // ── Proposed surface ────────────────────────────────────────────────────── // // Option A — comptime intrinsic that wraps a sx closure as a block: // // block := objc_block(@my_closure); // returns *void (an id) // msg_block(view, sel, 0.3, block); // pass like any id arg // // Internals: emit a Block_literal struct constant with the right invoke // fn pointer, isa, flags, descriptor pointer. Approximately what clang // generates for ^{...}. // // Option B — surface-level syntax `^{ ... }` that lowers to Option A // automatically. Cleaner for users; more parser work. // // Recommended: start with Option A (intrinsic). Migrate to Option B once // the codegen path is proven. // // ── Implementation sketch ──────────────────────────────────────────────── // // 1. New `library/modules/std/objc_block.sx` defining the Block_literal // struct that mirrors clang's layout (isa, flags, reserved, invoke fn // pointer, descriptor pointer). // 2. `objc_block(fn_or_closure) -> *void` intrinsic that builds the // literal at the call site. Initial implementation can be a // stack-allocated block (_NSConcreteStackBlock); upgrade to // heap-promoted (_Block_copy) once block lifetime exceeds the call. // 3. Link libSystem's symbols `_NSConcreteStackBlock` and // `_NSConcreteGlobalBlock` (auto on iOS; may need `#library "System"` // on macOS). // 4. (Deferred) surface syntax `^{ ... }` — parser hook + lowering // to the intrinsic. Must not clash with bitwise XOR `^`. // // ── References ──────────────────────────────────────────────────────────── // // - Apple block ABI spec (clang's "Block Implementation Specification") // - _NSConcreteStackBlock + _NSConcreteGlobalBlock from libSystem // // ── Real-world impact ───────────────────────────────────────────────────── // // Without this, the keyboard inset cannot be animated in lockstep with the // keyboard slide. See library/modules/platform/uikit.sx's // uikit_keyboard_will_change_frame comments for the deferred lockstep work. #import "modules/std.sx"; main :: () -> s32 { 0; }