From f5622306b60b179055deb62baeaf579a59155347 Mon Sep 17 00:00:00 2001 From: triton Date: Mon, 9 Sep 2013 23:04:30 +0100 Subject: [PATCH] Fixed CLITypeReferenceCollector to work correctly with nested namespaces. Fixes a problem generating the upcoming CLI-free C++ parser. --- .../Generators/CLI/CLITypeReferences.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Generator/Generators/CLI/CLITypeReferences.cs b/src/Generator/Generators/CLI/CLITypeReferences.cs index e90dfcfd..ebd89f0e 100644 --- a/src/Generator/Generators/CLI/CLITypeReferences.cs +++ b/src/Generator/Generators/CLI/CLITypeReferences.cs @@ -52,6 +52,18 @@ namespace CppSharp.Generators.CLI foreach (var record in collector.Declarations) { + if (record.Value is Namespace) + continue; + + var declNamespace = record.Value.Namespace; + + var isSameNamespace = declNamespace == @namespace; + if (declNamespace != null) + isSameNamespace |= declNamespace.QualifiedName == @namespace.QualifiedName; + + if (!isSameNamespace) + continue; + record.Value.Visit(this); GenerateInclude(record); ProcessTypeMap(record); @@ -90,7 +102,8 @@ namespace CppSharp.Generators.CLI if (declFile.Contains("String")) return; - GetTypeReference(decl).Include = new Include() + var typeRef = GetTypeReference(decl); + typeRef.Include = new Include() { File = declFile, TranslationUnit = decl.Namespace.TranslationUnit, @@ -114,6 +127,8 @@ namespace CppSharp.Generators.CLI private bool IsIncludeInHeader(ASTRecord record) { + if (TranslationUnit == record.Value.Namespace.TranslationUnit) + return false; return record.IsBaseClass() || record.IsFieldValueType(); }