Browse Source

Simplified overrides by just calling the base - all goes through the v-table anyway.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/560/head
Dimitar Dobrev 10 years ago
parent
commit
ae805eca31
  1. 28
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

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

@ -2230,14 +2230,20 @@ namespace CppSharp.Generators.CSharp
} }
} }
var index = 0; GenerateManagedCall(function);
}
private void GenerateManagedCall(Function function, bool prependBase = false)
{
var type = function.OriginalReturnType.Type; var type = function.OriginalReturnType.Type;
WriteLine("{0}{1}({2});", var index = 0;
WriteLine("{0}{1}{2}({3});",
type.IsPrimitiveType(PrimitiveType.Void) ? string.Empty : "return ", type.IsPrimitiveType(PrimitiveType.Void) ? string.Empty : "return ",
prependBase ? "base." : string.Empty,
function.Name, function.Name,
string.Join(", ", string.Join(", ",
function.Parameters.Where( function.Parameters.Where(
p => p.Kind == ParameterKind.Regular).Select( p => p.Kind != ParameterKind.IndirectReturnType).Select(
p => p.Ignore ? OverloadParamNameWithDefValue(p, ref index) : p => p.Ignore ? OverloadParamNameWithDefValue(p, ref index) :
(p.Usage == ParameterUsage.InOut ? "ref " : string.Empty) + p.Name))); (p.Usage == ParameterUsage.InOut ? "ref " : string.Empty) + p.Name)));
} }
@ -2301,11 +2307,21 @@ namespace CppSharp.Generators.CSharp
} }
} }
private void GenerateVirtualFunctionCall(Function function, Class @class) private void GenerateVirtualFunctionCall(Method method, Class @class)
{
Method rootBaseMethod;
if (method.IsOverride && method.SynthKind != FunctionSynthKind.AbstractImplCall &&
(rootBaseMethod = ((Class) method.Namespace).GetRootBaseMethod(method, true)) != null &&
!rootBaseMethod.IsPure)
{
GenerateManagedCall(method, true);
}
else
{ {
string delegateId; string delegateId;
Write(GetVirtualCallDelegate(function, @class, out delegateId)); Write(GetVirtualCallDelegate(method, @class, out delegateId));
GenerateFunctionCall(delegateId, function.Parameters, function); GenerateFunctionCall(delegateId, method.Parameters, method);
}
} }
public string GetVirtualCallDelegate(Function function, Class @class, public string GetVirtualCallDelegate(Function function, Class @class,

Loading…
Cancel
Save