Browse Source

Fixed the wrapping of default args assigned with a ctor expression with more than one param.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/496/merge
Dimitar Dobrev 10 years ago
parent
commit
ad6555f957
  1. 3
      src/Generator/Passes/HandleDefaultParamValuesPass.cs
  2. 1
      tests/CSharpTemp/CSharpTemp.Tests.cs
  3. 8
      tests/CSharpTemp/CSharpTemp.cpp
  4. 7
      tests/CSharpTemp/CSharpTemp.h

3
src/Generator/Passes/HandleDefaultParamValuesPass.cs

@ -5,7 +5,6 @@ using CppSharp.AST;
using CppSharp.AST.Extensions; using CppSharp.AST.Extensions;
using CppSharp.Generators.CSharp; using CppSharp.Generators.CSharp;
using CppSharp.Types; using CppSharp.Types;
using Type = CppSharp.AST.Type;
namespace CppSharp.Passes namespace CppSharp.Passes
{ {
@ -14,7 +13,7 @@ namespace CppSharp.Passes
private static readonly Regex regexFunctionParams = new Regex(@"\(?(.+)\)?", RegexOptions.Compiled); private static readonly Regex regexFunctionParams = new Regex(@"\(?(.+)\)?", RegexOptions.Compiled);
private static readonly Regex regexDoubleColon = new Regex(@"\w+::", RegexOptions.Compiled); private static readonly Regex regexDoubleColon = new Regex(@"\w+::", RegexOptions.Compiled);
private static readonly Regex regexName = new Regex(@"(\w+)", RegexOptions.Compiled); private static readonly Regex regexName = new Regex(@"(\w+)", RegexOptions.Compiled);
private static readonly Regex regexCtor = new Regex(@"^([\w<,>:]+)\s*(\(\w*\))$", RegexOptions.Compiled); private static readonly Regex regexCtor = new Regex(@"^([\w<,>:]+)\s*(\([\w, ]*\))$", RegexOptions.Compiled);
public HandleDefaultParamValuesPass() public HandleDefaultParamValuesPass()
{ {

1
tests/CSharpTemp/CSharpTemp.Tests.cs

@ -153,6 +153,7 @@ public class CSharpTempTests : GeneratorTestFixture
methodsWithDefaultValues.DefaultPointerToValueType(); methodsWithDefaultValues.DefaultPointerToValueType();
methodsWithDefaultValues.DefaultDoubleWithoutF(); methodsWithDefaultValues.DefaultDoubleWithoutF();
methodsWithDefaultValues.DefaultIntExpressionWithEnum(); methodsWithDefaultValues.DefaultIntExpressionWithEnum();
methodsWithDefaultValues.DefaultCtorWithMoreThanOneArg();
} }
[Test] [Test]

8
tests/CSharpTemp/CSharpTemp.cpp

@ -289,6 +289,10 @@ QGenericArgument::QGenericArgument(const char *name)
_name = name; _name = name;
} }
MethodsWithDefaultValues::QMargins::QMargins(int left, int top, int right, int bottom)
{
}
MethodsWithDefaultValues::MethodsWithDefaultValues(Foo foo) MethodsWithDefaultValues::MethodsWithDefaultValues(Foo foo)
{ {
m_foo = foo; m_foo = foo;
@ -403,6 +407,10 @@ void MethodsWithDefaultValues::defaultIntExpressionWithEnum(int i)
{ {
} }
void MethodsWithDefaultValues::defaultCtorWithMoreThanOneArg(QMargins m)
{
}
int MethodsWithDefaultValues::getA() int MethodsWithDefaultValues::getA()
{ {
return m_foo.A; return m_foo.A;

7
tests/CSharpTemp/CSharpTemp.h

@ -265,6 +265,12 @@ class QList
class DLL_API MethodsWithDefaultValues : public Quux class DLL_API MethodsWithDefaultValues : public Quux
{ {
public: public:
class DLL_API QMargins
{
public:
QMargins(int left, int top, int right, int bottom);
};
MethodsWithDefaultValues(Foo foo = Foo()); MethodsWithDefaultValues(Foo foo = Foo());
MethodsWithDefaultValues(int a); MethodsWithDefaultValues(int a);
MethodsWithDefaultValues(double d, QList<QColor> list = QList<QColor>()); MethodsWithDefaultValues(double d, QList<QColor> list = QList<QColor>());
@ -293,6 +299,7 @@ public:
void defaultPointerToValueType(QGenericArgument* pointer = 0); void defaultPointerToValueType(QGenericArgument* pointer = 0);
void defaultDoubleWithoutF(double d1 = 1.0, double d2 = 1.); void defaultDoubleWithoutF(double d1 = 1.0, double d2 = 1.);
void defaultIntExpressionWithEnum(int i = Qt::GlobalColor::black + 1); void defaultIntExpressionWithEnum(int i = Qt::GlobalColor::black + 1);
void defaultCtorWithMoreThanOneArg(QMargins m = QMargins(0, 0, 0, 0));
int getA(); int getA();
private: private:
Foo m_foo; Foo m_foo;

Loading…
Cancel
Save