On 17 Dec 2006, at 21:15, Jack Unrue wrote:
Is there any caching of CFFI foreign function meta-data behind the scenes, perhaps keyed by the foreign function name? Such as might be causing identical results no matter which is called first, or which load- foreign-library occurs first?
Note: my WinXP install has several different versions of comctl32.dll, one of which matches the shell32.dll version, but I have at least one configuration where I know the result really is wrong (as if the result from the other DllGetVersion call was being cached).
The issue here is that CFFI doesn't have any way to tell which of the DllGetVersion functions you want to call. Both DEFCFUNs are pointing at the same name. This is one of the things that UFFI still handles better (unless I just haven't been keeping up-to-date with CFFI).
In UFFI, rather than
(load-foreign-library "comctl32.dll")
You would say:
(load-foreign-library "comctl32.dll" :module "comctl") (load-foreign-library "shell32.dll" :module "shell")
then, when defining the functions:
(def-function ("DllGetVersion" comctl-dll-get-version) ((info :pointer)) :returning HRESULT :module "comctl")
(def-function ("DllGetVersion" shell-dll-get-version) ((info :pointer)) :returning HRESULT :module "shell")
you can see the extra ":module" parameter, which tells it which DLL contains the function you want to use. I'm pretty sure it's not possible to do anything similar from CFFI.
I thought this was being worked on, but I haven't been paying attention too much lately.