Skip to content

Commit 9688b81

Browse files
committed
followup 45266cd
1 parent 45266cd commit 9688b81

File tree

3 files changed

+46
-12
lines changed

3 files changed

+46
-12
lines changed

scripts/sipify.pl

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,12 @@ sub processDoxygenLine
441441
$line =~ s/\s*=\s*default\b//g;
442442

443443
# remove constructor definition, function bodies, member initializing list
444-
if ( $SIP_RUN != 1 && $line =~ m/^(\s*)?(explicit )?(virtual )?(static |const )*(([\w:]+(<.*?>)?\s+(\*|&)?)?(\w+|operator.{1,2})\([\w=()\/ ,&*<>:]*\)( (?:const|SIP_[A-Z_]*?))*)\s*(\{.*\})?(?!;)(\s*\/\/.*)?$/ ){
444+
if ( $SIP_RUN != 1 && $line =~ m/^(\s*)?(explicit )?(virtual )?(static |const )*(([\w:]+(<.*?>)?\s+(\*|&)?)?(\w+|operator.{1,2})\([\w=()\/ ,&*<>:-]*\)( (?:const|SIP_[A-Z_]*?))*)\s*(\{.*\})?(?!;)(\s*\/\/.*)?$/ ){
445445
my $newline = "$1$2$3$4$5;";
446446
if ($line !~ m/\{.*?\}$/){
447447
$line = $lines[$line_idx];
448448
$line_idx++;
449-
while ( $line =~ m/^\s*[:,] \w+\(.*?\)/){
449+
while ( $line =~ m/^\s*[:,] [\w<>]+\(.*?\)/){
450450
$line = $lines[$line_idx];
451451
$line_idx++;
452452
}
@@ -455,14 +455,11 @@ sub processDoxygenLine
455455
while ($line_idx < $line_count){
456456
$line = $lines[$line_idx];
457457
$line_idx++;
458-
if ( $line =~ m/^\s*{/ ){
459-
$nesting_index++;
460-
}
461-
elsif ( $line =~ m/\}\s*$/ ){
462-
$nesting_index--;
463-
if ($nesting_index == 0){
464-
last;
465-
}
458+
459+
$nesting_index += $line =~ tr/\{//;
460+
$nesting_index -= $line =~ tr/\}//;
461+
if ($nesting_index == 0){
462+
last;
466463
}
467464
}
468465
}
@@ -533,6 +530,24 @@ sub processDoxygenLine
533530
if ( $MULTILINE_DEFINITION == 1 ){
534531
if ( $line =~ m/^[^()]*([^()]*\([^()]*\)[^()]*)*\)[^()]*$/){
535532
$MULTILINE_DEFINITION = 0;
533+
# remove potential following body
534+
if ( $lines[$line_idx] =~ m/^\s*\{$/ ){
535+
my $last_line = $line;
536+
my $nesting_index = 0;
537+
while ($line_idx < $line_count){
538+
$line = $lines[$line_idx];
539+
$line_idx++;
540+
541+
$nesting_index += $line =~ tr/\{//;
542+
$nesting_index -= $line =~ tr/\}//;
543+
if ($nesting_index == 0){
544+
last;
545+
}
546+
}
547+
# add missing semi column
548+
pop(@output);
549+
push @output, "$last_line;\n";
550+
}
536551
}
537552
else
538553
{

tests/scripts/sipifyheader.expected.sip

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class QgsSipifyHeader : QtClass<QVariant>
7575
struct Data
7676
{
7777
Data( QgsMapLayer *layer, Qstring name );
78+
7879
QString mName;
7980
int mCount;
8081
QgsMapLayer *mLayer;
@@ -84,6 +85,7 @@ class QgsSipifyHeader : QtClass<QVariant>
8485
%Docstring
8586
A constructor with definition in header
8687
%End
88+
8789
QgsSipifyHeader( QWidget *parent /TransferThis/ = 0 );
8890
%Docstring
8991
A classic constructor with arguments
@@ -93,6 +95,7 @@ A constructor with definition in header
9395
%Docstring
9496
A constructor with no empty `()`
9597
%End
98+
9699
QgsSipifyHeader( QList<Point> a, const Issues &b = Issues::weDontHaveIssues(), QgsClass *b = 0 );
97100
%Docstring
98101
A constructor with some special character types
@@ -188,11 +191,16 @@ complex default value and type (i.e. containing commas) should be given as a str
188191

189192
void removeProxyFactory( QNetworkProxyFactory *factory /TransferBack/ );
190193

191-
bool removeFunctionBody( const QList<int, QString> &list, QgsVectorLayer *vl );
194+
bool removeFunctionBody( const QList<int, QString> &list, QgsVectorLayer *vl, Some::Thing _part = -1 /*default =-1*/ );
192195
%Docstring
193196
:rtype: bool
194197
%End
195198

199+
void multilineBodyAndDefinition( const QList<int,
200+
QString> &list,
201+
QgsVectorLayer *vl,
202+
Some::Thing _part = -1 /*default =-1*/ );
203+
196204
QgsRaster::RasterBuildPyramids buildPyramidsFlag() const;
197205
%Docstring
198206
Removing function body with namespaced return value
@@ -306,6 +314,7 @@ class ClassWithPrivateInheritanceOnly
306314
%Docstring
307315
A constructor with definition in header on several lines
308316
%End
317+
309318
};
310319

311320

@@ -323,6 +332,7 @@ class AbstractClass /Abstract/
323332
%Docstring
324333
A constructor
325334
%End
335+
326336
};
327337

328338
QFlags<QgsSipifyHeader::MyEnum> operator|(QgsSipifyHeader::MyEnum f1, QFlags<QgsSipifyHeader::MyEnum> f2);

tests/scripts/sipifyheader.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas
217217

218218
void removeProxyFactory( QNetworkProxyFactory *factory SIP_TRANSFERBACK );
219219

220-
bool removeFunctionBody( const QList<int, QString> &list, QgsVectorLayer *vl ) { doSomething; return true; } // some comments
220+
bool removeFunctionBody( const QList<int, QString> &list, QgsVectorLayer *vl, Some::Thing _part = -1 /*default =-1*/ ) { doSomething; return true; } // some comments
221221

222222
static inline QgsMapLayer *skippedMethodWithBody() SIP_SKIP
223223
{
@@ -228,6 +228,15 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas
228228
}
229229
}
230230

231+
void multilineBodyAndDefinition( const QList<int,
232+
QString> &list,
233+
QgsVectorLayer *vl,
234+
Some::Thing _part = -1 /*default =-1*/ )
235+
{
236+
doSomething;
237+
return true;
238+
}
239+
231240
//! Removing function body with namespaced return value
232241
QgsRaster::RasterBuildPyramids buildPyramidsFlag() const { return mBuildPyramidsFlag; }
233242

0 commit comments

Comments
 (0)