C++ interop - what to do about long and unsigned long?
Andrej Mitrovic via Digitalmars-d
digitalmars-d at puremagic.com
Fri Sep 12 01:35:46 PDT 2014
On 9/11/14, Andrei Alexandrescu via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> We've done some stuff at FB going with the "ah we have C interface so
> we'll just write C wrappers around the C++ code we'll use" and it didn't
> take long to figure that won't scale, like, at all.
I've had moderate success creating a codegenerator for automatically
writing C interface code to C++ and a D API on top. But, it's
extremely complicated and would likely take me years to finish, there
are so many edge cases. The generated code really lacks in performance
due to all the jumping around between forwarding functions and whatnot
(even though I've generated code which was faster than SWIG code for
cross-language virtual calls).
So I welcome any direct C++ interoperability support.
Btw, one thing I want to see supported is cross-language polymorphism,
meaning if you have this C++ function:
// in foo.cpp
Base foo() { return new Derived(); };
Then the following D code should work:
assert( cast(Derived)foo() );
Afaik SWIG had no support for this, my codegenerator did, but it
essentially had to go through a list of classes and attempt a cast for
each one before returning the D object of the right dynamic type.
More information about the Digitalmars-d
mailing list