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.
29 lines
1.0 KiB
Plaintext
29 lines
1.0 KiB
Plaintext
// `extern` C-variadic tail: trailing `..args: []T` on a extern fn maps
|
|
// to the C calling convention's `...`. Extras at the call site are
|
|
// passed via the variadic slot with the standard default argument
|
|
// promotion (i8/i16/bool → i32, f32 → f64) applied implicitly.
|
|
|
|
#import "modules/std.sx";
|
|
|
|
#import c {
|
|
#source "1218-ffi-foreign-cvariadic.c";
|
|
};
|
|
|
|
sx_ffi_sum_ints :: (n: i32, ..args: []i32) -> i64 extern;
|
|
sx_ffi_avg_doubles :: (n: i32, ..args: []f64) -> f64 extern;
|
|
sx_ffi_count_args :: (tag: *u8, ..args: []*u8) -> i32 extern;
|
|
|
|
main :: () -> i32 {
|
|
print("sum_ints(3, 10, 20, 30) = {}\n", sx_ffi_sum_ints(3, 10, 20, 30));
|
|
print("sum_ints(0) = {}\n", sx_ffi_sum_ints(0));
|
|
print("avg_doubles(2) = {}\n", sx_ffi_avg_doubles(2, 1.5, 2.5));
|
|
print("avg_doubles(3) = {}\n", sx_ffi_avg_doubles(3, 1.0, 2.0, 3.0));
|
|
|
|
a := "alpha".ptr;
|
|
b := "beta".ptr;
|
|
g := "gamma".ptr;
|
|
sentinel : *u8 = null;
|
|
print("count_args(3 strs) = {}\n", sx_ffi_count_args("tag".ptr, a, b, g, sentinel));
|
|
0
|
|
}
|