mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1024795, part 4 - Use a default value for initializing unions, except for nsTArray. r=bent
This restores the initialization behavior prior to bug 819791, except for the one case that bug requires.
This commit is contained in:
parent
7805ea0edf
commit
4790cd3937
@ -291,6 +291,7 @@ class Type(Node):
|
||||
def __init__(self, name, const=0,
|
||||
ptr=0, ptrconst=0, ptrptr=0, ptrconstptr=0,
|
||||
ref=0,
|
||||
hasimplicitcopyctor=True,
|
||||
T=None):
|
||||
"""
|
||||
To avoid getting fancy with recursive types, we limit the kinds
|
||||
@ -315,6 +316,7 @@ Any type, naked or pointer, can be const (const T) or ref (T&).
|
||||
self.ptrptr = ptrptr
|
||||
self.ptrconstptr = ptrconstptr
|
||||
self.ref = ref
|
||||
self.hasimplicitcopyctor = hasimplicitcopyctor
|
||||
self.T = T
|
||||
# XXX could get serious here with recursive types, but shouldn't
|
||||
# need that for this codegen
|
||||
|
@ -332,7 +332,7 @@ def _refptrTake(expr):
|
||||
return ExprCall(ExprSelect(expr, '.', 'take'))
|
||||
|
||||
def _cxxArrayType(basetype, const=0, ref=0):
|
||||
return Type('nsTArray', T=basetype, const=const, ref=ref)
|
||||
return Type('nsTArray', T=basetype, const=const, ref=ref, hasimplicitcopyctor=False)
|
||||
|
||||
def _cxxFallibleArrayType(basetype, const=0, ref=0):
|
||||
return Type('FallibleTArray', T=basetype, const=const, ref=ref)
|
||||
@ -849,6 +849,11 @@ IPDL union type."""
|
||||
return t
|
||||
|
||||
def defaultValue(self):
|
||||
# Use the default constructor for any class that does not have an
|
||||
# implicit copy constructor.
|
||||
if not self.bareType().hasimplicitcopyctor:
|
||||
return None
|
||||
|
||||
if self.ipdltype.isIPDL() and self.ipdltype.isActor():
|
||||
return ExprLiteral.NULL
|
||||
# XXX sneaky here, maybe need ExprCtor()?
|
||||
@ -4692,8 +4697,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
tmpvar = ExprVar('tmp')
|
||||
ct = c.bareType()
|
||||
readcase.addstmts([
|
||||
StmtDecl(Decl(ct, tmpvar.name),
|
||||
init=c.defaultValue() if ct.ptr else None),
|
||||
StmtDecl(Decl(ct, tmpvar.name), init=c.defaultValue()),
|
||||
StmtExpr(ExprAssn(ExprDeref(var), tmpvar)),
|
||||
StmtReturn(self.read(
|
||||
c.ipdltype,
|
||||
|
Loading…
Reference in New Issue
Block a user