// structs by value in native calls: a zc struct of word fields is passed to a c // function as its words. the helper library is built by test.sh (build/sbv.so). struct Pair { int a; int b; } struct Vec { float x; float y; } struct Trio { int a; int b; int c; } extern long pair_sum(struct Pair p); extern long pair_sum2(struct Pair p, struct Pair q); extern long vec_scaled(struct Vec v, long k); extern long many(long a, long b, long c, long d, long e, long f, struct Pair p); extern long trio_sum(long a, long b, long c, long d, long e, long f, struct Trio t); extern long eight(long a, long b, long c, long d, long e, long f, long g, long h, struct Pair p); int main() { Pair p; Pair q; Vec v; Trio t; cload(b"build/sbv.so"); p.a = 3; p.b = 4; put_n(pair_sum(p)); put_c(32); q.a = 10; q.b = 20; put_n(pair_sum2(p, q)); put_c(32); v.x = 1.5; v.y = 2.0; put_n(vec_scaled(v, 2)); put_c(32); put_n(many(1, 2, 3, 4, 5, 6, p)); put_c(32); t.a = 7; t.b = 8; t.c = 9; put_n(trio_sum(1, 2, 3, 4, 5, 6, t)); put_c(32); put_n(eight(1, 2, 3, 4, 5, 6, 7, 8, p)); put_c(10); return 0; }