From 68d8108ab363810db8dc2be50901bcd36d954878 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sun, 2 Apr 2017 10:54:04 +0200 Subject: [PATCH] Fix sipify constructor detection --- scripts/sipify.pl | 2 +- tests/scripts/sipifyheader.expected.sip | 13 ++++++++++++- tests/scripts/sipifyheader.h | 14 ++++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/scripts/sipify.pl b/scripts/sipify.pl index 90f35d4865d..d2a4dd8a7c4 100755 --- a/scripts/sipify.pl +++ b/scripts/sipify.pl @@ -253,7 +253,7 @@ while(!eof $header){ $line =~ s/\s*=\s*default\b//g; # remove constructor definition - if ( $line =~ m/^(\s*)?(explicit )?(\w+)\(([^()]*\([^()]*\)[^()]*)*\)(?!;)$/ ){ + if ( $line =~ m/^(\s*)?(explicit )?(\w+)\([\w\=\(\)\s\,\&\*\<\>]*\)(?!;)$/ ){ my $newline = $line =~ s/\n/;\n/r; my $nesting_index = 0; while(!eof $header){ diff --git a/tests/scripts/sipifyheader.expected.sip b/tests/scripts/sipifyheader.expected.sip index 02a432edbc3..ab79f1fcb30 100644 --- a/tests/scripts/sipifyheader.expected.sip +++ b/tests/scripts/sipifyheader.expected.sip @@ -66,6 +66,17 @@ A constructor with definition in header A classic constructor with arguments %End + QgsSipifyHeader( bool a = true ); +%Docstring +A constructor with no empty `()` +%End + + QgsSipifyHeader( QList a, const Issues &b = Issues::weDontHaveIssues(), QgsClass *b = 0 ); +%Docstring +A constructor with some special character types +%End + {} + QgsSipifyHeader(); %Docstring Default constructor @@ -108,7 +119,7 @@ Factory annotation void differentDefaultValue( bool defaultValue = false , QWidget *parent = 0, QString msg = "hello" ); - void differentType( QList &list ); + void differentType( QList & list ); void complexDefaultValueAndType( QList>> list = QList>> ); %Docstring diff --git a/tests/scripts/sipifyheader.h b/tests/scripts/sipifyheader.h index 7e3386cfe04..ff5c1e51d32 100644 --- a/tests/scripts/sipifyheader.h +++ b/tests/scripts/sipifyheader.h @@ -101,6 +101,16 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass, private QgsBaseCla */ QgsSipifyHeader( QWidget *parent SIP_TRANSFERTHIS = nullptr ); + //! A constructor with no empty `()` + QgsSipifyHeader( bool a = true ) + : mMember( nullptr ) + {} + + //! A constructor with some special character types + QgsSipifyHeader( QList a, const Issues &b = Issues::weDontHaveIssues(), QgsClass *b = nullptr ) + : mMember( nullptr ) + {} + //! Default constructor QgsSipifyHeader() = default; @@ -139,7 +149,7 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass, private QgsBaseCla void differentDefaultValue( bool defaultValue = true SIP_PYDEFAULTVALUE( false ), QWidget *parent = nullptr, QString msg = QString() SIP_PYDEFAULTVALUE( "hello" ) ); - void differentType( QList SIP_PYTYPE( QList ) &list ); + void differentType( QList SIP_PYTYPE( QList ) & list ); //! complex default value and type (i.e. containing commas) should be given as a string with single quotes void complexDefaultValueAndType( QList>> list = QList>>() SIP_PYDEFAULTVALUE( 'QList>>()' ) ); @@ -152,7 +162,7 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass, private QgsBaseCla void removeProxyFactory( QNetworkProxyFactory *factory SIP_TRANSFERBACK ); - bool removeFunctionBody( const QList &list, QgsVectorLayer *vl ) { doSomething; return true; } // some comments + bool removeFunctionBody( const QList &list, QgsVectorLayer *vl ) { doSomething; return true; } // some comments bool deletedFunction() = delete; // some comments