On Fri, 25 Nov 2011 08:22:34 +0100, Martin Nowak <d...@dawgfoto.de> wrote:

After going astray while doing C++ class bindings using smart_ptrs and ugly
mixins I think I found a really neat way.
It consists of a C++ header that defines a d_new template function.
It will allocate it's types from the D GC while hooking the C++ type's
destructor to a D finalizer. It even allows for nested scanning of C++
classes and allocating other data, e.g. arrays.

To use C++ class from D one only needs to define one factory function and
add the class declaration to a D source file and link in the d_new module.

Currently uses boost and offers no constructor arguments, due to the dreaded
forwarding problem.

https://gist.github.com/1391734

martin

It should actually be also possible to fake the complete C++ calling conventions using extern(C) functions. Then a mangler can be library implemented and allowing almost full access.

proof of concept
https://gist.github.com/1394145

martin

Reply via email to