Browse Source

Fixed the generation when a secondary base is used in more than one unit.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1139/head
Dimitar Dobrev 7 years ago
parent
commit
92da301135
  1. 4
      src/Generator/Passes/MultipleInheritancePass.cs
  2. 38
      tests/CSharp/AnotherUnit.cpp
  3. 33
      tests/CSharp/AnotherUnit.h
  4. 1
      tests/CSharp/CSharp.Tests.cs
  5. 30
      tests/CSharp/CSharp.cpp
  6. 26
      tests/CSharp/CSharp.h

4
src/Generator/Passes/MultipleInheritancePass.cs

@ -27,9 +27,9 @@ namespace CppSharp.Passes @@ -27,9 +27,9 @@ namespace CppSharp.Passes
VisitOptions.VisitFunctionParameters = false;
}
public override bool VisitTranslationUnit(TranslationUnit unit)
public override bool VisitASTContext(ASTContext context)
{
bool result = base.VisitTranslationUnit(unit);
bool result = base.VisitASTContext(context);
foreach (var @interface in interfaces.Where(i => !(i is ClassTemplateSpecialization)))
{
int index = @interface.Namespace.Declarations.IndexOf(@interface.OriginalClass);

38
tests/CSharp/AnotherUnit.cpp

@ -1,9 +1,47 @@ @@ -1,9 +1,47 @@
#include "AnotherUnit.h"
void SecondaryBase::VirtualMember()
{
}
int SecondaryBase::property()
{
return 0;
}
void SecondaryBase::setProperty(int value)
{
}
void SecondaryBase::function(bool* ok)
{
}
void SecondaryBase::protectedFunction()
{
}
int SecondaryBase::protectedProperty()
{
return 0;
}
void SecondaryBase::setProtectedProperty(int value)
{
}
void functionInAnotherUnit()
{
}
MultipleInheritance::MultipleInheritance()
{
}
MultipleInheritance::~MultipleInheritance()
{
}
namespace HasFreeConstant
{
extern const int DLL_API FREE_CONSTANT_IN_NAMESPACE = 5;

33
tests/CSharp/AnotherUnit.h

@ -3,6 +3,32 @@ @@ -3,6 +3,32 @@
#pragma once
class DLL_API SecondaryBase
{
public:
enum Property
{
P1,
P2
};
enum Function
{
M1,
M2
};
virtual void VirtualMember();
int property();
void setProperty(int value);
void function(bool* ok = 0);
typedef void HasPointerToEnum(Property* pointerToEnum);
HasPointerToEnum* hasPointerToEnum;
protected:
void protectedFunction();
int protectedProperty();
void setProtectedProperty(int value);
};
void DLL_API functionInAnotherUnit();
struct DLL_API ForwardDeclaredStruct;
@ -19,6 +45,13 @@ class ForwardInOtherUnitButSameModule @@ -19,6 +45,13 @@ class ForwardInOtherUnitButSameModule
{
};
class DLL_API MultipleInheritance : ForwardInOtherUnitButSameModule, SecondaryBase
{
public:
MultipleInheritance();
~MultipleInheritance();
};
namespace HasFreeConstant
{
extern const int DLL_API FREE_CONSTANT_IN_NAMESPACE;

1
tests/CSharp/CSharp.Tests.cs

@ -23,6 +23,7 @@ public unsafe class CSharpTests : GeneratorTestFixture @@ -23,6 +23,7 @@ public unsafe class CSharpTests : GeneratorTestFixture
#pragma warning disable 0219 // warning CS0219: The variable `foo' is assigned but its value is never used
ALLCAPS_UNDERSCORES a;
new MultipleInheritance().Dispose();
using (var testRenaming = new TestRenaming())
{
testRenaming.name();

30
tests/CSharp/CSharp.cpp

@ -839,36 +839,6 @@ HasVirtualDtor1* CallDtorVirtually::getHasVirtualDtor1(HasVirtualDtor1* returned @@ -839,36 +839,6 @@ HasVirtualDtor1* CallDtorVirtually::getHasVirtualDtor1(HasVirtualDtor1* returned
return returned;
}
void SecondaryBase::VirtualMember()
{
}
int SecondaryBase::property()
{
return 0;
}
void SecondaryBase::setProperty(int value)
{
}
void SecondaryBase::function(bool* ok)
{
}
void SecondaryBase::protectedFunction()
{
}
int SecondaryBase::protectedProperty()
{
return 0;
}
void SecondaryBase::setProtectedProperty(int value)
{
}
TestOverrideFromSecondaryBase::TestOverrideFromSecondaryBase()
{
}

26
tests/CSharp/CSharp.h

@ -684,32 +684,6 @@ protected: @@ -684,32 +684,6 @@ protected:
} u;
};
class DLL_API SecondaryBase
{
public:
enum Property
{
P1,
P2
};
enum Function
{
M1,
M2
};
virtual void VirtualMember();
int property();
void setProperty(int value);
void function(bool* ok = 0);
typedef void HasPointerToEnum(Property* pointerToEnum);
HasPointerToEnum* hasPointerToEnum;
protected:
void protectedFunction();
int protectedProperty();
void setProtectedProperty(int value);
};
class DLL_API TestOverrideFromSecondaryBase : public Foo, public SecondaryBase
{
public:

Loading…
Cancel
Save