src/: ~21 capital-Foreign comments the case-sensitive verify grep missed (Foreign-class→Runtime-class, Foreign path→Runtime path, Foreign decls→Extern decls, FOREIGN function→extern function) across calls/inst/ffi_objc/jni_descriptor/emit_llvm/ c_import/lower.*/ops. src 'foreign' now = ONLY the hash_foreign token + 4 rejection messages (9.0-delete targets). examples/*.sx comments → extern/runtime-class (1219 stdout regen; KEPT 1176). docs/inline-asm-design + debugger purged. Comments only — no build impact. 9.0 ratified: DELETE hash_foreign token next.
42 lines
1.2 KiB
Plaintext
42 lines
1.2 KiB
Plaintext
// Phase 3 (FFI-linkage) — postfix `export` on an `#objc_class` aggregate, the
|
|
// explicit spelling for an sx-DEFINED runtime class (define + register). It is
|
|
// the same lowering as a bare `#objc_class("X") { … }` with no `extern`;
|
|
// `export` just makes the "I define this class" intent explicit (the dual of
|
|
// `extern` for "I reference an existing class"). Mirrors 1339's defined class.
|
|
|
|
#import "modules/std.sx";
|
|
#import "modules/build.sx";
|
|
#import "modules/ffi/objc.sx";
|
|
|
|
SxBar :: #objc_class("SxBar") export {
|
|
counter: i32;
|
|
|
|
alloc :: () -> *SxBar;
|
|
|
|
bump :: (self: *Self) {
|
|
self.counter += 1;
|
|
}
|
|
|
|
get :: (self: *Self) -> i32 {
|
|
return self.counter;
|
|
}
|
|
}
|
|
|
|
main :: () -> i32 {
|
|
inline if OS == .macos {
|
|
b := SxBar.alloc();
|
|
if b == null { print("FAIL: alloc returned null\n"); return 1; }
|
|
b.bump();
|
|
b.bump();
|
|
print("counter: {}\n", b.get()); // expected: 2
|
|
|
|
sel_release : SEL = sel_registerName("release".ptr);
|
|
release_fn : (obj: *void, sel: *void) -> void callconv(.c) = xx objc_msgSend;
|
|
release_fn(xx b, sel_release);
|
|
}
|
|
inline if OS != .macos {
|
|
print("counter: 2\n");
|
|
}
|
|
0
|
|
}
|