[PATCH wayland 4/4] Make wl_resource opaque

Jason Ekstrand jason at jlekstrand.net
Sat Jun 1 15:40:55 PDT 2013


Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
---
 src/wayland-server.c | 25 +++++++++++++++++++++++++
 src/wayland-server.h | 40 ++++++++--------------------------------
 2 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/src/wayland-server.c b/src/wayland-server.c
index 13b9dc8..3fe9dea 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -102,6 +102,31 @@ struct wl_global {
 	struct wl_list link;
 };
 
+struct wl_resource {
+	struct wl_object object;
+	wl_resource_destroy_func_t destroy;
+	struct wl_list link;
+	struct wl_signal destroy_signal;
+	struct wl_client *client;
+	void *data;
+};
+
+static inline void
+wl_resource_init(struct wl_resource *resource,
+		 const struct wl_interface *interface,
+		 const void *implementation, uint32_t id, void *data)
+{
+	resource->object.id = id;
+	resource->object.interface = interface;
+	resource->object.implementation = implementation;
+
+	wl_signal_init(&resource->destroy_signal);
+
+	resource->destroy = NULL;
+	resource->client = NULL;
+	resource->data = data;
+}
+
 static int wl_debug = 0;
 
 static void
diff --git a/src/wayland-server.h b/src/wayland-server.h
index 677f998..912b22d 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -181,39 +181,15 @@ wl_signal_emit(struct wl_signal *signal, void *data)
 
 typedef void (*wl_resource_destroy_func_t)(struct wl_resource *resource);
 
-/* The wl_resource structure has be deprecated as a transparent structure.
- * While wl_resource will still exist, it will, in the future, be an opaque
- * pointer.  Instead of accessing wl_resource directly, it should be created by
- * wl_client_add_object and wl_client_new_object and only accessed by the
- * accessor functions provided.
- */
-struct wl_resource {
-	struct wl_object object;
-	wl_resource_destroy_func_t destroy;
-	struct wl_list link;
-	struct wl_signal destroy_signal;
-	struct wl_client *client;
-	void *data;
-};
-
-static inline void
-wl_resource_init(struct wl_resource *resource,
-		 const struct wl_interface *interface,
-		 const void *implementation, uint32_t id, void *data)
-{
-	resource->object.id = id;
-	resource->object.interface = interface;
-	resource->object.implementation = implementation;
-
-	wl_signal_init(&resource->destroy_signal);
-
-	resource->destroy = NULL;
-	resource->client = NULL;
-	resource->data = data;
-}
-
 struct wl_buffer {
-	struct wl_resource resource;
+	struct {
+		struct wl_object object;
+		wl_resource_destroy_func_t destroy;
+		struct wl_list link;
+		struct wl_signal destroy_signal;
+		struct wl_client *client;
+		void *data;
+	} resource;
 	int32_t width, height;
 	uint32_t busy_count;
 };
-- 
1.8.1.4



More information about the wayland-devel mailing list