[Ecls-list] How to wrap C++ classes using ECLs foreign function interface?
Dietrich Bollmann
dietrich at formgames.org
Fri Jun 7 05:12:55 UTC 2013
Hi Ralf Mattes,
Thank you very much for your answer!
> I think you'll find the best sample code in the eql project -
> just do a "git clone git://gitorious.org/eql/eql.git"
>
> This project embeds all of Qt into ECL.
I thought the same and therefore searched the EQL sources before writing my
last email. I had the impression that EQL (beyond the simple code in
lisp/ecl-readline.lisp) is based on CFFI which, as far as I understand,
currently does not work with ECL under MSVC++.
If I am not mistaken, in this environment currently the only way to access
foreign functions from ECL is to use ECL's own built-in foreign function
interface, tocompile the code accessing C or C++ functionality into a
static library (as dynamic loading from CFFI seems to not work in the
moment) and to link the latter statically to the rest of the code.
Is this a misunderstanding?
For the case that ECL's own FFI is the only way which currently works with
Microsoft's compilers, I had the impression that ECL's ecl_*foreign_data*()
functions have to be used to wrap a pointer to a C++ class instance into a
lisp object. But I could not find any usable example and (at least until
now) was not successful in producing some working code myself...
If this impression is wrong, please correct me!
If it happens to be correct and somebody has an idea about how to wrap the
simple C++ example from my last email into lisp, I would be most grateful!
Thanks a lot, Dietrich
Here the relevant part of my last email:
On Thu, Jun 6, 2013 at 6:25 PM, Dietrich Bollmann <dietrich at formgames.org>
wrote:
>
> How, for example, would I wrap the following simple program?
>
> ;; Making a cube of size 2
> Cube* cube = new Cube(2.0);
>
> ;; Changing its size to 10
> cube->setSize(10.0);
>
> ;; Getting its size
> cube->getSize();
>
> ;; Deleting the object
> delete cube;
>
> based on a class like the following
>
> class Cube {
> private:
> double _size;
> public:
> Cube(): _size(1.0) {}
> Cube(const double size): _size(size) {}
> void setSize(const double size) { _size = size; }
> double getSize() const { return _size; }
> };
>
> ?
>
On Thu, Jun 6, 2013 at 11:20 PM, R. Mattes <rm at mh-freiburg.de> wrote:
> On Thu, 6 Jun 2013 18:25:00 +0900, Dietrich Bollmann wrote
> > Hi,
> >
> > Is there some example about how to wrap C++ classes with ECLs foreign
> function interface?
>
> I think you'll find the best sample code in the eql project -
> just do a "git clone git://gitorious.org/eql/eql.git"
>
> This project embeds all of Qt into ECL.
>
> HTH Ralf Mattes
>
> --
> R. Mattes -
> Hochschule fuer Musik Freiburg
> rm at inm.mh-freiburg.de
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20130607/fc6173ff/attachment.html>
More information about the ecl-devel
mailing list