[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-xcb
Subject:    [Xcb] [PATCH libxcb v2 2/4] c_client: Don't serialise non-wire fields
From:       Daniel Stone <daniels () collabora ! com>
Date:       2017-06-08 18:41:09
Message-ID: 20170608184111.4704-3-daniels () collabora ! com
[Download RAW message or body]

For when we have a variable-sized field followed by a fixed field, make
sure we do not serialise non-wire fields.

Signed-off-by: Daniel Stone <daniels@collabora.com>
---
 src/c_client.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

v2: Do the same in more places.

diff --git a/src/c_client.py b/src/c_client.py
index 0cbdf30..f3fa5b1 100644
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -458,7 +458,7 @@ def _c_type_setup(self, name, postfix):
                 field.c_field_const_type = 'const ' + field.c_field_type
                 self.c_need_aux = True
 
-            if not field.type.fixed_size() and not field.type.is_case_or_bitcase:
+            if not field.type.fixed_size() and not field.type.is_case_or_bitcase and field.wire:
                 self.c_need_sizeof = True
 
             field.c_iterator_type = _t(field.field_type + ('iterator',))      # xcb_fieldtype_iterator_t
@@ -497,7 +497,7 @@ def _c_type_setup(self, name, postfix):
             _c_type_setup(field.type, field.field_type, ())
             if field.type.is_list:
                 _c_type_setup(field.type.member, field.field_type, ())
-                if (field.type.nmemb is None):
+                if (field.type.nmemb is None and field.wire):
                     self.c_need_sizeof = True
 
     if self.c_need_serialize:
@@ -1170,6 +1170,8 @@ def _c_serialize_helper_fields(context, self,
     _c_pre.push_indent(space + '    ')
 
     for field in self.fields:
+        if not field.wire:
+            continue
         if not field.visible:
             if not ((field.wire and not field.auto) or 'unserialize' == context):
                 continue
@@ -1194,7 +1196,9 @@ def _c_serialize_helper_fields(context, self,
 
         # fields with variable size
         else:
-            if field.type.is_pad:
+            if not field.wire:
+                continue
+            elif field.type.is_pad:
                 # Variable length pad is <pad align= />
                 code_lines.append('%s    xcb_align_to = %d;' % (space, field.type.align))
                 count += _c_serialize_helper_insert_padding(context, self, code_lines, space,
@@ -2308,7 +2312,7 @@ def _c_request_helper(self, name, void, regular, aux=False, reply_fds=False):
     count = 2
     if not self.c_var_followed_by_fixed_fields:
         for field in param_fields:
-            if not field.type.fixed_size():
+            if not field.type.fixed_size() and field.wire:
                 count = count + 2
                 if field.type.c_need_serialize:
                     # _serialize() keeps track of padding automatically
@@ -2379,7 +2383,7 @@ def _c_request_helper(self, name, void, regular, aux=False, reply_fds=False):
         count = 4
 
         for field in param_fields:
-            if not field.type.fixed_size():
+            if field.wire and not field.type.fixed_size():
                 _c('    /* %s %s */', field.type.c_type, field.c_field_name)
                 # default: simple cast to char *
                 if not field.type.c_need_serialize and not field.type.c_need_sizeof:
-- 
2.13.0

_______________________________________________
Xcb mailing list
Xcb@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/xcb
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic