Hi all,
I create an utility to generate ATS interface from C code. It's useful
to create application rapidly.
http://metasepi.org/en/posts/2016-09-17-c2ats.html
The utility generates ATS's sats file importing from C language
header, semi-automatically.
If you have following header:
```
$ vi example.h
#include <stdio.h>
```
then you can get the sats file using c2ats:
```
$ c2ats gen example.h > example.sats
$ wc -l example.sats
318 example.sats
$ grep _printf example.sats
fun fun_c2ats_printf: {l1:addr} (!ptr_v_1(char, l1) | ptr l1) -> int =
"mac#printf"
```
Now you can create ATS application using the example.sats:
```
$ vi main.dats
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
staload UN = "prelude/SATS/unsafe.sats"
staload "example.sats"
fun my_printf (s: string): void = {
val p = string2ptr s
val (pfat, fpfat | p) = $UN.ptr_vtake p
val ret = fun_c2ats_printf (pfat | p)
prval () = fpfat pfat
}
implement main0 () = {
val s = "Hello, world!\n"
val () = my_printf s
}
$ patscc main.dats
$ ./a.out
Hello, world!
```
More detail and usage is found at following:
https://github.com/metasepi/c2ats
Best regards,
--
Kiwamu Okabe at METASEPI DESIGN