Just Launched: You can now import projects and releases from Google Code onto SourceForge
We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps. Read More
Yaroslav Kavenchuk wrote:
>How define unnamed call-in function and determine it address?
I suggest you look at tests/ffi.tst again:
> (defun callback (x) (/ x 3))
> (with-c-var (x '(c-function (:arguments (x uint))
(:language :stdc)) #'callback) x)
;; or use #'(lambda ...) here instead
> (setq foo *)
> (funcall foo 123)
> (funcall foo 2)
*** - 2/3 cannot be converted to the foreign type UINT
The following restarts are available:
ABORT :R1 ABORT
> (foreign-address foo)
[...]> (foreign-free foo)
#<INVALID FOREIGN-FUNCTION #x081C3EE0>
Arguably, the current ffi:foreign-function constructor could be enhanced to accept a Lisp function objects as input and create a foreign-function object from it. That seems to make some sense.
Note that when some call-out function has as :argument (c-function ...), a Lisp function is automatically converted to a foreign function pointer that is then passed to the foreign function. But then, you don't get to see its address.
>How call c-function to its address (without name)?
Use funcall on the #<foreign-function #> object or what do you mean?
>>How call c-function to its address (without name)?
> Use funcall on the #<foreign-function #> object or what do you mean?
Now nothing :)
WBR, Yaroslav Kavenchuk.