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

Christian Linhart chris at demorecorder.com
Thu Aug 21 13:35:54 PDT 2014


---
 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:
-            # 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



More information about the Xcb mailing list