diff options
author | Stephen Kelly <steveire@gmail.com> | 2017-01-14 22:13:49 +0000 |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2017-01-15 11:18:50 +0000 |
commit | 636d6acc7adf8bf7169d38833340161dc42d3484 (patch) | |
tree | 2ff1bbefa5808aec21e902b10c9547e359067604 /tests/GenerateSipBindings/cpplib.cpp | |
parent | 8c347c61abafa68e247ff4664ae658cfa15af932 (diff) | |
download | extra-cmake-modules-636d6acc7adf8bf7169d38833340161dc42d3484.tar.gz extra-cmake-modules-636d6acc7adf8bf7169d38833340161dc42d3484.tar.bz2 |
Bindings: Fix handling of forward declarations
It is not appropriate to decorate each forward declaration with the SIP
attribute /External/. That is only needed for forward declarations of
types which are defined in a different module.
Local forward declarations can be omitted from the sip code. In sip
code, a forward declaration followed later by a full class definition is
an error.
Omit forward declarations unless they are decorated with the external
attribute. Introduce a rules database for consumers to decorate them
with the attribute as required.
Diffstat (limited to 'tests/GenerateSipBindings/cpplib.cpp')
-rw-r--r-- | tests/GenerateSipBindings/cpplib.cpp | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/tests/GenerateSipBindings/cpplib.cpp b/tests/GenerateSipBindings/cpplib.cpp index 8dc7492b..524a0936 100644 --- a/tests/GenerateSipBindings/cpplib.cpp +++ b/tests/GenerateSipBindings/cpplib.cpp @@ -1,6 +1,8 @@ #include "cpplib.h" +#include "external_lib.h" + MyObject::MyObject(QObject* parent) : QObject(parent) { @@ -65,19 +67,21 @@ int MyObject::groups(unsigned int maxCount) const return maxCount; } -class FwdDecl +int MyObject::externalFwdDecl(const ExternalFwdDecl& f) { + return f.getValue(); +} -}; - -int MyObject::fwdDecl(const FwdDecl&) +int MyObject::externalFwdDeclRef(ExternalFwdDecl& f) { - return 42; + return f.getValue(); } -int MyObject::fwdDeclRef(FwdDecl&) +int MyObject::localDeclListDecl(const QList<LocalFwdDecl>& l) { - return 42; + return std::accumulate(l.begin(), l.end(), 0, [](int current, LocalFwdDecl const& next){ + return current + next.getValue(); + }); } int MyObject::const_parameters(const int input, QObject* const obj) const @@ -86,6 +90,28 @@ int MyObject::const_parameters(const int input, QObject* const obj) const return input / 2; } +int MyObject::localFwdDecl(const LocalFwdDecl& f) +{ + return f.getValue(); +} + +int MyObject::localListDecl(const QList<int>& l) +{ + return std::accumulate(l.begin(), l.end(), 0); +} + +LocalFwdDecl::LocalFwdDecl(int value) + : m_value(value) +{ + +} + +int LocalFwdDecl::getValue() const +{ + return m_value; +} + + NonCopyable::NonCopyable() : mNum(new int(42)) { |