res: Add ClientIdMask enum
[free-sw/xcb/proto] / xcbgen / expr.py
index ddfb76c..4f8af6f 100644 (file)
@@ -11,11 +11,13 @@ class Field(object):
     visible is true iff the field should be in the request API.
     wire is true iff the field should be in the request structure.
     auto is true iff the field is on the wire but not in the request API (e.g. opcode)
+    enum is the enum name this field refers to, if any.
     '''
-    def __init__(self, type, field_type, field_name, visible, wire, auto):
+    def __init__(self, type, field_type, field_name, visible, wire, auto, enum=None):
         self.type = type
         self.field_type = field_type
         self.field_name = field_name
+        self.enum = enum
         self.visible = visible
         self.wire = wire
         self.auto = auto
@@ -117,7 +119,11 @@ class Expression(object):
             for p in reversed(parents): 
                 fields = dict([(f.field_name, f) for f in p.fields])
                 if self.lenfield_name in fields.keys():
-                    self.lenfield_parent = p
+                    if p.is_bitcase:
+                        # switch is the anchestor 
+                        self.lenfield_parent = p.parents[-1]
+                    else:
+                        self.lenfield_parent = p
                     self.lenfield_type = fields[self.lenfield_name].field_type
                     break