[PATCH 5/8] scanner: Send interface name and version for types new_id args

Kristian Høgsberg hoegsberg at gmail.com
Wed Oct 10 13:41:58 PDT 2012


On Wed, Oct 10, 2012 at 04:35:56PM +0300, Pekka Paalanen wrote:
> On Tue,  9 Oct 2012 22:38:02 -0400
> Kristian Høgsberg <krh at bitplanet.net> wrote:
> 
> > This makes the scanner generate the code and meta data to send the
> > interface name and version when we pass a typeless new_id.  This way, the
> > generic factory mechanism provided by wl_display.bind can be provided by
> > any interface.
> > ---
> >  protocol/wayland.xml |    6 ++----
> >  src/scanner.c        |   56 ++++++++++++++++++++++++++++++++++----------------
> >  2 files changed, 40 insertions(+), 22 deletions(-)
> > 
> > diff --git a/protocol/wayland.xml b/protocol/wayland.xml
> > index e9f8034..86b82b8 100644
> > --- a/protocol/wayland.xml
> > +++ b/protocol/wayland.xml
> > @@ -38,9 +38,7 @@
> >  	the identifier.
> >        </description>
> >        <arg name="name" type="uint" summary="unique number id for object"/>
> > -      <arg name="interface" type="string"/>
> > -      <arg name="version" type="uint"/>
> > -      <arg name="id" type="new_id" interface="wl_object"/>
> > +      <arg name="id" type="new_id"/>
> >      </request>
> >  
> >      <request name="sync">
> > @@ -58,7 +56,7 @@
> >  	The error event is sent out when a fatal (non-recoverable)
> >  	error has occurred.
> >        </description>
> > -      <arg name="object_id" type="object" interface="wl_object"/>
> > +      <arg name="object_id" type="object"/>
> >        <arg name="code" type="uint"/>
> >        <arg name="message" type="string"/>
> >      </event>
> > diff --git a/src/scanner.c b/src/scanner.c
> > index 0fc26e7..bf5df26 100644
> > --- a/src/scanner.c
> > +++ b/src/scanner.c
> ...
> > @@ -645,8 +656,8 @@ emit_stubs(struct wl_list *message_list, struct interface *interface)
> >  			       interface->name);
> >  
> >  		if (ret)
> > -			printf("\n\treturn (struct %s *) %s;\n",
> > -			       ret->interface_name, ret->name);
> > +			printf("\n\treturn (void *) %s;\n",
> > +			       ret->name);
> 
> This changes the cast on all wrapper functions. While it's not wrong in
> any way, could we keep the cast to the same type as returned from the
> function?

This is there because in case of an untyped new-id argument, we don't
have a type name there.  We could special case that and only use void
* in that case, but since the caller will get the right type anyway
(the return type of the function has the right type - either struct
name * or void *), it doesn't make a difference.

On second though, I think the implicit cast from void * to the return
type is going to trigger warnings in C++, so I'll just fix the cast.

> >  
> >  		printf("}\n\n");
> >  	}
> > @@ -799,6 +810,11 @@ emit_structs(struct wl_list *message_list, struct interface *interface)
> >  
> >  			if (is_interface && a->type == OBJECT)
> >  				printf("struct wl_resource *");
> > +			else if (is_interface && a->type == NEW_ID && a->interface_name == NULL)
> > +				printf("const char *interface, uint32_t version, uint32_t ");
> 
> We miss documentation comments for interface and version in the
> generated header.

Right, I'll add that.

Thanks,
Kristian

> > +			else if (!is_interface && a->type == OBJECT && a->interface_name == NULL)
> > +				printf("struct wl_object *");
> > +
> >  			else if (!is_interface && a->type == NEW_ID)
> >  				printf("struct %s *", a->interface_name);
> >  			else
> ...
> 
> 
> Thanks,
> pq
> _______________________________________________
> 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