Hi all,

I create an utility to generate ATS interface from C code. It's useful
to create application rapidly.


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 =

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:


Best regards,

You received this message because you are subscribed to the Google Groups 
"ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ats-lang-users+unsubscr...@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 

Reply via email to