From 8a68d2d16cf76d9ce274e65506d37564f1caf977 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Thu, 5 Nov 2015 05:35:40 +0200 Subject: [PATCH] Fixed the generation of overrides of virtuals from secondary bases. Signed-off-by: Dimitar Dobrev --- src/AST/ClassExtensions.cs | 10 ++++++---- src/Generator/Generators/CSharp/CSharpTextTemplate.cs | 4 ++-- .../Passes/GetterSetterToPropertyAdvancedPass.cs | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/AST/ClassExtensions.cs b/src/AST/ClassExtensions.cs index 0cc9a6f3..6b7b11c7 100644 --- a/src/AST/ClassExtensions.cs +++ b/src/AST/ClassExtensions.cs @@ -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 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) diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 8788af78..53e6e171 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -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 { if (!forceVirtualCall && method.IsOverride && !method.IsPure && method.SynthKind != FunctionSynthKind.AbstractImplCall && - @class.HasNonAbstractBaseMethod(method)) + @class.HasNonAbstractBaseMethodInPrimaryBase(method)) { GenerateManagedCall(method, true); } diff --git a/src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs b/src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs index 12302140..9c36e749 100644 --- a/src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs +++ b/src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs @@ -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)) {