Browse Source

Fixed the pass for conversion operators not to create them in abstract types.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/518/merge
Dimitar Dobrev 10 years ago
parent
commit
fc572cd57e
  1. 7
      src/Generator/Passes/ConstructorToConversionOperatorPass.cs
  2. 1
      tests/CSharpTemp/CSharpTemp.Tests.cs
  3. 12
      tests/CSharpTemp/CSharpTemp.cpp
  4. 3
      tests/CSharpTemp/CSharpTemp.h

7
src/Generator/Passes/ConstructorToConversionOperatorPass.cs

@ -23,17 +23,18 @@ namespace CppSharp.Passes @@ -23,17 +23,18 @@ namespace CppSharp.Passes
if (pointerType != null && !pointerType.IsReference)
return false;
}
var qualifiedPointee = parameter.Type.SkipPointerRefs();
var qualifiedPointee = parameter.Type.GetFinalPointee() ?? parameter.Type;
Class castFromClass;
var castToClass = method.OriginalNamespace as Class;
if (qualifiedPointee.TryGetClass(out castFromClass))
{
var castToClass = method.OriginalNamespace as Class;
if (castToClass == null)
return false;
if (castFromClass == castToClass)
return false;
}
if (castToClass != null && castToClass.IsAbstract)
return false;
var operatorKind = method.IsExplicit
? CXXOperatorKind.ExplicitConversion
: CXXOperatorKind.Conversion;

1
tests/CSharpTemp/CSharpTemp.Tests.cs

@ -21,6 +21,7 @@ public class CSharpTempTests : GeneratorTestFixture @@ -21,6 +21,7 @@ public class CSharpTempTests : GeneratorTestFixture
new InheritsProtectedVirtualFromSecondaryBase().Dispose();
new InheritanceBuffer().Dispose();
new HasProtectedVirtual().Dispose();
new Proprietor(5).Dispose();
using (var foo = new Foo())
{
var isNoParams = foo.IsNoParams;

12
tests/CSharpTemp/CSharpTemp.cpp

@ -170,6 +170,18 @@ int AbstractProprietor::parent() const @@ -170,6 +170,18 @@ int AbstractProprietor::parent() const
return 0;
}
AbstractProprietor::AbstractProprietor()
{
}
AbstractProprietor::AbstractProprietor(int i)
{
}
Proprietor::Proprietor(int i) : AbstractProprietor(i)
{
}
void Proprietor::setValue(int value)
{
m_value = value;

3
tests/CSharpTemp/CSharpTemp.h

@ -117,6 +117,8 @@ public: @@ -117,6 +117,8 @@ public:
virtual int parent() const;
protected:
AbstractProprietor();
AbstractProprietor(int i);
int m_value;
long m_property;
};
@ -125,6 +127,7 @@ class DLL_API Proprietor : public AbstractProprietor @@ -125,6 +127,7 @@ class DLL_API Proprietor : public AbstractProprietor
{
public:
Proprietor();
Proprietor(int i);
virtual void setValue(int value);
virtual long prop();

Loading…
Cancel
Save