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 TAA29873; Sun, 13 Oct 2002 19:11:17 +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 TAA29632 for ; Sun, 13 Oct 2002 19:11:16 +0200 (MET DST) Received: from relay.rinet.ru (relay.rinet.ru [195.54.192.35]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g9DHBFD07899 for ; Sun, 13 Oct 2002 19:11:16 +0200 (MET DST) Received: (from uucp@localhost) by relay.rinet.ru (8.11.6/8.11.6) with UUCP id g9DHBFl05306 for caml-list@inria.fr; Sun, 13 Oct 2002 21:11:15 +0400 (MSD) X-Envelope-To: caml-list@inria.fr Received: from pc-9-4.stormoff (PC-9-4) [192.168.0.100] by stormoff with esmtp (Exim 3.12 #1 (Debian)) id 180mGZ-0004KE-00; Sun, 13 Oct 2002 21:10:59 +0400 X-Comment-To: Xavier Leroy To: caml-list@inria.fr Subject: Re: [Caml-list] CamlIDL question References: <20021007140248.GA22632@rashko.ilt.kharkov.ua> <20021013104825.H13771@pauillac.inria.fr> From: Dmitry Bely Date: Sun, 13 Oct 2002 21:10:59 +0400 In-Reply-To: <20021013104825.H13771@pauillac.inria.fr> (Xavier Leroy's message of "Sun, 13 Oct 2002 10:48:25 +0200") Message-ID: User-Agent: Gnus/5.090007 (Oort Gnus v0.07) XEmacs/21.4 (Economic Science (Windows [1]), i586-pc-win32) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Xavier Leroy writes: >> Is the below trick is possible in CamlIDL? >> I want to wrap C library that uses structs for storing >> pointers to functions > > No, CamlIDL doesn't support C function pointers. The reason is that > mapping C functions pointers to Caml functions is easy, but mapping > Caml function closures to C functions is nearly impossible (there is > nowhere to store and pass the environment part of the closure). It's possible using the "trampoline" technique, when the necessary small stub functions are generated on the fly in the data (or stack) segment. This is how gcc's nested functions work. There is "ffcall" library that implements trampolines for (probably) all hardware platforms where OCaml may run. Am I using it with OcamlIDL to do just what Youry asked for. Unfortinately ffcall's author website has been disappeared, but it should not be a problem to find "ffcall-1.8c.tar.gz" somethere in the Internet. - Dmitry Bely ------------------- 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