Skip to content

Commit 67b241d

Browse files
committed
Added support for 16-bit wide characters (char16_t).
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 1408038 commit 67b241d

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

src/Generator/Generators/CLI/CLIMarshal.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ public bool VisitPrimitiveType(PrimitiveType primitive)
211211
return true;
212212
case PrimitiveType.Bool:
213213
case PrimitiveType.Char:
214+
case PrimitiveType.Char16:
214215
case PrimitiveType.WideChar:
215216
case PrimitiveType.SChar:
216217
case PrimitiveType.UChar:

src/Generator/Generators/CSharp/CSharpMarshal.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ public override bool VisitPrimitiveType(PrimitiveType primitive, TypeQualifiers
244244
return true;
245245
}
246246
goto default;
247-
case PrimitiveType.Char16:
248-
return false;
249247
case PrimitiveType.Bool:
250248
if (Context.MarshalKind == MarshalKind.NativeField)
251249
{
@@ -728,8 +726,6 @@ public override bool VisitPrimitiveType(PrimitiveType primitive, TypeQualifiers
728726
return true;
729727
}
730728
goto default;
731-
case PrimitiveType.Char16:
732-
return false;
733729
case PrimitiveType.Bool:
734730
if (Context.MarshalKind == MarshalKind.NativeField)
735731
{

tests/Common/Common.Tests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,4 +826,13 @@ public void TestRefToPrimitiveInSetter()
826826
Assert.That(testProperties.RefToPrimitiveInSetter, Is.EqualTo(value));
827827
}
828828
}
829+
830+
[Test]
831+
public void TestReturnChar16()
832+
{
833+
using (var foo = new Foo())
834+
{
835+
Assert.That(foo.ReturnChar16(), Is.EqualTo('a'));
836+
}
837+
}
829838
}

tests/Common/Common.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ int Foo::fooPtr()
7474
return 1;
7575
}
7676

77+
char16_t Foo::returnChar16()
78+
{
79+
return 'a';
80+
}
81+
7782
Foo2::Foo2() {}
7883

7984
Foo2 Foo2::operator<<(signed int i)

tests/Common/Common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class DLL_API Foo
108108
bool operator ==(const Foo& other) const;
109109

110110
int fooPtr();
111+
char16_t returnChar16();
111112
};
112113

113114
// HACK: do not move these to the cpp - C++/CLI is buggy and cannot link static fields initialised in the cpp

0 commit comments

Comments
 (0)