X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=xcbgen%2Fexpr.py;h=a03703f4fd248b11653d1c7cbcf247b41e5e4f77;hb=8c5c89f9f6c8e2b7334bdf19d47209e1ade4ef7c;hp=ddfb76c00d0bf09e5911206ea5798a127ca0ff04;hpb=d30664b58016687379d42d18056827fe57830d20;p=free-sw%2Fxcb%2Fproto diff --git a/xcbgen/expr.py b/xcbgen/expr.py index ddfb76c..a03703f 100644 --- a/xcbgen/expr.py +++ b/xcbgen/expr.py @@ -11,14 +11,18 @@ 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, isfd=False): 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 + self.isfd = isfd + self.parent = None class Expression(object): @@ -100,6 +104,12 @@ class Expression(object): 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 @@ -117,7 +127,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_case_or_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