X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fc_client.py;h=1d1bbf618ee9b0301c51953531ad2f63c3190aaf;hb=277ea629def6728c9d826ff88e95b31c3e25915f;hp=87f268b61998dd9ec7f4d26c4e31b030fb8c3258;hpb=355d4d6ab9f5c12c2ee4a91e8cf6eb4a2854d73c;p=free-sw%2Fxcb%2Flibxcb diff --git a/src/c_client.py b/src/c_client.py index 87f268b..1d1bbf6 100644 --- a/src/c_client.py +++ b/src/c_client.py @@ -358,7 +358,8 @@ def _c_type_setup(self, name, postfix): field.c_pointer = '*' field.c_field_const_type = 'const ' + field.c_field_type self.c_need_aux = True - elif 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: self.c_need_sizeof = True field.c_iterator_type = _t(field.field_type + ('iterator',)) # xcb_fieldtype_iterator_t @@ -770,6 +771,10 @@ def _c_serialize_helper_switch_field(context, self, field, c_switch_variable, pr elif context in ('unserialize', 'unpack'): length = "%s(xcb_tmp, %s&%s%s)" % (field.type.c_unpack_name, c_field_names, prefix_str, field.c_field_name) + elif 'sizeof' == context: + # remove trailing ", " from c_field_names because it will be used at end of arglist + my_c_field_names = c_field_names[:-2] + length = "%s(xcb_tmp, %s)" % (field.type.c_sizeof_name, my_c_field_names) return length # _c_serialize_helper_switch_field() @@ -869,9 +874,13 @@ def _c_serialize_helper_fields_fixed_size(context, self, field, # total padding = sizeof(pad0) * nmemb length += " * %d" % field.type.nmemb - if field.type.is_list: - # no such case in the protocol, cannot be tested and therefore ignored for now - raise Exception('list with fixed number of elemens unhandled in _unserialize()') + elif field.type.is_list: + # list with fixed number of elements + # length of array = sizeof(arrayElementType) * nmemb + length += " * %d" % field.type.nmemb + # use memcpy because C cannot assign whole arrays with operator= + value = ' memcpy(%s, xcb_tmp, %s);' % (abs_field_name, length) + elif 'serialize' == context: value = ' xcb_parts[xcb_parts_idx].iov_base = (char *) ' @@ -1042,7 +1051,12 @@ def _c_serialize_helper_fields(context, self, code_lines.append('%s xcb_parts_idx++;' % space) count += 1 - code_lines.append('%s xcb_align_to = ALIGNOF(%s);' % (space, 'char' if field.c_field_type == 'void' else field.c_field_type)) + code_lines.append( + '%s xcb_align_to = ALIGNOF(%s);' + % (space, + 'char' + if field.c_field_type == 'void' or field.type.is_switch + else field.c_field_type)) need_padding = True if self.c_var_followed_by_fixed_fields: