Skip to content
Permalink
Browse files
[sipify] operators, remove argument
 * skip some operators
 * allow to remove an argument with SIP_PYARGREMOVE
  • Loading branch information
3nids committed Apr 26, 2017
1 parent 0f9ddc2 commit 4cc4a27068162452543b34142c7065be17b956e3
@@ -1358,8 +1358,8 @@ EXPAND_AS_DEFINED = "SIP_TRANSFER" \
"SIP_KEEPREFERENCE" \
"SIP_PYNAME" \
"SIP_SKIP" \
"SIP_PYDEFAULTVALUE" \
"SIP_PYTYPE" \
"SIP_PYARGDEFAULT" \
"SIP_PYARGTYPE" \
"SIP_CONVERT_TO_SUBCLASS_CODE" \
"SIP_FEATURE" \
"SIP_IF_FEATURE" \
@@ -271,7 +271,7 @@ Copy constructor
:rtype: bool
%End

// QgsRectangle &operator=( const QgsRectangle &r1 );

void unionRect( const QgsRectangle &rect );
%Docstring
Updates the rectangle to include another rectangle.
@@ -39,7 +39,7 @@ class QgsProcessingAlgorithm

virtual ~QgsProcessingAlgorithm();

// QgsProcessingAlgorithm &operator=( const QgsProcessingAlgorithm &other ) = delete;

virtual QString name() const = 0;
%Docstring
Returns the algorithm name, used for identifying the algorithm. This string
@@ -37,7 +37,7 @@ class QgsProcessingContext
Constructor for QgsProcessingContext.
%End

// QgsProcessingContext &operator=( const QgsProcessingContext &other ) = delete;

QgsProcessingContext::Flags flags() const;
%Docstring
Returns any flags set in the context.
@@ -30,7 +30,7 @@ class QgsProcessingProvider : QObject

virtual ~QgsProcessingProvider();

// QgsProcessingProvider &operator=( const QgsProcessingProvider &other ) = delete;

virtual QIcon icon() const;
%Docstring
Returns an icon for the provider.
@@ -32,7 +32,7 @@ class QgsProcessingRegistry : QObject

~QgsProcessingRegistry();

// QgsProcessingRegistry &operator=( const QgsProcessingRegistry &other ) = delete;

QList<QgsProcessingProvider *> providers() const;
%Docstring
Get list of available providers.
@@ -80,7 +80,7 @@ class QgsConditionalStyle
QgsConditionalStyle( const QgsConditionalStyle &other );
QgsConditionalStyle( const QString &rule );

// QgsConditionalStyle &operator=( const QgsConditionalStyle &other );

bool matches( const QVariant &value, QgsExpressionContext &context ) const;
%Docstring
Check if the rule matches using the given value and feature
@@ -205,7 +205,7 @@ Constructs an invalid CRS object
Copy constructor
%End

// QgsCoordinateReferenceSystem &operator=( const QgsCoordinateReferenceSystem &srs );

operator QVariant() const;
%Docstring
Allows direct construction of QVariants from QgsCoordinateReferenceSystem.
@@ -57,7 +57,7 @@ Default constructor, creates an invalid QgsCoordinateTransform.
Copy constructor
%End

// QgsCoordinateTransform &operator=( const QgsCoordinateTransform &o );

~QgsCoordinateTransform();
%Docstring
Assignment operator
@@ -26,7 +26,7 @@ overhead of initialization for each redraw*
:rtype: QgsCoordinateTransformCache
%End

// QgsCoordinateTransformCache &operator=( const QgsCoordinateTransformCache &rh ) = delete;

QgsCoordinateTransform transform( const QString &srcAuthId, const QString &destAuthId, int srcDatumTransform = -1, int destDatumTransform = -1 );
%Docstring
Returns coordinate transformation. Cache keeps ownership
@@ -66,7 +66,7 @@ class QgsMapLayer : QObject

virtual ~QgsMapLayer();

// QgsMapLayer &operator=( QgsMapLayer const & ) = delete;

QgsMapLayer::LayerType type() const;
%Docstring
Returns the type of the layer.
@@ -56,7 +56,7 @@ class QgsCurveTransform
Copy constructor
%End

// QgsCurveTransform &operator=( const QgsCurveTransform &other );

QList< QgsPoint > controlPoints() const;
%Docstring
Returns a list of the control points for the transform.
@@ -187,7 +187,7 @@ class QgsPropertyTransformer
%Docstring
Copy constructor.
%End
// QgsPropertyTransformer &operator=( const QgsPropertyTransformer &other );

virtual ~QgsPropertyTransformer();

virtual Type transformerType() const = 0;
@@ -343,7 +343,7 @@ class QgsGenericNumericTransformer : QgsPropertyTransformer
%Docstring
Copy constructor.
%End
// QgsGenericNumericTransformer &operator=( const QgsGenericNumericTransformer &other );

virtual Type transformerType() const;
virtual QgsGenericNumericTransformer *clone();
virtual QVariant toVariant() const;
@@ -479,7 +479,7 @@ class QgsSizeScaleTransformer : QgsPropertyTransformer
%Docstring
Copy constructor.
%End
// QgsSizeScaleTransformer &operator=( const QgsSizeScaleTransformer &other );

virtual Type transformerType() const;
virtual QgsSizeScaleTransformer *clone() /Factory/;
virtual QVariant toVariant() const;
@@ -619,7 +619,7 @@ class QgsColorRampTransformer : QgsPropertyTransformer
Copy constructor
%End

// QgsColorRampTransformer &operator=( const QgsColorRampTransformer &other );

virtual Type transformerType() const;
virtual QgsColorRampTransformer *clone() /Factory/;
virtual QVariant toVariant() const;
@@ -335,7 +335,7 @@ class QgsVectorLayer : QgsMapLayer, QgsExpressionContextGenerator, QgsFeatureSin

virtual ~QgsVectorLayer();

// QgsVectorLayer &operator=( QgsVectorLayer const &rhs ) = delete;

QString storageType() const;
%Docstring
Returns the permanent storage type for this layer as a friendly name.
@@ -277,9 +277,8 @@ sub processDoxygenLine
$comment = '';
next;
}
# Skip assignment operator
if ( $line =~ m/operator=\s*\(/ ){
push @output, "// $line";
# Skip operators
if ( $line =~ m/operator(=|<<|>>)\s*\(/ ){
next;
}

@@ -515,8 +514,27 @@ sub processDoxygenLine
$line =~ s/\bSIP_ARRAYSIZE\b/\/ArraySize\//;

$line =~ s/SIP_PYNAME\(\s*(\w+)\s*\)/\/PyName=$1\//;
$line =~ s/(\w+)(\<(?>[^<>]|(?2))*\>)?\s+SIP_PYTYPE\(\s*\'?([^()']+)(\(\s*(?:[^()]++|(?2))*\s*\))?\'?\s*\)/$3/g;
$line =~ s/=\s+[^=]*?\s+SIP_PYDEFAULTVALUE\(\s*\'?([^()']+)(\(\s*(?:[^()]++|(?2))*\s*\))?\'?\s*\)/= $1/g;
$line =~ s/(\w+)(\<(?>[^<>]|(?2))*\>)?\s+SIP_PYARGTYPE\(\s*\'?([^()']+)(\(\s*(?:[^()]++|(?2))*\s*\))?\'?\s*\)/$3/g;
$line =~ s/=\s+[^=]*?\s+SIP_PYARGDEFAULT\(\s*\'?([^()']+)(\(\s*(?:[^()]++|(?2))*\s*\))?\'?\s*\)/= $1/g;

# remove argument
if ($line =~ m/SIP_PYARGREMOVE/){
if ( $MULTILINE_DEFINITION == 1 ){
my $prev_line = pop(@output) =~ s/\n$//r;
# update multi line status
my $parenthesis_balance = 0;
$parenthesis_balance += $prev_line =~ tr/\(//;
$parenthesis_balance -= $prev_line =~ tr/\)//;
if ($parenthesis_balance == 1){
$MULTILINE_DEFINITION = 0;
}
# concat with above line to bring previous commas
$line =~ s/^\s+//;
$line = "$prev_line $line\n";
}
# see https://regex101.com/r/5iNptO/4
$line =~ s/(?<coma>, +)?(const )?(\w+)(\<(?>[^<>]|(?4))*\>)? [\w&*]+ SIP_PYARGREMOVE( = [^()]*(\(\s*(?:[^()]++|(?6))*\s*\))?)?(?(<coma>)|,?)//g;
}

$line =~ s/SIP_FORCE//;

@@ -462,14 +462,20 @@ typedef unsigned long long qgssize;
#define SIP_FORCE

/*
* specify an alternative type for SIP methods
* specify an alternative type for SIP argument
*/
#define SIP_PYTYPE(type)
#define SIP_PYARGTYPE(type)

/*
* specify an alternative default value for SIP methods
* specify an alternative default value for SIP argument
*/
#define SIP_PYDEFAULTVALUE(value)
#define SIP_PYARGDEFAULT(value)

/*
* remove argument in SIP method
*/
#define SIP_PYARGREMOVE


/*
* http://pyqt.sourceforge.net/Docs/sip4/annotations.html?highlight=keepreference#function-annotation-ReleaseGIL
@@ -350,7 +350,7 @@ class CORE_EXPORT QgsFeature
* \since QGIS 2.9
* \see fields
*/
void setFields( const QgsFields &fields, bool initAttributes = false SIP_PYDEFAULTVALUE( true ) );
void setFields( const QgsFields &fields, bool initAttributes = false SIP_PYARGDEFAULT( true ) );

/** Returns the field map associated with the feature.
* \see setFields
@@ -106,7 +106,7 @@ A constructor with some special character types
Default constructor
%End

// QgsSipifyHeader &operator=( const QgsSipifyHeader other );

bool operator==( const QgsSipifyHeader other );
%Docstring
Comparison operator should be kept
@@ -281,6 +281,19 @@ Mulitline body
VertexType type;
}

void simple( );
%Docstring
remove argument
%End
void method( );
void test( );
void avoidIntersections( const QList<QgsVectorLayer *> &avoidIntersectionsLayers );

void position( );
void position( bool keep );
void position( bool keep, bool keep );
void position( bool keep );

void ZshouldBeShown();


@@ -40,10 +40,10 @@ typedef qint64 QgsFeatureId;
typedef WhatEver ShouldNotBeDisplayed;
#endif

typedef QSet<QgsFeatureId SIP_PYTYPE( qint64 )> QgsFeatureIds;
typedef QMap<QgsFeatureId SIP_PYTYPE( qint64 ), QgsAttributeMap SIP_PYTYPE( 'QMap<int, QVariant>' )> QgsChangedAttributesMap;
typedef QMap<QgsFeatureId, QgsAttributeMap> SIP_PYTYPE( 'QMap<qint64, QMap<int, QVariant> >' ) QgsChangedAttributesMap;
typedef QMap<QgsFeatureId, QPair<QMap<Something, Complex> >> SIP_PYTYPE( 'QMap<qint64, QMap<int, QVariant>>' ) QgsChangedAttributesMap;
typedef QSet<QgsFeatureId SIP_PYARGTYPE( qint64 )> QgsFeatureIds;
typedef QMap<QgsFeatureId SIP_PYARGTYPE( qint64 ), QgsAttributeMap SIP_PYARGTYPE( 'QMap<int, QVariant>' )> QgsChangedAttributesMap;
typedef QMap<QgsFeatureId, QgsAttributeMap> SIP_PYARGTYPE( 'QMap<qint64, QMap<int, QVariant> >' ) QgsChangedAttributesMap;
typedef QMap<QgsFeatureId, QPair<QMap<Something, Complex> >> SIP_PYARGTYPE( 'QMap<qint64, QMap<int, QVariant>>' ) QgsChangedAttributesMap;

/** \ingroup core
* A super QGIS class
@@ -202,12 +202,12 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas

void setDiagramRenderer( QgsDiagramRenderer *r SIP_TRANSFER );

void differentDefaultValue( bool defaultValue = true SIP_PYDEFAULTVALUE( false ), QWidget *parent = nullptr, QString msg = QString() SIP_PYDEFAULTVALUE( "hello" ) );
void differentDefaultValue( bool defaultValue = true SIP_PYARGDEFAULT( false ), QWidget *parent = nullptr, QString msg = QString() SIP_PYARGDEFAULT( "hello" ) );

void differentType( QList<QgsFeatureId> SIP_PYTYPE( QList<qint64> ) & list );
void differentType( QList<QgsFeatureId> SIP_PYARGTYPE( QList<qint64> ) & list );

//! complex default value and type (i.e. containing commas) should be given as a string with single quotes
void complexDefaultValueAndType( QList<QPair<QgsFeatureId SIP_PYTYPE( qint64 ), QMap<int, QString>>> list = QList<QPair<QgsFeatureId, QMap<int, QString>>>() SIP_PYDEFAULTVALUE( 'QList<QPair<qint64, QMap<int, QString>>>()' ) );
void complexDefaultValueAndType( QList<QPair<QgsFeatureId SIP_PYARGTYPE( qint64 ), QMap<int, QString>>> list = QList<QPair<QgsFeatureId, QMap<int, QString>>>() SIP_PYARGDEFAULT( 'QList<QPair<qint64, QMap<int, QString>>>()' ) );

inline int inlineKeyWordShouldNotAppear();

@@ -305,6 +305,17 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas
VertexType type;
}

//! remove argument
void simple( bool test SIP_PYARGREMOVE );
void method( bool myArg SIP_PYARGREMOVE = test );
void test( QgsMapLayer *vl SIP_PYARGREMOVE = nullptr );
void avoidIntersections( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
void position( bool single_remove SIP_PYARGREMOVE );
void position( bool first_remove SIP_PYARGREMOVE, bool keep );
void position( bool keep, bool middle_remove SIP_PYARGREMOVE, bool keep );
void position( bool keep, bool last_remove SIP_PYARGREMOVE );

#if 0
#if Whatever
void X();

0 comments on commit 4cc4a27

Please sign in to comment.