-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FFI accepts arguments and returns values
- Loading branch information
Showing
7 changed files
with
115 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
module ffi = import auro.ffi; | ||
module mylib = (ffi.`import`)({ `0` = mylib_name; }); | ||
module foo_mod = (mylib.get)({ name = foo_name; }); | ||
|
||
void foo () = foo_mod.``; | ||
type i8 = ffi.i8; | ||
i8 to_i8 (int) = ffi.i8$`new`; | ||
int from_i8 (i8) = ffi.i8$get; | ||
|
||
module foo_mod = (mylib.get)({ | ||
name = foo_name; | ||
in0 = i8; | ||
out = i8; | ||
}); | ||
|
||
i8 foo (i8) = foo_mod.``; | ||
|
||
string mylib_name () { return "./mylib"; } | ||
string foo_name () { return "foo"; } | ||
|
||
void main () { | ||
foo(); | ||
int n = from_i8(foo(to_i8(42))); | ||
println("This is auro: " + itos(n)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
void foo () { printf("This is C"); } | ||
#include <stdio.h> | ||
|
||
char foo (char n) { | ||
printf("This is C: %d\n", n); | ||
return n + 10; | ||
} |
Binary file not shown.