Browse Source

Merge pull request #117 from ddobrev/master

Improved the property generation by matching with an "is" prefix for read-write properties.
pull/123/head
João Matos 12 years ago
parent
commit
cf0a0a12d9
  1. 16
      src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs
  2. 10
      tests/CSharpTemp/CSharpTemp.cpp
  3. 3
      tests/CSharpTemp/CSharpTemp.h

16
src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs

@ -93,11 +93,7 @@ namespace CppSharp.Passes @@ -93,11 +93,7 @@ namespace CppSharp.Passes
string afterSet = nameBuilder.ToString();
foreach (var getter in nonSetters.Where(m => m.Namespace == type))
{
string name = GetPropertyName(getter.Name);
if (name.StartsWith("is"))
{
name = char.ToLowerInvariant(name[2]) + name.Substring(3);
}
var name = GetReadWritePropertyName(getter, afterSet);
if (name == afterSet &&
GetUnderlyingType(getter.OriginalReturnType).Equals(
GetUnderlyingType(setter.Parameters[0].QualifiedType)) &&
@ -136,6 +132,16 @@ namespace CppSharp.Passes @@ -136,6 +132,16 @@ namespace CppSharp.Passes
}
}
private static string GetReadWritePropertyName(INamedDecl getter, string afterSet)
{
string name = GetPropertyName(getter.Name);
if (name != afterSet && name.StartsWith("is"))
{
name = char.ToLowerInvariant(name[2]) + name.Substring(3);
}
return name;
}
private static Type GetUnderlyingType(QualifiedType type)
{
TagType tagType = type.Type as TagType;

10
tests/CSharpTemp/CSharpTemp.cpp

@ -164,3 +164,13 @@ void P::setTest(bool value) @@ -164,3 +164,13 @@ void P::setTest(bool value)
{
}
bool P::isBool()
{
return false;
}
void P::setIsBool(bool value)
{
}

3
tests/CSharpTemp/CSharpTemp.h

@ -115,6 +115,9 @@ public: @@ -115,6 +115,9 @@ public:
bool isTest();
void setTest(bool value);
bool isBool();
void setIsBool(bool value);
private:
ComplexType m_complexType;
};

Loading…
Cancel
Save