- objc.sx, objc_block.sx (from std/) + sdl3/opengl/raylib/stb/stb_truetype/ wasm vendor bindings (from modules/ root) -> modules/ffi/ - std/uikit.sx deleted: platform/uikit.sx already declares UIApplicationMain and imports objc; '#framework "UIKit"' cannot live in a file imported on macOS targets (unconditional link directive, UIKit is iOS-only), so the three iOS-only examples carry the 3-line glue inline. 1607/1608/1616 also un-rotted (dead ns_string -> 'xx "..."' Into conversions, callconv(.c) msgSend fn-ptrs) — all three build for ios-sim/ios again. - math/math.sx -> math/scalar.sx; one spelling '#import "modules/math"' everywhere (4 pinned IR snapshots regenerated: dir import adds Vec2/Mat4 to the type tables). - compiler.sx -> build.sx (imports, CLAUDE.md bundling table, specs.md). - testpkg/ + test_c.sx -> tests/fixtures/ (resolve CWD-relative from repo root, same as vendors/). - library-internal imports use full modules/... paths (std.sx tail, platform/bundle.sx, fixtures).
39 lines
1.3 KiB
Plaintext
39 lines
1.3 KiB
Plaintext
// Closure free-variable capture works through `FfiIntrinsicCall`
|
|
// nodes — names referenced inside `#objc_call` / `#jni_call` /
|
|
// `#jni_static_call` argument lists from inside a closure body are
|
|
// recognized as captured variables and bound from the closure's env
|
|
// struct at call time. `passthrough_works` is the baseline (normal
|
|
// expression capture); `passthrough_via_objc_call` exercises the same
|
|
// capture through an FFI intrinsic call's arg list.
|
|
|
|
#import "modules/std.sx";
|
|
#import "modules/build.sx";
|
|
#import "modules/ffi/objc.sx";
|
|
|
|
passthrough_works :: (recv: *void) -> Closure(s32) -> *void {
|
|
closure((d: s32) -> *void => recv) // captures `recv` — fine
|
|
}
|
|
|
|
passthrough_via_objc_call :: (recv: *void) -> Closure(s32) -> s64 {
|
|
// Same `recv` capture, but inside `#objc_call(...)`'s arg list.
|
|
closure((d: s32) -> s64 => #objc_call(s64)(recv, "hash"))
|
|
}
|
|
|
|
main :: () -> s32 {
|
|
inline if OS == .macos {
|
|
f := passthrough_works(null);
|
|
p := f(0);
|
|
print("ok (passthrough works) = {}\n", p == null);
|
|
|
|
// Capture inside the `#objc_call` arg list.
|
|
ns_object := objc_getClass("NSObject".ptr);
|
|
g := passthrough_via_objc_call(ns_object);
|
|
h := g(0);
|
|
print("ok (passthrough via #objc_call) = {}\n", h != 0);
|
|
}
|
|
inline if OS != .macos {
|
|
print("skipped (not macos)\n");
|
|
}
|
|
0
|
|
}
|