From: Dmitry Bely <dbely@mail.ru>
To: caml-list@inria.fr
Subject: Re: [Caml-list] camlidl and pointer to function
Date: 14 Nov 2001 15:16:15 +0300 [thread overview]
Message-ID: <wv0tv980.fsf@mail.ru> (raw)
In-Reply-To: <3BF23EE4.BB444C5C@crf.canon.fr>
"NASSOR Eric" <nassor@crf.canon.fr> 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
next prev parent reply other threads:[~2001-11-14 12:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-13 17:43 Dmitry Bely
2001-11-14 9:52 ` NASSOR Eric
2001-11-14 12:16 ` Dmitry Bely [this message]
[not found] ` <9stni6$hh6$1@qrnik.zagroda>
2001-11-14 14:56 ` Marcin 'Qrczak' Kowalczyk
2001-11-14 16:02 ` Dmitry Bely
2001-11-14 20:21 ` Dmitry Bely
2001-11-14 20:43 Krishnaswami, Neel
2001-11-15 8:23 ` Dmitry Bely
[not found] <9sul5k$ga4$1@qrnik.zagroda>
2001-11-14 21:24 ` Marcin 'Qrczak' Kowalczyk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=wv0tv980.fsf@mail.ru \
--to=dbely@mail.ru \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox