[Xcb] [PATCH proto] xcbgen: Handle multiple <enumref> in a <bitcase>

Daniel Martin consume.noise at gmail.com
Mon May 13 14:33:03 PDT 2013


Adopt the XML schema change from commit
    ee71d96 Allow multiple <enumref> in a <bitcase>
and its usage with commit
    b3b5e02 XKB: Fix GetKbdByName.

Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
 xcbgen/xtypes.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index c97273f..5469cd9 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -481,8 +481,14 @@ class BitcaseType(ComplexType):
     '''
     def __init__(self, index, name, elt, *parent):
         elts = list(elt)
-        self.expr = Expression(elts[0] if len(elts) else elt, self)
-        ComplexType.__init__(self, name, elts[1:])        
+        self.expr = []
+        fields = []
+        for elt in elts:
+            if elt.tag == 'enumref':
+                self.expr.append(Expression(elt, self))
+            else:
+                fields.append(elt)
+        ComplexType.__init__(self, name, fields)
         self.has_name = True
         self.index = 1
         self.lenfield_parent = list(parent) + [self]
@@ -510,8 +516,9 @@ class BitcaseType(ComplexType):
     def resolve(self, module):
         if self.resolved:
             return
-        
-        self.expr.resolve(module, self.parents+[self])
+
+        for e in self.expr:
+            e.resolve(module, self.parents+[self])
 
         # Resolve the bitcase expression
         ComplexType.resolve(self, module)
-- 
1.8.2.1



More information about the Xcb mailing list