Skip to content

Commit

Permalink
[sipify] keep external forward declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed May 24, 2017
1 parent 09d3e2f commit f63adfe
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions cmake_templates/Doxyfile.in
Expand Up @@ -2056,6 +2056,7 @@ EXPAND_AS_DEFINED = "SIP_ABSTRACT" \
"SIP_CONVERT_TO_SUBCLASS_CODE" \
"SIP_DEPRECATED" \
"SIP_END" \
"SIP_EXTERNAL" \
"SIP_FACTORY" \
"SIP_FEATURE" \
"SIP_IF_FEATURE" \
Expand Down
5 changes: 3 additions & 2 deletions python/core/effects/qgspainteffectregistry.sip
Expand Up @@ -8,6 +8,7 @@



class QgsPaintEffectWidget /External/;

class QgsPaintEffectAbstractMetadata
{
Expand Down Expand Up @@ -73,8 +74,6 @@ class QgsPaintEffectAbstractMetadata

};

typedef QgsPaintEffect *( *QgsPaintEffectCreateFunc )( const QgsStringMap & );
typedef QgsPaintEffectWidget *( *QgsPaintEffectWidgetFunc )();



Expand Down Expand Up @@ -161,6 +160,8 @@ class QgsPaintEffectRegistry
:rtype: bool
%End

private:
QgsPaintEffectRegistry( const QgsPaintEffectRegistry &rh );
};

/************************************************************************
Expand Down
18 changes: 13 additions & 5 deletions scripts/sipify.pl
Expand Up @@ -151,6 +151,7 @@ ()
$line =~ s/\bSIP_ARRAYSIZE\b/\/ArraySize\//g;
$line =~ s/\bSIP_DEPRECATED\b/\/Deprecated\//g;
$line =~ s/\bSIP_CONSTRAINED\b/\/Constrained\//g;
$line =~ s/\bSIP_EXTERNAL\b/\/External\//g;
$line =~ s/\bSIP_FACTORY\b/\/Factory\//;
$line =~ s/\bSIP_IN\b/\/In\//g;
$line =~ s/\bSIP_INOUT\b/\/In,Out\//g;
Expand Down Expand Up @@ -357,9 +358,16 @@ sub detect_comment_block{
}

# Skip forward declarations
if ($line =~ m/^\s*(class|struct) \w+;\s*(\/\/.*)?$/){
dbg_info('skipping forward declaration');
next;
if ($line =~ m/^\s*(class|struct) \w+(?<external> *SIP_EXTERNAL)?;\s*(\/\/.*)?$/){
if ($+{external}){
dbg_info('do not skip external forward declaration');
$comment = '';
}
else
{
dbg_info('skipping forward declaration');
next;
}
}
# Skip Q_OBJECT, Q_PROPERTY, Q_ENUM, Q_GADGET
if ($line =~ m/^\s*Q_(OBJECT|ENUMS|PROPERTY|GADGET|DECLARE_METATYPE|DECLARE_TYPEINFO|DECL_DEPRECATED).*?$/){
Expand Down Expand Up @@ -401,8 +409,8 @@ sub detect_comment_block{
}

# class declaration started
# https://regex101.com/r/6FWntP/5
if ( $line =~ m/^(\s*class)\s+([A-Z]+_EXPORT\s+)?(\w+)(\s*\:\s*(public|private)\s+\w+(<([\w]|::)+>)?(::\w+(<\w+>)?)*(,\s*(public|private)\s+\w+(<([\w]|::)+>)?(::\w+(<\w+>)?)*)*)?(?<annot>\s*SIP_.*)?$/ ){
# https://regex101.com/r/6FWntP/6
if ( $line =~ m/^(\s*class)\s+([A-Z]+_EXPORT\s+)?(\w+)(\s*\:\s*(public|private)\s+\w+(<([\w]|::)+>)?(::\w+(<\w+>)?)*(,\s*(public|private)\s+\w+(<([\w]|::)+>)?(::\w+(<\w+>)?)*)*)?(?<annot>\s*SIP_\w+)?(?!;)$/ ){
dbg_info("class definition started");
push @ACCESS, PUBLIC;
push @EXPORTED, 0;
Expand Down
10 changes: 6 additions & 4 deletions src/core/effects/qgspainteffectregistry.h
Expand Up @@ -17,13 +17,12 @@
#define QGSPAINTEFFECTREGISTRY_H

#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgis.h"
#include <QDomElement>
#include <QDomDocument>

class QgsPaintEffect;
class QgsPaintEffectWidget;
class QgsPaintEffectWidget SIP_EXTERNAL;

/** \ingroup core
* \class QgsPaintEffectAbstractMetadata
Expand Down Expand Up @@ -77,8 +76,8 @@ class CORE_EXPORT QgsPaintEffectAbstractMetadata

};

typedef QgsPaintEffect *( *QgsPaintEffectCreateFunc )( const QgsStringMap & );
typedef QgsPaintEffectWidget *( *QgsPaintEffectWidgetFunc )();
typedef QgsPaintEffect *( *QgsPaintEffectCreateFunc )( const QgsStringMap & ) SIP_SKIP;
typedef QgsPaintEffectWidget *( *QgsPaintEffectWidgetFunc )() SIP_SKIP;

/** \ingroup core
* \class QgsPaintEffectMetadata
Expand Down Expand Up @@ -219,6 +218,9 @@ class CORE_EXPORT QgsPaintEffectRegistry
static bool isDefaultStack( QgsPaintEffect *effect );

private:
#ifdef SIP_RUN
QgsPaintEffectRegistry( const QgsPaintEffectRegistry &rh );
#endif

QMap<QString, QgsPaintEffectAbstractMetadata *> mMetadata;
};
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgis_sip.h
Expand Up @@ -91,6 +91,11 @@
*/
#define SIP_CONSTRAINED

/*
* http://pyqt.sourceforge.net/Docs/sip4/annotations.html?highlight=external#class-annotation-External
*/
#define SIP_EXTERNAL

/*
* discard line
*/
Expand Down

0 comments on commit f63adfe

Please sign in to comment.