qt 6.5.1 original

This commit is contained in:
kleuter
2023-10-29 23:33:08 +01:00
parent 71d22ab6b0
commit 85d238dfda
21202 changed files with 5499099 additions and 0 deletions

View File

@ -0,0 +1,30 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# QTBUG-88538
if(NOT ANDROID AND NOT IOS)
add_subdirectory(qmakelib)
if(QT_FEATURE_qmake)
add_subdirectory(qmake)
endif()
add_subdirectory(moc)
add_subdirectory(rcc)
endif()
# QTBUG-88538
if(TARGET Qt::Widgets AND NOT ANDROID AND NOT IOS)
add_subdirectory(uic)
endif()
if(TARGET Qt::DBus)
add_subdirectory(qdbuscpp2xml)
add_subdirectory(qdbusxml2cpp)
endif()
if(TARGET Qt::Gui AND QT_FEATURE_process AND NOT CMAKE_CROSSCOMPILING)
# testapp (windeployqt) and source_basicapp (macdeployqt) require QtGui.
if(QT_FEATURE_macdeployqt)
add_subdirectory(macdeployqt)
endif()
if(QT_FEATURE_windeployqt AND BUILD_SHARED_LIBS)
# windeployqt does not work with static Qt builds. See QTBUG-69427.
add_subdirectory(windeployqt)
endif()
endif()

View File

@ -0,0 +1,11 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_macdeployqt Test:
#####################################################################
qt_internal_add_test(tst_macdeployqt
SOURCES
tst_macdeployqt.cpp
)

View File

@ -0,0 +1 @@
SOURCES = main.cpp

View File

@ -0,0 +1,19 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QGuiApplication>
#include <QRasterWindow>
#include <QScreen>
#include <QTimer>
// Simple test application just to verify that it comes up properly
int main(int argc, char ** argv)
{
QGuiApplication app(argc, argv);
QRasterWindow w;
w.setTitle("macdeployqt test application");
w.show();
QTimer::singleShot(200, &w, &QCoreApplication::quit);
return app.exec();
}

View File

@ -0,0 +1,11 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QtSql>
int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
return db.isValid() ? 0 : 1;
}

View File

@ -0,0 +1,2 @@
SOURCES = main.cpp
QT += sql

View File

@ -0,0 +1,10 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QtNetwork>
int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
return QSslSocket::supportsSsl() ? 0 : 1;
}

View File

@ -0,0 +1,2 @@
SOURCES = main.cpp
QT += network

View File

@ -0,0 +1,291 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QtCore>
#include <QtTest>
bool g_testDirectoryBuild = false; // toggle to keep build output for debugging.
QTemporaryDir *g_temporaryDirectory;
QString g_macdeployqtBinary;
QString g_qmakeBinary;
QString g_makeBinary;
QString g_installNameToolBinary;
#if QT_CONFIG(process)
static const QString msgProcessError(const QProcess &process, const QString &what)
{
QString result;
QTextStream(&result) << what << ": \"" << process.program() << ' '
<< process.arguments().join(QLatin1Char(' ')) << "\": " << process.errorString();
return result;
}
static bool runProcess(const QString &binary,
const QStringList &arguments,
QString *errorMessage,
const QString &workingDir = QString(),
const QProcessEnvironment &env = QProcessEnvironment(),
int timeOut = 10000,
QByteArray *stdOut = nullptr, QByteArray *stdErr = nullptr)
{
QProcess process;
if (!env.isEmpty())
process.setProcessEnvironment(env);
if (!workingDir.isEmpty())
process.setWorkingDirectory(workingDir);
process.start(binary, arguments, QIODevice::ReadOnly);
if (!process.waitForStarted()) {
*errorMessage = msgProcessError(process, "Failed to start");
return false;
}
if (!process.waitForFinished(timeOut)) {
*errorMessage = msgProcessError(process, "Timed out");
process.terminate();
if (!process.waitForFinished(300))
process.kill();
return false;
}
if (stdOut)
*stdOut = process.readAllStandardOutput();
if (stdErr)
*stdErr= process.readAllStandardError();
if (process.exitStatus() != QProcess::NormalExit) {
*errorMessage = msgProcessError(process, "Crashed");
return false;
}
if (process.exitCode() != QProcess::NormalExit) {
*errorMessage = msgProcessError(process, "Exit code " + QString::number(process.exitCode()));
return false;
}
return true;
}
#else
static bool runProcess(const QString &binary,
const QStringList &arguments,
QString *arguments,
const QString &workingDir = QString(),
const QProcessEnvironment &env = QProcessEnvironment(),
int timeOut = 5000,
QByteArray *stdOut = Q_NULLPTR, QByteArray *stdErr = Q_NULLPTR)
{
Q_UNUSED(binary);
Q_UNUSED(arguments);
Q_UNUSED(arguments);
Q_UNUSED(workingDir);
Q_UNUSED(env);
Q_UNUSED(timeOut);
Q_UNUSED(stdOut);
Q_UNUSED(stdErr);
return false;
}
#endif
QString sourcePath(const QString &name)
{
return "source_" + name;
}
QString buildPath(const QString &name)
{
if (g_testDirectoryBuild)
return "build_" + name;
return g_temporaryDirectory->path() + "/build_" + name;
}
bool qmake(const QString &source, const QString &destination, QString *errorMessage)
{
QStringList args = QStringList() << source;
return runProcess(g_qmakeBinary, args, errorMessage, destination);
}
bool make(const QString &destination, QString *errorMessage)
{
QStringList args;
return runProcess(g_makeBinary, args, errorMessage, destination,
{}, 60000);
}
void build(const QString &name)
{
// Build the app or framework according to the convention used
// by this test:
// source_name (source code)
// build_name (build artifacts)
QString source = sourcePath(name);
QString build = buildPath(name);
QString profile = name + ".pro";
QString sourcePath = QFINDTESTDATA(source);
QVERIFY(!sourcePath.isEmpty());
// Clear/set up build dir
QString buildPath = build;
QVERIFY(QDir(buildPath).removeRecursively());
QVERIFY(QDir().mkdir(buildPath));
QVERIFY(QDir(buildPath).exists());
// Build application
QString sourceProFile = QDir(sourcePath).canonicalPath() + '/' + profile;
QString errorMessage;
QVERIFY2(qmake(sourceProFile, buildPath, &errorMessage), qPrintable(errorMessage));
QVERIFY2(make(buildPath, &errorMessage), qPrintable(errorMessage));
}
bool changeInstallName(const QString &path, const QString &binary, const QString &from, const QString &to)
{
QStringList args = QStringList() << binary << "-change" << from << to;
QString errorMessage;
return runProcess(g_installNameToolBinary, args, &errorMessage, path);
}
bool deploy(const QString &name, const QStringList &options, QString *errorMessage)
{
QString bundle = name + ".app";
QString path = buildPath(name);
QStringList args = QStringList() << bundle << options;
return runProcess(g_macdeployqtBinary, args, errorMessage, path);
}
bool debugDeploy(const QString &name, const QStringList &options, QString *errorMessage)
{
QString bundle = name + ".app";
QString path = buildPath(name);
QStringList args = QStringList() << bundle << options << "-verbose=3";
QByteArray stdOut;
QByteArray stdErr;
bool exitOK = runProcess(g_macdeployqtBinary, args, errorMessage, path, QProcessEnvironment(),
10000, &stdOut, &stdErr);
qDebug() << "macdeployqt exit OK" << exitOK;
qDebug() << qPrintable(stdOut);
qDebug() << qPrintable(stdErr);
return exitOK;
}
bool run(const QString &name, QString *errorMessage)
{
QString path = buildPath(name);
QStringList args;
QString binary = name + ".app/Contents/MacOS/" + name;
return runProcess(binary, args, errorMessage, path);
}
bool runPrintLibraries(const QString &name, QString *errorMessage, QByteArray *stdErr)
{
QString binary = name + ".app/Contents/MacOS/" + name;
QString path = buildPath(name);
QStringList args;
QProcessEnvironment env = QProcessEnvironment();
env.insert("DYLD_PRINT_LIBRARIES", "true");
QByteArray stdOut;
return runProcess(binary, args, errorMessage, path, env, 5000, &stdOut, stdErr);
}
void runVerifyDeployment(const QString &name)
{
QString errorMessage;
// Verify that the application runs after deployment and that it loads binaries from
// the application bundle only.
QByteArray libraries;
QVERIFY2(runPrintLibraries(name, &errorMessage, &libraries), qPrintable(errorMessage));
const QList<QString> parts = QString::fromLocal8Bit(libraries).split("dyld: loaded:");
const QString qtPath = QLibraryInfo::path(QLibraryInfo::PrefixPath);
// Let assume Qt is not installed in system
foreach (QString part, parts) {
part = part.trimmed();
if (part.isEmpty())
continue;
QVERIFY(!parts.startsWith(qtPath));
}
}
class tst_macdeployqt : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void basicapp();
void plugins_data();
void plugins();
};
void tst_macdeployqt::initTestCase()
{
#ifdef QT_NO_PROCESS
QSKIP("This test requires QProcess support");
#endif
// Set up test-global unique temporary directory
g_temporaryDirectory = new QTemporaryDir();
QVERIFY(g_temporaryDirectory->isValid());
// Locate build and deployment tools
g_macdeployqtBinary = QLibraryInfo::path(QLibraryInfo::BinariesPath) + "/macdeployqt";
QVERIFY(!g_macdeployqtBinary.isEmpty());
g_qmakeBinary = QLibraryInfo::path(QLibraryInfo::BinariesPath) + "/qmake";
QVERIFY(!g_qmakeBinary.isEmpty());
g_makeBinary = QStandardPaths::findExecutable("make");
QVERIFY(!g_makeBinary.isEmpty());
g_installNameToolBinary = QStandardPaths::findExecutable("install_name_tool");
QVERIFY(!g_installNameToolBinary.isEmpty());
}
void tst_macdeployqt::cleanupTestCase()
{
delete g_temporaryDirectory;
}
// Verify that deployment of a basic Qt Gui application works
void tst_macdeployqt::basicapp()
{
#ifdef QT_NO_PROCESS
QSKIP("This test requires QProcess support");
#endif
QString errorMessage;
QString name = "basicapp";
// Build and verify that the application runs before deployment
build(name);
QVERIFY2(run(name, &errorMessage), qPrintable(errorMessage));
// Deploy application
QVERIFY2(deploy(name, QStringList(), &errorMessage), qPrintable(errorMessage));
// Verify deployment
runVerifyDeployment(name);
}
void tst_macdeployqt::plugins_data()
{
QTest::addColumn<QString>("name");
QTest::newRow("sqlite") << "plugin_sqlite";
QTest::newRow("tls") << "plugin_tls";
}
void tst_macdeployqt::plugins()
{
QFETCH(QString, name);
build(name);
// Verify that the test app runs before deployment.
QString errorMessage;
if (!run(name, &errorMessage)) {
qDebug() << qPrintable(errorMessage);
QSKIP("Could not run test application before deployment");
}
QVERIFY2(deploy(name, QStringList(), &errorMessage), qPrintable(errorMessage));
runVerifyDeployment(name);
}
QTEST_MAIN(tst_macdeployqt)
#include "tst_macdeployqt.moc"

View File

@ -0,0 +1,153 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_moc Test:
#####################################################################
set(JSON_HEADERS
backslash-newlines.h
c-comments.h
cstyle-enums.h
cxx11-enums.h
cxx11-explicit-override-control.h
cxx11-final-classes.h
cxx11-trailing-return.h
cxx17-namespaces.h
dir-in-include-path.h
escapes-in-string-literals.h
enum_with_include.h
forward-declared-param.h
function-with-attributes.h
gadgetwithnoenums.h
grand-parent-gadget-class.h
moc_include.h
namespace.h
namespaced-flags.h
no-keywords.h
non-gadget-parent-class.h
oldstyle-casts.h
parse-defines.h
plugin_metadata.h
pointery_to_incomplete.h
pure-virtual-signals.h
qinvokable.h
qprivateslots.h
qtbug-35657-gadget.h
related-metaobjects-in-gadget.h
related-metaobjects-in-namespaces.h
related-metaobjects-name-conflict.h
signal-with-default-arg.h
single-quote-digit-separator-n3781.h
single_function_keyword.h
slots-with-void-template.h
task192552.h
task234909.h
task240368.h
task87883.h
trigraphs.h
using-namespaces.h
)
qt_wrap_cpp(comparison_relevant_moc_list ${JSON_HEADERS}
TARGET tst_moc
OPTIONS
"-Muri=com.company.app"
"-Muri=com.company.app.private"
"-DDEFINE_CMDLINE_EMPTY="
"-DDEFINE_CMDLINE_SIGNAL=void cmdlineSignal(const QMap<int, int> &i)"
"--output-json"
)
list(TRANSFORM comparison_relevant_moc_list APPEND ".json" OUTPUT_VARIABLE moc_json_files)
qt_internal_add_test(tst_moc
SOURCES
cxx-attributes.h
tst_moc.cpp
${comparison_relevant_moc_list}
INCLUDE_DIRECTORIES
testproject
testproject/include
MOC_OPTIONS
"-Muri=com.company.app"
"-Muri=com.company.app.private"
"-DDEFINE_CMDLINE_EMPTY="
"-DDEFINE_CMDLINE_SIGNAL=void cmdlineSignal(const QMap<int, int> &i)"
"--output-json"
EXCEPTIONS
)
qt_internal_extend_target(tst_moc LIBRARIES Qt::CorePrivate)
qt_internal_extend_target(tst_moc CONDITION CMAKE_CROSSCOMPILING
DEFINES
MOC_CROSS_COMPILED
)
if (UNIX AND (CLANG OR GCC OR QCC))
qt_wrap_cpp(os9_moc os9-newlines.h)
endif()
qt_internal_extend_target(tst_moc CONDITION UNIX AND (CLANG OR GCC OR QCC)
SOURCES
os9-newlines.h
win-newlines.h
${os9_moc}
)
qt_internal_extend_target(tst_moc CONDITION CLANG OR GCC
SOURCES
dollars.h
)
qt_internal_extend_target(tst_moc CONDITION TARGET Qt::DBus
LIBRARIES
Qt::DBus
)
qt_internal_extend_target(tst_moc CONDITION TARGET Qt::Concurrent
LIBRARIES
Qt::Concurrent
)
qt_internal_extend_target(tst_moc CONDITION TARGET Qt::Network
LIBRARIES
Qt::Network
)
qt_internal_extend_target(tst_moc CONDITION TARGET Qt::Sql
LIBRARIES
Qt::Sql
)
get_target_property(target_binary_dir tst_moc BINARY_DIR)
set(cmake_autogen_cache_file
"${target_binary_dir}/CMakeFiles/tst_moc_autogen.dir/ParseCache.txt")
set(cmake_autogen_info_file
"${target_binary_dir}/CMakeFiles/tst_moc_autogen.dir/AutogenInfo.json")
set(moc_json_out ${target_binary_dir}/moc_json_out)
file(REMOVE ${moc_json_out})
foreach(filename ${moc_json_files})
file(APPEND ${moc_json_out} "${filename}\n")
endforeach()
set(metatype_file "allmocs.json")
configure_file("allmocs_baseline_in.json" "${target_binary_dir}/allmocs_baseline.json")
add_custom_command(TARGET tst_moc
POST_BUILD
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::moc
-o "allmocs.json"
--collect-json "@${moc_json_out}"
COMMENT "Running moc with --collect-json"
VERBATIM
)
# Add dependencies that are implicitly used inside the test
add_dependencies(tst_moc
Qt::qtpaths
Qt::moc
)

View File

@ -0,0 +1,6 @@
#include <QtCore/qobject.h>
class Object : public QObject
{
Q_OBJECT
};

View File

@ -0,0 +1,17 @@
// 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 TESTINTERFACE_H
#define TESTINTERFACE_H
#include <QtCore/qobject.h>
struct TestInterface
{
inline virtual ~TestInterface() {}
virtual void foobar() = 0;
};
Q_DECLARE_INTERFACE(TestInterface, "foo.bar/1.0")
#endif // TESTINTERFACE_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,18 @@
// 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 ASSIGN_NAMESPACE_H
#define ASSIGN_NAMESPACE_H
namespace A
{
namespace Nested
{
namespace Space {}
}
}
namespace Mine = Qt;
namespace Theirs = A::Nested::Space;
#endif // ASSIGN_NAMESPACE_H

View File

@ -0,0 +1,36 @@
// 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 BACKSLASH_NEWLINES_H
#define BACKSLASH_NEWLINES_H
#include <QObject>
const int blackslashNewlinesDummy = 0
#define value 0\
1
;
class BackslashNewlines : public QObject
{
Q_OBJECT
public slots:
#if value
void works() {}
#else
void buggy() {}
#endif
};
#undef value
#endif // BACKSLASH_NEWLINES_H
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wcomment")
// ends with \\\r should not make moc crash (QTBUG-53441) (no new lines on purpose!!) \
QT_WARNING_POP

View File

@ -0,0 +1,21 @@
// 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 C_COMMENTS_H
#define C_COMMENTS_H
#include <qobject.h>
/* test support for multi-line comments in preprocessor statements */
#if 0 /* comment starts here
ends here */ || defined(Q_MOC_RUN) || 1
class IfdefedClass : public QObject
{
Q_OBJECT
public:
inline IfdefedClass() {}
};
#endif
#endif // C_COMMENTS_H

View File

@ -0,0 +1,18 @@
// 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 CSTYLE_ENUMS_H
#define CSTYLE_ENUMS_H
#include <QObject>
class CStyleEnums
{
Q_GADGET
public:
typedef enum { Foo, Bar } Baz;
typedef enum { Foo2, Bar2 } Baz2;
Q_ENUM(Baz)
Q_ENUMS(Baz2)
};
#endif // CSTYLE_ENUMS_H

View File

@ -0,0 +1,89 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef CXXATTRIBUTE_H
#define CXXATTRIBUTE_H
#include <QtCore/QObject>
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunknown-attributes")
QT_WARNING_DISABLE_GCC("-Wattributes")
class [[deprecated]] CppAttribute : public QObject
{
Q_OBJECT
signals:
[[deprecated]] void deprecatedSignal();
public slots:
[[deprecated]] void deprecatedSlot() {}
[[deprecated]] [[tst_moc::maybe_unused]] int deprecatedSlot2() { return 42; }
[[deprecated("reason")]] void deprecatedReason() {}
[[deprecated("reason[")]] void deprecatedReasonWithLBRACK() {}
[[deprecated("reason[[")]] void deprecatedReasonWith2LBRACK() {}
[[deprecated("reason]")]] void deprecatedReasonWithRBRACK() {}
[[deprecated("reason]]")]] void deprecatedReasonWith2RBRACK() {}
void slotWithArguments([[tst_moc::maybe_unused]] int) {}
#if !defined(_MSC_VER) || _MSC_VER >= 1912
// On MSVC it causes:
// moc_cxx-attributes.cpp(133): fatal error C1001: An internal error has occurred in the compiler.
Q_INVOKABLE [[tst_moc::noreturn]] void noreturnSlot() { throw "unused"; }
[[tst_moc::noreturn]] Q_SCRIPTABLE void noreturnSlot2() { throw "unused"; }
[[deprecated]] int returnInt() { return 0; }
Q_SLOT [[tst_moc::noreturn]] [[deprecated]] void noreturnDeprecatedSlot() { throw "unused"; }
Q_INVOKABLE void noreturnSlot3() [[tst_moc::noreturn]] { throw "unused"; }
#endif
};
QT_WARNING_POP
#ifdef Q_MOC_RUN
# define TEST_COMPILER_DEPRECATION [[deprecated]]
# define TEST_COMPILER_DEPRECATION_X(x) [[deprecated(x)]]
#else
# define TEST_COMPILER_DEPRECATION Q_DECL_ENUMERATOR_DEPRECATED
# define TEST_COMPILER_DEPRECATION_X(x) Q_DECL_ENUMERATOR_DEPRECATED_X(x)
#endif
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
namespace TestQNamespaceDeprecated {
Q_NAMESPACE
enum class TestEnum1 {
Key1 = 11,
Key2 TEST_COMPILER_DEPRECATION,
Key3 TEST_COMPILER_DEPRECATION_X("reason"),
Key4 TEST_COMPILER_DEPRECATION_X("reason["),
Key5 TEST_COMPILER_DEPRECATION_X("reason[["),
Key6 TEST_COMPILER_DEPRECATION_X("reason]"),
Key7 TEST_COMPILER_DEPRECATION_X("reason]]"),
};
Q_ENUM_NS(TestEnum1)
// try to dizzy moc by adding a struct in between
struct TestGadget {
Q_GADGET
public:
enum class TestGEnum1 {
Key1 = 13,
Key2 TEST_COMPILER_DEPRECATION,
Key3 TEST_COMPILER_DEPRECATION_X("reason")
};
Q_ENUM(TestGEnum1)
};
enum class TestFlag1 {
None = 0,
Flag1 = 1,
Flag2 TEST_COMPILER_DEPRECATION = 2,
Flag3 TEST_COMPILER_DEPRECATION_X("reason") = 3,
Any = Flag1 | Flag2 | Flag3
};
Q_FLAG_NS(TestFlag1)
}
QT_WARNING_POP
#endif // CXXATTRIBUTE_H

View File

@ -0,0 +1,50 @@
// Copyright (C) 2011 Olivier Goffart.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef CXX11_ENUMS_H
#define CXX11_ENUMS_H
#include <QtCore/QObject>
class CXX11Enums
{
Q_GADGET
public:
enum class EnumClass { A0, A1, A2, A3 };
enum TypedEnum : char { B0, B1 , B2, B3 };
enum class TypedEnumClass : char { C0, C1, C2, C3 };
enum NormalEnum { D2 = 2, D3, D0 =0 , D1 };
enum class ClassFlag { F0 = 1, F1 = 2, F2 = 4, F3 = 8};
enum struct EnumStruct { G0, G1, G2, G3 };
enum struct TypedEnumStruct : char { H0, H1, H2, H3 };
enum struct StructFlag { I0 = 1, I1 = 2, I2 = 4, I3 = 8};
Q_DECLARE_FLAGS(ClassFlags, ClassFlag)
Q_DECLARE_FLAGS(StructFlags, StructFlag)
Q_ENUM(EnumClass)
Q_ENUM(TypedEnum)
Q_ENUM(TypedEnumClass)
Q_ENUM(NormalEnum)
Q_ENUM(EnumStruct)
Q_ENUM(TypedEnumStruct)
Q_FLAG(ClassFlags)
Q_FLAG(StructFlags)
};
// Also test the Q_ENUMS macro
class CXX11Enums2
{
Q_GADGET
public:
enum class EnumClass { A0, A1, A2, A3 };
enum TypedEnum : char { B0, B1 , B2, B3 };
enum class TypedEnumClass : char { C0, C1, C2, C3 };
enum NormalEnum { D2 = 2, D3, D0 =0 , D1 };
enum class ClassFlag { F0 = 1, F1 = 2, F2 = 4, F3 = 8 };
Q_DECLARE_FLAGS(ClassFlags, ClassFlag)
Q_ENUMS(EnumClass TypedEnum TypedEnumClass NormalEnum)
Q_FLAGS(ClassFlags)
};
#endif // CXX11_ENUMS_H

View File

@ -0,0 +1,223 @@
// Copyright (C) 2012 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 WITH Qt-GPL-exception-1.0
#ifndef TESTS_AUTO_CORELIB_TOOLS_MOC_CXX11_EXPLICIT_OVERRIDE_CONTROL_H
#define TESTS_AUTO_CORELIB_TOOLS_MOC_CXX11_EXPLICIT_OVERRIDE_CONTROL_H
#include <QtCore/QObject>
#ifndef Q_MOC_RUN // hide from moc
# define override
# define final
# define sealed
#endif
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wsuggest-override")
class ExplicitOverrideControlBase : public QObject
{
Q_OBJECT
public:
explicit ExplicitOverrideControlBase(QObject *parent = nullptr)
: QObject(parent) {}
private Q_SLOTS:
virtual void pureSlot0() = 0;
virtual void pureSlot1() = 0;
virtual void pureSlot2() const = 0;
virtual void pureSlot3() const = 0;
#if 0 // moc doesn't support volatile slots
virtual void pureSlot4() volatile = 0;
virtual void pureSlot5() volatile = 0;
virtual void pureSlot6() const volatile = 0;
virtual void pureSlot7() volatile const = 0;
virtual void pureSlot8() const volatile = 0;
virtual void pureSlot9() volatile const = 0;
#endif
};
class ExplicitOverrideControlFinalQt : public ExplicitOverrideControlBase
{
Q_OBJECT
public:
explicit ExplicitOverrideControlFinalQt(QObject *parent = nullptr)
: ExplicitOverrideControlBase(parent) {}
private Q_SLOTS:
void pureSlot0() Q_DECL_FINAL {}
void pureSlot1() Q_DECL_FINAL {}
void pureSlot2() const Q_DECL_FINAL {}
void pureSlot3() Q_DECL_FINAL const {}
#if 0 // moc doesn't support volatile slots
void pureSlot4() volatile Q_DECL_FINAL {}
void pureSlot5() Q_DECL_FINAL volatile {}
void pureSlot6() const volatile Q_DECL_FINAL {}
void pureSlot7() volatile Q_DECL_FINAL const {}
void pureSlot8() const Q_DECL_FINAL volatile {}
void pureSlot9() Q_DECL_FINAL volatile const {}
#endif
};
class ExplicitOverrideControlFinalCxx11 : public ExplicitOverrideControlBase
{
Q_OBJECT
public:
explicit ExplicitOverrideControlFinalCxx11(QObject *parent = nullptr)
: ExplicitOverrideControlBase(parent) {}
private Q_SLOTS:
void pureSlot0() final {}
void pureSlot1() final {}
void pureSlot2() const final {}
void pureSlot3() final const {}
#if 0 // moc doesn't support volatile slots
void pureSlot4() volatile final {}
void pureSlot5() final volatile {}
void pureSlot6() const volatile final {}
void pureSlot7() volatile final const {}
void pureSlot8() const final volatile {}
void pureSlot9() final volatile const {}
#endif
};
class ExplicitOverrideControlSealed : public ExplicitOverrideControlBase
{
Q_OBJECT
public:
explicit ExplicitOverrideControlSealed(QObject *parent = nullptr)
: ExplicitOverrideControlBase(parent) {}
private Q_SLOTS:
void pureSlot0() sealed {}
void pureSlot1() sealed {}
void pureSlot2() const sealed {}
void pureSlot3() sealed const {}
#if 0 // moc doesn't support volatile slots
void pureSlot4() volatile sealed {}
void pureSlot5() sealed volatile {}
void pureSlot6() const volatile sealed {}
void pureSlot7() volatile sealed const {}
void pureSlot8() const sealed volatile {}
void pureSlot9() sealed volatile const {}
#endif
};
class ExplicitOverrideControlOverrideQt : public ExplicitOverrideControlBase
{
Q_OBJECT
public:
explicit ExplicitOverrideControlOverrideQt(QObject *parent = nullptr)
: ExplicitOverrideControlBase(parent) {}
private Q_SLOTS:
void pureSlot0() override {}
void pureSlot1() override {}
void pureSlot2() const override {}
void pureSlot3() override const {}
#if 0 // moc doesn't support volatile slots
void pureSlot4() volatile override {}
void pureSlot5() override volatile {}
void pureSlot6() const volatile override {}
void pureSlot7() volatile override const {}
void pureSlot8() const override volatile {}
void pureSlot9() override volatile const {}
#endif
};
class ExplicitOverrideControlOverrideCxx11 : public ExplicitOverrideControlBase
{
Q_OBJECT
public:
explicit ExplicitOverrideControlOverrideCxx11(QObject *parent = nullptr)
: ExplicitOverrideControlBase(parent) {}
private Q_SLOTS:
void pureSlot0() override {}
void pureSlot1() override {}
void pureSlot2() const override {}
void pureSlot3() override const {}
#if 0 // moc doesn't support volatile slots
void pureSlot4() volatile override {}
void pureSlot5() override volatile {}
void pureSlot6() const volatile override {}
void pureSlot7() volatile override const {}
void pureSlot8() const override volatile {}
void pureSlot9() override volatile const {}
#endif
};
class ExplicitOverrideControlFinalQtOverrideQt : public ExplicitOverrideControlBase
{
Q_OBJECT
public:
explicit ExplicitOverrideControlFinalQtOverrideQt(QObject *parent = nullptr)
: ExplicitOverrideControlBase(parent) {}
private Q_SLOTS:
void pureSlot0() Q_DECL_FINAL override {}
void pureSlot1() override Q_DECL_FINAL {}
void pureSlot2() override const Q_DECL_FINAL {}
void pureSlot3() Q_DECL_FINAL const override {}
#if 0 // moc doesn't support volatile slots
void pureSlot4() volatile Q_DECL_FINAL override {}
void pureSlot5() override Q_DECL_FINAL volatile {}
void pureSlot6() override const volatile Q_DECL_FINAL {}
void pureSlot7() volatile override Q_DECL_FINAL const {}
void pureSlot8() const Q_DECL_FINAL override volatile {}
void pureSlot9() Q_DECL_FINAL volatile const override {}
#endif
};
class ExplicitOverrideControlFinalCxx11OverrideCxx11 : public ExplicitOverrideControlBase
{
Q_OBJECT
public:
explicit ExplicitOverrideControlFinalCxx11OverrideCxx11(QObject *parent = nullptr)
: ExplicitOverrideControlBase(parent) {}
private Q_SLOTS:
void pureSlot0() final override {}
void pureSlot1() override final {}
void pureSlot2() override const final {}
void pureSlot3() final const override {}
#if 0 // moc doesn't support volatile slots
void pureSlot4() volatile final override {}
void pureSlot5() override final volatile {}
void pureSlot6() const volatile final override {}
void pureSlot7() volatile final override const {}
void pureSlot8() const override final volatile {}
void pureSlot9() override final volatile const {}
#endif
};
class ExplicitOverrideControlSealedOverride : public ExplicitOverrideControlBase
{
Q_OBJECT
public:
explicit ExplicitOverrideControlSealedOverride(QObject *parent = nullptr)
: ExplicitOverrideControlBase(parent) {}
private Q_SLOTS:
void pureSlot0() sealed override {}
void pureSlot1() override sealed {}
void pureSlot2() override const sealed {}
void pureSlot3() sealed const override {}
#if 0 // moc doesn't support volatile slots
void pureSlot4() volatile sealed override {}
void pureSlot5() sealed override volatile {}
void pureSlot6() const override volatile sealed {}
void pureSlot7() volatile sealed override const {}
void pureSlot8() const sealed volatile override {}
void pureSlot9() override sealed volatile const {}
#endif
};
QT_WARNING_POP
#ifndef Q_MOC_RUN
# undef final
# undef sealed
# undef override
#endif
#endif // TESTS_AUTO_CORELIB_TOOLS_MOC_CXX11_EXPLICIT_OVERRIDE_CONTROL_H

View File

@ -0,0 +1,95 @@
// Copyright (C) 2012 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 WITH Qt-GPL-exception-1.0
#ifndef TESTS_AUTO_CORELIB_TOOLS_MOC_CXX11_FINAL_CLASSES_H
#define TESTS_AUTO_CORELIB_TOOLS_MOC_CXX11_FINAL_CLASSES_H
#include <QtCore/QObject>
#ifndef Q_MOC_RUN // hide from moc
# define final
# define sealed
# define EXPORT_MACRO
# define EXPORT_MACRO2(X,Y,Z)
#endif
class FinalTestClassQt Q_DECL_FINAL : public QObject
{
Q_OBJECT
public:
explicit FinalTestClassQt(QObject *parent = nullptr)
: QObject(parent) {}
};
class EXPORT_MACRO ExportedFinalTestClassQt Q_DECL_FINAL : public QObject
{
Q_OBJECT
public:
explicit ExportedFinalTestClassQt(QObject *parent = nullptr)
: QObject(parent) {}
};
class EXPORT_MACRO2(X,Y,Z) ExportedFinalTestClassQtX Q_DECL_FINAL : public QObject
{
Q_OBJECT
public:
explicit ExportedFinalTestClassQtX(QObject *parent = nullptr)
: QObject(parent) {}
};
class FinalTestClassCpp11 final : public QObject
{
Q_OBJECT
public:
explicit FinalTestClassCpp11(QObject *parent = nullptr)
: QObject(parent) {}
};
class EXPORT_MACRO ExportedFinalTestClassCpp11 final : public QObject
{
Q_OBJECT
public:
explicit ExportedFinalTestClassCpp11(QObject *parent = nullptr)
: QObject(parent) {}
};
class EXPORT_MACRO2(X,Y,Z) ExportedFinalTestClassCpp11X final : public QObject
{
Q_OBJECT
public:
explicit ExportedFinalTestClassCpp11X(QObject *parent = nullptr)
: QObject(parent) {}
};
class SealedTestClass sealed : public QObject
{
Q_OBJECT
public:
explicit SealedTestClass(QObject *parent = nullptr)
: QObject(parent) {}
};
class EXPORT_MACRO ExportedSealedTestClass sealed : public QObject
{
Q_OBJECT
public:
explicit ExportedSealedTestClass(QObject *parent = nullptr)
: QObject(parent) {}
};
class EXPORT_MACRO2(X,Y,Z) ExportedSealedTestClassX sealed : public QObject
{
Q_OBJECT
public:
explicit ExportedSealedTestClassX(QObject *parent = nullptr)
: QObject(parent) {}
};
#ifndef Q_MOC_RUN
# undef final
# undef sealed
# undef EXPORT_MACRO
# undef EXPORT_MACRO2
#endif
#endif // TESTS_AUTO_CORELIB_TOOLS_MOC_CXX11_FINAL_CLASSES_H

View File

@ -0,0 +1,43 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef CXX11_TRAILING_RETURN_H
#define CXX11_TRAILING_RETURN_H
#include <QtCore/QObject>
class CXX11TrailingReturn : public QObject
{
Q_OBJECT
public slots:
inline auto fun() -> void;
inline auto arguments(int i, char b) -> int;
inline auto inlineFunc(int i) -> int
{
return i + 1;
}
inline auto constRefReturn() -> const CXX11TrailingReturn &
{
return *this;
}
inline auto constConstRefReturn() const -> const CXX11TrailingReturn &
{
return *this;
}
signals:
auto trailingSignalReturn(int i) -> void;
};
auto CXX11TrailingReturn::fun() -> void
{
return;
}
auto CXX11TrailingReturn::arguments(int i, char b) -> int
{
return i + int(b);
}
#endif // CXX11_TRAILING_RETURN_H

View File

@ -0,0 +1,39 @@
// Copyright (C) 2011 Olivier Goffart.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef CXX17_NAMESPACES_H
#define CXX17_NAMESPACES_H
#include <QtCore/QObject>
#if defined(__cpp_nested_namespace_definitions) || defined(Q_MOC_RUN)
namespace CXX17Namespace::A::B {
namespace C::D {
namespace E::F::G { } // don't confuse moc
#else
namespace CXX17Namespace { namespace A { namespace B {
namespace C { namespace D {
#endif
Q_NAMESPACE
class ClassInNamespace
{
Q_GADGET
public:
enum GadEn { Value = 3 };
Q_ENUM(GadEn)
};
enum NamEn { Value = 4 };
Q_ENUM_NS(NamEn);
#if defined(__cpp_nested_namespace_definitions) || defined(Q_MOC_RUN)
}
}
#else
} } }
} }
#endif
#endif

View File

@ -0,0 +1,13 @@
// 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 DIR_IN_INCLUDE_PATH_H
#define DIR_IN_INCLUDE_PATH_H
#include <Plugin>
class DirInIncludePath : public QObject, public MyInterface
{
Q_OBJECT
Q_INTERFACES(MyInterface)
};
#endif // DIR_IN_INCLUDE_PATH_H

View File

@ -0,0 +1,36 @@
// Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef DOLLARS_H
#define DOLLARS_H
/* both GCC and clang allow $ in identifiers
* So moc should not throw a parse error if it parses a file that contains such identifiers
*/
#include <QObject>
#define macro$1 function1
#define $macro2 function2
namespace $NS {
class $CLS : public QObject
{
Q_PROPERTY(int rich$ MEMBER m_$rich$)
Q_PROPERTY(int money$$$ READ $$$money$$$ WRITE $$$setMoney$$$)
Q_OBJECT
int m_$rich$;
int m_money;
int $$$money$$$() { return m_money; }
int $$$setMoney$$$(int m) { return m_money = m; }
Q_SIGNALS:
void macro$1 ();
void $macro2 ();
void function$3 ($CLS * cl$s);
};
}
#endif // DOLLARS_H

View File

@ -0,0 +1,2 @@
parcel = 42,
part = 12,

View File

@ -0,0 +1,19 @@
// 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 ENUM_WITH_INCLUDE_H
#define ENUM_WITH_INCLUDE_H
#include <QtCore/QObject>
class Foo : public QObject {
enum en {
#include <enum_inc.h>
};
enum class en2 {
#include <enum_inc.h>
reference = 42
};
Q_OBJECT
};
#endif

View File

@ -0,0 +1,19 @@
// 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 ERROR_ON_WRONG_NOTIFY_H
#define ERROR_ON_WRONG_NOTIFY_H
#include <QtCore/QObject>
class ClassWithWrongNOTIFY : public QObject
{
Q_OBJECT
Q_PROPERTY(int foo READ foo WRITE setFoo NOTIFY fooChanged)
int m_foo;
public:
void setFoo(int i) { m_foo = i; }
int foo() { return m_foo; }
};
#endif // ERROR_ON_WRONG_NOTIFY_H

View File

@ -0,0 +1,15 @@
// 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 ESCAPES_IN_STRING_LITERALS_H
#define ESCAPES_IN_STRING_LITERALS_H
#include <QObject>
class StringLiterals: public QObject
{
Q_OBJECT
Q_CLASSINFO("Test", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\x53")
Q_CLASSINFO("Test2", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\123")
Q_CLASSINFO("Test3", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nb")
};
#endif // ESCAPES_IN_STRING_LITERALS_H

View File

@ -0,0 +1,23 @@
// 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 EXTRAQUALIFICATION_H
#define EXTRAQUALIFICATION_H
#include <QObject>
class Test : public QObject
{
Q_OBJECT
public slots:
// this is invalid code that does not compile, the extra qualification
// is bad. However for example older gccs silently accept it, so customers
// can write the code and moc generates bad metadata. So instead moc should
// now write out a warning and /not/ generate any code, because the code is
// bad and with a decent compiler it won't compile anyway.
void Test::badFunctionDeclaration() {}
public:
Q_SLOT void Test::anotherOne() {}
};
#endif // EXTRAQUALIFICATION_H

View File

@ -0,0 +1,21 @@
// 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 FORGOTTEN_QINTERFACE_H
#define FORGOTTEN_QINTERFACE_H
#include <QObject>
struct MyInterface
{
virtual ~MyInterface() {}
virtual void foo() = 0;
};
Q_DECLARE_INTERFACE(MyInterface, "foo.bar.blah")
class Test : public QObject, public MyInterface
{
Q_OBJECT
};
#endif // FORGOTTEN_QINTERFACE_H

View File

@ -0,0 +1,45 @@
// Copyright (C) 2016 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef FORWARD_DECLARED_PARAM_H
#define FORWARD_DECLARED_PARAM_H
#include <qobject.h>
#include <qmetatype.h>
Q_MOC_INCLUDE("forwarddeclaredparam.h")
// test support for const refs to forward-declared structs in parameters
struct ForwardDeclaredParam;
template <typename T> class ForwardDeclaredContainer;
struct FullyDefined {};
inline size_t qHash(const FullyDefined &, size_t seed = 0) { return seed; }
inline bool operator==(const FullyDefined &, const FullyDefined &) { return true; }
Q_DECLARE_METATYPE(FullyDefined)
class ForwardDeclaredParamClass : public QObject
{
Q_OBJECT
public slots:
void slotNaked(const ForwardDeclaredParam &) {}
void slotFDC(const ForwardDeclaredContainer<ForwardDeclaredParam> &) {}
void slotFDC(const ForwardDeclaredContainer<int> &) {}
void slotFDC(const ForwardDeclaredContainer<QString> &) {}
void slotFDC(const ForwardDeclaredContainer<FullyDefined> &) {}
void slotQSet(const QSet<ForwardDeclaredParam> &) {}
void slotQSet(const QSet<int> &) {}
void slotQSet(const QSet<QString> &) {}
void slotQSet(const QSet<FullyDefined> &) {}
signals:
void signalNaked(const ForwardDeclaredParam &);
void signalFDC(const ForwardDeclaredContainer<ForwardDeclaredParam> &);
void signalFDC(const ForwardDeclaredContainer<int> &);
void signalFDC(const ForwardDeclaredContainer<QString> &);
void signalFDC(const ForwardDeclaredContainer<FullyDefined> &);
void signalQSet(const QSet<ForwardDeclaredParam> &);
void signalQSet(const QSet<int> &);
void signalQSet(const QSet<QString> &);
void signalQSet(const QSet<FullyDefined> &);
};
#endif // FORWARD_DECLARED_PARAM_H

View File

@ -0,0 +1,5 @@
#ifndef FORWARDDECLAREDPARAM_H
#define FORWARDDECLAREDPARAM_H
struct ForwardDeclaredParam {};
template <typename T> class ForwardDeclaredContainer {};
#endif

View File

@ -0,0 +1,30 @@
// 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 FUNCTION_WITH_ATTRIBUTES_H
#define FUNCTION_WITH_ATTRIBUTES_H
#include <qobject.h>
// test support for gcc attributes with functions
#if defined(Q_CC_GNU) || defined(Q_MOC_RUN)
#define DEPRECATED1 __attribute__ ((__deprecated__))
#else
#define DEPRECATED1
#endif
#if defined(Q_CC_MSVC) || defined(Q_MOC_RUN)
#define DEPRECATED2 __declspec(deprecated)
#else
#define DEPRECATED2
#endif
class FunctionWithAttributes : public QObject
{
Q_OBJECT
public slots:
DEPRECATED1 void test1() {}
DEPRECATED2 void test2() {}
};
#endif // FUNCTION_WITH_ATTRIBUTES_H

View File

@ -0,0 +1,13 @@
// Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifdef FWDCLASS1_H
#error "This file can only be included once"
#endif
#define FWDCLASS1_H
class FwdClass1
{
public:
int x;
};

View File

@ -0,0 +1,13 @@
// Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifdef FWDCLASS2_H
#error "This file can only be included once"
#endif
#define FWDCLASS2_H
class FwdClass2
{
public:
int x;
};

View File

@ -0,0 +1,13 @@
// Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifdef FWDCLASS3_H
#error "This file can only be included once"
#endif
#define FWDCLASS3_H
class FwdClass3
{
public:
int x;
};

View File

@ -0,0 +1,28 @@
// 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 TASK175491
#define TASK175491
#include <QObject>
class GadgetWithNoEnums
{
Q_GADGET
public:
GadgetWithNoEnums() {}
virtual ~GadgetWithNoEnums() {}
};
class DerivedGadgetWithEnums : public GadgetWithNoEnums
{
Q_GADGET
public:
enum FooEnum { FooValue };
Q_ENUM( FooEnum )
DerivedGadgetWithEnums() {}
~DerivedGadgetWithEnums() {}
};
#endif

View File

@ -0,0 +1,19 @@
// 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 GRANDPARENTGADGETCLASS_H
#define GRANDPARENTGADGETCLASS_H
#include <QtCore/qobjectdefs.h>
namespace GrandParentGadget {
struct BaseGadget { Q_GADGET };
struct Derived : BaseGadget {};
struct DerivedGadget : Derived { Q_GADGET };
template<typename T> struct CRTP : BaseGadget {};
struct CRTPDerivedGadget : CRTP<CRTPDerivedGadget> { Q_GADGET };
}
#endif // GRANDPARENTGADGETCLASS_H

View File

@ -0,0 +1,18 @@
// 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 INTERFACE_FROM_FRAMEWORK_H
#define INTERFACE_FROM_FRAMEWORK_H
#include <Test/testinterface.h>
class TestComponent : public QObject, public TestInterface
{
Q_OBJECT
Q_INTERFACES(TestInterface)
public:
virtual inline foobar() { }
};
#endif // INTERFACE_FROM_FRAMEWORK_H

View File

@ -0,0 +1,17 @@
// 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 INTERFACE_FROM_INCLUDE_H
#define INTERFACE_FROM_INCLUDE_H
#include <testinterface.h>
class TestComponent : public QObject, public TestInterface
{
Q_OBJECT
Q_INTERFACES(TestInterface)
public:
virtual void foobar() { }
};
#endif

View File

@ -0,0 +1,16 @@
// 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 MACRO_ON_CMDLINE_H
#define MACRO_ON_CMDLINE_H
#if FOO
class Test : public QObject
{
Q_OBJECT
public:
};
#endif
#endif // MACRO_ON_CMDLINE_H

View File

@ -0,0 +1,49 @@
// Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef MOC_INCLUDE_H
#define MOC_INCLUDE_H
#include <QObject>
class FwdClass1;
class FwdClass2;
class FwdClass3;
Q_MOC_INCLUDE(fwdclass3.h)
namespace SomeRandomNamespace {
Q_MOC_INCLUDE("fwdclass1.h")
Q_NAMESPACE
}
class TestFwdProperties : public QObject
{
Q_OBJECT
Q_PROPERTY(FwdClass1 prop1 WRITE setProp1 READ getProp1)
Q_PROPERTY(FwdClass2 prop2 WRITE setProp2 READ getProp2)
Q_PROPERTY(FwdClass3 prop3 WRITE setProp3 READ getProp3)
public:
~TestFwdProperties();
void setProp1(const FwdClass1 &val);
void setProp2(const FwdClass2 &val);
void setProp3(const FwdClass3 &val);
const FwdClass1 &getProp1() { return *prop1; }
const FwdClass2 &getProp2() { return *prop2; }
const FwdClass3 &getProp3() { return *prop3; }
QScopedPointer<FwdClass1> prop1;
QScopedPointer<FwdClass2> prop2;
QScopedPointer<FwdClass3> prop3;
Q_MOC_INCLUDE(
\
"fwdclass2.h"
)
};
Q_MOC_INCLUDE(<QString>)
#endif // MOC_INCLUDE_H

View File

@ -0,0 +1,57 @@
// 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 NAMESPACE_H
#define NAMESPACE_H
#include <QObject>
#include "namespace_no_merge.h"
// moc should not merge namespace_no_merge.h content with this one !
namespace FooNamespace {
Q_NAMESPACE
enum class Enum1 {
Key1,
Key2
};
Q_ENUM_NS(Enum1)
namespace FooNestedNamespace {
Q_NAMESPACE
enum class Enum2 {
Key3,
Key4
};
Q_ENUM_NS(Enum2)
}
using namespace FooNamespace;
namespace Bar = FooNamespace;
// Moc should merge this namespace with the previous one
namespace FooNestedNamespace {
Q_NAMESPACE
enum class Enum3 {
Key5,
Key6
};
Q_ENUM_NS(Enum3)
namespace FooMoreNestedNamespace {
Q_NAMESPACE
enum class Enum4 {
Key7,
Key8
};
Q_ENUM_NS(Enum4)
}
}
}
#ifdef Q_MOC_RUN
namespace __identifier("<AtlImplementationDetails>") {} // QTBUG-56634
using namespace __identifier("<AtlImplementationDetails>"); // QTBUG-63772
#endif
#endif // NAMESPACE_H

View File

@ -0,0 +1,49 @@
// 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 NAMESPACE_NO_MERGE_H
#define NAMESPACE_NO_MERGE_H
#include <QObject>
namespace FooNamespace {
Q_NAMESPACE
enum class MEnum1 {
Key1,
Key2
};
Q_ENUM_NS(MEnum1)
namespace FooNestedNamespace {
Q_NAMESPACE
enum class MEnum2 {
Key3,
Key4
};
Q_ENUM_NS(MEnum2)
}
using namespace FooNamespace;
namespace Bar = FooNamespace;
// Moc should merge this namespace with the previous one
namespace FooNestedNamespace {
Q_NAMESPACE
enum class MEnum3 {
Key5,
Key6
};
Q_ENUM_NS(MEnum3)
namespace FooMoreNestedNamespace {
Q_NAMESPACE
enum class MEnum4 {
Key7,
Key8
};
Q_ENUM_NS(MEnum4)
}
}
}
#endif // NAMESPACE_NO_MERGE_H

View File

@ -0,0 +1,47 @@
// 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 NAMESPACED_FLAGS_H
#define NAMESPACED_FLAGS_H
#include <QObject>
namespace Foo {
class Bar : public QObject {
Q_OBJECT
Q_PROPERTY( Flags flags READ flags WRITE setFlags )
public:
explicit Bar( QObject * parent=0 ) : QObject( parent ), mFlags() {}
enum Flag { Read=1, Write=2 };
Q_DECLARE_FLAGS( Flags, Flag )
Q_FLAG(Flags)
void setFlags( Flags f ) { mFlags = f; }
Flags flags() const { return mFlags; }
private:
Flags mFlags;
};
class Baz : public QObject {
Q_OBJECT
//Q_PROPERTY( Bar::Flags flags READ flags WRITE setFlags ) // triggers assertion
Q_PROPERTY( Foo::Bar::Flags flags READ flags WRITE setFlags ) // fails to compile, or with the same assertion if moc fix is applied
Q_PROPERTY( QList<Foo::Bar::Flags> flagsList READ flagsList WRITE setFlagsList )
public:
explicit Baz( QObject * parent=0 ) : QObject( parent ), mFlags() {}
void setFlags( Bar::Flags f ) { mFlags = f; }
Bar::Flags flags() const { return mFlags; }
void setFlagsList( const QList<Bar::Flags> &f ) { mList = f; }
QList<Bar::Flags> flagsList() const { return mList; }
private:
Bar::Flags mFlags;
QList<Bar::Flags> mList;
};
}
Q_DECLARE_OPERATORS_FOR_FLAGS( Foo::Bar::Flags )
#endif // NAMESPACED_FLAGS_H

View File

@ -0,0 +1,56 @@
// 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 NO_KEYWORDS_H
#define NO_KEYWORDS_H
#define QT_NO_KEYWORDS
#undef signals
#undef slots
#undef emit
#define signals FooBar
#define slots Baz
#define emit Yoyodyne
#include <QtCore/QtCore>
#ifdef QT_CONCURRENT_LIB
#include <QtConcurrent/QtConcurrent>
#endif
#ifdef QT_NETWORK_LIB
#include <QtNetwork/QtNetwork>
#endif
#ifdef QT_SQL_LIB
#include <QtSql/QtSql>
#endif
#ifdef QT_DBUS_LIB
#include <QtDBus/QtDBus>
#endif
#undef signals
#undef slots
#undef emit
class MyBooooooostishClass : public QObject
{
Q_OBJECT
public:
inline MyBooooooostishClass() {}
Q_SIGNALS:
void mySignal();
public Q_SLOTS:
inline void mySlot() { mySignal(); }
private:
Q_DECL_UNUSED_MEMBER int signals;
Q_DECL_UNUSED_MEMBER double slots;
};
#define signals Q_SIGNALS
#define slots Q_SLOTS
#define emit Q_EMIT
#undef QT_NO_KEYWORDS
#endif // NO_KEYWORDS_H

View File

@ -0,0 +1,17 @@
// 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 NONGADGETPARENTCLASS_H
#define NONGADGETPARENTCLASS_H
#include <QtCore/qobjectdefs.h>
namespace NonGadgetParent {
struct Base {};
struct Derived : Base { Q_GADGET };
}
#endif // NONGADGETPARENTCLASS_H

View File

@ -0,0 +1,22 @@
// 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 OLDSTYLE_CASTS_H
#define OLDSTYLE_CASTS_H
#include <QtCore/qobject.h>
class OldStyleCast: public QObject
{
Q_OBJECT
public:
signals:
public slots:
inline void foo() {}
inline int bar(int, int*, const int *, volatile int *, const int * volatile *) { return 0; }
inline void slot(int, QObject * const) {}
};
#endif // OLDSTYLE_CASTS_H

View File

@ -0,0 +1 @@
// Copyright (C) 2016 The Qt Company Ltd.

View File

@ -0,0 +1,92 @@
// 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 PARSE_BOOST_H
#define PARSE_BOOST_H
#include <boost/aligned_storage.hpp>
#include <boost/any.hpp>
#include <boost/array.hpp>
#include <boost/assert.hpp>
#include <boost/assign.hpp>
#include <boost/bind.hpp>
#include <boost/blank_fwd.hpp>
#include <boost/blank.hpp>
#include <boost/call_traits.hpp>
#include <boost/cast.hpp>
#include <boost/checked_delete.hpp>
#include <boost/compressed_pair.hpp>
#include <boost/concept_archetype.hpp>
#include <boost/concept_check.hpp>
#include <boost/config.hpp>
#include <boost/crc.hpp>
#include <boost/cstdint.hpp>
#include <boost/cstdlib.hpp>
#include <boost/current_function.hpp>
#include <boost/dynamic_bitset_fwd.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/format.hpp>
#include <boost/functional.hpp>
#include <boost/function_equal.hpp>
#include <boost/function.hpp>
#include <boost/function_output_iterator.hpp>
#include <boost/generator_iterator.hpp>
#include <boost/get_pointer.hpp>
#include <boost/implicit_cast.hpp>
#include <boost/indirect_reference.hpp>
#include <boost/integer_fwd.hpp>
#include <boost/integer.hpp>
#include <boost/integer_traits.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/io_fwd.hpp>
#include <boost/iterator_adaptors.hpp>
#include <boost/iterator.hpp>
#include <boost/last_value.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/limits.hpp>
#include <boost/math_fwd.hpp>
#include <boost/mem_fn.hpp>
#include <boost/multi_array.hpp>
#include <boost/next_prior.hpp>
#include <boost/noncopyable.hpp>
#include <boost/nondet_random.hpp>
#include <boost/none.hpp>
#include <boost/non_type.hpp>
#include <boost/operators.hpp>
#include <boost/optional.hpp>
#include <boost/pfto.hpp>
#include <boost/pointee.hpp>
#include <boost/preprocessor.hpp>
#include <boost/progress.hpp>
#include <boost/property_map.hpp>
#include <boost/property_map_iterator.hpp>
#include <boost/random.hpp>
#include <boost/range.hpp>
#include <boost/rational.hpp>
#include <boost/ref.hpp>
#include <boost/scoped_array.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/shared_array.hpp>
#include <boost/shared_container_iterator.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/smart_cast.hpp>
#include <boost/smart_ptr.hpp>
#include <boost/spirit.hpp>
#include <boost/state_saver.hpp>
#include <boost/static_assert.hpp>
#include <boost/static_warning.hpp>
#include <boost/strong_typedef.hpp>
#include <boost/throw_exception.hpp>
#include <boost/timer.hpp>
#include <boost/token_functions.hpp>
#include <boost/token_iterator.hpp>
#include <boost/tokenizer.hpp>
#include <boost/type.hpp>
#include <boost/type_traits.hpp>
#include <boost/utility.hpp>
#include <boost/variant.hpp>
#include <boost/vector_property_map.hpp>
#include <boost/version.hpp>
#include <boost/visit_each.hpp>
#include <boost/weak_ptr.hpp>
#endif // PARSE_BOOST_H

View File

@ -0,0 +1,125 @@
// 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 PARSE_DEFINES_H
#define PARSE_DEFINES_H
#include <qobject.h>
Q_MOC_INCLUDE(<QMap>)
// this is intentionally ugly to test moc's preprocessing capabilities
#define PD_NAMESPACE PD
#define PD_BEGIN_NAMESPACE namespace PD_NAMESPACE {
#define PD_END_NAMESPACE }
#define PD_VOIDFUNCTION() voidFunction()
#define PD_CLASSNAME ParseDefine
#define PD_STRINGIFY(a) #a
#define PD_XSTRINGIFY(a) PD_STRINGIFY(a)
#define PD_SCOPED_STRING(a, b) PD_STRINGIFY(a) "::" PD_STRINGIFY(b)
#define PD_DEFINE1(a,b) a##b
#define PD_DEFINE2(a,b) a comb##b
#define PD_DEFINE3(a,b) a b##ined3()
#define PD_COMBINE(a,b) a b
#define PD_TEST_IDENTIFIER_ARG(if, while) if while
#define QString() error_type
#define PD_CLASSINFO Q_CLASSINFO
#define PD_VARARG(x, ...) x(__VA_ARGS__)
#if defined(Q_CC_GNU) || defined(Q_MOC_RUN)
//GCC extension for variadic macros
#define PD_VARARGEXT(x, y...) x(y)
#else
#define PD_VARARGEXT(x, ...) x(__VA_ARGS__)
#endif
#define PD_ADD_SUFFIX(x) PD_DEFINE1(x,_SUFFIX)
#define PD_DEFINE_ITSELF PD_ADD_SUFFIX(PD_DEFINE_ITSELF)
#ifndef Q_MOC_RUN
// macro defined on the command line (in tst_moc.pro)
#define DEFINE_CMDLINE_EMPTY
#define DEFINE_CMDLINE_SIGNAL void cmdlineSignal(const QMap<int, int> &i)
#endif
#define HASH_SIGN #
PD_BEGIN_NAMESPACE
class DEFINE_CMDLINE_EMPTY PD_CLASSNAME DEFINE_CMDLINE_EMPTY
: public DEFINE_CMDLINE_EMPTY QObject DEFINE_CMDLINE_EMPTY
{
Q_OBJECT
Q_CLASSINFO("TestString", PD_STRINGIFY(PD_CLASSNAME))
Q_CLASSINFO("TestString2", PD_XSTRINGIFY(PD_CLASSNAME))
PD_CLASSINFO("TestString3", "TestValue")
public:
PD_CLASSNAME() {}
public slots:
void PD_VOIDFUNCTION() {}
QString stringMethod() { return QString::fromLatin1(""); }
void PD_DEFINE1(comb, ined1()) {}
PD_DEFINE2(void, ined2()) {}
PD_DEFINE3(void, comb) {}
PD_COMBINE(void combined4(int, int), {})
PD_COMBINE(void combined5() {, })
PD_TEST_IDENTIFIER_ARG(void, combined6()) {}
PD_VARARG(void vararg1) {}
PD_VARARG(void vararg2, int) {}
PD_VARARG(void vararg3, int, int) {}
PD_VARARGEXT(void vararg4) {}
PD_VARARGEXT(void vararg5, int) {}
PD_VARARGEXT(void vararg6, int, int) {}
#define OUTERFUNCTION(x) x
#define INNERFUNCTION(x) OUTERFUNCTION(x)
#define INNER INNERFUNCTION
void INNERFUNCTION(INNERFUNCTION)(int) {}
void OUTERFUNCTION(INNERFUNCTION)(inner_expanded(int)) {}
void expanded_method OUTERFUNCTION(INNER)((int)) {}
#undef INNERFUNCTION
#define cond1() 0x1
#define cond2() 0x2
#if !(cond1() & cond2())
void conditionSlot() {}
#endif
void PD_DEFINE_ITSELF(int) {}
signals:
DEFINE_CMDLINE_SIGNAL;
#define QTBUG55853(X) PD_DEFINE1(X, signalQTBUG55853)
#define PD_EMPTY /* empty */
void QTBUG55853(PD_EMPTY)();
};
#undef QString
#ifdef Q_MOC_RUN
// Normaly, redefining keywords is forbidden, but we should not abort parsing
#define and &&
#define and_eq &=
#define bitand &
#define true 1
#undef true
#endif
PD_END_NAMESPACE
#endif

View File

@ -0,0 +1,15 @@
// 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 TESTPLUGINMETADATA
#define TESTPLUGINMETADATA
#include <QtPlugin>
class TestPluginMetaData : public QObject
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "test.meta.tags")
};
#endif

View File

@ -0,0 +1,27 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef POINTERY_TO_INCOMPLETE_H
#define POINTERY_TO_INCOMPLETE_H
#include <QObject>
#include <QSharedPointer>
#include <QWeakPointer>
#include <QPointer>
class FwdClass;
class TestPointeeCanBeIncomplete : public QObject
{
Q_OBJECT
public slots:
void setProp1(QPointer<FwdClass>) {}
void setProp2(QSharedPointer<FwdClass>) {}
void setProp3(const QWeakPointer<FwdClass> &) {}
void setProp4(FwdClass *) {}
void setProp5(const FwdClass *) {}
void setProp6(void *) {}
void setProp7(const void *) {}
};
#endif // POINTERY_TO_INCOMPLETE_H

View File

@ -0,0 +1,8 @@
// 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 PP_DOLLAR_SIGNS_H
#define PP_DOLLAR_SIGNS_H
$$ = parser->createFoo()
#endif // PP_DOLLAR_SIGNS_H

View File

@ -0,0 +1,26 @@
// 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 PURE_VIRTUAL_SIGNALS_H
#define PURE_VIRTUAL_SIGNALS_H
#include <QObject>
class PureVirtualSignalsTest : public QObject
{
Q_OBJECT
public:
signals:
virtual void mySignal() = 0;
void myOtherSignal();
virtual void mySignal2(int foo) = 0;
};
class PureVirtualSignalsImpl : public PureVirtualSignalsTest
{
Q_OBJECT
public:
signals:
void mySignal() override;
void mySignal2(int foo) override;
};
#endif // PURE_VIRTUAL_SIGNALS_H

View File

@ -0,0 +1,23 @@
// 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 QINVOKABLE_H
#define QINVOKABLE_H
#include <QObject>
class InvokableBeforeReturnType : public QObject
{
Q_OBJECT
public:
Q_INVOKABLE const char *foo() const { return ""; }
};
class InvokableBeforeInline : public QObject
{
Q_OBJECT
public:
Q_INVOKABLE inline void foo() {}
Q_INVOKABLE virtual void bar() {}
};
#endif // QINVOKABLE_H

View File

@ -0,0 +1,19 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef QMlMACRO_H
#define QMlMACRO_H
#include <QObject>
#include <QByteArray>
struct QmlMacro : QObject
{
Q_OBJECT
Q_CLASSINFO("QML.Element", "auto")
signals:
void f(QByteArray &b);
};
#endif

View File

@ -0,0 +1,26 @@
// 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 QPRIVATESLOTS_H
#define QPRIVATESLOTS_H
#include <QObject>
struct TestQPrivateSlots_Private
{
void _q_privateslot() {}
};
class TestQPrivateSlots: public QObject
{
Q_OBJECT
public:
TestQPrivateSlots() : d(new TestQPrivateSlots_Private()) {}
~TestQPrivateSlots() { delete d; }
private:
Q_PRIVATE_SLOT(d, void _q_privateslot())
Q_INVOKABLE void method1() {}; //task 204730
TestQPrivateSlots_Private *d;
};
#endif // QPRIVATESLOTS_H

View File

@ -0,0 +1,18 @@
// 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 QTBUG_35657_GADGET_H
#define QTBUG_35657_GADGET_H
#include <QObject>
namespace QTBUG_35657 {
class A {
Q_GADGET
Q_ENUMS(SomeEnum)
public:
enum SomeEnum { SomeEnumValue = 0 };
};
}
#endif // QTBUG_35657_GADGET_H

View File

@ -0,0 +1,21 @@
// 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 RELATED_METAOBJECTS_IN_GADGET_H
#define RELATED_METAOBJECTS_IN_GADGET_H
#include <QObject>
#include "qtbug-35657-gadget.h"
namespace QTBUG_35657 {
class B : public QObject
{
Q_OBJECT
Q_PROPERTY(A::SomeEnum blah READ blah)
public:
A::SomeEnum blah() const { return A::SomeEnumValue; }
};
}
#endif // RELATED_METAOBJECTS_IN_GADGET_H

View File

@ -0,0 +1,27 @@
// 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 RELATED_METAOBJECTS_IN_NAMESPACES_H
#define RELATED_METAOBJECTS_IN_NAMESPACES_H
#include <QObject>
namespace QTBUG_2151 {
class A : public QObject {
Q_OBJECT
Q_ENUMS(SomeEnum)
public:
enum SomeEnum { SomeEnumValue = 0 };
};
class B : public QObject
{
Q_OBJECT
Q_PROPERTY(A::SomeEnum blah READ blah)
public:
A::SomeEnum blah() const { return A::SomeEnumValue; }
};
}
#endif // RELATED_METAOBJECTS_IN_NAMESPACES_H

View File

@ -0,0 +1,79 @@
// 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 RELATED_METAOBJECTS_NAME_CONFLICT_H
#define RELATED_METAOBJECTS_NAME_CONFLICT_H
#include <QObject>
#define DECLARE_GADGET_AND_OBJECT_CLASSES \
class Gadget { \
Q_GADGET \
Q_ENUMS(SomeEnum) \
public: \
enum SomeEnum { SomeEnumValue = 0 }; \
}; \
class Object : public QObject{ \
Q_OBJECT \
Q_ENUMS(SomeEnum) \
public: \
enum SomeEnum { SomeEnumValue = 0 }; \
};
#define DECLARE_DEPENDING_CLASSES \
class DependingObject : public QObject \
{ \
Q_OBJECT \
Q_PROPERTY(Gadget::SomeEnum gadgetPoperty READ gadgetPoperty) \
Q_PROPERTY(Object::SomeEnum objectPoperty READ objectPoperty) \
public: \
Gadget::SomeEnum gadgetPoperty() const { return Gadget::SomeEnumValue; } \
Object::SomeEnum objectPoperty() const { return Object::SomeEnumValue; } \
};\
struct DependingNestedGadget : public QObject \
{ \
Q_OBJECT \
Q_PROPERTY(Nested::Gadget::SomeEnum nestedGadgetPoperty READ nestedGadgetPoperty) \
Nested::Gadget::SomeEnum nestedGadgetPoperty() const { return Nested::Gadget::SomeEnumValue; } \
};\
struct DependingNestedObject : public QObject \
{ \
Q_OBJECT \
Q_PROPERTY(Nested::Object::SomeEnum nestedObjectPoperty READ nestedObjectPoperty) \
Nested::Object::SomeEnum nestedObjectPoperty() const { return Nested::Object::SomeEnumValue; } \
};\
namespace Unsused {
DECLARE_GADGET_AND_OBJECT_CLASSES
} // Unused
namespace NS1 {
namespace Nested {
DECLARE_GADGET_AND_OBJECT_CLASSES
} // Nested
namespace NestedUnsused {
DECLARE_GADGET_AND_OBJECT_CLASSES
} // NestedUnused
DECLARE_GADGET_AND_OBJECT_CLASSES
DECLARE_DEPENDING_CLASSES
} // NS1
namespace NS2 {
namespace Nested {
DECLARE_GADGET_AND_OBJECT_CLASSES
} // Nested
namespace NestedUnsused {
DECLARE_GADGET_AND_OBJECT_CLASSES
} // NestedUnused
DECLARE_GADGET_AND_OBJECT_CLASSES
DECLARE_DEPENDING_CLASSES
} // NS2
#endif // RELATED_METAOBJECTS_NAME_CONFLICT_H

View File

@ -0,0 +1,16 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef SIGNAL_WITH_DEFAULT_ARG_H
#define SIGNAL_WITH_DEFAULT_ARG_H
#include <QtCore/qobject.h>
class SignalWithDefaultArg : public QObject
{
Q_OBJECT
signals:
void signalWithDefaultArg(int i = 12);
};
#endif // SIGNAL_WITH_DEFAULT_ARG_H

View File

@ -0,0 +1,24 @@
// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef SINGLE_QUOTE_DIGIT_SEPARATOR_N3781_H
#define SINGLE_QUOTE_DIGIT_SEPARATOR_N3781_H
#include <QObject>
class KDAB : public QObject
{
Q_OBJECT
public:
// C++1y allows use of single quote as a digit separator, useful for large
// numbers. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf
// Ensure that moc does not get confused with this.
enum Salaries {
Steve
#ifdef Q_MOC_RUN
= 1'234'567
#endif
};
Q_ENUMS(Salaries)
};
#endif // SINGLE_QUOTE_DIGIT_SEPARATOR_N3781_H

View File

@ -0,0 +1,47 @@
// 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 SINGLE_FUNCTION_KEYWORD_H
#define SINGLE_FUNCTION_KEYWORD_H
#include <QObject>
class SingleFunctionKeywordBeforeReturnType : public QObject
{
Q_OBJECT
public:
inline SingleFunctionKeywordBeforeReturnType() {}
Q_SIGNAL void mySignal();
Q_SLOT void mySlot() { mySignal(); }
};
class SingleFunctionKeywordBeforeInline : public QObject
{
Q_OBJECT
public:
inline SingleFunctionKeywordBeforeInline() {}
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wundefined-inline")
Q_SIGNAL inline void mySignal();
QT_WARNING_POP
Q_SLOT inline void mySlot() { emit mySignal(); }
};
class SingleFunctionKeywordAfterInline : public QObject
{
Q_OBJECT
public:
inline SingleFunctionKeywordAfterInline() {}
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wundefined-inline")
inline Q_SIGNAL void mySignal();
QT_WARNING_POP
inline Q_SLOT void mySlot() { emit mySignal(); }
};
#endif // SINGLE_FUNCTION_KEYWORD_H

View File

@ -0,0 +1,27 @@
// 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 SLOTS_WITH_VOID_TEMPLATE_H
#define SLOTS_WITH_VOID_TEMPLATE_H
#include <QObject>
template <typename T>
struct TestTemplate
{
T *blah;
};
class SlotsWithVoidTemplateTest : public QObject
{
Q_OBJECT
public slots:
inline void dummySlot() {}
inline void dummySlot2(void) {}
inline void anotherSlot(const TestTemplate<void> &) {}
inline TestTemplate<void> mySlot() { return TestTemplate<void>(); }
signals:
void mySignal(const TestTemplate<void> &);
void myVoidSignal();
void myVoidSignal2(void);
};
#endif // SLOTS_WITH_VOID_TEMPLATE_H

View File

@ -0,0 +1 @@
#define FOO 1

View File

@ -0,0 +1,21 @@
// 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 TASK192552_H
#define TASK192552_H
/*
<:: is not valid C++, but we want moc to treat it as < :: since this
is usually the intention
*/
#include <qobject.h>
class Task192552 : public QObject
{
Q_OBJECT
public:
#ifdef Q_MOC_RUN
QList<::QObject*> m_objects;
#endif
};
#endif // TASK192552_H

View File

@ -0,0 +1,39 @@
// 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 TASK234909_H
#define TASK234909_H
#include <qobject.h>
namespace NS_A {
namespace NS_B {
/*/
{
*/
class TestObject : public QObject {
Q_OBJECT
public:
};
}
}
namespace NS_A {
namespace NS_Main {
class TestMain : public QObject {
Q_OBJECT
public:
};
}
}
#endif // TASK234909_H

View File

@ -0,0 +1,34 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
// moc parsing issue with "unsigned" subphrase
#ifndef TASK240368_H
#define TASK240368_H
#include <QObject>
typedef struct { unsigned _1; } unsigned1;
typedef struct { unsigned qi; } unsignedQImage;
class TypenameWithUnsigned : public QObject {
Q_OBJECT
public slots:
void a(unsigned) { }
void b(unsigned u) { Q_UNUSED(u); }
void c(unsigned*) { }
void d(unsigned* p) { Q_UNUSED(p); }
void e(unsigned&) { }
void f(unsigned& r) { Q_UNUSED(r); }
void g(unsigned1) { }
void h(unsigned1 u1) { Q_UNUSED(u1); }
void i(unsigned,unsigned1) { }
void j(unsigned1,unsigned) { }
void k(unsignedQImage) { }
void l(unsignedQImage uqi) { Q_UNUSED(uqi); }
};
#endif

View File

View File

@ -0,0 +1,23 @@
// 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 TASK87883_H
#define TASK87883_H
/*
The bug is triggered only if there is a multiline comment after an #include
statement that in the following line contains a single quote but lacks a finishing
quote. So Moc tries to find the end quote, doesn't find it and by the skips over the
everything, including important class declarations :)
*/
#include <qobject.h> /* blah
foo ' bar */
class Task87883 : public QObject
{
Q_OBJECT
public:
inline Task87883() {}
};
#endif // TASK87883_H

View File

@ -0,0 +1,26 @@
// 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 TEMPLATE_GTGT_H
#define TEMPLATE_GTGT_H
template<class TYPE, size_t COUNT>
class myTemplate :
QString,
QList<TYPE, QList<COUNT>>
{};
template<class TYPE, size_t COUNT>
class myTemplate2 :
QString,
QList<TYPE, QList< (4 >> 2) >>
{};
class Widget : public QWidget
{
Q_OBJECT
public:
Widget()
{
}
};
#endif // TEMPLATE_GTGT_H

View File

@ -0,0 +1,14 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QObject>
struct MyInterface
{
virtual void blah() = 0;
};
QT_BEGIN_NAMESPACE
Q_DECLARE_INTERFACE(MyInterface, "MyInterface")
QT_END_NAMESPACE

View File

@ -0,0 +1 @@
#include "../Plugin/Plugin.h"

View File

@ -0,0 +1,29 @@
// 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 TRIGRAPHS_H
#define TRIGRAPHS_H
#include <QObject>
namespace AAA {
struct BaseA {};
}
namespace BBB {
class Foo : public QObject, public ::AAA::BaseA
{
Q_OBJECT
Q_SIGNALS:
// don't turn "> >" into ">>"
void foo(QList<QList<int> >);
void foo2(const QList<QList<int> > &);
// don't turn "< :" into "<:"
void bar(QList< ::AAA::BaseA*>);
void bar2(const QList< ::AAA::BaseA*> &);
void bar3(QList< ::AAA::BaseA const*>);
};
}
#endif // TRIGRAPHS_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
// 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 UNTERMINATED_FUNCTION_MACRO_H
#define UNTERMINATED_FUNCTION_MACRO_H
class Dummy : public QObject {
Q_OBJECT
}
#define MACRO(arg) do_something(arg)
static void foo() {
MACRO(foo
}
#endif // UNTERMINATED_FUNCTION_MACRO_H

View File

@ -0,0 +1,22 @@
// 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 USING_NAMESPACES_H
#define USING_NAMESPACES_H
namespace Foo {}
namespace Bar
{
namespace Huh
{
}
}
namespace Top
{
}
using namespace Foo;
using namespace Bar::Huh;
using namespace ::Top;
#endif // USING_NAMESPACES_H

View File

@ -0,0 +1,21 @@
// 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 WARN_ON_MULTIPLE_QOBJECT_SUBCLASSES_H
#define WARN_ON_MULTIPLE_QOBJECT_SUBCLASSES_H
#include <QtGui>
class Foo : public QObject
{
Q_OBJECT
public:
};
class Bar : public QWindow, public Foo
{
Q_OBJECT
};
#endif // WARN_ON_MULTIPLE_QOBJECT_SUBCLASSES_H

View File

@ -0,0 +1,14 @@
// 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 WARN_ON_PROPERTY_WITHOUT_READ_H
#define WARN_ON_PROPERTY_WITHOUT_READ_H
#include <QObject>
class ClassWithPropertyWithoutREAD : public QObject
{
Q_OBJECT
Q_PROPERTY(int foo)
Q_PROPERTY(int bar READ bar)
};
#endif // WARN_ON_PROPERTY_WITHOUT_READ_H

View File

@ -0,0 +1,11 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QObject>
class WinNewlines : public QObject
{
Q_OBJECT
public Q_SLOTS:
inline void testSlot() {}
};

View File

@ -0,0 +1,27 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qdbuscpp2xml Test:
#####################################################################
qt_internal_add_test(tst_qdbuscpp2xml
SOURCES
test1.h
tst_qdbuscpp2xml.cpp
LIBRARIES
Qt::DBus
)
# Resources:
set(qdbuscpp2xml_resource_files
"test1.h"
)
qt_internal_add_resource(tst_qdbuscpp2xml "qdbuscpp2xml"
PREFIX
"/tst_qdbuscpp2xml/"
FILES
${qdbuscpp2xml_resource_files}
)

View File

@ -0,0 +1,102 @@
// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef QDBUSCPP2XML_TEST1_H
#define QDBUSCPP2XML_TEST1_H
#include <QObject>
#include <QtDBus/QDBusSignature>
#include <QtDBus/QDBusObjectPath>
#include <QtDBus/QDBusUnixFileDescriptor>
class Test1 : public QObject
{
Q_OBJECT
Q_MOC_INCLUDE(<QtDBus/qdbusextratypes.h>)
Q_MOC_INCLUDE(<QtDBus/qdbusunixfiledescriptor.h>)
Q_CLASSINFO("D-Bus Interface", "org.qtProject.qdbuscpp2xmlTests.Test1")
Q_PROPERTY(int numProperty1 READ numProperty1 CONSTANT)
Q_PROPERTY(int numProperty2 READ numProperty2 WRITE setNumProperty2)
Q_ENUMS(Salaries)
public:
// C++1y allows use of single quote as a digit separator, useful for large
// numbers. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf
// Ensure that qdbuscpp2xml does not get confused with this appearing.
enum Salaries {
Steve
#ifdef Q_MOC_RUN
= 1'234'567
#endif
};
Test1(QObject *parent = nullptr) : QObject(parent) {}
int numProperty1() { return 42; }
int numProperty2() { return 42; }
void setNumProperty2(int) {}
signals:
void signalVoidType();
int signalIntType();
void signal_primitive_args(int a1, bool a2, short a3, ushort a4, uint a5, qlonglong a6, double a7, qlonglong a8 = 0);
void signal_string_args(const QByteArray &ba, const QString &a2);
void signal_Qt_args1(const QDate &a1, const QTime &a2, const QDateTime &a3,
const QRect &a4, const QRectF &a5, const QSize &a6, const QSizeF &a7);
void signal_Qt_args2(const QPoint &a1, const QPointF &a2, const QLine &a3, const QLineF &a4,
const QVariantList &a5, const QVariantMap &a6, const QVariantHash &a7);
void signal_QDBus_args(const QDBusObjectPath &a1, const QDBusSignature &a2, const QDBusUnixFileDescriptor &a3);
void signal_container_args1(const QList<bool> &a1, const QList<short> &a2, const QList<ushort> &a3, const QList<int> &a4, const QList<uint> &a5);
void signal_container_args2(const QList<qlonglong> &a1, const QList<qulonglong> &a2, const QList<double> &a3, const QList<QDBusObjectPath> &a4, const QList<QDBusSignature> &a5, const QList<QDBusUnixFileDescriptor> &a6);
Q_SCRIPTABLE void signalVoidType_scriptable();
Q_SCRIPTABLE int signalIntType_scriptable();
Q_SCRIPTABLE void signal_primitive_args_scriptable(int a1, bool a2, short a3, ushort a4, uint a5, qlonglong a6, double a7, qlonglong a8 = 0);
Q_SCRIPTABLE void signal_string_args_scriptable(const QByteArray &ba, const QString &a2);
Q_SCRIPTABLE void signal_Qt_args1_scriptable(const QDate &a1, const QTime &a2, const QDateTime &a3,
const QRect &a4, const QRectF &a5, const QSize &a6, const QSizeF &a7);
Q_SCRIPTABLE void signal_Qt_args2_scriptable(const QPoint &a1, const QPointF &a2, const QLine &a3, const QLineF &a4,
const QVariantList &a5, const QVariantMap &a6, const QVariantHash &a7);
Q_SCRIPTABLE void signal_QDBus_args_scriptable(const QDBusObjectPath &a1, const QDBusSignature &a2, const QDBusUnixFileDescriptor &a3);
Q_SCRIPTABLE void signal_container_args1_scriptable(const QList<bool> &a1, const QList<short> &a2, const QList<ushort> &a3, const QList<int> &a4, const QList<uint> &a5);
Q_SCRIPTABLE void signal_container_args2_scriptable(const QList<qlonglong> &a1, const QList<qulonglong> &a2, const QList<double> &a3, const QList<QDBusObjectPath> &a4, const QList<QDBusSignature> &a5, const QList<QDBusUnixFileDescriptor> &a6);
public slots:
void slotVoidType() {}
int slotIntType() { return 42; }
Q_SCRIPTABLE void slotVoidType_scriptable() {}
Q_SCRIPTABLE int slotIntType_scriptable() { return 42; }
protected slots:
void neverExported1() {}
int neverExported2() { return 42; }
Q_SCRIPTABLE void neverExported3() {}
Q_SCRIPTABLE int neverExported4() { return 42; }
private slots:
void neverExported5() {}
int neverExported6() { return 42; }
Q_SCRIPTABLE void neverExported7() {}
Q_SCRIPTABLE int neverExported8() { return 42; }
public:
Q_SCRIPTABLE void methodVoidType() {}
Q_SCRIPTABLE int methodIntType() { return 42; }
protected:
Q_SCRIPTABLE void neverExported9() {}
Q_SCRIPTABLE int neverExported10() { return 42; }
private:
Q_SCRIPTABLE void neverExported11() {}
Q_SCRIPTABLE int neverExported12() { return 42; }
};
#endif

View File

@ -0,0 +1,146 @@
// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
#include <QLibraryInfo>
#include <QProcess>
#include "test1.h"
#include <QtDBus/QDBusConnection>
// in qdbusxmlgenerator.cpp
QT_BEGIN_NAMESPACE
extern Q_DBUS_EXPORT QString qDBusGenerateMetaObjectXml(QString interface,
const QMetaObject *mo,
const QMetaObject *base,
int flags);
QT_END_NAMESPACE
static QString addXmlHeader(const QString &input)
{
return
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" \"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n<node>"
+ (input.isEmpty() ? QString() : QString("\n " + input.trimmed()))
+ "\n</node>\n";
}
class tst_qdbuscpp2xml : public QObject
{
Q_OBJECT
private slots:
void qdbuscpp2xml_data();
void qdbuscpp2xml();
void initTestCase();
void cleanupTestCase();
private:
QHash<QString, QObject*> m_tests;
};
void tst_qdbuscpp2xml::initTestCase()
{
m_tests.insert("test1", new Test1);
}
void tst_qdbuscpp2xml::cleanupTestCase()
{
qDeleteAll(m_tests);
}
void tst_qdbuscpp2xml::qdbuscpp2xml_data()
{
QTest::addColumn<QString>("inputfile");
QTest::addColumn<int>("flags");
QBitArray doneFlags(int(QDBusConnection::ExportAllContents) + 1);
for (int flag = 0x10; flag < QDBusConnection::ExportScriptableContents; flag += 0x10) {
QTest::newRow("xmlgenerator-" + QByteArray::number(flag)) << "test1" << flag;
doneFlags.setBit(flag);
for (int mask = QDBusConnection::ExportAllSlots; mask <= QDBusConnection::ExportAllContents; mask += 0x110) {
int flags = flag | mask;
if (doneFlags.testBit(flags))
continue;
QTest::newRow("xmlgenerator-" + QByteArray::number(flags)) << "test1" << flags;
doneFlags.setBit(flags);
}
}
}
void tst_qdbuscpp2xml::qdbuscpp2xml()
{
QFETCH(QString, inputfile);
QFETCH(int, flags);
// qdbuscpp2xml considers these equivalent
if (flags & QDBusConnection::ExportScriptableSlots)
flags |= QDBusConnection::ExportScriptableInvokables;
if (flags & QDBusConnection::ExportNonScriptableSlots)
flags |= QDBusConnection::ExportNonScriptableInvokables;
if (flags & QDBusConnection::ExportScriptableInvokables)
flags |= QDBusConnection::ExportScriptableSlots;
if (flags & QDBusConnection::ExportNonScriptableInvokables)
flags |= QDBusConnection::ExportNonScriptableSlots;
QStringList options;
if (flags & QDBusConnection::ExportScriptableProperties) {
if (flags & QDBusConnection::ExportNonScriptableProperties)
options << "-P";
else
options << "-p";
}
if (flags & QDBusConnection::ExportScriptableSignals) {
if (flags & QDBusConnection::ExportNonScriptableSignals)
options << "-S";
else
options << "-s";
}
if (flags & QDBusConnection::ExportScriptableSlots) {
if (flags & QDBusConnection::ExportNonScriptableSlots)
options << "-M";
else
options << "-m";
}
// Launch
const QString binpath = QLibraryInfo::path(QLibraryInfo::BinariesPath);
const QString command = binpath + QLatin1String("/qdbuscpp2xml");
QProcess process;
process.start(command, QStringList() << options << (QFINDTESTDATA(inputfile + QStringLiteral(".h"))));
if (!process.waitForFinished()) {
const QString path = QString::fromLocal8Bit(qgetenv("PATH"));
QString message = QString::fromLatin1("'%1' could not be found when run from '%2'. Path: '%3' ").
arg(command, QDir::currentPath(), path);
QFAIL(qPrintable(message));
}
const QChar cr = QLatin1Char('\r');
const QString err = QString::fromLocal8Bit(process.readAllStandardError()).remove(cr);
const QString out = QString::fromLatin1(process.readAllStandardOutput()).remove(cr);
if (!err.isEmpty()) {
qDebug() << "UNEXPECTED STDERR CONTENTS: " << err;
QFAIL("UNEXPECTED STDERR CONTENTS");
}
const QChar nl = QLatin1Char('\n');
const QStringList actualLines = out.split(nl);
QObject *testObject = m_tests.value(inputfile);
if (flags == 0)
flags = QDBusConnection::ExportScriptableContents
| QDBusConnection::ExportNonScriptableContents;
QString expected = qDBusGenerateMetaObjectXml(QString(), testObject->metaObject(), &QObject::staticMetaObject, flags);
expected = addXmlHeader(expected);
QCOMPARE(out, expected);
}
QTEST_APPLESS_MAIN(tst_qdbuscpp2xml)
#include "tst_qdbuscpp2xml.moc"

View File

@ -0,0 +1,11 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qdbusxml2cpp Test:
#####################################################################
qt_internal_add_test(tst_qdbusxml2cpp
SOURCES
tst_qdbusxml2cpp.cpp
)

View File

@ -0,0 +1,431 @@
// Copyright (C) 2016 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
#include <QLibraryInfo>
#include <QtCore/QProcess>
#include <QtCore/QRegularExpression>
// We just need the DBUS_TYPE_* constants, so use our own copy
#include "../../../../src/dbus/dbus_minimal_p.h"
class tst_qdbusxml2cpp : public QObject
{
Q_OBJECT
enum { Interface, Adaptor };
private slots:
void initTestCase_data();
void process_data();
void process();
void includeStyle_data();
void includeStyle();
void missingAnnotation_data();
void missingAnnotation();
void includeMoc_data();
void includeMoc();
};
struct BasicTypeList {
char dbusType[3];
char cppType[24];
};
static const BasicTypeList basicTypeList[] =
{
{ DBUS_TYPE_BOOLEAN_AS_STRING, "bool" },
{ DBUS_TYPE_BYTE_AS_STRING, "uchar" },
{ DBUS_TYPE_INT16_AS_STRING, "short" },
{ DBUS_TYPE_UINT16_AS_STRING, "ushort" },
{ DBUS_TYPE_INT32_AS_STRING, "int" },
{ DBUS_TYPE_UINT32_AS_STRING, "uint" },
{ DBUS_TYPE_INT64_AS_STRING, "qlonglong" },
{ DBUS_TYPE_UINT64_AS_STRING, "qulonglong" },
{ DBUS_TYPE_DOUBLE_AS_STRING, "double" },
{ DBUS_TYPE_STRING_AS_STRING, "QString" },
{ DBUS_TYPE_OBJECT_PATH_AS_STRING, "QDBusObjectPath" },
{ DBUS_TYPE_SIGNATURE_AS_STRING, "QDBusSignature" },
#ifdef DBUS_TYPE_UNIX_FD_AS_STRING
{ DBUS_TYPE_UNIX_FD_AS_STRING, "QDBusUnixFileDescriptor" },
#endif
{ DBUS_TYPE_VARIANT_AS_STRING, "QDBusVariant" },
{ DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING, "QByteArray" },
{ DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING, "QStringList" },
{ DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_VARIANT_AS_STRING, "QVariantList" }
};
static const int basicTypeCount = sizeof(basicTypeList) / sizeof(basicTypeList[0]);
static QString stripHeader(QString output)
{
static QRegularExpression header("^.*?(?=\\Rclass)", QRegularExpression::DotMatchesEverythingOption);
return output.remove(header);
}
static void runTool(QProcess &process, const QByteArray &data,
const QStringList &flags)
{
// test both interface and adaptor generation
QFETCH_GLOBAL(QString, commandLineArg);
// Run the tool
const QString binpath = QLibraryInfo::path(QLibraryInfo::BinariesPath);
QStringList arguments = { commandLineArg };
arguments += flags;
process.setArguments(arguments);
process.setProgram(binpath + QLatin1String("/qdbusxml2cpp"));
process.start(QIODevice::Text | QIODevice::ReadWrite);
QVERIFY2(process.waitForStarted(), qPrintable(process.errorString()));
static const char xmlHeader[] =
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE // \n is included
"<node>\n"
" <interface name=\"local.name.is.not.important\">\n"
" <!-- begin data -->\n";
static const char xmlFooter[] = "\n"
" <!-- end data -->\n"
" </interface>\n"
"</node>\n";
process.write(xmlHeader, sizeof(xmlHeader) - 1);
process.write(data);
process.write(xmlFooter, sizeof(xmlFooter) - 1);
while (process.bytesToWrite())
QVERIFY2(process.waitForBytesWritten(), qPrintable(process.errorString()));
// fprintf(stderr, "%s%s%s", xmlHeader, xmlSnippet.toLatin1().constData(), xmlFooter);
process.closeWriteChannel();
QVERIFY2(process.waitForFinished(), qPrintable(process.errorString()));
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
}
static void checkOneFile(const QString &fileName, const QByteArray &expected)
{
QFile file(fileName);
QVERIFY(file.exists());
const auto guard = QScopeGuard([&](){ QFile::remove(fileName); });
QVERIFY(file.open(QFile::Text | QFile::ReadOnly));
QByteArray text = file.readAll();
QVERIFY(text.contains(expected));
}
static void checkTwoFiles(const QString &headerName, const QString &sourceName, const QByteArray &expected)
{
QFile headerFile(headerName);
QFile sourceFile(sourceName);
QVERIFY(headerFile.exists());
const auto headerGuard = QScopeGuard([&](){ QFile::remove(headerName); });
QVERIFY(sourceFile.exists());
const auto sourceGuard = QScopeGuard([&](){ QFile::remove(sourceName); });
QVERIFY(sourceFile.open(QFile::Text | QFile::ReadOnly));
QByteArray text = sourceFile.readAll();
QVERIFY(text.contains(expected));
}
void tst_qdbusxml2cpp::initTestCase_data()
{
QTest::addColumn<int>("outputMode");
QTest::addColumn<QString>("commandLineArg");
QTest::newRow("interface") << int(Interface) << "-p";
QTest::newRow("adaptor") << int(Adaptor) << "-a";
}
void tst_qdbusxml2cpp::process_data()
{
QTest::addColumn<QString>("xmlSnippet");
QTest::addColumn<QRegularExpression>("interfaceSearch");
QTest::addColumn<QRegularExpression>("adaptorSearch");
// -- class info --
QTest::newRow("classinfo")
<< ""
<< QRegularExpression("staticInterfaceName\\(\\)\\s+"
"{ return \"local\\.name\\.is\\.not\\.important\"\\; }")
<< QRegularExpression("Q_CLASSINFO\\(\"D-Bus Interface\", \"local\\.name\\.is\\.not\\.important\"\\)");
// -- properties --
for (int i = 0; i < basicTypeCount; ++i) {
QRegularExpression rx(QString("\\bQ_PROPERTY\\(%1 PropertyIsPresent "
"READ propertyIsPresent WRITE setPropertyIsPresent\\b")
.arg(basicTypeList[i].cppType));
QTest::newRow(QByteArray("property-") + basicTypeList[i].dbusType)
<< QString("<property type=\"%1\" name=\"PropertyIsPresent\" access=\"readwrite\" />")
.arg(basicTypeList[i].dbusType)
<< rx << rx;
}
QTest::newRow("property-readonly-multi")
<< "<property type=\"i\" name=\"Value\" access=\"read\"></property>"
<< QRegularExpression("\\bQ_PROPERTY\\(int Value READ value(?! WRITE)")
<< QRegularExpression("\\bQ_PROPERTY\\(int Value READ value(?! WRITE)");
QTest::newRow("property-readonly")
<< "<property type=\"i\" name=\"Value\" access=\"read\" />"
<< QRegularExpression("\\bQ_PROPERTY\\(int Value READ value(?! WRITE)")
<< QRegularExpression("\\bQ_PROPERTY\\(int Value READ value(?! WRITE)");
QTest::newRow("property-writeonly")
<< "<property type=\"i\" name=\"Value\" access=\"write\" />"
<< QRegularExpression("\\bQ_PROPERTY\\(int Value WRITE setValue\\b")
<< QRegularExpression("\\bQ_PROPERTY\\(int Value WRITE setValue\\b");
QTest::newRow("property-getter-setter")
<< "<property type=\"b\" name=\"Enabled\" access=\"readwrite\">"
"<annotation name=\"org.qtproject.QtDBus.PropertyGetter\" value=\"wasEnabled\" />"
"<annotation name=\"org.qtproject.QtDBus.PropertySetter\" value=\"setEnabledFlag\" />"
"</property>"
<< QRegularExpression("\\bQ_PROPERTY\\(bool Enabled READ wasEnabled WRITE setEnabledFlag\\b.*"
"\\bbool wasEnabled\\(\\) const.*" // no semi-colon
"\\bvoid setEnabledFlag\\(bool", QRegularExpression::DotMatchesEverythingOption)
<< QRegularExpression("\\bQ_PROPERTY\\(bool Enabled READ wasEnabled WRITE setEnabledFlag\\b.*"
"\\bbool wasEnabled\\(\\) const;.*" // has semi-colon
"\\bvoid setEnabledFlag\\(bool", QRegularExpression::DotMatchesEverythingOption);
QTest::newRow("property-complex")
<< "<property type=\"(ii)\" name=\"Position\" access=\"readwrite\">"
"<annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"Point\"/>"
"</property>"
<< QRegularExpression("\\bQ_PROPERTY\\(Point Position READ position WRITE setPosition\\b")
<< QRegularExpression("\\bQ_PROPERTY\\(Point Position READ position WRITE setPosition\\b");
// -- methods --
for (int i = 0; i < basicTypeCount; ++i) {
QTest::newRow(QByteArray("method-") + basicTypeList[i].dbusType)
<< QString("<method name=\"Method\">"
"<arg type=\"%1\" direction=\"out\"/>"
"<arg type=\"%1\" direction=\"in\"/>"
"</method>")
.arg(basicTypeList[i].dbusType)
<< QRegularExpression(QString("Q_SLOTS:.*\\bQDBusPendingReply<%1> Method\\((const )?%1 ")
.arg(basicTypeList[i].cppType), QRegularExpression::DotMatchesEverythingOption)
<< QRegularExpression(QString("Q_SLOTS:.*\\b%1 Method\\((const )?%1 ")
.arg(basicTypeList[i].cppType), QRegularExpression::DotMatchesEverythingOption);
}
QTest::newRow("method-name")
<< "<method name=\"Method\">"
"<arg type=\"s\" direction=\"in\"/>"
"<annotation name=\"org.qtproject.QtDBus.MethodName\" value=\"MethodRenamed\" />"
"</method>"
<< QRegularExpression("Q_SLOTS:.*QDBusPendingReply<> MethodRenamed\\(const QString &\\w*",
QRegularExpression::DotMatchesEverythingOption)
<< QRegularExpression("Q_SLOTS:.*void MethodRenamed\\(const QString &\\w*",
QRegularExpression::DotMatchesEverythingOption);
QTest::newRow("method-complex")
<< "<method name=\"Method\">"
"<arg type=\"(dd)\" direction=\"in\"/>"
"<arg type=\"(ii)\" direction=\"out\"/>"
"<annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"Point\"/>"
"<annotation name=\"org.qtproject.QtDBus.QtTypeName.In0\" value=\"PointF\"/>"
"</method>"
<< QRegularExpression("Q_SLOTS:.*\\bQDBusPendingReply<Point> Method\\(PointF ",
QRegularExpression::DotMatchesEverythingOption)
<< QRegularExpression("Q_SLOTS:.*\\bPoint Method\\(PointF ",
QRegularExpression::DotMatchesEverythingOption);
QTest::newRow("method-ss")
<< "<method name=\"Method\">"
"<arg type=\"s\" direction=\"in\"/>"
"<arg type=\"s\" direction=\"in\"/>"
"<arg type=\"s\" direction=\"out\"/>"
"<arg type=\"s\" direction=\"out\"/>"
"</method>"
<< QRegularExpression("Q_SLOTS:.*QDBusPendingReply<QString, QString> Method\\(const QString &\\w*, const QString &\\w*\\)"
".*inline QDBusReply<QString> Method\\(const QString &\\w*, const QString &\\w*, QString &\\w*\\)",
QRegularExpression::DotMatchesEverythingOption)
<< QRegularExpression("Q_SLOTS:.*QString Method\\(const QString &\\w*, const QString &\\w*, QString &",
QRegularExpression::DotMatchesEverythingOption);
// -- signals --
for (int i = 0; i < basicTypeCount; ++i) {
QRegularExpression rx(QString("Q_SIGNALS:.*\\bvoid Signal\\((const )?%1\\b")
.arg(basicTypeList[i].cppType),
QRegularExpression::DotMatchesEverythingOption);
QTest::newRow(QByteArray("signal-") + basicTypeList[i].dbusType)
<< QString("<signal name=\"Signal\">"
"<arg type=\"%1\"/>"
"</signal>")
.arg(basicTypeList[i].dbusType)
<< rx << rx;
}
QRegularExpression rx(R"(Q_SIGNALS:.*\b\Qvoid Signal(const QVariantMap &map);\E)",
QRegularExpression::DotMatchesEverythingOption);
QTest::newRow("signal-complex")
<< R"(<signal name="Signal">
<arg type="a{sv}" name="map"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>"
</signal>)"
<< rx << rx;
}
void tst_qdbusxml2cpp::process()
{
QFETCH(QString, xmlSnippet);
QFETCH(QRegularExpression, interfaceSearch);
QFETCH(QRegularExpression, adaptorSearch);
QVERIFY2(interfaceSearch.isValid(), qPrintable(interfaceSearch.errorString()));
QVERIFY2(adaptorSearch.isValid(), qPrintable(adaptorSearch.errorString()));
QFETCH_GLOBAL(int, outputMode);
QProcess process;
QStringList flags = {"-", "-N"};
runTool(process, xmlSnippet.toLatin1(), flags);
if (QTest::currentTestFailed()) return;
QByteArray errOutput = process.readAllStandardError();
QVERIFY2(errOutput.isEmpty(), errOutput);
QCOMPARE(process.exitCode(), 0);
QByteArray fullOutput = process.readAll();
QString output = stripHeader(QString::fromLatin1(fullOutput));
QVERIFY2(!output.isEmpty(), fullOutput);
if (outputMode == Interface)
QVERIFY2(output.count(interfaceSearch) == 1, qPrintable(interfaceSearch.pattern() + "\nin\n" + output));
else
QVERIFY2(output.count(adaptorSearch) == 1, qPrintable(adaptorSearch.pattern() + "\nin\n" + output));
}
void tst_qdbusxml2cpp::includeStyle_data()
{
QTest::addColumn<bool>("isGlobal");
QTest::addColumn<QByteArray>("expected");
QTest::newRow("localInclude") << false << QByteArray("#include \"test.hpp\"");
QTest::newRow("globalInclude") << true << QByteArray("#include <test.hpp>");
}
void tst_qdbusxml2cpp::includeStyle()
{
QFETCH(bool, isGlobal);
QFETCH(QByteArray, expected);
QProcess process;
QStringList flags = {"-", "-N", (isGlobal ? "-I" : "-i"), "test.hpp"};
runTool(process,QByteArray{},flags);
QCOMPARE(process.exitCode(), 0);
QByteArray errOutput = process.readAllStandardError();
QVERIFY2(errOutput.isEmpty(), errOutput);
QByteArray fullOutput = process.readAll();
QVERIFY(!fullOutput.isEmpty());
QVERIFY(fullOutput.contains(expected));
}
void tst_qdbusxml2cpp::missingAnnotation_data()
{
QTest::addColumn<QString>("xmlSnippet");
QTest::addColumn<QString>("annotationName");
QTest::newRow("property")
<< R"(<property type="%1" name="name" access="readwrite"/>)"
<< "org.qtproject.QtDBus.QtTypeName";
QTest::newRow("method-in")
<< R"(<method name="Method">
<arg type="%1" name="name" direction="in"/>
</method>)"
<< "org.qtproject.QtDBus.QtTypeName.In0";
QTest::newRow("method-out")
<< R"(<method name="Method">
<arg type="%1" name="name" direction="out"/>
</method>)"
<< "org.qtproject.QtDBus.QtTypeName.Out0";
QTest::newRow("signal")
<< R"(<signal name="Signal">
<arg type="%1" name="name"/>
</signal>)"
<< "org.qtproject.QtDBus.QtTypeName.Out0";
QTest::newRow("signal-out")
<< R"(<signal name="Signal">
<arg type="%1" name="name" direction="out"/>
</signal>)"
<< "org.qtproject.QtDBus.QtTypeName.Out0";
}
void tst_qdbusxml2cpp::missingAnnotation()
{
QFETCH(QString, xmlSnippet);
QFETCH(QString, annotationName);
QString type = "(ii)";
QProcess process;
QStringList flags = {"-", "-N"};
runTool(process, xmlSnippet.arg(type).toLatin1(),flags);
if (QTest::currentTestFailed()) return;
// it must have failed
QString errOutput = QString::fromLatin1(process.readAllStandardError().trimmed());
QCOMPARE(process.exitCode(), 1);
QCOMPARE(process.readAllStandardOutput(), QByteArray());
QVERIFY(!errOutput.isEmpty());
// check it did suggest the right annotation
QString expected = R"(qdbusxml2cpp: Got unknown type `%1' processing ''
You should add <annotation name="%2" value="<type>"/> to the XML description for 'name')";
expected = expected.arg(type, annotationName);
QCOMPARE(errOutput, expected);
}
void tst_qdbusxml2cpp::includeMoc_data()
{
QTest::addColumn<QString>("filenames");
QTest::addColumn<QByteArray>("expected");
QTest::addColumn<QByteArray>("warning");
QTest::newRow("combined-h") << "foo.h" << QByteArray("#include \"foo.moc\"") << QByteArray("");
QTest::newRow("combined-cpp") << "foo.cpp" << QByteArray("#include \"foo.moc\"") << QByteArray("");
QTest::newRow("combined-cc") << "foo.cc" << QByteArray("#include \"foo.moc\"") << QByteArray("");
QTest::newRow("without extension") << "foo" << QByteArray("#include \"moc_foo.cpp\"") << QByteArray("");
QTest::newRow("cpp-only") << ":foo.cpp" << QByteArray("#include \"moc_foo.cpp\"")
<< QByteArray("warning: no header name is provided, assuming it to be \"foo.h\"");
QTest::newRow("header-and-cpp") << "foo_h.h:foo.cpp" << QByteArray("#include \"moc_foo_h.cpp\"") << QByteArray("");
QTest::newRow("combined-cpp with dots") << "foo.bar.cpp" << QByteArray("#include \"foo.bar.moc\"") << QByteArray("");
QTest::newRow("without extension with dots") << "foo.bar" << QByteArray("#include \"moc_foo.bar.cpp\"") << QByteArray("");
QTest::newRow("header-and-cpp with dots") << "foo.bar_h.h:foo.bar.cpp" << QByteArray("#include \"moc_foo.bar_h.cpp\"") << QByteArray("");
}
void tst_qdbusxml2cpp::includeMoc()
{
QFETCH(QString, filenames);
QFETCH(QByteArray, expected);
QFETCH(QByteArray, warning);
QProcess process;
QStringList flags = {filenames, "--moc"};
runTool(process,QByteArray{},flags);
QByteArray errOutput = process.readAllStandardError();
QVERIFY(errOutput.startsWith(warning));
QCOMPARE(process.exitCode(), 0);
QStringList parts = filenames.split(u':');
QFileInfo first{parts.first()};
const bool firstHasSuffix = QStringList({"h", "cpp", "cc"}).contains(first.suffix());
if ((parts.size() == 1) && firstHasSuffix) {
checkOneFile(parts.first(), expected);
} else if ((parts.size() == 1) && (!firstHasSuffix)) {
QString headerName{parts.first()};
headerName += ".h";
QString sourceName{parts.first()};
sourceName += ".cpp";
checkTwoFiles(headerName, sourceName, expected);
} else if ((parts.size() == 2) && (parts.first().isEmpty())) {
checkOneFile(parts.last(), expected);
}
else if ((parts.size() == 2) && !parts.first().isEmpty() && !parts.last().isEmpty()) {
checkTwoFiles(parts.first(), parts.last(), expected);
}
}
QTEST_MAIN(tst_qdbusxml2cpp)
#include "tst_qdbusxml2cpp.moc"

View File

@ -0,0 +1,34 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
testdata/*)
list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qmake
SOURCES
testcompiler.cpp testcompiler.h
tst_qmake.cpp
TESTDATA ${test_data}
)
set(dependencies
Qt::moc
Qt::qmake
)
if(TARGET Qt::Gui)
list(APPEND dependencies Qt::Gui)
endif()
if(TARGET Qt::Widgets)
list(APPEND dependencies Qt::Widgets)
endif()
if(TARGET Qt::rcc)
list(APPEND dependencies Qt::rcc)
endif()
if(TARGET Qt::uic)
list(APPEND dependencies Qt::uic)
endif()
# Add dependencies that are implicitly used inside the test
add_dependencies(tst_qmake ${dependencies})

View File

@ -0,0 +1,322 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "testcompiler.h"
#include <QProcess>
#include <QDir>
QString TestCompiler::targetName(BuildType buildMode, const QString& target, const QString& version)
{
Q_UNUSED(version);
QString targetName = target;
#if defined (Q_OS_WIN32)
switch (buildMode)
{
case Exe: // app
targetName.append(".exe");
break;
case Dll: // dll
if (!version.isEmpty())
targetName.append(version.section(".", 0, 0));
targetName.append(".dll");
break;
case Lib: // lib
#ifdef Q_CC_GNU
targetName.prepend("lib");
targetName.append(".a");
#else
targetName.append(".lib");
#endif
break;
case Plain:
// no conversion
break;
}
#elif defined( Q_OS_MAC )
switch (buildMode)
{
case Exe: // app
targetName += ".app/Contents/MacOS/" + target.section('/', -1);
break;
case Dll: // dll
targetName.prepend("lib");
if (!version.isEmpty())
targetName.append('.' + version);
targetName.append(".dylib");
break;
case Lib: // lib
targetName.prepend("lib");
targetName.append(".a");
break;
case Plain:
// no conversion
break;
}
#else
switch (buildMode)
{
case Exe: // app
break;
case Dll: // dll
targetName.prepend("lib");
#if defined (Q_OS_HPUX) && !defined (__ia64)
targetName.append(".sl");
#elif defined (Q_OS_AIX)
targetName.append(".a");
#else
targetName.append(".so");
#endif
break;
case Lib: // lib
targetName.prepend("lib");
targetName.append(".a");
break;
case Plain:
// no conversion
break;
}
#endif
return targetName;
}
TestCompiler::TestCompiler()
{
setBaseCommands( "", "" );
}
TestCompiler::~TestCompiler()
{
}
bool TestCompiler::errorOut()
{
qDebug("%s", qPrintable(testOutput_.join(QStringLiteral("\n"))));
return false;
}
// Return the system environment, remove MAKEFLAGS variable in
// case the CI uses jom passing flags incompatible to nmake
// or vice versa.
static inline QStringList systemEnvironment()
{
#ifdef Q_OS_WIN
static QStringList result;
if (result.isEmpty()) {
foreach (const QString &variable, QProcess::systemEnvironment()) {
if (variable.startsWith(QStringLiteral("MAKEFLAGS="), Qt::CaseInsensitive)) {
qWarning("Removing environment setting '%s'", qPrintable(variable));
} else {
result.push_back(variable);
}
}
}
#else
static const QStringList result = QProcess::systemEnvironment();
#endif // ifdef Q_OS_WIN
return result;
}
bool TestCompiler::runCommand(const QString &cmd, const QStringList &args, bool expectFail)
{
QString dbg = cmd;
if (dbg.contains(' '))
dbg.prepend('"').append('"');
foreach (QString arg, args) {
if (arg.contains(' '))
arg.prepend('"').append('"');
dbg.append(' ').append(arg);
}
testOutput_.append("Running command: " + dbg);
QProcess child;
child.setEnvironment(systemEnvironment() + environment_);
child.start(cmd, args);
if (!child.waitForStarted(-1)) {
testOutput_.append( "Unable to start child process." );
return errorOut();
}
child.waitForFinished(-1);
bool ok = child.exitStatus() == QProcess::NormalExit && (expectFail ^ (child.exitCode() == 0));
for (auto channel : { QProcess::StandardOutput, QProcess::StandardError }) {
child.setReadChannel(channel);
while (!child.atEnd()) {
const QString output = QString::fromLocal8Bit(child.readLine());
if (output.startsWith("Project MESSAGE: FAILED"))
ok = false;
testOutput_.append(output);
}
}
return ok ? true : errorOut();
}
void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd )
{
makeCmd_ = makeCmd;
qmakeCmd_ = qmakeCmd;
}
void TestCompiler::resetArguments()
{
makeArgs_.clear();
qmakeArgs_.clear();
}
void TestCompiler::setArguments(const QStringList &makeArgs, const QStringList &qmakeArgs)
{
makeArgs_ = makeArgs;
qmakeArgs_ = qmakeArgs;
}
void TestCompiler::resetEnvironment()
{
environment_.clear();
}
void TestCompiler::addToEnvironment( QString varAssignment )
{
environment_.push_back(varAssignment);
}
bool TestCompiler::makeClean( const QString &workPath )
{
QDir D;
if (!D.exists(workPath)) {
testOutput_.append( "Directory '" + workPath + "' doesn't exist" );
return errorOut();
}
D.setCurrent(workPath);
QFileInfo Fi( workPath + "/Makefile");
if (Fi.exists())
// Run make clean
return runCommand(makeCmd_, QStringList() << "clean");
return true;
}
bool TestCompiler::makeDistClean( const QString &workPath )
{
QDir D;
if (!D.exists(workPath)) {
testOutput_.append( "Directory '" + workPath + "' doesn't exist" );
return errorOut();
}
D.setCurrent(workPath);
QFileInfo Fi( workPath + "/Makefile");
if (Fi.exists())
// Run make distclean
return runCommand(makeCmd_, QStringList() << "distclean");
return true;
}
bool TestCompiler::qmakeProject( const QString &workDir, const QString &proName )
{
QDir D;
if (!D.exists(workDir)) {
testOutput_.append( "Directory '" + workDir + "' doesn't exist" );
return errorOut();
}
D.setCurrent(workDir);
QString projectFile = proName;
if (!projectFile.endsWith(".pro"))
projectFile += ".pro";
return runCommand(qmakeCmd_, QStringList() << "-project" << "-o" << projectFile << "DESTDIR=./");
}
bool TestCompiler::qmake(const QString &workDir, const QString &proName, const QString &buildDir,
const QStringList &additionalArguments)
{
QDir D;
D.setCurrent( workDir );
if (D.exists("Makefile"))
D.remove("Makefile");
QString projectFile = proName;
QString makeFile = buildDir;
if (!projectFile.endsWith(".pro"))
projectFile += ".pro";
if (!makeFile.isEmpty() && !makeFile.endsWith('/'))
makeFile += '/';
makeFile += "Makefile";
// Now start qmake and generate the makefile
return runCommand(qmakeCmd_, QStringList(qmakeArgs_) << projectFile << "-o" << makeFile
<< additionalArguments);
}
bool TestCompiler::qmake(const QString &workDir, const QStringList &arguments)
{
QDir d;
d.setCurrent(workDir); // ### runCommand should take a workingDir argument instead
return runCommand(qmakeCmd_, arguments);
}
bool TestCompiler::make( const QString &workPath, const QString &target, bool expectFail )
{
QDir D;
D.setCurrent( workPath );
QStringList args = makeArgs_;
if (makeCmd_.contains("nmake", Qt::CaseInsensitive) ||
makeCmd_.contains("jom", Qt::CaseInsensitive)) {
args << "/NOLOGO";
}
if (!target.isEmpty())
args << target;
return runCommand(makeCmd_, args, expectFail);
}
bool TestCompiler::exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version )
{
QFileInfo f(destDir + QLatin1Char('/') + targetName(buildType, exeName, version));
return f.exists();
}
bool TestCompiler::removeMakefile( const QString &workPath )
{
return removeFile( workPath, "Makefile" );
}
bool TestCompiler::removeProject( const QString &workPath, const QString &project )
{
QString projectFile = project;
if (!projectFile.endsWith(".pro"))
projectFile += ".pro";
return removeFile( workPath, projectFile );
}
bool TestCompiler::removeFile( const QString &workPath, const QString &fileName )
{
QDir D;
D.setCurrent( workPath );
return ( D.exists( fileName ) ) ? D.remove( fileName ) : true;
}
QString TestCompiler::commandOutput() const
{
#ifndef Q_OS_WIN
return testOutput_.join("\n");
#else
return testOutput_.join("\r\n");
#endif
}
void TestCompiler::clearCommandOutput()
{
testOutput_.clear();
}

View File

@ -0,0 +1,73 @@
// 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 TESTCOMPILER_H
#define TESTCOMPILER_H
#include <QObject>
#include <QStringList>
enum BuildType { Exe, Dll, Lib, Plain };
class TestCompiler : public QObject
{
Q_OBJECT
public:
TestCompiler();
virtual ~TestCompiler();
void setBaseCommands( QString makeCmd, QString qmakeCmd );
void resetArguments();
void setArguments(const QStringList &makeArgs, const QStringList &qmakeArgs);
void resetEnvironment();
void addToEnvironment( QString varAssignment );
static QString targetName(BuildType buildMode, const QString& target, const QString& version);
// executes a make clean in the specified workPath
bool makeClean( const QString &workPath );
// executes a make dist clean in the specified workPath
bool makeDistClean( const QString &workPath );
// executes a qmake -project on the specified workDir
bool qmakeProject( const QString &workDir, const QString &proName );
// executes a qmake on proName in the specified workDir, output goes to buildDir or workDir if it's null
bool qmake(const QString &workDir, const QString &proName, const QString &buildDir = QString(),
const QStringList &additionalArguments = QStringList());
// executes qmake in workDir with the specified arguments
bool qmake(const QString &workDir, const QStringList &arguments);
// executes a make in the specified workPath, with an optional target (eg. install)
bool make( const QString &workPath, const QString &target = QString(), bool expectFail = false );
// checks if the executable exists in destDir
bool exists(const QString &destDir, const QString &exeName, BuildType buildType,
const QString &version = QString());
// removes the makefile
bool removeMakefile( const QString &workPath );
// removes the project file specified by 'project' on the 'workPath'
bool removeProject( const QString &workPath, const QString &project );
// removes the file specified by 'fileName' on the 'workPath'
bool removeFile( const QString &workPath, const QString &fileName );
// Returns each line of stdout/stderr of the last commands
// separated by platform-specific line endings.
QString commandOutput() const;
// clear the results of storage of stdout for running previous commands
void clearCommandOutput();
bool runCommand(const QString &cmd, const QStringList &args, bool expectFail = false);
private:
bool errorOut();
QString makeCmd_;
QStringList makeArgs_;
QString qmakeCmd_;
QStringList qmakeArgs_;
QStringList environment_;
QStringList testOutput_;
};
#endif // TESTCOMPILER_H

View File

@ -0,0 +1,7 @@
SOURCES += main.cpp
QWERTY_BUNDLE.version = Bogus.78
QWERTY_BUNDLE.files = some-file "existing file" "non-existing file"
QWERTY_BUNDLE.path = QwertyData
QMAKE_BUNDLE_DATA = QWERTY_BUNDLE

View File

View File

@ -0,0 +1,6 @@
all:
C:\git\qt-kinetic-animations\bin\qmake qdir.pro -o Makefile -spec win32-msvc2008
nmake -f Makefile
first: all
qmake:
C:\git\qt-kinetic-animations\bin\qmake qdir.pro -o Makefile -spec win32-msvc2008

View File

@ -0,0 +1,5 @@
TEMPLATE = app
CONFIG += debug_and_release build_all
TARGET = bah
DESTDIR = shu
SOURCES += main.cpp

View File

@ -0,0 +1,4 @@
int main(int, char **)
{
return 0;
}

View File

@ -0,0 +1,7 @@
LIBS = -lqui -lqtest -lqui
CONFIG -= link_prl
JOINEDLIBS = $$join(LIBS, "_")
!contains(JOINEDLIBS, -lqui_-lqtest_-lqui) {
message("FAILED: duplibs")
}

View File

@ -0,0 +1 @@
# This just balances default_pre.prf (which does not daisy-chain to the one from qmake).

Some files were not shown because too many files have changed in this diff Show More