generator: support fixed size lists in var-sized structs
authorChristian Linhart <chris@demorecorder.com>
Thu, 21 Aug 2014 20:35:54 +0000 (22:35 +0200)
committerChristian Linhart <chris@demorecorder.com>
Sat, 6 Sep 2014 13:39:19 +0000 (15:39 +0200)
Message-ID: <1408653356-21191-1-git-send-email-chris@demorecorder.com>
Patch-Thread-Subject: [Xcb] xinput:QueryDeviceState: full-support: generator and xml-changes
Patch-Set: QueryDeviceState
Patch-Number: libxcb 1/3
Patch-Version: V1
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
Reviewed-By: Ran Benita <ran234@gmail.com>
src/c_client.py

index 87f268b..fa59fff 100644 (file)
@@ -870,8 +870,12 @@ def _c_serialize_helper_fields_fixed_size(context, self, field,
             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 *) '