Skip to content

Commit

Permalink
Add %Feature support to sipify
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 2, 2017
1 parent 68d8108 commit a609883
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/core/processing/qgsprocessingprovider.sip
Expand Up @@ -31,6 +31,7 @@ class QgsProcessingProvider

virtual ~QgsProcessingProvider();

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

virtual QIcon icon() const;
%Docstring
Expand Down
1 change: 1 addition & 0 deletions python/core/processing/qgsprocessingregistry.sip
Expand Up @@ -33,6 +33,7 @@ class QgsProcessingRegistry : QObject

~QgsProcessingRegistry();

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

QList<QgsProcessingProvider *> providers() const;
%Docstring
Expand Down
1 change: 1 addition & 0 deletions python/core/qgsvectorlayer.sip
Expand Up @@ -337,6 +337,7 @@ class QgsVectorLayer : QgsMapLayer, QgsExpressionContextGenerator

virtual ~QgsVectorLayer();

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

QString storageType() const;
%Docstring
Expand Down
24 changes: 24 additions & 0 deletions scripts/sipify.pl
Expand Up @@ -53,6 +53,24 @@ sub processDoxygenLine
$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/){
Expand Down Expand Up @@ -165,6 +183,12 @@ sub processDoxygenLine
}
}

# Skip assignment operator
if ( $line =~ m/operator=\s*\(/ ){
print "// $line";

This comment has been minimized.

Copy link
@3nids

3nids Apr 3, 2017

Member

With SIP_SKIP the line is just not printed (rather than commented).
I think we should stay consistent and remove the line here.
Otherwise change the idea and print everything commented.

next;
}

# Detect comment block
if ($line =~ m/^\s*\/\*/){
do {no warnings 'uninitialized';
Expand Down
20 changes: 20 additions & 0 deletions src/core/qgis.h
Expand Up @@ -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
14 changes: 14 additions & 0 deletions tests/scripts/sipifyheader.expected.sip
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions tests/scripts/sipifyheader.h
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a609883

Please sign in to comment.