Browse Source

Fixed a crash when setting up v-tables.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/94/head
Dimitar Dobrev 12 years ago
parent
commit
9deaa403bc
  1. 14
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  2. 1
      tests/CSharpTemp/CSharpTemp.cs

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

@ -1245,11 +1245,21 @@ namespace CppSharp.Generators.CSharp @@ -1245,11 +1245,21 @@ namespace CppSharp.Generators.CSharp
NewLine();
}
private void GenerateVTableClassSetupCall(Class @class)
private void GenerateVTableClassSetupCall(Class @class, bool addPointerGuard = false)
{
var entries = GetVTableMethodEntries(@class);
if (Options.GenerateVirtualTables && @class.IsDynamic && entries.Count != 0)
{
// called from internal ctors which may have been passed an IntPtr.Zero
if (addPointerGuard)
{
WriteLine("if ({0} != global::System.IntPtr.Zero)", Helpers.InstanceIdentifier);
PushIndent();
}
WriteLine("SetupVTables({0});", Generator.GeneratedIdentifier("Instance"));
if (addPointerGuard)
PopIndent();
}
}
private void GenerateVTableManagedCall(Method method)
@ -1613,7 +1623,7 @@ namespace CppSharp.Generators.CSharp @@ -1613,7 +1623,7 @@ namespace CppSharp.Generators.CSharp
if (ShouldGenerateClassNativeField(@class))
{
WriteLine("{0} = native;", Helpers.InstanceIdentifier);
GenerateVTableClassSetupCall(@class);
GenerateVTableClassSetupCall(@class, true);
}
}
else

1
tests/CSharpTemp/CSharpTemp.cs

@ -14,6 +14,7 @@ namespace CppSharp.Tests @@ -14,6 +14,7 @@ namespace CppSharp.Tests
{
driver.Options.GenerateInterfacesForMultipleInheritance = true;
driver.Options.GenerateProperties = true;
driver.Options.GenerateVirtualTables = true;
}
public static void Main(string[] args)

Loading…
Cancel
Save