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. 4
      src/Generator/Driver.cs
  2. 8
      tests/Basic/Basic.Tests.cs
  3. 1
      tests/Basic/Basic.cs
  4. 6
      tests/Basic/Basic.h

4
src/Generator/Driver.cs

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

8
tests/Basic/Basic.Tests.cs

@ -265,5 +265,13 @@ public class BasicTests : GeneratorTestFixture
var arrays = new TestArraysPointers(&values, 1); var arrays = new TestArraysPointers(&values, 1);
Assert.That(arrays.Value, Is.EqualTo(MyEnum.A)); 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
driver.Options.GenerateVirtualTables = true; driver.Options.GenerateVirtualTables = true;
driver.Options.GenerateCopyConstructors = true; driver.Options.GenerateCopyConstructors = true;
driver.Options.MarshalCharAsManagedChar = true; driver.Options.MarshalCharAsManagedChar = true;
driver.Options.GenerateProperties = true;
} }
public override void Preprocess(Driver driver, ASTContext ctx) public override void Preprocess(Driver driver, ASTContext ctx)

6
tests/Basic/Basic.h

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