Browse Source

Fixed generation of properties to behave as expected.

Fixed this by changing GenerateProperties to use GetterSetterToPropertyPass instead of GetterSetterToPropertyAdvancedPass.

Fixes issue #215.
pull/226/merge
triton 11 years ago
parent
commit
9166a55202
  1. 2
      src/Generator/Driver.cs
  2. 8
      tests/Basic/Basic.Tests.cs
  3. 1
      tests/Basic/Basic.cs
  4. 6
      tests/Basic/Basic.h

2
src/Generator/Driver.cs

@ -301,7 +301,7 @@ namespace CppSharp @@ -301,7 +301,7 @@ namespace CppSharp
TranslationUnitPasses.AddPass(new CheckVTableComponentsPass());
if (Options.GenerateProperties)
TranslationUnitPasses.AddPass(new GetterSetterToPropertyAdvancedPass());
TranslationUnitPasses.AddPass(new GetterSetterToPropertyPass());
}
public void ProcessCode()

8
tests/Basic/Basic.Tests.cs

@ -265,5 +265,13 @@ public class BasicTests : GeneratorTestFixture @@ -265,5 +265,13 @@ public class BasicTests : GeneratorTestFixture
var arrays = new TestArraysPointers(&values, 1);
Assert.That(arrays.Value, Is.EqualTo(MyEnum.A));
}
[Test]
public unsafe void TestGetterSetterToProperties()
{
var @class = new TestGetterSetterToProperties();
Assert.That(@class.Width, Is.EqualTo(640));
Assert.That(@class.Height, Is.EqualTo(480));
}
}

1
tests/Basic/Basic.cs

@ -20,6 +20,7 @@ namespace CppSharp.Tests @@ -20,6 +20,7 @@ namespace CppSharp.Tests
driver.Options.GenerateVirtualTables = true;
driver.Options.GenerateCopyConstructors = true;
driver.Options.MarshalCharAsManagedChar = true;
driver.Options.GenerateProperties = true;
}
public override void Preprocess(Driver driver, ASTContext ctx)

6
tests/Basic/Basic.h

@ -363,3 +363,9 @@ public: @@ -363,3 +363,9 @@ public:
MyEnum Value;
};
struct DLL_API TestGetterSetterToProperties
{
int getWidth() { return 640; }
int getHeight() { return 480; }
};
Loading…
Cancel
Save