Browse Source

Fixed vtable setup call generation when there are no valid methods in the vtable.

pull/92/head
triton 12 years ago
parent
commit
b51687a2f6
  1. 21
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

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

@ -1116,13 +1116,17 @@ namespace CppSharp.Generators.CSharp
#region Virtual Tables #region Virtual Tables
public void GenerateVTable(Class @class) public List<VTableComponent> GetVTableMethodEntries(Class @class)
{ {
var entries = VTables.GatherVTableMethodEntries(@class); var entries = VTables.GatherVTableMethodEntries(@class);
entries = entries.Where(e => !e.Method.Ignore || return entries.Where(e => !e.Method.Ignore ||
@class.Properties.Any(p => !p.Ignore && @class.Properties.Any(p => !p.Ignore &&
(p.GetMethod == e.Method || p.SetMethod == e.Method))).ToList(); (p.GetMethod == e.Method || p.SetMethod == e.Method))).ToList();
}
public void GenerateVTable(Class @class)
{
var entries = GetVTableMethodEntries(@class);
if (entries.Count == 0) if (entries.Count == 0)
return; return;
@ -1241,6 +1245,13 @@ namespace CppSharp.Generators.CSharp
NewLine(); NewLine();
} }
private void GenerateVTableClassSetupCall(Class @class)
{
var entries = GetVTableMethodEntries(@class);
if (Options.GenerateVirtualTables && @class.IsDynamic && entries.Count != 0)
WriteLine("SetupVTables({0});", Generator.GeneratedIdentifier("Instance"));
}
private void GenerateVTableManagedCall(Method method) private void GenerateVTableManagedCall(Method method)
{ {
if (method.IsDestructor) if (method.IsDestructor)
@ -1605,8 +1616,7 @@ namespace CppSharp.Generators.CSharp
if (ShouldGenerateClassNativeField(@class)) if (ShouldGenerateClassNativeField(@class))
{ {
WriteLine("{0} = native;", Helpers.InstanceIdentifier); WriteLine("{0} = native;", Helpers.InstanceIdentifier);
if (Options.GenerateVirtualTables && @class.IsDynamic) GenerateVTableClassSetupCall(@class);
WriteLine("SetupVTables({0});", Generator.GeneratedIdentifier("Instance"));
} }
} }
else else
@ -1857,8 +1867,7 @@ namespace CppSharp.Generators.CSharp
WriteLine(");"); WriteLine(");");
} }
if (Options.GenerateVirtualTables && @class.IsDynamic) GenerateVTableClassSetupCall(@class);
WriteLine("SetupVTables({0});", Generator.GeneratedIdentifier("Instance"));
} }
public void GenerateInternalFunctionCall(Function function, public void GenerateInternalFunctionCall(Function function,

Loading…
Cancel
Save