Skip to content

Commit

Permalink
followup 45266cd
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Apr 26, 2017
1 parent 45266cd commit 9688b81
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
35 changes: 25 additions & 10 deletions scripts/sipify.pl
Expand Up @@ -441,12 +441,12 @@ sub processDoxygenLine
$line =~ s/\s*=\s*default\b//g;

# remove constructor definition, function bodies, member initializing list
if ( $SIP_RUN != 1 && $line =~ m/^(\s*)?(explicit )?(virtual )?(static |const )*(([\w:]+(<.*?>)?\s+(\*|&)?)?(\w+|operator.{1,2})\([\w=()\/ ,&*<>:]*\)( (?:const|SIP_[A-Z_]*?))*)\s*(\{.*\})?(?!;)(\s*\/\/.*)?$/ ){
if ( $SIP_RUN != 1 && $line =~ m/^(\s*)?(explicit )?(virtual )?(static |const )*(([\w:]+(<.*?>)?\s+(\*|&)?)?(\w+|operator.{1,2})\([\w=()\/ ,&*<>:-]*\)( (?:const|SIP_[A-Z_]*?))*)\s*(\{.*\})?(?!;)(\s*\/\/.*)?$/ ){
my $newline = "$1$2$3$4$5;";
if ($line !~ m/\{.*?\}$/){
$line = $lines[$line_idx];
$line_idx++;
while ( $line =~ m/^\s*[:,] \w+\(.*?\)/){
while ( $line =~ m/^\s*[:,] [\w<>]+\(.*?\)/){
$line = $lines[$line_idx];
$line_idx++;
}
Expand All @@ -455,14 +455,11 @@ sub processDoxygenLine
while ($line_idx < $line_count){
$line = $lines[$line_idx];
$line_idx++;
if ( $line =~ m/^\s*{/ ){
$nesting_index++;
}
elsif ( $line =~ m/\}\s*$/ ){
$nesting_index--;
if ($nesting_index == 0){
last;
}

$nesting_index += $line =~ tr/\{//;
$nesting_index -= $line =~ tr/\}//;
if ($nesting_index == 0){
last;
}
}
}
Expand Down Expand Up @@ -533,6 +530,24 @@ sub processDoxygenLine
if ( $MULTILINE_DEFINITION == 1 ){
if ( $line =~ m/^[^()]*([^()]*\([^()]*\)[^()]*)*\)[^()]*$/){
$MULTILINE_DEFINITION = 0;
# remove potential following body
if ( $lines[$line_idx] =~ m/^\s*\{$/ ){
my $last_line = $line;
my $nesting_index = 0;
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
pop(@output);
push @output, "$last_line;\n";
}
}
else
{
Expand Down
12 changes: 11 additions & 1 deletion tests/scripts/sipifyheader.expected.sip
Expand Up @@ -75,6 +75,7 @@ class QgsSipifyHeader : QtClass<QVariant>
struct Data
{
Data( QgsMapLayer *layer, Qstring name );

QString mName;
int mCount;
QgsMapLayer *mLayer;
Expand All @@ -84,6 +85,7 @@ class QgsSipifyHeader : QtClass<QVariant>
%Docstring
A constructor with definition in header
%End

QgsSipifyHeader( QWidget *parent /TransferThis/ = 0 );
%Docstring
A classic constructor with arguments
Expand All @@ -93,6 +95,7 @@ A constructor with definition in header
%Docstring
A constructor with no empty `()`
%End

QgsSipifyHeader( QList<Point> a, const Issues &b = Issues::weDontHaveIssues(), QgsClass *b = 0 );
%Docstring
A constructor with some special character types
Expand Down Expand Up @@ -188,11 +191,16 @@ complex default value and type (i.e. containing commas) should be given as a str

void removeProxyFactory( QNetworkProxyFactory *factory /TransferBack/ );

bool removeFunctionBody( const QList<int, QString> &list, QgsVectorLayer *vl );
bool removeFunctionBody( const QList<int, QString> &list, QgsVectorLayer *vl, Some::Thing _part = -1 /*default =-1*/ );
%Docstring
:rtype: bool
%End

void multilineBodyAndDefinition( const QList<int,
QString> &list,
QgsVectorLayer *vl,
Some::Thing _part = -1 /*default =-1*/ );

QgsRaster::RasterBuildPyramids buildPyramidsFlag() const;
%Docstring
Removing function body with namespaced return value
Expand Down Expand Up @@ -306,6 +314,7 @@ class ClassWithPrivateInheritanceOnly
%Docstring
A constructor with definition in header on several lines
%End

};


Expand All @@ -323,6 +332,7 @@ class AbstractClass /Abstract/
%Docstring
A constructor
%End

};

QFlags<QgsSipifyHeader::MyEnum> operator|(QgsSipifyHeader::MyEnum f1, QFlags<QgsSipifyHeader::MyEnum> f2);
Expand Down
11 changes: 10 additions & 1 deletion tests/scripts/sipifyheader.h
Expand Up @@ -217,7 +217,7 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas

void removeProxyFactory( QNetworkProxyFactory *factory SIP_TRANSFERBACK );

bool removeFunctionBody( const QList<int, QString> &list, QgsVectorLayer *vl ) { doSomething; return true; } // some comments
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 All @@ -228,6 +228,15 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas
}
}

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

//! Removing function body with namespaced return value
QgsRaster::RasterBuildPyramids buildPyramidsFlag() const { return mBuildPyramidsFlag; }

Expand Down

0 comments on commit 9688b81

Please sign in to comment.