Skip to content

Commit

Permalink
Adjustments for std:wstring support for CLI
Browse files Browse the repository at this point in the history
- Adjusted TypeMap for wstring in Stdlib.CLI.cs
- Fixed typo in Common.Test.cs
- Added check in test
- Added wstring exports in Std-symbols.cpp
  • Loading branch information
strentler committed Sep 14, 2021
1 parent 587f466 commit f1743e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ template __declspec(dllexport) std::basic_string<char, std::char_traits<char>, s
template __declspec(dllexport) std::basic_string<char, std::char_traits<char>, std::allocator<char>>::~basic_string() noexcept;
template __declspec(dllexport) std::basic_string<char, std::char_traits<char>, std::allocator<char>>& std::basic_string<char, std::char_traits<char>, std::allocator<char>>::assign(const char* const);
template __declspec(dllexport) const char* std::basic_string<char, std::char_traits<char>, std::allocator<char>>::data() const noexcept;

template __declspec(dllexport) std::allocator<wchar_t>::allocator() noexcept;
template __declspec(dllexport) std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>::basic_string() noexcept(true);
template __declspec(dllexport) std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>::~basic_string() noexcept;
template __declspec(dllexport) std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>& std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>::assign(const wchar_t* const);
template __declspec(dllexport) const wchar_t* std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>::data() const noexcept;
2 changes: 1 addition & 1 deletion src/Generator/Types/Std/Stdlib.CLI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public override void CLIMarshalToManaged(MarshalContext ctx)
}
}

[TypeMap("std::wstring", GeneratorKind = GeneratorKind.CLI)]
[TypeMap("basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t>>", GeneratorKind = GeneratorKind.CLI)]
public partial class WString : TypeMap
{
public override Type CLISignatureType(TypePrinterContext ctx)
Expand Down
5 changes: 3 additions & 2 deletions tests/Common/Common.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,15 +1020,16 @@ This is a very long string. This is a very long string. This is a very long stri

using (var hasStdWString = new HasStdWString())
{
Assert.That(hasStdWString.TestStdWStringPassedByValue(t), Is.EqualTo(t + "_test"));
Assert.That(hasStdWString.TestStdWString(t), Is.EqualTo(t + "_test"));
hasStdWString.S = t;
Assert.That(hasStdWString.S, Is.EqualTo(t));
Assert.That(hasStdWString.StdWString, Is.EqualTo(t));
Assert.That(hasStdWString.StdWString, Is.EqualTo(t)
Assert.That(hasStdWString.StdWString, Is.EqualTo(t));
Assert.That(hasStdWString.TestStdWString(unicodeString1), Is.EqualTo(unicodeString1 + "_test"));
hasStdWString.S = unicodeString1;
Assert.That(hasStdWString.S, Is.EqualTo(unicodeString1));
Assert.That(hasStdWString.StdWString, Is.EqualTo(unicodeString1)
Assert.That(hasStdWString.StdWString, Is.EqualTo(unicodeString1));
Assert.That(hasStdWString.TestStdWString(unicodeString2), Is.EqualTo(unicodeString2 + "_test"));
hasStdWString.S = unicodeString2;
Assert.That(hasStdWString.S, Is.EqualTo(unicodeString2));
Expand Down

0 comments on commit f1743e9

Please sign in to comment.