Browse Source

Added a setting to the C++ type printer to resolve typedefs.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/614/head
Dimitar Dobrev 10 years ago
parent
commit
84ab1bf35c
  1. 9
      src/Generator/Types/CppTypePrinter.cs

9
src/Generator/Types/CppTypePrinter.cs

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using CppSharp.AST; using CppSharp.AST;
using CppSharp.AST.Extensions;
using Type = CppSharp.AST.Type; using Type = CppSharp.AST.Type;
namespace CppSharp.Types namespace CppSharp.Types
@ -25,6 +26,8 @@ namespace CppSharp.Types
PrintTypeQualifiers = printTypeQualifiers; PrintTypeQualifiers = printTypeQualifiers;
} }
public bool ResolveTypedefs { get; set; }
public string VisitTagType(TagType tag, TypeQualifiers quals) public string VisitTagType(TagType tag, TypeQualifiers quals)
{ {
return tag.Declaration.Visit(this); return tag.Declaration.Visit(this);
@ -126,6 +129,12 @@ namespace CppSharp.Types
public string VisitTypedefType(TypedefType typedef, TypeQualifiers quals) public string VisitTypedefType(TypedefType typedef, TypeQualifiers quals)
{ {
if (ResolveTypedefs)
{
var decl = typedef.Declaration;
FunctionType func;
return decl.Type.IsPointerTo(out func) ? VisitDeclaration(decl) : decl.Type.Visit(this);
}
return GetDeclName(typedef.Declaration); return GetDeclName(typedef.Declaration);
} }

Loading…
Cancel
Save