mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
[sipify] better remove body, remove duplicate code
This commit is contained in:
parent
c2b1272246
commit
f20b9b96e7
@ -904,11 +904,10 @@ Returns an extruded version of this geometry.
|
|||||||
:rtype: QgsGeometry
|
:rtype: QgsGeometry
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
|
||||||
QgsPoint asPoint() const;
|
QgsPoint asPoint() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
Accessor functions for getting geometry data */
|
Return contents of the geometry as a point
|
||||||
|
|
||||||
/** Return contents of the geometry as a point
|
|
||||||
if wkbType is WKBPoint, otherwise returns [0,0]
|
if wkbType is WKBPoint, otherwise returns [0,0]
|
||||||
:rtype: QgsPoint
|
:rtype: QgsPoint
|
||||||
%End
|
%End
|
||||||
|
@ -45,7 +45,6 @@ class QgsConstWkbPtr
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class QgsDataProvider : QObject
|
class QgsDataProvider : QObject
|
||||||
{
|
{
|
||||||
%Docstring
|
%Docstring
|
||||||
@ -354,7 +353,6 @@ Current time stamp of data source
|
|||||||
.. versionadded:: 2.16
|
.. versionadded:: 2.16
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
|
||||||
QVariant providerProperty( ProviderProperty property, const QVariant &defaultValue = QVariant() ) const;
|
QVariant providerProperty( ProviderProperty property, const QVariant &defaultValue = QVariant() ) const;
|
||||||
%Docstring
|
%Docstring
|
||||||
Get the current value of a certain provider property.
|
Get the current value of a certain provider property.
|
||||||
@ -364,7 +362,6 @@ Current time stamp of data source
|
|||||||
:rtype: QVariant
|
:rtype: QVariant
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void fullExtentCalculated();
|
void fullExtentCalculated();
|
||||||
|
@ -149,7 +149,7 @@ class QgsPropertyTransformer
|
|||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
#include "qgspropertytransformer.h"
|
#include "qgspropertytransformer.h"
|
||||||
%End
|
%End
|
||||||
private:
|
|
||||||
%ConvertToSubClassCode
|
%ConvertToSubClassCode
|
||||||
if ( sipCpp->transformerType() == QgsPropertyTransformer::GenericNumericTransformer )
|
if ( sipCpp->transformerType() == QgsPropertyTransformer::GenericNumericTransformer )
|
||||||
sipType = sipType_QgsGenericNumericTransformer;
|
sipType = sipType_QgsGenericNumericTransformer;
|
||||||
|
@ -78,7 +78,7 @@ $debug == 0 or push @output, "CODE SIP_RUN MultiLine\n";
|
|||||||
sub dbg
|
sub dbg
|
||||||
{
|
{
|
||||||
my $msg = '';
|
my $msg = '';
|
||||||
$debug == 0 or $msg = sprintf("%-4s %-1d %-1d ", $_[0], $SIP_RUN, $MULTILINE_DEFINITION);
|
$debug == 0 or $msg = sprintf("%d %-4s %-1d %-1d ", $line_idx, $_[0], $SIP_RUN, $MULTILINE_DEFINITION);
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
sub dbg_info
|
sub dbg_info
|
||||||
@ -89,6 +89,42 @@ sub dbg_info
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub remove_constructor_or_body {
|
||||||
|
# https://regex101.com/r/ZaP3tC/1
|
||||||
|
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*\/\/.*)?$/
|
||||||
|
|| $line =~ m/SIP_SKIP\s*(?!;)\s*(\/\/.*)?$/ ){
|
||||||
|
dbg_info("remove constructor definition, function bodies, member initializing list");
|
||||||
|
my $newline = "$1$2$3$4$5;";
|
||||||
|
if ($line !~ m/{.*}(\s*SIP_\w+)?\s*(\/\/.*)?$/){
|
||||||
|
dbg_info(" go for multiline");
|
||||||
|
$line = $lines[$line_idx];
|
||||||
|
$line_idx++;
|
||||||
|
while ( $line =~ m/^\s*[:,]\s+[\w<>]+\(.*?\)/){
|
||||||
|
dbg_info(" member initializing list");
|
||||||
|
$line = $lines[$line_idx];
|
||||||
|
$line_idx++;
|
||||||
|
}
|
||||||
|
if ( $line =~ m/^\s*\{/ ){
|
||||||
|
my $nesting_index = 0;
|
||||||
|
while ($line_idx < $line_count){
|
||||||
|
dbg_info(" remove body");
|
||||||
|
$nesting_index += $line =~ tr/\{//;
|
||||||
|
$nesting_index -= $line =~ tr/\}//;
|
||||||
|
if ($nesting_index == 0){
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
$line = $lines[$line_idx];
|
||||||
|
$line_idx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$line = $newline;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# main loop
|
# main loop
|
||||||
while ($line_idx < $line_count){
|
while ($line_idx < $line_count){
|
||||||
$line = $lines[$line_idx];
|
$line = $lines[$line_idx];
|
||||||
@ -233,9 +269,11 @@ while ($line_idx < $line_count){
|
|||||||
|
|
||||||
# SIP_SKIP
|
# SIP_SKIP
|
||||||
if ( $line =~ m/SIP_SKIP/ ){
|
if ( $line =~ m/SIP_SKIP/ ){
|
||||||
|
dbg_info('SIP SKIP!');
|
||||||
$comment = '';
|
$comment = '';
|
||||||
# if multiline definition, remove previous lines
|
# if multiline definition, remove previous lines
|
||||||
if ( $MULTILINE_DEFINITION == 1){
|
if ( $MULTILINE_DEFINITION == 1){
|
||||||
|
dbg_info('SIP_SKIP with MultiLine');
|
||||||
my $opening_line = '';
|
my $opening_line = '';
|
||||||
while ( $opening_line !~ m/^[^()]*\(([^()]*\([^()]*\)[^()]*)*[^()]*$/){
|
while ( $opening_line !~ m/^[^()]*\(([^()]*\([^()]*\)[^()]*)*[^()]*$/){
|
||||||
$opening_line = pop(@output);
|
$opening_line = pop(@output);
|
||||||
@ -245,32 +283,7 @@ while ($line_idx < $line_count){
|
|||||||
$MULTILINE_DEFINITION = 0;
|
$MULTILINE_DEFINITION = 0;
|
||||||
}
|
}
|
||||||
# also skip method body if there is one
|
# also skip method body if there is one
|
||||||
if ($lines[$line_idx] =~ m/^\s*\{/){
|
remove_constructor_or_body();
|
||||||
my $nesting_index = 0;
|
|
||||||
dbg_info("skipping method body of SIP_SKIP method");
|
|
||||||
while ($line_idx < $line_count){
|
|
||||||
$line = $lines[$line_idx];
|
|
||||||
$line_idx++;
|
|
||||||
if ( $nesting_index == 0 ){
|
|
||||||
if ( $line =~ m/^\s*(:|,)/ ){
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
$line =~ m/^\s*\{/ or die 'Constructor definition misses {';
|
|
||||||
if ( $line =~ m/^\s*\{.*?\}/ ){
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
$nesting_index = 1;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$nesting_index += $line =~ tr/\{//;
|
|
||||||
$nesting_index -= $line =~ tr/\}//;
|
|
||||||
if ($nesting_index eq 0){
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# line skipped, go to next iteration
|
# line skipped, go to next iteration
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
@ -305,12 +318,14 @@ while ($line_idx < $line_count){
|
|||||||
pop(@global_bracket_nesting_index);
|
pop(@global_bracket_nesting_index);
|
||||||
pop(@ACCESS);
|
pop(@ACCESS);
|
||||||
}
|
}
|
||||||
else{
|
if ($#ACCESS == 1){
|
||||||
|
dbg_info("reached top level");
|
||||||
# top level should stasy public
|
# top level should stasy public
|
||||||
dbg_info
|
dbg_info
|
||||||
$ACCESS[$#ACCESS] = PUBLIC;
|
$ACCESS[$#ACCESS] = PUBLIC;
|
||||||
$comment = '';
|
$comment = '';
|
||||||
}
|
}
|
||||||
|
$private_section_line = '';
|
||||||
}
|
}
|
||||||
dbg_info("new bracket balance: @global_bracket_nesting_index");
|
dbg_info("new bracket balance: @global_bracket_nesting_index");
|
||||||
}
|
}
|
||||||
@ -495,35 +510,7 @@ while ($line_idx < $line_count){
|
|||||||
$line =~ s/\s*=\s*default\b//g;
|
$line =~ s/\s*=\s*default\b//g;
|
||||||
|
|
||||||
# remove constructor definition, function bodies, member initializing list
|
# remove constructor definition, function bodies, member initializing list
|
||||||
# https://regex101.com/r/ZaP3tC/1
|
$SIP_RUN == 1 or remove_constructor_or_body();
|
||||||
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*(\/\/.*)?$/){
|
|
||||||
dbg_info(" go for multiline");
|
|
||||||
$line = $lines[$line_idx];
|
|
||||||
$line_idx++;
|
|
||||||
while ( $line =~ m/^\s*[:,]\s+[\w<>]+\(.*?\)/){
|
|
||||||
dbg_info(" member initializing list");
|
|
||||||
$line = $lines[$line_idx];
|
|
||||||
$line_idx++;
|
|
||||||
}
|
|
||||||
my $nesting_index = 1;
|
|
||||||
if ( $line =~ m/^\s*\{$/ ){
|
|
||||||
while ($line_idx < $line_count){
|
|
||||||
dbg_info(" remove body");
|
|
||||||
$line = $lines[$line_idx];
|
|
||||||
$line_idx++;
|
|
||||||
$nesting_index += $line =~ tr/\{//;
|
|
||||||
$nesting_index -= $line =~ tr/\}//;
|
|
||||||
if ($nesting_index == 0){
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$line = $newline;
|
|
||||||
}
|
|
||||||
|
|
||||||
# remove inline declarations
|
# remove inline declarations
|
||||||
if ( $line =~ m/^(\s*)?(static |const )*(([\w:]+(<.*?>)?\s+(\*|&)?)?(\w+)( (?:const*?))*)\s*(\{.*\});(\s*\/\/.*)?$/ ){
|
if ( $line =~ m/^(\s*)?(static |const )*(([\w:]+(<.*?>)?\s+(\*|&)?)?(\w+)( (?:const*?))*)\s*(\{.*\});(\s*\/\/.*)?$/ ){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user