Browse Source

Added support for printing logical names to CppTypePrinter.

pull/222/head
triton 12 years ago
parent
commit
d85051a8e9
  1. 42
      src/Generator/Types/CppTypePrinter.cs

42
src/Generator/Types/CppTypePrinter.cs

@ -6,7 +6,7 @@ using Type = CppSharp.AST.Type; @@ -6,7 +6,7 @@ using Type = CppSharp.AST.Type;
namespace CppSharp.Types
{
public enum CppTypePrintKind
public enum CppTypePrintScopeKind
{
Local,
Qualified,
@ -15,11 +15,12 @@ namespace CppSharp.Types @@ -15,11 +15,12 @@ namespace CppSharp.Types
public class CppTypePrinter : ITypePrinter<string>, IDeclVisitor<string>
{
public CppTypePrintKind PrintKind;
public CppTypePrintScopeKind PrintScopeKind;
public bool PrintLogicalNames;
public CppTypePrinter(ITypeMapDatabase database)
{
PrintKind = CppTypePrintKind.GlobalQualified;
PrintScopeKind = CppTypePrintScopeKind.GlobalQualified;
}
public string VisitTagType(TagType tag, TypeQualifiers quals)
@ -127,21 +128,6 @@ namespace CppSharp.Types @@ -127,21 +128,6 @@ namespace CppSharp.Types
return attributed.Modified.Visit(this);
}
public string GetDeclName(Declaration declaration)
{
switch (PrintKind)
{
case CppTypePrintKind.Local:
return declaration.OriginalName;
case CppTypePrintKind.Qualified:
return declaration.QualifiedOriginalName;
case CppTypePrintKind.GlobalQualified:
return "::" + declaration.QualifiedOriginalName;
}
throw new NotSupportedException();
}
public string VisitDecayedType(DecayedType decayed, TypeQualifiers quals)
{
return decayed.Decayed.Visit(this);
@ -239,6 +225,24 @@ namespace CppSharp.Types @@ -239,6 +225,24 @@ namespace CppSharp.Types
throw new System.NotImplementedException();
}
public string GetDeclName(Declaration declaration)
{
switch (PrintScopeKind)
{
case CppTypePrintScopeKind.Local:
return PrintLogicalNames ? declaration.LogicalOriginalName
: declaration.OriginalName;
case CppTypePrintScopeKind.Qualified:
return PrintLogicalNames ? declaration.QualifiedLogicalOriginalName
: declaration.QualifiedOriginalName;
case CppTypePrintScopeKind.GlobalQualified:
return "::" + (PrintLogicalNames ? declaration.QualifiedLogicalOriginalName
: declaration.QualifiedOriginalName);
}
throw new NotSupportedException();
}
public string VisitDeclaration(Declaration decl)
{
return GetDeclName(decl);
@ -246,7 +250,7 @@ namespace CppSharp.Types @@ -246,7 +250,7 @@ namespace CppSharp.Types
public string VisitClassDecl(Class @class)
{
return GetDeclName(@class);
return VisitDeclaration(@class);
}
public string VisitFieldDecl(Field field)

Loading…
Cancel
Save