From bcc93850fc73689bdd796b19f98cca525636a0fd Mon Sep 17 00:00:00 2001 From: Ievgenii Meshcheriakov Date: Fri, 30 Jun 2023 17:02:37 +0200 Subject: [PATCH] QDBusIntrospection: Pass diagnostics reporter to parser This would allow to emit parser-related diagnostics from tools like qdbusxml2cpp. Also such tools could stop processing if there were parse errors. Task-number: QTBUG-2597 Change-Id: I573296bb57613d5a443b8c4dbe645b7e82f65adc Reviewed-by: Thiago Macieira --- src/dbus/qdbusintrospection.cpp | 20 +++++++++++--------- src/dbus/qdbusintrospection_p.h | 7 ++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/dbus/qdbusintrospection.cpp b/src/dbus/qdbusintrospection.cpp index 3f8766636f..484d901ad7 100644 --- a/src/dbus/qdbusintrospection.cpp +++ b/src/dbus/qdbusintrospection.cpp @@ -297,11 +297,11 @@ QT_BEGIN_NAMESPACE If there are multiple interfaces in this XML data, it is undefined which one will be returned. */ -QDBusIntrospection::Interface -QDBusIntrospection::parseInterface(const QString &xml) +QDBusIntrospection::Interface QDBusIntrospection::parseInterface(const QString &xml, + DiagnosticsReporter *reporter) { // be lazy - Interfaces ifs = parseInterfaces(xml); + Interfaces ifs = parseInterfaces(xml, reporter); if (ifs.isEmpty()) return Interface(); @@ -315,11 +315,11 @@ QDBusIntrospection::parseInterface(const QString &xml) If the first element tag in this document fragment is \, the interfaces parsed will be those found as child elements of the \ tag. */ -QDBusIntrospection::Interfaces -QDBusIntrospection::parseInterfaces(const QString &xml) +QDBusIntrospection::Interfaces QDBusIntrospection::parseInterfaces(const QString &xml, + DiagnosticsReporter *reporter) { QString null; - QDBusXmlParser parser(null, null, xml); + QDBusXmlParser parser(null, null, xml, reporter); return parser.interfaces(); } @@ -334,10 +334,12 @@ QDBusIntrospection::parseInterfaces(const QString &xml) This function does not parse the interfaces contained in the node, nor sub-object's contents. It will only list their names. */ -QDBusIntrospection::Object -QDBusIntrospection::parseObject(const QString &xml, const QString &service, const QString &path) +QDBusIntrospection::Object QDBusIntrospection::parseObject(const QString &xml, + const QString &service, + const QString &path, + DiagnosticsReporter *reporter) { - QDBusXmlParser parser(service, path, xml); + QDBusXmlParser parser(service, path, xml, reporter); QSharedDataPointer retval = parser.object(); if (!retval) return QDBusIntrospection::Object(); diff --git a/src/dbus/qdbusintrospection_p.h b/src/dbus/qdbusintrospection_p.h index 38a7d5cc66..8a95e71794 100644 --- a/src/dbus/qdbusintrospection_p.h +++ b/src/dbus/qdbusintrospection_p.h @@ -155,10 +155,11 @@ public: }; public: - static Interface parseInterface(const QString &xml); - static Interfaces parseInterfaces(const QString &xml); + static Interface parseInterface(const QString &xml, DiagnosticsReporter *reporter = nullptr); + static Interfaces parseInterfaces(const QString &xml, DiagnosticsReporter *reporter = nullptr); static Object parseObject(const QString &xml, const QString &service = QString(), - const QString &path = QString()); + const QString &path = QString(), + DiagnosticsReporter *reporter = nullptr); private: QDBusIntrospection();