Skip to content
Permalink
Browse files
[sipify] handle override method signature on several lines
  • Loading branch information
3nids committed Apr 20, 2017
1 parent 8f2a5c7 commit 1ab5a628dfd7dc30620aee6d0cff026b5857ebef
Showing with 25 additions and 3 deletions.
  1. +19 −3 scripts/sipify.pl
  2. +3 −0 tests/scripts/sipifyheader.expected.sip
  3. +3 −0 tests/scripts/sipifyheader.h
@@ -338,11 +338,26 @@ sub processDoxygenLine
# remove keywords
if ( $line =~ m/\boverride\b/){
$is_override = 1;
if ( $line !~ m/^(\s*)virtual\b(.*)$/ ){

# handle multiline definition to add virtual keyword on opening line
if ( $MULTILINE_DEFINITION == 1 ){
my $virtual_line = $line;
my $virtual_line_idx = $line_idx;
while ( $virtual_line !~ m/^[^()]*\(([^()]*\([^()]*\)[^()]*)*[^()]*$/){
$virtual_line_idx--;
$virtual_line = $lines[$virtual_line_idx];
$virtual_line_idx >= 0 or die 'could not reach opening definition';
}
if ( $virtual_line !~ m/^(\s*)virtual\b(.*)$/ ){
my $idx = $#output-$line_idx+$virtual_line_idx+2;
#print "len: $#output line_idx: $line_idx virt: $virtual_line_idx\n"idx: $idx\n$output[$idx]\n";
$output[$idx] = $virtual_line =~ s/^(\s*?)\b(.*)$/$1 virtual $2\n/r;
}
}
elsif ( $line !~ m/^(\s*)virtual\b(.*)$/ ){
#sip often requires the virtual keyword to be present, or it chokes on covariant return types
#in overridden methods
$line =~ m/^(\s*?)\b(.*)$/;
$line = "$1virtual $2\n";
$line =~ s/^(\s*?)\b(.*)$/$1virtual $2\n/;
}
}
$line =~ s/\s*\boverride\b//;
@@ -467,6 +482,7 @@ sub processDoxygenLine
# write comment
if ( $line =~ m/^\s*$/ )
{
$is_override = 0;
next;
}
elsif ( $line =~ m/\/\// || $line =~ m/\s*typedef / || $line =~ m/\s*struct / ){
@@ -207,6 +207,9 @@ Removing function body with virtual const reference
virtual int overrideWithoutVirtual();


virtual void overrideWithoutVirtualMultLine( const QList<int, QString> &list1,
const QList<int, QString> &list2 );

QString returnTypeString() const;
%Docstring
:rtype: str
@@ -225,6 +225,9 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas

int overrideWithoutVirtual() override;

void overrideWithoutVirtualMultLine( const QList<int, QString> &list1,
const QList<int, QString> &list2 ) override;

QString returnTypeString() const;

double returnTypeDouble() const;

0 comments on commit 1ab5a62

Please sign in to comment.