summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason@jlekstrand.net>2013-06-20 20:36:47 -0500
committerKristian Høgsberg <krh@bitplanet.net>2013-06-21 19:18:04 -0400
commit5ac5d55d81dc1dad8f68ddde60b9f8895641567d (patch)
tree2f21706b469fdf9e3280ea057a1a5768c4c5b63e
parent96afa347762bd9796288e8052ccc42989a68386d (diff)
Add a wl_resource_instance_of function
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
-rw-r--r--src/connection.c8
-rw-r--r--src/wayland-private.h3
-rw-r--r--src/wayland-server.c9
-rw-r--r--src/wayland-server.h5
4 files changed, 21 insertions, 4 deletions
diff --git a/src/connection.c b/src/connection.c
index b26402f..95edd6e 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -737,8 +737,8 @@ wl_connection_demarshal(struct wl_connection *connection,
return NULL;
}
-static int
-interface_equal(const struct wl_interface *a, const struct wl_interface *b)
+int
+wl_interface_equal(const struct wl_interface *a, const struct wl_interface *b)
{
/* In most cases the pointer equality test is sufficient.
* However, in some cases, depending on how things are split
@@ -784,8 +784,8 @@ wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects)
}
if (object != NULL && message->types[i] != NULL &&
- !interface_equal((object)->interface,
- message->types[i])) {
+ !wl_interface_equal((object)->interface,
+ message->types[i])) {
printf("invalid object (%u), type (%s), "
"message %s(%s)\n",
id, (object)->interface->name,
diff --git a/src/wayland-private.h b/src/wayland-private.h
index 6f7a347..71066b5 100644
--- a/src/wayland-private.h
+++ b/src/wayland-private.h
@@ -73,6 +73,9 @@ struct wl_connection;
struct wl_closure;
struct wl_proxy;
+int wl_interface_equal(const struct wl_interface *iface1,
+ const struct wl_interface *iface2);
+
struct wl_connection *wl_connection_create(int fd);
void wl_connection_destroy(struct wl_connection *connection);
void wl_connection_copy(struct wl_connection *connection, void *data, size_t size);
diff --git a/src/wayland-server.c b/src/wayland-server.c
index 28a10cc..7907283 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -504,6 +504,15 @@ wl_resource_set_destructor(struct wl_resource *resource,
resource->destroy = destroy;
}
+WL_EXPORT int
+wl_resource_instance_of(struct wl_resource *resource,
+ const struct wl_interface *interface,
+ const void *implementation)
+{
+ return wl_interface_equal(resource->object.interface, interface) &&
+ resource->object.implementation == implementation;
+}
+
WL_EXPORT void
wl_resource_add_destroy_listener(struct wl_resource *resource,
struct wl_listener * listener)
diff --git a/src/wayland-server.h b/src/wayland-server.h
index cffe7f6..72a4833 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -273,6 +273,11 @@ wl_resource_get_user_data(struct wl_resource *resource);
void
wl_resource_set_destructor(struct wl_resource *resource,
wl_resource_destroy_func_t destroy);
+int
+wl_resource_instance_of(struct wl_resource *resource,
+ const struct wl_interface *interface,
+ const void *implementation);
+
void
wl_resource_add_destroy_listener(struct wl_resource *resource,
struct wl_listener * listener);