Navigation Menu

Skip to content

Commit

Permalink
[sipify] use single regex for all double annotation cases
Browse files Browse the repository at this point in the history
followup ac54a3f
  • Loading branch information
3nids committed May 4, 2017
1 parent f7f32e6 commit eda1730
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
8 changes: 2 additions & 6 deletions scripts/sipify.pl
Expand Up @@ -574,14 +574,10 @@ sub remove_constructor_or_body {
$line =~ s/SIP_PYNAME\(\s*(\w+)\s*\)/\/PyName=$1\//;

# combine multiple annotations
# https://regex101.com/r/uvCt4M/1
do {no warnings 'uninitialized';
$line =~ s/\/(\w+(=\w+)?)\/\s*\/(\w+(=\w+)?)\/\s*;(\s*(\/\/.*)?)$/\/$1,$3\/$5;/;
(! $3) or dbg_info("combine multiple annotations -- works only for 2");
};
# combine multiple argument annotations
# https://regex101.com/r/uvCt4M/3
do {no warnings 'uninitialized';
$line =~ s/\/(\w+(=\w+)?)\/\s*\/(\w+(=\w+)?)\//\/$1,$3\//;
(! $3) or dbg_info("combine multiple annotations -- works only for 2");
};

# unprinted annotations
Expand Down
3 changes: 1 addition & 2 deletions tests/scripts/sipifyheader.expected.sip
Expand Up @@ -208,8 +208,6 @@ complex default value and type (i.e. containing commas) should be given as a str

void removeProxyFactory( QNetworkProxyFactory *factory /TransferBack/ );

void multiAnnotationArg( SomeClass **object /Out,TransferBack/, int &another /Out/ );

bool removeFunctionBody( const QList<int, QString> &list, QgsVectorLayer *vl, Some::Thing _part = -1 /*default =-1*/ );
%Docstring
:rtype: bool
Expand Down Expand Up @@ -303,6 +301,7 @@ Mulitline body
}

void combinedAnnotations() /Factory,PyName=otherName/;
void multiAnnotationArg( SomeClass **object /Out,TransferBack/, int &another /Out/ );

void simple( );
%Docstring
Expand Down
3 changes: 1 addition & 2 deletions tests/scripts/sipifyheader.h
Expand Up @@ -240,8 +240,6 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas

void removeProxyFactory( QNetworkProxyFactory *factory SIP_TRANSFERBACK );

void multiAnnotationArg( SomeClass **object SIP_OUT SIP_TRANSFERBACK, int &another SIP_OUT );

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

static inline QgsMapLayer *skippedMethodWithBody() SIP_SKIP
Expand Down Expand Up @@ -331,6 +329,7 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas
}

void combinedAnnotations() SIP_FACTORY SIP_PYNAME( otherName );
void multiAnnotationArg( SomeClass **object SIP_OUT SIP_TRANSFERBACK, int &another SIP_OUT );

//! remove argument
void simple( bool test SIP_PYARGREMOVE );
Expand Down

0 comments on commit eda1730

Please sign in to comment.