Browse Source

Added support for 16-bit wide characters (char16_t).

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1033/head
Dimitar Dobrev 8 years ago
parent
commit
67b241d95b
  1. 1
      src/Generator/Generators/CLI/CLIMarshal.cs
  2. 4
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  3. 9
      tests/Common/Common.Tests.cs
  4. 5
      tests/Common/Common.cpp
  5. 1
      tests/Common/Common.h

1
src/Generator/Generators/CLI/CLIMarshal.cs

@ -211,6 +211,7 @@ namespace CppSharp.Generators.CLI @@ -211,6 +211,7 @@ namespace CppSharp.Generators.CLI
return true;
case PrimitiveType.Bool:
case PrimitiveType.Char:
case PrimitiveType.Char16:
case PrimitiveType.WideChar:
case PrimitiveType.SChar:
case PrimitiveType.UChar:

4
src/Generator/Generators/CSharp/CSharpMarshal.cs

@ -244,8 +244,6 @@ namespace CppSharp.Generators.CSharp @@ -244,8 +244,6 @@ namespace CppSharp.Generators.CSharp
return true;
}
goto default;
case PrimitiveType.Char16:
return false;
case PrimitiveType.Bool:
if (Context.MarshalKind == MarshalKind.NativeField)
{
@ -728,8 +726,6 @@ namespace CppSharp.Generators.CSharp @@ -728,8 +726,6 @@ namespace CppSharp.Generators.CSharp
return true;
}
goto default;
case PrimitiveType.Char16:
return false;
case PrimitiveType.Bool:
if (Context.MarshalKind == MarshalKind.NativeField)
{

9
tests/Common/Common.Tests.cs

@ -826,4 +826,13 @@ This is a very long string. This is a very long string. This is a very long stri @@ -826,4 +826,13 @@ This is a very long string. This is a very long string. This is a very long stri
Assert.That(testProperties.RefToPrimitiveInSetter, Is.EqualTo(value));
}
}
[Test]
public void TestReturnChar16()
{
using (var foo = new Foo())
{
Assert.That(foo.ReturnChar16(), Is.EqualTo('a'));
}
}
}

5
tests/Common/Common.cpp

@ -74,6 +74,11 @@ int Foo::fooPtr() @@ -74,6 +74,11 @@ int Foo::fooPtr()
return 1;
}
char16_t Foo::returnChar16()
{
return 'a';
}
Foo2::Foo2() {}
Foo2 Foo2::operator<<(signed int i)

1
tests/Common/Common.h

@ -108,6 +108,7 @@ public: @@ -108,6 +108,7 @@ public:
bool operator ==(const Foo& other) const;
int fooPtr();
char16_t returnChar16();
};
// HACK: do not move these to the cpp - C++/CLI is buggy and cannot link static fields initialised in the cpp

Loading…
Cancel
Save