Move examples/*.sx and their expected/ snapshots into per-category subfolders (examples/<category>/...). Folder = leading filename token, with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus runner and LSP sweep now discover each category's expected/ dir, while issues/ stays flat. Example 1058's repo-root-relative companion import is made file-relative. Path strings embedded in 164 snapshots were regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
36 lines
1.1 KiB
Plaintext
36 lines
1.1 KiB
Plaintext
// Phase 3 step 3.0: one-arg selector mangling. `addObject(o)` derives
|
|
// `addObject:` — the sx method name becomes the keyword, a single
|
|
// trailing `:` for the single arg. Selector arity (count of `:`) must
|
|
// equal sx-side arity excluding self.
|
|
//
|
|
// Pre-3.0: bails at lower.zig with the Phase 3/4 diagnostic.
|
|
#import "modules/std.sx";
|
|
#import "modules/build.sx";
|
|
#import "modules/ffi/objc.sx";
|
|
|
|
SxProbeOneArg :: #objc_class("SxProbeOneArg") extern {
|
|
addObject :: (self: *Self, val: i32) -> i32;
|
|
}
|
|
|
|
addObject_imp :: (self: *void, _cmd: *void, val: i32) -> i32 abi(.c) {
|
|
val * 2
|
|
}
|
|
|
|
main :: () -> i32 {
|
|
inline if OS == .macos {
|
|
ns_object := objc_getClass("NSObject".ptr);
|
|
cls := objc_allocateClassPair(ns_object, "SxProbeOneArg".ptr, 0);
|
|
sel := sel_registerName("addObject:".ptr);
|
|
class_addMethod(cls, sel, xx addObject_imp, "i@:i".ptr);
|
|
objc_registerClassPair(cls);
|
|
|
|
inst : *SxProbeOneArg = xx class_createInstance(cls, 0);
|
|
n := inst.addObject(21);
|
|
print("addObject(21) = {}\n", n);
|
|
}
|
|
inline if OS != .macos {
|
|
print("skipped (not macos)\n");
|
|
}
|
|
0
|
|
}
|