[Xcb] [lib 5/5] c_client.py: No sizeofs for Events, Replies, Requests

Daniel Martin consume.noise at gmail.com
Mon Dec 2 15:10:45 PST 2013


On Fri, Nov 22, 2013 at 08:38:01PM -0800, Josh Triplett wrote:
> On Fri, Nov 22, 2013 at 11:27:32PM +0100, Daniel Martin wrote:
> > Don't generate _sizeof() functions for Events, Replies and Requests.
> > Those sizeof functions are used to iterate over lists with variadic
> > sized elements. But, there're no lists of Events, Replies or Requests
> > that would require such a helper function for the iterator.
> > 
> > Signed-off-by: Daniel Martin <consume.noise at gmail.com>
> 
> These functions are exported by the library, and removing them would
> change the API.  You have no way of knowing if these functions have
> callers.  Please do not remove them.

It'd change the api, but those _sizeof()s are used otherwise from within
_iterator() functions, which don't exist.

> In addition, I don't think there's anything preventing a structure from
> embedding one of these structures, in which case these functions *would*
> be needed.

In that case it would be more easy to calculate the size with the
'length' field. The _sizeof() function would iterator through the whole
buffer to do the same.

But, I can remove this patch.

> >  src/c_client.py | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/c_client.py b/src/c_client.py
> > index 59cc19a..362a3a1 100644
> > --- a/src/c_client.py
> > +++ b/src/c_client.py
> > @@ -428,8 +428,8 @@ def _c_type_setup(self, name, postfix):
> >                  #   special cases -> unserialize
> >                  if self.is_switch or self.var_followed_by_fixed_fields:
> >                      _c_serialize('unserialize', self)
> > -                    
> > -        if self.need_sizeof:
> > +
> > +        if self.need_sizeof and not isinstance(self, (Event, Reply, Request)):
> >              if self.c_sizeof_name not in finished_sizeof:
> >                  if not module.namespace.is_ext or self.name[:2] == module.namespace.prefix:
> >                      finished_sizeof.append(self.c_sizeof_name)
> > -- 
> > 1.8.4.2
> > 
> > _______________________________________________
> > Xcb mailing list
> > Xcb at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/xcb


More information about the Xcb mailing list