Add %Feature support to sipify

This commit is contained in:
Matthias Kuhn 2017-04-02 12:53:31 +02:00
parent 68d8108ab3
commit a609883cc0
7 changed files with 77 additions and 0 deletions

View File

@ -31,6 +31,7 @@ class QgsProcessingProvider
virtual ~QgsProcessingProvider();
// QgsProcessingProvider &operator=( const QgsProcessingProvider &other ) = delete;
virtual QIcon icon() const;
%Docstring

View File

@ -33,6 +33,7 @@ class QgsProcessingRegistry : QObject
~QgsProcessingRegistry();
// QgsProcessingRegistry &operator=( const QgsProcessingRegistry &other ) = delete;
QList<QgsProcessingProvider *> providers() const;
%Docstring

View File

@ -337,6 +337,7 @@ class QgsVectorLayer : QgsMapLayer, QgsExpressionContextGenerator
virtual ~QgsVectorLayer();
// QgsVectorLayer &operator=( QgsVectorLayer const &rhs ) = delete;
QString storageType() const;
%Docstring

View File

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

View File

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

View File

@ -48,6 +48,13 @@ class QgsSipifyHeader : QtClass<QVariant>
%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,

View File

@ -82,6 +82,16 @@ typedef QVector<QVariant> QgsSuperClass;
*/
class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, 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<QVariant>, 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,