Files
sx/examples/0716-modules-cli-argv.sx
agra 811a280517 refactor(ffi-linkage): Phase 9.3 — purge 'foreign' from comments (src caps + examples + docs)
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.
2026-06-15 10:52:56 +03:00

32 lines
1.1 KiB
Plaintext

// Real OS-argv accessor from `modules/std/cli.sx` (extern _NSGetArgv).
//
// Only DETERMINISTIC structural invariants are asserted — the actual arg
// contents depend on how the test is invoked (under `sx run` the process
// argv is the interpreter's: ["sx", "run", "<this file>"]), so we never
// pin exact strings:
// - argc >= 1 (every process has argv[0])
// - argv[0] is non-empty (the executable path)
// - os_argc() agrees with the filled slice length (no truncation)
//
// `buf` is a stack `[64]string`; `os_args` fills it with zero-copy views
// over the C runtime's argv block — no heap, no per-arg allocation.
#import "modules/std.sx";
#import "modules/std/cli.sx";
main :: () {
buf : [64]string = ---;
args := os_args(buf[0..64]);
if args.len >= 1 { print("argc>=1: ok\n"); }
else { print("argc>=1: FAIL ({})\n", args.len); }
if args.len >= 1 {
if args[0].len > 0 { print("arg0-nonempty: ok\n"); }
else { print("arg0-nonempty: FAIL\n"); }
}
if os_argc() == args.len { print("argc-consistent: ok\n"); }
else { print("argc-consistent: FAIL (os_argc={} len={})\n", os_argc(), args.len); }
}