Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #7948 from m-kuhn/final
It's the `final` countdown
  • Loading branch information
m-kuhn committed Sep 19, 2018
2 parents d129c2c + b2072d8 commit fde813c
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 118 deletions.
6 changes: 6 additions & 0 deletions python/CMakeLists.txt
Expand Up @@ -168,6 +168,12 @@ IF(${SIP_VERSION_STR} VERSION_GREATER 4.19.6)
SET(DOCSTRINGSTEMPLATE "")
ENDIF(${SIP_VERSION_STR} VERSION_GREATER 4.19.6)

IF(${SIP_VERSION_STR} VERSION_GREATER 4.19.0)
SET(SIP_FINAL "final")
ELSE(${SIP_VERSION_STR} VERSION_GREATER 4.19.0)
SET(SIP_FINAL "override")
ENDIF(${SIP_VERSION_STR} VERSION_GREATER 4.19.0)

# core module
FILE(GLOB_RECURSE sip_files_core core/*.sip core/*.sip.in)
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core})
Expand Down
1 change: 0 additions & 1 deletion python/core/auto_generated/qgis.sip.in
Expand Up @@ -232,7 +232,6 @@ typedef unsigned long long qgssize;




/************************************************************************
* This file has been generated automatically from *
* *
Expand Down
115 changes: 42 additions & 73 deletions python/core/auto_generated/qgsvectorlayer.sip.in
Expand Up @@ -404,8 +404,7 @@ Uses :py:class:`QgsExpression`
:return: The expression which will be used to preview features for this layer
%End

virtual QgsVectorDataProvider *dataProvider();

QgsVectorDataProvider *dataProvider() ${SIP_FINAL};

void setProviderEncoding( const QString &encoding );
%Docstring
Expand Down Expand Up @@ -443,8 +442,7 @@ Returns the join buffer object.
%End
const QList<QgsVectorLayerJoinInfo> vectorJoins() const;

virtual bool setDependencies( const QSet<QgsMapLayerDependency> &layers );

bool setDependencies( const QSet<QgsMapLayerDependency> &layers ) ${SIP_FINAL};
%Docstring
Sets the list of dependencies.

Expand All @@ -457,8 +455,7 @@ Sets the list of dependencies.
.. versionadded:: 3.0
%End

virtual QSet<QgsMapLayerDependency> dependencies() const;

QSet<QgsMapLayerDependency> dependencies() const ${SIP_FINAL};
%Docstring
Gets the list of dependencies. This includes data dependencies set by the user (:py:func:`setDataDependencies`)
as well as dependencies given by the provider
Expand Down Expand Up @@ -724,8 +721,7 @@ Ownership is transferred.
Returns point, line or polygon
%End

virtual QgsWkbTypes::Type wkbType() const;

QgsWkbTypes::Type wkbType() const ${SIP_FINAL};
%Docstring
Returns the WKBType or WKBUnknown in case of error
%End
Expand All @@ -735,13 +731,10 @@ Returns the WKBType or WKBUnknown in case of error
Returns the provider type for this layer
%End

virtual QgsCoordinateReferenceSystem sourceCrs() const;

virtual QString sourceName() const;


virtual bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context );
QgsCoordinateReferenceSystem sourceCrs() const ${SIP_FINAL};
QString sourceName() const ${SIP_FINAL};

bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) ${SIP_FINAL};
%Docstring
Reads vector layer specific state from project file Dom node.

Expand All @@ -750,8 +743,7 @@ Reads vector layer specific state from project file Dom node.
Called by :py:func:`QgsMapLayer.readXml()`
%End

virtual bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const;

bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const ${SIP_FINAL};
%Docstring
Write vector layer specific state to project file Dom node.

Expand All @@ -760,13 +752,10 @@ Write vector layer specific state to project file Dom node.
Called by :py:func:`QgsMapLayer.writeXml()`
%End

virtual QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const;

virtual QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const;


virtual void resolveReferences( QgsProject *project );
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};

void resolveReferences( QgsProject *project ) ${SIP_FINAL};
%Docstring
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.

Expand Down Expand Up @@ -831,8 +820,8 @@ Load a named style from file/local db/datasource db
:param categories: the style categories to be loaded.
%End

virtual QString loadNamedStyle( const QString &theURI, bool &resultFlag /Out/,
QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
QString loadNamedStyle( const QString &theURI, bool &resultFlag /Out/,
QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) ${SIP_FINAL};
%Docstring
Calls loadNamedStyle( theURI, resultFlag, false );
Retained for backward compatibility
Expand Down Expand Up @@ -872,8 +861,8 @@ Returns the current auxiliary layer.
%End


virtual bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) ${SIP_FINAL};
%Docstring
Read the symbology for the current layer from the Dom node supplied.

Expand All @@ -885,8 +874,8 @@ Read the symbology for the current layer from the Dom node supplied.
:return: true in case of success.
%End

virtual bool readStyle( const QDomNode &node, QString &errorMessage,
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
bool readStyle( const QDomNode &node, QString &errorMessage,
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) ${SIP_FINAL};
%Docstring
Read the style for the current layer from the Dom node supplied.

Expand All @@ -898,8 +887,8 @@ Read the style for the current layer from the Dom node supplied.
:return: true in case of success.
%End

virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const;
bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const ${SIP_FINAL};
%Docstring
Write the symbology for the layer into the docment provided.

Expand All @@ -912,8 +901,8 @@ Write the symbology for the layer into the docment provided.
:return: true in case of success.
%End

virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const;
bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const ${SIP_FINAL};
%Docstring
Write just the style information for the layer into the document

Expand All @@ -938,8 +927,7 @@ Writes the symbology of the layer into the document provided in SLD 1.1 format
:return: true in case of success
%End

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

bool readSld( const QDomNode &node, QString &errorMessage ) ${SIP_FINAL};

long featureCount( const QString &legendKey ) const;
%Docstring
Expand All @@ -949,8 +937,7 @@ calculated by countSymbolFeatures()
:return: number of features rendered by symbol or -1 if failed or counts are not available
%End

virtual FeatureAvailability hasFeatures() const;

FeatureAvailability hasFeatures() const ${SIP_FINAL};
%Docstring
Determines if this vector layer has features.

Expand Down Expand Up @@ -997,8 +984,7 @@ if the geometry type of the new data source matches the current geometry type of
.. versionadded:: 3.2
%End

virtual QString loadDefaultStyle( bool &resultFlag /Out/ );

QString loadDefaultStyle( bool &resultFlag /Out/ ) ${SIP_FINAL};

QgsVectorLayerFeatureCounter *countSymbolFeatures();
%Docstring
Expand Down Expand Up @@ -1034,8 +1020,7 @@ Returns the string (typically sql) used to define a subset of the layer.
:return: The subset string or null QString if not implemented by the provider
%End

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const;

QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const ${SIP_FINAL};
%Docstring
Query the layer for features specified in request.

Expand Down Expand Up @@ -1065,8 +1050,7 @@ Query the layer for the features with the given ids.
Query the layer for the features which intersect the specified rectangle.
%End

virtual bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = 0 );

bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = 0 ) ${SIP_FINAL};

bool updateFeature( QgsFeature &feature, bool skipDefaultValues = false );
%Docstring
Expand Down Expand Up @@ -1428,14 +1412,12 @@ Set labeling configuration. Takes ownership of the object.
.. versionadded:: 3.0
%End

virtual bool isEditable() const;

bool isEditable() const ${SIP_FINAL};
%Docstring
Returns true if the provider is in editing mode
%End

virtual bool isSpatial() const;

bool isSpatial() const ${SIP_FINAL};
%Docstring
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeometry
%End
Expand All @@ -1453,26 +1435,22 @@ false otherwise.
.. versionadded:: 3.0
%End

virtual void reload();

void reload() ${SIP_FINAL};
%Docstring
Synchronises with changes in the datasource
%End

virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) /Factory/;

QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) ${SIP_FINAL} /Factory/;
%Docstring
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context

.. versionadded:: 2.4
%End

virtual QgsRectangle extent() const;
QgsRectangle extent() const ${SIP_FINAL};
QgsRectangle sourceExtent() const ${SIP_FINAL};

virtual QgsRectangle sourceExtent() const;


virtual QgsFields fields() const;
QgsFields fields() const ${SIP_FINAL};
%Docstring
Returns the list of fields of this layer.
This also includes fields which have not yet been saved to the provider.
Expand All @@ -1490,8 +1468,7 @@ Returns list of attribute indexes. i.e. a list from 0 ... fieldCount()
Returns the list of attributes which make up the layer's primary keys.
%End

virtual long featureCount() const;

long featureCount() const ${SIP_FINAL};
%Docstring
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.
Expand Down Expand Up @@ -1715,8 +1692,7 @@ Deletes a list of attribute fields (but does not commit it)
:return: true if at least one attribute has been deleted
%End

virtual bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = 0 );

bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = 0 ) ${SIP_FINAL};

bool deleteFeature( QgsFeatureId fid );
%Docstring
Expand Down Expand Up @@ -1999,8 +1975,7 @@ for the field at `index`.
.. versionadded:: 3.0
%End

virtual QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const;

QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const ${SIP_FINAL};
%Docstring
Calculates a list of unique values contained within an attribute in the layer. Note that
in some circumstances when unsaved changes are present for the layer then the returned list
Expand Down Expand Up @@ -2034,8 +2009,7 @@ returned list).
:return: list of unique strings containing substring
%End

virtual QVariant minimumValue( int index ) const;

QVariant minimumValue( int index ) const ${SIP_FINAL};
%Docstring
Returns the minimum value for an attribute column or an invalid variant in case of error.
Note that in some circumstances when unsaved changes are present for the layer then the
Expand All @@ -2047,8 +2021,7 @@ been changed inside the edit buffer then the previous saved value may be returne
.. seealso:: :py:func:`uniqueValues`
%End

virtual QVariant maximumValue( int index ) const;

QVariant maximumValue( int index ) const ${SIP_FINAL};
%Docstring
Returns the maximum value for an attribute column or an invalid variant in case of error.
Note that in some circumstances when unsaved changes are present for the layer then the
Expand Down Expand Up @@ -2112,8 +2085,7 @@ and 1.0 (fully opaque).
.. versionadded:: 3.0
%End

virtual QString htmlMetadata() const;

QString htmlMetadata() const ${SIP_FINAL};

void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod );
%Docstring
Expand Down Expand Up @@ -2181,11 +2153,9 @@ It may also contain embedded expressions.
.. versionadded:: 3.0
%End

virtual QgsExpressionContext createExpressionContext() const;


virtual QgsExpressionContextScope *createExpressionContextScope() const /Factory/;
QgsExpressionContext createExpressionContext() const ${SIP_FINAL};

QgsExpressionContextScope *createExpressionContextScope() const ${SIP_FINAL} /Factory/;

QgsEditFormConfig editFormConfig() const;
%Docstring
Expand Down Expand Up @@ -2596,8 +2566,7 @@ Emitted when the feature count for symbols on this layer has been recalculated.
%End

protected:
virtual void setExtent( const QgsRectangle &rect );

void setExtent( const QgsRectangle &rect ) ${SIP_FINAL};
%Docstring
Sets the extent
%End
Expand Down
2 changes: 1 addition & 1 deletion scripts/sipify.pl
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//;
$LINE =~ s/\s*\bFINAL\b/ \${SIP_FINAL}/;
$LINE =~ s/\s*\bextern \b//;
$LINE =~ s/\s*\bMAYBE_UNUSED \b//;
$LINE =~ s/\s*\bNODISCARD \b//;
Expand Down
4 changes: 3 additions & 1 deletion src/core/qgis.h
Expand Up @@ -636,6 +636,8 @@ typedef unsigned long long qgssize;
#define MAYBE_UNUSED
#endif


#ifndef FINAL
#define FINAL final
#endif


11 changes: 11 additions & 0 deletions src/core/qgis_sip.h
Expand Up @@ -197,6 +197,17 @@
*/
#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
#if defined FINAL
#undef FINAL
#endif
#define 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
5 changes: 5 additions & 0 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -2863,6 +2863,11 @@ bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds &fids )
return res;
}

QgsFields QgsVectorLayer::fields() const
{
return mFields;
}

QgsAttributeList QgsVectorLayer::primaryKeyAttributes() const
{
QgsAttributeList pkAttributesList;
Expand Down

0 comments on commit fde813c

Please sign in to comment.