From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA25013; Tue, 17 Apr 2001 22:20:10 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA25141 for ; Tue, 17 Apr 2001 22:20:09 +0200 (MET DST) Received: from hci.ucsd.edu (hci.ucsd.edu [132.239.215.210]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f3HKK8n25622 for ; Tue, 17 Apr 2001 22:20:08 +0200 (MET DST) Received: (from dsf@localhost) by hci.ucsd.edu (8.9.3/8.9.3) id NAA16948; Tue, 17 Apr 2001 13:20:07 -0700 To: caml-list@inria.fr Subject: [Caml-list] Foreign function interface generator with examples From: David Fox Date: 17 Apr 2001 13:20:07 -0700 In-Reply-To: "Stefan Monnier"'s message of "12 Apr 2001 11:47:34 -0400" Message-ID: X-Mailer: Gnus v5.7/Emacs 20.3 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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