[Xcb] [PATCH proto 1/1] Calculate length of length less lists
Jaya Tiwari
tiwari.jaya18 at gmail.com
Wed Apr 22 23:47:04 PDT 2015
Signed-off-by: Jaya Tiwari <tiwari.jaya18 at gmail.com>
---
xcbgen/xtypes.py | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index 4d6bbc0..7e69493 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -176,15 +176,23 @@ class ListType(Type):
parent is the structure type containing the list.
expr is an Expression object containing the length information, for variable-sized lists.
'''
- def __init__(self, elt, member, *parent):
+ def __init__(self, elt, member, num_of_var_fields, *parent):
Type.__init__(self, member.name)
self.is_list = True
self.member = member
self.parents = list(parent)
+ has_request = False
if elt.tag == 'list':
elts = list(elt)
- self.expr = Expression(elts[0] if len(elts) else elt, self)
+
+ if 'request' in str(self.parents[0].elt.tag):
+ has_request = True
+ if len(elts) == 0 and has_request and num_of_var_fields == 1:
+ 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
@@ -302,7 +310,11 @@ class ComplexType(Type):
if self.resolved:
return
enum = None
+ num_of_var_fields = 0
+ for child in self.elt:
+ if child.tag != 'pad' and child.tag != 'field':
+ num_of_var_fields = num_of_var_fields + 1
# Resolve all of our field datatypes.
for child in list(self.elt):
if child.tag == 'pad':
@@ -325,7 +337,7 @@ class ComplexType(Type):
elif child.tag == 'list':
field_name = child.get('name')
fkey = child.get('type')
- type = ListType(child, module.get_type(fkey), *self.lenfield_parent)
+ type = ListType(child, module.get_type(fkey), num_of_var_fields, *self.lenfield_parent)
visible = True
elif child.tag == 'switch':
field_name = child.get('name')
--
1.9.1
More information about the Xcb
mailing list