Skip to content
Permalink
Browse files
[sipify] Add support for abstract classes
  • Loading branch information
m-kuhn committed Apr 7, 2017
1 parent cd3528a commit cfeab26bd85f201d7439416c4e9f5de71a6c651b
Showing with 46 additions and 3 deletions.
  1. +2 −1 cmake_templates/Doxyfile.in
  2. +4 −1 scripts/sipify.pl
  3. +5 −0 src/core/qgis.h
  4. +13 −1 tests/scripts/sipifyheader.expected.sip
  5. +22 −0 tests/scripts/sipifyheader.h
@@ -1363,7 +1363,8 @@ EXPAND_AS_DEFINED = "SIP_TRANSFER" \
"SIP_CONVERT_TO_SUBCLASS_CODE" \
"SIP_FEATURE" \
"SIP_IF_FEATURE" \
"SIP_END"
"SIP_END" \
"SIP_ABSTRACT"

# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
# doxygen's preprocessor will remove all function-like macros that are alone
@@ -227,7 +227,7 @@ sub processDoxygenLine
}

# class declaration started
if ( $line =~ m/^(\s*class)\s*([A-Z]+_EXPORT)?\s+(\w+)(\s*\:.*)?$/ ){
if ( $line =~ m/^(\s*class)\s*([A-Z]+_EXPORT)?\s+(\w+)(\s*\:.*)?(\s*SIP_ABSTRACT)?$/ ){
do {no warnings 'uninitialized';
$classname = $3;
$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
$m =~ s/(\s*:)?\s*$//;
$line .= $m;
}
if ($5) {
$line .= ' /Abstract/';
}

$line .= "\n{\n";
if ( $comment !~ m/^\s*$/ ){
@@ -472,3 +472,8 @@ typedef unsigned long long qgssize;
* Will insert a `%End` directive in sip files
*/
#define SIP_END

/*
* Class level annotation for abstract classes
*/
#define SIP_ABSTRACT
@@ -201,8 +201,20 @@ A constructor with definition in header on several lines

}

QFlags<QgsSipifyHeader::MyEnum> operator|(QgsSipifyHeader::MyEnum f1, QFlags<QgsSipifyHeader::MyEnum> f2);
class AbstractClass /Abstract/

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Apr 7, 2017

Collaborator

@m-kuhn This commit broke the Q_DECLARE_OPERATORS_FOR_FLAGS handling (and removed the expected output from the test ;) )

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Apr 8, 2017

Author Member

Fortunately it only broke the test and not the flag - because the header file contained code that wouldn't compile anyway (missing ; after class definition).

{
%Docstring
Documentation goes here
%End

%TypeHeaderCode
#include "sipifyheader.h"
%End
public:
explicit AbstractClass();
%Docstring
A constructor
%End

/************************************************************************
* This file has been generated automatically from *
@@ -259,6 +259,28 @@ class CORE_EXPORT ClassWithPrivateInheritanceOnly : private QgsBaseClass

}

/**
* \class AbstractClass
* \ingroup core
* Documentation goes here
*/
class CORE_EXPORT AbstractClass SIP_ABSTRACT
{
public:
//! A constructor
explicit AbstractClass()
{
}

private:

/**
* This method should be overridden by subclasses but not exposed to the public
* or protected API.
*/
virtual QString reason() = 0;
}

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsSipifyHeader::Flags )


0 comments on commit cfeab26

Please sign in to comment.