diff --git a/src/AST/Declaration.cs b/src/AST/Declaration.cs index f34df430..374194bb 100644 --- a/src/AST/Declaration.cs +++ b/src/AST/Declaration.cs @@ -153,7 +153,7 @@ namespace CppSharp.AST { get { - return GetQualifiedName(decl => decl.Name, decl => decl.Namespace); + return GetQualifiedName(decl => GetDeclName(decl, decl.Name), decl => decl.Namespace); } } @@ -162,7 +162,7 @@ namespace CppSharp.AST get { return GetQualifiedName( - decl => decl.OriginalName, decl => decl.OriginalNamespace); + decl => GetDeclName(decl, decl.OriginalName), decl => decl.OriginalNamespace); } } @@ -171,7 +171,7 @@ namespace CppSharp.AST get { return GetQualifiedName( - decl => decl.LogicalName, decl => decl.Namespace); + decl => GetDeclName(decl, decl.LogicalName), decl => decl.Namespace); } } @@ -180,10 +180,20 @@ namespace CppSharp.AST get { return GetQualifiedName( - decl => decl.LogicalOriginalName, decl => decl.OriginalNamespace); + decl => GetDeclName(decl, decl.LogicalOriginalName), decl => decl.OriginalNamespace); } } + private static string GetDeclName(Declaration decl, string name) + { + var specialization = decl as ClassTemplateSpecialization; + if (specialization != null) + return string.Format("{0}<{1}>", name, + string.Join(", ", specialization.Arguments.Select( + a => a.Type.Type == null ? string.Empty : a.Type.ToString()))); + return name; + } + // Comment associated with declaration. public RawComment Comment; diff --git a/src/Generator.Tests/AST/TestAST.cs b/src/Generator.Tests/AST/TestAST.cs index 620409c2..3a8eff2c 100644 --- a/src/Generator.Tests/AST/TestAST.cs +++ b/src/Generator.Tests/AST/TestAST.cs @@ -14,6 +14,11 @@ namespace CppSharp.Generator.Tests.AST [TestFixtureSetUp] public void Init() { + CppSharp.AST.Type.TypePrinterDelegate = type => + { + PrimitiveType primitiveType; + return type.IsPrimitiveType(out primitiveType) ? primitiveType.ToString() : string.Empty; + }; } [SetUp] @@ -372,8 +377,17 @@ namespace CppSharp.Generator.Tests.AST public void TestCompletionOfClassTemplates() { var templates = AstContext.FindDecl("ForwardedTemplate").ToList(); - Assert.IsFalse(templates.Single( - t => t.DebugText == "template \r\nclass ForwardedTemplate\r\n{\r\n}").IsIncomplete); + var template = templates.Single( + t => t.DebugText == "template \r\nclass ForwardedTemplate\r\n{\r\n}"); + Assert.IsFalse(template.IsIncomplete); + } + + [Test] + public void TestOriginalNamesOfSpecializations() + { + var template = AstContext.FindDecl("TestSpecializationArguments").First(); + Assert.That(template.Specializations[0].Constructors.First().QualifiedName, + Is.Not.EqualTo(template.Specializations[1].Constructors.First().QualifiedName)); } } } diff --git a/src/Generator/Generators/CLI/CLITypePrinter.cs b/src/Generator/Generators/CLI/CLITypePrinter.cs index b1868ccc..23842805 100644 --- a/src/Generator/Generators/CLI/CLITypePrinter.cs +++ b/src/Generator/Generators/CLI/CLITypePrinter.cs @@ -191,7 +191,7 @@ namespace CppSharp.Generators.CLI public string VisitMemberPointerType(MemberPointerType member, TypeQualifiers quals) { - throw new NotImplementedException(); + return member.Pointee.Visit(this); } public string VisitBuiltinType(BuiltinType builtin, TypeQualifiers quals) diff --git a/tests/Native/AST.h b/tests/Native/AST.h index 8ede7e8c..c46d1b48 100644 --- a/tests/Native/AST.h +++ b/tests/Native/AST.h @@ -118,7 +118,7 @@ public: TestSpecializationArguments() {} }; -void instantiatesTemplate(TestSpecializationArguments t) +void instantiatesTemplate(TestSpecializationArguments i, TestSpecializationArguments f) { }