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 MAA19837; Tue, 18 May 2004 12:08:04 +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 MAA19821 for ; Tue, 18 May 2004 12:08:03 +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 i4IA7xEV019696 for ; Tue, 18 May 2004 12:08:01 +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 i4IA7mk2070376; Tue, 18 May 2004 19:37:49 +0930 (CST) Subject: Re: [Caml-list] Automatic wrapper generator From: skaller Reply-To: skaller@users.sourceforge.net To: Richard Jones Cc: caml-list In-Reply-To: <20040518085805.GB15477@redhat.com> References: <1084869517.19838.409.camel@pelican.wigram> <20040518085805.GB15477@redhat.com> Content-Type: text/plain Message-Id: <1084874867.19838.427.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 18 May 2004 20:07:48 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 40A9E07F.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 hacks:01 hackery:01 struct:01 pointers:01 pointers:01 'just:01 9660:01 glebe:01 ocaml:01 ocaml:01 garbage:01 nsw:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, 2004-05-18 at 18:58, Richard Jones wrote: > John, > > This is of course brilliant news if it can be made to work. I think it can be "made" to work. By 'made' I mean: C headers are relatively unstructured hacks, some important header files actually contain *syntax* errors for example! So it is to be expected the client will need to apply some directives to guide the wrapping, so as to 'undo' the C hackery if you like. > I can > help you with testing - I've got a few different platforms around > here. Great! Note: there is currently no Ocaml back end. > I'm interested to know, though: how do you deal with ownership of > objects: eg. The struct returned from gethostbyname(3) is static and > so shouldn't be managed/freed from OCaml; whereas getnameinfo(3) > requires you to pass in allocated buffers and their sizes. This > information isn't available in the header files ... Simple. I don't. For a low level C interface, everything works exactly 'as if in C'. If you need to create a string you call 'malloc' and 'strcpy', just as in C. So, if there is a static data structure and you call a function that returns it, you have to manage it from Felix or Ocaml exactly as in C: don't free it or you'll core dump. Note that this couldn't possibly work in Ocaml except that the garbage collector is smart and *knows* which pointers to leave alone. Those pointers you manage 'just as you would do in C'. -- 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