mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 779013 - Align the mValue union in IPDL-generated code. r=cjones
This commit is contained in:
parent
84abd878e1
commit
f7e93b5541
@ -358,9 +358,21 @@ class TypeUnion(Node):
|
|||||||
Node.__init__(self)
|
Node.__init__(self)
|
||||||
self.name = name
|
self.name = name
|
||||||
self.components = [ ] # [ Decl ]
|
self.components = [ ] # [ Decl ]
|
||||||
|
# Expr -- evaluates to a constant value representing
|
||||||
|
# the maximum alignment of all types in the union
|
||||||
|
self.alignment = None
|
||||||
|
|
||||||
def addComponent(self, type, name):
|
def addComponent(self, c):
|
||||||
self.components.append(Decl(type, name))
|
self.components.append(Decl(c.unionType(), c.name))
|
||||||
|
alignme = ExprCall(ExprVar('MOZ_ALIGNOF'), [ c.internalType() ])
|
||||||
|
if self.alignment:
|
||||||
|
self.alignment = ExprCall(ExprVar('PR_MAX'), [ alignme, self.alignment ])
|
||||||
|
else:
|
||||||
|
self.alignment = alignme
|
||||||
|
|
||||||
|
def addAlignment(self):
|
||||||
|
if self.alignment:
|
||||||
|
self.components.append(Decl(Type('mozilla::AlignedElem', T=self.alignment), '__align'))
|
||||||
|
|
||||||
class Typedef(Node):
|
class Typedef(Node):
|
||||||
def __init__(self, fromtype, totypename):
|
def __init__(self, fromtype, totypename):
|
||||||
|
@ -2098,7 +2098,9 @@ def _generateCxxUnion(ud):
|
|||||||
# the C++ union the discunion use for storage
|
# the C++ union the discunion use for storage
|
||||||
valueunion = TypeUnion(valuetype.name)
|
valueunion = TypeUnion(valuetype.name)
|
||||||
for c in ud.components:
|
for c in ud.components:
|
||||||
valueunion.addComponent(c.unionType(), c.name)
|
valueunion.addComponent(c);
|
||||||
|
valueunion.addAlignment();
|
||||||
|
|
||||||
cls.addstmts([ StmtDecl(Decl(valueunion,'')),
|
cls.addstmts([ StmtDecl(Decl(valueunion,'')),
|
||||||
Whitespace.NL ])
|
Whitespace.NL ])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user