[Xcb] [PATCH libxcb v2 3/4] Code generator: Use xcb_send_request_with_fds()
Ran Benita
ran234 at gmail.com
Sat May 16 06:56:59 PDT 2015
On Thu, May 14, 2015 at 09:54:59AM +0200, Uli Schlachter wrote:
> Signed-off-by: Uli Schlachter <psychon at znc.in>
> ---
> src/c_client.py | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/src/c_client.py b/src/c_client.py
> index e55fc3c..8bf34f2 100644
> --- a/src/c_client.py
> +++ b/src/c_client.py
> @@ -2298,6 +2298,8 @@ def _c_request_helper(self, name, void, regular, aux=False, reply_fds=False):
> _c(' unsigned int i;')
> _c(' unsigned int xcb_tmp_len;')
> _c(' char *xcb_tmp;')
> + if any(field.isfd for field in param_fields):
> + _c(' int fds[%d];' % (len(filter(lambda field: field.isfd, param_fields))))
In python3 filter(..) is not a list so this doesn't work. You can use
len([field for field in param_fields if field.isfd])
or
sum(1 for field in param_fields if field.isfd)
if you're so inclined.
But maybe just initialize `num_fds` in the beginning with some
expression like above and use it everywhere.
Ran
> _c('')
>
> # fixed size fields
> @@ -2398,11 +2400,16 @@ def _c_request_helper(self, name, void, regular, aux=False, reply_fds=False):
> # no padding necessary - _serialize() keeps track of padding automatically
>
> _c('')
> + num_fds = 0
> for field in param_fields:
> if field.isfd:
> - _c(' xcb_send_fd(c, %s);', field.c_field_name)
> + _c(' fds[%d] = %s;', num_fds, field.c_field_name)
> + num_fds = num_fds + 1
>
> - _c(' xcb_ret.sequence = xcb_send_request(c, %s, xcb_parts + 2, &xcb_req);', func_flags)
> + if num_fds == 0:
> + _c(' xcb_ret.sequence = xcb_send_request(c, %s, xcb_parts + 2, &xcb_req);', func_flags)
> + else:
> + _c(' xcb_ret.sequence = xcb_send_request_with_fds(c, %s, xcb_parts + 2, &xcb_req, %d, fds);', func_flags, num_fds)
>
> # free dyn. all. data, if any
> for f in free_calls:
> --
> 2.1.4
>
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
More information about the Xcb
mailing list