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 NAA09105; Wed, 14 Nov 2001 13:15:28 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA09284 for ; Wed, 14 Nov 2001 13:15:27 +0100 (MET) Received: from relay.rinet.ru (relay.rinet.ru [195.54.192.35]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id fAECFQ518461 for ; Wed, 14 Nov 2001 13:15:26 +0100 (MET) Received: (from uucp@localhost) by relay.rinet.ru (8.11.6/8.11.6) with UUCP id fAECFHk08663 for caml-list@inria.fr; Wed, 14 Nov 2001 15:15:17 +0300 (MSK) X-Envelope-To: caml-list@inria.fr Received: from bely.stormoff (BELY) [192.168.0.10] by stormoff with esmtp (Exim 2.05 #1 (Debian)) id 163ywi-0004aD-00; Wed, 14 Nov 2001 15:15:12 +0300 X-Comment-To: "NASSOR Eric" To: caml-list@inria.fr Subject: Re: [Caml-list] camlidl and pointer to function References: <3BF23EE4.BB444C5C@crf.canon.fr> From: Dmitry Bely Date: 14 Nov 2001 15:16:15 +0300 Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Civil Service (Windows)) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk "NASSOR Eric" writes: > > I have a C library function with interface like following: > > > > typedef [abstract] void* SomeType; > > typedef int (*CallBack)(int); > > void convert( SomeType* in, SomeType* out, CallBack c); > > > > It would be nice to use it in caml the following way: > > > > external convert: someType->someType->(int->int)->unit = "something" > > ... > > convert stIn stOut ((+) 1) > > ... > > > > Unfortinately CamIDL language does not allow the pointer to function as a > > valid type, but maybe there is some common solution/workaround for this > > problem? Or the only way is writing necessary stubs and conversion > > functions by hands? Is is possible at all? > > > > It is possible to call back caml code from a C code which was called from caml, but > you need to write a few lines of code. > here is an example extracted from my application (with a few simplifications). > the resulting caml function iter_tree can be called recursively, it can also raise > exceptions. The problem is that C library is binary-only (Intel image processing library), and CallBack type is exactly typedef int (*CallBack)(int); I cannot add value parameter containing Caml callback here. I can store it in a global C variable, but then the entire application will be not thread-safe. Locking the entire ml2c(); f(); c2ml(); section is also not desirable... Hope to hear from you soon, Dmitry ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr