X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fc_client.py;h=1f3277a9034022493747cdfc9ac6d3a5bd006e50;hb=29cca33b9001961fa2c33bb9d9fe4a9983913fce;hp=8e79480cde1b1a42b0d9a351f2201b48bea00b3a;hpb=22e1013131984a217e9bddeac3a6a4183e35f0c1;p=free-sw%2Fxcb%2Flibxcb diff --git a/src/c_client.py b/src/c_client.py index 8e79480..1f3277a 100644 --- a/src/c_client.py +++ b/src/c_client.py @@ -399,8 +399,9 @@ def _c_type_setup(self, name, postfix): if self.need_sizeof: if self.c_sizeof_name not in finished_sizeof: - finished_sizeof.append(self.c_sizeof_name) - _c_serialize('sizeof', self) + if not module.namespace.is_ext or self.name[:2] == module.namespace.prefix: + finished_sizeof.append(self.c_sizeof_name) + _c_serialize('sizeof', self) # _c_type_setup() def _c_helper_absolute_name(prefix, field=None): @@ -874,7 +875,7 @@ def _c_serialize_helper_fields_variable_size(context, self, field, # special case: intermixed fixed and variable size fields if self.var_followed_by_fixed_fields and 'unserialize' == context: - value = ' %s = xcb_tmp;' % field.c_field_name + value = ' %s = (%s *)xcb_tmp;' % (field.c_field_name, field.c_field_type) temp_vars.append(' %s *%s;' % (field.type.c_type, field.c_field_name)) # special case: switch if 'unpack' == context: @@ -1133,8 +1134,7 @@ def _c_serialize(context, self): return elif self.var_followed_by_fixed_fields: # special case: call _unserialize() - _c(' %s *_aux = NULL;', self.c_type) - _c(' return %s(%s, &_aux);', self.c_unserialize_name, reduce(lambda x,y: "%s, %s" % (x, y), param_names)) + _c(' return %s(%s, NULL);', self.c_unserialize_name, reduce(lambda x,y: "%s, %s" % (x, y), param_names)) _c('}') return else: @@ -1179,6 +1179,12 @@ def _c_serialize(context, self): # allocate memory and copy everything into a continuous memory area # note: this is not necessary in case of unpack if context in ('serialize', 'unserialize'): + # unserialize: check for sizeof-only invocation + if 'unserialize' == context: + _c('') + _c(' if (NULL == _aux)') + _c(' return xcb_buffer_len;') + _c('') _c(' if (NULL == %s) {', aux_ptr) _c(' /* allocate memory */') @@ -1212,12 +1218,13 @@ def _c_serialize(context, self): # unserialize: assign variable size fields individually if 'unserialize' == context: - _c(' *%s = xcb_out;', aux_ptr) - _c(' xcb_tmp = (char *)(*_aux+1);') + _c(' xcb_tmp = ((char *)*_aux)+xcb_buffer_len;') + param_fields.reverse() for field in param_fields: if not field.type.fixed_size(): - _c(' memcpy(xcb_tmp, %s, %s_len);', field.c_field_name, field.c_field_name) - _c(' xcb_tmp += %s_len;', field.c_field_name) + _c(' xcb_tmp -= %s_len;', field.c_field_name) + _c(' memmove(xcb_tmp, %s, %s_len);', field.c_field_name, field.c_field_name) + _c(' *%s = xcb_out;', aux_ptr) _c('') _c(' return xcb_buffer_len;') @@ -1293,11 +1300,13 @@ def _c_iterator(self, name): _c(' xcb_generic_iterator_t child;') _c(' child.data = (%s *)(((char *)R) + %s(R));', self.c_type, self.c_sizeof_name) + _c(' i->index = (char *) child.data - (char *) i->data;') else: _c(' xcb_generic_iterator_t child = %s;', _c_iterator_get_end(self.last_varsized_field, 'R')) + _c(' i->index = child.index;') _c(' --i->rem;') _c(' i->data = (%s *) child.data;', self.c_type) - _c(' i->index = child.index;') + else: _c(' --i->rem;') _c(' ++i->data;') @@ -1937,7 +1946,7 @@ def _c_request_helper(self, name, cookie_type, void, regular, aux=False): _c(' %s xcb_out;', self.c_type) if self.var_followed_by_fixed_fields: _c(' /* in the protocol description, variable size fields are followed by fixed size fields */') - _c(' char *xcb_aux = 0;') + _c(' void *xcb_aux = 0;') for idx, f in enumerate(serial_fields):