Browse Source

Added a test about operators in nested classes.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/72/head
Dimitar Dobrev 12 years ago
parent
commit
5b6beaaf33
  1. 9
      src/Generator/Passes/CheckAmbiguousFunctions.cs
  2. 3
      tests/CSharpTemp/CSharpTemp.Tests.cs
  3. 5
      tests/CSharpTemp/CSharpTemp.cpp
  4. 6
      tests/CSharpTemp/CSharpTemp.h

9
src/Generator/Passes/CheckAmbiguousFunctions.cs

@ -36,15 +36,8 @@ namespace CppSharp.Passes @@ -36,15 +36,8 @@ namespace CppSharp.Passes
foreach (var overload in overloads)
{
if (function.OperatorKind == CXXOperatorKind.Conversion)
{
if (function != overload &&
function.OriginalReturnType == overload.OriginalReturnType)
{
overload.ExplicityIgnored = true;
function.IsAmbiguous = true;
}
continue;
}
if (overload == function) continue;
if (overload.Ignore) continue;

3
tests/CSharpTemp/CSharpTemp.Tests.cs

@ -46,5 +46,8 @@ public class CSharpTempTests @@ -46,5 +46,8 @@ public class CSharpTempTests
Assert.That(baz.returnQux().farAwayFunc(), Is.EqualTo(20));
int cast = baz;
Assert.That(cast, Is.EqualTo(500));
var nested = new Baz.Nested();
int nestedCast = nested;
Assert.That(nestedCast, Is.EqualTo(300));
}
}

5
tests/CSharpTemp/CSharpTemp.cpp

@ -46,6 +46,11 @@ Foo& Bar::operator[](int i) @@ -46,6 +46,11 @@ Foo& Bar::operator[](int i)
return m_foo;
}
Baz::Nested::operator int() const
{
return 300;
}
int Baz::takesQux(const Qux& qux)
{
return qux.farAwayFunc();

6
tests/CSharpTemp/CSharpTemp.h

@ -38,6 +38,12 @@ private: @@ -38,6 +38,12 @@ private:
class DLL_API Baz : public Foo, public Bar
{
public:
class DLL_API Nested
{
public:
operator int() const;
};
int takesQux(const Qux& qux);
Qux returnQux();
operator int() const;

Loading…
Cancel
Save