From d85051a8e92028ad3194d436cb074e1f8476cd37 Mon Sep 17 00:00:00 2001 From: triton Date: Tue, 8 Apr 2014 12:42:13 +0100 Subject: [PATCH] Added support for printing logical names to CppTypePrinter. --- src/Generator/Types/CppTypePrinter.cs | 42 +++++++++++++++------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/Generator/Types/CppTypePrinter.cs b/src/Generator/Types/CppTypePrinter.cs index f8083593..63b0cffe 100644 --- a/src/Generator/Types/CppTypePrinter.cs +++ b/src/Generator/Types/CppTypePrinter.cs @@ -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 public class CppTypePrinter : ITypePrinter, IDeclVisitor { - 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 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 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 public string VisitClassDecl(Class @class) { - return GetDeclName(@class); + return VisitDeclaration(@class); } public string VisitFieldDecl(Field field)