Skip to content
Permalink
Browse files
[sipify] fix multiline definition with member initiliazing list
  • Loading branch information
3nids committed Apr 30, 2017
1 parent 82418ea commit 92b5265d82f6d84bdd79b1440901c43a0d7765cc
Showing with 55 additions and 28 deletions.
  1. +43 −28 scripts/sipify.pl
  2. +4 −0 tests/scripts/sipifyheader.expected.sip
  3. +8 −0 tests/scripts/sipifyheader.h
@@ -82,7 +82,10 @@ sub dbg
}
sub dbg_info
{
$debug == 0 or push @output, $_[0]."\n";
if ($debug == 1){
push @output, $_[0]."\n";
print $_[0]."\n";
}
}

# main loop
@@ -468,7 +471,7 @@ sub dbg_info
dbg_info(" go for multiline");
$line = $lines[$line_idx];
$line_idx++;
while ( $line =~ m/^\s*[:,] [\w<>]+\(.*?\)/){
while ( $line =~ m/^\s*[:,]\s+[\w<>]+\(.*?\)/){
dbg_info(" member initializing list");
$line = $lines[$line_idx];
$line_idx++;
@@ -569,33 +572,45 @@ sub dbg_info

# multiline definition (parenthesis left open)
if ( $MULTILINE_DEFINITION == 1 ){
# see https://regex101.com/r/DN01iM/2
if ( $line =~ m/^([^()]+(\((?:[^()]++|(?1))*\)))*[^()]*\)[^()]*$/){
$MULTILINE_DEFINITION = 0;
# remove potential following body
if ( $SIP_RUN == 0 && $lines[$line_idx] =~ m/^\s*\{$/ ){
dbg_info("remove following body of multiline def");
my $last_line = $line;
my $nesting_index = 0;
while ($line_idx < $line_count){
$line = $lines[$line_idx];
$line_idx++;
dbg_info("on multiline");
# https://regex101.com/r/DN01iM/2
if ( $line =~ m/^([^()]+(\((?:[^()]++|(?1))*\)))*[^()]*\)[^()]*$/){
$MULTILINE_DEFINITION = 0;
dbg_info("ending multiline");
# remove potential following body

$nesting_index += $line =~ tr/\{//;
$nesting_index -= $line =~ tr/\}//;
if ($nesting_index == 0){
last;
}
}
# add missing semi column
my $dummy = pop(@output);
push @output, dbg("MLT")."$last_line;\n";
}
}
else
{
next;
}

if ( $SIP_RUN == 0 && $line !~ m/(\{.*\}|;)\s*(\/\/.*)?$/ ){
dbg_info("remove following body of multiline def");
my $last_line = $line;
$line = $lines[$line_idx];
$line_idx++;
while ( $line =~ m/^\s*[:,]\s+[\w<>]+\(.*?\)/){
dbg_info(" member initializing list");
$line = $lines[$line_idx];
$line_idx++;
}
my $nesting_index = 1;
if ( $line =~ m/^\s*\{$/ ){
while ($line_idx < $line_count){
$line = $lines[$line_idx];
$line_idx++;
$nesting_index += $line =~ tr/\{//;
$nesting_index -= $line =~ tr/\}//;
if ($nesting_index == 0){
last;
}
}
}
# add missing semi column
my $dummy = pop(@output);
push @output, dbg("MLT")."$last_line;\n";
}
}
else
{
next;
}
}
elsif ( $line =~ m/^[^()]+\([^()]*([^()]*\([^()]*\)[^()]*)*[^)]*$/ ){
dbg_info("Mulitline detected");
@@ -101,6 +101,10 @@ A constructor with no empty `()`
A constructor with some special character types
%End

Parameter( const QString &name,
bool optional = false,
const QVariant &defaultValue = QVariant() );

QgsSipifyHeader();
%Docstring
Default constructor
@@ -145,6 +145,14 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas
: mMember( nullptr )
{}

Parameter( const QString &name,
bool optional = false,
const QVariant &defaultValue = QVariant() )
: mName( name )
, mOptional( optional )
, mDefaultValue( defaultValue )
{}

//! Default constructor
QgsSipifyHeader() = default;

0 comments on commit 92b5265

Please sign in to comment.