From 22c80b3fe1c042ab26b07a10891684b2f980eed3 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Wed, 11 Jan 2017 21:56:12 +0000 Subject: [PATCH] Improve CheckIgnoredDecls.IsTypeExternal to deal with declarations with no namespaces. --- src/Generator/Passes/CheckIgnoredDecls.cs | 26 ++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Generator/Passes/CheckIgnoredDecls.cs b/src/Generator/Passes/CheckIgnoredDecls.cs index 8fded460..38ed5fac 100644 --- a/src/Generator/Passes/CheckIgnoredDecls.cs +++ b/src/Generator/Passes/CheckIgnoredDecls.cs @@ -403,16 +403,22 @@ namespace CppSharp.Passes private bool IsTypeExternal(Module module, Type type) { Declaration declaration; - if ((type.GetFinalPointee() ?? type).TryGetDeclaration(out declaration)) - { - declaration = declaration.CompleteDeclaration ?? declaration; - if (declaration.TranslationUnit.Module.Libraries.Any(l => - Context.Symbols.Libraries.First( - lib => lib.FileName == l).Dependencies.Any( - d => module != declaration.TranslationUnit.Module && - module.Libraries.Contains(d)))) - return true; - } + if (!(type.GetFinalPointee() ?? type).TryGetDeclaration(out declaration)) + return false; + + declaration = declaration.CompleteDeclaration ?? declaration; + if (declaration.Namespace == null || declaration.TranslationUnit.Module == null) + return false; + + // Check if there’s another module which wraps libraries with dependencies on + // the ones in the current module. + if (declaration.TranslationUnit.Module.Libraries.Any(l => + Context.Symbols.Libraries.First( + lib => lib.FileName == l).Dependencies.Any( + d => module != declaration.TranslationUnit.Module && + module.Libraries.Contains(d)))) + return true; + return false; }