summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reimann <oss@arcor.de>2010-07-15 01:06:49 +0200
committerChristoph Reimann <oss@arcor.de>2010-07-15 01:06:49 +0200
commit946817d43e10a581b75d8fcab91a6b68e31fb965 (patch)
tree59cf8ba64d92918911e0b346c005e125c4dc07f7
parent73c14cd5f2cebc0255a395c4cb1d5a85a11a0120 (diff)
assign switch name to bitcases as well (important in case of switch that appear inside another switch)
-rw-r--r--xcbgen/expr.py6
-rw-r--r--xcbgen/xtypes.py11
2 files changed, 13 insertions, 4 deletions
diff --git a/xcbgen/expr.py b/xcbgen/expr.py
index ddfb76c..274c290 100644
--- a/xcbgen/expr.py
+++ b/xcbgen/expr.py
@@ -117,7 +117,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
diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index 046513e..abfb841 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -33,6 +33,7 @@ class Type(object):
self.is_union = False
self.is_pad = False
self.is_switch = False
+ self.is_bitcase = False
def resolve(self, module):
'''
@@ -372,12 +373,14 @@ class SwitchType(ComplexType):
return
# pads = 0
+ parents = list(self.parent) + [self]
+
# Resolve all of our field datatypes.
for index, child in enumerate(list(self.elt)):
if child.tag == 'bitcase':
# use self.parent to indicate anchestor,
# as switch does not contain named fields itself
- type = BitcaseType(index, child, *self.parent)
+ type = BitcaseType(index, self.name, child, *parents)
visible = True
# Get the full type name for the field
@@ -463,12 +466,14 @@ class BitcaseType(ComplexType):
'''
Derived class representing a struct data type.
'''
- def __init__(self, index, elt, *parent):
+ def __init__(self, index, name, elt, *parent):
elts = list(elt)
self.expr = Expression(elts[0] if len(elts) else elt, self)
- ComplexType.__init__(self, ('bitcase%d' % index,), elts[1:])
+ ComplexType.__init__(self, name, elts[1:])
+ self.index = 1
self.lenfield_parent = list(parent) + [self]
self.parents = list(parent)
+ self.is_bitcase = True
def make_member_of(self, module, switch_type, field_type, field_name, visible, wire, auto):
'''