[Openmcl-devel] docs on using external-call?
gb at clozure.com
Mon Jun 5 23:24:58 UTC 2006
On Mon, 5 Jun 2006, Kaveh Kardan wrote:
> I am calling a C++ library from OpenMCL. ffigen will not generate
> the interface for a C++ header file, even for functions (the .ffi
> file is created, but no cdb fils are generated).
> This means I have to use external-call, for which I cannot find many
> One thing I would like to be able to do is pass a lisp callback to a C
> ++ function, much like is done with:
> (#_glutDisplayFunc display-cb)
> But if I try something like:
> (external-call "_my_func" :function #'display-cb :void)
> I get an error.
> What is the correct way of doing this?
If one does:
(defcallback my-func (...) ...)
tnen the value of the global variable MY-FUNC will be a MACPTR to some
address (DEFCALLBACK has stored a little bit of machine code at that address.)
One can use that MACPTR to pass the address of that little block of code
to a foreign function that expects a "pointer to function" as an argument
Note that (DEFCALLBACK MY-FUNC ...) doesn't affect the function cell of
the symbol MY-FUNC at all; it's actually hard (I never remember how)
to get one's hands on the lisp function that's eventually called.
> And are there more detailed
> examples of using external-call documented somewhere?
There aren't even too many uses of EXTERNAL-CALL in the OpenMCL sources/
Whether it uses EXTERNAL-CALL or #_ or whatever, something demonstrating
how callback pointers can be passed to foreign functions (your basic
question) would make a good example.
> Kaveh Kardan Chief Technologist
> kaveh at hawaii.edu Academy for Creative Media
> (808)956-5302 University of Hawaii
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
More information about the Openmcl-devel