That said, now I can create real ffi closures and get their addresses for later use,
and more important, call them.
Hopefully on my way back home I finish the marshalling code and can show some demo.
To give you a clue on how it is used:
Code: Select all
(set 'a (callback (lambda (a b c) (mul a b c)) "int" "int" "int" "int"))
(println (a 1 2 3))
(println a)
(exit)
Code: Select all
OK <0x7b0008>
Me was called ...
with 3 arguments
6
<closure><6D0090>
which then calls a trampoline function which executes the lambda in the callback definition.
The missing pieces are stuffing the lamba with arguments and returning the result cell(s) back
to the caller.
This explanation might get clearer if you see the code, though.