This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: calling kawa functions from java (FFI)
Bruce Lewis wrote:
"Mato Mira, Fernando" <Fernando.Matomira@dialog.com> writes:
How does one call kawa functions from Java? That is, not using
Scheme.eval. I have some
Scheme objects stored in Java variables that I need to pass to the function.
You have to use Scheme.eval once, like this:
import gnu.mapping.*;
Procedure request_handler = (Procedure) interp.eval(handler_name);
Unless of course you already have the Procedure as a Java value,
perhaps because it was returned from some other function.
Then, use the appropriate method from gnu/mapping/Procedure.java as many
times as you wish, e.g. for a two-argument function:
request_handler.apply2(obj1, obj2)
As a clarification: If you have a Procedure that takes a variable
number of parameters, and want to call it with two arguments, you
can use either apply2 or pass a 2-element array to applyN. And
if you have a two-argument function, you can call it with either apply2
or applyN.
The following might be useful, even though it is a bit out of date:
http://www.gnu.org/software/kawa/internals.html
--
--Per Bothner
per@bothner.com http://per.bothner.com/