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 KAA13521; Tue, 18 May 2004 10:38:45 +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 KAA13683 for ; Tue, 18 May 2004 10:38:43 +0200 (MET DST) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i4I8ceEV008175 for ; Tue, 18 May 2004 10:38:42 +0200 Received: from [192.168.1.200] (ppp119-251.lns2.syd3.internode.on.net [150.101.119.251] (may be forged)) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i4I8cbk2040632 for ; Tue, 18 May 2004 18:08:38 +0930 (CST) Subject: [Caml-list] Automatic wrapper generator From: skaller Reply-To: skaller@users.sourceforge.net To: caml-list Content-Type: text/plain Message-Id: <1084869517.19838.409.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 18 May 2004 18:38:37 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 40A9CB91.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; sourceforge:01 hackery:01 usr:01 include':01 stdio:01 stdio:01 printf:01 invokes:01 compiles:01 ocaml's:01 printf:01 char:01 frontc:01 wrappers:01 usr:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk This is a brief status report concerning the Felix automatic wrapper generator (reason for posting to Caml list explained below). With some platform specific hackery, I am now able to wrap 90% of all headers in '/usr/include' and execute a single Felix test case: ----------------------- include "stdio_h"; C_hack::ignore(stdio_h::printf(c"%s\n", c"Hello World")); -------------------- Line 1 includes the wrapper generated for stdio.h. Line 2 invokes the wrapper for a popular function 'printf()'. This program compiles and executes correctly. C_hack::ignore is the same as Ocaml's ignore function, it throws away the result of calling printf. The lexical elements c".." generate C char arrays (instead of Felix strings which are C++ STL strings). The include directive pulls in a precompiled header containing a module named stdio_h, which is used as a qualifier to the function name printf(). It isn't clear I have got everything right yet, there is still a long way to go. However I do consider this a reasonable "proof-of-principle" demonstration that automatic wrapping of the complete C development environment is possible. The wrapper generator uses the frontc/Cil parser, and generates the wrappers for of /usr/include in a couple of seconds. RELEVANCE TO OCAML. ------------------ There isn't much that I'm doing for Felix wrappers that can't be applied to Ocaml: perhaps with some extra work it seems possible to make an Ocaml back end to generate Foreign Function Interfaces for the whole C environment in a few seconds. Felix does have a few advantages over Ocaml that may need to be considered in adapting the code, for example, in Felix everything is automatically mutually recursive, and so the order of definitions of types and functions is irrelevant. Ocaml sometimes needs sequential definitions, and has some problems with intermodule recursion. However, I do not see any major obstacles. [EG: intermodule recursion is a mess to handle by hand... but it's no problem for a mechanical wrapper generator] Note of course the generated wrappers are, at least currently, LOW LEVEL and thus not safe. for some time, people have been crying for 'MORE LIBRARIES' for Ocaml. Here's your chance to get THE LOT in one go. I'm willing to work on adapting the wrapper generator so it can be used to generate Ocaml wrappers, provided it continues to be useful generating Felix ones. However, I can't tackle this on my own. The generator needs to understand a heap of highly platform specific details, and a thus a lot of people need to try it on many platforms to provide the feedback needed to make it configurable enough to actually work on many platforms. Any comments appreciated. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners