From ee171eb9fa27d6ef36e5f1602f4b82c6847727bb Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Mon, 13 Feb 2017 00:29:45 +0200 Subject: [PATCH] Freed up the native parser options when done with. Signed-off-by: Dimitar Dobrev --- .../CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs | 6 +++--- .../CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs | 6 +++--- .../CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs | 6 +++--- src/CppParser/CppParser.cpp | 2 ++ src/CppParser/CppParser.h | 1 + src/Generator.Tests/AST/TestAST.cs | 6 ++++++ src/Generator/Driver.cs | 4 ++++ 7 files changed, 22 insertions(+), 9 deletions(-) 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 9860e866..dcd4b4d6 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 @@ -17218,7 +17218,7 @@ namespace CppSharp [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZN8CppSharp9CppParser16CppParserOptionsC2ERKS1_")] - internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0); + internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr _0); [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, @@ -17407,7 +17407,7 @@ namespace CppSharp private static void* __CopyValue(CppParserOptions.__Internal native) { var ret = Marshal.AllocHGlobal(132); - global::CppSharp.Parser.CppParserOptions.__Internal.cctor_2(ret, new global::System.IntPtr(&native)); + global::CppSharp.Parser.CppParserOptions.__Internal.cctor_1(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); } @@ -17441,7 +17441,7 @@ namespace CppSharp if (ReferenceEquals(_0, null)) throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); var __arg0 = _0.__Instance; - __Internal.cctor_2((__Instance + __PointerAdjustment), __arg0); + __Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); } public void Dispose() 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 8d43891c..7d25e4bf 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 @@ -17217,7 +17217,7 @@ namespace CppSharp [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZN8CppSharp9CppParser16CppParserOptionsC2ERKS1_")] - internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0); + internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr _0); [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, @@ -17406,7 +17406,7 @@ namespace CppSharp private static void* __CopyValue(CppParserOptions.__Internal native) { var ret = Marshal.AllocHGlobal(256); - global::CppSharp.Parser.CppParserOptions.__Internal.cctor_2(ret, new global::System.IntPtr(&native)); + global::CppSharp.Parser.CppParserOptions.__Internal.cctor_1(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); } @@ -17440,7 +17440,7 @@ namespace CppSharp if (ReferenceEquals(_0, null)) throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); var __arg0 = _0.__Instance; - __Internal.cctor_2((__Instance + __PointerAdjustment), __arg0); + __Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); } public void Dispose() 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 1fe58e10..9d9840e9 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 @@ -17217,7 +17217,7 @@ namespace CppSharp [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZN8CppSharp9CppParser16CppParserOptionsC2ERKS1_")] - internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0); + internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr _0); [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, @@ -17406,7 +17406,7 @@ namespace CppSharp private static void* __CopyValue(CppParserOptions.__Internal native) { var ret = Marshal.AllocHGlobal(272); - global::CppSharp.Parser.CppParserOptions.__Internal.cctor_2(ret, new global::System.IntPtr(&native)); + global::CppSharp.Parser.CppParserOptions.__Internal.cctor_1(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); } @@ -17440,7 +17440,7 @@ namespace CppSharp if (ReferenceEquals(_0, null)) throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); var __arg0 = _0.__Instance; - __Internal.cctor_2((__Instance + __PointerAdjustment), __arg0); + __Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); } public void Dispose() diff --git a/src/CppParser/CppParser.cpp b/src/CppParser/CppParser.cpp index bd85dc03..fd89f6f3 100644 --- a/src/CppParser/CppParser.cpp +++ b/src/CppParser/CppParser.cpp @@ -23,6 +23,8 @@ CppParserOptions::CppParserOptions() { } +CppParserOptions::~CppParserOptions() {} + DEF_VECTOR_STRING(CppParserOptions, Arguments) DEF_STRING(CppParserOptions, LibraryFile) DEF_VECTOR_STRING(CppParserOptions, SourceFiles) diff --git a/src/CppParser/CppParser.h b/src/CppParser/CppParser.h index 0f8f10b2..6d98c747 100644 --- a/src/CppParser/CppParser.h +++ b/src/CppParser/CppParser.h @@ -46,6 +46,7 @@ enum class LanguageVersion struct CS_API CppParserOptions { CppParserOptions(); + ~CppParserOptions(); VECTOR_STRING(Arguments) diff --git a/src/Generator.Tests/AST/TestAST.cs b/src/Generator.Tests/AST/TestAST.cs index 4f91eabc..3c6c696e 100644 --- a/src/Generator.Tests/AST/TestAST.cs +++ b/src/Generator.Tests/AST/TestAST.cs @@ -22,6 +22,12 @@ namespace CppSharp.Generator.Tests.AST ParseLibrary("AST.h", "ASTExtensions.h"); } + [TestFixtureTearDown] + public void CleanUp() + { + ParserOptions.Dispose(); + } + [Test] public void TestASTParameter() { diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs index 8e86cda2..5690a1ea 100644 --- a/src/Generator/Driver.cs +++ b/src/Generator/Driver.cs @@ -198,6 +198,9 @@ namespace CppSharp parser.SourcesParsed += OnSourceFileParsed; parser.ParseProject(Project, Options.UnityBuild); + + foreach (var source in Project.Sources.Where(s => s.Options != null)) + source.Options.Dispose(); Context.TargetInfo = parser.GetTargetInfo(ParserOptions); Context.ASTContext = ClangParser.ConvertASTContext(parser.ASTContext); @@ -534,6 +537,7 @@ namespace CppSharp driver.Generator.Dispose(); driver.Context.TargetInfo.Dispose(); + driver.ParserOptions.Dispose(); } } } \ No newline at end of file