Browse Source

Reworked the CLI type references functionality.

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

32
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,15 +120,19 @@ namespace CppSharp.Generators.CLI
return; return;
var typeRef = GetTypeReference(decl); var typeRef = GetTypeReference(decl);
typeRef.Include = new Include() if (typeRef.Include.TranslationUnit == null)
{
typeRef.Include = new Include
{ {
File = declFile, File = declFile,
TranslationUnit = decl.Namespace.TranslationUnit, TranslationUnit = decl.Namespace.TranslationUnit,
Kind = Include.IncludeKind.Quoted, Kind = Include.IncludeKind.Quoted,
InHeader = IsIncludeInHeader(record)
}; };
} }
typeRef.Include.InHeader |= IsIncludeInHeader(record);
}
private bool IsBuiltinTypedef(Declaration decl) private bool IsBuiltinTypedef(Declaration decl)
{ {
var typedefDecl = decl as TypedefDecl; var typedefDecl = decl as TypedefDecl;
@ -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