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 OAA27124; Tue, 18 May 2004 14:11:52 +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 OAA27107 for ; Tue, 18 May 2004 14:11:51 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i4ICBmEV001708 for ; Tue, 18 May 2004 14:11:50 +0200 Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1BQ3Rj-0005Js-00 for ; Tue, 18 May 2004 13:11:47 +0100 Date: Tue, 18 May 2004 13:11:47 +0100 Cc: caml-list Subject: Re: [Caml-list] Automatic wrapper generator Message-ID: <20040518121147.GA20094@redhat.com> References: <1084869517.19838.409.camel@pelican.wigram> <20040518090635.GA6918@bourg.inria.fr> <1084875941.19838.446.camel@pelican.wigram> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1084875941.19838.446.camel@pelican.wigram> User-Agent: Mutt/1.5.5.1+cvs20040105i From: Richard Jones X-Miltered: at nez-perce with ID 40A9FD84.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 2004:99 parses:01 unistd:01 xlib:01 frontc:01 peoples:01 clashes:01 swig:01 interfacing:01 hvs:99 avs:99 high-level:01 wrappers:01 behave:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, May 18, 2004 at 08:25:41PM +1000, skaller wrote: > 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. The actual problem with Gtk revolves (yet again) around memory management. Gtk uses a rather half-baked reference counting scheme. The problems with this are similar to the problems with interfacing Perl (see below). > 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. It sounds very similar to Perl4caml, which offers two levels of interface. At the lowest level you get to manipulate SVs, HVs and AVs directly from OCaml [1]. You have to convert strings/ints to SVs when calling Perl code (using sv_of_string, etc.), and when returning values you have to convert them from SVs to OCaml native types (using string_of_sv, etc.). For some libraries I've written high-level wrappers which do all this conversion for you, allowing you to use objects and modules which look just like OCaml native objects [2]. Perl uses reference counting. I still haven't worked out a scheme to make reference counting behave well with the OCaml garbage collector, so the current version of Perl4caml will never deallocate Perl objects (there is an experimental makefile flag to turn deallocation on, but this sometimes causes programs to crash). I've tried wrapping the Perl objects in custom blocks, but it doesn't work, and I'd appreciate some help sorting it out! Rich. [1] The low-level interface: http://www.merjis.com/developers/perl4caml/html/Perl.html [2] Example of a high-level wrapper: http://www.merjis.com/developers/perl4caml/html/Pl_HTML_Element.html http://www.merjis.com/developers/perl4caml/html/Pl_HTML_Element.html_element.html -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment http://www.winwinsales.co.uk/ - CRM improvement consultancy ------------------- 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