Long live QT_TECH_PREVIEW_API
A macro to mark tech preview APIs, in order to make header reviews easier: * newly introduced TP APIs are clearly marked as such; * an API that leaves TP and becomes stable requires to change the header, and not just the documentation (and therefore will again appear in the header review). The idea is to use this macro as if it were a C++ attribute. It can't actually be an attribute, because we want to use it to tag e.g. macro expansions (like Q_PROPERTY). Change-Id: I05c5a91a4fa5bedfbd1c6146d4dc00e1d1d28628 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 32a1151245034e4d5d3162df21518e38b6f81fcd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
18d15404cb
commit
467749ce99
@ -72,4 +72,43 @@
|
|||||||
# define QT6_CALL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT6_CALL_NEW_OVERLOAD)
|
# define QT6_CALL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT6_CALL_NEW_OVERLOAD)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macro to tag Tech Preview APIs.
|
||||||
|
It expands to nothing, because we want to use it in places where
|
||||||
|
nothing is generally allowed (not even an attribute); for instance:
|
||||||
|
to tag other macros, Q_PROPERTY declarations, and so on.
|
||||||
|
|
||||||
|
Still: use it as if it were an C++ attribute.
|
||||||
|
|
||||||
|
To mark a class as TP:
|
||||||
|
class QT_TECH_PREVIEW_API Q_CORE_EXPORT QClass { ... };
|
||||||
|
|
||||||
|
To mark a function:
|
||||||
|
QT_TECH_PREVIEW_API void qFunction();
|
||||||
|
|
||||||
|
To mark an enumeration or enumerator:
|
||||||
|
enum class QT_TECH_PREVIEW_API QEnum {
|
||||||
|
Enum1,
|
||||||
|
Enum2 QT_TECH_PREVIEW_API,
|
||||||
|
};
|
||||||
|
|
||||||
|
To mark parts of a class:
|
||||||
|
class QClass : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
QT_TECH_PREVIEW_API
|
||||||
|
Q_PROPERTY(int countNG ...) // this is TP
|
||||||
|
|
||||||
|
Q_PROPERTY(int count ...) // this is stable API
|
||||||
|
|
||||||
|
public:
|
||||||
|
QT_TECH_PREVIEW_API
|
||||||
|
void f(); // TP
|
||||||
|
|
||||||
|
void g(); // stable
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
#define QT_TECH_PREVIEW_API
|
||||||
|
|
||||||
#endif /* QTVERSIONCHECKS_H */
|
#endif /* QTVERSIONCHECKS_H */
|
||||||
|
43
tests/auto/tools/moc/tech-preview.h
Normal file
43
tests/auto/tools/moc/tech-preview.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (C) 2024 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||||
|
|
||||||
|
#ifndef TECH_PREVIEW_H
|
||||||
|
#define TECH_PREVIEW_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class QT_TECH_PREVIEW_API MyTechPreviewObject : public QObject
|
||||||
|
{
|
||||||
|
QT_TECH_PREVIEW_API
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
QT_TECH_PREVIEW_API
|
||||||
|
Q_PROPERTY(int status MEMBER m_status)
|
||||||
|
|
||||||
|
int m_status = 0;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void myMethod() {}
|
||||||
|
QT_TECH_PREVIEW_API void myTPMethod() {}
|
||||||
|
|
||||||
|
Q_INVOKABLE QT_TECH_PREVIEW_API void myTPInvokable1() {}
|
||||||
|
QT_TECH_PREVIEW_API Q_INVOKABLE void myTPInvokable2() {}
|
||||||
|
|
||||||
|
enum class QT_TECH_PREVIEW_API MyTechPreviewEnum
|
||||||
|
{
|
||||||
|
A, B, C,
|
||||||
|
TP QT_TECH_PREVIEW_API,
|
||||||
|
X, Y, Z
|
||||||
|
};
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void mySignal();
|
||||||
|
QT_TECH_PREVIEW_API void myTPSignal();
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void mySlot() {}
|
||||||
|
QT_TECH_PREVIEW_API void myTPSlot() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // TECH_PREVIEW_H
|
@ -62,6 +62,8 @@
|
|||||||
|
|
||||||
#include "qmlmacro.h"
|
#include "qmlmacro.h"
|
||||||
|
|
||||||
|
#include "tech-preview.h"
|
||||||
|
|
||||||
using namespace Qt::StringLiterals;
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
#ifdef Q_MOC_RUN
|
#ifdef Q_MOC_RUN
|
||||||
|
Loading…
x
Reference in New Issue
Block a user