Skip to content

Commit

Permalink
followup b46de90
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Apr 30, 2017
1 parent 7f3941e commit 5e220e6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/sipify.pl
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,11 @@ sub remove_constructor_or_body {
$line =~ s/SIP_PYNAME\(\s*(\w+)\s*\)/\/PyName=$1\//;

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

# unprinted annotations
$line =~ s/(\w+)(\<(?>[^<>]|(?2))*\>)?\s+SIP_PYARGTYPE\(\s*\'?([^()']+)(\(\s*(?:[^()]++|(?2))*\s*\))?\'?\s*\)/$3/g;
Expand Down Expand Up @@ -657,14 +659,17 @@ sub remove_constructor_or_body {
next;
}
elsif ( $line =~ m/\/\// || $line =~ m/\s*typedef / || $line =~ m/\s*struct / || $line =~ m/operator\[\]\(/ ){
dbg_info('skipping comment');
$comment = '';
$return_type = '';
}
elsif ( $comment !~ m/^\s*$/ || $return_type ne ''){
if ( $is_override == 1 && $comment =~ m/^\s*$/ ){
# overridden method with no new docs - so don't create a Docstring and use
# parent class Docstring
}
else {
dbg_info('writing comment');
push @output, dbg("CM1")."%Docstring\n";
if ( $comment !~ m/^\s*$/ ){
push @output, dbg("CM2")."$comment\n";
Expand Down
5 changes: 5 additions & 0 deletions tests/scripts/sipifyheader.expected.sip
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ remove argument
void position( bool keep, bool keep );
void position( bool keep );

Whatever &operator[]( int i ) /Factory/;
%MethodCode
....
%End

void ZshouldBeShown();

void methodCodeWithMultiLineDef();
Expand Down
8 changes: 8 additions & 0 deletions tests/scripts/sipifyheader.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,14 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas
void position( bool keep, bool middle_remove SIP_PYARGREMOVE, bool keep );
void position( bool keep, bool last_remove SIP_PYARGREMOVE );

//! Some comment
Whatever &operator[]( int i ) SIP_FACTORY;
#ifdef SIP_RUN
%MethodCode
....
%End
#endif

#if 0
#if Whatever
void X();
Expand Down

0 comments on commit 5e220e6

Please sign in to comment.