Skip to content

Commit

Permalink
Add SIP_FINAL
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 18, 2018
1 parent ddaa8ea commit d9f5d53
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 40 deletions.
2 changes: 1 addition & 1 deletion scripts/sipify.pl
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ sub detect_non_method_member{
do {no warnings 'uninitialized';
$LINE =~ s/^(\s*template\s*<)(?:class|typename) (\w+>)(.*)$/$1$2$3/;
$LINE =~ s/\s*\boverride\b//;
$LINE =~ s/\s*\bfinal\b/ final/;
$LINE =~ s/\s*\bSIP_FINAL\b/ final/;
$LINE =~ s/\s*\bextern \b//;
$LINE =~ s/\s*\bMAYBE_UNUSED \b//;
$LINE =~ s/\s*\bNODISCARD \b//;
Expand Down
10 changes: 10 additions & 0 deletions src/core/qgis_sip.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@
*/
#define SIP_DOC_TEMPLATE

/*
* Sip supports the final keyword since version 4.19.0, earlier than that
* we will have build issues because it tries to override final methods.
*/
#if SIP_VERSION >= 0x041300
#define SIP_FINAL final
#else
#define SIP_FINAL override
#endif

/*
* Define Python special method (bool, repr, etc.) using the given method or code
* sipify.pl will create a dedicated python file named according to the class
Expand Down
78 changes: 39 additions & 39 deletions src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*/
QString displayExpression() const;

QgsVectorDataProvider *dataProvider() final;
const QgsVectorDataProvider *dataProvider() const final SIP_SKIP;
QgsVectorDataProvider *dataProvider() SIP_FINAL;
const QgsVectorDataProvider *dataProvider() const SIP_FINAL SIP_SKIP;

//! Sets the textencoding of the data provider
void setProviderEncoding( const QString &encoding );
Expand Down Expand Up @@ -519,7 +519,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \returns false if a dependency cycle has been detected
* \since QGIS 3.0
*/
bool setDependencies( const QSet<QgsMapLayerDependency> &layers ) final;
bool setDependencies( const QSet<QgsMapLayerDependency> &layers ) SIP_FINAL;

/**
* Gets the list of dependencies. This includes data dependencies set by the user (\see setDataDependencies)
Expand All @@ -528,7 +528,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \returns a set of QgsMapLayerDependency
* \since QGIS 3.0
*/
QSet<QgsMapLayerDependency> dependencies() const final;
QSet<QgsMapLayerDependency> dependencies() const SIP_FINAL;

/**
* Add a new field which is calculated by the expression specified
Expand Down Expand Up @@ -752,34 +752,34 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
QgsWkbTypes::GeometryType geometryType() const;

//! Returns the WKBType or WKBUnknown in case of error
QgsWkbTypes::Type wkbType() const final;
QgsWkbTypes::Type wkbType() const SIP_FINAL;

//! Returns the provider type for this layer
QString providerType() const;

QgsCoordinateReferenceSystem sourceCrs() const final;
QString sourceName() const final;
QgsCoordinateReferenceSystem sourceCrs() const SIP_FINAL;
QString sourceName() const SIP_FINAL;

/**
* Reads vector layer specific state from project file Dom node.
* \note Called by QgsMapLayer::readXml().
*/
bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) final;
bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) SIP_FINAL;

/**
* Write vector layer specific state to project file Dom node.
* \note Called by QgsMapLayer::writeXml().
*/
bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const final;
bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const SIP_FINAL;

QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const final;
QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const final;
QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const SIP_FINAL;
QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const SIP_FINAL;

/**
* Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
* \since QGIS 3.0
*/
void resolveReferences( QgsProject *project ) final;
void resolveReferences( QgsProject *project ) SIP_FINAL;

/**
* Save named and sld style of the layer to the style table in the db.
Expand Down Expand Up @@ -834,7 +834,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* Retained for backward compatibility
*/
QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT,
QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) final;
QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) SIP_FINAL;

/**
* Loads the auxiliary layer for this vector layer. If there's no
Expand Down Expand Up @@ -885,7 +885,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \returns true in case of success.
*/
bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) final;
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) SIP_FINAL;

/**
* Read the style for the current layer from the Dom node supplied.
Expand All @@ -896,7 +896,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \returns true in case of success.
*/
bool readStyle( const QDomNode &node, QString &errorMessage,
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) final;
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) SIP_FINAL;

/**
* Write the symbology for the layer into the docment provided.
Expand All @@ -908,7 +908,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \returns true in case of success.
*/
bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const final;
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const SIP_FINAL;

/**
* Write just the style information for the layer into the document
Expand All @@ -920,7 +920,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \returns true in case of success.
*/
bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const final;
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const SIP_FINAL;

/**
* Writes the symbology of the layer into the document provided in SLD 1.1 format
Expand All @@ -932,7 +932,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*/
bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props = QgsStringMap() ) const;

bool readSld( const QDomNode &node, QString &errorMessage ) final;
bool readSld( const QDomNode &node, QString &errorMessage ) SIP_FINAL;

/**
* Number of features rendered with specified legend key. Features must be first
Expand All @@ -951,7 +951,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*
* \since QGIS 3.4
*/
FeatureAvailability hasFeatures() const final;
FeatureAvailability hasFeatures() const SIP_FINAL;

/**
* Update the data source of the layer. The layer's renderer and legend will be preserved only
Expand Down Expand Up @@ -980,7 +980,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*/
void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false );

QString loadDefaultStyle( bool &resultFlag SIP_OUT ) final;
QString loadDefaultStyle( bool &resultFlag SIP_OUT ) SIP_FINAL;

/**
* Count features for symbols.
Expand Down Expand Up @@ -1016,7 +1016,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \param request feature request describing parameters of features to return
* \returns iterator for matching features from provider
*/
QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const final;
QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const SIP_FINAL;

/**
* Query the layer for features matching a given expression.
Expand Down Expand Up @@ -1053,7 +1053,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
return getFeatures( QgsFeatureRequest( rectangle ) );
}

bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = nullptr ) final;
bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = nullptr ) SIP_FINAL;

/**
* Updates an existing \a feature in the layer, replacing the attributes and geometry for the feature
Expand Down Expand Up @@ -1335,10 +1335,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
void setLabeling( QgsAbstractVectorLayerLabeling *labeling SIP_TRANSFER );

//! Returns true if the provider is in editing mode
bool isEditable() const final;
bool isEditable() const SIP_FINAL;

//! Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeometry
bool isSpatial() const final;
bool isSpatial() const SIP_FINAL;

//! Returns true if the provider has been modified since the last commit
virtual bool isModified() const;
Expand All @@ -1352,24 +1352,24 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
bool isAuxiliaryField( int index, int &srcIndex ) const;

//! Synchronises with changes in the datasource
void reload() final;
void reload() SIP_FINAL;

/**
* Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context
* \since QGIS 2.4
*/
QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) final SIP_FACTORY;
QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) SIP_FINAL SIP_FACTORY;

QgsRectangle extent() const final;
QgsRectangle sourceExtent() const final;
QgsRectangle extent() const SIP_FINAL;
QgsRectangle sourceExtent() const SIP_FINAL;

/**
* Returns the list of fields of this layer.
* This also includes fields which have not yet been saved to the provider.
*
* \returns A list of fields
*/
QgsFields fields() const final;
QgsFields fields() const SIP_FINAL;

/**
* Returns list of attribute indexes. i.e. a list from 0 ... fieldCount()
Expand All @@ -1385,7 +1385,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* Returns feature count including changes which have not yet been committed
* If you need only the count of committed features call this method on this layer's provider.
*/
long featureCount() const final;
long featureCount() const SIP_FINAL;

/**
* Make layer read-only (editing disabled) or not
Expand Down Expand Up @@ -1574,7 +1574,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*/
bool deleteAttributes( const QList<int> &attrs );

bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = nullptr ) final;
bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = nullptr ) SIP_FINAL;

/**
* Deletes a feature from the layer (but does not commit it).
Expand Down Expand Up @@ -1819,7 +1819,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \see minimumValue()
* \see maximumValue()
*/
QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const final;
QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const SIP_FINAL;

/**
* Returns unique string values of an attribute which contain a specified subset string. Subset
Expand All @@ -1845,7 +1845,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \see maximumValue()
* \see uniqueValues()
*/
QVariant minimumValue( int index ) const final;
QVariant minimumValue( int index ) const SIP_FINAL;

/**
* Returns the maximum value for an attribute column or an invalid variant in case of error.
Expand All @@ -1855,7 +1855,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \see minimumValue()
* \see uniqueValues()
*/
QVariant maximumValue( int index ) const final;
QVariant maximumValue( int index ) const SIP_FINAL;

/**
* Calculates an aggregated value from the layer's features.
Expand Down Expand Up @@ -1896,7 +1896,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*/
double opacity() const;

QString htmlMetadata() const final;
QString htmlMetadata() const SIP_FINAL;

/**
* Set the simplification settings for fast rendering of features
Expand Down Expand Up @@ -1956,9 +1956,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*/
void setMapTipTemplate( const QString &mapTipTemplate );

QgsExpressionContext createExpressionContext() const final;
QgsExpressionContext createExpressionContext() const SIP_FINAL;

QgsExpressionContextScope *createExpressionContextScope() const final SIP_FACTORY;
QgsExpressionContextScope *createExpressionContextScope() const SIP_FINAL SIP_FACTORY;

/**
* Returns the configuration of the form used to represent this vector layer.
Expand Down Expand Up @@ -2338,15 +2338,15 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte

protected:
//! Sets the extent
void setExtent( const QgsRectangle &rect ) final;
void setExtent( const QgsRectangle &rect ) SIP_FINAL;

private:
void updateDefaultValues( QgsFeatureId fid, QgsFeature feature = QgsFeature() );

/**
* Returns true if the provider is in read-only mode
*/
bool isReadOnly() const final;
bool isReadOnly() const SIP_FINAL;

/**
* Bind layer to a specific data provider
Expand Down

0 comments on commit d9f5d53

Please sign in to comment.