[RFC wayland] Track protocol object versions inside wl_proxy.

Pekka Paalanen ppaalanen at gmail.com
Mon Dec 21 06:23:29 PST 2015


On Thu, 12 Nov 2015 14:01:33 -0600
Derek Foreman <derekf at osg.samsung.com> wrote:

> From: Jason Ekstrand <jason at jlekstrand.net>
> 
> This provides a standardized mechanism for tracking protocol object
> versions in client code.  The wl_display object is created with version 1.
> Every time an object is created from within wl_registry_bind, it gets the
> bound version.  Every other time an object is created, it simply inherits
> it's version from the parent object that created it.
> 
> ---
> Sooo, seems to finally fix the EGLSwapBuffersWithDamage problem, we also
> need this patch.  However, it's not complete.
> 
> I've rebased it and updated it.  Here's the original posting:
> http://lists.freedesktop.org/archives/wayland-devel/2014-April/014004.html
> 
> Of special importance is:
> http://lists.freedesktop.org/archives/wayland-devel/2014-April/014011.html
> 
> And the proposed solution to the new backwards compatibility issue.  If we
> get a consensus on a way forward, I can pick this up and finish it off...
> 
>  src/scanner.c             |  29 ++++++++----
>  src/wayland-client-core.h |  14 ++++++
>  src/wayland-client.c      | 112 +++++++++++++++++++++++++++++++++++++++++++---
>  3 files changed, 140 insertions(+), 15 deletions(-)
> 
> diff --git a/src/scanner.c b/src/scanner.c
> index 8ecdd56..850e72a 100644
> --- a/src/scanner.c
> +++ b/src/scanner.c
> @@ -889,6 +889,14 @@ emit_stubs(struct wl_list *message_list, struct interface *interface)
>  	       interface->name, interface->name, interface->name,
>  	       interface->name);
>  
> +	printf("static inline uint32_t\n"
> +	       "%s_get_version(struct %s *%s)\n"
> +	       "{\n"
> +	       "\treturn wl_proxy_get_version((struct wl_proxy *) %s);\n"
> +	       "}\n\n",
> +	       interface->name, interface->name, interface->name,
> +	       interface->name);
> +
>  	has_destructor = 0;
>  	has_destroy = 0;
>  	wl_list_for_each(m, message_list, link) {
> @@ -960,20 +968,25 @@ emit_stubs(struct wl_list *message_list, struct interface *interface)
>  
>  		printf(")\n"
>  		       "{\n");
> -		if (ret) {
> +		if (ret && ret->interface_name == NULL) {

Hi,

it took a while to decipher what all these cases are. This one is the
wl_registry.bind case: new_id without hardcoded type in the XML.

>  			printf("\tstruct wl_proxy *%s;\n\n"
> -			       "\t%s = wl_proxy_marshal_constructor("
> +			       "\t%s = wl_proxy_marshal_constructor_versioned("
>  			       "(struct wl_proxy *) %s,\n"
> -			       "\t\t\t %s_%s, ",
> +			       "\t\t\t %s_%s, interface, version",
>  			       ret->name, ret->name,
>  			       interface->name,
>  			       interface->uppercase_name,
>  			       m->uppercase_name);
> -
> -			if (ret->interface_name == NULL)
> -				printf("interface");
> -			else
> -				printf("&%s_interface", ret->interface_name);
> +		} else if (ret) {

This is the normal factory case: new_id with hardcoded type.

> +			printf("\tstruct wl_proxy *%s;\n\n"
> +			       "\t%s = wl_proxy_marshal_constructor("
> +			       "(struct wl_proxy *) %s,\n"
> +			       "\t\t\t %s_%s, &%s_interface",
> +			       ret->name, ret->name,
> +			       interface->name,
> +			       interface->uppercase_name,
> +			       m->uppercase_name,
> +			       ret->interface_name);
>  		} else {

And this is the usual case of no new_id at all.

Would be nice to add comments to that effect.

>  			printf("\twl_proxy_marshal((struct wl_proxy *) %s,\n"
>  			       "\t\t\t %s_%s",
> diff --git a/src/wayland-client-core.h b/src/wayland-client-core.h
> index 8b4b4b8..ed41773 100644
> --- a/src/wayland-client-core.h
> +++ b/src/wayland-client-core.h
> @@ -138,10 +138,21 @@ wl_proxy_marshal_constructor(struct wl_proxy *proxy,
>  			     const struct wl_interface *interface,
>  			     ...);
>  
> +struct wl_proxy *wl_proxy_marshal_constructor_versioned(struct wl_proxy *proxy,

Split.

> +							uint32_t opcode,
> +							const struct wl_interface *interface,
> +							uint32_t version,
> +							...);
>  struct wl_proxy *
>  wl_proxy_marshal_array_constructor(struct wl_proxy *proxy,
>  				   uint32_t opcode, union wl_argument *args,
>  				   const struct wl_interface *interface);
> +struct wl_proxy *
> +wl_proxy_marshal_array_constructor_versioned(struct wl_proxy *proxy,
> +					     uint32_t opcode,
> +					     union wl_argument *args,
> +					     const struct wl_interface *interface,
> +					     uint32_t version);
>  
>  void
>  wl_proxy_destroy(struct wl_proxy *proxy);
> @@ -165,6 +176,9 @@ void *
>  wl_proxy_get_user_data(struct wl_proxy *proxy);
>  
>  uint32_t
> +wl_proxy_get_version(struct wl_proxy *proxy);
> +
> +uint32_t
>  wl_proxy_get_id(struct wl_proxy *proxy);
>  
>  const char *

Regardless of the cosmetics:
Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20151221/8e0c73d1/attachment.sig>


More information about the wayland-devel mailing list