qdbusxml2cpp: invert Q_DECL_DEPRECATED and inline in the output

Commit 93dad2bf91 (6.0) changed
Q_DECL_DEPRECATED to use the [[deprecated]] attribute, which must appear
before inline and other keywords.

To keep it next to Q_NOREPLY, I also moved the "inline" into the next
string.

Added missing tests for both.

Pick-to: 6.2 6.4 6.5
Fixes: QTBUG-110979
Change-Id: I9671dee8ceb64aa9b9cafffd1741656e86f40453
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Thiago Macieira 2023-02-06 17:07:41 -08:00
parent 0128c3742e
commit f67b32e735
2 changed files with 56 additions and 5 deletions

View File

@ -606,13 +606,15 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf
continue;
}
hs << " inline "
<< (isDeprecated ? "Q_DECL_DEPRECATED " : "");
if (isDeprecated)
hs << " Q_DECL_DEPRECATED ";
else
hs << " ";
if (isNoReply) {
hs << "Q_NOREPLY void ";
hs << "Q_NOREPLY inline void ";
} else {
hs << "QDBusPendingReply<";
hs << "inline QDBusPendingReply<";
for (qsizetype i = 0; i < method.outputArgs.size(); ++i)
hs << (i > 0 ? ", " : "")
<< templateArg(qtTypeName(method.outputArgs.at(i).name, method.outputArgs.at(i).type,
@ -648,7 +650,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf
if (method.outputArgs.size() > 1) {
// generate the old-form QDBusReply methods with multiple incoming parameters
hs << " inline " << (isDeprecated ? "Q_DECL_DEPRECATED " : "") << "QDBusReply<"
hs << (isDeprecated ? " Q_DECL_DEPRECATED " : " ") << "inline QDBusReply<"
<< templateArg(qtTypeName(method.outputArgs.first().name, method.outputArgs.first().type,
method.annotations, 0, "Out"))
<< "> ";

View File

@ -240,6 +240,46 @@ void tst_qdbusxml2cpp::process_data()
<< QRegularExpression("Q_SLOTS:.*QString Method\\(const QString &\\w*, const QString &\\w*, QString &",
QRegularExpression::DotMatchesEverythingOption);
QTest::newRow("method-deprecated-0out")
<< "<method name=\"Method\">"
"<annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>"
"</method>"
<< QRegularExpression("Q_SLOTS:.*Q_DECL_DEPRECATED inline QDBusPendingReply<> Method\\(\\)",
QRegularExpression::DotMatchesEverythingOption)
<< QRegularExpression("Q_SLOTS:.*void Method\\(\\)",
QRegularExpression::DotMatchesEverythingOption);
QTest::newRow("method-deprecated-2out")
<< "<method name=\"Method\">"
"<annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>"
"<arg type=\"s\" direction=\"out\"/>"
"<arg type=\"s\" direction=\"out\"/>"
"</method>"
<< QRegularExpression("Q_SLOTS:.*Q_DECL_DEPRECATED inline QDBusPendingReply<QString, QString> Method\\(\\)"
".*Q_DECL_DEPRECATED inline QDBusReply<QString> Method\\(QString &\\w*\\)",
QRegularExpression::DotMatchesEverythingOption)
<< QRegularExpression("Q_SLOTS:.*QString Method\\(QString &",
QRegularExpression::DotMatchesEverythingOption);
QTest::newRow("method-noreply")
<< "<method name=\"Method\">"
"<annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>"
"</method>"
<< QRegularExpression("Q_SLOTS:.*Q_NOREPLY inline void Method\\(\\).*\\bQDBus::NoBlock\\b",
QRegularExpression::DotMatchesEverythingOption)
<< QRegularExpression("Q_SLOTS:.*Q_NOREPLY void Method\\(",
QRegularExpression::DotMatchesEverythingOption);
QTest::newRow("method-deprecated-noreply")
<< "<method name=\"Method\">"
"<annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>"
"<annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>"
"</method>"
<< QRegularExpression("Q_SLOTS:.*Q_DECL_DEPRECATED Q_NOREPLY inline void Method\\(\\).*\\bQDBus::NoBlock\\b",
QRegularExpression::DotMatchesEverythingOption)
<< QRegularExpression("Q_SLOTS:.*Q_NOREPLY void Method\\(",
QRegularExpression::DotMatchesEverythingOption);
// -- signals --
for (int i = 0; i < basicTypeCount; ++i) {
QRegularExpression rx(QString("Q_SIGNALS:.*\\bvoid Signal\\((const )?%1\\b")
@ -261,6 +301,15 @@ void tst_qdbusxml2cpp::process_data()
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>"
</signal>)"
<< rx << rx;
QTest::newRow("signal-deprecated")
<< R"(<signal name="Signal">
<annotation name="org.freedesktop.DBus.Deprecated" value="true"/>
</signal>)"
<< QRegularExpression(R"(Q_SIGNALS:.*\bQ_DECL_DEPRECATED void Signal\(\))",
QRegularExpression::DotMatchesEverythingOption)
<< QRegularExpression(R"(Q_SIGNALS:.*\bvoid Signal\(\))",
QRegularExpression::DotMatchesEverythingOption);
}
void tst_qdbusxml2cpp::process()