Browse Source

Reworked per-Abi vtable code to correctly handle all platforms.

pull/552/merge
triton 11 years ago
parent
commit
89cdf8b997
  1. 48
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

48
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -1397,16 +1397,10 @@ namespace CppSharp.Generators.CSharp
WriteLine("if (__ManagedVTables == null)"); WriteLine("if (__ManagedVTables == null)");
WriteStartBraceIndent(); WriteStartBraceIndent();
switch (Driver.Options.Abi) if (Options.IsMicrosoftAbi)
{ AllocateNewVTablesMS(@class, entries, wrappedEntries);
case CppAbi.Microsoft: else
AllocateNewVTablesMS(@class, entries, wrappedEntries); AllocateNewVTablesItanium(@class, entries, wrappedEntries);
break;
case CppAbi.Itanium:
case CppAbi.ARM:
AllocateNewVTablesItanium(@class, entries, wrappedEntries);
break;
}
WriteCloseBraceIndent(); WriteCloseBraceIndent();
NewLine(); NewLine();
@ -1663,29 +1657,27 @@ namespace CppSharp.Generators.CSharp
public void GenerateVTablePointers(Class @class) public void GenerateVTablePointers(Class @class)
{ {
switch (Driver.Options.Abi) if (Options.IsMicrosoftAbi)
{ {
case CppAbi.Microsoft: var index = 0;
var index = 0; foreach (var info in @class.Layout.VFTables)
foreach (var info in @class.Layout.VFTables) {
{
PushBlock(CSharpBlockKind.InternalsClassField);
WriteLine("[FieldOffset({0})]", info.VFPtrFullOffset);
WriteLine("public global::System.IntPtr vfptr{0};", index++);
PopBlock(NewLineKind.BeforeNextBlock);
}
break;
case CppAbi.Itanium:
case CppAbi.ARM:
PushBlock(CSharpBlockKind.InternalsClassField); PushBlock(CSharpBlockKind.InternalsClassField);
WriteLine("[FieldOffset(0)]"); WriteLine("[FieldOffset({0})]", info.VFPtrFullOffset);
WriteLine("public global::System.IntPtr vfptr0;"); WriteLine("public global::System.IntPtr vfptr{0};", index++);
PopBlock(NewLineKind.BeforeNextBlock); PopBlock(NewLineKind.BeforeNextBlock);
break; }
}
else
{
PushBlock(CSharpBlockKind.InternalsClassField);
WriteLine("[FieldOffset(0)]");
WriteLine("public global::System.IntPtr vfptr0;");
PopBlock(NewLineKind.BeforeNextBlock);
} }
} }

Loading…
Cancel
Save