Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug 14195: Added C++ mangling for passing function signatures #4419

Merged
merged 1 commit into from
Feb 20, 2015

Conversation

Ingrater
Copy link
Contributor

Added support for mangling the C++ equivalent type of:

template <typename T>
struct Delegate1 {};

template <typename R1>
struct Delegate1 < R1() > {};

template <typename T1, typename T2>
struct Delegate2 {};

template < typename R1, typename T1, typename T2, typename R2, typename T3, typename T4 >
struct Delegate2<R1(T1, T2), R2(T3, T4)> {};

void test14195a(Delegate1<void()> func){}

void test14195b(Delegate2<int(float, double), int(float, double)> func){}

The corresponding D code can be found in cppmangle.d. I hit this issue when trying to bind a C++ Delegate implementation to D.

@yebblies
Copy link
Member

How hard is it to do linux mangling as well? I'd prefer the tests were in cppa/cppb so that the mangling is automatically verified.

buf.writeByte('$');
buf.writeByte('$');
buf.writeByte('A'); // mutable
buf.writeByte('6'); // Function
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using writestring("$$A6") would be more compact.

@WalterBright
Copy link
Member

I'd like to see a test for this in cppa/cppb as well for the same reason @yebblies stated. And such would provide motivation, and a test case, for doing the Linux mangling as well.

@Ingrater
Copy link
Contributor Author

Juding from the source code this is already implemented for linux. I will move the tests over to cppa/cppb as soon as I find time.

@Ingrater Ingrater force-pushed the fix14195 branch 2 times, most recently from 1819f11 to a986740 Compare February 18, 2015 21:20
@Ingrater
Copy link
Contributor Author

I tried enabeling the test on non-windows systems and got the following error message from the build machines: undefined reference to `DelegateTest1(Delegate1<void ()>)'
While this tells me that it is almost correctly implemented (because the linker can demangle it), the fact that it does not link tells me its only 'almost' correct. I don't have a linux development environment setup at the moment and don't have time nor interrest to fix this on non-windows systems.

@Ingrater
Copy link
Contributor Author

Sorry, forget what I said. It is already correctly implemented on linux, I just made a mistake transitioning the test to cppa/cppb.

@yebblies
Copy link
Member

In future pull requests please remember to add a bugzilla link to the description.

@yebblies
Copy link
Member

Auto-merge toggled on

braddr added a commit that referenced this pull request Feb 20, 2015
Fixed bug 14195: Added C++ mangling for passing function signatures
@braddr braddr merged commit a68e1c1 into dlang:master Feb 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants