Hi!
Attached is a hasty patch to enable CFFI-SYS:%FOREIGN-FUNCALL and CFFI-SYS:%FOREIGN-FUNCALL-POINTER for LispWorks. The idea is to create one foreign funcallable per signature and cache those in a hash table. I took a quick glance at the source code of CMUCL's ALIEN-FUNCALL and my impression (not really understanding the details) was that CMUCL actually does something similar internally - it creates a "stub" if necessary, depending on the types. As you can observe at the REPL it compiles /something/ when ALIEN-FUNCALL is called.
Granted, it is kind of ugly to call FLI:DEFINE-FOREIGN-FUNCALLABLE in non-top-level position but I think this solution is better than nothing. It looks to me as if FOREIGN-FUNCALL is mostly intended for interactive use and for "one-shot" invocations - correct me if I'm wrong.
I don't know if CMUCL's "stubs" will ever be garbage-collected, the foreign funcallables in my patch certainly won't. I don't expect this to be a big problem, though.
I tried the CFFI test suite and it basically ran through with three exceptions - FUNCALL.FLOAT, DEREF.FLOAT.2, and DEREF.FLOAT.3. My guess is that these are due to LispWorks identifying FLOAT and DOUBLE-FLOAT and are not related to my patch.
Two minor quibbles, unrelated:
1. The documentation says it is only about the cffi-luis branch but it seems to me that the main branch and cffi-luis are almost identical - or did I miss something?
2. This form
(define-foreign-library libcurl (:unix (:or "libcurl.so.3" "libcurl.so")) (t (:default "libcurl")))
in the (very nice, BTW) tutorial didn't work for me on Linux, neither with LispWorks nor with CMUCL. I had to remove the second (:UNIX) line to make it work.
edi@vmware:~$ ls -l /usr/lib/libcurl* lrwxrwxrwx 1 root root 16 Dec 28 19:29 /usr/lib/libcurl.so.3 -> libcurl.so.3.0.0 -rw-r--r-- 1 root root 196632 Dec 7 12:39 /usr/lib/libcurl.so.3.0.0
Cheers, Edi.