Skip to content

Commit

Permalink
[sipify] do not comment global operators
Browse files Browse the repository at this point in the history
fix class/struct level detection
sipify qgsmargins.qgs
  • Loading branch information
3nids authored and m-kuhn committed May 15, 2017
1 parent 3f85b05 commit e455b15
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 13 deletions.
1 change: 0 additions & 1 deletion python/auto_sip.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ core/qgsexception.sip
core/qgis.sip
core/qgsexpressioncontext.sip
core/qgsfeaturerequest.sip
core/qgsmargins.sip
core/qgsoptionalexpression.sip
core/qgspaintenginehack.sip
core/qgspainting.sip
Expand Down
38 changes: 38 additions & 0 deletions python/core/qgsmargins.sip
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsmargins.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsMargins
{

Expand Down Expand Up @@ -138,14 +150,40 @@ class QgsMargins


bool operator==( const QgsMargins &lhs, const QgsMargins &rhs );

bool operator!=( const QgsMargins &lhs, const QgsMargins &rhs );

QgsMargins operator+( const QgsMargins &m1, const QgsMargins &m2 );

QgsMargins operator-( const QgsMargins &m1, const QgsMargins &m2 );

QgsMargins operator+( const QgsMargins &lhs, double rhs );

QgsMargins operator+( double lhs, const QgsMargins &rhs );

QgsMargins operator-( const QgsMargins &lhs, double rhs );

QgsMargins operator*( const QgsMargins &margins, double factor );

QgsMargins operator*( double factor, const QgsMargins &margins );

QgsMargins operator/( const QgsMargins &margins, double divisor );







QgsMargins operator+( const QgsMargins &margins );

QgsMargins operator-( const QgsMargins &margins );


/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsmargins.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
13 changes: 7 additions & 6 deletions scripts/sipify.pl
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ sub dbg_info
}

sub remove_constructor_or_body {
# https://regex101.com/r/ZaP3tC/3
# https://regex101.com/r/ZaP3tC/4
do {no warnings 'uninitialized';
if ( $line =~ m/^(\s*)?(explicit )?(virtual )?(static |const )*(([\w:]+(<.*?>)?\s+(\*|&)?)?(~?\w+|operator.{1,2})\(([\w=()\/ ,&*<>."-]|::)*\)( (?:const|SIP_[A-Z_]*?))*)\s*((\s*[:,]\s+\w+\(.*\))*\s*\{.*\};?|(?!;))(\s*\/\/.*)?$/
if ( $line =~ m/^(\s*)?(explicit )?(virtual )?(static |const )*(([\w:]+(<.*?>)?\s+[*&]?)?(~?\w+|(\w+::)?operator.{1,2})\(([\w=()\/ ,&*<>."-]|::)*\)( (?:const|SIP_[A-Z_]*?))*)\s*((\s*[:,]\s+\w+\(.*\))*\s*\{.*\};?|(?!;))(\s*\/\/.*)?$/
|| $line =~ m/SIP_SKIP\s*(?!;)\s*(\/\/.*)?$/
|| $line =~ m/^\s*class.*SIP_SKIP/ ){
dbg_info("remove constructor definition, function bodies, member initializing list");
Expand Down Expand Up @@ -336,7 +336,7 @@ ()
next;
}
# Skip Q_OBJECT, Q_PROPERTY, Q_ENUM, Q_GADGET
if ($line =~ m/^\s*Q_(OBJECT|ENUMS|PROPERTY|GADGET|DECLARE_METATYPE).*?$/){
if ($line =~ m/^\s*Q_(OBJECT|ENUMS|PROPERTY|GADGET|DECLARE_METATYPE|DECLARE_TYPEINFO).*?$/){
next;
}

Expand Down Expand Up @@ -375,11 +375,11 @@ ()
$global_bracket_nesting_index[$#global_bracket_nesting_index] += $bracket_balance;
if ($global_bracket_nesting_index[$#global_bracket_nesting_index] == 0){
dbg_info(" going up in class/struct tree");
if ($#ACCESS > 1){
if ($#ACCESS > 0){
pop(@global_bracket_nesting_index);
pop(@ACCESS);
}
if ($#ACCESS == 1){
if ($#ACCESS == 0){
dbg_info("reached top level");
# top level should stasy public
dbg_info
Expand Down Expand Up @@ -439,7 +439,7 @@ ()
}
}

if ( $line =~ m/^(\s*struct)\s+(\w+)$/ ) {
if ( $line =~ m/^\s*struct(\s+\w+_EXPORT)?\s+\w+$/ ) {
dbg_info(" going to struct => public");
push @ACCESS, PUBLIC;
push @global_bracket_nesting_index, 0;
Expand Down Expand Up @@ -689,6 +689,7 @@ ()
$line =~ m/\s*typedef / ||
$line =~ m/\s*struct / ||
$line =~ m/operator\[\]\(/ ||
($line =~ m/operator[!+-=*\/\[\]]{1,2}/ && $#ACCESS == 0) || # apparently global operators cannot be documented
$line =~ m/^\s*%\w+(.*)?$/ ){
dbg_info('skipping comment');
$comment = '';
Expand Down
12 changes: 6 additions & 6 deletions src/core/qgsmargins.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,17 @@ inline QgsMargins operator/( const QgsMargins &margins, double divisor )
margins.right() / divisor, margins.bottom() / divisor );
}

inline QgsMargins &QgsMargins::operator+=( const QgsMargins &margins )
inline QgsMargins &QgsMargins::operator+=( const QgsMargins &margins ) SIP_SKIP
{
return *this = *this + margins;
}

inline QgsMargins &QgsMargins::operator-=( const QgsMargins &margins )
inline QgsMargins &QgsMargins::operator-=( const QgsMargins &margins ) SIP_SKIP
{
return *this = *this - margins;
}

inline QgsMargins &QgsMargins::operator+=( double addend )
inline QgsMargins &QgsMargins::operator+=( double addend ) SIP_SKIP
{
mLeft += addend;
mTop += addend;
Expand All @@ -284,7 +284,7 @@ inline QgsMargins &QgsMargins::operator+=( double addend )
return *this;
}

inline QgsMargins &QgsMargins::operator-=( double subtrahend )
inline QgsMargins &QgsMargins::operator-=( double subtrahend ) SIP_SKIP
{
mLeft -= subtrahend;
mTop -= subtrahend;
Expand All @@ -293,12 +293,12 @@ inline QgsMargins &QgsMargins::operator-=( double subtrahend )
return *this;
}

inline QgsMargins &QgsMargins::operator*=( double factor )
inline QgsMargins &QgsMargins::operator*=( double factor ) SIP_SKIP
{
return *this = *this * factor;
}

inline QgsMargins &QgsMargins::operator/=( double divisor )
inline QgsMargins &QgsMargins::operator/=( double divisor ) SIP_SKIP
{
return *this = *this / divisor;
}
Expand Down

0 comments on commit e455b15

Please sign in to comment.