This next step uses the define-foreign-function macro to define a FLI function, or interface function, to be used to call the
function. An interface function takes its arguments, converts them into a C format, calls the foreign function, receives the return values, and converts them into a suitable Lisp format.
(fli:define-foreign-function (get-cursor-position "GetCursorPos")
In this example, the defined FLI function is
. It takes as its argument a pointer of type
, converts this to a C format, and calls
. It takes the return value it receives from
and converts it into the FLI
type we defined earlier.
We have now defined all the types and functions required to get the cursor position. The next step is to allocate memory for an instance of the
structure using allocate-foreign-object. The following line of code binds
to a pointer that points to such an instance.
(setq location (fli:allocate-foreign-object :type 'point))
Finally, we can use our interface function
to get the cursor position:
LispWorks Foreign Language Interface User Guide and Reference Manual - 7 Dec 2011