caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Fox <dsfox@cogsci.ucsd.edu>
To: caml-list@inria.fr
Subject: [Caml-list] Foreign function interface generator with examples
Date: 17 Apr 2001 13:20:07 -0700	[thread overview]
Message-ID: <lubspv5le0.fsf_-_@hci.ucsd.edu> (raw)
In-Reply-To: "Stefan Monnier"'s message of "12 Apr 2001 11:47:34 -0400"

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


             reply	other threads:[~2001-04-17 20:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-17 20:20 David Fox [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=lubspv5le0.fsf_-_@hci.ucsd.edu \
    --to=dsfox@cogsci.ucsd.edu \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).