From 76d6795bbf2d2535e335c21ec07046ae865efbaf Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Sat, 18 Sep 2021 23:14:03 +0300 Subject: [PATCH] Add built-in compilation of extra symbols Fixes https://github.com/mono/CppSharp/issues/1456 and https://github.com/mono/CppSharp/issues/1253. Signed-off-by: Dimitar Dobrev --- build/LLVM.lua | 14 +- src/AST/TargetTriple.cs | 3 +- src/CppParser/Bindings/CLI/CppParser.cpp | 34 +- src/CppParser/Bindings/CLI/CppParser.h | 6 +- .../CppSharp.CppParser-symbols.cpp | 1 - .../CppSharp.CppParser.cs | 39 ++- .../CppSharp.CppParser-symbols.cpp | 1 - .../i686-pc-win32-msvc/CppSharp.CppParser.cs | 39 ++- .../CppSharp.CppParser-symbols.cpp | 1 - .../CppSharp.CppParser.cs | 39 ++- .../CppSharp.CppParser-symbols.cpp | 1 - .../CppSharp.CppParser.cs | 39 ++- .../CppSharp.CppParser-symbols.cpp | 1 - .../x86_64-linux-gnu/CppSharp.CppParser.cs | 39 ++- .../CppSharp.CppParser-symbols.cpp | 1 - .../CppSharp.CppParser.cs | 39 ++- src/CppParser/CppParser.cpp | 66 +++- src/CppParser/CppParser.h | 5 +- src/CppParser/Link.cpp | 187 +++++++++++ src/CppParser/Parser.cpp | 59 ++++ src/CppParser/Parser.h | 11 +- src/Generator.Tests/AST/TestAST.cs | 21 +- src/Generator.Tests/ASTTestFixture.cs | 47 ++- src/Generator.Tests/GeneratorTest.cs | 4 +- src/Generator.Tests/Passes/TestPasses.cs | 14 +- src/Generator/BindingContext.cs | 2 + src/Generator/Driver.cs | 3 +- src/Generator/Passes/GenerateSymbolsPass.cs | 77 ++++- src/Generator/Passes/SymbolsCodeGenerator.cs | 4 +- tests/CSharp/CSharp.cpp | 296 +----------------- tests/CSharp/CSharp.h | 81 +---- tests/CSharp/CSharpTemplates.cpp | 60 ---- tests/CSharp/CSharpTemplates.h | 62 +--- tests/Common/Common.cpp | 290 ++--------------- tests/Common/Common.h | 77 +---- tests/Encodings/Encodings.cpp | 8 - tests/Encodings/Encodings.h | 3 - tests/NamespacesBase/NamespacesBase.cpp | 8 - tests/NamespacesBase/NamespacesBase.h | 10 - .../NamespacesDerived.Gen.cs | 2 +- tests/NamespacesDerived/NamespacesDerived.cpp | 24 -- tests/NamespacesDerived/NamespacesDerived.h | 7 - tests/Test.Generator.props | 6 - tests/VTables/VTables.cpp | 20 -- tests/VTables/VTables.h | 5 - 45 files changed, 734 insertions(+), 1022 deletions(-) create mode 100644 src/CppParser/Link.cpp diff --git a/build/LLVM.lua b/build/LLVM.lua index a392ff15..3de5dc4d 100644 --- a/build/LLVM.lua +++ b/build/LLVM.lua @@ -42,6 +42,7 @@ function SetupLLVMIncludes() includedirs { path.join(LLVMRootDirDebug, "include"), + path.join(LLVMRootDirDebug, "lld/include"), path.join(LLVMRootDirDebug, "clang/include"), path.join(LLVMRootDirDebug, "clang/lib"), path.join(LLVMRootDirDebug, "build/include"), @@ -52,6 +53,7 @@ function SetupLLVMIncludes() includedirs { path.join(LLVMRootDirRelease, "include"), + path.join(LLVMRootDirRelease, "lld/include"), path.join(LLVMRootDirRelease, "clang/include"), path.join(LLVMRootDirRelease, "clang/lib"), path.join(LLVMRootDirRelease, "build/include"), @@ -62,6 +64,7 @@ function SetupLLVMIncludes() includedirs { path.join(LLVMRootDir, "include"), + path.join(LLVMRootDir, "lld/include"), path.join(LLVMRootDir, "clang/include"), path.join(LLVMRootDir, "clang/lib"), path.join(LLVMBuildDir, "include"), @@ -195,7 +198,16 @@ function SetupLLVMLibs() "LLVMDebugInfoMSF", "LLVMBinaryFormat", "LLVMSupport", - "LLVMDemangle" + "LLVMDemangle", + "lldCommon", + "lldCore", + "lldCOFF", + "lldELF", + "lldDriver", + "lldReaderWriter", + "lldYAML", + "lldMachO", + "lldMachOOld" } filter(c) diff --git a/src/AST/TargetTriple.cs b/src/AST/TargetTriple.cs index 11df60ef..fc577320 100644 --- a/src/AST/TargetTriple.cs +++ b/src/AST/TargetTriple.cs @@ -10,7 +10,8 @@ namespace CppSharp.AST { var parts = targetTriple.Split('-'); return parts.Contains("windows") || - parts.Contains("win32") || parts.Contains("win64"); + parts.Contains("win32") || parts.Contains("win64") || + parts.Any(p => p.StartsWith("mingw")); } public static bool IsMacOS(this string targetTriple) diff --git a/src/CppParser/Bindings/CLI/CppParser.cpp b/src/CppParser/Bindings/CLI/CppParser.cpp index 9bbc3342..fb2d398e 100644 --- a/src/CppParser/Bindings/CLI/CppParser.cpp +++ b/src/CppParser/Bindings/CLI/CppParser.cpp @@ -543,10 +543,21 @@ CppSharp::Parser::LinkerOptions::~LinkerOptions() delete NativePtr; } -CppSharp::Parser::LinkerOptions::LinkerOptions() +CppSharp::Parser::LinkerOptions::LinkerOptions(::System::String^ Triple) { __ownsNativeInstance = true; - NativePtr = new struct ::CppSharp::CppParser::LinkerOptions(); + auto ___arg0 = clix::marshalString(Triple); + auto __arg0 = ___arg0.c_str(); + NativePtr = new struct ::CppSharp::CppParser::LinkerOptions(__arg0); +} + +CppSharp::Parser::LinkerOptions::LinkerOptions(CppSharp::Parser::LinkerOptions^ Other) +{ + __ownsNativeInstance = true; + if (ReferenceEquals(Other, nullptr)) + throw gcnew ::System::ArgumentNullException("Other", "Cannot be null because it is a C++ reference (&)."); + auto &__arg0 = *(struct ::CppSharp::CppParser::LinkerOptions*)Other->NativePtr; + NativePtr = new struct ::CppSharp::CppParser::LinkerOptions(__arg0); } ::System::String^ CppSharp::Parser::LinkerOptions::GetArguments(unsigned int i) @@ -606,15 +617,6 @@ void CppSharp::Parser::LinkerOptions::ClearLibraries() ((struct ::CppSharp::CppParser::LinkerOptions*)NativePtr)->clearLibraries(); } -CppSharp::Parser::LinkerOptions::LinkerOptions(CppSharp::Parser::LinkerOptions^ _0) -{ - __ownsNativeInstance = true; - if (ReferenceEquals(_0, nullptr)) - throw gcnew ::System::ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); - auto &__arg0 = *(struct ::CppSharp::CppParser::LinkerOptions*)_0->NativePtr; - NativePtr = new struct ::CppSharp::CppParser::LinkerOptions(__arg0); -} - ::System::IntPtr CppSharp::Parser::LinkerOptions::__Instance::get() { return ::System::IntPtr(NativePtr); @@ -1030,6 +1032,16 @@ CppSharp::Parser::ParserResult^ CppSharp::Parser::ClangParser::ParseLibrary(CppS return (__ret == nullptr) ? nullptr : gcnew ::CppSharp::Parser::ParserResult((struct ::CppSharp::CppParser::ParserResult*)__ret); } +CppSharp::Parser::ParserResult^ CppSharp::Parser::ClangParser::Build(CppSharp::Parser::CppParserOptions^ Opts, CppSharp::Parser::LinkerOptions^ LinkerOptions, ::System::String^ File, bool Last) +{ + auto __arg0 = (struct ::CppSharp::CppParser::CppParserOptions*)Opts->NativePtr; + auto __arg1 = (struct ::CppSharp::CppParser::LinkerOptions*)LinkerOptions->NativePtr; + auto __arg2 = clix::marshalString(File); + auto __ret = ::CppSharp::CppParser::ClangParser::Build(__arg0, __arg1, __arg2, Last); + if (__ret == nullptr) return nullptr; + return (__ret == nullptr) ? nullptr : gcnew ::CppSharp::Parser::ParserResult((struct ::CppSharp::CppParser::ParserResult*)__ret); +} + CppSharp::Parser::ClangParser::ClangParser() { __ownsNativeInstance = true; diff --git a/src/CppParser/Bindings/CLI/CppParser.h b/src/CppParser/Bindings/CLI/CppParser.h index f2281727..db06432c 100644 --- a/src/CppParser/Bindings/CLI/CppParser.h +++ b/src/CppParser/Bindings/CLI/CppParser.h @@ -291,9 +291,9 @@ namespace CppSharp LinkerOptions(struct ::CppSharp::CppParser::LinkerOptions* native, bool ownNativeInstance); static LinkerOptions^ __CreateInstance(::System::IntPtr native); static LinkerOptions^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance); - LinkerOptions(); + LinkerOptions(::System::String^ Triple); - LinkerOptions(CppSharp::Parser::LinkerOptions^ _0); + LinkerOptions(CppSharp::Parser::LinkerOptions^ Other); ~LinkerOptions(); @@ -506,6 +506,8 @@ namespace CppSharp static CppSharp::Parser::ParserResult^ ParseLibrary(CppSharp::Parser::LinkerOptions^ Opts); + static CppSharp::Parser::ParserResult^ Build(CppSharp::Parser::CppParserOptions^ Opts, CppSharp::Parser::LinkerOptions^ LinkerOptions, ::System::String^ File, bool Last); + protected: bool __ownsNativeInstance; diff --git a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser-symbols.cpp b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser-symbols.cpp index 15c63c71..5d383a06 100644 --- a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser-symbols.cpp +++ b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser-symbols.cpp @@ -372,7 +372,6 @@ extern "C" void c__N_CppSharp_N_CppParser_S_ParserTargetInfo_ParserTargetInfo___ struct CppSharp::CppParser::ParserTargetInfo& (CppSharp::CppParser::ParserTargetInfo::*_239)(const struct CppSharp::CppParser::ParserTargetInfo&) = &CppSharp::CppParser::ParserTargetInfo::operator=; extern "C" void c__N_CppSharp_N_CppParser_S_CppParserOptions_CppParserOptions___1__N_CppSharp_N_CppParser_S_CppParserOptions(void* __instance, const CppSharp::CppParser::CppParserOptions& _0) { ::new (__instance) CppSharp::CppParser::CppParserOptions(_0); } struct CppSharp::CppParser::CppParserOptions& (CppSharp::CppParser::CppParserOptions::*_240)(const struct CppSharp::CppParser::CppParserOptions&) = &CppSharp::CppParser::CppParserOptions::operator=; -extern "C" void c__N_CppSharp_N_CppParser_S_LinkerOptions_LinkerOptions___1__N_CppSharp_N_CppParser_S_LinkerOptions(void* __instance, const CppSharp::CppParser::LinkerOptions& _0) { ::new (__instance) CppSharp::CppParser::LinkerOptions(_0); } struct CppSharp::CppParser::LinkerOptions& (CppSharp::CppParser::LinkerOptions::*_241)(const struct CppSharp::CppParser::LinkerOptions&) = &CppSharp::CppParser::LinkerOptions::operator=; struct CppSharp::CppParser::ParserDiagnostic& (CppSharp::CppParser::ParserDiagnostic::*_242)(const struct CppSharp::CppParser::ParserDiagnostic&) = &CppSharp::CppParser::ParserDiagnostic::operator=; struct CppSharp::CppParser::ParserResult& (CppSharp::CppParser::ParserResult::*_243)(const struct CppSharp::CppParser::ParserResult&) = &CppSharp::CppParser::ParserResult::operator=; diff --git a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs index 83441d97..cdcb76a0 100644 --- a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs @@ -40011,11 +40011,11 @@ namespace CppSharp internal global::Std.Vector.__Internalc__N_std_N___1_S_vector____N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C___N_std_N___1_S_allocator__S0_ LibraryDirs; internal global::Std.Vector.__Internalc__N_std_N___1_S_vector____N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C___N_std_N___1_S_allocator__S0_ Libraries; - [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsC2Ev", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void ctor(__IntPtr __instance); + [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsC2EPKc", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void ctor(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string Triple); [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsC2ERKS1_", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void cctor(__IntPtr __instance, __IntPtr _0); + internal static extern void cctor(__IntPtr __instance, __IntPtr Other); [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsD2Ev", CallingConvention = __CallingConvention.Cdecl)] internal static extern void dtor(__IntPtr __instance); @@ -40106,22 +40106,22 @@ namespace CppSharp __Instance = new __IntPtr(native); } - public LinkerOptions() + public LinkerOptions(string Triple) { __Instance = Marshal.AllocHGlobal(sizeof(global::CppSharp.Parser.LinkerOptions.__Internal)); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - __Internal.ctor(__Instance); + __Internal.ctor(__Instance, Triple); } - public LinkerOptions(global::CppSharp.Parser.LinkerOptions _0) + public LinkerOptions(global::CppSharp.Parser.LinkerOptions Other) { __Instance = Marshal.AllocHGlobal(sizeof(global::CppSharp.Parser.LinkerOptions.__Internal)); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - if (ReferenceEquals(_0, null)) - throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); - var __arg0 = _0.__Instance; + if (ReferenceEquals(Other, null)) + throw new global::System.ArgumentNullException("Other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = Other.__Instance; __Internal.cctor(__Instance, __arg0); } @@ -40193,6 +40193,11 @@ namespace CppSharp __Internal.ClearLibraries(__Instance); } + public static implicit operator global::CppSharp.Parser.LinkerOptions(string Triple) + { + return new global::CppSharp.Parser.LinkerOptions(Triple); + } + public uint ArgumentsCount { get @@ -40632,6 +40637,9 @@ namespace CppSharp [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser11ClangParser12ParseLibraryEPNS0_13LinkerOptionsE", CallingConvention = __CallingConvention.Cdecl)] internal static extern __IntPtr ParseLibrary(__IntPtr Opts); + + [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser11ClangParser5BuildEPNS0_16CppParserOptionsEPKNS0_13LinkerOptionsERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEb", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr Build(__IntPtr Opts, __IntPtr LinkerOptions, __IntPtr File, bool Last); } public __IntPtr __Instance { get; protected set; } @@ -40731,6 +40739,19 @@ namespace CppSharp var __result0 = global::CppSharp.Parser.ParserResult.__GetOrCreateInstance(__ret, false); return __result0; } + + public static global::CppSharp.Parser.ParserResult Build(global::CppSharp.Parser.CppParserOptions Opts, global::CppSharp.Parser.LinkerOptions LinkerOptions, string File, bool Last) + { + var __arg0 = Opts is null ? __IntPtr.Zero : Opts.__Instance; + var __arg1 = LinkerOptions is null ? __IntPtr.Zero : LinkerOptions.__Instance; + var __basicString2 = new global::Std.BasicString, global::Std.Allocator>(); + global::Std.BasicStringExtensions.Assign(__basicString2, File); + var __arg2 = __basicString2.__Instance; + var __ret = __Internal.Build(__arg0, __arg1, __arg2, Last); + __basicString2.Dispose(); + var __result0 = global::CppSharp.Parser.ParserResult.__GetOrCreateInstance(__ret, false); + return __result0; + } } } } diff --git a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser-symbols.cpp b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser-symbols.cpp index c1e47a1a..14cb12bb 100644 --- a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser-symbols.cpp +++ b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser-symbols.cpp @@ -372,7 +372,6 @@ extern "C" __declspec(dllexport) void c__N_CppSharp_N_CppParser_S_ParserTargetIn struct CppSharp::CppParser::ParserTargetInfo& (CppSharp::CppParser::ParserTargetInfo::*_239)(const struct CppSharp::CppParser::ParserTargetInfo&) = &CppSharp::CppParser::ParserTargetInfo::operator=; extern "C" __declspec(dllexport) void c__N_CppSharp_N_CppParser_S_CppParserOptions_CppParserOptions___1__N_CppSharp_N_CppParser_S_CppParserOptions(void* __instance, const CppSharp::CppParser::CppParserOptions& _0) { ::new (__instance) CppSharp::CppParser::CppParserOptions(_0); } struct CppSharp::CppParser::CppParserOptions& (CppSharp::CppParser::CppParserOptions::*_240)(const struct CppSharp::CppParser::CppParserOptions&) = &CppSharp::CppParser::CppParserOptions::operator=; -extern "C" __declspec(dllexport) void c__N_CppSharp_N_CppParser_S_LinkerOptions_LinkerOptions___1__N_CppSharp_N_CppParser_S_LinkerOptions(void* __instance, const CppSharp::CppParser::LinkerOptions& _0) { ::new (__instance) CppSharp::CppParser::LinkerOptions(_0); } struct CppSharp::CppParser::LinkerOptions& (CppSharp::CppParser::LinkerOptions::*_241)(const struct CppSharp::CppParser::LinkerOptions&) = &CppSharp::CppParser::LinkerOptions::operator=; struct CppSharp::CppParser::ParserDiagnostic& (CppSharp::CppParser::ParserDiagnostic::*_242)(const struct CppSharp::CppParser::ParserDiagnostic&) = &CppSharp::CppParser::ParserDiagnostic::operator=; struct CppSharp::CppParser::ParserResult& (CppSharp::CppParser::ParserResult::*_243)(const struct CppSharp::CppParser::ParserResult&) = &CppSharp::CppParser::ParserResult::operator=; diff --git a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs index 3702f83d..4498b2c3 100644 --- a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs @@ -40022,11 +40022,11 @@ namespace CppSharp internal global::Std.Vector.__Internalc__N_std_S_vector____N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C___N_std_S_allocator__S0_ LibraryDirs; internal global::Std.Vector.__Internalc__N_std_S_vector____N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C___N_std_S_allocator__S0_ Libraries; - [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "??0LinkerOptions@CppParser@CppSharp@@QAE@XZ", CallingConvention = __CallingConvention.ThisCall)] - internal static extern __IntPtr ctor(__IntPtr __instance); + [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "??0LinkerOptions@CppParser@CppSharp@@QAE@PBD@Z", CallingConvention = __CallingConvention.ThisCall)] + internal static extern __IntPtr ctor(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string Triple); [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "??0LinkerOptions@CppParser@CppSharp@@QAE@ABU012@@Z", CallingConvention = __CallingConvention.ThisCall)] - internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0); + internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr Other); [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "??1LinkerOptions@CppParser@CppSharp@@QAE@XZ", CallingConvention = __CallingConvention.ThisCall)] internal static extern void dtor(__IntPtr __instance); @@ -40117,22 +40117,22 @@ namespace CppSharp __Instance = new __IntPtr(native); } - public LinkerOptions() + public LinkerOptions(string Triple) { __Instance = Marshal.AllocHGlobal(sizeof(global::CppSharp.Parser.LinkerOptions.__Internal)); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - __Internal.ctor(__Instance); + __Internal.ctor(__Instance, Triple); } - public LinkerOptions(global::CppSharp.Parser.LinkerOptions _0) + public LinkerOptions(global::CppSharp.Parser.LinkerOptions Other) { __Instance = Marshal.AllocHGlobal(sizeof(global::CppSharp.Parser.LinkerOptions.__Internal)); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - if (ReferenceEquals(_0, null)) - throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); - var __arg0 = _0.__Instance; + if (ReferenceEquals(Other, null)) + throw new global::System.ArgumentNullException("Other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = Other.__Instance; __Internal.cctor(__Instance, __arg0); } @@ -40204,6 +40204,11 @@ namespace CppSharp __Internal.ClearLibraries(__Instance); } + public static implicit operator global::CppSharp.Parser.LinkerOptions(string Triple) + { + return new global::CppSharp.Parser.LinkerOptions(Triple); + } + public uint ArgumentsCount { get @@ -40643,6 +40648,9 @@ namespace CppSharp [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "?ParseLibrary@ClangParser@CppParser@CppSharp@@SAPAUParserResult@23@PAULinkerOptions@23@@Z", CallingConvention = __CallingConvention.Cdecl)] internal static extern __IntPtr ParseLibrary(__IntPtr Opts); + + [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "?Build@ClangParser@CppParser@CppSharp@@SAPAUParserResult@23@PAUCppParserOptions@23@PBULinkerOptions@23@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N@Z", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr Build(__IntPtr Opts, __IntPtr LinkerOptions, __IntPtr File, bool Last); } public __IntPtr __Instance { get; protected set; } @@ -40742,6 +40750,19 @@ namespace CppSharp var __result0 = global::CppSharp.Parser.ParserResult.__GetOrCreateInstance(__ret, false); return __result0; } + + public static global::CppSharp.Parser.ParserResult Build(global::CppSharp.Parser.CppParserOptions Opts, global::CppSharp.Parser.LinkerOptions LinkerOptions, string File, bool Last) + { + var __arg0 = Opts is null ? __IntPtr.Zero : Opts.__Instance; + var __arg1 = LinkerOptions is null ? __IntPtr.Zero : LinkerOptions.__Instance; + var __basicString2 = new global::Std.BasicString, global::Std.Allocator>(); + global::Std.BasicStringExtensions.Assign(__basicString2, File); + var __arg2 = __basicString2.__Instance; + var __ret = __Internal.Build(__arg0, __arg1, __arg2, Last); + __basicString2.Dispose(); + var __result0 = global::CppSharp.Parser.ParserResult.__GetOrCreateInstance(__ret, false); + return __result0; + } } } } diff --git a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser-symbols.cpp b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser-symbols.cpp index 15c63c71..5d383a06 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser-symbols.cpp +++ b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser-symbols.cpp @@ -372,7 +372,6 @@ extern "C" void c__N_CppSharp_N_CppParser_S_ParserTargetInfo_ParserTargetInfo___ struct CppSharp::CppParser::ParserTargetInfo& (CppSharp::CppParser::ParserTargetInfo::*_239)(const struct CppSharp::CppParser::ParserTargetInfo&) = &CppSharp::CppParser::ParserTargetInfo::operator=; extern "C" void c__N_CppSharp_N_CppParser_S_CppParserOptions_CppParserOptions___1__N_CppSharp_N_CppParser_S_CppParserOptions(void* __instance, const CppSharp::CppParser::CppParserOptions& _0) { ::new (__instance) CppSharp::CppParser::CppParserOptions(_0); } struct CppSharp::CppParser::CppParserOptions& (CppSharp::CppParser::CppParserOptions::*_240)(const struct CppSharp::CppParser::CppParserOptions&) = &CppSharp::CppParser::CppParserOptions::operator=; -extern "C" void c__N_CppSharp_N_CppParser_S_LinkerOptions_LinkerOptions___1__N_CppSharp_N_CppParser_S_LinkerOptions(void* __instance, const CppSharp::CppParser::LinkerOptions& _0) { ::new (__instance) CppSharp::CppParser::LinkerOptions(_0); } struct CppSharp::CppParser::LinkerOptions& (CppSharp::CppParser::LinkerOptions::*_241)(const struct CppSharp::CppParser::LinkerOptions&) = &CppSharp::CppParser::LinkerOptions::operator=; struct CppSharp::CppParser::ParserDiagnostic& (CppSharp::CppParser::ParserDiagnostic::*_242)(const struct CppSharp::CppParser::ParserDiagnostic&) = &CppSharp::CppParser::ParserDiagnostic::operator=; struct CppSharp::CppParser::ParserResult& (CppSharp::CppParser::ParserResult::*_243)(const struct CppSharp::CppParser::ParserResult&) = &CppSharp::CppParser::ParserResult::operator=; diff --git a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs index ead86835..ab4a5bb6 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs @@ -40010,11 +40010,11 @@ namespace CppSharp internal global::Std.Vector.__Internalc__N_std_N___1_S_vector____N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C___N_std_N___1_S_allocator__S0_ LibraryDirs; internal global::Std.Vector.__Internalc__N_std_N___1_S_vector____N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C___N_std_N___1_S_allocator__S0_ Libraries; - [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsC2Ev", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void ctor(__IntPtr __instance); + [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsC2EPKc", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void ctor(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string Triple); [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsC2ERKS1_", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void cctor(__IntPtr __instance, __IntPtr _0); + internal static extern void cctor(__IntPtr __instance, __IntPtr Other); [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsD2Ev", CallingConvention = __CallingConvention.Cdecl)] internal static extern void dtor(__IntPtr __instance); @@ -40105,22 +40105,22 @@ namespace CppSharp __Instance = new __IntPtr(native); } - public LinkerOptions() + public LinkerOptions(string Triple) { __Instance = Marshal.AllocHGlobal(sizeof(global::CppSharp.Parser.LinkerOptions.__Internal)); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - __Internal.ctor(__Instance); + __Internal.ctor(__Instance, Triple); } - public LinkerOptions(global::CppSharp.Parser.LinkerOptions _0) + public LinkerOptions(global::CppSharp.Parser.LinkerOptions Other) { __Instance = Marshal.AllocHGlobal(sizeof(global::CppSharp.Parser.LinkerOptions.__Internal)); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - if (ReferenceEquals(_0, null)) - throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); - var __arg0 = _0.__Instance; + if (ReferenceEquals(Other, null)) + throw new global::System.ArgumentNullException("Other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = Other.__Instance; __Internal.cctor(__Instance, __arg0); } @@ -40192,6 +40192,11 @@ namespace CppSharp __Internal.ClearLibraries(__Instance); } + public static implicit operator global::CppSharp.Parser.LinkerOptions(string Triple) + { + return new global::CppSharp.Parser.LinkerOptions(Triple); + } + public uint ArgumentsCount { get @@ -40631,6 +40636,9 @@ namespace CppSharp [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser11ClangParser12ParseLibraryEPNS0_13LinkerOptionsE", CallingConvention = __CallingConvention.Cdecl)] internal static extern __IntPtr ParseLibrary(__IntPtr Opts); + + [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser11ClangParser5BuildEPNS0_16CppParserOptionsEPKNS0_13LinkerOptionsERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEb", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr Build(__IntPtr Opts, __IntPtr LinkerOptions, __IntPtr File, bool Last); } public __IntPtr __Instance { get; protected set; } @@ -40730,6 +40738,19 @@ namespace CppSharp var __result0 = global::CppSharp.Parser.ParserResult.__GetOrCreateInstance(__ret, false); return __result0; } + + public static global::CppSharp.Parser.ParserResult Build(global::CppSharp.Parser.CppParserOptions Opts, global::CppSharp.Parser.LinkerOptions LinkerOptions, string File, bool Last) + { + var __arg0 = Opts is null ? __IntPtr.Zero : Opts.__Instance; + var __arg1 = LinkerOptions is null ? __IntPtr.Zero : LinkerOptions.__Instance; + var __basicString2 = new global::Std.BasicString, global::Std.Allocator>(); + global::Std.BasicStringExtensions.Assign(__basicString2, File); + var __arg2 = __basicString2.__Instance; + var __ret = __Internal.Build(__arg0, __arg1, __arg2, Last); + __basicString2.Dispose(); + var __result0 = global::CppSharp.Parser.ParserResult.__GetOrCreateInstance(__ret, false); + return __result0; + } } } } diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser-symbols.cpp b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser-symbols.cpp index 15c63c71..5d383a06 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser-symbols.cpp +++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser-symbols.cpp @@ -372,7 +372,6 @@ extern "C" void c__N_CppSharp_N_CppParser_S_ParserTargetInfo_ParserTargetInfo___ struct CppSharp::CppParser::ParserTargetInfo& (CppSharp::CppParser::ParserTargetInfo::*_239)(const struct CppSharp::CppParser::ParserTargetInfo&) = &CppSharp::CppParser::ParserTargetInfo::operator=; extern "C" void c__N_CppSharp_N_CppParser_S_CppParserOptions_CppParserOptions___1__N_CppSharp_N_CppParser_S_CppParserOptions(void* __instance, const CppSharp::CppParser::CppParserOptions& _0) { ::new (__instance) CppSharp::CppParser::CppParserOptions(_0); } struct CppSharp::CppParser::CppParserOptions& (CppSharp::CppParser::CppParserOptions::*_240)(const struct CppSharp::CppParser::CppParserOptions&) = &CppSharp::CppParser::CppParserOptions::operator=; -extern "C" void c__N_CppSharp_N_CppParser_S_LinkerOptions_LinkerOptions___1__N_CppSharp_N_CppParser_S_LinkerOptions(void* __instance, const CppSharp::CppParser::LinkerOptions& _0) { ::new (__instance) CppSharp::CppParser::LinkerOptions(_0); } struct CppSharp::CppParser::LinkerOptions& (CppSharp::CppParser::LinkerOptions::*_241)(const struct CppSharp::CppParser::LinkerOptions&) = &CppSharp::CppParser::LinkerOptions::operator=; struct CppSharp::CppParser::ParserDiagnostic& (CppSharp::CppParser::ParserDiagnostic::*_242)(const struct CppSharp::CppParser::ParserDiagnostic&) = &CppSharp::CppParser::ParserDiagnostic::operator=; struct CppSharp::CppParser::ParserResult& (CppSharp::CppParser::ParserResult::*_243)(const struct CppSharp::CppParser::ParserResult&) = &CppSharp::CppParser::ParserResult::operator=; diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs index 40963315..d7ab7caa 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs @@ -40010,11 +40010,11 @@ namespace CppSharp internal global::Std.Vector.__Internalc__N_std_S_vector____N_std_N___cxx11_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C___N_std_S_allocator__S0_ LibraryDirs; internal global::Std.Vector.__Internalc__N_std_S_vector____N_std_N___cxx11_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C___N_std_S_allocator__S0_ Libraries; - [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsC2Ev", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void ctor(__IntPtr __instance); + [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsC2EPKc", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void ctor(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string Triple); [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsC2ERKS1_", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void cctor(__IntPtr __instance, __IntPtr _0); + internal static extern void cctor(__IntPtr __instance, __IntPtr Other); [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsD2Ev", CallingConvention = __CallingConvention.Cdecl)] internal static extern void dtor(__IntPtr __instance); @@ -40105,22 +40105,22 @@ namespace CppSharp __Instance = new __IntPtr(native); } - public LinkerOptions() + public LinkerOptions(string Triple) { __Instance = Marshal.AllocHGlobal(sizeof(global::CppSharp.Parser.LinkerOptions.__Internal)); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - __Internal.ctor(__Instance); + __Internal.ctor(__Instance, Triple); } - public LinkerOptions(global::CppSharp.Parser.LinkerOptions _0) + public LinkerOptions(global::CppSharp.Parser.LinkerOptions Other) { __Instance = Marshal.AllocHGlobal(sizeof(global::CppSharp.Parser.LinkerOptions.__Internal)); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - if (ReferenceEquals(_0, null)) - throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); - var __arg0 = _0.__Instance; + if (ReferenceEquals(Other, null)) + throw new global::System.ArgumentNullException("Other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = Other.__Instance; __Internal.cctor(__Instance, __arg0); } @@ -40192,6 +40192,11 @@ namespace CppSharp __Internal.ClearLibraries(__Instance); } + public static implicit operator global::CppSharp.Parser.LinkerOptions(string Triple) + { + return new global::CppSharp.Parser.LinkerOptions(Triple); + } + public uint ArgumentsCount { get @@ -40631,6 +40636,9 @@ namespace CppSharp [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser11ClangParser12ParseLibraryEPNS0_13LinkerOptionsE", CallingConvention = __CallingConvention.Cdecl)] internal static extern __IntPtr ParseLibrary(__IntPtr Opts); + + [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser11ClangParser5BuildEPNS0_16CppParserOptionsEPKNS0_13LinkerOptionsERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr Build(__IntPtr Opts, __IntPtr LinkerOptions, __IntPtr File, bool Last); } public __IntPtr __Instance { get; protected set; } @@ -40730,6 +40738,19 @@ namespace CppSharp var __result0 = global::CppSharp.Parser.ParserResult.__GetOrCreateInstance(__ret, false); return __result0; } + + public static global::CppSharp.Parser.ParserResult Build(global::CppSharp.Parser.CppParserOptions Opts, global::CppSharp.Parser.LinkerOptions LinkerOptions, string File, bool Last) + { + var __arg0 = Opts is null ? __IntPtr.Zero : Opts.__Instance; + var __arg1 = LinkerOptions is null ? __IntPtr.Zero : LinkerOptions.__Instance; + var __basicString2 = new global::Std.BasicString, global::Std.Allocator>(); + global::Std.BasicStringExtensions.Assign(__basicString2, File); + var __arg2 = __basicString2.__Instance; + var __ret = __Internal.Build(__arg0, __arg1, __arg2, Last); + __basicString2.Dispose(); + var __result0 = global::CppSharp.Parser.ParserResult.__GetOrCreateInstance(__ret, false); + return __result0; + } } } } diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser-symbols.cpp b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser-symbols.cpp index 15c63c71..5d383a06 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser-symbols.cpp +++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser-symbols.cpp @@ -372,7 +372,6 @@ extern "C" void c__N_CppSharp_N_CppParser_S_ParserTargetInfo_ParserTargetInfo___ struct CppSharp::CppParser::ParserTargetInfo& (CppSharp::CppParser::ParserTargetInfo::*_239)(const struct CppSharp::CppParser::ParserTargetInfo&) = &CppSharp::CppParser::ParserTargetInfo::operator=; extern "C" void c__N_CppSharp_N_CppParser_S_CppParserOptions_CppParserOptions___1__N_CppSharp_N_CppParser_S_CppParserOptions(void* __instance, const CppSharp::CppParser::CppParserOptions& _0) { ::new (__instance) CppSharp::CppParser::CppParserOptions(_0); } struct CppSharp::CppParser::CppParserOptions& (CppSharp::CppParser::CppParserOptions::*_240)(const struct CppSharp::CppParser::CppParserOptions&) = &CppSharp::CppParser::CppParserOptions::operator=; -extern "C" void c__N_CppSharp_N_CppParser_S_LinkerOptions_LinkerOptions___1__N_CppSharp_N_CppParser_S_LinkerOptions(void* __instance, const CppSharp::CppParser::LinkerOptions& _0) { ::new (__instance) CppSharp::CppParser::LinkerOptions(_0); } struct CppSharp::CppParser::LinkerOptions& (CppSharp::CppParser::LinkerOptions::*_241)(const struct CppSharp::CppParser::LinkerOptions&) = &CppSharp::CppParser::LinkerOptions::operator=; struct CppSharp::CppParser::ParserDiagnostic& (CppSharp::CppParser::ParserDiagnostic::*_242)(const struct CppSharp::CppParser::ParserDiagnostic&) = &CppSharp::CppParser::ParserDiagnostic::operator=; struct CppSharp::CppParser::ParserResult& (CppSharp::CppParser::ParserResult::*_243)(const struct CppSharp::CppParser::ParserResult&) = &CppSharp::CppParser::ParserResult::operator=; diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs index 674c0fa5..07b3c703 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs @@ -40010,11 +40010,11 @@ namespace CppSharp internal global::Std.Vector.__Internalc__N_std_S_vector____N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C___N_std_S_allocator__S0_ LibraryDirs; internal global::Std.Vector.__Internalc__N_std_S_vector____N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C___N_std_S_allocator__S0_ Libraries; - [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsC2Ev", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void ctor(__IntPtr __instance); + [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsC2EPKc", CallingConvention = __CallingConvention.Cdecl)] + internal static extern void ctor(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string Triple); [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsC2ERKS1_", CallingConvention = __CallingConvention.Cdecl)] - internal static extern void cctor(__IntPtr __instance, __IntPtr _0); + internal static extern void cctor(__IntPtr __instance, __IntPtr Other); [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser13LinkerOptionsD2Ev", CallingConvention = __CallingConvention.Cdecl)] internal static extern void dtor(__IntPtr __instance); @@ -40105,22 +40105,22 @@ namespace CppSharp __Instance = new __IntPtr(native); } - public LinkerOptions() + public LinkerOptions(string Triple) { __Instance = Marshal.AllocHGlobal(sizeof(global::CppSharp.Parser.LinkerOptions.__Internal)); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - __Internal.ctor(__Instance); + __Internal.ctor(__Instance, Triple); } - public LinkerOptions(global::CppSharp.Parser.LinkerOptions _0) + public LinkerOptions(global::CppSharp.Parser.LinkerOptions Other) { __Instance = Marshal.AllocHGlobal(sizeof(global::CppSharp.Parser.LinkerOptions.__Internal)); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - if (ReferenceEquals(_0, null)) - throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); - var __arg0 = _0.__Instance; + if (ReferenceEquals(Other, null)) + throw new global::System.ArgumentNullException("Other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = Other.__Instance; __Internal.cctor(__Instance, __arg0); } @@ -40192,6 +40192,11 @@ namespace CppSharp __Internal.ClearLibraries(__Instance); } + public static implicit operator global::CppSharp.Parser.LinkerOptions(string Triple) + { + return new global::CppSharp.Parser.LinkerOptions(Triple); + } + public uint ArgumentsCount { get @@ -40631,6 +40636,9 @@ namespace CppSharp [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser11ClangParser12ParseLibraryEPNS0_13LinkerOptionsE", CallingConvention = __CallingConvention.Cdecl)] internal static extern __IntPtr ParseLibrary(__IntPtr Opts); + + [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser11ClangParser5BuildEPNS0_16CppParserOptionsEPKNS0_13LinkerOptionsERKSsb", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr Build(__IntPtr Opts, __IntPtr LinkerOptions, __IntPtr File, bool Last); } public __IntPtr __Instance { get; protected set; } @@ -40730,6 +40738,19 @@ namespace CppSharp var __result0 = global::CppSharp.Parser.ParserResult.__GetOrCreateInstance(__ret, false); return __result0; } + + public static global::CppSharp.Parser.ParserResult Build(global::CppSharp.Parser.CppParserOptions Opts, global::CppSharp.Parser.LinkerOptions LinkerOptions, string File, bool Last) + { + var __arg0 = Opts is null ? __IntPtr.Zero : Opts.__Instance; + var __arg1 = LinkerOptions is null ? __IntPtr.Zero : LinkerOptions.__Instance; + var __basicString2 = new global::Std.BasicString, global::Std.Allocator>(); + global::Std.BasicStringExtensions.Assign(__basicString2, File); + var __arg2 = __basicString2.__Instance; + var __ret = __Internal.Build(__arg0, __arg1, __arg2, Last); + __basicString2.Dispose(); + var __result0 = global::CppSharp.Parser.ParserResult.__GetOrCreateInstance(__ret, false); + return __result0; + } } } } diff --git a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser-symbols.cpp b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser-symbols.cpp index c1e47a1a..14cb12bb 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser-symbols.cpp +++ b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser-symbols.cpp @@ -372,7 +372,6 @@ extern "C" __declspec(dllexport) void c__N_CppSharp_N_CppParser_S_ParserTargetIn struct CppSharp::CppParser::ParserTargetInfo& (CppSharp::CppParser::ParserTargetInfo::*_239)(const struct CppSharp::CppParser::ParserTargetInfo&) = &CppSharp::CppParser::ParserTargetInfo::operator=; extern "C" __declspec(dllexport) void c__N_CppSharp_N_CppParser_S_CppParserOptions_CppParserOptions___1__N_CppSharp_N_CppParser_S_CppParserOptions(void* __instance, const CppSharp::CppParser::CppParserOptions& _0) { ::new (__instance) CppSharp::CppParser::CppParserOptions(_0); } struct CppSharp::CppParser::CppParserOptions& (CppSharp::CppParser::CppParserOptions::*_240)(const struct CppSharp::CppParser::CppParserOptions&) = &CppSharp::CppParser::CppParserOptions::operator=; -extern "C" __declspec(dllexport) void c__N_CppSharp_N_CppParser_S_LinkerOptions_LinkerOptions___1__N_CppSharp_N_CppParser_S_LinkerOptions(void* __instance, const CppSharp::CppParser::LinkerOptions& _0) { ::new (__instance) CppSharp::CppParser::LinkerOptions(_0); } struct CppSharp::CppParser::LinkerOptions& (CppSharp::CppParser::LinkerOptions::*_241)(const struct CppSharp::CppParser::LinkerOptions&) = &CppSharp::CppParser::LinkerOptions::operator=; struct CppSharp::CppParser::ParserDiagnostic& (CppSharp::CppParser::ParserDiagnostic::*_242)(const struct CppSharp::CppParser::ParserDiagnostic&) = &CppSharp::CppParser::ParserDiagnostic::operator=; struct CppSharp::CppParser::ParserResult& (CppSharp::CppParser::ParserResult::*_243)(const struct CppSharp::CppParser::ParserResult&) = &CppSharp::CppParser::ParserResult::operator=; diff --git a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs index aa2e6a41..bf578471 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs @@ -40067,11 +40067,11 @@ namespace CppSharp internal global::Std.Vector.__Internalc__N_std_S_vector____N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C___N_std_S_allocator__S0_ LibraryDirs; internal global::Std.Vector.__Internalc__N_std_S_vector____N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C___N_std_S_allocator__S0_ Libraries; - [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "??0LinkerOptions@CppParser@CppSharp@@QEAA@XZ", CallingConvention = __CallingConvention.Cdecl)] - internal static extern __IntPtr ctor(__IntPtr __instance); + [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "??0LinkerOptions@CppParser@CppSharp@@QEAA@PEBD@Z", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr ctor(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string Triple); [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "??0LinkerOptions@CppParser@CppSharp@@QEAA@AEBU012@@Z", CallingConvention = __CallingConvention.Cdecl)] - internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0); + internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr Other); [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "??1LinkerOptions@CppParser@CppSharp@@QEAA@XZ", CallingConvention = __CallingConvention.Cdecl)] internal static extern void dtor(__IntPtr __instance); @@ -40162,22 +40162,22 @@ namespace CppSharp __Instance = new __IntPtr(native); } - public LinkerOptions() + public LinkerOptions(string Triple) { __Instance = Marshal.AllocHGlobal(sizeof(global::CppSharp.Parser.LinkerOptions.__Internal)); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - __Internal.ctor(__Instance); + __Internal.ctor(__Instance, Triple); } - public LinkerOptions(global::CppSharp.Parser.LinkerOptions _0) + public LinkerOptions(global::CppSharp.Parser.LinkerOptions Other) { __Instance = Marshal.AllocHGlobal(sizeof(global::CppSharp.Parser.LinkerOptions.__Internal)); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - if (ReferenceEquals(_0, null)) - throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); - var __arg0 = _0.__Instance; + if (ReferenceEquals(Other, null)) + throw new global::System.ArgumentNullException("Other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = Other.__Instance; __Internal.cctor(__Instance, __arg0); } @@ -40249,6 +40249,11 @@ namespace CppSharp __Internal.ClearLibraries(__Instance); } + public static implicit operator global::CppSharp.Parser.LinkerOptions(string Triple) + { + return new global::CppSharp.Parser.LinkerOptions(Triple); + } + public uint ArgumentsCount { get @@ -40688,6 +40693,9 @@ namespace CppSharp [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "?ParseLibrary@ClangParser@CppParser@CppSharp@@SAPEAUParserResult@23@PEAULinkerOptions@23@@Z", CallingConvention = __CallingConvention.Cdecl)] internal static extern __IntPtr ParseLibrary(__IntPtr Opts); + + [SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "?Build@ClangParser@CppParser@CppSharp@@SAPEAUParserResult@23@PEAUCppParserOptions@23@PEBULinkerOptions@23@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N@Z", CallingConvention = __CallingConvention.Cdecl)] + internal static extern __IntPtr Build(__IntPtr Opts, __IntPtr LinkerOptions, __IntPtr File, bool Last); } public __IntPtr __Instance { get; protected set; } @@ -40787,6 +40795,19 @@ namespace CppSharp var __result0 = global::CppSharp.Parser.ParserResult.__GetOrCreateInstance(__ret, false); return __result0; } + + public static global::CppSharp.Parser.ParserResult Build(global::CppSharp.Parser.CppParserOptions Opts, global::CppSharp.Parser.LinkerOptions LinkerOptions, string File, bool Last) + { + var __arg0 = Opts is null ? __IntPtr.Zero : Opts.__Instance; + var __arg1 = LinkerOptions is null ? __IntPtr.Zero : LinkerOptions.__Instance; + var __basicString2 = new global::Std.BasicString, global::Std.Allocator>(); + global::Std.BasicStringExtensions.Assign(__basicString2, File); + var __arg2 = __basicString2.__Instance; + var __ret = __Internal.Build(__arg0, __arg1, __arg2, Last); + __basicString2.Dispose(); + var __result0 = global::CppSharp.Parser.ParserResult.__GetOrCreateInstance(__ret, false); + return __result0; + } } } } diff --git a/src/CppParser/CppParser.cpp b/src/CppParser/CppParser.cpp index 0f2a9491..b7fc4a41 100644 --- a/src/CppParser/CppParser.cpp +++ b/src/CppParser/CppParser.cpp @@ -7,6 +7,7 @@ #include "CppParser.h" #include "Parser.h" +#include #include namespace CppSharp { namespace CppParser { @@ -61,7 +62,70 @@ ParserResult::~ParserResult() DEF_VECTOR(ParserResult, ParserDiagnostic, Diagnostics) DEF_VECTOR(ParserResult, NativeLibrary*, Libraries) -LinkerOptions::LinkerOptions() {} +LinkerOptions::LinkerOptions(const char* Triple) +{ + llvm::Triple TargetTriple(Triple && strlen(Triple) > 0 ? + llvm::Triple::normalize(Triple) : llvm::sys::getDefaultTargetTriple()); + switch (TargetTriple.getOS()) + { + case llvm::Triple::OSType::Win32: + addArguments("-dll"); + addArguments("libcmt.lib"); + switch (TargetTriple.getEnvironment()) + { + case llvm::Triple::EnvironmentType::MSVC: + break; + + case llvm::Triple::EnvironmentType::GNU: + addArguments("libstdc++-6.dll"); + break; + + default: + throw std::invalid_argument("Target triple environment"); + } + break; + + case llvm::Triple::OSType::Linux: + addArguments("-L/usr/lib/x86_64-linux-gnu"); + addArguments("-lc"); + addArguments("--shared"); + addArguments("-rpath"); + addArguments("."); + break; + + case llvm::Triple::OSType::Darwin: + case llvm::Triple::OSType::MacOSX: + addArguments("-lc++"); + addArguments("-lSystem"); + addArguments("-dylib"); + addArguments("-sdk_version"); + addArguments("10.12.0"); + addArguments("-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"); + addArguments("-rpath"); + addArguments("."); + break; + + default: + throw std::invalid_argument("Target triple operating system"); + } +} + +LinkerOptions::LinkerOptions(const LinkerOptions& Other) +{ + for (const std::string& Argument : Other.Arguments) + { + Arguments.push_back(Argument); + } + for (const std::string& LibraryDir : Other.LibraryDirs) + { + LibraryDirs.push_back(LibraryDir); + } + for (const std::string& Library : Other.Libraries) + { + Libraries.push_back(Library); + } +} + LinkerOptions::~LinkerOptions() {} DEF_VECTOR_STRING(LinkerOptions, Arguments) diff --git a/src/CppParser/CppParser.h b/src/CppParser/CppParser.h index 795af0d0..6e3129a7 100644 --- a/src/CppParser/CppParser.h +++ b/src/CppParser/CppParser.h @@ -56,7 +56,8 @@ private: struct CS_API LinkerOptions { - LinkerOptions(); + LinkerOptions(const char* Triple); + LinkerOptions(const LinkerOptions& Other); ~LinkerOptions(); VECTOR_STRING(Arguments) @@ -121,6 +122,8 @@ public: static ParserResult* ParseHeader(CppParserOptions* Opts); static ParserResult* ParseLibrary(LinkerOptions* Opts); + static ParserResult* Build(CppParserOptions* Opts, + const LinkerOptions* LinkerOptions, const std::string& File, bool Last); }; } } \ No newline at end of file diff --git a/src/CppParser/Link.cpp b/src/CppParser/Link.cpp new file mode 100644 index 00000000..4f3eda7f --- /dev/null +++ b/src/CppParser/Link.cpp @@ -0,0 +1,187 @@ +/************************************************************************ +* +* CppSharp +* Licensed under the simplified BSD license. All rights reserved. +* +************************************************************************/ + +#include "CppParser.h" +#include "Parser.h" +#include +#include +#include + +using namespace CppSharp::CppParser; + +void Parser::Link(const std::string& File, const LinkerOptions* LinkerOptions) +{ + std::vector args; + llvm::StringRef Dir(llvm::sys::path::parent_path(File)); + llvm::StringRef Stem = llvm::sys::path::stem(File); + + const llvm::Triple Triple = c->getTarget().getTriple(); + switch (Triple.getOS()) + { + case llvm::Triple::OSType::Win32: + args.push_back("-subsystem:windows"); + switch (Triple.getEnvironment()) + { + case llvm::Triple::EnvironmentType::MSVC: + LinkWindows(LinkerOptions, args, Dir, Stem); + break; + + case llvm::Triple::EnvironmentType::GNU: + LinkWindows(LinkerOptions, args, Dir, Stem, true); + break; + + default: + throw std::invalid_argument("Target triple environment"); + } + break; + + case llvm::Triple::OSType::Linux: + LinkELF(LinkerOptions, args, Dir, Stem); + break; + + case llvm::Triple::OSType::Darwin: + case llvm::Triple::OSType::MacOSX: + LinkMachO(LinkerOptions, args, Dir, Stem); + break; + + default: + throw std::invalid_argument("Target triple operating system"); + } +} + +void Parser::LinkWindows(const LinkerOptions* LinkerOptions, + std::vector& args, + const llvm::StringRef& Dir, llvm::StringRef& Stem, bool MinGW) +{ +#ifdef _WIN32 + using namespace llvm; + using namespace clang; + + if (MinGW) + { + args.push_back("-lldmingw"); + } + + const Triple& Triple = c->getTarget().getTriple(); + driver::Driver D("", Triple.str(), c->getDiagnostics()); + opt::InputArgList Args(0, 0); + driver::toolchains::MSVCToolChain TC(D, Triple, Args); + + std::vector LibraryPaths; + LibraryPaths.push_back("-libpath:" + TC.getSubDirectoryPath( + clang::driver::toolchains::MSVCToolChain::SubDirectoryType::Lib)); + std::string CRTPath; + if (TC.getUniversalCRTLibraryPath(Args, CRTPath)) + LibraryPaths.push_back("-libpath:" + CRTPath); + std::string WinSDKPath; + if (TC.getWindowsSDKLibraryPath(Args, WinSDKPath)) + LibraryPaths.push_back("-libpath:" + WinSDKPath); + for (const auto& LibraryDir : LinkerOptions->LibraryDirs) + LibraryPaths.push_back("-libpath:" + LibraryDir); + for (const auto& LibraryPath : LibraryPaths) + args.push_back(LibraryPath.data()); + + for (const std::string& Arg : LinkerOptions->Arguments) + { + args.push_back(Arg.data()); + } + + std::string LibExtension(MinGW ? "" : ".lib"); + + std::vector Libraries; + for (const auto& Library : LinkerOptions->Libraries) + Libraries.push_back(Library + LibExtension); + for (const auto& Library : Libraries) + args.push_back(Library.data()); + + args.push_back(c->getFrontendOpts().OutputFile.data()); + SmallString<1024> Output(Dir); + sys::path::append(Output, Stem + ".dll"); + std::string Out("-out:" + std::string(Output)); + args.push_back(Out.data()); + + lld::coff::link(args, false, outs(), errs()); +#endif +} + +void Parser::LinkELF(const LinkerOptions* LinkerOptions, + std::vector& args, + llvm::StringRef& Dir, llvm::StringRef& Stem) +{ +#ifdef __linux__ + using namespace llvm; + + args.push_back("-flavor gnu"); + for (const std::string& Arg : LinkerOptions->Arguments) + { + args.push_back(Arg.data()); + } + + std::string LinkingDir("-L" + Dir.str()); + args.push_back(LinkingDir.data()); + std::vector LibraryDirs; + for (const auto& LibraryDir : LinkerOptions->LibraryDirs) + LibraryDirs.push_back("-L" + LibraryDir); + for (const auto& LibraryDir : LibraryDirs) + args.push_back(LibraryDir.data()); + + std::vector Libraries; + for (const auto& Library : LinkerOptions->Libraries) + Libraries.push_back("-l" + Library); + for (const auto& Library : Libraries) + args.push_back(Library.data()); + + args.push_back(c->getFrontendOpts().OutputFile.data()); + + args.push_back("-o"); + SmallString<1024> Output(Dir); + sys::path::append(Output, "lib" + Stem + ".so"); + std::string Out(Output); + args.push_back(Out.data()); + + lld::elf::link(args, false, outs(), errs()); +#endif +} + +void Parser::LinkMachO(const LinkerOptions* LinkerOptions, + std::vector& args, + llvm::StringRef& Dir, llvm::StringRef& Stem) +{ +#ifdef __APPLE__ + using namespace llvm; + + args.push_back("-flavor darwinnew"); + for (const std::string& Arg : LinkerOptions->Arguments) + { + args.push_back(Arg.data()); + } + + std::string LinkingDir("-L" + Dir.str()); + args.push_back(LinkingDir.data()); + std::vector LibraryDirs; + for (const auto& LibraryDir : LinkerOptions->LibraryDirs) + LibraryDirs.push_back("-L" + LibraryDir); + for (const auto& LibraryDir : LibraryDirs) + args.push_back(LibraryDir.data()); + + std::vector Libraries; + for (const auto& Library : LinkerOptions->Libraries) + Libraries.push_back("-l" + Library); + for (const auto& Library : Libraries) + args.push_back(Library.data()); + + args.push_back(c->getFrontendOpts().OutputFile.data()); + + args.push_back("-o"); + SmallString<1024> Output(Dir); + sys::path::append(Output, "lib" + Stem + ".dylib"); + std::string Out(Output); + args.push_back(Out.data()); + + lld::mach_o::link(args, false, outs(), errs()); +#endif +} \ No newline at end of file diff --git a/src/CppParser/Parser.cpp b/src/CppParser/Parser.cpp index a65fd1d4..d5c635c6 100644 --- a/src/CppParser/Parser.cpp +++ b/src/CppParser/Parser.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -245,6 +246,9 @@ void Parser::Setup() std::vector args; args.push_back("-cc1"); + args.push_back("-flto"); + args.push_back("-O3"); + args.push_back("-fno-use-cxa-atexit"); for (unsigned I = 0, E = opts->Arguments.size(); I != E; ++I) { @@ -4651,6 +4655,22 @@ ParserResult* Parser::ParseLibrary(const LinkerOptions* Opts) return res; } +ParserResult* Parser::Build(const LinkerOptions* LinkerOptions, const std::string& File, bool Last) +{ + ParserResult* error = Compile(File); + if (error) + return error; + + Link(File, LinkerOptions); + + if (Last) + llvm::llvm_shutdown(); + + auto res = new ParserResult(); + HandleDiagnostics(res); + return res; +} + ParserResult* ClangParser::ParseHeader(CppParserOptions* Opts) { if (!Opts) @@ -4690,6 +4710,45 @@ ParserResult* ClangParser::ParseLibrary(LinkerOptions* Opts) return Parser::ParseLibrary(Opts); } +ParserResult* ClangParser::Build(CppParserOptions* Opts, + const LinkerOptions* LinkerOptions, const std::string& File, bool Last) +{ + if (!Opts) + return 0; + + Parser Parser(Opts); + return Parser.Build(LinkerOptions, File, Last); +} + +ParserResult* Parser::Compile(const std::string& File) +{ + llvm::InitializeAllAsmPrinters(); + llvm::StringRef Stem = llvm::sys::path::stem(File); + Setup(); + + c->getDiagnostics().setClient(new ::DiagnosticConsumer()); + + c->getFrontendOpts().Inputs.clear(); + c->getFrontendOpts().Inputs.push_back(clang::FrontendInputFile(File, clang::Language::CXX)); + + const llvm::Triple Triple = c->getTarget().getTriple(); + llvm::StringRef Dir(llvm::sys::path::parent_path(File)); + llvm::SmallString<1024> Object(Dir); + llvm::sys::path::append(Object, + (Triple.isOSWindows() ? "" : "lib") + Stem + ".o"); + c->getFrontendOpts().OutputFile = std::string(Object); + + llvm::LLVMContext context; + auto action = std::make_unique(&context); + if (!c->ExecuteAction(*action)) + { + auto res = new ParserResult(); + HandleDiagnostics(res); + return res; + } + return 0; +} + ParserTargetInfo* Parser::GetTargetInfo() { auto parserTargetInfo = new ParserTargetInfo(); diff --git a/src/CppParser/Parser.h b/src/CppParser/Parser.h index d4bc4546..9d904d75 100644 --- a/src/CppParser/Parser.h +++ b/src/CppParser/Parser.h @@ -56,7 +56,7 @@ public: void Setup(); ParserResult* Parse(const std::vector& SourceFiles); static ParserResult* ParseLibrary(const LinkerOptions* Opts); - + ParserResult* Build(const LinkerOptions* LinkerOptions, const std::string& File, bool Last); void WalkAST(clang::TranslationUnitDecl* TU); void HandleDeclaration(const clang::Decl* D, Declaration* Decl); CppParserOptions* opts; @@ -169,6 +169,15 @@ private: llvm::object::ObjectFile* ObjectFile, std::vector& NativeLibs); ParserTargetInfo* GetTargetInfo(); + ParserResult* Compile(const std::string& File); + void Link(const std::string& File, const LinkerOptions* LinkerOptions); + void LinkWindows(const LinkerOptions* LinkerOptions, std::vector& args, + const llvm::StringRef& Dir, llvm::StringRef& Stem, bool MinGW = false); + void LinkELF(const LinkerOptions* LinkerOptions, std::vector& args, + llvm::StringRef& Dir, llvm::StringRef& Stem); + void LinkMachO(const LinkerOptions* LinkerOptions, std::vector& args, + llvm::StringRef& Dir, llvm::StringRef& Stem); + int index; std::unique_ptr c; llvm::LLVMContext LLVMCtx; diff --git a/src/Generator.Tests/AST/TestAST.cs b/src/Generator.Tests/AST/TestAST.cs index 63d5c6fd..968e7e7d 100644 --- a/src/Generator.Tests/AST/TestAST.cs +++ b/src/Generator.Tests/AST/TestAST.cs @@ -2,7 +2,6 @@ using System; using System.Linq; using CppSharp.AST; using CppSharp.AST.Extensions; -using CppSharp.Generators; using CppSharp.Generators.C; using CppSharp.Generators.CSharp; using CppSharp.Passes; @@ -13,26 +12,8 @@ namespace CppSharp.Generator.Tests.AST [TestFixture] public class TestAST : ASTTestFixture { - private BindingContext Context; - - [OneTimeSetUp] - public void Init() - { - Context = new BindingContext(new DriverOptions()); - Context.TypeMaps = new Types.TypeMapDatabase(Context); - - CppSharp.AST.Type.TypePrinterDelegate = type => - { - PrimitiveType primitiveType; - return type.IsPrimitiveType(out primitiveType) ? primitiveType.ToString() : string.Empty; - }; - ParseLibrary("AST.h", "ASTExtensions.h"); - } - - [OneTimeTearDown] - public void CleanUp() + public TestAST() : base("AST.h", "ASTExtensions.h") { - Driver.Dispose(); } [Test] diff --git a/src/Generator.Tests/ASTTestFixture.cs b/src/Generator.Tests/ASTTestFixture.cs index 83fac310..e6130d46 100644 --- a/src/Generator.Tests/ASTTestFixture.cs +++ b/src/Generator.Tests/ASTTestFixture.cs @@ -4,6 +4,8 @@ using CppSharp.Utils; using CppSharp.Parser; using CppSharp.Passes; using CppSharp.Generators; +using NUnit.Framework; +using CppSharp.AST.Extensions; namespace CppSharp.Generator.Tests { @@ -11,22 +13,44 @@ namespace CppSharp.Generator.Tests { protected Driver Driver; protected ASTContext AstContext; + protected BindingContext Context; + + public ASTTestFixture(params string[] files) + { + this.files = files; + } + + [OneTimeSetUp] + public void Init() + { + ParseLibrary(files); + } + + [OneTimeTearDown] + public void CleanUp() + { + if (files.Length > 0) + { + Driver.Dispose(); + } + } protected void ParseLibrary(params string[] files) { - var options = new DriverOptions { GeneratorKind = GeneratorKind.CSharp }; - var parserOptions = new ParserOptions(); + if (files.Length == 0) + { + return; + } - var testsPath = GeneratorTest.GetTestsDirectory("Native"); - parserOptions.SkipPrivateDeclarations = true; + var options = new DriverOptions { GeneratorKind = GeneratorKind.CSharp }; var module = options.AddModule("Test"); - module.IncludeDirs.Add(testsPath); + module.IncludeDirs.Add(GeneratorTest.GetTestsDirectory("Native")); module.Headers.AddRange(files); Driver = new Driver(options) { - ParserOptions = parserOptions + ParserOptions = new ParserOptions { SkipPrivateDeclarations = true } }; Driver.Setup(); @@ -37,6 +61,17 @@ namespace CppSharp.Generator.Tests AstContext = Driver.Context.ASTContext; new CleanUnitPass { Context = Driver.Context }.VisitASTContext(AstContext); new ResolveIncompleteDeclsPass { Context = Driver.Context }.VisitASTContext(AstContext); + + Context = new BindingContext(options, Driver.ParserOptions); + Context.TypeMaps = new Types.TypeMapDatabase(Context); + + CppSharp.AST.Type.TypePrinterDelegate = type => + { + PrimitiveType primitiveType; + return type.IsPrimitiveType(out primitiveType) ? primitiveType.ToString() : string.Empty; + }; } + + private readonly string[] files; } } diff --git a/src/Generator.Tests/GeneratorTest.cs b/src/Generator.Tests/GeneratorTest.cs index d2f7e759..feff986f 100644 --- a/src/Generator.Tests/GeneratorTest.cs +++ b/src/Generator.Tests/GeneratorTest.cs @@ -27,8 +27,8 @@ namespace CppSharp.Utils options.OutputDir = Path.Combine(GetOutputDirectory(), "build", "gen", name); options.Quiet = true; options.GenerateDebugOutput = true; + options.CheckSymbols = true; var testModule = options.AddModule(name); - testModule.SharedLibraryName = $"{name}.Native"; Diagnostics.Message(""); Diagnostics.Message("Generating bindings for {0} ({1})", @@ -40,6 +40,8 @@ namespace CppSharp.Utils var path = Path.GetFullPath(GetTestsDirectory(name)); testModule.IncludeDirs.Add(path); + testModule.LibraryDirs.Add(options.OutputDir); + testModule.Libraries.Add($"{name}.Native"); Diagnostics.Message("Looking for tests in: {0}", path); var files = Directory.EnumerateFiles(path, "*.h", SearchOption.AllDirectories); diff --git a/src/Generator.Tests/Passes/TestPasses.cs b/src/Generator.Tests/Passes/TestPasses.cs index bcbb4bd0..ae21670d 100644 --- a/src/Generator.Tests/Passes/TestPasses.cs +++ b/src/Generator.Tests/Passes/TestPasses.cs @@ -4,19 +4,13 @@ using CppSharp.Generators.CSharp; using CppSharp.Passes; using NUnit.Framework; using System.Collections; -using System.Collections.Generic; -using System.Globalization; using System.Linq; -using System.Runtime.CompilerServices; -using System.Text.RegularExpressions; namespace CppSharp.Generator.Tests.Passes { [TestFixture] public class TestPasses : ASTTestFixture { - private PassBuilder passBuilder; - [SetUp] public void Setup() { @@ -24,6 +18,12 @@ namespace CppSharp.Generator.Tests.Passes passBuilder = new PassBuilder(Driver.Context); } + [TearDown] + public void TearDown() + { + Driver.Dispose(); + } + [Test] public void TestExtractInterfacePass() { @@ -451,5 +451,7 @@ namespace CppSharp.Generator.Tests.Passes Assert.IsNotNull(@protected); Assert.AreEqual(AccessSpecifier.Protected, @protected.Access); } + + private PassBuilder passBuilder; } } diff --git a/src/Generator/BindingContext.cs b/src/Generator/BindingContext.cs index 66c59f67..b89f735b 100644 --- a/src/Generator/BindingContext.cs +++ b/src/Generator/BindingContext.cs @@ -9,6 +9,7 @@ namespace CppSharp.Generators { public DriverOptions Options { get; } public ParserOptions ParserOptions { get; set; } + public LinkerOptions LinkerOptions { get; set; } public ASTContext ASTContext { get; set; } public ParserTargetInfo TargetInfo { get; set; } @@ -25,6 +26,7 @@ namespace CppSharp.Generators { Options = options; ParserOptions = parserOptions; + LinkerOptions = new LinkerOptions(ParserOptions.TargetTriple); Symbols = new SymbolContext(); diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs index 57cc5e57..2c8f53e2 100644 --- a/src/Generator/Driver.cs +++ b/src/Generator/Driver.cs @@ -179,7 +179,7 @@ namespace CppSharp ClangParser.LibraryParsed += OnFileParsed; foreach (var module in Options.Modules) { - using (var linkerOptions = new LinkerOptions()) + using (var linkerOptions = new LinkerOptions(Context.LinkerOptions)) { foreach (var libraryDir in module.LibraryDirs) linkerOptions.AddLibraryDirs(libraryDir); @@ -399,6 +399,7 @@ namespace CppSharp Generator?.Dispose(); Context?.TargetInfo?.Dispose(); ParserOptions.Dispose(); + Context?.LinkerOptions.Dispose(); } private bool hasParsingErrors; diff --git a/src/Generator/Passes/GenerateSymbolsPass.cs b/src/Generator/Passes/GenerateSymbolsPass.cs index b23fb5c0..5829e13b 100644 --- a/src/Generator/Passes/GenerateSymbolsPass.cs +++ b/src/Generator/Passes/GenerateSymbolsPass.cs @@ -42,11 +42,44 @@ namespace CppSharp.Passes var e = new SymbolsCodeEventArgs(module); SymbolsCodeGenerated?.Invoke(this, e); - if (string.IsNullOrEmpty(e.CustomCompiler)) - RemainingCompilationTasks--; - else + if (!string.IsNullOrEmpty(e.CustomCompiler)) + { InvokeCompiler(e.CustomCompiler, e.CompilerArguments, e.OutputDir, module); + continue; + } + + if (Options.CheckSymbols && (module == Options.SystemModule || + // if the user's provided no libraries, he only wants to generate code + (module.LibraryDirs.Count > 0 && module.Libraries.Count > 0))) + { + using (var linkerOptions = new LinkerOptions(Context.LinkerOptions)) + { + foreach (var libraryDir in module.Dependencies.Union( + new[] { module }).SelectMany(d => d.LibraryDirs)) + linkerOptions.AddLibraryDirs(libraryDir); + + foreach (var library in module.Dependencies.Union( + new[] { module }).SelectMany(d => d.Libraries)) + linkerOptions.AddLibraries(library); + + using (var result = Parser.ClangParser.Build( + Context.ParserOptions, linkerOptions, path, + Last: remainingCompilationTasks == 1)) + { + if (PrintDiagnostics(result)) + { + compiledLibraries[module] = new CompiledLibrary + { + OutputDir = Options.OutputDir, + Library = module.SymbolsLibraryName + }; + } + } + } + } + + RemainingCompilationTasks--; } } @@ -146,6 +179,42 @@ namespace CppSharp.Passes return symbolsCodeGenerator; } + private static bool PrintDiagnostics(ParserResult result) + { + bool success = true; + for (uint i = 0; i < result.DiagnosticsCount; i++) + { + var diag = result.GetDiagnostics(i); + switch (diag.Level) + { + case ParserDiagnosticLevel.Ignored: + case ParserDiagnosticLevel.Note: + Diagnostics.Message("{0}({1},{2}): {3}: {4}", + diag.FileName, diag.LineNumber, diag.ColumnNumber, + diag.Level.ToString().ToLower(), diag.Message); + break; + case ParserDiagnosticLevel.Warning: + Diagnostics.Warning("{0}({1},{2}): {3}: {4}", + diag.FileName, diag.LineNumber, diag.ColumnNumber, + diag.Level.ToString().ToLower(), diag.Message); + break; + case ParserDiagnosticLevel.Error: + Diagnostics.Error("{0}({1},{2}): {3}: {4}", + diag.FileName, diag.LineNumber, diag.ColumnNumber, + diag.Level.ToString().ToLower(), diag.Message); + success = false; + break; + case ParserDiagnosticLevel.Fatal: + Diagnostics.Debug("{0}({1},{2}): {3}: {4}", + diag.FileName, diag.LineNumber, diag.ColumnNumber, + diag.Level.ToString().ToLower(), diag.Message); + success = false; + break; + } + } + return success; + } + private void InvokeCompiler(string compiler, string arguments, string outputDir, Module module) { new Thread(() => @@ -215,7 +284,7 @@ namespace CppSharp.Passes private void CollectSymbols(string outputDir, string library) { - using (var linkerOptions = new LinkerOptions()) + using (var linkerOptions = new LinkerOptions(Context.LinkerOptions)) { linkerOptions.AddLibraryDirs(outputDir); var output = GetOutputFile(library); diff --git a/src/Generator/Passes/SymbolsCodeGenerator.cs b/src/Generator/Passes/SymbolsCodeGenerator.cs index e0bac514..6fc53153 100644 --- a/src/Generator/Passes/SymbolsCodeGenerator.cs +++ b/src/Generator/Passes/SymbolsCodeGenerator.cs @@ -110,7 +110,9 @@ namespace CppSharp.Passes private string GetExporting() { - return Context.ParserOptions.IsMicrosoftAbi ? + return Context.ParserOptions.IsMicrosoftAbi || + (Context.ParserOptions.TargetTriple.IsWindows() && + TranslationUnit.Module == Options.SystemModule) ? "__declspec(dllexport) " : string.Empty; } diff --git a/tests/CSharp/CSharp.cpp b/tests/CSharp/CSharp.cpp index 62a15ce1..1e814dd7 100644 --- a/tests/CSharp/CSharp.cpp +++ b/tests/CSharp/CSharp.cpp @@ -33,10 +33,6 @@ Foo::Foo(const Foo& other) : A(other.A), P(other.P), { } -Foo::~Foo() -{ -} - int Foo::method() { return 1; @@ -178,11 +174,6 @@ void Quux::setSetterWithDefaultOverload(Foo* value) _setterWithDefaultOverload = value; } -QColor::QColor() -{ - -} - QColor::QColor(Qt::GlobalColor color) { @@ -241,15 +232,15 @@ int Qux::type() const return 0; } -Bar::Bar(Qux qux) +Bar::Bar() : index(0) { } -Bar::Bar(Items item) +Bar::Bar(Qux qux) { } -Bar::~Bar() +Bar::Bar(Items item) { } @@ -302,21 +293,9 @@ int Bar::type() const return 1; } -ForceCreationOfInterface::ForceCreationOfInterface() -{ -} +Baz::Baz() : P(5), functionTypedef(0) {} -ForceCreationOfInterface::~ForceCreationOfInterface() -{ -} - -Baz::Baz() : P(5) {} - -Baz::Baz(Bar::Items item) -{ -} - -Baz::~Baz() +Baz::Baz(Bar::Items item) : Baz() { } @@ -363,17 +342,18 @@ int AbstractProprietor::parent() const return 0; } -AbstractProprietor::AbstractProprietor() +AbstractProprietor::AbstractProprietor() : m_value(0), m_property(0) { } -AbstractProprietor::AbstractProprietor(int i) +AbstractProprietor::AbstractProprietor(int i) : AbstractProprietor() { } Proprietor::Proprietor() : _items(Bar::Items::Item1), _itemsByValue(Bar::Items::Item1) {} -Proprietor::Proprietor(int i) : AbstractProprietor(i) +Proprietor::Proprietor(int i) : AbstractProprietor(i), + _items(Bar::Items::Item1), _itemsByValue(Bar::Items::Item1) { } @@ -510,7 +490,7 @@ TestDestructors::~TestDestructors() { Marker = 0xcafe; } int TestDestructors::Marker = 0; -TestCopyConstructorVal::TestCopyConstructorVal() +TestCopyConstructorVal::TestCopyConstructorVal() : A(0), B(0) { } @@ -520,14 +500,6 @@ TestCopyConstructorVal::TestCopyConstructorVal(const TestCopyConstructorVal& oth B = other.B; } -TestRenaming::TestRenaming() -{ -} - -TestRenaming::~TestRenaming() -{ -} - void TestRenaming::name() { } @@ -541,18 +513,10 @@ int TestRenaming::property() return 1; } -UsesPointerToEnum::UsesPointerToEnum() -{ -} - void UsesPointerToEnum::hasPointerToEnumInParam(Flags* flag) { } -UsesPointerToEnumInParamOfVirtual::UsesPointerToEnumInParamOfVirtual() -{ -} - UsesPointerToEnumInParamOfVirtual::~UsesPointerToEnumInParamOfVirtual() { } @@ -578,7 +542,8 @@ UntypedFlags operator|(UntypedFlags lhs, UntypedFlags rhs) return static_cast(static_cast(lhs) | static_cast(rhs)); } -QGenericArgument::QGenericArgument(const char *name, const void* data) +QGenericArgument::QGenericArgument(const char* name, const void* data) : + fixedArrayInValueType { 0 } { _name = name; } @@ -844,10 +809,6 @@ int MethodsWithDefaultValues::getA() return m_foo.A; } -HasOverridesWithChangedAccessBase::HasOverridesWithChangedAccessBase() -{ -} - void HasOverridesWithChangedAccessBase::privateOverride(int i) { } @@ -860,10 +821,6 @@ void HasOverridesWithChangedAccessBase::differentIncreasedAccessOverride() { } -HasOverridesWithChangedAccess::HasOverridesWithChangedAccess() -{ -} - void HasOverridesWithChangedAccess::privateOverride(int i) { } @@ -872,18 +829,10 @@ void HasOverridesWithChangedAccess::publicOverride() { } -HasOverridesWithIncreasedProtectedAccess::HasOverridesWithIncreasedProtectedAccess() -{ -} - void HasOverridesWithIncreasedProtectedAccess::differentIncreasedAccessOverride() { } -HasOverridesWithIncreasedAccess::HasOverridesWithIncreasedAccess() -{ -} - void HasOverridesWithIncreasedAccess::privateOverride(int i) { } @@ -896,14 +845,6 @@ AbstractWithProperty::~AbstractWithProperty() { } -HasOverriddenInManaged::HasOverriddenInManaged() -{ -} - -HasOverriddenInManaged::~HasOverriddenInManaged() -{ -} - void HasOverriddenInManaged::setOverriddenInManaged(Baz* value) { overriddenInManaged = value; @@ -1015,10 +956,6 @@ void TestNativeToManagedMap::setPropertyWithNoVirtualDtor(Bar* bar) this->bar = bar; } -CallDtorVirtually::CallDtorVirtually() -{ -} - CallDtorVirtually::~CallDtorVirtually() { Destroyed = true; @@ -1037,14 +974,6 @@ CallDtorVirtually* CallDtorVirtually::getNonOwnedInstance() return &nonOwnedInstance; } -TestOverrideFromSecondaryBase::TestOverrideFromSecondaryBase() -{ -} - -TestOverrideFromSecondaryBase::~TestOverrideFromSecondaryBase() -{ -} - void TestOverrideFromSecondaryBase::VirtualMember() { } @@ -1099,30 +1028,10 @@ TestParamToInterfacePass::TestParamToInterfacePass() : TestParamToInterfacePassB { } -HasProtectedVirtual::HasProtectedVirtual() -{ -} - void HasProtectedVirtual::protectedVirtual() { } -InheritanceBuffer::InheritanceBuffer() -{ -} - -InheritanceBuffer::~InheritanceBuffer() -{ -} - -InheritsProtectedVirtualFromSecondaryBase::InheritsProtectedVirtualFromSecondaryBase() -{ -} - -InheritsProtectedVirtualFromSecondaryBase::~InheritsProtectedVirtualFromSecondaryBase() -{ -} - void InheritsProtectedVirtualFromSecondaryBase::protectedVirtual() { } @@ -1131,27 +1040,15 @@ void freeFunctionWithUnsupportedDefaultArg(Foo foo) { } -TypeMappedWithOperator::TypeMappedWithOperator() -{ -} - int TypeMappedWithOperator::operator |(int i) { return 0; } -HasPropertyWithDerivedType::HasPropertyWithDerivedType() -{ -} - void HasPropertyWithDerivedType::causeRenamingError() { } -HasOverrideOfHasPropertyWithDerivedType::HasOverrideOfHasPropertyWithDerivedType() -{ -} - void HasOverrideOfHasPropertyWithDerivedType::causeRenamingError() { } @@ -1185,32 +1082,16 @@ void MultiOverloadPtrToRef::TakePrimTypePtr(int* ptr) ptr[2] = 300; } -OverrideFromIndirectSecondaryBaseBase::OverrideFromIndirectSecondaryBaseBase() -{ -} - int OverrideFromIndirectSecondaryBaseBase::property() { return 0; } -OverrideFromDirectSecondaryBase::OverrideFromDirectSecondaryBase() -{ -} - -OverrideFromIndirectSecondaryBase::OverrideFromIndirectSecondaryBase() -{ -} - int OverrideFromIndirectSecondaryBase::property() { return 1; } -TestOutTypeInterfaces::TestOutTypeInterfaces() -{ -} - void TestOutTypeInterfaces::funcTryInterfaceTypePtrOut(CS_OUT TestParamToInterfacePassBaseTwo* classTry) { } @@ -1219,61 +1100,33 @@ void TestOutTypeInterfaces::funcTryInterfaceTypeOut(CS_OUT TestParamToInterfaceP { } -DerivesFromTemplateInstantiation::DerivesFromTemplateInstantiation() -{ -} - int PassConstantArrayRef(int(&arr)[2]) { return arr[0]; } -TestComparison::TestComparison() -{ -} - bool TestComparison::operator ==(const TestComparison& other) const { return A == other.A && B == other.B; } -OverridePropertyFromIndirectPrimaryBaseBase::OverridePropertyFromIndirectPrimaryBaseBase() -{ -} - OverridePropertyFromIndirectPrimaryBaseBase::~OverridePropertyFromIndirectPrimaryBaseBase() { } -OverridePropertyFromDirectPrimaryBase::OverridePropertyFromDirectPrimaryBase() -{ -} - void OverridePropertyFromDirectPrimaryBase::setProperty(int value) { } -OverridePropertyFromIndirectPrimaryBase::OverridePropertyFromIndirectPrimaryBase() -{ -} - int OverridePropertyFromIndirectPrimaryBase::property() { return 5; } -AbstractOverrideFromSecondaryBase::AbstractOverrideFromSecondaryBase() -{ -} - AbstractOverrideFromSecondaryBase::~AbstractOverrideFromSecondaryBase() { } -QObject::QObject() -{ -} - QObject::~QObject() { } @@ -1286,10 +1139,6 @@ QPaintDevice::QPaintDevice() : test(0) { } -QPaintDevice::~QPaintDevice() -{ -} - void QPaintDevice::changeVTableLayout() { } @@ -1299,10 +1148,6 @@ QWidget::QWidget() QApplication::instance->notify(this); } -QWidget::~QWidget() -{ -} - void QWidget::event() { QApplication::instance->notify(&child); @@ -1313,10 +1158,6 @@ QPainter::QPainter(QPaintDevice& paintDevice) paintDevice.test = 5; } -QPainter::~QPainter() -{ -} - QApplication::QApplication() { instance = this; @@ -1338,10 +1179,6 @@ char* HasSamePropertyInDerivedAbstractType::property() return 0; } -InheritsFromHasSamePropertyInDerivedAbstractType::InheritsFromHasSamePropertyInDerivedAbstractType() -{ -} - InheritsFromHasSamePropertyInDerivedAbstractType::~InheritsFromHasSamePropertyInDerivedAbstractType() { } @@ -1358,10 +1195,6 @@ MultipleInheritanceFieldOffsets::MultipleInheritanceFieldOffsets() : own(3) { } -VirtualDtorAddedInDerived::VirtualDtorAddedInDerived() -{ -} - VirtualDtorAddedInDerived::~VirtualDtorAddedInDerived() { dtorCalled = true; @@ -1423,14 +1256,6 @@ int HasConflictWithAbstractProperty::conflictWithProperty() return 0; } -HasVirtualTakesReturnsProblematicTypes::HasVirtualTakesReturnsProblematicTypes() -{ -} - -HasVirtualTakesReturnsProblematicTypes::~HasVirtualTakesReturnsProblematicTypes() -{ -} - const char* HasVirtualTakesReturnsProblematicTypes::virtualTakesAndReturnsString(const char* c) { return c; @@ -1470,10 +1295,6 @@ TestString::TestString() : unicodeConst(L"ქართული ენა"), uni { } -TestString::~TestString() -{ -} - TestChar32String::TestChar32String() : thirtyTwoBitConst(U"ქართული ენა") { @@ -1511,30 +1332,6 @@ void decltypeFunctionPointer() {} void usesDecltypeFunctionPointer(funcPtr func) {} -PrimaryBaseWithAbstractWithDefaultArg::PrimaryBaseWithAbstractWithDefaultArg() -{ -} - -PrimaryBaseWithAbstractWithDefaultArg::~PrimaryBaseWithAbstractWithDefaultArg() -{ -} - -SecondaryBaseWithAbstractWithDefaultArg::SecondaryBaseWithAbstractWithDefaultArg() -{ -} - -SecondaryBaseWithAbstractWithDefaultArg::~SecondaryBaseWithAbstractWithDefaultArg() -{ -} - -HasSecondaryBaseWithAbstractWithDefaultArg::HasSecondaryBaseWithAbstractWithDefaultArg() -{ -} - -HasSecondaryBaseWithAbstractWithDefaultArg::~HasSecondaryBaseWithAbstractWithDefaultArg() -{ -} - void HasSecondaryBaseWithAbstractWithDefaultArg::abstract(const Foo& foo) { } @@ -1543,28 +1340,16 @@ void HasSecondaryBaseWithAbstractWithDefaultArg::abstractWithNoDefaultArg(const { } -MissingObjectOnVirtualCallSecondaryBase::MissingObjectOnVirtualCallSecondaryBase() -{ -} - int MissingObjectOnVirtualCallSecondaryBase::f() { return 5; } -MissingObjectOnVirtualCall::MissingObjectOnVirtualCall() -{ -} - int MissingObjectOnVirtualCall::f() { return 15; } -HasMissingObjectOnVirtualCall::HasMissingObjectOnVirtualCall() -{ -} - int HasMissingObjectOnVirtualCall::makeMissingObjectOnVirtualCall() { return stackOverflowOnVirtualCall->f(); @@ -1611,26 +1396,10 @@ int ImplementsAbstractsFromPrimaryAndSecondary::abstractReturnsFieldInSecondaryB return field + 2; } -HasBaseSetter::HasBaseSetter() -{ -} - -HasBaseSetter::~HasBaseSetter() -{ -} - void HasBaseSetter::setBaseSetter(int value) { } -HasGetterAndOverriddenSetter::HasGetterAndOverriddenSetter() -{ -} - -HasGetterAndOverriddenSetter::~HasGetterAndOverriddenSetter() -{ -} - int HasGetterAndOverriddenSetter::baseSetter() { return field; @@ -1689,10 +1458,6 @@ ComplexArrayElement::ComplexArrayElement() : BoolField(false), IntField(0), Floa { } -HasComplexArray::HasComplexArray() -{ -} - TestIndexedProperties::TestIndexedProperties() : field(0) { } @@ -1728,14 +1493,6 @@ void InlineNamespace::FunctionInsideInlineNamespace() { } -TestArrays::TestArrays() -{ -} - -TestArrays::~TestArrays() -{ -} - int TestArrays::takeArrays(Foo* arrayOfPointersToObjects[], int arrayOfPrimitives[], Foo arrayOfObjects[]) const { return arrayOfPointersToObjects[0]->A + arrayOfPointersToObjects[1]->A + @@ -1787,30 +1544,10 @@ int TestArrays::virtualTakeArrays(Foo *fixedArrayOfPointersToObjects[], int fixe return takeArrays(fixedArrayOfPointersToObjects, fixedArrayOfPrimitives, fixedArrayOfPointersToPrimitives); } -HasFixedArrayOfPointers::HasFixedArrayOfPointers() -{ -} - -HasFixedArrayOfPointers::~HasFixedArrayOfPointers() -{ -} - -SimpleInterface::SimpleInterface() -{ -} - -SimpleInterface::~SimpleInterface() -{ -} - InterfaceTester::InterfaceTester() : interface(0) { } -InterfaceTester::~InterfaceTester() -{ -} - int InterfaceTester::capacity() { return interface->capacity(); @@ -1831,14 +1568,6 @@ void InterfaceTester::setInterface(SimpleInterface* i) interface = i; } -HasFunctionPtrField::HasFunctionPtrField() -{ -} - -HasFunctionPtrField::~HasFunctionPtrField() -{ -} - void va_listFunction(va_list v) { } @@ -1918,7 +1647,6 @@ const char32_t* TestCSharpString32(const char32_t* in, const char32_t** out) return ret.data(); } -ConversionFunctions::ConversionFunctions() = default; ConversionFunctions::operator short* () { return &field; } ConversionFunctions::operator short& () { return field; } ConversionFunctions::operator short() { return field; } diff --git a/tests/CSharp/CSharp.h b/tests/CSharp/CSharp.h index fd89203d..0db2cd98 100644 --- a/tests/CSharp/CSharp.h +++ b/tests/CSharp/CSharp.h @@ -24,7 +24,6 @@ public: Foo(char16_t ch); Foo(wchar_t ch); Foo(const Foo& other); - ~Foo(); int method(); int operator[](int i) const; int operator[](unsigned int i); @@ -111,7 +110,6 @@ public: Bar(); Bar(Qux qux); Bar(Items item); - ~Bar(); int method(); const Foo& operator[](int i) const; Foo& operator[](int i); @@ -143,13 +141,8 @@ private: Foo m_foo; }; -Bar::Bar() : index(0) {} - class DLL_API ForceCreationOfInterface : public Foo, public Bar { -public: - ForceCreationOfInterface(); - ~ForceCreationOfInterface(); }; class DLL_API Baz : public Foo, public Bar @@ -165,7 +158,6 @@ public: Baz(); Baz(Bar::Items item); - ~Baz(); int P; @@ -293,8 +285,6 @@ public: class DLL_API TestRenaming { public: - TestRenaming(); - ~TestRenaming(); void name(); void Name(); int property(); @@ -312,7 +302,6 @@ enum class Flags class DLL_API UsesPointerToEnum { public: - UsesPointerToEnum(); Flags* _flags; void hasPointerToEnumInParam(Flags* flag); }; @@ -320,7 +309,6 @@ public: class DLL_API UsesPointerToEnumInParamOfVirtual { public: - UsesPointerToEnumInParamOfVirtual(); virtual ~UsesPointerToEnumInParamOfVirtual(); virtual QFlags hasPointerToEnumInParam(const QFlags& pointerToEnum) const; static QFlags callOverrideOfHasPointerToEnumInParam( @@ -364,7 +352,6 @@ namespace Qt class DLL_API QColor { public: - QColor(); QColor(Qt::GlobalColor color); }; @@ -506,7 +493,6 @@ protected: class DLL_API HasOverridesWithChangedAccessBase { public: - HasOverridesWithChangedAccessBase(); virtual void privateOverride(int i = 5); protected: virtual void publicOverride(); @@ -517,7 +503,6 @@ private: class DLL_API HasOverridesWithChangedAccess : public HasOverridesWithChangedAccessBase { public: - HasOverridesWithChangedAccess(); void publicOverride(); private: virtual void privateOverride(int i); @@ -525,8 +510,6 @@ private: class DLL_API HasOverridesWithIncreasedProtectedAccess : public HasOverridesWithChangedAccess { -public: - HasOverridesWithIncreasedProtectedAccess(); protected: virtual void differentIncreasedAccessOverride(); }; @@ -534,7 +517,6 @@ protected: class DLL_API HasOverridesWithIncreasedAccess : public HasOverridesWithChangedAccess { public: - HasOverridesWithIncreasedAccess(); virtual void privateOverride(int i); virtual void differentIncreasedAccessOverride(); }; @@ -557,8 +539,6 @@ class DLL_API IgnoredTypeInheritingNonIgnoredWithNoEmptyCtor : public P class DLL_API HasOverriddenInManaged { public: - HasOverriddenInManaged(); - ~HasOverriddenInManaged(); void setOverriddenInManaged(Baz *value); int callOverriddenInManaged(); private: @@ -708,7 +688,6 @@ private: class DLL_API CallDtorVirtually : public HasVirtualDtor1 { public: - CallDtorVirtually(); ~CallDtorVirtually(); static bool Destroyed; static HasVirtualDtor1* getHasVirtualDtor1(HasVirtualDtor1* returned); @@ -728,8 +707,6 @@ protected: class DLL_API TestOverrideFromSecondaryBase : public Foo, public SecondaryBase { public: - TestOverrideFromSecondaryBase(); - ~TestOverrideFromSecondaryBase(); void VirtualMember(); void setProperty(int value); }; @@ -760,24 +737,16 @@ public: class DLL_API HasProtectedVirtual { -public: - HasProtectedVirtual(); protected: virtual void protectedVirtual(); }; class DLL_API InheritanceBuffer : public Foo, public HasProtectedVirtual { -public: - InheritanceBuffer(); - ~InheritanceBuffer(); }; class DLL_API InheritsProtectedVirtualFromSecondaryBase : public InheritanceBuffer { -public: - InheritsProtectedVirtualFromSecondaryBase(); - ~InheritsProtectedVirtualFromSecondaryBase(); protected: void protectedVirtual(); }; @@ -787,7 +756,6 @@ void DLL_API freeFunctionWithUnsupportedDefaultArg(Foo foo = Foo()); class DLL_API TypeMappedWithOperator { public: - TypeMappedWithOperator(); int operator |(int i); }; @@ -796,7 +764,6 @@ class HasOverrideOfHasPropertyWithDerivedType; class DLL_API HasPropertyWithDerivedType { public: - HasPropertyWithDerivedType(); HasOverrideOfHasPropertyWithDerivedType* hasPropertyWithDerivedTypeSubclass; virtual void causeRenamingError(); }; @@ -804,7 +771,6 @@ public: class DLL_API HasOverrideOfHasPropertyWithDerivedType : public HasPropertyWithDerivedType { public: - HasOverrideOfHasPropertyWithDerivedType(); virtual void causeRenamingError(); }; @@ -824,20 +790,16 @@ public: class DLL_API OverrideFromIndirectSecondaryBaseBase { public: - OverrideFromIndirectSecondaryBaseBase(); virtual int property(); }; class DLL_API OverrideFromDirectSecondaryBase : public Foo, public OverrideFromIndirectSecondaryBaseBase { -public: - OverrideFromDirectSecondaryBase(); }; class DLL_API OverrideFromIndirectSecondaryBase : public OverrideFromDirectSecondaryBase { public: - OverrideFromIndirectSecondaryBase(); int property(); }; @@ -850,7 +812,6 @@ public: class DLL_API TestOutTypeInterfaces { public: - TestOutTypeInterfaces(); void funcTryInterfaceTypePtrOut(CS_OUT TestParamToInterfacePassBaseTwo* classTry); void funcTryInterfaceTypeOut(CS_OUT TestParamToInterfacePassBaseTwo classTry); }; @@ -870,8 +831,6 @@ TemplateWithDependentField::TemplateWithDependentField() class DLL_API DerivesFromTemplateInstantiation : public TemplateWithDependentField { -public: - DerivesFromTemplateInstantiation(); }; DLL_API int PassConstantArrayRef(int(&arr)[2]); @@ -879,7 +838,6 @@ DLL_API int PassConstantArrayRef(int(&arr)[2]); class DLL_API TestComparison { public: - TestComparison(); int A; float B; bool operator ==(const TestComparison& other) const; @@ -888,7 +846,6 @@ public: class DLL_API OverridePropertyFromIndirectPrimaryBaseBase { public: - OverridePropertyFromIndirectPrimaryBaseBase(); virtual ~OverridePropertyFromIndirectPrimaryBaseBase(); virtual int property() = 0; virtual void setProperty(int value) = 0; @@ -897,21 +854,18 @@ public: class DLL_API OverridePropertyFromDirectPrimaryBase : public OverridePropertyFromIndirectPrimaryBaseBase { public: - OverridePropertyFromDirectPrimaryBase(); void setProperty(int value); }; class DLL_API OverridePropertyFromIndirectPrimaryBase : public OverridePropertyFromDirectPrimaryBase { public: - OverridePropertyFromIndirectPrimaryBase(); int property(); }; class DLL_API AbstractOverrideFromSecondaryBase : public Foo, public OverridePropertyFromIndirectPrimaryBaseBase { public: - AbstractOverrideFromSecondaryBase(); virtual ~AbstractOverrideFromSecondaryBase(); virtual void setProperty(int value) = 0; }; @@ -919,7 +873,6 @@ public: class DLL_API QObject { public: - QObject(); virtual ~QObject(); virtual void event(); }; @@ -928,7 +881,6 @@ class DLL_API QPaintDevice { public: QPaintDevice(); - ~QPaintDevice(); int test; virtual void changeVTableLayout(); }; @@ -937,7 +889,6 @@ class DLL_API QWidget : public QObject, QPaintDevice { public: QWidget(); - ~QWidget(); virtual void event(); private: QObject child; @@ -947,7 +898,6 @@ class DLL_API QPainter { public: QPainter(QPaintDevice& paintDevice); - ~QPainter(); }; class DLL_API QApplication : public QObject @@ -965,10 +915,9 @@ public: char* property(); }; -class InheritsFromHasSamePropertyInDerivedAbstractType : public HasSamePropertyInDerivedAbstractType +class DLL_API InheritsFromHasSamePropertyInDerivedAbstractType : public HasSamePropertyInDerivedAbstractType { public: - InheritsFromHasSamePropertyInDerivedAbstractType(); virtual ~InheritsFromHasSamePropertyInDerivedAbstractType(); virtual int property() = 0; }; @@ -998,7 +947,6 @@ public: class DLL_API VirtualDtorAddedInDerived : public Foo { public: - VirtualDtorAddedInDerived(); virtual ~VirtualDtorAddedInDerived(); static bool dtorCalled; }; @@ -1082,8 +1030,6 @@ class ForwardInOtherUnitButSameModule; class DLL_API HasVirtualTakesReturnsProblematicTypes { public: - HasVirtualTakesReturnsProblematicTypes(); - ~HasVirtualTakesReturnsProblematicTypes(); virtual const char* virtualTakesAndReturnsString(const char* c); const char* callsVirtualToReturnString(const char* c); virtual bool virtualTakesAndReturnsBool(bool b); @@ -1150,7 +1096,6 @@ class DLL_API TestString { public: TestString(); - ~TestString(); const wchar_t* unicodeConst; wchar_t* unicode; }; @@ -1189,24 +1134,18 @@ DLL_API void usesDecltypeFunctionPointer(funcPtr func); class DLL_API PrimaryBaseWithAbstractWithDefaultArg { public: - PrimaryBaseWithAbstractWithDefaultArg(); - ~PrimaryBaseWithAbstractWithDefaultArg(); virtual void abstractWithNoDefaultArg(const Foo& foo) = 0; }; class DLL_API SecondaryBaseWithAbstractWithDefaultArg { public: - SecondaryBaseWithAbstractWithDefaultArg(); - ~SecondaryBaseWithAbstractWithDefaultArg(); virtual void abstract(const Foo& foo = Foo()) = 0; }; class DLL_API HasSecondaryBaseWithAbstractWithDefaultArg : public PrimaryBaseWithAbstractWithDefaultArg, public SecondaryBaseWithAbstractWithDefaultArg { public: - HasSecondaryBaseWithAbstractWithDefaultArg(); - ~HasSecondaryBaseWithAbstractWithDefaultArg(); virtual void abstract(const Foo& foo = Foo()); virtual void abstractWithNoDefaultArg(const Foo& foo = Foo()); }; @@ -1214,21 +1153,18 @@ public: class DLL_API MissingObjectOnVirtualCallSecondaryBase { public: - MissingObjectOnVirtualCallSecondaryBase(); virtual int f(); }; class DLL_API MissingObjectOnVirtualCall : public HasVirtualDtor1, public MissingObjectOnVirtualCallSecondaryBase { public: - MissingObjectOnVirtualCall(); int f(); }; class DLL_API HasMissingObjectOnVirtualCall { public: - HasMissingObjectOnVirtualCall(); int makeMissingObjectOnVirtualCall(); void setMissingObjectOnVirtualCall(MissingObjectOnVirtualCall* value); private: @@ -1267,16 +1203,12 @@ private: class DLL_API HasBaseSetter { public: - HasBaseSetter(); - ~HasBaseSetter(); virtual void setBaseSetter(int value); }; class DLL_API HasGetterAndOverriddenSetter : public HasBaseSetter { public: - HasGetterAndOverriddenSetter(); - ~HasGetterAndOverriddenSetter(); void setBaseSetter(int value); int baseSetter(); protected: @@ -1343,7 +1275,6 @@ struct DLL_API ComplexArrayElement struct DLL_API HasComplexArray { - HasComplexArray(); ComplexArrayElement complexArray[ARRAY_LENGTH_MACRO]; }; @@ -1378,8 +1309,6 @@ inline namespace InlineNamespace class DLL_API TestArrays { public: - TestArrays(); - ~TestArrays(); int takeArrays(Foo* arrayOfPointersToObjects[], int arrayOfPrimitives[], Foo arrayOfObjects[]) const; int takeArrays(Foo* fixedArrayOfPointersToObjects[3], int fixedArrayOfPrimitives[4], int* fixedArrayOfPointersToPrimitives[5]) const; @@ -1398,8 +1327,6 @@ class TestForwardedClassInAnotherUnit class DLL_API HasFixedArrayOfPointers { public: - HasFixedArrayOfPointers(); - ~HasFixedArrayOfPointers(); Foo* fixedArrayOfPointers[3]; }; @@ -1414,8 +1341,6 @@ static int FOOBAR_CONSTANT = 42; class DLL_API SimpleInterface { public: - SimpleInterface(); - ~SimpleInterface(); virtual int size() const = 0; virtual int capacity() const = 0; virtual void* get(int n) = 0; @@ -1426,7 +1351,6 @@ class DLL_API InterfaceTester { public: InterfaceTester(); - ~InterfaceTester(); int capacity(); int size(); void* get(int n); @@ -1438,8 +1362,6 @@ private: class DLL_API HasFunctionPtrField { public: - HasFunctionPtrField(); - ~HasFunctionPtrField(); int (*functionPtrField)(const char*); int (*functionPtrTakeFunctionPtrField)(int(*TakenInFuncPtrField)()); }; @@ -1510,7 +1432,6 @@ struct DLL_API ClassZeroAllocatedMemoryTest struct DLL_API ConversionFunctions { - ConversionFunctions(); operator short* (); operator short& (); operator short(); diff --git a/tests/CSharp/CSharpTemplates.cpp b/tests/CSharp/CSharpTemplates.cpp index bbf955f1..2ae88924 100644 --- a/tests/CSharp/CSharpTemplates.cpp +++ b/tests/CSharp/CSharpTemplates.cpp @@ -23,22 +23,6 @@ void T2::setField(int value) field = value; } -DerivedFromSpecializationOfUnsupportedTemplate::DerivedFromSpecializationOfUnsupportedTemplate() -{ -} - -DerivedFromSpecializationOfUnsupportedTemplate::~DerivedFromSpecializationOfUnsupportedTemplate() -{ -} - -HasDefaultTemplateArgument::HasDefaultTemplateArgument() -{ -} - -HasDefaultTemplateArgument::~HasDefaultTemplateArgument() -{ -} - bool HasDefaultTemplateArgument::property() { return field; @@ -61,22 +45,6 @@ void HasDefaultTemplateArgument::setStaticProperty(const bool& t) bool HasDefaultTemplateArgument::staticField; -DerivesFromExplicitSpecialization::DerivesFromExplicitSpecialization() -{ -} - -DerivesFromExplicitSpecialization::~DerivesFromExplicitSpecialization() -{ -} - -HasVirtualTemplate::HasVirtualTemplate() -{ -} - -HasVirtualTemplate::~HasVirtualTemplate() -{ -} - VirtualTemplate HasVirtualTemplate::getVCopy() { return *v; @@ -92,26 +60,6 @@ int HasVirtualTemplate::function() return v->function(); } -SpecializedInterfaceForMap::SpecializedInterfaceForMap() -{ -} - -SpecializedInterfaceForMap::~SpecializedInterfaceForMap() -{ -} - -HasSpecializationForSecondaryBase::HasSpecializationForSecondaryBase() -{ -} - -HasSpecializationForSecondaryBase::~HasSpecializationForSecondaryBase() -{ -} - -TemplateSpecializer::TemplateSpecializer() -{ -} - IndependentFields TemplateSpecializer::getIndependentFields() { return IndependentFields(); @@ -141,14 +89,6 @@ VirtualTemplate TemplateSpecializer::returnSpecializedWithVoid() return VirtualTemplate(); } -RegularDynamic::RegularDynamic() -{ -} - -RegularDynamic::~RegularDynamic() -{ -} - void RegularDynamic::virtualFunction() { } diff --git a/tests/CSharp/CSharpTemplates.h b/tests/CSharp/CSharpTemplates.h index 78cd32c8..6dc19710 100644 --- a/tests/CSharp/CSharpTemplates.h +++ b/tests/CSharp/CSharpTemplates.h @@ -6,6 +6,12 @@ #include #include +class DeriveProtectedDtor +{ +protected: + ~DeriveProtectedDtor() {} +}; + class DLL_API QString { }; @@ -249,9 +255,6 @@ DependentValueFields DependentValueFields::operator+(const DependentValueF class DLL_API DerivedFromSpecializationOfUnsupportedTemplate : public DependentValueFields { -public: - DerivedFromSpecializationOfUnsupportedTemplate(); - ~DerivedFromSpecializationOfUnsupportedTemplate(); }; template @@ -346,8 +349,6 @@ template <> class DLL_API HasDefaultTemplateArgument { public: - HasDefaultTemplateArgument(); - ~HasDefaultTemplateArgument(); bool property(); void setProperty(const bool& t); static bool staticProperty(); @@ -432,9 +433,6 @@ DerivesFromTemplateWithExplicitSpecialization::~DerivesFromTemplateWithExp class DLL_API DerivesFromExplicitSpecialization : public DerivesFromTemplateWithExplicitSpecialization { -public: - DerivesFromExplicitSpecialization(); - ~DerivesFromExplicitSpecialization(); }; template @@ -455,6 +453,7 @@ class TemplateWithIndexer { public: TemplateWithIndexer(); + ~TemplateWithIndexer(); T& operator[](int i); T& operator[](const T& key); T& operator[](const char* string); @@ -470,6 +469,11 @@ TemplateWithIndexer::TemplateWithIndexer() { } +template +TemplateWithIndexer::~TemplateWithIndexer() +{ +} + template T& TemplateWithIndexer::operator[](int i) { @@ -542,8 +546,6 @@ T* VirtualTemplate::function(T* t) class DLL_API HasVirtualTemplate { public: - HasVirtualTemplate(); - ~HasVirtualTemplate(); VirtualTemplate getVCopy(); void setV(VirtualTemplate* value); int function(); @@ -554,18 +556,12 @@ private: class DLL_API SpecializedInterfaceForMap : public InternalWithExtension { -public: - SpecializedInterfaceForMap(); - ~SpecializedInterfaceForMap(); }; class DLL_API HasSpecializationForSecondaryBase : public DependentValueFields, public IndependentFields, public InternalWithExtension { -public: - HasSpecializationForSecondaryBase(); - ~HasSpecializationForSecondaryBase(); }; template @@ -574,7 +570,6 @@ class TemplateInAnotherUnit; class DLL_API TemplateSpecializer { public: - TemplateSpecializer(); template class NestedTemplate { @@ -652,8 +647,6 @@ struct MapResultType, MapFunctor> class DLL_API RegularDynamic { public: - RegularDynamic(); - ~RegularDynamic(); virtual void virtualFunction(); }; @@ -789,37 +782,6 @@ template<> inline void* qbswap<1>(const void *source, size_t count, void *dest) return 0; } -// force the symbols for the template instantiations because we do not have the auto-compilation for the generated C++ source -template class DLL_API IndependentFields; -template class DLL_API IndependentFields; -template class DLL_API IndependentFields; -template class DLL_API IndependentFields; -template class DLL_API IndependentFields; -template class DLL_API Base; -template class DLL_API DependentValueFields; -template class DLL_API DependentValueFields; -template class DLL_API DependentValueFields; -template class DLL_API DependentValueFields; -template class DLL_API DependentPointerFields; -template class DLL_API VirtualTemplate; -template class DLL_API VirtualTemplate; -template class DLL_API HasDefaultTemplateArgument; -template class DLL_API DerivedChangesTypeName; -template class DLL_API TemplateWithIndexer; -template class DLL_API TemplateWithIndexer; -template class DLL_API TemplateWithIndexer; -template class DLL_API TemplateWithIndexer; -template class DLL_API TemplateWithIndexer; -template class DLL_API TemplateWithIndexer; -template class DLL_API TemplateWithIndexer; -template class DLL_API TemplateDerivedFromRegularDynamic; -template class DLL_API HasCtorWithMappedToEnum; -template class DLL_API TwoTemplateArgs; -template class DLL_API TwoTemplateArgs; -template class DLL_API TwoTemplateArgs; -template class DLL_API TwoTemplateArgs; -template class DLL_API TwoTemplateArgs; - class TestForwardedClassInAnotherUnit; // Forward declaration of class as friend diff --git a/tests/Common/Common.cpp b/tests/Common/Common.cpp index d6bade92..8f7ddd9d 100644 --- a/tests/Common/Common.cpp +++ b/tests/Common/Common.cpp @@ -1,42 +1,6 @@ #include "Common.h" #include -TestPacking::TestPacking() -{ -} - -TestPacking1::TestPacking1() -{ -} - -TestPacking1::~TestPacking1() -{ -} - -TestPacking2::TestPacking2() -{ -} - -TestPacking2::~TestPacking2() -{ -} - -TestPacking4::TestPacking4() -{ -} - -TestPacking4::~TestPacking4() -{ -} - -TestPacking8::TestPacking8() -{ -} - -TestPacking8::~TestPacking8() -{ -} - Foo::NestedAbstract::~NestedAbstract() { } @@ -76,7 +40,7 @@ void Foo::TakesTypedefedPtr(FooPtr date) { } -int Foo::TakesRef(const Foo &other) +int Foo::TakesRef(const Foo& other) { return other.A; } @@ -111,7 +75,7 @@ Foo2 Foo2::operator<<(signed int i) Foo2 Foo2::operator<<(signed long l) { - return *this << (signed int) l; + return *this << (signed int)l; } char Foo2::testCharMarshalling(char c) @@ -155,10 +119,6 @@ bool operator ==(Bar::Item item, const Bar& bar) return item == bar.RetItem1(); } -Bar2::Nested::Nested() -{ -} - Bar2::Nested::operator int() const { return 300; @@ -189,16 +149,6 @@ Foo2 Bar2::needFixedInstance() const return f; } -Hello::Hello () -{ - //cout << "Ctor!" << "\n"; -} - -Hello::Hello(const Hello& hello) -{ - -} - void Hello::PrintHello(const char* s) { //cout << "PrintHello: " << s << "\n"; @@ -315,28 +265,28 @@ void Hello::EnumInOutRef(Enum& e) void Hello::StringOut(CS_OUT const char** str) { - *str = "HelloStringOut"; + *str = "HelloStringOut"; } void Hello::StringOutRef(CS_OUT const char*& str) { - str = "HelloStringOutRef"; + str = "HelloStringOutRef"; } void Hello::StringInOut(CS_IN_OUT const char** str) { - if (strcmp(*str, "Hello") == 0) - *str = "StringInOut"; - else - *str = "Failed"; + if (strcmp(*str, "Hello") == 0) + *str = "StringInOut"; + else + *str = "Failed"; } void Hello::StringInOutRef(CS_IN_OUT const char*& str) { - if (strcmp(str, "Hello") == 0) - str = "StringInOutRef"; - else - str = "Failed"; + if (strcmp(str, "Hello") == 0) + str = "StringInOutRef"; + else + str = "Failed"; } void Hello::StringTypedef(const TypedefChar* str) @@ -386,18 +336,6 @@ AbstractFoo::~AbstractFoo() { } -ImplementsAbstractFoo::ImplementsAbstractFoo() -{ -} - -ImplementsAbstractFoo::ImplementsAbstractFoo(const ImplementsAbstractFoo& other) -{ -} - -ImplementsAbstractFoo::~ImplementsAbstractFoo() -{ -} - int ImplementsAbstractFoo::pureFunction(typedefInOverride i) { return 5; @@ -413,10 +351,6 @@ int ImplementsAbstractFoo::pureFunction2(bool* ok) return 15; } -ReturnsAbstractFoo::ReturnsAbstractFoo() {} - -ReturnsAbstractFoo::~ReturnsAbstractFoo() {} - const AbstractFoo& ReturnsAbstractFoo::getFoo() { return i; @@ -431,10 +365,6 @@ Ex2* DerivedException::clone() return 0; } -DefaultParameters::DefaultParameters() -{ -} - void DefaultParameters::Foo(int a, int b) { } @@ -451,10 +381,6 @@ void DefaultParameters::Bar() { } -common::common() -{ -} - int test(common& s) { return 5; @@ -465,7 +391,7 @@ int operator *(TestMoveOperatorToClass klass, int b) return klass.A * b; } -TestMoveOperatorToClass::TestMoveOperatorToClass() +TestMoveOperatorToClass::TestMoveOperatorToClass() { } @@ -495,14 +421,6 @@ void va_listFunction(va_list v) { } -TestNestedTypes::TestNestedTypes() -{ -} - -TestNestedTypes::~TestNestedTypes() -{ -} - void TestDelegates::MarshalUnattributedDelegate(DelegateInGlobalNamespace del) { } @@ -530,12 +448,12 @@ int (*TestDelegates::MarshalAnonymousDelegate4())(int n) return f; } -int TestDelegates::MarshalAnonymousDelegate5(int (STDCALL *del)(int)) +int TestDelegates::MarshalAnonymousDelegate5(int (STDCALL* del)(int)) { return del(2); } -int TestDelegates::MarshalAnonymousDelegate6(int (STDCALL *del)(int)) +int TestDelegates::MarshalAnonymousDelegate6(int (STDCALL* del)(int)) { return del(3); } @@ -545,17 +463,17 @@ ClassA::ClassA(int value) Value = value; } -ClassB::ClassB(const ClassA &x) +ClassB::ClassB(const ClassA& x) { Value = x.Value; } -ClassC::ClassC(const ClassA *x) +ClassC::ClassC(const ClassA* x) { Value = x->Value; } -ClassC::ClassC(const ClassB &x) +ClassC::ClassC(const ClassB& x) { Value = x.Value; } @@ -596,14 +514,6 @@ void DelegateNamespace::f2(void (*)()) { } -HasStdString::HasStdString() -{ -} - -HasStdString::~HasStdString() -{ -} - std::string HasStdString::testStdString(const std::string& s) { return s + "_test"; @@ -629,10 +539,10 @@ int Function() } TestProperties::TestProperties() : Field(0), ArchiveName(0), - FieldValue(0), _refToPrimitiveInSetter(0), - _getterAndSetterWithTheSameName(0), _setterReturnsBoolean(0), - _virtualSetterReturnsBoolean(0), _conflict(Conflict::Value1), - ConstRefField(Field) +FieldValue(0), _refToPrimitiveInSetter(0), +_getterAndSetterWithTheSameName(0), _setterReturnsBoolean(0), +_virtualSetterReturnsBoolean(0), _conflict(Conflict::Value1), +ConstRefField(Field) { } @@ -822,11 +732,6 @@ int TestProperties::GetArchiveName() const { return 20; } - -HasOverridenSetter::HasOverridenSetter() -{ -} - void HasOverridenSetter::setVirtual(bool value) { } @@ -885,23 +790,13 @@ Bar& TestIndexedProperties::operator[](const Foo& key) return bar; } -TestVariables::TestVariables() -{ -} - int TestVariables::VALUE; void TestVariables::SetValue(int value) { VALUE = value; } -TestWideStrings::TestWideStrings() -{ -} - LPCWSTR TestWideStrings::GetWidePointer() { return L"Hello"; } LPCWSTR TestWideStrings::GetWideNullPointer() { return 0; } -TestFixedArrays::TestFixedArrays() {} - InternalCtorAmbiguity::InternalCtorAmbiguity(void* param) { // cause a crash to indicate this is the incorrect ctor to invoke @@ -989,10 +884,6 @@ void HasVirtualProperty::setProtectedProperty(int value) { } -ChangedAccessOfInheritedProperty::ChangedAccessOfInheritedProperty() -{ -} - int ChangedAccessOfInheritedProperty::getProperty() { return 2; @@ -1011,19 +902,11 @@ void ChangedAccessOfInheritedProperty::setProtectedProperty(int value) { } -ReturnsEmpty::ReturnsEmpty() -{ -} - Empty ReturnsEmpty::getEmpty() { return Empty(); } -RefTypeClassPassTry::RefTypeClassPassTry() -{ -} - void funcTryRefTypePtrOut(CS_OUT RefTypeClassPassTry* classTry) { } @@ -1044,10 +927,6 @@ HasProblematicFields::HasProblematicFields() : b(false), c(0) { } -HasVirtualReturningHasProblematicFields::HasVirtualReturningHasProblematicFields() -{ -} - HasProblematicFields HasVirtualReturningHasProblematicFields::returnsProblematicFields() { return HasProblematicFields(); @@ -1067,45 +946,20 @@ int DerivedClassVirtual::retInt(const Foo2& foo) { return 2; } - -DerivedClassAbstractVirtual::~DerivedClassAbstractVirtual() -{ -} - -DerivedClassOverrideAbstractVirtual::DerivedClassOverrideAbstractVirtual() -{ -} - int DerivedClassOverrideAbstractVirtual::retInt(const Foo& foo) { return 1; } -BufferForVirtualFunction::BufferForVirtualFunction() -{ -} - -OverridesNonDirectVirtual::OverridesNonDirectVirtual() -{ -} - int OverridesNonDirectVirtual::retInt(const Foo& foo) { return 3; } -AbstractWithVirtualDtor::AbstractWithVirtualDtor() -{ -} - AbstractWithVirtualDtor::~AbstractWithVirtualDtor() { } -NonTrivialDtorBase::NonTrivialDtorBase() -{ -} - NonTrivialDtorBase::~NonTrivialDtorBase() { } @@ -1132,19 +986,11 @@ void NonTrivialDtor::setDtorCalled(bool value) bool NonTrivialDtor::dtorCalled = false; -DerivedFromTemplateInstantiationWithVirtual::DerivedFromTemplateInstantiationWithVirtual() -{ -} - int func_union(union_t u) { return u.c; } -HasProtectedEnum::HasProtectedEnum() -{ -} - void HasProtectedEnum::function(ProtectedEnum param) { } @@ -1157,18 +1003,6 @@ void FuncWithTemplateTypeAlias(TypeAliasTemplate i) { } -HasAbstractOperator::~HasAbstractOperator() -{ -} - -HasOverloadsWithDifferentPointerKindsToSameType::HasOverloadsWithDifferentPointerKindsToSameType() -{ -} - -HasOverloadsWithDifferentPointerKindsToSameType::~HasOverloadsWithDifferentPointerKindsToSameType() -{ -} - void HasOverloadsWithDifferentPointerKindsToSameType::overload(int& i) { } @@ -1239,7 +1073,7 @@ HasCopyAndMoveConstructor::HasCopyAndMoveConstructor(int value) field = value; } -HasCopyAndMoveConstructor::HasCopyAndMoveConstructor(const HasCopyAndMoveConstructor &other) +HasCopyAndMoveConstructor::HasCopyAndMoveConstructor(const HasCopyAndMoveConstructor& other) { field = other.field; } @@ -1249,31 +1083,11 @@ HasCopyAndMoveConstructor::HasCopyAndMoveConstructor(HasCopyAndMoveConstructor&& field = other.field; } -HasCopyAndMoveConstructor::~HasCopyAndMoveConstructor() -{ -} - int HasCopyAndMoveConstructor::getField() { return field; } -HasVirtualFunctionsWithStringParams::HasVirtualFunctionsWithStringParams() -{ -} - -HasVirtualFunctionsWithStringParams::~HasVirtualFunctionsWithStringParams() -{ -} - -ImplementsVirtualFunctionsWithStringParams::ImplementsVirtualFunctionsWithStringParams() -{ -} - -ImplementsVirtualFunctionsWithStringParams::~ImplementsVirtualFunctionsWithStringParams() -{ -} - void ImplementsVirtualFunctionsWithStringParams::PureVirtualFunctionWithStringParams(std::string testString1, std::string testString2) { } @@ -1283,14 +1097,6 @@ int HasVirtualFunctionsWithStringParams::VirtualFunctionWithStringParam(std::str return 5; } -HasVirtualFunctionWithBoolParams::HasVirtualFunctionWithBoolParams() -{ -} - -HasVirtualFunctionWithBoolParams::~HasVirtualFunctionWithBoolParams() -{ -} - bool HasVirtualFunctionWithBoolParams::virtualFunctionWithBoolParamAndReturnsBool(bool testBool) { return testBool; @@ -1300,10 +1106,6 @@ HasProtectedCtorWithProtectedParam::HasProtectedCtorWithProtectedParam(Protected { } -SecondaryBaseWithIgnoredVirtualMethod::SecondaryBaseWithIgnoredVirtualMethod() -{ -} - SecondaryBaseWithIgnoredVirtualMethod::~SecondaryBaseWithIgnoredVirtualMethod() { } @@ -1316,10 +1118,6 @@ void SecondaryBaseWithIgnoredVirtualMethod::ignored(const IgnoredType& ignoredPa { } -DerivedFromSecondaryBaseWithIgnoredVirtualMethod::DerivedFromSecondaryBaseWithIgnoredVirtualMethod() -{ -} - DerivedFromSecondaryBaseWithIgnoredVirtualMethod::~DerivedFromSecondaryBaseWithIgnoredVirtualMethod() { } @@ -1336,24 +1134,6 @@ AmbiguousParamNames::AmbiguousParamNames(int instance, int in) { } -AmbiguousParamNames::~AmbiguousParamNames() -{ -} - -HasPropertyNamedAsParent::HasPropertyNamedAsParent() -{ -} - -HasPropertyNamedAsParent::~HasPropertyNamedAsParent() -{ -} - -ReturnByValueWithReturnParam::ReturnByValueWithReturnParam() {} - -ReturnByValueWithReturnParam::ReturnByValueWithReturnParam(const ReturnByValueWithReturnParam& other) : _ptr(other._ptr) {} - -ReturnByValueWithReturnParam::~ReturnByValueWithReturnParam() {} - int ReturnByValueWithReturnParam::getUseCount() { return _ptr.use_count(); } ReturnByValueWithReturnParam ReturnByValueWithReturnParamFactory::generate() @@ -1410,7 +1190,7 @@ LPCSTR TakeTypedefedMappedType(LPCSTR string) return UTF8.data(); } -StructWithCopyCtor::StructWithCopyCtor() {} +StructWithCopyCtor::StructWithCopyCtor() : mBits(0) {} StructWithCopyCtor::StructWithCopyCtor(const StructWithCopyCtor& other) : mBits(other.mBits) {} uint16_t TestStructWithCopyCtorByValue(StructWithCopyCtor s) @@ -1426,30 +1206,14 @@ DerivedCovariant::~DerivedCovariant() { } -NonPrimitiveType::NonPrimitiveType() -{ -} - int NonPrimitiveType::GetFoo() { return foo; } -TestFixedNonPrimitiveArrays::TestFixedNonPrimitiveArrays() -{ -} - -TestGetterSetterToProperties::TestGetterSetterToProperties() -{ -} - int TestGetterSetterToProperties::getWidth() { return 640; } int TestGetterSetterToProperties::getHeight() { return 480; } -PointerToTypedefPointerTest::PointerToTypedefPointerTest() -{ -} - void DLL_API PointerToTypedefPointerTestMethod(LPPointerToTypedefPointerTest* lp, int valToSet) { (*(*lp)).val = valToSet; @@ -1465,7 +1229,7 @@ TestArraysPointers::TestArraysPointers(MyEnum* values, int count) if (values && count) Value = values[0]; } -TestCopyConstructorRef::TestCopyConstructorRef() +TestCopyConstructorRef::TestCopyConstructorRef() : A(0), B(0) { } @@ -1478,10 +1242,6 @@ TestCopyConstructorRef::TestCopyConstructorRef(const TestCopyConstructorRef& oth SomeStruct::SomeStruct() : p(1) {} -ClassWithOverloadedOperators::ClassWithOverloadedOperators() { - -} - ClassWithOverloadedOperators::ClassWithOverloadedOperators::operator char() { return 1; } ClassWithOverloadedOperators::operator int() { return 2; } ClassWithOverloadedOperators::operator short() { return 3; } diff --git a/tests/Common/Common.h b/tests/Common/Common.h index 80f21d93..c7fa4c99 100644 --- a/tests/Common/Common.h +++ b/tests/Common/Common.h @@ -14,39 +14,26 @@ public: int i1; int i2; bool b; - TestPacking(); }; #pragma pack(1) class DLL_API TestPacking1: public TestPacking { -public: - TestPacking1(); - ~TestPacking1(); }; #pragma pack(2) class DLL_API TestPacking2: public TestPacking { -public: - TestPacking2(); - ~TestPacking2(); }; #pragma pack(4) class DLL_API TestPacking4: public TestPacking { -public: - TestPacking4(); - ~TestPacking4(); }; #pragma pack(8) class DLL_API TestPacking8: public TestPacking { -public: - TestPacking8(); - ~TestPacking8(); }; #pragma pack() @@ -76,7 +63,7 @@ public: EmptyEnum2 }; - class NestedAbstract + class DLL_API NestedAbstract { public: virtual ~NestedAbstract(); @@ -171,7 +158,6 @@ struct DLL_API Bar2 : public Bar struct DLL_API Nested { - Nested(); operator int() const; }; @@ -215,9 +201,6 @@ public: long l; }; - Hello (); - Hello(const Hello& hello); - void PrintHello(const char* s); bool test1(int i, float f); int add(int a, int b); @@ -268,9 +251,6 @@ public: class DLL_API ImplementsAbstractFoo : public AbstractFoo { public: - ImplementsAbstractFoo(); - ImplementsAbstractFoo(const ImplementsAbstractFoo& other); - ~ImplementsAbstractFoo(); typedef int typedefInOverride; virtual int pureFunction(typedefInOverride i = 0); virtual int pureFunction1(); @@ -281,8 +261,6 @@ private: class DLL_API ReturnsAbstractFoo { public: - ReturnsAbstractFoo(); - ~ReturnsAbstractFoo(); const AbstractFoo& getFoo(); private: @@ -314,7 +292,6 @@ struct DLL_API DerivedException : public Exception // Tests for ambiguous call to native functions with default parameters struct DLL_API DefaultParameters { - DefaultParameters(); void Foo(int a, int b = 0); void Foo(int a); @@ -337,8 +314,6 @@ class Derived : public Base // Tests the MoveFunctionToClassPass class DLL_API common { -public: - common(); }; DLL_API int test(common& s); @@ -511,8 +486,6 @@ namespace SomeNamespace class DLL_API ClassWithOverloadedOperators { public: - ClassWithOverloadedOperators(); - operator char(); operator int(); operator short(); @@ -611,7 +584,6 @@ private: class DLL_API HasOverridenSetter : public TestProperties { public: - HasOverridenSetter(); void setVirtual(bool value) override; int virtualSetterReturnsBoolean() override; @@ -666,7 +638,6 @@ public: // Tests variables struct DLL_API TestVariables { - TestVariables(); static int VALUE; void SetValue(int value = VALUE); }; @@ -674,7 +645,6 @@ struct DLL_API TestVariables typedef const wchar_t * LPCWSTR; struct DLL_API TestWideStrings { - TestWideStrings(); LPCWSTR GetWidePointer(); LPCWSTR GetWideNullPointer(); }; @@ -686,7 +656,6 @@ typedef void (*VoidPtrRetFunctionTypedef) (); class DLL_API TestFixedArrays { public: - TestFixedArrays(); VoidPtrRetFunctionTypedef Array[10]; #ifndef _MSC_VER TestWideStrings ZeroSizedClassArray[0]; @@ -706,7 +675,6 @@ public: class DLL_API NonPrimitiveType { public: - NonPrimitiveType(); int GetFoo(); int foo; @@ -715,13 +683,11 @@ public: class DLL_API TestFixedNonPrimitiveArrays { public: - TestFixedNonPrimitiveArrays(); NonPrimitiveType NonPrimitiveTypeArray[3]; }; struct DLL_API TestGetterSetterToProperties { - TestGetterSetterToProperties(); int getWidth(); int getHeight(); }; @@ -800,8 +766,6 @@ DLL_API void va_listFunction(va_list v); struct DLL_API TestNestedTypes { public: - TestNestedTypes(); - ~TestNestedTypes(); union as_types { int as_int; @@ -822,8 +786,6 @@ public: class DLL_API HasStdString { public: - HasStdString(); - ~HasStdString(); std::string testStdString(const std::string& s); std::string testStdStringPassedByValue(std::string s); std::string s; @@ -895,8 +857,6 @@ public: class DLL_API RefTypeClassPassTry { -public: - RefTypeClassPassTry(); }; void DLL_API funcTryRefTypePtrOut(CS_OUT RefTypeClassPassTry* classTry); @@ -925,7 +885,6 @@ protected: class DLL_API ChangedAccessOfInheritedProperty : public HasVirtualProperty { public: - ChangedAccessOfInheritedProperty(); int getProtectedProperty(); void setProtectedProperty(int value); protected: @@ -940,7 +899,6 @@ class DLL_API Empty class DLL_API ReturnsEmpty { public: - ReturnsEmpty(); Empty getEmpty(); }; @@ -960,7 +918,6 @@ public: class DLL_API HasVirtualReturningHasProblematicFields { public: - HasVirtualReturningHasProblematicFields(); virtual HasProblematicFields returnsProblematicFields(); }; @@ -982,27 +939,22 @@ public: class DLL_API DerivedClassAbstractVirtual : public DerivedClassVirtual { public: - ~DerivedClassAbstractVirtual(); virtual int retInt(const Foo& foo) = 0; }; class DLL_API DerivedClassOverrideAbstractVirtual : public DerivedClassAbstractVirtual { public: - DerivedClassOverrideAbstractVirtual(); virtual int retInt(const Foo& foo); }; class DLL_API BufferForVirtualFunction : public BaseClassVirtual { -public: - BufferForVirtualFunction(); }; class DLL_API OverridesNonDirectVirtual : public BufferForVirtualFunction { public: - OverridesNonDirectVirtual(); virtual int retInt(const Foo& foo); }; @@ -1080,7 +1032,6 @@ AbstractTemplate::AbstractTemplate() class DLL_API AbstractWithVirtualDtor { public: - AbstractWithVirtualDtor(); virtual ~AbstractWithVirtualDtor(); virtual void abstract() = 0; }; @@ -1088,7 +1039,6 @@ public: class DLL_API NonTrivialDtorBase { public: - NonTrivialDtorBase(); ~NonTrivialDtorBase(); }; @@ -1143,8 +1093,6 @@ int FunctionTemplateWithDependentTypeDefaultExpr(size_t size = sizeof(T)) { class DLL_API DerivedFromTemplateInstantiationWithVirtual : public TemplateWithVirtual { -public: - DerivedFromTemplateInstantiationWithVirtual(); }; typedef union @@ -1156,8 +1104,6 @@ int DLL_API func_union(union_t u); class DLL_API HasProtectedEnum { -public: - HasProtectedEnum(); protected: enum class ProtectedEnum { @@ -1207,7 +1153,6 @@ private: class DLL_API HasAbstractOperator { public: - ~HasAbstractOperator(); virtual bool operator==(const HasAbstractOperator& other) = 0; }; @@ -1267,8 +1212,6 @@ enum class DLL_API HasOverloadsWithDifferentPointerKindsToSameType { public: - HasOverloadsWithDifferentPointerKindsToSameType(); - ~HasOverloadsWithDifferentPointerKindsToSameType(); void overload(int& i); void overload(int&& i); void overload(const int& i); @@ -1294,7 +1237,6 @@ public: HasCopyAndMoveConstructor(int value); HasCopyAndMoveConstructor(const HasCopyAndMoveConstructor& other); HasCopyAndMoveConstructor(HasCopyAndMoveConstructor&& other); - ~HasCopyAndMoveConstructor(); int getField(); private: int field; @@ -1303,8 +1245,6 @@ private: class DLL_API HasVirtualFunctionsWithStringParams { public: - HasVirtualFunctionsWithStringParams(); - ~HasVirtualFunctionsWithStringParams(); virtual void PureVirtualFunctionWithStringParams(std::string testString1, std::string testString2) = 0; virtual int VirtualFunctionWithStringParam(std::string testString); }; @@ -1312,16 +1252,12 @@ public: class DLL_API ImplementsVirtualFunctionsWithStringParams : public HasVirtualFunctionsWithStringParams { public: - ImplementsVirtualFunctionsWithStringParams(); - ~ImplementsVirtualFunctionsWithStringParams(); virtual void PureVirtualFunctionWithStringParams(std::string testString1, std::string testString2); }; class DLL_API HasVirtualFunctionWithBoolParams { public: - HasVirtualFunctionWithBoolParams(); - ~HasVirtualFunctionWithBoolParams(); virtual bool virtualFunctionWithBoolParamAndReturnsBool(bool testBool); }; @@ -1338,7 +1274,7 @@ protected: class DLL_API SecondaryBaseWithIgnoredVirtualMethod { public: - SecondaryBaseWithIgnoredVirtualMethod(); + // HACK: do not delete: work around https://github.com/mono/CppSharp/issues/1534 ~SecondaryBaseWithIgnoredVirtualMethod(); virtual void generated(); virtual void ignored(const IgnoredType& ignoredParam); @@ -1347,7 +1283,7 @@ public: class DLL_API DerivedFromSecondaryBaseWithIgnoredVirtualMethod : public Foo, public SecondaryBaseWithIgnoredVirtualMethod { public: - DerivedFromSecondaryBaseWithIgnoredVirtualMethod(); + // HACK: do not delete: work around https://github.com/mono/CppSharp/issues/1534 ~DerivedFromSecondaryBaseWithIgnoredVirtualMethod(); void generated(); void ignored(const IgnoredType& ignoredParam); @@ -1357,23 +1293,17 @@ class DLL_API AmbiguousParamNames { public: AmbiguousParamNames(int instance, int in); - ~AmbiguousParamNames(); }; class DLL_API HasPropertyNamedAsParent { public: - HasPropertyNamedAsParent(); - ~HasPropertyNamedAsParent(); int hasPropertyNamedAsParent; }; class DLL_API ReturnByValueWithReturnParam { public: - ReturnByValueWithReturnParam(); - ReturnByValueWithReturnParam(const ReturnByValueWithReturnParam& other); - ~ReturnByValueWithReturnParam(); int getUseCount(); private: @@ -1577,7 +1507,6 @@ QScopedPointer d_ptr; struct DLL_API PointerToTypedefPointerTest { - PointerToTypedefPointerTest(); int val; }; typedef PointerToTypedefPointerTest *LPPointerToTypedefPointerTest; diff --git a/tests/Encodings/Encodings.cpp b/tests/Encodings/Encodings.cpp index 7c4289e8..3e8ace21 100644 --- a/tests/Encodings/Encodings.cpp +++ b/tests/Encodings/Encodings.cpp @@ -2,14 +2,6 @@ std::string Foo::StringVariable = ""; -Foo::Foo() -{ -} - -Foo::~Foo() -{ -} - // TODO: move this, it has nothing to do with Unicode, it's here only not to break the CLI branch int Foo::operator[](int i) const { diff --git a/tests/Encodings/Encodings.h b/tests/Encodings/Encodings.h index 9ab7efd4..3fe2203d 100644 --- a/tests/Encodings/Encodings.h +++ b/tests/Encodings/Encodings.h @@ -4,9 +4,6 @@ class DLL_API Foo { public: - Foo(); - ~Foo(); - const char* Unicode; static std::string StringVariable; diff --git a/tests/NamespacesBase/NamespacesBase.cpp b/tests/NamespacesBase/NamespacesBase.cpp index 51757f77..c6365348 100644 --- a/tests/NamespacesBase/NamespacesBase.cpp +++ b/tests/NamespacesBase/NamespacesBase.cpp @@ -41,14 +41,6 @@ int HasVirtualInCore::virtualInCore(int parameter) return 1; } -SecondaryBase::SecondaryBase() -{ -} - -SecondaryBase::~SecondaryBase() -{ -} - void SecondaryBase::function() { } diff --git a/tests/NamespacesBase/NamespacesBase.h b/tests/NamespacesBase/NamespacesBase.h index 29709a02..99838835 100644 --- a/tests/NamespacesBase/NamespacesBase.h +++ b/tests/NamespacesBase/NamespacesBase.h @@ -13,11 +13,6 @@ namespace OverlappingNamespace class DLL_API InBaseLib { - public: - InBaseLib() - { - - }; }; } @@ -115,10 +110,5 @@ typedef DerivedFromSecondaryBaseInDependency RenameDerivedBeforeBase; class DLL_API SecondaryBase { public: - SecondaryBase(); - ~SecondaryBase(); void function(); }; - -// force the symbols for the template instantiations because we do not have the auto-compilation for the generated C++ source -template class DLL_API TemplateClass; diff --git a/tests/NamespacesDerived/NamespacesDerived.Gen.cs b/tests/NamespacesDerived/NamespacesDerived.Gen.cs index 3cf6eaaa..27adc4a4 100644 --- a/tests/NamespacesDerived/NamespacesDerived.Gen.cs +++ b/tests/NamespacesDerived/NamespacesDerived.Gen.cs @@ -23,7 +23,7 @@ namespace CppSharp.Tests module.IncludeDirs.Add(Path.GetFullPath(GetTestsDirectory(@base))); module.Headers.Add($"{@base}.h"); module.OutputNamespace = @base; - module.LibraryDirs.Add(driver.Options.OutputDir); + module.LibraryDirs.AddRange(driver.Options.Modules[1].LibraryDirs); module.Libraries.Add($"{@base}.Native"); driver.Options.Modules[1].Dependencies.Add(module); } diff --git a/tests/NamespacesDerived/NamespacesDerived.cpp b/tests/NamespacesDerived/NamespacesDerived.cpp index ebcfba01..29c549e7 100644 --- a/tests/NamespacesDerived/NamespacesDerived.cpp +++ b/tests/NamespacesDerived/NamespacesDerived.cpp @@ -33,14 +33,6 @@ void Derived::setNestedNSComponent(OverlappingNamespace::InBaseLib c) nestedNSComponent = c; } -Derived2::Derived2() -{ -} - -Derived2::~Derived2() -{ -} - Base3 Derived2::getBase() { return baseComponent; @@ -85,32 +77,16 @@ DerivedFromExternalSpecialization::DerivedFromExternalSpecialization(int i, { } -DerivedFromExternalSpecialization::~DerivedFromExternalSpecialization() -{ -} - TemplateWithIndependentFields DerivedFromExternalSpecialization::returnExternalSpecialization() { return TemplateWithIndependentFields(); } -HasVirtualInDependency::HasVirtualInDependency() -{ -} - int HasVirtualInDependency::callManagedOverride() { return managedObject->virtualInCore(0); } -DerivedFromSecondaryBaseInDependency::DerivedFromSecondaryBaseInDependency() -{ -} - -DerivedFromSecondaryBaseInDependency::~DerivedFromSecondaryBaseInDependency() -{ -} - bool operator<<(const Base& b, const char* str) { return false; diff --git a/tests/NamespacesDerived/NamespacesDerived.h b/tests/NamespacesDerived/NamespacesDerived.h index 97349867..223ad8ff 100644 --- a/tests/NamespacesDerived/NamespacesDerived.h +++ b/tests/NamespacesDerived/NamespacesDerived.h @@ -48,8 +48,6 @@ template class TemplateClass; class DLL_API Derived2 : public Base3 { public: - Derived2(); - ~Derived2(); Base3 baseComponent; Base3 getBase(); void setBase(Base3); @@ -71,7 +69,6 @@ private: class DLL_API HasVirtualInDependency : public HasVirtualInCore { public: - HasVirtualInDependency(); HasVirtualInDependency* managedObject; int callManagedOverride(); }; @@ -82,15 +79,11 @@ public: DerivedFromExternalSpecialization(int i, TemplateWithIndependentFields defaultExternalSpecialization = TemplateWithIndependentFields()); - ~DerivedFromExternalSpecialization(); TemplateWithIndependentFields returnExternalSpecialization(); }; class DLL_API DerivedFromSecondaryBaseInDependency : public Derived, public SecondaryBase { -public: - DerivedFromSecondaryBaseInDependency(); - ~DerivedFromSecondaryBaseInDependency(); }; DLL_API bool operator<<(const Base& b, const char* str); diff --git a/tests/Test.Generator.props b/tests/Test.Generator.props index 7d808a08..8ea3c57d 100644 --- a/tests/Test.Generator.props +++ b/tests/Test.Generator.props @@ -18,11 +18,5 @@ - - - - - \ No newline at end of file diff --git a/tests/VTables/VTables.cpp b/tests/VTables/VTables.cpp index 73f5b6e9..688c23a6 100644 --- a/tests/VTables/VTables.cpp +++ b/tests/VTables/VTables.cpp @@ -1,14 +1,6 @@ #include "VTables.h" #include -Foo::Foo() -{ -} - -Foo::~Foo() -{ -} - int Foo::vfoo() { return 5; @@ -39,14 +31,6 @@ int FooCallFoo(Foo* foo) return foo->vfoo() + 2; } -BaseClassVirtual::BaseClassVirtual() -{ -} - -BaseClassVirtual::BaseClassVirtual(const BaseClassVirtual& other) -{ -} - int BaseClassVirtual::virtualCallRetInt(BaseClassVirtual* base) { return base->retInt(); @@ -72,10 +56,6 @@ const char* BaseClassVirtual::getTypeName() return typeid(BaseClassVirtual).name(); } -DerivedClassVirtual::DerivedClassVirtual() -{ -} - int DerivedClassVirtual::retInt() { return 10; diff --git a/tests/VTables/VTables.h b/tests/VTables/VTables.h index 40fa8880..f2860087 100644 --- a/tests/VTables/VTables.h +++ b/tests/VTables/VTables.h @@ -9,8 +9,6 @@ public: }; - Foo(); - ~Foo(); virtual int vfoo(); virtual int vbar(); @@ -25,8 +23,6 @@ DLL_API int FooCallFoo(Foo* foo); class DLL_API BaseClassVirtual { public: - BaseClassVirtual(); - BaseClassVirtual(const BaseClassVirtual& other); static int virtualCallRetInt(BaseClassVirtual* base); virtual int retInt(); static BaseClassVirtual getBase(); @@ -37,6 +33,5 @@ public: class DLL_API DerivedClassVirtual : public BaseClassVirtual { public: - DerivedClassVirtual(); virtual int retInt() override; };