| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QCONSTRUCTORMACROS_H |
| 5 | #define QCONSTRUCTORMACROS_H |
| 6 | |
| 7 | #if 0 |
| 8 | #pragma qt_class(QtConstructorMacros) |
| 9 | #pragma qt_sync_stop_processing |
| 10 | #endif |
| 11 | |
| 12 | #if defined(__cplusplus) |
| 13 | |
| 14 | #ifndef Q_CONSTRUCTOR_FUNCTION |
| 15 | # define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \ |
| 16 | namespace { \ |
| 17 | static const struct AFUNC ## _ctor_class_ { \ |
| 18 | inline AFUNC ## _ctor_class_() { AFUNC(); } \ |
| 19 | } AFUNC ## _ctor_instance_; \ |
| 20 | } |
| 21 | |
| 22 | # define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC) |
| 23 | #endif |
| 24 | |
| 25 | #ifndef Q_DESTRUCTOR_FUNCTION |
| 26 | # define Q_DESTRUCTOR_FUNCTION0(AFUNC) \ |
| 27 | namespace { \ |
| 28 | static const struct AFUNC ## _dtor_class_ { \ |
| 29 | inline AFUNC ## _dtor_class_() { } \ |
| 30 | inline ~ AFUNC ## _dtor_class_() { AFUNC(); } \ |
| 31 | } AFUNC ## _dtor_instance_; \ |
| 32 | } |
| 33 | # define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC) |
| 34 | #endif |
| 35 | |
| 36 | #endif // __cplusplus |
| 37 | |
| 38 | #endif // QCONSTRUCTORMACROS_H |
| 39 | |