Browse Source

Fixed the generation of overrides of virtuals from secondary bases.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/256/merge
Dimitar Dobrev 10 years ago
parent
commit
8a68d2d16c
  1. 10
      src/AST/ClassExtensions.cs
  2. 4
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  3. 3
      src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs

10
src/AST/ClassExtensions.cs

@ -93,10 +93,11 @@ namespace CppSharp.AST @@ -93,10 +93,11 @@ namespace CppSharp.AST
return null;
}
public static bool HasNonAbstractBaseMethod(this Class @class, Method method)
public static bool HasNonAbstractBaseMethodInPrimaryBase(this Class @class, Method method)
{
var baseMethod = @class.GetBaseMethod(method, true, true);
return baseMethod != null && !baseMethod.IsPure;
return baseMethod != null && !baseMethod.IsPure &&
!((Class) baseMethod.OriginalNamespace).IsInterface;
}
public static Property GetBaseProperty(this Class @class, Property @override,
@ -134,10 +135,11 @@ namespace CppSharp.AST @@ -134,10 +135,11 @@ namespace CppSharp.AST
return null;
}
public static bool HasNonAbstractBaseProperty(this Class @class, Property property)
public static bool HasNonAbstractBasePropertyInPrimaryBase(this Class @class, Property property)
{
var baseProperty = @class.GetBaseProperty(property, true, true);
return baseProperty != null && !baseProperty.IsPure;
return baseProperty != null && !baseProperty.IsPure &&
!((Class) baseProperty.OriginalNamespace).IsInterface;
}
public static Property GetPropertyByName(this Class @class, string propertyName)

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

@ -2263,7 +2263,7 @@ namespace CppSharp.Generators.CSharp @@ -2263,7 +2263,7 @@ namespace CppSharp.Generators.CSharp
{
if (property.IsOverride && !property.IsPure &&
method.SynthKind != FunctionSynthKind.AbstractImplCall &&
@class.HasNonAbstractBaseProperty(property))
@class.HasNonAbstractBasePropertyInPrimaryBase(property))
{
WriteLine(parameters == null ?
"return base.{0};" : "base.{0} = value;", property.Name);
@ -2281,7 +2281,7 @@ namespace CppSharp.Generators.CSharp @@ -2281,7 +2281,7 @@ namespace CppSharp.Generators.CSharp
{
if (!forceVirtualCall && method.IsOverride && !method.IsPure &&
method.SynthKind != FunctionSynthKind.AbstractImplCall &&
@class.HasNonAbstractBaseMethod(method))
@class.HasNonAbstractBaseMethodInPrimaryBase(method))
{
GenerateManagedCall(method, true);
}

3
src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs

@ -147,7 +147,8 @@ namespace CppSharp.Passes @@ -147,7 +147,8 @@ namespace CppSharp.Passes
: AccessSpecifier.Protected,
Name = GetPropertyName(getter.Name),
Namespace = type,
QualifiedType = getter.OriginalReturnType
QualifiedType = getter.OriginalReturnType,
OriginalNamespace = getter.OriginalNamespace
};
if (getter.IsOverride || (setter != null && setter.IsOverride))
{

Loading…
Cancel
Save