[Xcb-commit] src

Peter Harris peterh at kemper.freedesktop.org
Thu Jan 27 12:42:32 PST 2011


 src/c_client.py |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

New commits:
commit c2e023646298da05e212056fbc6b329e4dd9a100
Author: Peter Harris <pharris at opentext.com>
Date:   Thu Dec 23 13:32:17 2010 -0500

    Don't try to sizeof(void)
    
    sizeof(void) is a gcc extension, and not portable.
    
    Xorg Bugzilla 31959
    http://bugs.freedesktop.org/show_bug.cgi?id=31959
    http://lists.freedesktop.org/archives/xcb/2010-May/006039.html
    
    Signed-off-by: Peter Harris <pharris at opentext.com>
    Tested-by: Cyril Brulebois <kibi at debian.org>

diff --git a/src/c_client.py b/src/c_client.py
index 91719b7..a10b3f1 100644
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -1423,6 +1423,11 @@ def _c_accessor_get_expr(expr, field_mapping):
     else:
         return lenexp
 
+def type_pad_type(type):
+    if type == 'void':
+        return 'char'
+    return type
+
 def _c_accessors_field(self, field):
     '''
     Declares the accessor functions for a non-list field that follows a variable-length field.
@@ -1457,7 +1462,7 @@ def _c_accessors_field(self, field):
         else:
             _c('    xcb_generic_iterator_t prev = %s;', _c_iterator_get_end(field.prev_varsized_field, 'R'))
             _c('    return * (%s *) ((char *) prev.data + XCB_TYPE_PAD(%s, prev.index) + %d);', 
-               field.c_field_type, field.first_field_after_varsized.type.c_type, field.prev_varsized_offset)
+               field.c_field_type, type_pad_type(field.first_field_after_varsized.type.c_type), field.prev_varsized_offset)
         _c('}')
     else:
         _hc('')
@@ -1488,7 +1493,7 @@ def _c_accessors_field(self, field):
         else:
             _c('    xcb_generic_iterator_t prev = %s;', _c_iterator_get_end(field.prev_varsized_field, 'R'))
             _c('    return (%s) ((char *) prev.data + XCB_TYPE_PAD(%s, prev.index) + %d);', 
-               return_type, field.first_field_after_varsized.type.c_type, field.prev_varsized_offset)
+               return_type, type_pad_type(field.first_field_after_varsized.type.c_type), field.prev_varsized_offset)
         _c('}')
 
     
@@ -1575,7 +1580,7 @@ def _c_accessors_list(self, field):
         else:
             _c('    xcb_generic_iterator_t prev = %s;', _c_iterator_get_end(field.prev_varsized_field, 'R'))
             _c('    return (%s *) ((char *) prev.data + XCB_TYPE_PAD(%s, prev.index) + %d);', 
-               field.c_field_type, field.first_field_after_varsized.type.c_type, field.prev_varsized_offset)
+               field.c_field_type, type_pad_type(field.first_field_after_varsized.type.c_type), field.prev_varsized_offset)
         _c('}')
 
     _hc('')
@@ -1679,7 +1684,7 @@ def _c_accessors_list(self, field):
         else:
             _c('    xcb_generic_iterator_t prev = %s;', _c_iterator_get_end(field.prev_varsized_field, 'R'))
             _c('    i.data = (%s *) ((char *) prev.data + XCB_TYPE_PAD(%s, prev.index));', 
-               field.c_field_type, field.c_field_type)
+               field.c_field_type, type_pad_type(field.c_field_type))
         if switch_obj is None:
             _c('    i.rem = %s;', _c_accessor_get_expr(field.type.expr, fields))
         _c('    i.index = (char *) i.data - (char *) %s;', 'R' if switch_obj is None else 'S' )


More information about the xcb-commit mailing list