[Xcb] [PATCH proto 4/7] xcbgen: sumof with nested expression
Christian Linhart
chris at demorecorder.com
Wed Sep 3 04:17:57 PDT 2014
Add parser support for sumof with a nested expression.
For example:
<sumof ref="mylist1">
<fieldref>bar</fieldref>
</sumof>
The nested expression is added as the "rhs"-field of the
expression.object.
---
xcbgen/expr.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/xcbgen/expr.py b/xcbgen/expr.py
index 51e738f..ee2d3fd 100644
--- a/xcbgen/expr.py
+++ b/xcbgen/expr.py
@@ -100,14 +100,20 @@ class Expression(object):
elif elt.tag == 'enumref':
self.op = 'enumref'
self.lenfield_name = (elt.get('ref'), elt.text)
elif elt.tag == 'sumof':
self.op = 'sumof'
self.lenfield_name = elt.get('ref')
+ subexpressions = list(elt)
+ if len(subexpressions) > 0:
+ #sumof with a nested expression which is to be evaluated
+ #for each list-element in the context of that list-element.
+ #sumof then returns the sum of the results of these evaluations
+ self.rhs = Expression(subexpressions[0], parent)
else:
# Notreached
raise Exception("undefined tag '%s'" % elt.tag)
def fixed_size(self):
return self.nmemb != None
--
2.0.1
More information about the Xcb
mailing list