Browse Source

Fixed a bug with removing the "override" modifier when overriding a member of a secondary base.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/513/head
Dimitar Dobrev 10 years ago
parent
commit
8fd62e6294
  1. 2
      src/AST/ClassExtensions.cs
  2. 4
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  3. 7
      tests/CSharpTemp/CSharpTemp.Tests.cs
  4. 8
      tests/CSharpTemp/CSharpTemp.cpp
  5. 16
      tests/CSharpTemp/CSharpTemp.h

2
src/AST/ClassExtensions.cs

@ -66,7 +66,7 @@ namespace CppSharp.AST @@ -66,7 +66,7 @@ namespace CppSharp.AST
method.Parameters.SequenceEqual(@override.Parameters,
new ParameterTypeComparer())
select method).FirstOrDefault()
let rootBaseMethod = @base.Class.GetRootBaseMethod(@override) ?? baseMethod
let rootBaseMethod = @base.Class.GetRootBaseMethod(@override, onlyFirstBase) ?? baseMethod
where rootBaseMethod != null || onlyFirstBase
select rootBaseMethod).FirstOrDefault();
}

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

@ -2008,7 +2008,9 @@ namespace CppSharp.Generators.CSharp @@ -2008,7 +2008,9 @@ namespace CppSharp.Generators.CSharp
}
// check if overriding a function from a secondary base
var isOverride = method.IsOverride && @class.GetRootBaseMethod(method, true) != null;
Method rootBaseMethod;
var isOverride = method.IsOverride &&
(rootBaseMethod = @class.GetRootBaseMethod(method, true)) != null && rootBaseMethod.IsVirtual;
if (method.IsVirtual && !isOverride && !method.IsOperator && !method.IsPure)
Write("virtual ");

7
tests/CSharpTemp/CSharpTemp.Tests.cs

@ -17,9 +17,10 @@ public class CSharpTempTests : GeneratorTestFixture @@ -17,9 +17,10 @@ public class CSharpTempTests : GeneratorTestFixture
[Test]
public void TestUncompilableCode()
{
using (new ForceCreationOfInterface())
{
}
new ForceCreationOfInterface().Dispose();
new InheritsProtectedVirtualFromSecondaryBase().Dispose();
new InheritanceBuffer().Dispose();
new HasProtectedVirtual().Dispose();
}
[Test]

8
tests/CSharpTemp/CSharpTemp.cpp

@ -586,3 +586,11 @@ TestParamToInterfacePass::TestParamToInterfacePass(TestParamToInterfacePassBaseT @@ -586,3 +586,11 @@ TestParamToInterfacePass::TestParamToInterfacePass(TestParamToInterfacePassBaseT
TestParamToInterfacePass::TestParamToInterfacePass() : TestParamToInterfacePassBaseOne(), TestParamToInterfacePassBaseTwo()
{
}
void HasProtectedVirtual::protectedVirtual()
{
}
void InheritsProtectedVirtualFromSecondaryBase::protectedVirtual()
{
}

16
tests/CSharpTemp/CSharpTemp.h

@ -550,3 +550,19 @@ public: @@ -550,3 +550,19 @@ public:
TestParamToInterfacePass(TestParamToInterfacePassBaseTwo b);
TestParamToInterfacePass();
};
class DLL_API HasProtectedVirtual
{
protected:
virtual void protectedVirtual();
};
class DLL_API InheritanceBuffer : public Foo, public HasProtectedVirtual
{
};
class DLL_API InheritsProtectedVirtualFromSecondaryBase : public InheritanceBuffer
{
protected:
void protectedVirtual();
};

Loading…
Cancel
Save