Skip to content
Permalink
Browse files
[sipify] improvements
 * add In annotation
 * remove struct forward declarations
 * fix members initialization list in header
 * merge removal code for function bodies and constructor definition
  • Loading branch information
3nids committed Apr 26, 2017
1 parent 946f0fa commit 45266cd03ef8037fd657b992357b0d2d716522da
@@ -33,6 +33,7 @@ class QgsAction
%Docstring
Default constructor
%End

QgsAction( ActionType type, const QString &description, const QString &command, bool capture = false );
%Docstring
Create a new QgsAction
@@ -42,6 +43,7 @@ class QgsAction
\param command The action text. Its interpretation depends on the type
\param capture If this is set to true, the output will be captured when an action is run
%End

QgsAction( ActionType type, const QString &description, const QString &action, const QString &icon, bool capture, const QString &shortTitle = QString(), const QSet<QString> &actionScopes = QSet<QString>() );
%Docstring
Create a new QgsAction
@@ -54,6 +56,7 @@ class QgsAction
\param shortTitle A short string used to label user interface elements like buttons
\param actionScopes A set of scopes in which this action will be available
%End

QString name() const;
%Docstring
The name of the action. This may be a longer description.
@@ -29,6 +29,7 @@ class QgsActionManager
%Docstring
Constructor
%End

QUuid addAction( QgsAction::ActionType type, const QString &name, const QString &command, bool capture = false );
%Docstring
Add an action with the given name and action details.
@@ -59,6 +59,7 @@ class QgsAttributeEditorElement /Abstract/
\param name
\param parent
%End

virtual ~QgsAttributeEditorElement();

QString name() const;
@@ -143,6 +144,7 @@ class QgsAttributeEditorContainer : QgsAttributeEditorElement
\param parent The parent. May be another container.
%End


virtual ~QgsAttributeEditorContainer();

virtual void addChildElement( QgsAttributeEditorElement *element );
@@ -254,6 +256,7 @@ class QgsAttributeEditorField : QgsAttributeEditorElement
\param idx The index of the field which should be embedded
\param parent The parent of this widget (used as container)
%End

int idx() const;
%Docstring
Return the index of the field
@@ -284,6 +287,7 @@ class QgsAttributeEditorRelation : QgsAttributeEditorElement
\param relationId The id of the relation to embed
\param parent The parent (used as container)
%End

QgsAttributeEditorRelation( const QString &name, const QgsRelation &relation, QgsAttributeEditorElement *parent );
%Docstring
Creates a new element which embeds a relation.
@@ -292,6 +296,7 @@ class QgsAttributeEditorRelation : QgsAttributeEditorElement
\param relation The relation to embed
\param parent The parent (used as container)
%End

const QgsRelation &relation() const;
%Docstring
Get the id of the relation which shall be embedded
@@ -36,6 +36,7 @@ class QgsAttributeTableConfig
Constructor for ColumnConfig
%End


QgsAttributeTableConfig::Type type; //!< The type of this column.
QString name; //!< The name of the attribute if this column represents a field
bool hidden; //!< Flag that controls if the column is hidden
@@ -102,6 +102,7 @@ class QgsGradientStop
\param offset positional offset for stop, between 0 and 1.0
\param color color for stop
%End

double offset;
%Docstring
Relative positional offset, between 0 and 1
@@ -685,7 +686,7 @@ lazy loading - have to call loadPalette() explicitly
%End
void setVariantName( const QString &variantName );
void setVariantList( const QStringList &variantList );
void setName( const QString &schemeName, const QString &variantName = "", const QStringList &variantList = QStringList() );
void setName( const QString &schemeName, const QString &variantName = QString(), const QStringList &variantList = QStringList() );

void loadPalette();
bool hasMultiStops() const;
@@ -39,6 +39,7 @@ class QgsFeedback : QObject
%Docstring
Construct a feedback object
%End

void cancel();
%Docstring
Tells the internal routines that the current operation should be canceled. This should be run by the main thread
@@ -9,7 +9,6 @@



struct sqlite3;

class QgsOfflineEditing : QObject
{
@@ -38,6 +38,7 @@ class QgsScaleBarSettings
%Docstring
Constructor for QgsScaleBarSettings.
%End

int numberOfSegments() const;
%Docstring
Returns the number of segments included in the scalebar.
@@ -32,8 +32,11 @@ class QgsIdentifyMenu : QMenu
struct ActionData
{
ActionData();

ActionData( QgsMapLayer *layer, QgsMapLayerAction *mapLayerAction = 0 );

ActionData( QgsMapLayer *layer, QgsFeatureId fid, QgsMapLayerAction *mapLayerAction = 0 );

bool mIsValid;
bool mAllResults;
bool mIsExternalAction;
@@ -24,6 +24,7 @@ class QgsOptionsPageWidget : QWidget
%Docstring
Constructor for QgsOptionsPageWidget.
%End

public slots:

virtual void apply() = 0;
@@ -49,10 +50,12 @@ QGIS crashing when a plugin crashes/exits without deregistering a factory
%Docstring
Constructor
%End

QgsOptionsWidgetFactory( const QString &title, const QIcon &icon );
%Docstring
Constructor
%End

virtual QIcon icon() const;
%Docstring
The icon that will be shown in the UI for the panel.
@@ -201,7 +201,7 @@ sub processDoxygenLine
}

# Skip forward declarations
if ($line =~ m/^\s*class \w+;$/){
if ($line =~ m/^\s*(class|struct) \w+;$/){
next;
}
# Skip Q_OBJECT, Q_PROPERTY, Q_ENUM, Q_GADGET
@@ -440,43 +440,18 @@ sub processDoxygenLine
$line =~ s/\bnullptr\b/0/g;
$line =~ s/\s*=\s*default\b//g;

# remove constructor definition
if ( $line =~ m/^(\s*)?(explicit )?(\w+)\([\w\=\(\)\s\,\&\*\<\>]*\)(?!;)$/ ){
my $newline = $line =~ s/\n/;\n/r;
my $nesting_index = 0;
while ($line_idx < $line_count){
$line = $lines[$line_idx];
$line_idx++;
if ( $nesting_index == 0 ){
if ( $line =~ m/^\s*(:|,)/ ){
next;
}
$line =~ m/^\s*\{/ or die 'Constructor definition misses {';
if ( $line =~ m/^\s*\{.*?\}/ ){
last;
}
$nesting_index = 1;
next;
}
else {
$nesting_index += $line =~ tr/\{//;
$nesting_index -= $line =~ tr/\}//;
if ($nesting_index eq 0){
last;
}
}
}
$line = $newline;
}

# remove function bodies
if ( $SIP_RUN != 1 && $line =~ m/^(\s*)?(virtual )?(static |const )*(([\w:]+(<.*?>)?\s+(\*|&)?)?(\w+|operator.{1,2})\(.*?(\(.*\))*.*\)( (?:const|SIP_[A-Z_]*?))*)\s*(\{.*\})?(?!;)(\s*\/\/.*)?$/ ){
my $newline = "$1$2$3$4;";
# remove constructor definition, function bodies, member initializing list
if ( $SIP_RUN != 1 && $line =~ m/^(\s*)?(explicit )?(virtual )?(static |const )*(([\w:]+(<.*?>)?\s+(\*|&)?)?(\w+|operator.{1,2})\([\w=()\/ ,&*<>:]*\)( (?:const|SIP_[A-Z_]*?))*)\s*(\{.*\})?(?!;)(\s*\/\/.*)?$/ ){
my $newline = "$1$2$3$4$5;";
if ($line !~ m/\{.*?\}$/){
$line = $lines[$line_idx];
$line_idx++;
while ( $line =~ m/^\s*[:,] \w+\(.*?\)/){
$line = $lines[$line_idx];
$line_idx++;
}
my $nesting_index = 1;
if ( $line =~ m/^\s*\{\s*$/ ){
if ( $line =~ m/^\s*\{$/ ){
while ($line_idx < $line_count){
$line = $lines[$line_idx];
$line_idx++;
@@ -532,6 +507,7 @@ sub processDoxygenLine

$line =~ s/\bSIP_FACTORY\b/\/Factory\//;
$line =~ s/\bSIP_OUT\b/\/Out\//g;
$line =~ s/\bSIP_IN\b/\/In\//g;
$line =~ s/\bSIP_INOUT\b/\/In,Out\//g;
$line =~ s/\bSIP_TRANSFER\b/\/Transfer\//g;
$line =~ s/\bSIP_KEEPREFERENCE\b/\/KeepReference\//;
@@ -413,6 +413,11 @@ typedef unsigned long long qgssize;
*/
#define SIP_OUT

/*
* http://pyqt.sourceforge.net/Docs/sip4/annotations.html?highlight=keepreference#argument-annotation-In
*/
#define SIP_IN

/*
* Combination of
* http://pyqt.sourceforge.net/Docs/sip4/annotations.html?highlight=keepreference#argument-annotation-In
@@ -604,7 +604,7 @@ class CORE_EXPORT QgsCptCityColorRamp : public QgsGradientColorRamp
void setSchemeName( const QString &schemeName ) { mSchemeName = schemeName; mFileLoaded = false; }
void setVariantName( const QString &variantName ) { mVariantName = variantName; mFileLoaded = false; }
void setVariantList( const QStringList &variantList ) { mVariantList = variantList; }
void setName( const QString &schemeName, const QString &variantName = "", const QStringList &variantList = QStringList() )
void setName( const QString &schemeName, const QString &variantName = QString(), const QStringList &variantList = QStringList() )
{ mSchemeName = schemeName; mVariantName = variantName; mVariantList = variantList; mFileLoaded = false; }

void loadPalette() { loadFile(); }
@@ -97,7 +97,6 @@ A constructor with no empty `()`
%Docstring
A constructor with some special character types
%End
{}

QgsSipifyHeader();
%Docstring
@@ -261,7 +260,17 @@ Mulitline body

struct PublicStruct
{
int var;
explicit PublicStruct( int _part = -1, int _ring = -1, int _vertex = -1, VertexType _type = SegmentVertex );

bool isValid( const QgsAbstractGeometry *geom ) const;
%Docstring
:rtype: bool
%End

int part;
int ring;
int vertex;
VertexType type;
}

void ZshouldBeShown();
@@ -276,7 +276,24 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas

struct CORE_EXPORT PublicStruct
{
int var;
explicit PublicStruct( int _part = -1, int _ring = -1, int _vertex = -1, VertexType _type = SegmentVertex )
: part( _part )
, ring( _ring )
, vertex( _vertex )
, type( _type )
{}

bool isValid( const QgsAbstractGeometry *geom ) const
{
return ( part >= 0 && part < geom->partCount() ) &&
( ring < geom->ringCount( part ) ) &&
( vertex < 0 || vertex < geom->vertexCount( part, ring ) );
}

int part;
int ring;
int vertex;
VertexType type;
}

#if 0

0 comments on commit 45266cd

Please sign in to comment.