Skip to content

Commit

Permalink
[sip] more reverse engineering
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed May 23, 2017
1 parent fe9594f commit 2929f9d
Show file tree
Hide file tree
Showing 43 changed files with 102 additions and 85 deletions.
16 changes: 9 additions & 7 deletions scripts/sipify_header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ while read -r sipfile; do


header=$(${GP}sed -E 's/(.*)\.sip/src\/\1.h/' <<< $sipfile)
echo "$header"
echo "*************"
echo "*** $header"

# continue

Expand All @@ -61,31 +62,32 @@ while read -r sipfile; do
#echo ${annot_head[$i]}
while read -r line; do
echo $line
line=$(${GP}sed -r 's/^\s+//; s/\s+/ /g; s/\s+$//g;' <<< $line)
line=$(${GP}sed -r 's/^\s+//; s/\s+/ /g; s/\s+$//g; s/^virtual//;' <<< $line)
orig_line=$(${GP}sed -r "s@ /${annot_head[$i]}/@@g" <<< $line)
dest_line=$(${GP}sed -r "s@/${annot_head[$i]}/@${annot_sip[$i]}@g" <<< $line)
esc_orig_line=$(${GP}sed -r 's/([(){}*+?$^&])/\\\1/g' <<< $orig_line)
esc_dest_line=$(${GP}sed -r 's/([&])/\\\1/g' <<< $dest_line)
esc_dest_line=$(${GP}sed -r 's/;//g' <<< $esc_dest_line)
esc_orig_line=$(${GP}sed -r 's/0/(\?:0|nullptr)/g' <<< $esc_orig_line)
esc_orig_line=$(${GP}sed -r 's/""/(""|QString\(\))/g' <<< $esc_orig_line)
esc_dest_line=$(${GP}sed -r 's/(\*\w+) = 0/\1 = nullptr/g' <<< $esc_dest_line)
esc_orig_line=$(${GP}sed -r 's/((= 0)?;)/\(\\s\*override\)\?\\s\*\1/g' <<< $esc_orig_line)
esc_dest_line=$(${GP}sed -r 's/(( SIP_\w+)?( = 0)?;)/\\1\1/' <<< $esc_dest_line)
esc_orig_line=$(${GP}sed -r 's/((= 0)?);/\( \*override\)\? \*\?\1\( \*\\{.\*\\}\|;\|$\)/g' <<< $esc_orig_line)
esc_dest_line=$(${GP}sed -r 's/( SIP_\w+)?( = 0)?(;)?$/\\1\1\2\3\\2/' <<< $esc_dest_line)
echo "orig: $esc_orig_line"
echo "dest: $esc_dest_line"
#echo "${GP}sed -i -r \"s/$esc_orig_line/$esc_dest_line/\" $header"
echo "${GP}sed -i -r \"s/$esc_orig_line/$esc_dest_line/\" $header"
perl -pi.bak -e "s/$esc_orig_line/$esc_dest_line/" $header
done < <(egrep "\/${annot_head[$i]}\/" python/$sipfile)
done

# if [[ $sipfile =~ core/diagram/qgshistogramdiagram.sip ]]; then
# if [[ $sipfile =~ core/qgsdiagramrenderer.sip ]]; then
# exit
# fi


if ! cmp $header $m >/dev/null 2>&1; then
if ! egrep -xq "#include \"qgis(_sip)?.h\"" $header; then
gawk -i inplace '{print} /^#include/ && !n {print "#include \"qgis.h\""; n++}' $header
gawk -i inplace '{print} /^#include/ && !n {print "#include \"qgis_sip.h\""; n++}' $header
fi
fi
rm $m
Expand Down
4 changes: 2 additions & 2 deletions src/core/effects/qgspainteffectregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class CORE_EXPORT QgsPaintEffectAbstractMetadata
* if there's no GUI for the paint effect class.
* \returns configuration widget
*/
virtual QgsPaintEffectWidget *createWidget() { return nullptr; }
virtual QgsPaintEffectWidget *createWidget() SIP_FACTORY { return nullptr; }

protected:
QString mName;
Expand Down Expand Up @@ -139,7 +139,7 @@ class CORE_EXPORT QgsPaintEffectMetadata : public QgsPaintEffectAbstractMetadata
* \note not available in Python bindings
* \see createWidget
*/
virtual QgsPaintEffectWidget *createWidget() override { return mWidgetFunc ? mWidgetFunc() : nullptr; } SIP_SKIP
virtual QgsPaintEffectWidget *createWidget() override SIP_FACTORY { return mWidgetFunc ? mWidgetFunc() : nullptr; } SIP_SKIP

protected:
QgsPaintEffectCreateFunc mCreateFunc;
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsdiagramrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ class CORE_EXPORT QgsDiagramRenderer
* \see sizeLegendSymbol()
* \see setSizeLegend()
*/
void setSizeLegendSymbol( QgsMarkerSymbol *symbol ) { mSizeLegendSymbol.reset( symbol ); }
void setSizeLegendSymbol( QgsMarkerSymbol *symbol SIP_TRANSFER ) { mSizeLegendSymbol.reset( symbol ); }

protected:
QgsDiagramRenderer( const QgsDiagramRenderer &other );
Expand Down Expand Up @@ -619,7 +619,7 @@ class CORE_EXPORT QgsSingleCategoryDiagramRenderer : public QgsDiagramRenderer
public:
QgsSingleCategoryDiagramRenderer();

QgsSingleCategoryDiagramRenderer *clone() const override;
QgsSingleCategoryDiagramRenderer *clone() const override SIP_FACTORY;

QString rendererName() const override { return QStringLiteral( "SingleCategory" ); }

Expand Down Expand Up @@ -651,7 +651,7 @@ class CORE_EXPORT QgsLinearlyInterpolatedDiagramRenderer : public QgsDiagramRend
public:
QgsLinearlyInterpolatedDiagramRenderer();

QgsLinearlyInterpolatedDiagramRenderer *clone() const override;
QgsLinearlyInterpolatedDiagramRenderer *clone() const override SIP_FACTORY;

//! Returns list with all diagram settings in the renderer
QList<QgsDiagramSettings> diagramSettings() const override;
Expand Down
3 changes: 2 additions & 1 deletion src/core/raster/qgsbilinearrasterresampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define QGSBILINEARRASTERRESAMPLER_H

#include "qgsrasterresampler.h"
#include "qgis_sip.h"
#include <QColor>

#include "qgis_core.h"
Expand All @@ -33,7 +34,7 @@ class CORE_EXPORT QgsBilinearRasterResampler: public QgsRasterResampler

void resample( const QImage &srcImage, QImage &dstImage ) override;
QString type() const override { return QStringLiteral( "bilinear" ); }
QgsBilinearRasterResampler *clone() const override;
QgsBilinearRasterResampler *clone() const override SIP_FACTORY;
};

#endif // QGSBILINEARRASTERRESAMPLER_H
2 changes: 1 addition & 1 deletion src/core/raster/qgsbrightnesscontrastfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CORE_EXPORT QgsBrightnessContrastFilter : public QgsRasterInterface
public:
QgsBrightnessContrastFilter( QgsRasterInterface *input = nullptr );

QgsBrightnessContrastFilter *clone() const override;
QgsBrightnessContrastFilter *clone() const override SIP_FACTORY;

int bandCount() const override;

Expand Down
3 changes: 2 additions & 1 deletion src/core/raster/qgscubicrasterresampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define QGSCUBICRASTERRESAMPLER_H

#include "qgsrasterresampler.h"
#include "qgis_sip.h"
#include <QColor>

#include "qgis_core.h"
Expand All @@ -30,7 +31,7 @@ class CORE_EXPORT QgsCubicRasterResampler: public QgsRasterResampler
{
public:
QgsCubicRasterResampler();
QgsCubicRasterResampler *clone() const override;
QgsCubicRasterResampler *clone() const override SIP_FACTORY;
void resample( const QImage &srcImage, QImage &dstImage ) override;
QString type() const override { return QStringLiteral( "cubic" ); }

Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgshillshaderenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CORE_EXPORT QgsHillshadeRenderer : public QgsRasterRenderer
*/
QgsHillshadeRenderer( QgsRasterInterface *input, int band, double lightAzimuth, double lightAltitude );

QgsHillshadeRenderer *clone() const override;
QgsHillshadeRenderer *clone() const override SIP_FACTORY;

/**
* \brief Factory method to create a new renderer
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgshuesaturationfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CORE_EXPORT QgsHueSaturationFilter : public QgsRasterInterface

QgsHueSaturationFilter( QgsRasterInterface *input = nullptr );

QgsHueSaturationFilter *clone() const override;
QgsHueSaturationFilter *clone() const override SIP_FACTORY;

int bandCount() const override;

Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsmultibandcolorrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CORE_EXPORT QgsMultiBandColorRenderer: public QgsRasterRenderer
//! QgsMultiBandColorRenderer cannot be copied. Use clone() instead.
const QgsMultiBandColorRenderer &operator=( const QgsMultiBandColorRenderer & ) = delete;

QgsMultiBandColorRenderer *clone() const override;
QgsMultiBandColorRenderer *clone() const override SIP_FACTORY;

static QgsRasterRenderer *create( const QDomElement &elem, QgsRasterInterface *input );

Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgspalettedrasterrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CORE_EXPORT QgsPalettedRasterRenderer: public QgsRasterRenderer
//! QgsPalettedRasterRenderer cannot be copied. Use clone() instead.
const QgsPalettedRasterRenderer &operator=( const QgsPalettedRasterRenderer & ) = delete;

QgsPalettedRasterRenderer *clone() const override;
QgsPalettedRasterRenderer *clone() const override SIP_FACTORY;
static QgsRasterRenderer *create( const QDomElement &elem, QgsRasterInterface *input ) SIP_FACTORY;

QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback = nullptr ) override SIP_FACTORY;
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterdataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast
* \since QGIS 2.8
*
*/
virtual QgsImageFetcher *getLegendGraphicFetcher( const QgsMapSettings *mapSettings )
virtual QgsImageFetcher *getLegendGraphicFetcher( const QgsMapSettings *mapSettings ) SIP_FACTORY
{
Q_UNUSED( mapSettings );
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
/** Returns the data provider in a const-correct manner
\note available in Python bindings as constDataProvider()
*/
const QgsRasterDataProvider *dataProvider() const override;
const QgsRasterDataProvider *dataProvider() const SIP_PYNAME( constDataProvider ) override;

//! Synchronises with changes in the datasource
virtual void reload() override;
Expand Down
3 changes: 2 additions & 1 deletion src/core/raster/qgsrasternuller.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define QGSRASTERNULLER_H

#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgsrasterrange.h"
#include "qgsrasterinterface.h"

Expand All @@ -38,7 +39,7 @@ class CORE_EXPORT QgsRasterNuller : public QgsRasterInterface
double max;
};

QgsRasterNuller *clone() const override;
QgsRasterNuller *clone() const override SIP_FACTORY;

int bandCount() const override;

Expand Down
3 changes: 2 additions & 1 deletion src/core/raster/qgsrasterprojector.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define QGSRASTERPROJECTOR_H

#include "qgis_core.h"
#include "qgis_sip.h"
#include <QVector>
#include <QList>

Expand Down Expand Up @@ -57,7 +58,7 @@ class CORE_EXPORT QgsRasterProjector : public QgsRasterInterface

QgsRasterProjector();

QgsRasterProjector *clone() const override;
QgsRasterProjector *clone() const override SIP_FACTORY;

int bandCount() const override;

Expand Down
3 changes: 2 additions & 1 deletion src/core/raster/qgsrasterrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define QGSRASTERRENDERER_H

#include "qgis_core.h"
#include "qgis_sip.h"
#include <QPair>

#include "qgsrasterinterface.h"
Expand Down Expand Up @@ -73,7 +74,7 @@ class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface
int alphaBand() const { return mAlphaBand; }

//! Get symbology items if provided by renderer
virtual void legendSymbologyItems( QList< QPair< QString, QColor > > &symbolItems ) const { Q_UNUSED( symbolItems ); }
virtual void legendSymbologyItems( QList< QPair< QString, QColor > > &symbolItems SIP_OUT ) const { Q_UNUSED( symbolItems ); }

//! Sets base class members from xml. Usually called from create() methods of subclasses
void readXml( const QDomElement &rendererElem ) override;
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterresamplefilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CORE_EXPORT QgsRasterResampleFilter : public QgsRasterInterface
public:
QgsRasterResampleFilter( QgsRasterInterface *input = nullptr );

QgsRasterResampleFilter *clone() const override;
QgsRasterResampleFilter *clone() const override SIP_FACTORY;

int bandCount() const override;

Expand Down
3 changes: 2 additions & 1 deletion src/core/raster/qgsrastershaderfunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ email : ersts@amnh.org
*/

#include "qgis_core.h"
#include "qgis_sip.h"
#include <QColor>
#include <QPair>

Expand Down Expand Up @@ -53,7 +54,7 @@ class CORE_EXPORT QgsRasterShaderFunction
double minimumValue() const { return mMinimumValue; }
double maximumValue() const { return mMaximumValue; }

virtual void legendSymbologyItems( QList< QPair< QString, QColor > > &symbolItems ) const { Q_UNUSED( symbolItems ); }
virtual void legendSymbologyItems( QList< QPair< QString, QColor > > &symbolItems SIP_OUT ) const { Q_UNUSED( symbolItems ); }

protected:
//! \brief User defineable maximum value for the shading function
Expand Down
3 changes: 2 additions & 1 deletion src/core/raster/qgssinglebandcolordatarenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define QGSSINGLEBANDCOLORDATARENDERER_H

#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgsrasterrenderer.h"

class QDomElement;
Expand All @@ -36,7 +37,7 @@ class CORE_EXPORT QgsSingleBandColorDataRenderer: public QgsRasterRenderer
//! QgsSingleBandColorDataRenderer cannot be copied. Use clone() instead.
const QgsSingleBandColorDataRenderer &operator=( const QgsSingleBandColorDataRenderer & ) = delete;

QgsSingleBandColorDataRenderer *clone() const override;
QgsSingleBandColorDataRenderer *clone() const override SIP_FACTORY;

static QgsRasterRenderer *create( const QDomElement &elem, QgsRasterInterface *input );

Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgssinglebandgrayrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CORE_EXPORT QgsSingleBandGrayRenderer: public QgsRasterRenderer
//! QgsSingleBandGrayRenderer cannot be copied. Use clone() instead.
const QgsSingleBandGrayRenderer &operator=( const QgsSingleBandGrayRenderer & ) = delete;

QgsSingleBandGrayRenderer *clone() const override;
QgsSingleBandGrayRenderer *clone() const override SIP_FACTORY;

static QgsRasterRenderer *create( const QDomElement &elem, QgsRasterInterface *input );

Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgssinglebandpseudocolorrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CORE_EXPORT QgsSingleBandPseudoColorRenderer: public QgsRasterRenderer
//! QgsSingleBandPseudoColorRenderer cannot be copied. Use clone() instead.
const QgsSingleBandPseudoColorRenderer &operator=( const QgsSingleBandPseudoColorRenderer & ) = delete;

QgsSingleBandPseudoColorRenderer *clone() const override;
QgsSingleBandPseudoColorRenderer *clone() const override SIP_FACTORY;

static QgsRasterRenderer *create( const QDomElement &elem, QgsRasterInterface *input );

Expand All @@ -57,7 +57,7 @@ class CORE_EXPORT QgsSingleBandPseudoColorRenderer: public QgsRasterRenderer
QgsRasterShader *shader() { return mShader.get(); }

//! \note available in Python as constShader
const QgsRasterShader *shader() const { return mShader.get(); }
const QgsRasterShader *shader() const SIP_PYNAME( constShader ) { return mShader.get(); }

/** Creates a color ramp shader
* \param colorRamp vector color ramp
Expand Down
4 changes: 2 additions & 2 deletions src/core/symbology-ng/qgscptcityarchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class CORE_EXPORT QgsCptCityDataItem : public QObject

virtual bool equal( const QgsCptCityDataItem *other );

virtual QWidget *paramWidget() { return nullptr; }
virtual QWidget *paramWidget() SIP_FACTORY { return nullptr; }

// list of actions provided by this item - usually used for popup menu on right-click
virtual QList<QAction *> actions() { return QList<QAction *>(); }
Expand Down Expand Up @@ -245,7 +245,7 @@ class CORE_EXPORT QgsCptCityCollectionItem : public QgsCptCityDataItem
~QgsCptCityCollectionItem();

void setPopulated() { mPopulated = true; }
void addChild( QgsCptCityDataItem *item ) { mChildren.append( item ); }
void addChild( QgsCptCityDataItem *item SIP_TRANSFER ) { mChildren.append( item ); }
QVector<QgsCptCityDataItem *> childrenRamps( bool recursive );

protected:
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsellipsesymbollayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CORE_EXPORT QgsEllipseSymbolLayer: public QgsMarkerSymbolLayer
QString layerType() const override;
void startRender( QgsSymbolRenderContext &context ) override;
void stopRender( QgsSymbolRenderContext &context ) override;
QgsEllipseSymbolLayer *clone() const override;
QgsEllipseSymbolLayer *clone() const override SIP_FACTORY;
QgsStringMap properties() const override;

void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props ) const override;
Expand Down
Loading

0 comments on commit 2929f9d

Please sign in to comment.