|
From: Yaroslav K. <kav...@je...> - 2005-06-16 12:01:09
|
Hoehle, Joerg-Cyril wrote:
<skip head>
>>There are a few operators that I didn"t figure out how to implement
>>for CLISP (quoting from the spec):
>>Macro: %FOREIGN-FUNCALL name {arg-type arg}* &optional result-type
>
> Maybe two steps
> a) define function
> b) invoke it
> Or expand to
> (funcall
> (ffi:foreign-function
> (ffi::foreign-library-function
> name (ffi::foreign-library name)
> nil (ffi:parse-c-type '(c-function :arguments ... :return-type
> ...))))
> args...)
> Look at (macroexpand-1'(ffi:def-call-out ...)) for insights.
<skip tail>
Excuse me, but shouldn't it so:
(funcall
(ffi::foreign-library-function
name (ffi::foreign-library name)
nil (ffi:parse-c-type '(ffi:c-function (:arguments ...)
(:return-type...))) args...)
(without (ffi:foreign-function...))?
Example:
CL-USER> (ffi::foreign-library-function "Tcl_GetVersion"
(ffi::foreign-library "tcl84.dll") nil
(ffi:parse-c-type '(ffi:c-function (:return-type NIL)
(:arguments (major (ffi:c-ptr ffi:int) :out)
(minor (ffi:c-ptr ffi:int) :out)
(patchLevel (ffi:c-ptr ffi:int) :out)
(type (ffi:c-ptr ffi:int) :out)))))
#<FOREIGN-FUNCTION "Tcl_GetVersion" #x01764417>
CL-USER> (funcall *)
8
4
9
2
CL-USER>
Thanks.
--
WBR, Yaroslav Kavenchuk.
|