Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Future of labels
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Fox <dsfox@c...>
Subject: [Caml-list] Foreign function interface generator with examples
This is to announce a package for generating ocaml foreign function
interfaces.  It is designed to allow you to specify the interface to C
types and data using ocaml code, which is then translated into a mix
of C code and ocaml external declarations.  It is patterned after the
foreign function facilities of Manuel Serrano's Bigloo Scheme
compiler, and it even includes a program to convert a set of Bigloo
directives into an ocaml specification.  Furthermore, Bigloo includes
a program to convert C header files into Bigloo foreign interface
directives, so the automatic generation of these interfaces is within
reach.

Several examples are included, one called "libc.ml" which provides
access to a few libc functions and structures.  It includes getenv,
gettimeofday and the timeval struct, fopen, fread, fclose, and a few
others.  The second is x.ml, which was automatically generated from a
scheme file xlib.sch, which itself was generated from the C header
files for Xlib using the cigloo tool, which is part of the bigloo
distribution.  From this it builds xtop, a top level with access to
the X library, and "hello", a translation to ocaml of a small Xlib
example program borrowed from a book by Oliver Jones.  (Warning, as of
ocaml-3.01 the xtop program gets a segmentation fault.)  The third
example is in the xextra subdirectory, an X library extension written
in C++ and an image viewer program "xextra-test."  Left mouse button
drags, middle and right buttons zoom in and out.

There are more than a few remaining rough spots in the program.  I
haven't tried some of the types it purports to handle.  This situation
should improve in the coming weeks.  This is only my second ocaml
program, so I am making this preliminary release to try and get some
comments and suggestions about whether the thing works, about any
aspect of the design or implementation that people want to tell me
about, or even whether the idea of generating FFI's this way has
value.  And if anyone wants to help.  You may notice a few peculiar
things about the program:

  1) I don't understand the module system,
  2) I don't understand signatures,
  3) I don't understand labels,

and so on and so on.

So, get it here: ftp://ftp.fox-thompson.com/pub/ffi.tar.gz

David Fox
April, 2001
La Jolla, CA
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr