From ded67db971a2d185dc999255942141e54b44c478 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 18 Jan 2017 23:03:16 +0000 Subject: Bindings: Handle const-ref of non-record parameter defaults --- find-modules/sip_generator.py | 6 +++++- tests/GenerateSipBindings/cpplib.cpp | 5 +++++ tests/GenerateSipBindings/cpplib.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/find-modules/sip_generator.py b/find-modules/sip_generator.py index 35f6667d..7804b3ae 100644 --- a/find-modules/sip_generator.py +++ b/find-modules/sip_generator.py @@ -579,7 +579,9 @@ class SipGenerator(object): result = parameter.type.get_declaration().type if parameter.type.kind == TypeKind.LVALUEREFERENCE: - return parameter.type.get_pointee().get_declaration().type + if parameter.type.get_pointee().get_declaration().type.kind != TypeKind.INVALID: + return parameter.type.get_pointee().get_declaration().type + return parameter.type.get_pointee() if parameter.type.get_declaration().type.kind == TypeKind.INVALID: return parameter.type @@ -603,6 +605,8 @@ class SipGenerator(object): return "0" if parameterType.kind == TypeKind.POINTER: return "nullptr" + if parameterType.spelling.startswith("const "): + return parameterType.spelling[6:] + "()" return parameterType.spelling + "()" if not "::" in parameterType.spelling: return text diff --git a/tests/GenerateSipBindings/cpplib.cpp b/tests/GenerateSipBindings/cpplib.cpp index 863c456e..47370ca0 100644 --- a/tests/GenerateSipBindings/cpplib.cpp +++ b/tests/GenerateSipBindings/cpplib.cpp @@ -125,6 +125,11 @@ void MyObject::intBraces(int i) } +void MyObject::intRefBraces(int const& s) +{ + +} + void MyObject::pointerBraces(int* p) { diff --git a/tests/GenerateSipBindings/cpplib.h b/tests/GenerateSipBindings/cpplib.h index 8333e7f0..a91b5486 100644 --- a/tests/GenerateSipBindings/cpplib.h +++ b/tests/GenerateSipBindings/cpplib.h @@ -57,6 +57,7 @@ public: void stringBraces(QString s = {}); void stringRefBraces(QString const& s = {}); void intBraces(int i = {}); + void intRefBraces(int const& i = {}); void pointerBraces(int* p = {}); int const_parameters(const int input, QObject* const obj = 0) const; -- cgit v1.2.1