Browse Source

Fixed CLITypeReferenceCollector to work correctly with nested namespaces.

Fixes a problem generating the upcoming CLI-free C++ parser.
pull/53/merge
triton 12 years ago
parent
commit
f5622306b6
  1. 17
      src/Generator/Generators/CLI/CLITypeReferences.cs

17
src/Generator/Generators/CLI/CLITypeReferences.cs

@ -52,6 +52,18 @@ namespace CppSharp.Generators.CLI
foreach (var record in collector.Declarations) 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); record.Value.Visit(this);
GenerateInclude(record); GenerateInclude(record);
ProcessTypeMap(record); ProcessTypeMap(record);
@ -90,7 +102,8 @@ namespace CppSharp.Generators.CLI
if (declFile.Contains("String")) if (declFile.Contains("String"))
return; return;
GetTypeReference(decl).Include = new Include() var typeRef = GetTypeReference(decl);
typeRef.Include = new Include()
{ {
File = declFile, File = declFile,
TranslationUnit = decl.Namespace.TranslationUnit, TranslationUnit = decl.Namespace.TranslationUnit,
@ -114,6 +127,8 @@ namespace CppSharp.Generators.CLI
private bool IsIncludeInHeader(ASTRecord<Declaration> record) private bool IsIncludeInHeader(ASTRecord<Declaration> record)
{ {
if (TranslationUnit == record.Value.Namespace.TranslationUnit)
return false;
return record.IsBaseClass() || record.IsFieldValueType(); return record.IsBaseClass() || record.IsFieldValueType();
} }

Loading…
Cancel
Save