Skip to content
Permalink
Browse files
sipify improvements
 * one liner enum (without assignements)
 * remove function bodies of skipped methods
  • Loading branch information
3nids committed Apr 24, 2017
1 parent 5a19463 commit 8f35ee464f0a32284263b684abbdf2a42c0e9131
Showing with 39 additions and 12 deletions.
  1. +27 −12 scripts/sipify.pl
  2. +5 −0 tests/scripts/sipifyheader.expected.sip
  3. +7 −0 tests/scripts/sipifyheader.h
@@ -200,6 +200,13 @@ sub processDoxygenLine
}
$MULTILINE_DEFINITION = 0;
}
# also skip method body if there is one
if ($lines[$line_idx] =~ m/^\s*\{/){
while($lines[$line_idx] !~ m/^\s*\}/){
$line_idx++;
}
$line_idx++;
}
next;
}

@@ -310,23 +317,31 @@ sub processDoxygenLine
# Enum declaration
if ( $line =~ m/^\s*enum\s+\w+.*?$/ ){
push @output, "$line\n";
$line = $lines[$line_idx];
$line_idx++;
$line =~ m/^\s*\{\s*$/ || die "Unexpected content: enum should be followed by {\nline: $line";
push @output, "$line\n";
while ($line_idx < $line_count){
if ($line =~ m/\{((\s*\w+)(\s*=\s*[\w\s\d<|]+.*?)?(,?))+\s*\}/){
# one line declaration
$line !~ m/=/ or die 'spify.pl does not handle enum one liners with value assignment. Use multiple lines instead.';
push @output, "$line\n";
}
else
{
$line = $lines[$line_idx];
$line_idx++;
if ($line =~ m/\};/){
last;
$line =~ m/^\s*\{\s*$/ || die "Unexpected content: enum should be followed by {\nline: $line";
push @output, "$line\n";
while ($line_idx < $line_count){
$line = $lines[$line_idx];
$line_idx++;
if ($line =~ m/\};/){
last;
}
$line =~ s/(\s*\w+)(\s*=\s*[\w\s\d<|]+.*?)?(,?).*$/$1$3/;
push @output, "$line\n";
}
$line =~ s/(\s*\w+)(\s*=\s*[\w\s\d<|]+.*?)?(,?).*$/$1$3/;
push @output, "$line\n";
# enums don't have Docstring apparently
$comment = '';
next;
}
push @output, "$line\n";
# enums don't have Docstring apparently
$comment = '';
next;
}

# skip non-method member declaration in non-public sections
@@ -70,6 +70,10 @@ class QgsSipifyHeader : QtClass<QVariant>
typedef QFlags<QgsSipifyHeader::MyEnum> Flags;


enum OneLiner { Success, NoSuccess };
enum OneLiner { Success, NoSuccess };
enum OneLiner;

struct Data
{
Data( QgsMapLayer *layer, Qstring name );
@@ -191,6 +195,7 @@ complex default value and type (i.e. containing commas) should be given as a str
%Docstring
:rtype: bool
%End

QgsRaster::RasterBuildPyramids buildPyramidsFlag() const;
%Docstring
Removing function body with namespaced return value
@@ -106,6 +106,8 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas
};
Q_DECLARE_FLAGS( Flags, MyEnum )

enum OneLiner { Success, NoSuccess };

/**
* Docstring headers for structs are not supported by sip (as of 4.18) and
* therefore this docstring must not to be copied to the sipfile.
@@ -217,6 +219,11 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas

bool removeFunctionBody( const QList<int, QString> &list, QgsVectorLayer *vl ) { doSomething; return true; } // some comments

static inline QgsMapLayer *skippedMethodWithBody() SIP_SKIP
{
OhNoYouShouldnotHaveReadThis();
}

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

0 comments on commit 8f35ee4

Please sign in to comment.