[PATCH wayland 4/4] Make wl_resource opaque

Kristian Høgsberg hoegsberg at gmail.com
Tue Jun 4 22:01:53 PDT 2013


On Sat, Jun 01, 2013 at 05:40:55PM -0500, Jason Ekstrand wrote:
> 
> 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;

Not applying this patch for now as you mention in 0/4.  However, I'd
like to also make wl_object private and just unroll the wl_object
struct here - is that possible?

Kristian

> +		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
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list