From a5362af730d15bece536aadbc153099b1fbbf4bb Mon Sep 17 00:00:00 2001 From: triton Date: Wed, 18 Dec 2013 12:16:05 +0000 Subject: [PATCH] Improved visited checking in the ASTVisitor. Since this is a pretty common pattern, this factors the visited checking of declarations inside the VisitDeclaration overload. Because of this, we need to make sure we call VisitDeclaration is called (only once) instead of AlreadyVisited. --- src/AST/ASTVisitor.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/AST/ASTVisitor.cs b/src/AST/ASTVisitor.cs index 05fc269b..e2d3e1f3 100644 --- a/src/AST/ASTVisitor.cs +++ b/src/AST/ASTVisitor.cs @@ -17,6 +17,7 @@ namespace CppSharp.AST public class AstVisitorOptions { + public bool VisitDeclaration = true; public bool VisitClassBases = true; public bool VisitClassFields = true; public bool VisitClassProperties = true; @@ -240,17 +241,11 @@ namespace CppSharp.AST public virtual bool VisitDeclaration(Declaration decl) { - return true; + return !AlreadyVisited(decl); } public virtual bool VisitClassDecl(Class @class) { - if (AlreadyVisited(@class)) - return true; - - if (!VisitDeclaration(@class)) - return false; - if (!VisitDeclarationContext(@class)) return false;