Browse Source

Avoided naming conflicts between methods of different specialisations of a template.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/661/head
Dimitar Dobrev 9 years ago
parent
commit
e57ea530e1
  1. 18
      src/AST/Declaration.cs
  2. 18
      src/Generator.Tests/AST/TestAST.cs
  3. 2
      src/Generator/Generators/CLI/CLITypePrinter.cs
  4. 2
      tests/Native/AST.h

18
src/AST/Declaration.cs

@ -153,7 +153,7 @@ namespace CppSharp.AST @@ -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 @@ -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 @@ -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 @@ -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;

18
src/Generator.Tests/AST/TestAST.cs

@ -14,6 +14,11 @@ namespace CppSharp.Generator.Tests.AST @@ -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 @@ -372,8 +377,17 @@ namespace CppSharp.Generator.Tests.AST
public void TestCompletionOfClassTemplates()
{
var templates = AstContext.FindDecl<ClassTemplate>("ForwardedTemplate").ToList();
Assert.IsFalse(templates.Single(
t => t.DebugText == "template <typename T>\r\nclass ForwardedTemplate\r\n{\r\n}").IsIncomplete);
var template = templates.Single(
t => t.DebugText == "template <typename T>\r\nclass ForwardedTemplate\r\n{\r\n}");
Assert.IsFalse(template.IsIncomplete);
}
[Test]
public void TestOriginalNamesOfSpecializations()
{
var template = AstContext.FindDecl<ClassTemplate>("TestSpecializationArguments").First();
Assert.That(template.Specializations[0].Constructors.First().QualifiedName,
Is.Not.EqualTo(template.Specializations[1].Constructors.First().QualifiedName));
}
}
}

2
src/Generator/Generators/CLI/CLITypePrinter.cs

@ -191,7 +191,7 @@ namespace CppSharp.Generators.CLI @@ -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)

2
tests/Native/AST.h

@ -118,7 +118,7 @@ public: @@ -118,7 +118,7 @@ public:
TestSpecializationArguments() {}
};
void instantiatesTemplate(TestSpecializationArguments<int> t)
void instantiatesTemplate(TestSpecializationArguments<int> i, TestSpecializationArguments<float> f)
{
}

Loading…
Cancel
Save