c_client.py: use pattern matching with enumerate()

Signed-off-by: Ran Benita <ran234@gmail.com>
This commit is contained in:
Ran Benita 2015-03-18 12:27:31 +02:00 committed by Christian Linhart
parent cb621341a6
commit ff6cb3913b

View File

@ -629,8 +629,7 @@ def _c_helper_resolve_field_names (prefix):
all_fields = {} all_fields = {}
tmp_prefix = [] tmp_prefix = []
# look for fields in the remaining containers # look for fields in the remaining containers
for idx, p in enumerate(prefix): for idx, (name, sep, obj) in enumerate(prefix):
name, sep, obj = p
if ''==sep: if ''==sep:
# sep can be preset in prefix, if not, make a sensible guess # sep can be preset in prefix, if not, make a sensible guess
sep = '.' if (obj.is_switch or obj.is_case_or_bitcase) else '->' sep = '.' if (obj.is_switch or obj.is_case_or_bitcase) else '->'
@ -1033,7 +1032,7 @@ def _c_serialize_helper_fields_fixed_size(context, self, field,
if not self.is_case_or_bitcase: if not self.is_case_or_bitcase:
code_lines.append('%s /* %s.%s */' % (space, self.c_type, field.c_field_name)) code_lines.append('%s /* %s.%s */' % (space, self.c_type, field.c_field_name))
else: else:
scoped_name = [p[2].c_type if idx==0 else p[0] for idx, p in enumerate(prefix)] scoped_name = [obj.c_type if idx==0 else name for idx, (name, _, obj) in enumerate(prefix)]
typename = ".".join(scoped_name) typename = ".".join(scoped_name)
code_lines.append('%s /* %s.%s */' % (space, typename, field.c_field_name)) code_lines.append('%s /* %s.%s */' % (space, typename, field.c_field_name))
@ -2291,7 +2290,7 @@ def _c_request_helper(self, name, void, regular, aux=False, reply_fds=False):
_c(' void *xcb_aux = 0;') _c(' void *xcb_aux = 0;')
for idx, f in enumerate(serial_fields): for idx, _ in enumerate(serial_fields):
if aux: if aux:
_c(' void *xcb_aux%d = 0;' % (idx)) _c(' void *xcb_aux%d = 0;' % (idx))
if list_with_var_size_elems: if list_with_var_size_elems: