Skip to content

Commit

Permalink
[sipify] rename SIP_PYARGTYPE to SIP_PYTYPE since it can be used to c…
Browse files Browse the repository at this point in the history
…hanged return types too
  • Loading branch information
3nids committed May 3, 2017
1 parent 75fa28f commit 6958db6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmake_templates/Doxyfile.in
Expand Up @@ -2062,7 +2062,7 @@ EXPAND_AS_DEFINED = "SIP_TRANSFER" \
"SIP_PYNAME" \
"SIP_SKIP" \
"SIP_PYARGDEFAULT" \
"SIP_PYARGTYPE" \
"SIP_PYTYPE" \
"SIP_PYARGREMOVE" \
"SIP_CONVERT_TO_SUBCLASS_CODE" \
"SIP_FEATURE" \
Expand Down
2 changes: 1 addition & 1 deletion scripts/sipify.pl
Expand Up @@ -581,7 +581,7 @@ sub remove_constructor_or_body {
};

# unprinted annotations
$line =~ s/(\w+)(\<(?>[^<>]|(?2))*\>)?\s+SIP_PYARGTYPE\(\s*\'?([^()']+)(\(\s*(?:[^()]++|(?2))*\s*\))?\'?\s*\)/$3/g;
$line =~ s/(\w+)(\<(?>[^<>]|(?2))*\>)?\s+SIP_PYTYPE\(\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/){
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometryutils.h
Expand Up @@ -178,7 +178,7 @@ class CORE_EXPORT QgsGeometryUtils
* @note added in 3.0
*/
static void segmentizeArc( const QgsPointV2 &p1, const QgsPointV2 &p2, const QgsPointV2 &p3,
QgsPointSequence SIP_PYARGTYPE( QList<QgsPointV2> ) &points SIP_OUT, double tolerance = M_PI_2 / 90,
QgsPointSequence SIP_PYTYPE( QList<QgsPointV2> ) &points SIP_OUT, double tolerance = M_PI_2 / 90,
QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle,
bool hasZ = false, bool hasM = false );

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgis.h
Expand Up @@ -462,9 +462,9 @@ typedef unsigned long long qgssize;
#define SIP_FORCE

/*
* specify an alternative type for SIP argument
* specify an alternative type for SIP argument or return value
*/
#define SIP_PYARGTYPE(type)
#define SIP_PYTYPE(type)

/*
* specify an alternative default value for SIP argument
Expand Down
2 changes: 2 additions & 0 deletions tests/scripts/sipifyheader.expected.sip
Expand Up @@ -315,6 +315,8 @@ remove argument
void position( bool keep, bool keep );
void position( bool keep );

static SIP_PYLIST changeReturnType( QVector<int> *resultTree = 0, QVector<double> &resultCost = 0 );

Whatever &operator[]( int i ) /Factory/;
%MethodCode
....
Expand Down
14 changes: 8 additions & 6 deletions tests/scripts/sipifyheader.h
Expand Up @@ -50,10 +50,10 @@ typedef qint64 QgsFeatureId;
typedef WhatEver ShouldNotBeDisplayed;
#endif

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;
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;

/** \ingroup core
* A super QGIS class
Expand Down Expand Up @@ -227,10 +227,10 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas

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

void differentType( QList<QgsFeatureId> SIP_PYARGTYPE( QList<qint64> ) & list );
void differentType( QList<QgsFeatureId> SIP_PYTYPE( 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_PYARGTYPE( qint64 ), QMap<int, QString>>> list = QList<QPair<QgsFeatureId, QMap<int, QString>>>() SIP_PYARGDEFAULT( 'QList<QPair<qint64, QMap<int, QString>>>()' ) );
void complexDefaultValueAndType( QList<QPair<QgsFeatureId SIP_PYTYPE( qint64 ), QMap<int, QString>>> list = QList<QPair<QgsFeatureId, QMap<int, QString>>>() SIP_PYARGDEFAULT( 'QList<QPair<qint64, QMap<int, QString>>>()' ) );

inline int inlineKeyWordShouldNotAppear();

Expand Down Expand Up @@ -341,6 +341,8 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas
void position( bool keep, bool middle_remove SIP_PYARGREMOVE, bool keep );
void position( bool keep, bool last_remove SIP_PYARGREMOVE );

static void SIP_PYTYPE(SIP_PYLIST) changeReturnType( QVector<int> *resultTree = 0, QVector<double> &resultCost = 0 );

//! Some comment
Whatever &operator[]( int i ) SIP_FACTORY;
#ifdef SIP_RUN
Expand Down

0 comments on commit 6958db6

Please sign in to comment.