[Ecls-list] Easy way to bind c++ class instances in lisp?

Pascal J. Bourguignon pjb at informatimago.com
Fri Dec 7 18:46:14 UTC 2012


Peter Enerccio <enerccio at gmail.com>
writes:

> I am looking for easy way of wrapping around class instances of c++.
> I can wrap it in lisp with classes with slot containing fixnum of the
> pointer and then recast it in c++ but its cumberstone and has lot of
> boiler plate on both lisp and c++ side. Any other way of doing that?
> Could be even in lisp altogether, because then I could generate c
> code out of it or something.

If you compile ecl with the same C++ compiler as your C++ code, then you
can use the FFI:C-INLINE macro along with the rest of the FFI to
interface between your lisp code and your C++ code.


Otherwise, I would write a C wrapper over C++ classes, and use CFFI to
interface to that wrapper (you can use swig to generate the CFFI API on
the C wrapper).

You can even try to apply swig on C++ code, but it is only able to
generate the C wrapper automatically in the simpliests of the cases.
C++ code often seems designed to prevent FFI!


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.





More information about the ecl-devel mailing list