mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
Merge pull request #6745 from yebblies/cppmanglert
Let Target determine how to mangle extern(C++) symbols merged-on-behalf-of: Iain Buclaw <ibuclaw@gdcproject.org>
This commit is contained in:
commit
2cc58d9b0e
4 changed files with 1697 additions and 1682 deletions
3352
src/ddmd/cppmangle.d
3352
src/ddmd/cppmangle.d
File diff suppressed because it is too large
Load diff
|
@ -28,6 +28,7 @@ import ddmd.id;
|
||||||
import ddmd.mtype;
|
import ddmd.mtype;
|
||||||
import ddmd.root.ctfloat;
|
import ddmd.root.ctfloat;
|
||||||
import ddmd.root.outbuffer;
|
import ddmd.root.outbuffer;
|
||||||
|
import ddmd.target;
|
||||||
import ddmd.utf;
|
import ddmd.utf;
|
||||||
import ddmd.visitor;
|
import ddmd.visitor;
|
||||||
|
|
||||||
|
@ -451,7 +452,7 @@ public:
|
||||||
buf.writestring(d.ident.toChars());
|
buf.writestring(d.ident.toChars());
|
||||||
return;
|
return;
|
||||||
case LINKcpp:
|
case LINKcpp:
|
||||||
buf.writestring(toCppMangle(d));
|
buf.writestring(Target.toCppMangle(d));
|
||||||
return;
|
return;
|
||||||
case LINKdefault:
|
case LINKdefault:
|
||||||
d.error("forward declaration");
|
d.error("forward declaration");
|
||||||
|
|
|
@ -10,7 +10,10 @@
|
||||||
|
|
||||||
module ddmd.target;
|
module ddmd.target;
|
||||||
|
|
||||||
|
import ddmd.cppmangle;
|
||||||
|
import ddmd.dclass;
|
||||||
import ddmd.dmodule;
|
import ddmd.dmodule;
|
||||||
|
import ddmd.dsymbol;
|
||||||
import ddmd.expression;
|
import ddmd.expression;
|
||||||
import ddmd.globals;
|
import ddmd.globals;
|
||||||
import ddmd.identifier;
|
import ddmd.identifier;
|
||||||
|
@ -429,6 +432,25 @@ struct Target
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern (C++) static const(char)* toCppMangle(Dsymbol s)
|
||||||
|
{
|
||||||
|
static if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS)
|
||||||
|
return toCppMangleItanium(s);
|
||||||
|
else static if (TARGET_WINDOS)
|
||||||
|
return toCppMangleMSVC(s);
|
||||||
|
else
|
||||||
|
static assert(0, "fix this");
|
||||||
|
}
|
||||||
|
extern (C++) static const(char)* cppTypeInfoMangle(ClassDeclaration cd)
|
||||||
|
{
|
||||||
|
static if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS)
|
||||||
|
return cppTypeInfoMangleItanium(cd);
|
||||||
|
else static if (TARGET_WINDOS)
|
||||||
|
return cppTypeInfoMangleMSVC(cd);
|
||||||
|
else
|
||||||
|
static assert(0, "fix this");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
|
|
|
@ -777,7 +777,7 @@ Symbol* toSymbolCpp(ClassDeclaration cd)
|
||||||
*/
|
*/
|
||||||
Symbol *toSymbolCppTypeInfo(ClassDeclaration cd)
|
Symbol *toSymbolCppTypeInfo(ClassDeclaration cd)
|
||||||
{
|
{
|
||||||
const id = cppTypeInfoMangle(cd);
|
const id = Target.cppTypeInfoMangle(cd);
|
||||||
auto s = symbol_calloc(id, cast(uint)strlen(id));
|
auto s = symbol_calloc(id, cast(uint)strlen(id));
|
||||||
s.Sclass = SCextern;
|
s.Sclass = SCextern;
|
||||||
s.Sfl = FLextern; // C++ code will provide the definition
|
s.Sfl = FLextern; // C++ code will provide the definition
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue