From da748748c0239c21b9d62c77b51e269ad1d7de9f Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sun, 1 Mar 2020 12:08:28 -0500 Subject: better #foreign system --- tests/foreign/foreign.toc | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'tests/foreign/foreign.toc') diff --git a/tests/foreign/foreign.toc b/tests/foreign/foreign.toc index beaa822..d88a223 100644 --- a/tests/foreign/foreign.toc +++ b/tests/foreign/foreign.toc @@ -1,20 +1,13 @@ -voidptr ::= &u8; - -getstdout ::= fn() voidptr { - #builtin("stdout") -}; - - -fwrite :: fn(voidptr, u64, u64, voidptr) u64 = #foreign "fwrite", "libc.so.6"; -fputc :: fn(i32, voidptr) i32 = #foreign "fputc", "libc.so.6"; +fwrite ::= #foreign("fwrite", "libc.so.6") fn (#C &"void const", #C size_t, #C size_t, &u8) #C size_t; +fputc ::= #foreign("fputc", "libc.so.6") fn (#C int, &u8) #C int; writes ::= fn(x : []char) { - fwrite(&x[0] as voidptr, 1, x.len as u64, getstdout()); + fwrite(&x[0], 1, x.len as u64, #builtin("stdout")); }; puts ::= fn(x : []char) { writes(x); - fputc('\n' as i32, getstdout()); + fputc('\n' as i32, #builtin("stdout")); }; hw ::= fn() int { -- cgit v1.2.3