Browse Source

Extended the check for duplicate names to ignore repeated operators since they cannot be renamed. Added an ignored test for an unrelated run-time issue.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/49/head
Dimitar Dobrev 13 years ago
parent
commit
d9bc5bec86
  1. 6
      src/Generator/Passes/CheckDuplicatedNamesPass.cs
  2. 9
      tests/Basic/Basic.Tests.cs
  3. 14
      tests/Basic/Basic.cpp
  4. 3
      tests/Basic/Basic.h

6
src/Generator/Passes/CheckDuplicatedNamesPass.cs

@ -37,7 +37,7 @@ namespace CppSharp.Passes
return true; return true;
} }
private bool UpdateName(Method method) private bool UpdateName(Function method)
{ {
var @params = method.Parameters.Where(p => p.Kind != ParameterKind.IndirectReturnType) var @params = method.Parameters.Where(p => p.Kind != ParameterKind.IndirectReturnType)
.Select(p => p.QualifiedType.ToString()); .Select(p => p.QualifiedType.ToString());
@ -57,6 +57,10 @@ namespace CppSharp.Passes
if (Count < methodCount+1) if (Count < methodCount+1)
Count = methodCount+1; Count = methodCount+1;
if (method.IsOperator)
// TODO: turn into a method; append the original type (say, "signed long") of the last parameter to the type so that the user knows which overload is called
method.ExplicityIgnored = true;
else
method.Name += methodCount.ToString(CultureInfo.InvariantCulture); method.Name += methodCount.ToString(CultureInfo.InvariantCulture);
return true; return true;
} }

9
tests/Basic/Basic.Tests.cs

@ -52,5 +52,14 @@ public class BasicTests
Assert.That(barSum.A, Is.EqualTo(bar.A + bar1.A)); Assert.That(barSum.A, Is.EqualTo(bar.A + bar1.A));
Assert.That(barSum.B, Is.EqualTo(bar.B + bar1.B)); Assert.That(barSum.B, Is.EqualTo(bar.B + bar1.B));
} }
[Test, Ignore]
public void TestLeftShiftOperator()
{
Foo2 foo2 = new Foo2();
foo2.C = 2;
Foo2 result = foo2 << 3;
Assert.That(result.C, Is.EqualTo(16));
}
} }

14
tests/Basic/Basic.cpp

@ -4,6 +4,20 @@ Foo::Foo()
{ {
} }
Foo2& Foo2::operator <<(signed int i)
{
Foo2 foo;
foo.C = C << i;
return foo;
}
Foo2& Foo2::operator <<(signed long l)
{
Foo2 foo;
foo.C = C << l;
return foo;
}
Bar::Bar() Bar::Bar()
{ {
} }

3
tests/Basic/Basic.h

@ -22,6 +22,9 @@ class DLL_API Foo2 : public Foo
public: public:
int C; int C;
Foo2& operator<<(signed int i);
Foo2& operator<<(signed long l);
}; };
struct DLL_API Bar struct DLL_API Bar

Loading…
Cancel
Save