Skip to content

Commit e455b15

Browse files
3nidsm-kuhn
authored andcommittedMay 15, 2017
[sipify] do not comment global operators
fix class/struct level detection sipify qgsmargins.qgs
1 parent 3f85b05 commit e455b15

File tree

4 files changed

+51
-13
lines changed

4 files changed

+51
-13
lines changed
 

‎python/auto_sip.blacklist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ core/qgsexception.sip
33
core/qgis.sip
44
core/qgsexpressioncontext.sip
55
core/qgsfeaturerequest.sip
6-
core/qgsmargins.sip
76
core/qgsoptionalexpression.sip
87
core/qgspaintenginehack.sip
98
core/qgspainting.sip

‎python/core/qgsmargins.sip

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgsmargins.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
113
class QgsMargins
214
{
315

@@ -138,14 +150,40 @@ class QgsMargins
138150

139151

140152
bool operator==( const QgsMargins &lhs, const QgsMargins &rhs );
153+
141154
bool operator!=( const QgsMargins &lhs, const QgsMargins &rhs );
155+
142156
QgsMargins operator+( const QgsMargins &m1, const QgsMargins &m2 );
157+
143158
QgsMargins operator-( const QgsMargins &m1, const QgsMargins &m2 );
159+
144160
QgsMargins operator+( const QgsMargins &lhs, double rhs );
161+
145162
QgsMargins operator+( double lhs, const QgsMargins &rhs );
163+
146164
QgsMargins operator-( const QgsMargins &lhs, double rhs );
165+
147166
QgsMargins operator*( const QgsMargins &margins, double factor );
167+
148168
QgsMargins operator*( double factor, const QgsMargins &margins );
169+
149170
QgsMargins operator/( const QgsMargins &margins, double divisor );
171+
172+
173+
174+
175+
176+
177+
150178
QgsMargins operator+( const QgsMargins &margins );
179+
151180
QgsMargins operator-( const QgsMargins &margins );
181+
182+
183+
/************************************************************************
184+
* This file has been generated automatically from *
185+
* *
186+
* src/core/qgsmargins.h *
187+
* *
188+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
189+
************************************************************************/

‎scripts/sipify.pl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ sub dbg_info
9393
}
9494

9595
sub remove_constructor_or_body {
96-
# https://regex101.com/r/ZaP3tC/3
96+
# https://regex101.com/r/ZaP3tC/4
9797
do {no warnings 'uninitialized';
98-
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*\/\/.*)?$/
98+
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*\/\/.*)?$/
9999
|| $line =~ m/SIP_SKIP\s*(?!;)\s*(\/\/.*)?$/
100100
|| $line =~ m/^\s*class.*SIP_SKIP/ ){
101101
dbg_info("remove constructor definition, function bodies, member initializing list");
@@ -336,7 +336,7 @@ ()
336336
next;
337337
}
338338
# Skip Q_OBJECT, Q_PROPERTY, Q_ENUM, Q_GADGET
339-
if ($line =~ m/^\s*Q_(OBJECT|ENUMS|PROPERTY|GADGET|DECLARE_METATYPE).*?$/){
339+
if ($line =~ m/^\s*Q_(OBJECT|ENUMS|PROPERTY|GADGET|DECLARE_METATYPE|DECLARE_TYPEINFO).*?$/){
340340
next;
341341
}
342342

@@ -375,11 +375,11 @@ ()
375375
$global_bracket_nesting_index[$#global_bracket_nesting_index] += $bracket_balance;
376376
if ($global_bracket_nesting_index[$#global_bracket_nesting_index] == 0){
377377
dbg_info(" going up in class/struct tree");
378-
if ($#ACCESS > 1){
378+
if ($#ACCESS > 0){
379379
pop(@global_bracket_nesting_index);
380380
pop(@ACCESS);
381381
}
382-
if ($#ACCESS == 1){
382+
if ($#ACCESS == 0){
383383
dbg_info("reached top level");
384384
# top level should stasy public
385385
dbg_info
@@ -439,7 +439,7 @@ ()
439439
}
440440
}
441441

442-
if ( $line =~ m/^(\s*struct)\s+(\w+)$/ ) {
442+
if ( $line =~ m/^\s*struct(\s+\w+_EXPORT)?\s+\w+$/ ) {
443443
dbg_info(" going to struct => public");
444444
push @ACCESS, PUBLIC;
445445
push @global_bracket_nesting_index, 0;
@@ -689,6 +689,7 @@ ()
689689
$line =~ m/\s*typedef / ||
690690
$line =~ m/\s*struct / ||
691691
$line =~ m/operator\[\]\(/ ||
692+
($line =~ m/operator[!+-=*\/\[\]]{1,2}/ && $#ACCESS == 0) || # apparently global operators cannot be documented
692693
$line =~ m/^\s*%\w+(.*)?$/ ){
693694
dbg_info('skipping comment');
694695
$comment = '';

‎src/core/qgsmargins.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,17 +265,17 @@ inline QgsMargins operator/( const QgsMargins &margins, double divisor )
265265
margins.right() / divisor, margins.bottom() / divisor );
266266
}
267267

268-
inline QgsMargins &QgsMargins::operator+=( const QgsMargins &margins )
268+
inline QgsMargins &QgsMargins::operator+=( const QgsMargins &margins ) SIP_SKIP
269269
{
270270
return *this = *this + margins;
271271
}
272272

273-
inline QgsMargins &QgsMargins::operator-=( const QgsMargins &margins )
273+
inline QgsMargins &QgsMargins::operator-=( const QgsMargins &margins ) SIP_SKIP
274274
{
275275
return *this = *this - margins;
276276
}
277277

278-
inline QgsMargins &QgsMargins::operator+=( double addend )
278+
inline QgsMargins &QgsMargins::operator+=( double addend ) SIP_SKIP
279279
{
280280
mLeft += addend;
281281
mTop += addend;
@@ -284,7 +284,7 @@ inline QgsMargins &QgsMargins::operator+=( double addend )
284284
return *this;
285285
}
286286

287-
inline QgsMargins &QgsMargins::operator-=( double subtrahend )
287+
inline QgsMargins &QgsMargins::operator-=( double subtrahend ) SIP_SKIP
288288
{
289289
mLeft -= subtrahend;
290290
mTop -= subtrahend;
@@ -293,12 +293,12 @@ inline QgsMargins &QgsMargins::operator-=( double subtrahend )
293293
return *this;
294294
}
295295

296-
inline QgsMargins &QgsMargins::operator*=( double factor )
296+
inline QgsMargins &QgsMargins::operator*=( double factor ) SIP_SKIP
297297
{
298298
return *this = *this * factor;
299299
}
300300

301-
inline QgsMargins &QgsMargins::operator/=( double divisor )
301+
inline QgsMargins &QgsMargins::operator/=( double divisor ) SIP_SKIP
302302
{
303303
return *this = *this / divisor;
304304
}

0 commit comments

Comments
 (0)