Browse Source

Reworked the CLI type references functionality.

pull/144/head
triton 12 years ago
parent
commit
ede3149a41
  1. 40
      src/Generator/Generators/CLI/CLITypeReferences.cs

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

@ -11,6 +11,9 @@ namespace CppSharp.Generators.CLI
public override string ToString() public override string ToString()
{ {
if(Include.InHeader)
return Include.ToString();
if (!string.IsNullOrWhiteSpace(FowardReference)) if (!string.IsNullOrWhiteSpace(FowardReference))
return FowardReference; return FowardReference;
@ -117,13 +120,17 @@ namespace CppSharp.Generators.CLI
return; return;
var typeRef = GetTypeReference(decl); var typeRef = GetTypeReference(decl);
typeRef.Include = new Include() if (typeRef.Include.TranslationUnit == null)
{ {
File = declFile, typeRef.Include = new Include
TranslationUnit = decl.Namespace.TranslationUnit, {
Kind = Include.IncludeKind.Quoted, File = declFile,
InHeader = IsIncludeInHeader(record) TranslationUnit = decl.Namespace.TranslationUnit,
}; Kind = Include.IncludeKind.Quoted,
};
}
typeRef.Include.InHeader |= IsIncludeInHeader(record);
} }
private bool IsBuiltinTypedef(Declaration decl) private bool IsBuiltinTypedef(Declaration decl)
@ -143,17 +150,21 @@ namespace CppSharp.Generators.CLI
{ {
if (TranslationUnit == record.Value.Namespace.TranslationUnit) if (TranslationUnit == record.Value.Namespace.TranslationUnit)
return false; return false;
return record.IsBaseClass() || record.IsFieldValueType(); return record.IsBaseClass() || record.IsFieldValueType();
} }
public override bool VisitDeclaration(Declaration decl) public override bool VisitDeclaration(Declaration decl)
{ {
return ShouldVisitDecl(decl); if (decl.Namespace != null && decl.Namespace.TranslationUnit.IsSystemHeader)
return false;
return !decl.Ignore;
} }
public override bool VisitClassDecl(Class @class) public override bool VisitClassDecl(Class @class)
{ {
if(!ShouldVisitDecl(@class)) if (!VisitDeclaration(@class))
return false; return false;
if (@class.IsIncomplete && @class.CompleteDeclaration != null) if (@class.IsIncomplete && @class.CompleteDeclaration != null)
@ -169,7 +180,7 @@ namespace CppSharp.Generators.CLI
public override bool VisitEnumDecl(Enumeration @enum) public override bool VisitEnumDecl(Enumeration @enum)
{ {
if(!ShouldVisitDecl(@enum)) if (!VisitDeclaration(@enum))
return false; return false;
var @base = ""; var @base = "";
@ -182,16 +193,5 @@ namespace CppSharp.Generators.CLI
return false; return false;
} }
private bool ShouldVisitDecl(Declaration decl)
{
if(decl.Namespace != null && decl.Namespace.TranslationUnit.IsSystemHeader)
return false;
if (decl.Ignore)
return false;
return true;
}
} }
} }
Loading…
Cancel
Save