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: skaller <skaller@u...>
Subject: Re: [Caml-list] Automatic wrapper generator
On Tue, 2004-05-18 at 19:06, Basile Starynkevitch local wrote:

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

Yes, it parses the whole of GTK2 and unistd.h and Xlib.h,
433 files total. I am not responsible for this though:
the parsing is done by frontc, and the parse tree is then
massaged by Cil. All I did here was repackage
other peoples work.

Some files don't parse correctly, and some
have clashes, a couple are serious.

Whether the resultant 'glue code' is correct 
I do not know yet. The techniques are the same
as the SWIG based generator I was using previously,
and I managed to correctly call some gdk functions
returning screen dimensions.

> 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

No distinction is made. You are right that we would like to 
build higher level interfaces than this tool can currently
generate.

It is possible to apply *some* rules in a more
advanced version of the tool. These rules would handle
type mapping, ownership, and perhaps other things like
input/output distinctions for pointers.

However at some stage, the only way to make a genuinely
Ocaml centric version of a library such as Gtk is to write
the wrapper code by hand.

A low level generator is still useful though.
It can help by importing the C interface into Ocaml,
so at least you can try to do most of the remodelling
to a higher level interface in Ocaml.

And it may still be useful, especially if you just
need one or two functions from some library where
a hand written wrapper doesn't exist.

Finally, a low level wrapper generator can be upgraded
with experience to handle common issues such as
typemapping.

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