www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Cpp/D interface semantic

reply Guillaume Chatelet <chatelet.guillaume gmail.com> writes:
This is currently part of the dmd test suite [1]:

 extern (C++) interface E
 {
     int bar(int i, int j, int k);
 }
 
 extern (C++) int callE(E);
 
 static assert (callE.mangleof == "_Z5callEP1E");
The last line checks that callE() will pass its argument by pointer. This is fine in the case where E is a D interface because of reference semantics: it should be passed by pointer. But, in the case where an extern(C++) function calls an extern(C++) type should it be value semantic - as it is in C++ - or reference semantic - as it is in D? Thoughts? -- 1. https://github.com/dlang/dmd/blob/master/test/compilable/cppmangle.d#L102
Jun 26 2016
parent reply Johan Engelen <j j.nl> writes:
On Sunday, 26 June 2016 at 07:51:16 UTC, Guillaume Chatelet wrote:
 This is fine in the case where E is a D interface because of 
 reference semantics: it should be passed by pointer.

 But, in the case where an extern(C++) function calls an 
 extern(C++) type should it be value semantic - as it is in C++ 
 - or reference semantic - as it is in D?
I think the semantics should be D, so e.g. reference semantics for an extern(C++) class. (This is all over ddmd source: many front-end classes are extern(C++)). A related PR: https://github.com/dlang/dmd/pull/5875
Jun 26 2016
parent reply Guillaume Chatelet <chatelet.guillaume gmail.com> writes:
On Sunday, 26 June 2016 at 09:28:19 UTC, Johan Engelen wrote:
 On Sunday, 26 June 2016 at 07:51:16 UTC, Guillaume Chatelet 
 wrote:
 This is fine in the case where E is a D interface because of 
 reference semantics: it should be passed by pointer.

 But, in the case where an extern(C++) function calls an 
 extern(C++) type should it be value semantic - as it is in C++ 
 - or reference semantic - as it is in D?
I think the semantics should be D, so e.g. reference semantics for an extern(C++) class. (This is all over ddmd source: many front-end classes are extern(C++)). A related PR: https://github.com/dlang/dmd/pull/5875
Sounds good to me. Johan I saw you created a few bugs for C++ name mangling. Can you assigne the one for Linux to me. I'm redesigning the algorithm and I need as many corner cases as possible. Current test set is here: https://github.com/gchatelet/dmd/tree/new_cpp_mangling2/test/mangling
Jun 26 2016
parent Guillaume Chatelet <chatelet.guillaume gmail.com> writes:
On Sunday, 26 June 2016 at 14:48:00 UTC, Guillaume Chatelet wrote:
 Johan I saw you created a few bugs for C++ name mangling. Can 
 you assigne the one for Linux to me. I'm redesigning the 
 algorithm and I need as many corner cases as possible.
Note: I'm only touching the 'Linux' C++ mangling code, so I'm only interested C++ mangling issues on the following platform: TARGET_LINUX, TARGET_OSX, TARGET_FREEBSD, TARGET_OPENBSD, TARGET_SOLARIS.
Jun 26 2016