On 2018-05-03 09:34:56 +0000, kinke said:

That's why there's `extern(C++, class) struct Image`, see https://dlang.org/spec/cpp_interface.html#classes.

Hi, thanks. I didn't understand the docs as without any code examples for all the different cases, it's hard to derive the syntax and how to use it if one just gets started with this interface.

As const is transitive in D, mangling a const object reference as C++ `const T *const` is consistent, but also means that a `const T *` cannot be mapped directly to D via a class (but as `const(T)*` if T is a D struct).

Not sure I understand this too. This is now what I get:

DMD: public: unsigned int __cdecl b2d::Context2D::_begin(class b2d::Image & __ptr64,class b2d::Context2D::InitParams const * __ptr64 const) __ptr64 LIB: public: unsigned int __cdecl b2d::Context2D::_begin(class b2d::Image & __ptr64,class b2d::Context2D::InitParams const * __ptr64) __ptr64

So I somehow get some more const from D. This is the code I used:

   final uint _begin(ref Image image, const(InitParams) initParams);

Any idea how to solve this?

I really like that I'm able to use C++ stuff from D but interfacing the tow is a bit tedious... it would be great to be able to write the C++ signature in the extern(C++) scope and have it translated to the D equivalent internally.


--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster

Reply via email to