Skip to content

Commit 2aba4c5

Browse files
committed
Merge remote-tracking branch 'upstream/master' into sip-annotated
2 parents a26a6ef + 298e14b commit 2aba4c5

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

scripts/sipify.pl

+9-4
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ sub remove_constructor_or_body {
9999
|| $line =~ m/SIP_SKIP\s*(?!;)\s*(\/\/.*)?$/ ){
100100
dbg_info("remove constructor definition, function bodies, member initializing list");
101101
my $newline = "$1$2$3$4$5;";
102-
if ($line !~ m/{.*}(\s*SIP_\w+)?\s*(\/\/.*)?$/){
102+
if ($line !~ m/{.*}(\s*SIP_\w+)*\s*(\/\/.*)?$/){
103103
dbg_info(" go for multiline");
104104
$line = $lines[$line_idx];
105105
$line_idx++;
@@ -554,6 +554,7 @@ sub remove_constructor_or_body {
554554
# remove export macro from struct definition
555555
$line =~ s/^(\s*struct )\w+_EXPORT (.+)$/$1$2/;
556556

557+
# printed annotations
557558
$line =~ s/\bSIP_FACTORY\b/\/Factory\//;
558559
$line =~ s/\bSIP_OUT\b/\/Out\//g;
559560
$line =~ s/\bSIP_IN\b/\/In\//g;
@@ -565,11 +566,16 @@ sub remove_constructor_or_body {
565566
$line =~ s/\bSIP_RELEASEGIL\b/\/ReleaseGIL\//;
566567
$line =~ s/\bSIP_ARRAY\b/\/Array\//;
567568
$line =~ s/\bSIP_ARRAYSIZE\b/\/ArraySize\//;
568-
569569
$line =~ s/SIP_PYNAME\(\s*(\w+)\s*\)/\/PyName=$1\//;
570+
571+
# combine multiple annotations
572+
dbg_info("combine multiple annotations -- works only for 2");
573+
# https://regex101.com/r/uvCt4M/1
574+
$line =~ s/\/(\w+(=\w+)?)\/\s*\/(\w+(=\w+)?)\/\s*;(\s*(\/\/.*)?)$/\/$1,$3\/$5;/;
575+
576+
# unprinted annotations
570577
$line =~ s/(\w+)(\<(?>[^<>]|(?2))*\>)?\s+SIP_PYARGTYPE\(\s*\'?([^()']+)(\(\s*(?:[^()]++|(?2))*\s*\))?\'?\s*\)/$3/g;
571578
$line =~ s/=\s+[^=]*?\s+SIP_PYARGDEFAULT\(\s*\'?([^()']+)(\(\s*(?:[^()]++|(?2))*\s*\))?\'?\s*\)/= $1/g;
572-
573579
# remove argument
574580
if ($line =~ m/SIP_PYARGREMOVE/){
575581
if ( $MULTILINE_DEFINITION == 1 ){
@@ -588,7 +594,6 @@ sub remove_constructor_or_body {
588594
# see https://regex101.com/r/5iNptO/4
589595
$line =~ s/(?<coma>, +)?(const )?(\w+)(\<(?>[^<>]|(?4))*\>)? [\w&*]+ SIP_PYARGREMOVE( = [^()]*(\(\s*(?:[^()]++|(?6))*\s*\))?)?(?(<coma>)|,?)//g;
590596
}
591-
592597
$line =~ s/SIP_FORCE//;
593598

594599
# fix astyle placing space after % character

tests/scripts/sipifyheader.expected.sip

+2
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ Mulitline body
290290
VertexType type;
291291
}
292292

293+
void combinedAnnotations() /Factory,PyName=otherName/;
294+
293295
void simple( );
294296
%Docstring
295297
remove argument

tests/scripts/sipifyheader.h

+2
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas
316316
VertexType type;
317317
}
318318

319+
void combinedAnnotations() SIP_FACTORY SIP_PYNAME(otherName);
320+
319321
//! remove argument
320322
void simple( bool test SIP_PYARGREMOVE );
321323
void method( bool myArg SIP_PYARGREMOVE = test );

0 commit comments

Comments
 (0)