Dear Attila,
i'll push a little cleanup in the next hours (mostly file reorganization and a TODO). i'll drop you a mail....
I had a horrible discussion yesterday on #lisp (irc.freenode.org) -- I wonder why people always get so insulting in discussions about these topics -- about accessing C++ libraries from Lisp by Swing or Verrazano and the conclusion seems to be that binary interface of C++ is just not standardized enough, yet, (and will probably never be) to target it directly or try to access (or write to) virtual tables from Lisp. So creating C wrappers for the C++ classes seems to be the way to go.
The only C++ document that at least tries to define some standard is incomplete and targets only the Itanium architecture: http://www.codesourcery.com/cxx-abi/abi.html
Most of the people even think that C++ libraries that don't provide C wrappers themselves should be ignored altogether.
What do you think?
Best regards, Bruno Daniel
I had a horrible discussion yesterday on #lisp (irc.freenode.org) -- I wonder why people always get so insulting in discussions about these topics -- about
most lispers have passionate opinion about stuff like that. try to criticise the overuse of cons, or the verbose syntax of defclass and you'll see what i'm talking about... :)
accessing C++ libraries from Lisp by Swing or Verrazano and the conclusion seems to be that binary interface of C++ is just not standardized enough, yet, (and will probably never be) to target it directly or try to access (or write to) virtual tables from Lisp. So creating C wrappers for the C++ classes seems to be the way to go.
well, that's also an option, and maybe a better one. i didn't put enough thinking to really formulate an opinion, but there's cffi-grovel (which is iirc merged into the new soon-to-be-released-cffi-version). also, if you clean up the internals of verrazano then it would be trivial to add a generation target (hint: using a contextl layer) that automatically generates the c wrapper functions for c++ libs.
then look into iolib, it has some asdf additions to automatically compile c files at load-op.
The only C++ document that at least tries to define some standard is incomplete and targets only the Itanium architecture: http://www.codesourcery.com/cxx-abi/abi.html
Most of the people even think that C++ libraries that don't provide C wrappers themselves should be ignored altogether.
What do you think?
i don't think that it would be completely pointless to add an ABI abstraction layer, but it would be very hard/limited to use, so after some thoughts i'd also try the automatic generation of the C layer first.
look into (the new) cffi-grovel, think through how it relates to verrazano (i suspect they are duplicate efforts in some way, so consider some kind of merging, too). maybe the cffi devs have some words on how cffi-govel is generating the c files.
hth,
Dear Attilla,
thanks for your lightning-speed answer! Thanks also for pointing me to cffi-grovel. I'm going to have a close look on it. Maybe we could let Verrazano generate the cffi-grovel calls after calling gccxml and cffi-grovel would do the rest (creating the C wrappers, calling the compiler and everything).
I just found this: http://cffi-net.accela.net/html/cffi-grovel/spec-file-syntax.html#spec-file-... "(cstruct-and-class ...)
Defines a CFFI foreign struct, as with cstruct and defines a CLOS class to be used with it. This is useful for mapping foreign structures to application-layer code that shouldn't need to worry about memory allocation issues."
So it won't be necessary to free the memory manually (and call the destructor) because this is automatically done in some kind of finalizer by the garbage collector? This would be very convenient. In cases where the ownership of a C++ object is passed to some other C++ object (e.g. in a C++ GUI library, the dialog widget usually owns the widgets put into it and is responsible for deleting them) we will have to avoid creating such a Lisp wrapper object; otherwise the C++ object will be deleted twice.
Best regards, Bruno Daniel