Browse Source

Prevented the renaming of constructors if there is duplication of names.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/119/head
Dimitar Dobrev 12 years ago
parent
commit
79883199f5
  1. 7
      src/Generator/Passes/CheckDuplicatedNamesPass.cs
  2. 28
      src/Generator/Types/TypeMap.cs
  3. 2
      tests/CSharpTemp/CSharpTemp.Tests.cs
  4. 10
      tests/CSharpTemp/CSharpTemp.cpp
  5. 3
      tests/CSharpTemp/CSharpTemp.cs
  6. 3
      tests/CSharpTemp/CSharpTemp.h

7
src/Generator/Passes/CheckDuplicatedNamesPass.cs

@ -46,7 +46,7 @@ namespace CppSharp.Passes @@ -46,7 +46,7 @@ namespace CppSharp.Passes
return true;
}
private bool UpdateName(Function method)
private bool UpdateName(Method method)
{
var @params = method.Parameters.Where(p => p.Kind != ParameterKind.IndirectReturnType)
.Select(p => p.QualifiedType.ToString());
@ -72,6 +72,11 @@ namespace CppSharp.Passes @@ -72,6 +72,11 @@ namespace CppSharp.Passes
Driver.Diagnostics.EmitWarning("Duplicate operator {0} ignored", method.Name);
method.ExplicityIgnored = true;
}
else if (method.IsConstructor)
{
Driver.Diagnostics.EmitWarning("Duplicate constructor {0} ignored", method.Name);
method.ExplicityIgnored = true;
}
else
method.Name += methodCount.ToString(CultureInfo.InvariantCulture);
return true;

28
src/Generator/Types/TypeMap.cs

@ -135,19 +135,6 @@ namespace CppSharp.Types @@ -135,19 +135,6 @@ namespace CppSharp.Types
{
var typePrinter = new CppTypePrinter(this);
if (FindTypeMap(type.Visit(typePrinter), out typeMap))
{
typeMap.Type = type;
return true;
}
typePrinter.PrintLocalName = true;
if (FindTypeMap(type.Visit(typePrinter), out typeMap))
{
typeMap.Type = type;
return true;
}
TemplateSpecializationType template = type as TemplateSpecializationType;
if (template != null)
{
@ -156,7 +143,7 @@ namespace CppSharp.Types @@ -156,7 +143,7 @@ namespace CppSharp.Types
typeMap.Type = type;
return true;
}
typePrinter.PrintLocalName = false;
typePrinter.PrintLocalName = true;
if (FindTypeMap(template.Template.TemplatedDecl.Visit(typePrinter), out typeMap))
{
typeMap.Type = type;
@ -164,6 +151,19 @@ namespace CppSharp.Types @@ -164,6 +151,19 @@ namespace CppSharp.Types
}
}
if (FindTypeMap(type.Visit(typePrinter), out typeMap))
{
typeMap.Type = type;
return true;
}
typePrinter.PrintLocalName = false;
if (FindTypeMap(type.Visit(typePrinter), out typeMap))
{
typeMap.Type = type;
return true;
}
return false;
}

2
tests/CSharpTemp/CSharpTemp.Tests.cs

@ -68,7 +68,7 @@ public class CSharpTempTests @@ -68,7 +68,7 @@ public class CSharpTempTests
Assert.That(proprietor.Value, Is.EqualTo(20));
proprietor.Prop = 50;
Assert.That(proprietor.Prop, Is.EqualTo(50));
var p = new P();
var p = new P(null);
p.Value = 20;
Assert.That(p.Value, Is.EqualTo(30));
p.Prop = 50;

10
tests/CSharpTemp/CSharpTemp.cpp

@ -150,6 +150,16 @@ void ComplexType::takesQFlags(const QFlags<int> f) @@ -150,6 +150,16 @@ void ComplexType::takesQFlags(const QFlags<int> f)
}
P::P(const Qux &qux)
{
}
P::P(Qux *qux)
{
}
ComplexType P::complexType()
{
return m_complexType;

3
tests/CSharpTemp/CSharpTemp.cs

@ -12,7 +12,8 @@ namespace CppSharp.Tests @@ -12,7 +12,8 @@ namespace CppSharp.Tests
{
public override string CSharpSignature(CSharpTypePrinterContext ctx)
{
TemplateArgument templateArgument = ((TemplateSpecializationType) ctx.Type.Desugar()).Arguments[0];
TemplateArgument templateArgument =
((TemplateSpecializationType) ctx.Type.Desugar()).Arguments[0];
return templateArgument.Type.Type.ToString();
}

3
tests/CSharpTemp/CSharpTemp.h

@ -113,6 +113,9 @@ public: @@ -113,6 +113,9 @@ public:
class DLL_API P : Proprietor
{
public:
P(const Qux& qux);
P(Qux* qux);
virtual void setValue(int value);
virtual long prop();

Loading…
Cancel
Save