Browse Source

Removed the now useless internal declarations for virtual non-operators.

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

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

@ -541,7 +541,7 @@ namespace CppSharp.Generators.CSharp
method.SynthKind != FunctionSynthKind.AdjustedMethod) method.SynthKind != FunctionSynthKind.AdjustedMethod)
return; return;
if (method.IsProxy) if (method.IsProxy || (method.IsVirtual && !method.IsOperator))
return; return;
functions.Add(method); functions.Add(method);
@ -813,7 +813,8 @@ namespace CppSharp.Generators.CSharp
return Tuple.Create(library, decl.Mangled); return Tuple.Create(library, decl.Mangled);
} }
private void GeneratePropertySetter<T>(T decl, Class @class, bool isAbstract = false) private void GeneratePropertySetter<T>(T decl,
Class @class, bool isAbstract = false, Property property = null)
where T : Declaration, ITypedDecl where T : Declaration, ITypedDecl
{ {
if (!(decl is Function || decl is Field) ) if (!(decl is Function || decl is Field) )
@ -853,15 +854,14 @@ namespace CppSharp.Generators.CSharp
param.QualifiedType = function.Parameters[0].QualifiedType; param.QualifiedType = function.Parameters[0].QualifiedType;
var method = function as Method;
if (function.SynthKind == FunctionSynthKind.AbstractImplCall) if (function.SynthKind == FunctionSynthKind.AbstractImplCall)
{ GenerateVirtualPropertyCall(function, @class.BaseClass, property,
string delegateId; new List<Parameter> { param });
Write(GetVirtualCallDelegate(function, @class.BaseClass, out delegateId)); else if (method != null && method.IsVirtual)
GenerateFunctionCall(delegateId, new List<Parameter> { param }, function); GenerateVirtualPropertyCall(method, @class, property, new List<Parameter> { param });
}
else else
{ {
var method = function as Method;
if (method != null && method.OperatorKind == CXXOperatorKind.Subscript) if (method != null && method.OperatorKind == CXXOperatorKind.Subscript)
{ {
if (method.OperatorKind == CXXOperatorKind.Subscript) if (method.OperatorKind == CXXOperatorKind.Subscript)
@ -994,7 +994,7 @@ namespace CppSharp.Generators.CSharp
} }
private void GeneratePropertyGetter<T>(QualifiedType returnType, T decl, private void GeneratePropertyGetter<T>(QualifiedType returnType, T decl,
Class @class, bool isAbstract = false) Class @class, bool isAbstract = false, Property property = null)
where T : Declaration, ITypedDecl where T : Declaration, ITypedDecl
{ {
PushBlock(CSharpBlockKind.Method); PushBlock(CSharpBlockKind.Method);
@ -1012,9 +1012,12 @@ namespace CppSharp.Generators.CSharp
NewLine(); NewLine();
WriteStartBraceIndent(); WriteStartBraceIndent();
var method = function as Method; var method = function as Method;
if (method != null && method.SynthKind == FunctionSynthKind.AbstractImplCall) if (function.SynthKind == FunctionSynthKind.AbstractImplCall)
GenerateVirtualFunctionCall(method, @class.BaseClass); GenerateVirtualPropertyCall(method, @class.BaseClass, property);
else if (method != null && method.IsVirtual)
GenerateVirtualPropertyCall(method, @class, property);
else else
GenerateInternalFunctionCall(function, function.Parameters, returnType.Type); GenerateInternalFunctionCall(function, function.Parameters, returnType.Type);
} }
@ -1242,10 +1245,10 @@ namespace CppSharp.Generators.CSharp
else else
{ {
if (prop.HasGetter) if (prop.HasGetter)
GeneratePropertyGetter(prop.QualifiedType, prop.GetMethod, @class, prop.IsPure); GeneratePropertyGetter(prop.QualifiedType, prop.GetMethod, @class, prop.IsPure, prop);
if (prop.HasSetter) if (prop.HasSetter)
GeneratePropertySetter(prop.SetMethod, @class, prop.IsPure); GeneratePropertySetter(prop.SetMethod, @class, prop.IsPure, prop);
} }
WriteCloseBraceIndent(); WriteCloseBraceIndent();
@ -2321,12 +2324,31 @@ namespace CppSharp.Generators.CSharp
} }
} }
private void GenerateVirtualPropertyCall(Function method, Class @class,
Property property, List<Parameter> parameters = null)
{
Property baseProperty;
if (property.IsOverride && !property.IsPure &&
method.SynthKind != FunctionSynthKind.AbstractImplCall &&
(baseProperty = ((Class) method.Namespace).GetBaseProperty(property, true, true)) != null &&
!baseProperty.IsPure)
{
WriteLine(parameters == null ? "return base.{0};" : "base.{0} = value;", property.Name);
}
else
{
string delegateId;
Write(GetVirtualCallDelegate(method, @class, out delegateId));
GenerateFunctionCall(delegateId, parameters ?? method.Parameters, method);
}
}
private void GenerateVirtualFunctionCall(Method method, Class @class) private void GenerateVirtualFunctionCall(Method method, Class @class)
{ {
Method rootBaseMethod; Method baseMethod;
if (method.IsOverride && !method.IsPure && method.SynthKind != FunctionSynthKind.AbstractImplCall && if (method.IsOverride && !method.IsPure && method.SynthKind != FunctionSynthKind.AbstractImplCall &&
(rootBaseMethod = ((Class) method.Namespace).GetBaseMethod(method, true, true)) != null && (baseMethod = ((Class) method.Namespace).GetBaseMethod(method, true, true)) != null &&
!rootBaseMethod.IsPure) !baseMethod.IsPure)
{ {
GenerateManagedCall(method, true); GenerateManagedCall(method, true);
} }

Loading…
Cancel
Save