Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Automatic wrapper generator
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Basile Starynkevitch local <basile.starynkevitch@i...>
Subject: Re: [Caml-list] Automatic wrapper generator
On Tue, May 18, 2004 at 06:38:37PM +1000, skaller wrote:
> 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. [....]
> 
> 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.  [...]

very good, but I suggest a more difficult test: GTK2 (or at least the
contained Glib2 library).

Are you able to parse GTK2 or Glib2 or unistd.h or Xlib.h with your
machinery, and to generate sensible glue code for these?

I tend to believe that while <stdio.h> has some intricacies (in
particular, the variadic printf & scanf routines) there are other
header files which are more complex to parse automatically.

How do you handle C pointers, and more importantly, how do you
separate the C pointers which carry a result - for instance like in
scanf("%d",&i) and those which point to a composite input argument -
for instance the fd_set pointer arguments to select? I tend to believe
that both cases should be interfaced very differently in Ocaml


Anyway, bravo for the good work

Regards.
-- 
Basile STARYNKEVITCH -- basile dot starynkevitch at inria dot fr
Project cristal.inria.fr - phone +33 1 3963 5197 - mobile 6 8501 2359
http://cristal.inria.fr/~starynke --- all opinions are only mine 

-------------------
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