[Xcb-commit] libxcb: 2 commits - src
Daniel Stone
daniels at kemper.freedesktop.org
Sat Jul 22 12:12:20 UTC 2017
src/c_client.py | 52 ++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 38 insertions(+), 14 deletions(-)
New commits:
commit a3e9821bec08a69b355b46b0655562b9df61bb21
Author: Daniel Stone <daniels at collabora.com>
Date: Wed Apr 26 17:55:54 2017 +0200
c_client: Add support for lists of FDs
Matching xcbgen changes, add support having a ListType which contains
file descriptors. Use this to send a variable number of FDs to the
server, including when the list size is not fixed.
Signed-off-by: Daniel Stone <daniels at collabora.com>
diff --git a/src/c_client.py b/src/c_client.py
index f3fa5b1..2213a31 100644
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -2340,12 +2340,30 @@ def _c_request_helper(self, name, void, regular, aux=False, reply_fds=False):
if aux:
_c(' void *xcb_aux%d = 0;' % (idx))
if list_with_var_size_elems:
- _c(' unsigned int i;')
_c(' unsigned int xcb_tmp_len;')
_c(' char *xcb_tmp;')
- num_fds = len([field for field in param_fields if field.isfd])
- if num_fds > 0:
- _c(' int fds[%d];' % (num_fds))
+
+ num_fds_fixed = 0
+ num_fds_expr = []
+ for field in param_fields:
+ if field.isfd:
+ if not field.type.is_list:
+ num_fds_fixed += 1
+ else:
+ num_fds_expr.append(_c_accessor_get_expr(field.type.expr, None))
+
+ if list_with_var_size_elems or len(num_fds_expr) > 0:
+ _c(' unsigned int i;')
+
+ if num_fds_fixed > 0:
+ num_fds_expr.append('%d' % (num_fds_fixed))
+ if len(num_fds_expr) > 0:
+ num_fds = '+'.join(num_fds_expr)
+ _c(' int fds[%s];' % (num_fds))
+ _c(' int fd_index = 0;')
+ else:
+ num_fds = None
+
_c('')
# fixed size fields
@@ -2451,16 +2469,18 @@ def _c_request_helper(self, name, void, regular, aux=False, reply_fds=False):
# no padding necessary - _serialize() keeps track of padding automatically
_c('')
- fd_index = 0
for field in param_fields:
if field.isfd:
- _c(' fds[%d] = %s;', fd_index, field.c_field_name)
- fd_index = fd_index + 1
+ if not field.type.is_list:
+ _c(' fds[fd_index++] = %s;', field.c_field_name)
+ else:
+ _c(' for (i = 0; i < %s; i++)', _c_accessor_get_expr(field.type.expr, None))
+ _c(' fds[fd_index++] = %s[i];', field.c_field_name)
- if num_fds == 0:
+ if not num_fds:
_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)
+ _c(' xcb_ret.sequence = xcb_send_request_with_fds(c, %s, xcb_parts + 2, &xcb_req, %s, fds);', func_flags, num_fds)
# free dyn. all. data, if any
for f in free_calls:
commit c7aa4e682fdc7f0035f928af6eafd052e38cc15a
Author: Daniel Stone <daniels at collabora.com>
Date: Wed Apr 26 17:54:01 2017 +0200
c_client: Don't serialise non-wire fields
For when we have a variable-sized field followed by a fixed field, make
sure we do not serialise non-wire fields.
Signed-off-by: Daniel Stone <daniels at collabora.com>
diff --git a/src/c_client.py b/src/c_client.py
index 0cbdf30..f3fa5b1 100644
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -458,7 +458,7 @@ def _c_type_setup(self, name, postfix):
field.c_field_const_type = 'const ' + field.c_field_type
self.c_need_aux = True
- if not field.type.fixed_size() and not field.type.is_case_or_bitcase:
+ if not field.type.fixed_size() and not field.type.is_case_or_bitcase and field.wire:
self.c_need_sizeof = True
field.c_iterator_type = _t(field.field_type + ('iterator',)) # xcb_fieldtype_iterator_t
@@ -497,7 +497,7 @@ def _c_type_setup(self, name, postfix):
_c_type_setup(field.type, field.field_type, ())
if field.type.is_list:
_c_type_setup(field.type.member, field.field_type, ())
- if (field.type.nmemb is None):
+ if (field.type.nmemb is None and field.wire):
self.c_need_sizeof = True
if self.c_need_serialize:
@@ -1170,6 +1170,8 @@ def _c_serialize_helper_fields(context, self,
_c_pre.push_indent(space + ' ')
for field in self.fields:
+ if not field.wire:
+ continue
if not field.visible:
if not ((field.wire and not field.auto) or 'unserialize' == context):
continue
@@ -1194,7 +1196,9 @@ def _c_serialize_helper_fields(context, self,
# fields with variable size
else:
- if field.type.is_pad:
+ if not field.wire:
+ continue
+ elif field.type.is_pad:
# Variable length pad is <pad align= />
code_lines.append('%s xcb_align_to = %d;' % (space, field.type.align))
count += _c_serialize_helper_insert_padding(context, self, code_lines, space,
@@ -2308,7 +2312,7 @@ def _c_request_helper(self, name, void, regular, aux=False, reply_fds=False):
count = 2
if not self.c_var_followed_by_fixed_fields:
for field in param_fields:
- if not field.type.fixed_size():
+ if not field.type.fixed_size() and field.wire:
count = count + 2
if field.type.c_need_serialize:
# _serialize() keeps track of padding automatically
@@ -2379,7 +2383,7 @@ def _c_request_helper(self, name, void, regular, aux=False, reply_fds=False):
count = 4
for field in param_fields:
- if not field.type.fixed_size():
+ if field.wire and not field.type.fixed_size():
_c(' /* %s %s */', field.type.c_type, field.c_field_name)
# default: simple cast to char *
if not field.type.c_need_serialize and not field.type.c_need_sizeof:
More information about the xcb-commit
mailing list