| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the test suite of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 21 | ** included in the packaging of this file. Please review the following |
| 22 | ** information to ensure the GNU General Public License requirements will |
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 24 | ** |
| 25 | ** $QT_END_LICENSE$ |
| 26 | ** |
| 27 | ****************************************************************************/ |
| 28 | #include "testtypes.h" |
| 29 | #include <QtQml/qqml.h> |
| 30 | |
| 31 | SelfRegisteringType *SelfRegisteringType::m_me = nullptr; |
| 32 | SelfRegisteringType::SelfRegisteringType() |
| 33 | : m_v(0) |
| 34 | { |
| 35 | m_me = this; |
| 36 | } |
| 37 | |
| 38 | SelfRegisteringType *SelfRegisteringType::me() |
| 39 | { |
| 40 | return m_me; |
| 41 | } |
| 42 | |
| 43 | void SelfRegisteringType::clearMe() |
| 44 | { |
| 45 | m_me = nullptr; |
| 46 | } |
| 47 | |
| 48 | SelfRegisteringOuterType *SelfRegisteringOuterType::m_me = nullptr; |
| 49 | bool SelfRegisteringOuterType::beenDeleted = false; |
| 50 | SelfRegisteringOuterType::SelfRegisteringOuterType() |
| 51 | : m_v(nullptr) |
| 52 | { |
| 53 | m_me = this; |
| 54 | beenDeleted = false; |
| 55 | } |
| 56 | |
| 57 | SelfRegisteringOuterType::~SelfRegisteringOuterType() |
| 58 | { |
| 59 | beenDeleted = true; |
| 60 | } |
| 61 | |
| 62 | SelfRegisteringOuterType *SelfRegisteringOuterType::me() |
| 63 | { |
| 64 | return m_me; |
| 65 | } |
| 66 | |
| 67 | CompletionRegisteringType *CompletionRegisteringType::m_me = nullptr; |
| 68 | CompletionRegisteringType::CompletionRegisteringType() |
| 69 | { |
| 70 | } |
| 71 | |
| 72 | void CompletionRegisteringType::classBegin() |
| 73 | { |
| 74 | } |
| 75 | |
| 76 | void CompletionRegisteringType::componentComplete() |
| 77 | { |
| 78 | m_me = this; |
| 79 | } |
| 80 | |
| 81 | CompletionRegisteringType *CompletionRegisteringType::me() |
| 82 | { |
| 83 | return m_me; |
| 84 | } |
| 85 | |
| 86 | void CompletionRegisteringType::clearMe() |
| 87 | { |
| 88 | m_me = nullptr; |
| 89 | } |
| 90 | |
| 91 | CallbackRegisteringType::callback CallbackRegisteringType::m_callback = nullptr; |
| 92 | void *CallbackRegisteringType::m_data = nullptr; |
| 93 | CallbackRegisteringType::CallbackRegisteringType() |
| 94 | : m_v(0) |
| 95 | { |
| 96 | } |
| 97 | |
| 98 | void CallbackRegisteringType::clearCallback() |
| 99 | { |
| 100 | m_callback = nullptr; |
| 101 | m_data = nullptr; |
| 102 | } |
| 103 | |
| 104 | void CallbackRegisteringType::registerCallback(callback c, void *d) |
| 105 | { |
| 106 | m_callback = c; |
| 107 | m_data = d; |
| 108 | } |
| 109 | |
| 110 | CompletionCallbackType::callback CompletionCallbackType::m_callback = nullptr; |
| 111 | void *CompletionCallbackType::m_data = nullptr; |
| 112 | CompletionCallbackType::CompletionCallbackType() |
| 113 | { |
| 114 | } |
| 115 | |
| 116 | void CompletionCallbackType::classBegin() |
| 117 | { |
| 118 | } |
| 119 | |
| 120 | void CompletionCallbackType::componentComplete() |
| 121 | { |
| 122 | if (m_callback) m_callback(this, m_data); |
| 123 | } |
| 124 | |
| 125 | void CompletionCallbackType::clearCallback() |
| 126 | { |
| 127 | m_callback = nullptr; |
| 128 | m_data = nullptr; |
| 129 | } |
| 130 | |
| 131 | void CompletionCallbackType::registerCallback(callback c, void *d) |
| 132 | { |
| 133 | m_callback = c; |
| 134 | m_data = d; |
| 135 | } |
| 136 | |
| 137 | void registerTypes() |
| 138 | { |
| 139 | qmlRegisterType<SelfRegisteringType>(uri: "Qt.test" , versionMajor: 1,versionMinor: 0, qmlName: "SelfRegistering" ); |
| 140 | qmlRegisterType<SelfRegisteringOuterType>(uri: "Qt.test" , versionMajor: 1,versionMinor: 0, qmlName: "SelfRegisteringOuter" ); |
| 141 | qmlRegisterType<CompletionRegisteringType>(uri: "Qt.test" , versionMajor: 1,versionMinor: 0, qmlName: "CompletionRegistering" ); |
| 142 | qmlRegisterType<CallbackRegisteringType>(uri: "Qt.test" , versionMajor: 1,versionMinor: 0, qmlName: "CallbackRegistering" ); |
| 143 | qmlRegisterType<CompletionCallbackType>(uri: "Qt.test" , versionMajor: 1,versionMinor: 0, qmlName: "CompletionCallback" ); |
| 144 | } |
| 145 | |