diff --git a/python/core/processing/qgsprocessingprovider.sip b/python/core/processing/qgsprocessingprovider.sip index e0a279da5f8..390d2464748 100644 --- a/python/core/processing/qgsprocessingprovider.sip +++ b/python/core/processing/qgsprocessingprovider.sip @@ -31,6 +31,7 @@ class QgsProcessingProvider virtual ~QgsProcessingProvider(); +// QgsProcessingProvider &operator=( const QgsProcessingProvider &other ) = delete; virtual QIcon icon() const; %Docstring diff --git a/python/core/processing/qgsprocessingregistry.sip b/python/core/processing/qgsprocessingregistry.sip index c9c37ff0359..fed08944438 100644 --- a/python/core/processing/qgsprocessingregistry.sip +++ b/python/core/processing/qgsprocessingregistry.sip @@ -33,6 +33,7 @@ class QgsProcessingRegistry : QObject ~QgsProcessingRegistry(); +// QgsProcessingRegistry &operator=( const QgsProcessingRegistry &other ) = delete; QList providers() const; %Docstring diff --git a/python/core/qgsvectorlayer.sip b/python/core/qgsvectorlayer.sip index 09da6c232a6..1f2ae8187c1 100644 --- a/python/core/qgsvectorlayer.sip +++ b/python/core/qgsvectorlayer.sip @@ -337,6 +337,7 @@ class QgsVectorLayer : QgsMapLayer, QgsExpressionContextGenerator virtual ~QgsVectorLayer(); +// QgsVectorLayer &operator=( QgsVectorLayer const &rhs ) = delete; QString storageType() const; %Docstring diff --git a/scripts/sipify.pl b/scripts/sipify.pl index d2a4dd8a7c4..1699b8b88c4 100755 --- a/scripts/sipify.pl +++ b/scripts/sipify.pl @@ -53,6 +53,24 @@ while(!eof $header){ $line = readline $header; #print $line; + if ($line =~ m/^\s*SIP_FEATURE\( (\w+) \)(.*)$/){ + print "%Feature $1$2"; + next; + } + if ($line =~ m/^\s*SIP_IF_FEATURE\( (\!?\w+) \)(.*)$/){ + print "%If ($1)$2"; + next; + } + if ($line =~ m/^\s*SIP_CONVERT_TO_SUBCLASS_CODE(.*)$/){ + print "%ConvertToSubClassCode$1\n"; + next; + } + + if ($line =~ m/^\s*SIP_END(.*)$/){ + print "%End$1"; + next; + } + # Skip preprocessor stuff if ($line =~ m/^\s*#/){ if ( $line =~ m/^\s*#ifdef SIP_RUN/){ @@ -165,6 +183,12 @@ while(!eof $header){ } } + # Skip assignment operator + if ( $line =~ m/operator=\s*\(/ ){ + print "// $line"; + next; + } + # Detect comment block if ($line =~ m/^\s*\/\*/){ do {no warnings 'uninitialized'; diff --git a/src/core/qgis.h b/src/core/qgis.h index 845493c80a3..71d0e4f88dd 100644 --- a/src/core/qgis.h +++ b/src/core/qgis.h @@ -452,3 +452,23 @@ typedef unsigned long long qgssize; * http://pyqt.sourceforge.net/Docs/sip4/annotations.html?highlight=keepreference#function-annotation-ReleaseGIL */ #define SIP_RELEASEGIL + +/** + * Will insert a `%Feature feature` directive in sip files + */ +#define SIP_FEATURE(feature) + +/** + * Will insert a `%If feature` directive in sip files + */ +#define SIP_IF_FEATURE(feature) + +/** + * Convert to subclass code + */ +#define SIP_CONVERT_TO_SUBCLASS_CODE(code) + +/** + * Will insert a `%End` directive in sip files + */ +#define SIP_END diff --git a/tests/scripts/sipifyheader.expected.sip b/tests/scripts/sipifyheader.expected.sip index ab79f1fcb30..053de89344f 100644 --- a/tests/scripts/sipifyheader.expected.sip +++ b/tests/scripts/sipifyheader.expected.sip @@ -48,6 +48,13 @@ class QgsSipifyHeader : QtClass %TypeHeaderCode #include "sipifyheader.h" +%End + +%ConvertToSubClassCode + if ( sipCpp->headerType() == QgsSipifyHeader::Special ) + sipType = sipType_QgsSpecialSipifyHeader; + else + sipType = sipType_QgsStandardSipifyHeader; %End public: enum MyEnum @@ -80,6 +87,13 @@ A constructor with some special character types QgsSipifyHeader(); %Docstring Default constructor +%End + +// QgsSipifyHeader &operator=( const QgsSipifyHeader other ); + + bool operator==( const QgsSipifyHeader other ); +%Docstring +Comparison operator should be kept %End void multilineMethod( const QgsPoint &startPoint, diff --git a/tests/scripts/sipifyheader.h b/tests/scripts/sipifyheader.h index ff5c1e51d32..4187eb59e4b 100644 --- a/tests/scripts/sipifyheader.h +++ b/tests/scripts/sipifyheader.h @@ -82,6 +82,16 @@ typedef QVector QgsSuperClass; */ class CORE_EXPORT QgsSipifyHeader : public QtClass, private QgsBaseClass { + +#ifdef SIP_RUN + SIP_CONVERT_TO_SUBCLASS_CODE + if ( sipCpp->headerType() == QgsSipifyHeader::Special ) + sipType = sipType_QgsSpecialSipifyHeader; + else + sipType = sipType_QgsStandardSipifyHeader; + SIP_END +#endif + public: //! This is an enum enum MyEnum @@ -114,6 +124,12 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass, private QgsBaseCla //! Default constructor QgsSipifyHeader() = default; + //! Assignment operator should be removed in sip + QgsSipifyHeader &operator=( const QgsSipifyHeader other ); + + //! Comparison operator should be kept + bool operator==( const QgsSipifyHeader other ); + //! A multiline method signature void multilineMethod( const QgsPoint &startPoint, QgsFeatureId featureId,