From fc55c7ed094172dfffba8d23113c531cab4c0f76 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Sat, 4 Feb 2017 16:08:42 +0200 Subject: [PATCH] Added a mechanism for external code to block the pass for finding symbols. It's useful when waiting for new symbols, such as inlines and templates, to be compiled. --- src/Generator/Passes/FindSymbolsPass.cs | 34 ++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Generator/Passes/FindSymbolsPass.cs b/src/Generator/Passes/FindSymbolsPass.cs index 1fed9fdd..a04dd732 100644 --- a/src/Generator/Passes/FindSymbolsPass.cs +++ b/src/Generator/Passes/FindSymbolsPass.cs @@ -1,4 +1,5 @@ -using CppSharp.AST; +using System.Threading; +using CppSharp.AST; namespace CppSharp.Passes { @@ -16,6 +17,34 @@ namespace CppSharp.Passes VisitOptions.VisitClassFields = false; } + public bool Wait + { + get { return wait; } + set + { + if (wait != value) + { + wait = value; + if (!wait) + { + manualResetEvent.Set(); + manualResetEvent.Dispose(); + manualResetEvent = null; + } + } + } + } + + public override bool VisitASTContext(ASTContext context) + { + if (Wait) + { + manualResetEvent = new ManualResetEvent(false); + manualResetEvent.WaitOne(); + } + return base.VisitASTContext(context); + } + public override bool VisitDeclaration(Declaration decl) { if (!base.VisitDeclaration(decl)) @@ -52,5 +81,8 @@ namespace CppSharp.Passes mangledDecl.Mangled = symbol; return true; } + + private bool wait; + private ManualResetEvent manualResetEvent; } }