From 8a54d30917b6a89a705b483846e3068059f9ffc7 Mon Sep 17 00:00:00 2001 From: triton Date: Fri, 3 Jan 2014 18:47:53 +0000 Subject: [PATCH] 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. --- src/Generator/AST/ASTRecord.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Generator/AST/ASTRecord.cs b/src/Generator/AST/ASTRecord.cs index 30be7e01..4e3b816f 100644 --- a/src/Generator/AST/ASTRecord.cs +++ b/src/Generator/AST/ASTRecord.cs @@ -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 return recordStack.Any(rec => decl == rec.Object); } + public bool Contains(Func 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 if (decl is TranslationUnit) return false; + if (recordStack.Contains(record => record.Object is Type)) + return false; + if (recordStack.IsBeingVisited(decl)) return false;