Browse Source

Improved the handling of function calls in default args.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/256/merge
Dimitar Dobrev 10 years ago
parent
commit
132509203b
  1. 4
      src/Generator/Generators/CSharp/CSharpExpressionPrinter.cs
  2. 1
      tests/CSharp/CSharp.Tests.cs
  3. 9
      tests/CSharp/CSharp.cpp
  4. 2
      tests/CSharp/CSharp.h

4
src/Generator/Generators/CSharp/CSharpExpressionPrinter.cs

@ -50,11 +50,13 @@ namespace CppSharp.Generators.CSharp @@ -50,11 +50,13 @@ namespace CppSharp.Generators.CSharp
};
case GenerationKind.Internal:
// a non-ctor can only be internal if it's been converted to a property
var property = ((Class) callExpr.Declaration.Namespace).Properties.First(
p => p.GetMethod == callExpr.Declaration);
return new CSharpExpressionPrinterResult
{
Value = string.Format("{0}.{1}",
typePrinter.VisitDeclaration(callExpr.Declaration.Namespace),
callExpr.Declaration.Name)
property.Name)
};
default:
return new CSharpExpressionPrinterResult { Value = expr.String };

1
tests/CSharp/CSharp.Tests.cs

@ -199,6 +199,7 @@ public class CSharpTests : GeneratorTestFixture @@ -199,6 +199,7 @@ public class CSharpTests : GeneratorTestFixture
methodsWithDefaultValues.DefaultWithRefManagedLong();
methodsWithDefaultValues.DefaultWithFunctionCall();
methodsWithDefaultValues.DefaultWithPropertyCall();
methodsWithDefaultValues.DefaultWithGetPropertyCall();
}
}

9
tests/CSharp/CSharp.cpp

@ -53,6 +53,11 @@ int Foo::propertyCall() @@ -53,6 +53,11 @@ int Foo::propertyCall()
return 1;
}
int Foo::getGetPropertyCall()
{
return 1;
}
const Foo& Bar::operator[](int i) const
{
return m_foo;
@ -502,6 +507,10 @@ void MethodsWithDefaultValues::defaultWithPropertyCall(int f) @@ -502,6 +507,10 @@ void MethodsWithDefaultValues::defaultWithPropertyCall(int f)
{
}
void MethodsWithDefaultValues::defaultWithGetPropertyCall(int f)
{
}
int MethodsWithDefaultValues::getA()
{
return m_foo.A;

2
tests/CSharp/CSharp.h

@ -19,6 +19,7 @@ public: @@ -19,6 +19,7 @@ public:
static const int rename = 5;
static int makeFunctionCall();
static int propertyCall();
static int getGetPropertyCall();
protected:
int P;
@ -368,6 +369,7 @@ public: @@ -368,6 +369,7 @@ public:
void defaultWithRefManagedLong(long long* i = 0);
void defaultWithFunctionCall(int f = Foo::makeFunctionCall());
void defaultWithPropertyCall(int f = Foo::propertyCall());
void defaultWithGetPropertyCall(int f = Foo::getGetPropertyCall());
int getA();
private:
Foo m_foo;

Loading…
Cancel
Save