summaryrefslogtreecommitdiffstats
path: root/src/qtwaylandscanner/qtwaylandscanner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qtwaylandscanner/qtwaylandscanner.cpp')
-rw-r--r--src/qtwaylandscanner/qtwaylandscanner.cpp224
1 files changed, 114 insertions, 110 deletions
diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp
index 24977a2f2..861c655bd 100644
--- a/src/qtwaylandscanner/qtwaylandscanner.cpp
+++ b/src/qtwaylandscanner/qtwaylandscanner.cpp
@@ -1,44 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <QCoreApplication>
#include <QFile>
+#include <QFileInfo>
#include <QXmlStreamReader>
#include <vector>
@@ -123,13 +88,14 @@ private:
QByteArray m_scannerName;
QByteArray m_headerPath;
QByteArray m_prefix;
- QVector <QByteArray> m_includes;
+ QByteArray m_buildMacro;
+ QList <QByteArray> m_includes;
QXmlStreamReader *m_xml = nullptr;
};
bool Scanner::parseArguments(int argc, char **argv)
{
- QVector<QByteArray> args;
+ QList<QByteArray> args;
args.reserve(argc);
for (int i = 0; i < argc; ++i)
args << QByteArray(argv[i]);
@@ -156,6 +122,8 @@ bool Scanner::parseArguments(int argc, char **argv)
m_headerPath = option.mid(14);
} else if (option.startsWith("--prefix=")) {
m_prefix = option.mid(10);
+ } else if (option.startsWith("--build-macro=")) {
+ m_buildMacro = option.mid(14);
} else if (option.startsWith("--add-include=")) {
auto include = option.mid(14);
if (!include.isEmpty())
@@ -223,13 +191,13 @@ Scanner::WaylandEvent Scanner::readEvent(QXmlStreamReader &xml, bool request)
.arguments = {},
};
while (xml.readNextStartElement()) {
- if (xml.name() == "arg") {
+ if (xml.name() == u"arg") {
WaylandArgument argument = {
.name = byteArrayValue(xml, "name"),
.type = byteArrayValue(xml, "type"),
.interface = byteArrayValue(xml, "interface"),
.summary = byteArrayValue(xml, "summary"),
- .allowNull = boolValue(xml, "allowNull"),
+ .allowNull = boolValue(xml, "allow-null"),
};
event.arguments.push_back(std::move(argument));
}
@@ -247,7 +215,7 @@ Scanner::WaylandEnum Scanner::readEnum(QXmlStreamReader &xml)
};
while (xml.readNextStartElement()) {
- if (xml.name() == "entry") {
+ if (xml.name() == u"entry") {
WaylandEnumEntry entry = {
.name = byteArrayValue(xml, "name"),
.value = byteArrayValue(xml, "value"),
@@ -273,11 +241,11 @@ Scanner::WaylandInterface Scanner::readInterface(QXmlStreamReader &xml)
};
while (xml.readNextStartElement()) {
- if (xml.name() == "event")
+ if (xml.name() == u"event")
interface.events.push_back(readEvent(xml, false));
- else if (xml.name() == "request")
+ else if (xml.name() == u"request")
interface.requests.push_back(readEvent(xml, true));
- else if (xml.name() == "enum")
+ else if (xml.name() == u"enum")
interface.enums.push_back(readEnum(xml));
else
xml.skipCurrentElement();
@@ -438,7 +406,7 @@ bool Scanner::process()
if (!m_xml->readNextStartElement())
return false;
- if (m_xml->name() != "protocol") {
+ if (m_xml->name() != u"protocol") {
m_xml->raiseError(QStringLiteral("The file is not a wayland protocol file."));
return false;
}
@@ -455,10 +423,12 @@ bool Scanner::process()
//QByteArray preProcessorProtocolName = QByteArray(m_protocolName).replace('-', '_').toUpper();
QByteArray preProcessorProtocolName = QByteArray(m_protocolName).toUpper();
+ const QByteArray fileBaseName = QFileInfo(file).completeBaseName().toLocal8Bit();
+
std::vector<WaylandInterface> interfaces;
while (m_xml->readNextStartElement()) {
- if (m_xml->name() == "interface")
+ if (m_xml->name() == u"interface")
interfaces.push_back(readInterface(*m_xml));
else
m_xml->skipCurrentElement();
@@ -467,9 +437,32 @@ bool Scanner::process()
if (m_xml->hasError())
return false;
- for (auto b : qAsConst(m_includes))
+ printf("// This file was generated by qtwaylandscanner\n");
+ printf("// source file is %s\n\n", qPrintable(QFileInfo(file).fileName()));
+
+ for (auto b : std::as_const(m_includes))
printf("#include %s\n", b.constData());
+ auto printExportMacro = [this](const char *prefix, const QByteArray &preProcessorProtocolName) {
+ QByteArray exportMacro = prefix + preProcessorProtocolName + "_EXPORT";
+ printf("#if !defined(%s)\n", exportMacro.constData());
+ printf("# if defined(QT_SHARED) && !defined(QT_STATIC)\n");
+ if (m_buildMacro.isEmpty()) {
+ printf("# define %s Q_DECL_EXPORT\n", exportMacro.constData());
+ } else {
+ printf("# if defined(%s)\n", m_buildMacro.constData());
+ printf("# define %s Q_DECL_EXPORT\n", exportMacro.constData());
+ printf("# else\n");
+ printf("# define %s Q_DECL_IMPORT\n", exportMacro.constData());
+ printf("# endif\n");
+ }
+ printf("# else\n");
+ printf("# define %s\n", exportMacro.constData());
+ printf("# endif\n");
+ printf("#endif\n");
+ return exportMacro;
+ };
+
if (m_option == ServerHeader) {
QByteArray inclusionGuard = QByteArray("QT_WAYLAND_SERVER_") + preProcessorProtocolName.constData();
printf("#ifndef %s\n", inclusionGuard.constData());
@@ -477,9 +470,9 @@ bool Scanner::process()
printf("\n");
printf("#include \"wayland-server-core.h\"\n");
if (m_headerPath.isEmpty())
- printf("#include \"wayland-%s-server-protocol.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include \"wayland-%s-server-protocol.h\"\n", fileBaseName.constData());
else
- printf("#include <%s/wayland-%s-server-protocol.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include <%s/wayland-%s-server-protocol.h>\n", m_headerPath.constData(), fileBaseName.constData());
printf("#include <QByteArray>\n");
printf("#include <QMultiMap>\n");
printf("#include <QString>\n");
@@ -498,17 +491,8 @@ bool Scanner::process()
printf("QT_WARNING_DISABLE_GCC(\"-Wmissing-field-initializers\")\n");
printf("QT_WARNING_DISABLE_CLANG(\"-Wmissing-field-initializers\")\n");
QByteArray serverExport;
- if (m_headerPath.size()) {
- serverExport = QByteArray("Q_WAYLAND_SERVER_") + preProcessorProtocolName + "_EXPORT";
- printf("\n");
- printf("#if !defined(%s)\n", serverExport.constData());
- printf("# if defined(QT_SHARED)\n");
- printf("# define %s Q_DECL_EXPORT\n", serverExport.constData());
- printf("# else\n");
- printf("# define %s\n", serverExport.constData());
- printf("# endif\n");
- printf("#endif\n");
- }
+ if (m_headerPath.size())
+ serverExport = printExportMacro("Q_WAYLAND_SERVER_", preProcessorProtocolName);
printf("\n");
printf("namespace QtWaylandServer {\n");
@@ -529,7 +513,7 @@ bool Scanner::process()
printf(" class %s %s\n {\n", serverExport.constData(), interfaceName);
printf(" public:\n");
- printf(" %s(struct ::wl_client *client, int id, int version);\n", interfaceName);
+ printf(" %s(struct ::wl_client *client, uint32_t id, int version);\n", interfaceName);
printf(" %s(struct ::wl_display *display, int version);\n", interfaceName);
printf(" %s(struct ::wl_resource *resource);\n", interfaceName);
printf(" %s();\n", interfaceName);
@@ -552,13 +536,13 @@ bool Scanner::process()
printf(" static Resource *fromResource(struct ::wl_resource *resource);\n");
printf(" };\n");
printf("\n");
- printf(" void init(struct ::wl_client *client, int id, int version);\n");
+ printf(" void init(struct ::wl_client *client, uint32_t id, int version);\n");
printf(" void init(struct ::wl_display *display, int version);\n");
printf(" void init(struct ::wl_resource *resource);\n");
printf("\n");
printf(" Resource *add(struct ::wl_client *client, int version);\n");
- printf(" Resource *add(struct ::wl_client *client, int id, int version);\n");
- printf(" Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version);\n");
+ printf(" Resource *add(struct ::wl_client *client, uint32_t id, int version);\n");
+ printf(" Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version);\n");
printf("\n");
printf(" Resource *resource() { return m_resource; }\n");
printf(" const Resource *resource() const { return m_resource; }\n");
@@ -634,7 +618,6 @@ bool Scanner::process()
printf(" QMultiMap<struct ::wl_client*, Resource*> m_resource_map;\n");
printf(" Resource *m_resource;\n");
printf(" struct ::wl_global *m_global;\n");
- printf(" uint32_t m_globalVersion;\n");
printf(" struct DisplayDestroyedListener : ::wl_listener {\n");
printf(" %s *parent;\n", interfaceName);
printf(" };\n");
@@ -652,13 +635,14 @@ bool Scanner::process()
if (m_option == ServerCode) {
if (m_headerPath.isEmpty())
- printf("#include \"qwayland-server-%s.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include \"qwayland-server-%s.h\"\n", fileBaseName.constData());
else
- printf("#include <%s/qwayland-server-%s.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include <%s/qwayland-server-%s.h>\n", m_headerPath.constData(), fileBaseName.constData());
printf("\n");
printf("QT_BEGIN_NAMESPACE\n");
printf("QT_WARNING_PUSH\n");
printf("QT_WARNING_DISABLE_GCC(\"-Wmissing-field-initializers\")\n");
+ printf("QT_WARNING_DISABLE_CLANG(\"-Wmissing-field-initializers\")\n");
printf("\n");
printf("namespace QtWaylandServer {\n");
@@ -678,7 +662,7 @@ bool Scanner::process()
QByteArray stripped = stripInterfaceName(interface.name);
const char *interfaceNameStripped = stripped.constData();
- printf(" %s::%s(struct ::wl_client *client, int id, int version)\n", interfaceName, interfaceName);
+ printf(" %s::%s(struct ::wl_client *client, uint32_t id, int version)\n", interfaceName, interfaceName);
printf(" : m_resource_map()\n");
printf(" , m_resource(nullptr)\n");
printf(" , m_global(nullptr)\n");
@@ -715,8 +699,11 @@ bool Scanner::process()
printf(" %s::~%s()\n", interfaceName, interfaceName);
printf(" {\n");
- printf(" for (auto resource : qAsConst(m_resource_map))\n");
- printf(" wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr);\n");
+ printf(" for (auto resource : std::as_const(m_resource_map))\n");
+ printf(" resource->%s_object = nullptr;\n", interfaceNameStripped);
+ printf("\n");
+ printf(" if (m_resource)\n");
+ printf(" m_resource->%s_object = nullptr;\n", interfaceNameStripped);
printf("\n");
printf(" if (m_global) {\n");
printf(" wl_global_destroy(m_global);\n");
@@ -725,7 +712,7 @@ bool Scanner::process()
printf(" }\n");
printf("\n");
- printf(" void %s::init(struct ::wl_client *client, int id, int version)\n", interfaceName);
+ printf(" void %s::init(struct ::wl_client *client, uint32_t id, int version)\n", interfaceName);
printf(" {\n");
printf(" m_resource = bind(client, id, version);\n");
printf(" }\n");
@@ -745,7 +732,7 @@ bool Scanner::process()
printf(" }\n");
printf("\n");
- printf(" %s::Resource *%s::add(struct ::wl_client *client, int id, int version)\n", interfaceName, interfaceName);
+ printf(" %s::Resource *%s::add(struct ::wl_client *client, uint32_t id, int version)\n", interfaceName, interfaceName);
printf(" {\n");
printf(" Resource *resource = bind(client, id, version);\n");
printf(" m_resource_map.insert(client, resource);\n");
@@ -756,7 +743,6 @@ bool Scanner::process()
printf(" void %s::init(struct ::wl_display *display, int version)\n", interfaceName);
printf(" {\n");
printf(" m_global = wl_global_create(display, &::%s_interface, version, this, bind_func);\n", interfaceName);
- printf(" m_globalVersion = version;\n");
printf(" m_displayDestroyedListener.notify = %s::display_destroy_func;\n", interfaceName);
printf(" m_displayDestroyedListener.parent = this;\n");
printf(" wl_display_add_destroy_listener(display, &m_displayDestroyedListener);\n");
@@ -788,7 +774,7 @@ bool Scanner::process()
printf(" void %s::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)\n", interfaceName);
printf(" {\n");
printf(" %s *that = static_cast<%s *>(data);\n", interfaceName, interfaceName);
- printf(" that->add(client, id, qMin(that->m_globalVersion, version));\n");
+ printf(" that->add(client, id, version);\n");
printf(" }\n");
printf("\n");
@@ -805,8 +791,14 @@ bool Scanner::process()
printf(" Resource *resource = Resource::fromResource(client_resource);\n");
printf(" Q_ASSERT(resource);\n");
printf(" %s *that = resource->%s_object;\n", interfaceName, interfaceNameStripped);
- printf(" that->m_resource_map.remove(resource->client(), resource);\n");
- printf(" that->%s_destroy_resource(resource);\n", interfaceNameStripped);
+ printf(" if (Q_LIKELY(that)) {\n");
+ printf(" that->m_resource_map.remove(resource->client(), resource);\n");
+ printf(" that->%s_destroy_resource(resource);\n", interfaceNameStripped);
+ printf("\n");
+ printf(" that = resource->%s_object;\n", interfaceNameStripped);
+ printf(" if (that && that->m_resource == resource)\n");
+ printf(" that->m_resource = nullptr;\n");
+ printf(" }\n");
printf(" delete resource;\n");
printf(" }\n");
printf("\n");
@@ -880,6 +872,11 @@ bool Scanner::process()
printf(" {\n");
printf(" Q_UNUSED(client);\n");
printf(" Resource *r = Resource::fromResource(resource);\n");
+ printf(" if (Q_UNLIKELY(!r->%s_object)) {\n", interfaceNameStripped);
+ if (e.type == "destructor")
+ printf(" wl_resource_destroy(resource);\n");
+ printf(" return;\n");
+ printf(" }\n");
printf(" static_cast<%s *>(r->%s_object)->%s_%s(\n", interfaceName, interfaceNameStripped, interfaceNameStripped, e.name.constData());
printf(" r");
for (const WaylandArgument &a : e.arguments) {
@@ -903,6 +900,11 @@ bool Scanner::process()
printEvent(e);
printf("\n");
printf(" {\n");
+ printf(" Q_ASSERT_X(m_resource, \"%s::%s\", \"Uninitialised resource\");\n", interfaceName, e.name.constData());
+ printf(" if (Q_UNLIKELY(!m_resource)) {\n");
+ printf(" qWarning(\"could not call %s::%s as it's not initialised\");\n", interfaceName, e.name.constData());
+ printf(" return;\n");
+ printf(" }\n");
printf(" send_%s(\n", e.name.constData());
printf(" m_resource->handle");
for (const WaylandArgument &a : e.arguments) {
@@ -938,9 +940,12 @@ bool Scanner::process()
printf(",\n");
QByteArray cType = waylandToCType(a.type, a.interface);
QByteArray qtType = waylandToQtType(a.type, a.interface, e.request);
- if (a.type == "string")
- printf(" %s.toUtf8().constData()", a.name.constData());
- else if (a.type == "array")
+ if (a.type == "string") {
+ printf(" ");
+ if (a.allowNull)
+ printf("%s.isNull() ? nullptr : ", a.name.constData());
+ printf("%s.toUtf8().constData()", a.name.constData());
+ } else if (a.type == "array")
printf(" &%s_data", a.name.constData());
else if (cType == qtType)
printf(" %s", a.name.constData());
@@ -963,9 +968,9 @@ bool Scanner::process()
printf("#define %s\n", inclusionGuard.constData());
printf("\n");
if (m_headerPath.isEmpty())
- printf("#include \"wayland-%s-client-protocol.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include \"wayland-%s-client-protocol.h\"\n", fileBaseName.constData());
else
- printf("#include <%s/wayland-%s-client-protocol.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include <%s/wayland-%s-client-protocol.h>\n", m_headerPath.constData(), fileBaseName.constData());
printf("#include <QByteArray>\n");
printf("#include <QString>\n");
printf("\n");
@@ -974,20 +979,12 @@ bool Scanner::process()
printf("QT_BEGIN_NAMESPACE\n");
printf("QT_WARNING_PUSH\n");
printf("QT_WARNING_DISABLE_GCC(\"-Wmissing-field-initializers\")\n");
+ printf("QT_WARNING_DISABLE_CLANG(\"-Wmissing-field-initializers\")\n");
QByteArray clientExport;
+ if (m_headerPath.size())
+ clientExport = printExportMacro("Q_WAYLAND_CLIENT_", preProcessorProtocolName);
- if (m_headerPath.size()) {
- clientExport = QByteArray("Q_WAYLAND_CLIENT_") + preProcessorProtocolName + "_EXPORT";
- printf("\n");
- printf("#if !defined(%s)\n", clientExport.constData());
- printf("# if defined(QT_SHARED)\n");
- printf("# define %s Q_DECL_EXPORT\n", clientExport.constData());
- printf("# else\n");
- printf("# define %s\n", clientExport.constData());
- printf("# endif\n");
- printf("#endif\n");
- }
printf("\n");
printf("namespace QtWayland {\n");
@@ -1008,13 +1005,13 @@ bool Scanner::process()
printf(" class %s %s\n {\n", clientExport.constData(), interfaceName);
printf(" public:\n");
- printf(" %s(struct ::wl_registry *registry, int id, int version);\n", interfaceName);
+ printf(" %s(struct ::wl_registry *registry, uint32_t id, int version);\n", interfaceName);
printf(" %s(struct ::%s *object);\n", interfaceName, interfaceName);
printf(" %s();\n", interfaceName);
printf("\n");
printf(" virtual ~%s();\n", interfaceName);
printf("\n");
- printf(" void init(struct ::wl_registry *registry, int id, int version);\n");
+ printf(" void init(struct ::wl_registry *registry, uint32_t id, int version);\n");
printf(" void init(struct ::%s *object);\n", interfaceName);
printf("\n");
printf(" struct ::%s *object() { return m_%s; }\n", interfaceName, interfaceName);
@@ -1023,6 +1020,8 @@ bool Scanner::process()
printf("\n");
printf(" bool isInitialized() const;\n");
printf("\n");
+ printf(" uint32_t version() const;");
+ printf("\n");
printf(" static const struct ::wl_interface *interface();\n");
printEnums(interface.enums);
@@ -1081,13 +1080,14 @@ bool Scanner::process()
if (m_option == ClientCode) {
if (m_headerPath.isEmpty())
- printf("#include \"qwayland-%s.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include \"qwayland-%s.h\"\n", fileBaseName.constData());
else
- printf("#include <%s/qwayland-%s.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include <%s/qwayland-%s.h>\n", m_headerPath.constData(), fileBaseName.constData());
printf("\n");
printf("QT_BEGIN_NAMESPACE\n");
printf("QT_WARNING_PUSH\n");
printf("QT_WARNING_DISABLE_GCC(\"-Wmissing-field-initializers\")\n");
+ printf("QT_WARNING_DISABLE_CLANG(\"-Wmissing-field-initializers\")\n");
printf("\n");
printf("namespace QtWayland {\n");
printf("\n");
@@ -1097,13 +1097,8 @@ bool Scanner::process()
printf("static inline void *wlRegistryBind(struct ::wl_registry *registry, uint32_t name, const struct ::wl_interface *interface, uint32_t version)\n");
printf("{\n");
printf(" const uint32_t bindOpCode = 0;\n");
- printf("#if (WAYLAND_VERSION_MAJOR == 1 && WAYLAND_VERSION_MINOR > 10) || WAYLAND_VERSION_MAJOR > 1\n");
printf(" return (void *) wl_proxy_marshal_constructor_versioned((struct wl_proxy *) registry,\n");
- printf(" bindOpCode, interface, version, name, interface->name, version, nullptr);\n");
- printf("#else\n");
- printf(" return (void *) wl_proxy_marshal_constructor((struct wl_proxy *) registry,\n");
- printf(" bindOpCode, interface, name, interface->name, version, nullptr);\n");
- printf("#endif\n");
+ printf(" bindOpCode, interface, version, name, interface->name, version, nullptr);\n");
printf("}\n");
printf("\n");
@@ -1124,7 +1119,7 @@ bool Scanner::process()
bool hasEvents = !interface.events.empty();
- printf(" %s::%s(struct ::wl_registry *registry, int id, int version)\n", interfaceName, interfaceName);
+ printf(" %s::%s(struct ::wl_registry *registry, uint32_t id, int version)\n", interfaceName, interfaceName);
printf(" {\n");
printf(" init(registry, id, version);\n");
printf(" }\n");
@@ -1149,7 +1144,7 @@ bool Scanner::process()
printf(" }\n");
printf("\n");
- printf(" void %s::init(struct ::wl_registry *registry, int id, int version)\n", interfaceName);
+ printf(" void %s::init(struct ::wl_registry *registry, uint32_t id, int version)\n", interfaceName);
printf(" {\n");
printf(" m_%s = static_cast<struct ::%s *>(wlRegistryBind(registry, id, &%s_interface, version));\n", interfaceName, interfaceName, interfaceName);
if (hasEvents)
@@ -1181,6 +1176,12 @@ bool Scanner::process()
printf(" }\n");
printf("\n");
+ printf(" uint32_t %s::version() const\n", interfaceName);
+ printf(" {\n");
+ printf(" return wl_proxy_get_version(reinterpret_cast<wl_proxy*>(m_%s));\n", interfaceName);
+ printf(" }\n");
+ printf("\n");
+
printf(" const struct wl_interface *%s::interface()\n", interfaceName);
printf(" {\n");
printf(" return &::%s_interface;\n", interfaceName);
@@ -1213,7 +1214,7 @@ bool Scanner::process()
printf("\n");
}
int actualArgumentCount = new_id ? int(e.arguments.size()) - 1 : int(e.arguments.size());
- printf(" %s%s_%s(\n", new_id ? "return " : "", interfaceName, e.name.constData());
+ printf(" %s::%s_%s(\n", new_id ? "return " : "", interfaceName, e.name.constData());
printf(" m_%s%s", interfaceName, actualArgumentCount > 0 ? "," : "");
bool needsComma = false;
for (const WaylandArgument &a : e.arguments) {
@@ -1230,9 +1231,12 @@ bool Scanner::process()
} else {
QByteArray cType = waylandToCType(a.type, a.interface);
QByteArray qtType = waylandToQtType(a.type, a.interface, e.request);
- if (a.type == "string")
- printf(" %s.toUtf8().constData()", a.name.constData());
- else if (a.type == "array")
+ if (a.type == "string") {
+ printf(" ");
+ if (a.allowNull)
+ printf("%s.isNull() ? nullptr : ", a.name.constData());
+ printf("%s.toUtf8().constData()", a.name.constData());
+ } else if (a.type == "array")
printf(" &%s_data", a.name.constData());
else if (cType == qtType)
printf(" %s", a.name.constData());