Browse Source

Fixed a bug in ASTRecord that made us infinitely recurse in some code.

Basically we should not visit a declaration if we are visiting from a type.
pull/146/merge
triton 12 years ago
parent
commit
8a54d30917
  1. 11
      src/Generator/AST/ASTRecord.cs

11
src/Generator/AST/ASTRecord.cs

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using CppSharp.AST;
using Type = CppSharp.AST.Type;
@ -104,6 +105,11 @@ namespace CppSharp.Generators.AST @@ -104,6 +105,11 @@ namespace CppSharp.Generators.AST
return recordStack.Any(rec => decl == rec.Object);
}
public bool Contains(Func<ASTRecord, bool> func)
{
return recordStack.Any(func);
}
public bool IsBeingVisited(Declaration decl)
{
var record = recordStack.FirstOrDefault(rec => decl == rec.Object);
@ -195,6 +201,9 @@ namespace CppSharp.Generators.AST @@ -195,6 +201,9 @@ namespace CppSharp.Generators.AST
if (decl is TranslationUnit)
return false;
if (recordStack.Contains(record => record.Object is Type))
return false;
if (recordStack.IsBeingVisited(decl))
return false;

Loading…
Cancel
Save