From 71c14cdb2bc3efa398271c80c206d6edb897e6b7 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Sun, 9 Apr 2017 22:16:44 +0300 Subject: [PATCH] Fixed the C++ printing of qualified specializations. Signed-off-by: Dimitar Dobrev --- src/AST/CppTypePrinter.cs | 3 ++- src/Generator.Tests/AST/TestAST.cs | 9 +++++++++ tests/Native/AST.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/AST/CppTypePrinter.cs b/src/AST/CppTypePrinter.cs index 51ddbdb7..39d2a82d 100644 --- a/src/AST/CppTypePrinter.cs +++ b/src/AST/CppTypePrinter.cs @@ -183,7 +183,8 @@ namespace CppSharp.AST if (specialization == null) return string.Empty; - return VisitClassTemplateSpecializationDecl(specialization); + var qual = GetStringQuals(quals); + return $@"{qual}{VisitClassTemplateSpecializationDecl(specialization)}"; } public virtual string VisitDependentTemplateSpecializationType( diff --git a/src/Generator.Tests/AST/TestAST.cs b/src/Generator.Tests/AST/TestAST.cs index 1792becd..bb61d8fb 100644 --- a/src/Generator.Tests/AST/TestAST.cs +++ b/src/Generator.Tests/AST/TestAST.cs @@ -504,5 +504,14 @@ namespace CppSharp.Generator.Tests.AST Assert.That(template.Specializations[1].Classes[0].Visit(cppTypePrinter), Is.EqualTo("TestTemplateClass::NestedInTemplate")); } + + [Test] + public void TestPrintQualifiedSpecialization() + { + var functionWithSpecializationArg = AstContext.FindFunction("functionWithSpecializationArg").First(); + var cppTypePrinter = new CppTypePrinter { PrintScopeKind = TypePrintScopeKind.Qualified }; + Assert.That(functionWithSpecializationArg.Parameters[0].Visit(cppTypePrinter), + Is.EqualTo("const TestTemplateClass")); + } } } diff --git a/tests/Native/AST.h b/tests/Native/AST.h index e73c81ab..147c37eb 100644 --- a/tests/Native/AST.h +++ b/tests/Native/AST.h @@ -169,3 +169,5 @@ bool functionWithSpecInfo(const T1& t11, const T1& t12, const T2& t2); template<> bool functionWithSpecInfo(const float& t11, const float& t12, const float& t2); + +void functionWithSpecializationArg(const TestTemplateClass);