[Xcb] [PATCH proto 1/1] calculate lengthless list

Christian Linhart chris at demorecorder.com
Tue Nov 10 16:01:32 PST 2015


From: Jaya Tiwari <tiwari.jaya18 at gmail.com>

Some rework done by Christian Linhart

Signed-off-by: Jaya Tiwari <tiwari.jaya18 at gmail.com>
Signed-off-by: Christian Linhart <chris at demorecorder.com>
---
 xcbgen/xtypes.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index 4d6bbc0..6d0930b 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -177,18 +177,25 @@ class ListType(Type):
     expr is an Expression object containing the length information, for variable-sized lists.
     '''
     def __init__(self, elt, member, *parent):
         Type.__init__(self, member.name)
         self.is_list = True
         self.member = member
         self.parents = list(parent)
+        lenfield_name = False
 
         if elt.tag == 'list':
             elts = list(elt)
             self.expr = Expression(elts[0] if len(elts) else elt, self)
+            is_list_in_parent = self.parents[0].elt.tag in ('request', 'event', 'reply', 'error')
+            if not len(elts) and is_list_in_parent:
+                self.expr = Expression(elt,self)
+                self.expr.op = 'calculate_len'
+            else:
+                self.expr = Expression(elts[0] if len(elts) else elt, self)
 
         self.size = member.size if member.fixed_size() else None
         self.nmemb = self.expr.nmemb if self.expr.fixed_size() else None
 
     def make_member_of(self, module, complex_type, field_type, field_name, visible, wire, auto, enum=None):
         if not self.fixed_size():
             # We need a length field.
-- 
2.1.4



More information about the Xcb mailing list