summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2019-12-01 14:23:57 +0100
committerUli Schlachter <psychon@znc.in>2019-12-28 08:30:47 +0000
commit3cc42f6d233aba508c932a7d1d5578799e9236fa (patch)
tree0f502612188561296b477e361aef5880cd634163
parent7540642b342dbadac06583b3520f6b135e280f9c (diff)
Fix size computation of imported lists
XFixes contains a CreateRegion request: <request name="CreateRegion" opcode="5"> <field type="REGION" name="region" /> <list type="RECTANGLE" name="rectangles" /> </request> This request contains a list of type RECTANGLE. This struct comes from xproto and is thus not contained in xfixes itself. Normal "Struct"s have their resolve() method called early, because they appear in the module itself. However, in the CreateRegion case, this struct is imported and thus does not get resolved. Instead, ListType's resolve() method calls self.member.resolve(module). Thus, only at this point is the struct resolved. Why is this important? Struct.resolve() is the same as ComplexType.resolve() and this function does self.calc_size() at the end. Thus, only after the struct was resolved is its size known. Before that, the size is just set to 0 (this happens in ComplexType.__init__). However, ListType.__init__ already computes its size member based on its member. At this point, this is still 0 so the list ends up believing its size to be zero. Fix this by recomputing self.size in ListType.resolve(). Signed-off-by: Uli Schlachter <psychon@znc.in>
-rw-r--r--xcbgen/xtypes.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index 0fa420b..8a9d130 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -333,6 +333,9 @@ class ListType(Type):
self.member.resolve(module)
self.expr.resolve(module, self.parents)
+ # resolve() could have changed the size (ComplexType starts with size 0)
+ self.size = self.member.size if self.member.fixed_size() else None
+
self.required_start_align = self.member.required_start_align
# Find my length field again. We need the actual Field object in the expr.