Browse Source

Much improved checking of type completion.

pull/1/head
triton 13 years ago
parent
commit
b069ce6b4b
  1. 92
      src/Generator/Types/Types.cs

92
src/Generator/Types/Types.cs

@ -97,6 +97,36 @@ namespace Cxxi
return true; return true;
} }
public override bool VisitTypedefType(TypedefType typedef,
TypeQualifiers quals)
{
var decl = typedef.Declaration;
TypeMap typeMap = null;
if (TypeMapDatabase.FindTypeMap(decl, out typeMap))
{
if (typeMap.IsIgnored)
return true;
}
return base.VisitTypedefType(typedef, quals);
}
public override bool VisitTemplateSpecializationType(
TemplateSpecializationType template, TypeQualifiers quals)
{
var decl = template.Template.TemplatedDecl;
TypeMap typeMap = null;
if (TypeMapDatabase.FindTypeMap(decl, out typeMap))
{
if (typeMap.IsIgnored)
return true;
}
return base.VisitTemplateSpecializationType(template, quals);
}
} }
/// <summary> /// <summary>
@ -112,7 +142,10 @@ namespace Cxxi
public void Collect(Declaration declaration) public void Collect(Declaration declaration)
{ {
if (declaration.Namespace.TranslationUnit.IsSystemHeader) var @namespace = declaration.Namespace;
if (@namespace != null)
if (@namespace.TranslationUnit.IsSystemHeader)
return; return;
ForwardReferences.Add(declaration); ForwardReferences.Add(declaration);
@ -123,36 +156,65 @@ namespace Cxxi
ForwardReferences = new HashSet<Declaration>(); ForwardReferences = new HashSet<Declaration>();
} }
public override bool VisitBuiltinType(BuiltinType builtin, TypeQualifiers quals) public override bool VisitClassDecl(Class @class)
{ {
// Built-in types should not need forward references. if (AlreadyVisited(@class))
return true; return true;
}
public override bool VisitClassDecl(Class @class)
{
Collect(@class); Collect(@class);
// If the class is incomplete, then we cannot process the record
// members, else it will add references to declarations that
// should have not been found.
if (@class.IsIncomplete)
return true; return true;
}
public override bool VisitParameterDecl(Parameter parameter) foreach (var field in @class.Fields)
{ VisitFieldDecl(field);
if (parameter.Type == null)
return false; foreach (var method in @class.Methods)
VisitMethodDecl(method);
return parameter.Type.Visit(this); return true;
} }
public override bool VisitEnumDecl(Enumeration @enum) public override bool VisitEnumDecl(Enumeration @enum)
{ {
Collect(@enum); Collect(@enum);
return @enum.Type.Visit(this, new TypeQualifiers()); return true;
} }
public override bool VisitMacroDefinition(MacroDefinition macro) public override bool VisitFieldDecl(Field field)
{
Class @class;
if (field.Type.IsTagDecl(out @class))
{ {
// Macros are not relevant for forward references. if (@class.IsValueType)
Collect(@field);
}
else
{
field.Type.Visit(this);
}
return true; return true;
} }
public override bool VisitTypedefType(TypedefType typedef,
TypeQualifiers quals)
{
var decl = typedef.Declaration;
if (decl.Type == null)
return false;
FunctionType function;
if (decl.Type.IsPointerTo<FunctionType>(out function))
{
Collect(decl);
}
return decl.Type.Visit(this);
}
} }
} }

Loading…
Cancel
Save