Permalink
Browse files

Enabled the tests for std::string.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information...
ddobrev committed Jun 14, 2017
1 parent f729414 commit 422b98a0fd85a60544ed8c382d98123ec217ddb8
@@ -1,6 +1,6 @@
#include <string>
template std::__1::allocator<char>::allocator() noexcept;
template std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::basic_string(const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::value_type*, const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::allocator_type&);
template std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string();
template const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::value_type* std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::c_str() const noexcept;
template __attribute__((visibility("default"))) std::__1::allocator<char>::allocator() noexcept;
template __attribute__((visibility("default"))) std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::basic_string(const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::value_type*, const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::allocator_type&);
template __attribute__((visibility("default"))) std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string();
template __attribute__((visibility("default"))) const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::value_type* std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::c_str() const noexcept;
@@ -1235,6 +1235,15 @@ public unsafe partial struct __Internal
[FieldOffset(0)]
internal global::Std.__1.Tree.__Internal __tree_;
}
public unsafe partial class ValueCompare
{
[StructLayout(LayoutKind.Explicit, Size = 0)]
public partial struct __Internal
{
}
}
}
}
}
@@ -1,6 +1,6 @@
#include <string>
template std::__1::allocator<char>::allocator() noexcept;
template std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::basic_string(const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::value_type*, const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::allocator_type&);
template std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string();
template const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::value_type* std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::c_str() const noexcept;
template __attribute__((visibility("default"))) std::__1::allocator<char>::allocator() noexcept;
template __attribute__((visibility("default"))) std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::basic_string(const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::value_type*, const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::allocator_type&);
template __attribute__((visibility("default"))) std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string();
template __attribute__((visibility("default"))) const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::value_type* std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::c_str() const noexcept;
@@ -1235,6 +1235,15 @@ public unsafe partial struct __Internal
[FieldOffset(0)]
internal global::Std.__1.Tree.__Internal __tree_;
}
public unsafe partial class ValueCompare
{
[StructLayout(LayoutKind.Explicit, Size = 0)]
public partial struct __Internal
{
}
}
}
}
}
@@ -91,9 +91,13 @@ public static bool CheckIgnoreProperty(Property prop)
type = type.Desugar();
type = type.GetFinalPointee() ?? type;
ClassTemplateSpecialization specialization;
if (!type.TryGetDeclaration(out specialization) ||
specialization.IsExplicitlyGenerated)
type.TryGetDeclaration(out specialization);
if (specialization == null || specialization.IsExplicitlyGenerated)
{
if (specialization != null)
addSpecialization(specialization);
return;
}
TypeMap typeMap;
typeMaps.FindTypeMap(specialization, out typeMap);
@@ -4,6 +4,7 @@
using CppSharp.AST;
using CppSharp.AST.Extensions;
using CppSharp.Generators;
using CppSharp.Parser;
namespace CppSharp.Passes
{
@@ -30,7 +31,11 @@ public override bool VisitMethodDecl(Method method)
{
if (method.Namespace is ClassTemplateSpecialization)
{
var exporting = Context.ParserOptions.IsMicrosoftAbi ? "__declspec(dllexport) " : string.Empty;
var exporting = string.Empty;
if (Context.ParserOptions.IsMicrosoftAbi)
exporting = "__declspec(dllexport) ";
else if (TargetTriple.IsMacOS(Context.ParserOptions.TargetTriple))
exporting = "__attribute__((visibility(\"default\"))) ";
WriteLine($"template {exporting}{method.Visit(cppTypePrinter)};");
return true;
}
@@ -74,8 +74,8 @@ public override bool VisitFieldDecl(Field field)
private void CleanSpecializations(Class template)
{
template.Specializations.RemoveAll(s => !s.IsExplicitlyGenerated &&
!specializations.Contains(s) && !internalSpecializations.Contains(s));
template.Specializations.RemoveAll(
s => !specializations.Contains(s) && !internalSpecializations.Contains(s));
foreach (var specialization in template.Specializations.Where(
s => !s.IsExplicitlyGenerated &&
@@ -12,5 +12,12 @@ public static bool IsWindows(string targetTriple)
return parts.Contains("windows") ||
parts.Contains("win32") || parts.Contains("win64");
}
public static bool IsMacOS(string targetTriple)
{
var parts = targetTriple.Split('-');
return parts.Contains("apple") ||
parts.Contains("darwin") || parts.Contains("osx");
}
}
}
@@ -7,5 +7,5 @@ void functionInAnotherUnit()
namespace HasFreeConstant
{
extern const int DLL_API FREE_CONSTANT_IN_NAMESPACE = 5;
// extern const std::string DLL_API STD_STRING_CONSTANT = "test";
extern const std::string DLL_API STD_STRING_CONSTANT = "test";
}
@@ -1,5 +1,5 @@
#include "../Tests.h"
//#include <string>
#include <string>
void DLL_API functionInAnotherUnit();
@@ -20,5 +20,5 @@ class ForwardInOtherUnitButSameModule
namespace HasFreeConstant
{
extern const int DLL_API FREE_CONSTANT_IN_NAMESPACE;
// extern const std::string DLL_API STD_STRING_CONSTANT;
extern const std::string DLL_API STD_STRING_CONSTANT;
}
@@ -543,12 +543,12 @@ public void TestGetEnumFromNativePointer()
}
}
[Test, Ignore("We need symbols for std::string to invoke and auto-compilation of exported templates is not added yet.")]
[Test, Platform(Exclude = "Linux", Reason = "This fails on Linux for no reason at all.")]
public void TestStdStringConstant()
{
//Assert.That(CSharp.HasFreeConstant.AnotherUnit.STD_STRING_CONSTANT, Is.EqualTo("test"));
Assert.That(CSharp.HasFreeConstant.AnotherUnit.STD_STRING_CONSTANT, Is.EqualTo("test"));
// check a second time to ensure it hasn't been improperly freed
//Assert.That(CSharp.HasFreeConstant.AnotherUnit.STD_STRING_CONSTANT, Is.EqualTo("test"));
Assert.That(CSharp.HasFreeConstant.AnotherUnit.STD_STRING_CONSTANT, Is.EqualTo("test"));
}
[Test, Ignore("The completion of types is temporarily suspended because of problems with QtWidgets.")]
@@ -711,7 +711,7 @@ public void TestStaticFields()
Assert.That(Foo.ReadWrite, Is.EqualTo(25));
}
[Test, Ignore("We need symbols for std::string to invoke and auto-compilation of exported templates is not added yet.")]
[Test]
public void TestStdString()
{
// when C++ memory is deleted, it's only marked as free but not immediadely freed
@@ -435,7 +435,15 @@ void DelegateNamespace::f2(void (*)())
{
}
std::string HasStdString::testStdString(std::string s)
HasStdString::HasStdString()
{
}
HasStdString::~HasStdString()
{
}
std::string HasStdString::testStdString(const std::string& s)
{
return s + "_test";
}
@@ -768,7 +768,9 @@ struct DLL_API TestNestedTypes
class DLL_API HasStdString
{
public:
std::string testStdString(std::string s);
HasStdString();
~HasStdString();
std::string testStdString(const std::string& s);
std::string s;
std::string& getStdString();
};

0 comments on commit 422b98a

Please sign in to comment.