Browse Source

Generate valid C# when std::string is only used for non-private fields

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1214/head
Dimitar Dobrev 7 years ago
parent
commit
1d2880751a
  1. 4
      src/Generator/Passes/TrimSpecializationsPass.cs
  2. 11
      tests/VTables/VTables.Tests.cs
  3. 2
      tests/VTables/VTables.h

4
src/Generator/Passes/TrimSpecializationsPass.cs

@ -85,9 +85,7 @@ namespace CppSharp.Passes @@ -85,9 +85,7 @@ namespace CppSharp.Passes
return true;
}
TypeMap typeMap;
if (!Context.TypeMaps.FindTypeMap(field.Type, out typeMap) &&
!ASTUtils.CheckTypeForSpecialization(field.Type,
if (!ASTUtils.CheckTypeForSpecialization(field.Type,
field, AddSpecialization, Context.TypeMaps))
CheckForInternalSpecialization(field, field.Type);

11
tests/VTables/VTables.Tests.cs

@ -78,4 +78,15 @@ public class VTablesTests : GeneratorTestFixture @@ -78,4 +78,15 @@ public class VTablesTests : GeneratorTestFixture
var retBase = new ManagedDerivedClassVirtualRetBase();
TestVirtualFunction(retBase, 10);
}
[Test]
public void TestStdStringInField()
{
using (var foo = new Foo())
{
Assert.That(foo.S, Is.Empty);
foo.S = "test";
Assert.That(foo.S, Is.EqualTo("test"));
}
}
}

2
tests/VTables/VTables.h

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "../Tests.h"
#include <string>
class DLL_API Foo
{
@ -15,6 +16,7 @@ public: @@ -15,6 +16,7 @@ public:
virtual int append();
virtual int append(int a);
int callVirtualWithParameter(int a);
std::string s;
};
DLL_API int FooCallFoo(Foo* foo);

Loading…
Cancel
Save