summaryrefslogtreecommitdiff
path: root/src/qtwaylandscanner/qtwaylandscanner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qtwaylandscanner/qtwaylandscanner.cpp')
-rw-r--r--src/qtwaylandscanner/qtwaylandscanner.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp
index b609523b..5b9707a5 100644
--- a/src/qtwaylandscanner/qtwaylandscanner.cpp
+++ b/src/qtwaylandscanner/qtwaylandscanner.cpp
@@ -439,7 +439,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf(" struct ::wl_client *client() const { return handle->client; }\n");
printf(" int version() const { return wl_resource_get_version(handle); }\n");
printf("\n");
- printf(" static Resource *fromResource(struct ::wl_resource *resource) { return static_cast<Resource *>(resource->data); }\n");
+ 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");
@@ -708,6 +708,13 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf(" return resource;\n");
printf(" }\n");
+ printf(" %s::Resource *%s::Resource::fromResource(struct ::wl_resource *resource)\n", interfaceName, interfaceName);
+ printf(" {\n");
+ printf(" if (wl_resource_instance_of(resource, &::%s_interface, %s))\n", interfaceName, interfaceMember.constData());
+ printf(" return static_cast<Resource *>(resource->data);\n");
+ printf(" return 0;\n");
+ printf(" }\n");
+
if (hasRequests) {
printf("\n");
printf(" const struct ::%s_interface %s::m_%s_interface = {", interfaceName, interfaceName, interfaceName);