Skip to content

Commit

Permalink
[sipify] Combine multiple argument annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 3, 2017
1 parent 5068024 commit ac54a3f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/sipify.pl
Expand Up @@ -579,6 +579,10 @@ sub remove_constructor_or_body {
$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

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson May 4, 2017

Author Collaborator

@3nids the line above only works for annotations at the end of a definition - it wasn't working for me for multiple annotations for a single argument

This comment has been minimized.

Copy link
@3nids

3nids May 4, 2017

Member

yep, sorry, realized that afterwards. I simplified a bit the code to do a single replace.

do {no warnings 'uninitialized';
$line =~ s/\/(\w+(=\w+)?)\/\s*\/(\w+(=\w+)?)\//\/$1,$3\//;
};

# unprinted annotations
$line =~ s/(\w+)(\<(?>[^<>]|(?2))*\>)?\s+SIP_PYTYPE\(\s*\'?([^()']+)(\(\s*(?:[^()]++|(?2))*\s*\))?\'?\s*\)/$3/g;
Expand Down
2 changes: 2 additions & 0 deletions tests/scripts/sipifyheader.expected.sip
Expand Up @@ -208,6 +208,8 @@ 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
2 changes: 2 additions & 0 deletions tests/scripts/sipifyheader.h
Expand Up @@ -240,6 +240,8 @@ 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

0 comments on commit ac54a3f

Please sign in to comment.