зеркало из https://github.com/mozilla/gecko-dev.git
Bug 779013 - Align the mValue union in IPDL-generated code. r=cjones
This commit is contained in:
Родитель
0d135d98b8
Коммит
e54b931d0c
|
@ -358,9 +358,21 @@ class TypeUnion(Node):
|
|||
Node.__init__(self)
|
||||
self.name = name
|
||||
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):
|
||||
self.components.append(Decl(type, name))
|
||||
def addComponent(self, c):
|
||||
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):
|
||||
def __init__(self, fromtype, totypename):
|
||||
|
|
|
@ -2098,7 +2098,9 @@ def _generateCxxUnion(ud):
|
|||
# the C++ union the discunion use for storage
|
||||
valueunion = TypeUnion(valuetype.name)
|
||||
for c in ud.components:
|
||||
valueunion.addComponent(c.unionType(), c.name)
|
||||
valueunion.addComponent(c);
|
||||
valueunion.addAlignment();
|
||||
|
||||
cls.addstmts([ StmtDecl(Decl(valueunion,'')),
|
||||
Whitespace.NL ])
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче