Skip to content

Commit cfeab26

Browse files
committedApr 7, 2017
[sipify] Add support for abstract classes
1 parent cd3528a commit cfeab26

File tree

5 files changed

+46
-3
lines changed

5 files changed

+46
-3
lines changed
 

‎cmake_templates/Doxyfile.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,8 @@ EXPAND_AS_DEFINED = "SIP_TRANSFER" \
13631363
"SIP_CONVERT_TO_SUBCLASS_CODE" \
13641364
"SIP_FEATURE" \
13651365
"SIP_IF_FEATURE" \
1366-
"SIP_END"
1366+
"SIP_END" \
1367+
"SIP_ABSTRACT"
13671368

13681369
# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
13691370
# doxygen's preprocessor will remove all function-like macros that are alone

‎scripts/sipify.pl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ sub processDoxygenLine
227227
}
228228

229229
# class declaration started
230-
if ( $line =~ m/^(\s*class)\s*([A-Z]+_EXPORT)?\s+(\w+)(\s*\:.*)?$/ ){
230+
if ( $line =~ m/^(\s*class)\s*([A-Z]+_EXPORT)?\s+(\w+)(\s*\:.*)?(\s*SIP_ABSTRACT)?$/ ){
231231
do {no warnings 'uninitialized';
232232
$classname = $3;
233233
$line =~ m/\b[A-Z]+_EXPORT\b/ or die "Class$classname in $headerfile should be exported with appropriate [LIB]_EXPORT macro. If this should not be available in python, wrap it in a `#ifndef SIP_RUN` block.";
@@ -241,6 +241,9 @@ sub processDoxygenLine
241241
$m =~ s/(\s*:)?\s*$//;
242242
$line .= $m;
243243
}
244+
if ($5) {
245+
$line .= ' /Abstract/';
246+
}
244247

245248
$line .= "\n{\n";
246249
if ( $comment !~ m/^\s*$/ ){

‎src/core/qgis.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,8 @@ typedef unsigned long long qgssize;
472472
* Will insert a `%End` directive in sip files
473473
*/
474474
#define SIP_END
475+
476+
/*
477+
* Class level annotation for abstract classes
478+
*/
479+
#define SIP_ABSTRACT

‎tests/scripts/sipifyheader.expected.sip

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,20 @@ A constructor with definition in header on several lines
201201

202202
}
203203

204-
QFlags<QgsSipifyHeader::MyEnum> operator|(QgsSipifyHeader::MyEnum f1, QFlags<QgsSipifyHeader::MyEnum> f2);
204+
class AbstractClass /Abstract/
Code has comments. Press enter to view.
205+
{
206+
%Docstring
207+
Documentation goes here
208+
%End
205209

210+
%TypeHeaderCode
211+
#include "sipifyheader.h"
212+
%End
213+
public:
214+
explicit AbstractClass();
215+
%Docstring
216+
A constructor
217+
%End
206218

207219
/************************************************************************
208220
* This file has been generated automatically from *

‎tests/scripts/sipifyheader.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,28 @@ class CORE_EXPORT ClassWithPrivateInheritanceOnly : private QgsBaseClass
259259

260260
}
261261

262+
/**
263+
* \class AbstractClass
264+
* \ingroup core
265+
* Documentation goes here
266+
*/
267+
class CORE_EXPORT AbstractClass SIP_ABSTRACT
268+
{
269+
public:
270+
//! A constructor
271+
explicit AbstractClass()
272+
{
273+
}
274+
275+
private:
276+
277+
/**
278+
* This method should be overridden by subclasses but not exposed to the public
279+
* or protected API.
280+
*/
281+
virtual QString reason() = 0;
282+
}
283+
262284
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsSipifyHeader::Flags )
263285

264286

0 commit comments

Comments
 (0)
Please sign in to comment.