[Xcb] [PATCH libxcb 1/3] generator: support fixed size lists in var-sized structs

Ran Benita ran234 at gmail.com
Fri Sep 5 06:30:16 PDT 2014


On Thu, Aug 21, 2014 at 10:35:54PM +0200, Christian Linhart wrote:
> ---
>  src/c_client.py | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/c_client.py b/src/c_client.py
> index 87f268b..fa59fff 100644
> --- a/src/c_client.py
> +++ b/src/c_client.py
> @@ -866,16 +866,20 @@ def _c_serialize_helper_fields_fixed_size(context, self, field,
>              for i in range(field.type.nmemb):
>                  code_lines.append('%s    %s[%d] = *(%s *)xcb_tmp;' %
>                                    (space, abs_field_name, i, field.c_field_type))
>              # total padding = sizeof(pad0) * nmemb
>              length += " * %d" % field.type.nmemb
>  
>          if field.type.is_list:

Another small comment: maybe while you're here you can change this to
`elif`.

Ran

> -            # 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()')
> +            #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 *) '
>  
>          if field.type.is_expr:
>              # need to register a temporary variable for the expression in case we know its type
>              if field.type.c_type is None:
> -- 
> 2.0.1
> 
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb


More information about the Xcb mailing list