Browse Source

Added an option to the C++ printer to print the local as opposed to the globally qualified name. Implemented the printing of template specialisations.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/113/head
Dimitar Dobrev 12 years ago
parent
commit
24558b3385
  1. 17
      src/Generator/Types/CppTypePrinter.cs

17
src/Generator/Types/CppTypePrinter.cs

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CppSharp.AST;
using Type = CppSharp.AST.Type;
@ -11,6 +12,8 @@ namespace CppSharp.Types @@ -11,6 +12,8 @@ namespace CppSharp.Types
{
}
public bool PrintLocalName { get; set; }
public string VisitTagType(TagType tag, TypeQualifiers quals)
{
return tag.Declaration.Visit(this);
@ -106,6 +109,8 @@ namespace CppSharp.Types @@ -106,6 +109,8 @@ namespace CppSharp.Types
public string VisitTypedefType(TypedefType typedef, TypeQualifiers quals)
{
if (PrintLocalName)
return typedef.Declaration.OriginalName;
return "::" + typedef.Declaration.QualifiedOriginalName;
}
@ -116,8 +121,12 @@ namespace CppSharp.Types @@ -116,8 +121,12 @@ namespace CppSharp.Types
public string VisitTemplateSpecializationType(TemplateSpecializationType template, TypeQualifiers quals)
{
var decl = template.Template.TemplatedDecl;
return decl.Visit(this);
string prefix = PrintLocalName ? string.Empty : "::";
return string.Format("{0}{1}<{2}>", prefix, template.Template.TemplatedDecl.Visit(this),
string.Join(", ",
template.Arguments.Where(
a => a.Type.Type != null &&
!(a.Type.Type is DependentNameType)).Select(a => a.Type.Visit(this))));
}
public string VisitTemplateParameterType(TemplateParameterType param, TypeQualifiers quals)
@ -205,6 +214,8 @@ namespace CppSharp.Types @@ -205,6 +214,8 @@ namespace CppSharp.Types
public string VisitClassDecl(Class @class)
{
if (PrintLocalName)
return @class.OriginalName;
return string.Format("::{0}", @class.QualifiedOriginalName);
}
@ -235,6 +246,8 @@ namespace CppSharp.Types @@ -235,6 +246,8 @@ namespace CppSharp.Types
public string VisitEnumDecl(Enumeration @enum)
{
if (PrintLocalName)
return @enum.OriginalName;
return string.Format("::{0}", @enum.QualifiedOriginalName);
}

Loading…
Cancel
Save