Browse Source

Extended the searching for type maps to try resolving type defs.

pull/742/head
Dimitar Dobrev 9 years ago
parent
commit
5a17cc12e1
  1. 9
      src/AST/CppTypePrinter.cs
  2. 8
      src/Generator/Types/TypeMap.cs

9
src/AST/CppTypePrinter.cs

@ -41,7 +41,8 @@ namespace CppSharp.AST @@ -41,7 +41,8 @@ namespace CppSharp.AST
public virtual string VisitTagType(TagType tag, TypeQualifiers quals)
{
var qual = GetStringQuals(quals);
return $"{qual} {tag.Declaration.Visit(this)}";
return $@"{qual}{(string.IsNullOrEmpty(qual) ? string.Empty : " ")}{
tag.Declaration.Visit(this)}";
}
public virtual string VisitArrayType(ArrayType array, TypeQualifiers quals)
@ -107,7 +108,8 @@ namespace CppSharp.AST @@ -107,7 +108,8 @@ namespace CppSharp.AST
public virtual string VisitBuiltinType(BuiltinType builtin, TypeQualifiers quals)
{
var qual = GetStringQuals(quals);
return $"{qual} {VisitPrimitiveType(builtin.Type)}";
return $@"{qual}{(string.IsNullOrEmpty(qual) ? string.Empty : " ")}{
VisitPrimitiveType(builtin.Type)}";
}
public virtual string VisitPrimitiveType(PrimitiveType primitive)
@ -151,7 +153,8 @@ namespace CppSharp.AST @@ -151,7 +153,8 @@ namespace CppSharp.AST
if (ResolveTypedefs && !typedef.Declaration.Type.IsPointerTo(out func))
return typedef.Declaration.Type.Visit(this);
var qual = GetStringQuals(quals);
return $"{qual} {typedef.Declaration.Visit(this)}";
return $@"{qual}{(string.IsNullOrEmpty(qual) ? string.Empty : " ")}{
typedef.Declaration.Visit(this)}";
}
public virtual string VisitAttributedType(AttributedType attributed, TypeQualifiers quals)

8
src/Generator/Types/TypeMap.cs

@ -180,6 +180,14 @@ namespace CppSharp.Types @@ -180,6 +180,14 @@ namespace CppSharp.Types
return true;
}
typePrinter.ResolveTypedefs = true;
if (FindTypeMap(decl.Visit(typePrinter), out typeMap))
{
typeMap.Type = type;
return true;
}
typePrinter.ResolveTypedefs = false;
typePrinter.PrintScopeKind = CppTypePrintScopeKind.Local;
if (FindTypeMap(decl.Visit(typePrinter), out typeMap))
{

Loading…
Cancel
Save