DGen
- When generating `extern ...` statements for a given `Module` only tack on the `extern` to the emit if it is NOT `isExternal()` (if it is not a TLang externed variable/function). This is because those would already have them via the call to the signature generation function. This updates the `emitxterns(Module, File)` method. - When generating signatures for `Variable`(s) ensure that ones which have `isExternal()` return `true` have `extern ...` added to the front og the generated signature. This updates the `generateSignature_Variable(Variable var)` method.
This commit is contained in:
parent
59edbde04d
commit
c439019665
|
@ -1089,7 +1089,14 @@ public final class DCodeEmitter : CodeEmitter
|
||||||
// Emit public functions
|
// Emit public functions
|
||||||
foreach(Function func; mos.funcs())
|
foreach(Function func; mos.funcs())
|
||||||
{
|
{
|
||||||
string externEmit = format("extern %s;", generateSignature(func));
|
// Generate signature
|
||||||
|
string signature = generateSignature(func);
|
||||||
|
|
||||||
|
// Decide whether or not `extern` is needed
|
||||||
|
string externPart = func.isExternal() ? "" : "extern ";
|
||||||
|
|
||||||
|
// Generate the emit
|
||||||
|
string externEmit = format("%s%s;", externPart, signature);
|
||||||
|
|
||||||
gprintln(format("FuncExternEmit: '%s'", externEmit));
|
gprintln(format("FuncExternEmit: '%s'", externEmit));
|
||||||
modOut.writeln(externEmit);
|
modOut.writeln(externEmit);
|
||||||
|
@ -1098,7 +1105,14 @@ public final class DCodeEmitter : CodeEmitter
|
||||||
// Emit public variables
|
// Emit public variables
|
||||||
foreach(Variable var; mos.vars())
|
foreach(Variable var; mos.vars())
|
||||||
{
|
{
|
||||||
string externEmit = format("extern %s;", generateSignature_Variable(var));
|
// Generate signature
|
||||||
|
string signature = generateSignature_Variable(var);
|
||||||
|
|
||||||
|
// Decide whether or not `extern` is needed
|
||||||
|
string externPart = var.isExternal() ? "" : "extern ";
|
||||||
|
|
||||||
|
// Generate the emit
|
||||||
|
string externEmit = format("%s%s;", externPart, signature);
|
||||||
|
|
||||||
gprintln(format("VarExternEmit: '%s'", externEmit));
|
gprintln(format("VarExternEmit: '%s'", externEmit));
|
||||||
modOut.writeln(externEmit);
|
modOut.writeln(externEmit);
|
||||||
|
@ -1212,6 +1226,12 @@ public final class DCodeEmitter : CodeEmitter
|
||||||
// <type> <name>
|
// <type> <name>
|
||||||
signature = typeTransform(varType)~" "~symbolName;
|
signature = typeTransform(varType)~" "~symbolName;
|
||||||
|
|
||||||
|
// If if is external then it needs `extern ...`
|
||||||
|
if(var.isExternal())
|
||||||
|
{
|
||||||
|
signature = "extern "~signature;
|
||||||
|
}
|
||||||
|
|
||||||
return signature;
|
return signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue