diff --git a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Std-symbols.cpp b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Std-symbols.cpp index a924cc9790..513a804659 100644 --- a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Std-symbols.cpp +++ b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Std-symbols.cpp @@ -1,7 +1,12 @@ +#include + +#ifdef _LIBCPP_VERSION + #define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS +#endif + #include -template __attribute__((visibility("default"))) std::basic_string, std::allocator>::basic_string(); -template __attribute__((visibility("default"))) std::basic_string, std::allocator>::~basic_string() noexcept; -template __attribute__((visibility("default"))) std::basic_string, std::allocator>& std::basic_string, std::allocator>::assign(const std::basic_string, std::allocator>::value_type*); -template __attribute__((visibility("default"))) const std::basic_string, std::allocator>::value_type* std::basic_string, std::allocator>::c_str() const noexcept; +template class std::char_traits; +template class std::allocator; +template class std::basic_string, std::allocator>; diff --git a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Std-symbols.cpp b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Std-symbols.cpp index 37da19155c..eed819e70f 100644 --- a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Std-symbols.cpp +++ b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Std-symbols.cpp @@ -1,3 +1,9 @@ +#include + +#ifdef _LIBCPP_VERSION + #define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS +#endif + #include diff --git a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std-symbols.cpp b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std-symbols.cpp index a924cc9790..513a804659 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std-symbols.cpp +++ b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std-symbols.cpp @@ -1,7 +1,12 @@ +#include + +#ifdef _LIBCPP_VERSION + #define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS +#endif + #include -template __attribute__((visibility("default"))) std::basic_string, std::allocator>::basic_string(); -template __attribute__((visibility("default"))) std::basic_string, std::allocator>::~basic_string() noexcept; -template __attribute__((visibility("default"))) std::basic_string, std::allocator>& std::basic_string, std::allocator>::assign(const std::basic_string, std::allocator>::value_type*); -template __attribute__((visibility("default"))) const std::basic_string, std::allocator>::value_type* std::basic_string, std::allocator>::c_str() const noexcept; +template class std::char_traits; +template class std::allocator; +template class std::basic_string, std::allocator>; diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/Std-symbols.cpp b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/Std-symbols.cpp index 41119deaa9..513a804659 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/Std-symbols.cpp +++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/Std-symbols.cpp @@ -1,3 +1,9 @@ +#include + +#ifdef _LIBCPP_VERSION + #define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS +#endif + #include diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Std-symbols.cpp b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Std-symbols.cpp index 41119deaa9..513a804659 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Std-symbols.cpp +++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Std-symbols.cpp @@ -1,3 +1,9 @@ +#include + +#ifdef _LIBCPP_VERSION + #define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS +#endif + #include diff --git a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/Std-symbols.cpp b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/Std-symbols.cpp index 37da19155c..eed819e70f 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/Std-symbols.cpp +++ b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/Std-symbols.cpp @@ -1,3 +1,9 @@ +#include + +#ifdef _LIBCPP_VERSION + #define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS +#endif + #include diff --git a/src/Generator/Passes/SymbolsCodeGenerator.cs b/src/Generator/Passes/SymbolsCodeGenerator.cs index 12b723fad6..5bf507bb7a 100644 --- a/src/Generator/Passes/SymbolsCodeGenerator.cs +++ b/src/Generator/Passes/SymbolsCodeGenerator.cs @@ -5,7 +5,6 @@ using CppSharp.AST; using CppSharp.AST.Extensions; using CppSharp.Generators; -using CppSharp.Parser; namespace CppSharp.Passes { @@ -20,6 +19,16 @@ public SymbolsCodeGenerator(BindingContext context, IEnumerable public override void Process() { + WriteLine("#include "); + NewLine(); + + // check if we use the Clang standard C++ lib and if so, + // make sure we export all symbols marked with _LIBCPP_INLINE_VISIBILITY + WriteLine("#ifdef _LIBCPP_VERSION"); + WriteLine(" #define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); + WriteLine("#endif"); + NewLine(); + if (TranslationUnit.Module == Options.SystemModule) WriteLine("#include "); else @@ -62,12 +71,8 @@ public override bool VisitFunctionDecl(Function function) private string GetExporting() { - var exporting = string.Empty; - if (Context.ParserOptions.IsMicrosoftAbi) - exporting = "__declspec(dllexport) "; - else if (TargetTriple.IsMacOS(Context.ParserOptions.TargetTriple)) - exporting = "__attribute__((visibility(\"default\"))) "; - return exporting; + return Context.ParserOptions.IsMicrosoftAbi ? + "__declspec(dllexport) " : string.Empty; } private string GetWrapper(Module module) diff --git a/src/Generator/Types/Std/Stdlib.cs b/src/Generator/Types/Std/Stdlib.cs index dfb7fabb62..e89f7e69ae 100644 --- a/src/Generator/Types/Std/Stdlib.cs +++ b/src/Generator/Types/Std/Stdlib.cs @@ -137,7 +137,7 @@ public override void CSharpMarshalToNative(CSharpMarshalContext ctx) ctx.Before.WriteLine($@"{qualifiedBasicString}Extensions.{ assign.Name}({varBasicString}, {ctx.Parameter.Name});"); ctx.Return.Write($"{varBasicString}.{Helpers.InstanceIdentifier}"); - if (!type.IsAddress()) + if (!type.IsPointer()) ctx.Cleanup.WriteLine($"{varBasicString}.Dispose(false);"); } }