caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Foreign function interface generator with examples
@ 2001-04-17 20:20 David Fox
  2001-04-18  3:06 ` David Fox
  0 siblings, 1 reply; 8+ messages in thread
From: David Fox @ 2001-04-17 20:20 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-04-20 22:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-17 20:20 [Caml-list] Foreign function interface generator with examples David Fox
2001-04-18  3:06 ` David Fox
2001-04-18 13:53   ` David Fox
2001-04-20  3:01     ` David Fox
2001-04-20  8:52       ` Chris Hecker
2001-04-20  9:37       ` jeanmarc.eber
2001-04-20 11:51       ` Fabrice Le Fessant
2001-04-20 22:02       ` David Fox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).