Browse Source

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.
pull/144/head
triton 12 years ago
parent
commit
a5362af730
  1. 9
      src/AST/ASTVisitor.cs

9
src/AST/ASTVisitor.cs

@ -17,6 +17,7 @@ namespace CppSharp.AST @@ -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 @@ -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;

Loading…
Cancel
Save