From: Holger Schauer
Subject: ACL - foreign function interface
Date: 
Message-ID: <4lfltc$s2l@omega.gmd.de>
Hello !

I have some questions about the ffi of Allegro 3.0 for
Windows. The documentation isn't all that useful, a more
worked out example would probably be a big help. Perhaps
anybody has encountered the same problems/questions and
has already solved them.

(1) The first problem is related to accessing data
which is second referred, i.e. you only get a pointer
to a pointer to a data structure.

On the C-side this would look like this:

char *p;
char string[10]="Just a test";

WIN32DLLEXPORT char** ffitest()
{
 p=string;
	
 return &p;
}


Using the ''normal'' definition for accessing a foreign
function, calling ffitest yields a cpointer as expected.

However it is not possible to access the string as a whole
using the cref function:

(ct:cref (:char *) (ffitest) *)

yields the first character ("F") as a fixnum but not the whole
string. One can't use the subsequence function on that because you
don't have a sequence here. It would be very useful if one
could access that structure directly and not only fieldwise.

(2) The second problem has to do with the way arguments are passed
to the ffi. If I understand the documentation right, it is only
possible to pass arguments by value but not by reference. This would
be very annoying because several C-functions I have use call-by-
reference to manipulate data (and to return the modified data). This hasn't
been a problem with an other lisp and is also possible in ACL for Unix, I
believe.

In the hope that anybody can help me ...

Thanks in advance,

 Holger Schauer

*** GMD - German National Research Center for Information Technology
 *** Schloss Birlinghoven, Sankt Augustin
  *** FIT.MMK BGP-MS