Skip to content

Commit

Permalink
[sipify] fix oneliner constructor and destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Apr 30, 2017
1 parent 39d8724 commit c2b1272
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion scripts/sipify.pl
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ sub dbg_info
$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*\/\/.*)?$/ ){
# https://regex101.com/r/ZaP3tC/1
if ( $SIP_RUN != 1 && $line =~ m/^(\s*)?(explicit )?(virtual )?(static |const )*(([\w:]+(<.*?>)?\s+(\*|&)?)?(~?\w+|operator.{1,2})\(([\w=()\/ ,&*<>-]|::)*\)( (?:const|SIP_[A-Z_]*?))*)\s*((\s*[:,]\s+\w+\(.*\))*\s*\{.*\};?|(?!;))(\s*\/\/.*)?$/ ){
dbg_info("remove constructor definition, function bodies, member initializing list");
my $newline = "$1$2$3$4$5;";
if ($line !~ m/\{.*?\}\s*(\/\/.*)?$/){
Expand Down
9 changes: 6 additions & 3 deletions tests/scripts/sipifyheader.expected.sip
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,12 @@ A constructor with no empty `()`
A constructor with some special character types
%End

Parameter( const QString &name,
bool optional = false,
const QVariant &defaultValue = QVariant() );
Constructor();
virtual ~Destructor();

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

QgsSipifyHeader();
%Docstring
Expand Down
9 changes: 6 additions & 3 deletions tests/scripts/sipifyheader.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,12 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas
: mMember( nullptr )
{}

Parameter( const QString &name,
bool optional = false,
const QVariant &defaultValue = QVariant() )
Constructor() : mHasNamedNodes( false ) {}
virtual ~Destructor() { qDeleteAll( mList ); }

Constructor( const QString &name,
bool optional = false,
const QVariant &defaultValue = QVariant() )
: mName( name )
, mOptional( optional )
, mDefaultValue( defaultValue )
Expand Down

0 comments on commit c2b1272

Please sign in to comment.