generator: support fixed size lists in var-sized structs
authorChristian Linhart <chris@DemoRecorder.com>
Sat, 6 Sep 2014 18:06:15 +0000 (20:06 +0200)
committerChristian Linhart <chris@demorecorder.com>
Tue, 9 Sep 2014 21:54:41 +0000 (23:54 +0200)
V2: patch revised according to suggestions from Ran Benita:
* removed blanks before an after parentheses of function-calls or tuples
* replaced if by elif in "if field.type.is_list". ( this fixes old code )

Message-ID: <540B4D17.1080908@DemoRecorder.com>
Patch-Thread-Subject: [Xcb] xinput:QueryDeviceState: full-support: generator and xml-changes
Patch-Set: QueryDeviceState
Patch-Number: libxcb 1/3
Patch-Version: V2
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
Reviewed-By: Ran Benita <ran234@gmail.com>
src/c_client.py

index 87f268b..6f8f8f2 100644 (file)
@@ -869,9 +869,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 *) '