[Ecls-list] Accessing C variables
Juan Jose Garcia Ripoll
lisp at arrakis.es
Fri Sep 2 01:43:12 UTC 2005
On Fri, 2005-09-02 at 13:48 +1000, Dean O'Connor wrote:
> Is there a way to point/bind to the existing C++ data structures in Lisp
> interpreter real time? So the Lisp scripts can understand and read the data.
> The C++ structures could be classes, or structs, but could be reduced to
> more basic data-types.
UFFI provides you with C structures and other C datatypes. You can
define the type of your data and then provide ECL with a pointer. How to
do it is described in the UFFI manual, which ECL follows
CFFI is an alternative foreign function interface which aims to support
not only C, but also C++. There was a preliminary port to ECL (with
_lots_ of room for optimization), but I have not had time to follow the
In both of the cases, you need not copy the data. It is enough to give
the lisp a pointer to the data and tell it the type. UFFI and CFFI both
build functions to access the slots or elements of structures and arrays
Learning the FFI will save you a lot of time. The alternative, to code
by hand all functions to access and manipulate the C/C++ code, is
doable, but hairy, as you will need to deal with ECL's internal notion
of foreign data, which is not yet well documented.
More information about the ecl-devel