Browse Source

Removed default parameters when they use ignored declarations.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/681/head
Dimitar Dobrev 9 years ago
parent
commit
9d940c8f51
  1. 14
      src/Generator/Passes/HandleDefaultParamValuesPass.cs
  2. 1
      tests/CSharp/CSharp.Tests.cs
  3. 4
      tests/CSharp/CSharp.cpp
  4. 1
      tests/CSharp/CSharp.h

14
src/Generator/Passes/HandleDefaultParamValuesPass.cs

@ -47,7 +47,10 @@ namespace CppSharp.Passes @@ -47,7 +47,10 @@ namespace CppSharp.Passes
var result = parameter.DefaultArgument.String;
if (PrintExpression(parameter.Type, parameter.DefaultArgument, ref result) == null)
overloadIndices.Add(function.Parameters.IndexOf(parameter));
parameter.DefaultArgument.String = result;
if (string.IsNullOrEmpty(result))
parameter.DefaultArgument = null;
else
parameter.DefaultArgument.String = result;
}
GenerateOverloads(function, overloadIndices);
@ -70,7 +73,14 @@ namespace CppSharp.Passes @@ -70,7 +73,14 @@ namespace CppSharp.Passes
return true;
if (expression.Class == StatementClass.Call)
return expression.Declaration.Ignore ? false : (bool?) null;
{
if (expression.Declaration.Ignore)
{
result = null;
return false;
}
return null;
}
var defaultConstruct = CheckForDefaultConstruct(desugared, expression, ref result);
if (defaultConstruct != false)

1
tests/CSharp/CSharp.Tests.cs

@ -216,6 +216,7 @@ public unsafe class CSharpTests : GeneratorTestFixture @@ -216,6 +216,7 @@ public unsafe class CSharpTests : GeneratorTestFixture
methodsWithDefaultValues.DefaultWithEnumInLowerCasedNameSpace();
methodsWithDefaultValues.DefaultWithCharFromInt();
methodsWithDefaultValues.DefaultWithFreeConstantInNameSpace();
methodsWithDefaultValues.DefaultWithStdNumericLimits(5);
}
}

4
tests/CSharp/CSharp.cpp

@ -591,6 +591,10 @@ void MethodsWithDefaultValues::defaultWithFreeConstantInNameSpace(int c) @@ -591,6 +591,10 @@ void MethodsWithDefaultValues::defaultWithFreeConstantInNameSpace(int c)
{
}
void MethodsWithDefaultValues::defaultWithStdNumericLimits(int i)
{
}
int MethodsWithDefaultValues::getA()
{
return m_foo.A;

1
tests/CSharp/CSharp.h

@ -413,6 +413,7 @@ public: @@ -413,6 +413,7 @@ public:
void defaultWithEnumInLowerCasedNameSpace(lowerCaseNameSpace::Enum e = lowerCaseNameSpace::Enum::Item2);
void defaultWithCharFromInt(char c = 32);
void defaultWithFreeConstantInNameSpace(int c = HasFreeConstant::FREE_CONSTANT_IN_NAMESPACE);
void defaultWithStdNumericLimits(int i = std::numeric_limits<double>::infinity());
int getA();
private:
Foo m_foo;

Loading…
Cancel
Save