diff options
Diffstat (limited to 'sources/shiboken6/tests/libsample/protected.h')
-rw-r--r-- | sources/shiboken6/tests/libsample/protected.h | 114 |
1 files changed, 51 insertions, 63 deletions
diff --git a/sources/shiboken6/tests/libsample/protected.h b/sources/shiboken6/tests/libsample/protected.h index 0f4fbf299..059cced5d 100644 --- a/sources/shiboken6/tests/libsample/protected.h +++ b/sources/shiboken6/tests/libsample/protected.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of Qt for Python. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef PROTECTED_H #define PROTECTED_H @@ -32,26 +7,30 @@ #include "libsamplemacros.h" #include "objecttype.h" #include "point.h" + #include <string> #include <list> class LIBSAMPLE_API ProtectedNonPolymorphic { public: + LIBMINIMAL_DEFAULT_COPY_MOVE(ProtectedNonPolymorphic) + explicit ProtectedNonPolymorphic(const char *name) : m_name(name) {} - ~ProtectedNonPolymorphic() {} + ~ProtectedNonPolymorphic() = default; - inline const char* publicName() { return m_name.c_str(); } + inline const char *publicName() { return m_name.c_str(); } - inline static ProtectedNonPolymorphic* create() { return new ProtectedNonPolymorphic("created"); } + inline static ProtectedNonPolymorphic *create() + { return new ProtectedNonPolymorphic("created"); } protected: - inline const char* protectedName() { return m_name.c_str(); } + inline const char *protectedName() { return m_name.c_str(); } inline int protectedSum(int a0, int a1) { return a0 + a1; } inline int modifiedProtectedSum(int a0, int a1) { return a0 + a1; } - inline static const char* protectedStatic() { return "protectedStatic"; } - inline const char* dataTypeName(void *data = nullptr) const { return "pointer"; } - inline const char* dataTypeName(int data) const { return "integer"; } + inline static const char *protectedStatic() { return "protectedStatic"; } + const char *dataTypeName(void *data = nullptr) const; + const char *dataTypeName(int data) const; private: std::string m_name; @@ -60,15 +39,18 @@ private: class LIBSAMPLE_API ProtectedPolymorphic { public: + LIBMINIMAL_DEFAULT_COPY_MOVE(ProtectedPolymorphic) + explicit ProtectedPolymorphic(const char *name) : m_name(name) {} - virtual ~ProtectedPolymorphic() {} + virtual ~ProtectedPolymorphic() = default; - inline static ProtectedPolymorphic* create() { return new ProtectedPolymorphic("created"); } - inline const char* publicName() { return m_name.c_str(); } - inline const char* callProtectedName() { return protectedName(); } + inline static ProtectedPolymorphic *create() + { return new ProtectedPolymorphic("created"); } + inline const char *publicName() { return m_name.c_str(); } + inline const char *callProtectedName() { return protectedName(); } protected: - virtual const char* protectedName() { return m_name.c_str(); } + virtual const char *protectedName() { return m_name.c_str(); } private: std::string m_name; @@ -77,22 +59,29 @@ private: class LIBSAMPLE_API ProtectedPolymorphicDaughter : public ProtectedPolymorphic { public: - explicit ProtectedPolymorphicDaughter(const char *name) : ProtectedPolymorphic(name) {} - inline static ProtectedPolymorphicDaughter* create() { return new ProtectedPolymorphicDaughter("created"); } + explicit ProtectedPolymorphicDaughter(const char *name) : + ProtectedPolymorphic(name) {} + inline static ProtectedPolymorphicDaughter *create() + { return new ProtectedPolymorphicDaughter("created"); } }; class LIBSAMPLE_API ProtectedPolymorphicGrandDaughter: public ProtectedPolymorphicDaughter { public: - explicit ProtectedPolymorphicGrandDaughter(const char *name) : ProtectedPolymorphicDaughter(name) {} - inline static ProtectedPolymorphicGrandDaughter* create() { return new ProtectedPolymorphicGrandDaughter("created"); } + explicit ProtectedPolymorphicGrandDaughter(const char *name) : + ProtectedPolymorphicDaughter(name) {} + inline static ProtectedPolymorphicGrandDaughter *create() + { return new ProtectedPolymorphicGrandDaughter("created"); } }; class LIBSAMPLE_API ProtectedVirtualDestructor { public: - ProtectedVirtualDestructor() {} - inline static ProtectedVirtualDestructor* create() { return new ProtectedVirtualDestructor(); } + LIBMINIMAL_DISABLE_COPY_MOVE(ProtectedVirtualDestructor) + + ProtectedVirtualDestructor() noexcept = default; + inline static ProtectedVirtualDestructor *create() + { return new ProtectedVirtualDestructor(); } inline static int dtorCalled() { return dtor_called; } inline static void resetDtorCounter() { dtor_called = 0; } protected: @@ -104,8 +93,10 @@ private: class LIBSAMPLE_API ProtectedEnumClass { public: - ProtectedEnumClass() {} - virtual ~ProtectedEnumClass() {} + LIBMINIMAL_DISABLE_COPY_MOVE(ProtectedEnumClass) + + ProtectedEnumClass() noexcept = default; + virtual ~ProtectedEnumClass() = default; enum PublicEnum { PublicItem0, PublicItem1 @@ -115,36 +106,33 @@ protected: ProtectedItem0, ProtectedItem1 }; - ProtectedEnum callProtectedEnumMethod(ProtectedEnum in) { return protectedEnumMethod(in); } - inline PublicEnum callPublicEnumMethod(PublicEnum in) { return publicEnumMethod(in); } + ProtectedEnum callProtectedEnumMethod(ProtectedEnum in) + { return protectedEnumMethod(in); } + inline PublicEnum callPublicEnumMethod(PublicEnum in) + { return publicEnumMethod(in); } virtual ProtectedEnum protectedEnumMethod(ProtectedEnum in) { return in; } virtual PublicEnum publicEnumMethod(PublicEnum in) { return in; } }; - class LIBSAMPLE_API ProtectedProperty { public: - ProtectedProperty() - : protectedValueTypeProperty(Point(0, 0)), - protectedProperty(0), - protectedEnumProperty(Event::NO_EVENT), - protectedValueTypePointerProperty(nullptr), - protectedObjectTypeProperty(nullptr) - {} + ProtectedProperty() = default; + protected: // This is deliberately the first member to test wrapper registration // for value type members sharing the same memory address. - Point protectedValueTypeProperty; - int protectedProperty; + Point protectedValueTypeProperty{0, 0}; + int protectedProperty = 0; std::list<int> protectedContainerProperty; - Event::EventType protectedEnumProperty; - Point* protectedValueTypePointerProperty; - ObjectType* protectedObjectTypeProperty; + Event::EventType protectedEnumProperty = Event::NO_EVENT; + Point *protectedValueTypePointerProperty = nullptr; + ObjectType *protectedObjectTypeProperty = nullptr; }; -LIBSAMPLE_API inline ProtectedProperty* createProtectedProperty() { +LIBSAMPLE_API inline ProtectedProperty *createProtectedProperty() +{ return new ProtectedProperty; } |