- 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).
49 lines
1.5 KiB
Plaintext
49 lines
1.5 KiB
Plaintext
// M1.3 — `obj.class` accessor on Obj-C pointers.
|
|
//
|
|
// Any Obj-C-class pointer (foreign or sx-defined) can be probed
|
|
// for its runtime class object via `obj.class`. Lowers to
|
|
// `object_getClass(obj)`. Returns `Class` (alias for *void —
|
|
// parameterized `Class(T)` covariance is M1.1.b).
|
|
//
|
|
// Verifies both shapes:
|
|
// 1. (*SxFoo).class — sx-defined class. Returns the SxFoo Class.
|
|
// 2. (*NSObject).class — foreign class via stdlib. Returns NSObject's
|
|
// Class.
|
|
|
|
#import "modules/std.sx";
|
|
#import "modules/build.sx";
|
|
#import "modules/ffi/objc.sx";
|
|
|
|
NSObjectFwd :: #foreign #objc_class("NSObject") {
|
|
alloc :: () -> *NSObjectFwd;
|
|
init :: (self: *NSObjectFwd) -> *NSObjectFwd;
|
|
}
|
|
|
|
SxFoo :: #objc_class("SxFoo") {
|
|
counter: s32;
|
|
alloc :: () -> *SxFoo;
|
|
bump :: (self: *Self) { self.counter += 1; }
|
|
}
|
|
|
|
main :: () -> s32 {
|
|
inline if OS == .macos {
|
|
// sx-defined class round-trip.
|
|
f := SxFoo.alloc();
|
|
cls_f : Class = f.class;
|
|
expected_f : Class = objc_getClass("SxFoo".ptr);
|
|
if cls_f != expected_f { print("FAIL: SxFoo.class mismatch\n"); return 1; }
|
|
|
|
// foreign class round-trip.
|
|
nso := NSObjectFwd.alloc().init();
|
|
cls_n : Class = nso.class;
|
|
expected_n : Class = objc_getClass("NSObject".ptr);
|
|
if cls_n != expected_n { print("FAIL: NSObject.class mismatch\n"); return 1; }
|
|
|
|
print("class accessor: ok\n");
|
|
}
|
|
inline if OS != .macos {
|
|
print("class accessor: ok\n");
|
|
}
|
|
0
|
|
}
|