diff --git a/src/AST/TranslationUnit.cs b/src/AST/TranslationUnit.cs
index b1f8896c..17e191ab 100644
--- a/src/AST/TranslationUnit.cs
+++ b/src/AST/TranslationUnit.cs
@@ -31,28 +31,39 @@ namespace CppSharp.AST
/// Contains the path to the file.
public string FilePath;
+ private string fileName;
+ private string fileNameWithoutExtension;
+
/// Contains the name of the file.
public string FileName
{
- get { return Path.GetFileName(FilePath); }
+ get { return fileName ?? (fileName = Path.GetFileName(FilePath)); }
}
/// Contains the name of the module.
public string FileNameWithoutExtension
{
- get { return Path.GetFileNameWithoutExtension(FileName); }
+ get
+ {
+ return fileNameWithoutExtension ??
+ (fileNameWithoutExtension = Path.GetFileNameWithoutExtension(FileName));
+ }
}
/// Contains the include path.
public string IncludePath;
+ private string fileRelativeDirectory;
+ private string fileRelativePath;
+
public string FileRelativeDirectory
{
get
{
+ if (fileRelativeDirectory != null) return fileRelativeDirectory;
var path = IncludePath.Replace('\\', '/');
var index = path.LastIndexOf('/');
- return path.Substring(0, index);
+ return fileRelativeDirectory = path.Substring(0, index);
}
}
@@ -60,7 +71,8 @@ namespace CppSharp.AST
{
get
{
- return Path.Combine(FileRelativeDirectory, FileName);
+ return fileRelativePath ??
+ (fileRelativePath = Path.Combine(FileRelativeDirectory, FileName));
}
}
}
diff --git a/src/Generator/Passes/CheckIgnoredDecls.cs b/src/Generator/Passes/CheckIgnoredDecls.cs
index f6a6f4c0..ccbfc717 100644
--- a/src/Generator/Passes/CheckIgnoredDecls.cs
+++ b/src/Generator/Passes/CheckIgnoredDecls.cs
@@ -1,5 +1,4 @@
-using System;
-using CppSharp.AST;
+using CppSharp.AST;
using CppSharp.AST.Extensions;
using CppSharp.Types;
@@ -322,7 +321,7 @@ namespace CppSharp.Passes
/// reasons: incomplete definitions, being explicitly ignored, or also
/// by being a type we do not know how to handle.
///
- bool HasInvalidType(AST.Type type, out string msg)
+ private bool HasInvalidType(Type type, out string msg)
{
if (type == null)
{
@@ -356,7 +355,7 @@ namespace CppSharp.Passes
return false;
}
- bool HasInvalidDecl(Declaration decl, out string msg)
+ private bool HasInvalidDecl(Declaration decl, out string msg)
{
if (decl == null)
{
@@ -364,7 +363,7 @@ namespace CppSharp.Passes
return true;
}
- if (!IsDeclComplete(decl))
+ if (decl.IsIncomplete)
{
msg = "incomplete";
return true;
@@ -380,19 +379,21 @@ namespace CppSharp.Passes
return false;
}
- static bool IsTypeComplete(AST.Type type)
+ private static bool IsTypeComplete(Type type)
{
- var checker = new TypeCompletionChecker();
- return type.Visit(checker);
- }
+ var desugared = type.Desugar();
+ var finalType = (desugared.GetFinalPointee() ?? desugared).Desugar();
- static bool IsDeclComplete(Declaration decl)
- {
- var checker = new TypeCompletionChecker();
- return decl.Visit(checker);
+ var templateSpecializationType = finalType as TemplateSpecializationType;
+ if (templateSpecializationType != null)
+ finalType = templateSpecializationType.Desugared;
+
+ Declaration decl;
+ if (!finalType.TryGetDeclaration(out decl)) return true;
+ return !decl.IsIncomplete;
}
- bool IsTypeIgnored(AST.Type type)
+ private bool IsTypeIgnored(Type type)
{
var checker = new TypeIgnoreChecker(Driver.TypeDatabase);
type.Visit(checker);
@@ -400,12 +401,14 @@ namespace CppSharp.Passes
return checker.IsIgnored;
}
- bool IsDeclIgnored(Declaration decl)
+ private bool IsDeclIgnored(Declaration decl)
{
- var checker = new TypeIgnoreChecker(Driver.TypeDatabase);
- decl.Visit(checker);
+ var parameter = decl as Parameter;
+ if (parameter != null && parameter.Type.Desugar().IsPrimitiveType(PrimitiveType.Null))
+ return true;
- return checker.IsIgnored;
+ TypeMap typeMap;
+ return Driver.TypeDatabase.FindTypeMap(decl, out typeMap) ? typeMap.IsIgnored : decl.Ignore;
}
#endregion
diff --git a/src/Generator/Types/Types.cs b/src/Generator/Types/Types.cs
index d5f23165..0bd40b49 100644
--- a/src/Generator/Types/Types.cs
+++ b/src/Generator/Types/Types.cs
@@ -4,29 +4,6 @@ using CppSharp.Types;
namespace CppSharp
{
- ///
- /// This type checker is used to check if a type is complete.
- ///
- public class TypeCompletionChecker : AstVisitor
- {
- public TypeCompletionChecker()
- {
- Options.VisitClassBases = false;
- Options.VisitTemplateArguments = false;
- }
-
- public override bool VisitDeclaration(Declaration decl)
- {
- if (AlreadyVisited(decl))
- return false;
-
- if (decl.CompleteDeclaration != null)
- return true;
-
- return !decl.IsIncomplete;
- }
- }
-
///
/// This type checker is used to check if a type is ignored.
///