[cffi-devel] bits from a new tutorial

Martin Simmons martin at lispworks.com
Thu Dec 22 13:15:03 UTC 2005


>>>>> On Thu, 22 Dec 2005 10:14:38 +0000, =?ISO-8859-1?Q?Lu=EDs_Oliveira?= <luismbo at gmail.com> said:

  Luís> This tutorial shows the usefulness of foreign-funcall for C functions  
  Luís> with varargs. Lispworks unfortunately doesn't export this  
  Luís> functionality. Martin, I wonder if Lispworks will ever export  
  Luís> something like this or if we could have some clues on how to use  
  Luís> unexported functionality to implement cffi-sys:%foreign-funcall (and  
  Luís> eventually cffi-sys:%foreign-funcall-pointer).

No, LispWorks doesn't support that kind of call with random run-time types.
The problem is that some of the low level calling conventions are very baroque
in which registers they use to pass the arguments, so supporting a call
pattern with run-time types is too complicated.  Defining a small number of
FLI:DEFINE-FOREIGN-FUNCTION wrappers for the same C function with specific
types has sufficed so far in our cases.

You can get some of the functionality by using the :ONE-OF type in LispWorks,
but you can't use it to mix float, non-float and aggregate types for the same
value.  LispWorks also has FLI:DEFINE-FOREIGN-FUNCALLABLE for creating
specific "FUNCALL" functions to allow calling of function pointers.

-- 
Martin Simmons                              Email: martin at lispworks.com
LispWorks Ltd, St John's Innovation Centre    TEL:   +44 1223 421860
Cowley Road, Cambridge CB4 0WS, England.      FAX:   +44 870 2206189



More information about the cffi-devel mailing list