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 MAA20707; Tue, 18 May 2004 12:25:48 +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 MAA20931; Tue, 18 May 2004 12:25:47 +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 i4IAPiEV021986; Tue, 18 May 2004 12:25:45 +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 i4IAPgk2075942; Tue, 18 May 2004 19:55:42 +0930 (CST) Subject: Re: [Caml-list] Automatic wrapper generator From: skaller Reply-To: skaller@users.sourceforge.net To: Basile Starynkevitch local Cc: caml-list In-Reply-To: <20040518090635.GA6918@bourg.inria.fr> References: <1084869517.19838.409.camel@pelican.wigram> <20040518090635.GA6918@bourg.inria.fr> Content-Type: text/plain Message-Id: <1084875941.19838.446.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 18 May 2004 20:25:41 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 40A9E4A8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sourceforge:01 2004:99 basile:01 unistd:01 xlib:01 glue:01 parses:01 unistd:01 xlib:01 frontc:01 peoples:01 clashes:01 swig:01 pointers:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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