Browse Source

Removed a check for const-ness because of a parser bug. Added tests for properties of complex types.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/94/head
Dimitar Dobrev 12 years ago
parent
commit
501f123277
  1. 5
      src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs
  2. 5
      tests/CSharpTemp/CSharpTemp.Tests.cs
  3. 10
      tests/CSharpTemp/CSharpTemp.cpp
  4. 12
      tests/CSharpTemp/CSharpTemp.h

5
src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs

@ -139,8 +139,9 @@ namespace CppSharp.Passes
TagType tagType = type.Type as TagType; TagType tagType = type.Type as TagType;
if (tagType != null) if (tagType != null)
return type.Type; return type.Type;
if (!type.Qualifiers.IsConst) // TODO: we should normally check pointer types for const;
return type.Type; // however, there's some bug, probably in the parser, that returns IsConst = false for "const Type& arg"
// so skip the check for the time being
PointerType pointerType = type.Type as PointerType; PointerType pointerType = type.Type as PointerType;
return pointerType != null ? pointerType.Pointee : type.Type; return pointerType != null ? pointerType.Pointee : type.Type;
} }

5
tests/CSharpTemp/CSharpTemp.Tests.cs

@ -74,5 +74,10 @@ public class CSharpTempTests
Assert.That(p.value, Is.EqualTo(30)); Assert.That(p.value, Is.EqualTo(30));
p.prop = 50; p.prop = 50;
Assert.That(p.prop, Is.EqualTo(150)); Assert.That(p.prop, Is.EqualTo(150));
ComplexType complexType = new ComplexType();
complexType.check = 5;
p.complexType = complexType;
Assert.That(p.complexType.check, Is.EqualTo(5));
} }
} }

10
tests/CSharpTemp/CSharpTemp.cpp

@ -95,3 +95,13 @@ long P::prop()
{ {
return m_property + 100; return m_property + 100;
} }
ComplexType P::complexType()
{
return m_complexType;
}
void P::setComplexType(ComplexType value)
{
m_complexType = value;
}

12
tests/CSharpTemp/CSharpTemp.h

@ -86,9 +86,21 @@ public:
virtual long prop(); virtual long prop();
}; };
class ComplexType
{
public:
int check;
};
class DLL_API P : Proprietor class DLL_API P : Proprietor
{ {
public: public:
virtual void setValue(int value); virtual void setValue(int value);
virtual long prop(); virtual long prop();
ComplexType complexType();
void setComplexType(ComplexType value);
private:
ComplexType m_complexType;
}; };

Loading…
Cancel
Save