moc: move some of the helpers into a header dedicated to it
Change-Id: Id0fb9ab0089845ee8843fffd16f9d080029f2f7f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
parent
a8ebadac59
commit
c23b595769
@ -141,7 +141,7 @@ qt_internal_add_module(Core
|
||||
kernel/qmetaobjectbuilder.cpp kernel/qmetaobjectbuilder_p.h
|
||||
kernel/qmetatype.cpp kernel/qmetatype.h kernel/qmetatype_p.h
|
||||
kernel/qmimedata.cpp kernel/qmimedata.h
|
||||
kernel/qtmetamacros.h
|
||||
kernel/qtmetamacros.h kernel/qtmochelpers.h
|
||||
kernel/qobject.cpp kernel/qobject.h kernel/qobject_p.h kernel/qobject_p_p.h
|
||||
kernel/qobject_impl.h
|
||||
kernel/qobjectcleanuphandler.cpp kernel/qobjectcleanuphandler.h
|
||||
|
@ -25,12 +25,6 @@
|
||||
# define QT_END_NAMESPACE
|
||||
# define QT_BEGIN_INCLUDE_NAMESPACE
|
||||
# define QT_END_INCLUDE_NAMESPACE
|
||||
#ifndef QT_BEGIN_MOC_NAMESPACE
|
||||
# define QT_BEGIN_MOC_NAMESPACE
|
||||
#endif
|
||||
#ifndef QT_END_MOC_NAMESPACE
|
||||
# define QT_END_MOC_NAMESPACE
|
||||
#endif
|
||||
# define QT_FORWARD_DECLARE_CLASS(name) class name;
|
||||
# define QT_FORWARD_DECLARE_STRUCT(name) struct name;
|
||||
|
||||
@ -42,12 +36,6 @@
|
||||
# define QT_END_NAMESPACE }
|
||||
# define QT_BEGIN_INCLUDE_NAMESPACE }
|
||||
# define QT_END_INCLUDE_NAMESPACE namespace QT_NAMESPACE {
|
||||
#ifndef QT_BEGIN_MOC_NAMESPACE
|
||||
# define QT_BEGIN_MOC_NAMESPACE QT_USE_NAMESPACE
|
||||
#endif
|
||||
#ifndef QT_END_MOC_NAMESPACE
|
||||
# define QT_END_MOC_NAMESPACE
|
||||
#endif
|
||||
# define QT_FORWARD_DECLARE_CLASS(name) \
|
||||
QT_BEGIN_NAMESPACE class name; QT_END_NAMESPACE \
|
||||
using QT_PREPEND_NAMESPACE(name);
|
||||
@ -82,6 +70,14 @@ namespace QT_NAMESPACE {}
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* ### Qt 6.9 (or later): remove *_MOC_* macros (moc does not need them since 6.5) */
|
||||
#ifndef QT_BEGIN_MOC_NAMESPACE
|
||||
# define QT_BEGIN_MOC_NAMESPACE QT_USE_NAMESPACE
|
||||
#endif
|
||||
#ifndef QT_END_MOC_NAMESPACE
|
||||
# define QT_END_MOC_NAMESPACE
|
||||
#endif
|
||||
|
||||
/* silence syncqt warning */
|
||||
QT_BEGIN_NAMESPACE
|
||||
QT_END_NAMESPACE
|
||||
|
32
src/corelib/kernel/qtmochelpers.h
Normal file
32
src/corelib/kernel/qtmochelpers.h
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright (C) 2022 Intel Corporation.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QTMOCHELPERS_H
|
||||
#define QTMOCHELPERS_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists to be used by the code that
|
||||
// moc generates. This file will not change quickly, but it over the long term,
|
||||
// it will likely change or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if 0
|
||||
#pragma qt_no_master_include
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace QtMocHelpers {
|
||||
|
||||
} // namespace QtMocHelpers
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
#endif // QTMOCHELPERS_H
|
@ -1091,6 +1091,16 @@ void Moc::generate(FILE *out, FILE *jsonOutput)
|
||||
for (const QByteArray &qtContainer : qtContainers)
|
||||
fprintf(out, "#include <QtCore/%s>\n", qtContainer.constData());
|
||||
|
||||
fprintf(out, "\n%s#include <QtCore/qtmochelpers.h>\n%s\n",
|
||||
#if QT_VERSION <= QT_VERSION_CHECK(6, 9, 0)
|
||||
"#if __has_include(<QtCore/qtmochelpers.h>)\n",
|
||||
"#else\n"
|
||||
"QT_BEGIN_MOC_NAMESPACE\n"
|
||||
"#endif\n"
|
||||
#else
|
||||
"", ""
|
||||
#endif
|
||||
);
|
||||
|
||||
fprintf(out, "#if !defined(Q_MOC_OUTPUT_REVISION)\n"
|
||||
"#error \"The header file '%s' doesn't include <QObject>.\"\n", fn.constData());
|
||||
@ -1107,7 +1117,6 @@ void Moc::generate(FILE *out, FILE *jsonOutput)
|
||||
"#endif\n\n");
|
||||
#endif
|
||||
|
||||
fprintf(out, "QT_BEGIN_MOC_NAMESPACE\n");
|
||||
fprintf(out, "QT_WARNING_PUSH\n");
|
||||
fprintf(out, "QT_WARNING_DISABLE_DEPRECATED\n");
|
||||
fprintf(out, "QT_WARNING_DISABLE_GCC(\"-Wuseless-cast\")\n");
|
||||
@ -1120,7 +1129,6 @@ void Moc::generate(FILE *out, FILE *jsonOutput)
|
||||
fputs("", out);
|
||||
|
||||
fprintf(out, "QT_WARNING_POP\n");
|
||||
fprintf(out, "QT_END_MOC_NAMESPACE\n");
|
||||
|
||||
if (jsonOutput) {
|
||||
QJsonObject mocData;
|
||||
|
Loading…
Reference in New Issue
Block a user