Bug 885804: Change IPDL codegen to rename (De)allocPFoo functions to (De)allocPFoo(Parent|Child) r=jlebar

This commit is contained in:
David Zbarsky 2013-07-08 11:48:39 -04:00
parent 3861f19f4c
commit 781af3f62f

View File

@ -7,7 +7,7 @@ from copy import deepcopy
import ipdl.ast
from ipdl.cxx.ast import *
from ipdl.type import ActorType, ProcessGraph, TypeVisitor
from ipdl.type import Actor, ActorType, ProcessGraph, TypeVisitor
# FIXME/cjones: the chromium Message logging code doesn't work on
# gcc/POSIX, because it wprintf()s across the chromium/mozilla
@ -542,11 +542,11 @@ def _cxxConstPtrToType(ipdltype, side):
t.ptrconst = 1
return t
def _allocMethod(ptype):
return ExprVar('Alloc'+ ptype.name())
def _allocMethod(ptype, side):
return ExprVar('Alloc'+ str(Actor(ptype, side)))
def _deallocMethod(ptype):
return ExprVar('Dealloc'+ ptype.name())
def _deallocMethod(ptype, side):
return ExprVar('Dealloc'+ str(Actor(ptype, side)))
##
## A _HybridDecl straddles IPDL and C++ decls. It knows which C++
@ -2687,13 +2687,13 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
actortype = md.actorDecl().bareType(self.side)
self.cls.addstmt(StmtDecl(MethodDecl(
_allocMethod(managed).name,
_allocMethod(managed, self.side).name,
params=md.makeCxxParams(side=self.side, implicit=0),
ret=actortype,
virtual=1, pure=1)))
self.cls.addstmt(StmtDecl(MethodDecl(
_deallocMethod(managed).name,
_deallocMethod(managed, self.side).name,
params=[ Decl(actortype, 'actor') ],
ret=Type.BOOL,
virtual=1, pure=1)))
@ -2703,7 +2703,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
# new channel is opened
actortype = _cxxBareType(actor.asType(), actor.side)
self.cls.addstmt(StmtDecl(MethodDecl(
_allocMethod(actor.ptype).name,
_allocMethod(actor.ptype, actor.side).name,
params=[ Decl(Type('Transport', ptr=1), 'transport'),
Decl(Type('ProcessId'), 'otherProcess') ],
ret=actortype,
@ -3325,7 +3325,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
cond=ExprBinary(ivar, '<', _callCxxArrayLength(kidsvar)),
update=ExprPrefixUnop(ivar, '++'))
foreachdealloc.addstmts([
StmtExpr(ExprCall(_deallocMethod(managed),
StmtExpr(ExprCall(_deallocMethod(managed, self.side),
args=[ ithkid ]))
])
@ -3723,7 +3723,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
"actor not managed by this!"),
Whitespace.NL,
StmtExpr(_callCxxArrayRemoveSorted(manageearray, actorvar)),
StmtExpr(ExprCall(_deallocMethod(manageeipdltype),
StmtExpr(ExprCall(_deallocMethod(manageeipdltype, self.side),
args=[ actorvar ])),
StmtReturn()
])
@ -3980,7 +3980,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
iffailopen.addifstmt(StmtReturn(_Result.ValuError))
iffailalloc = StmtIf(ExprNot(ExprCall(
_allocMethod(actor.ptype),
_allocMethod(actor.ptype, actor.side),
args=[ tvar, pidvar ])))
iffailalloc.addifstmt(StmtReturn(_Result.ProcessingError))
@ -4657,7 +4657,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
helperdecl.params = helperdecl.params[1:]
helper = MethodDefn(helperdecl)
callctor = self.callAllocActor(md, retsems='out')
callctor = self.callAllocActor(md, retsems='out', side=self.side)
helper.addstmt(StmtReturn(ExprCall(
ExprVar(helperdecl.name), args=[ callctor ] + callctor.args)))
return helper
@ -4797,7 +4797,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
# alloc the actor, register it under the foreign ID
+ [ StmtExpr(ExprAssn(
actorvar,
self.callAllocActor(md, retsems='in'))) ]
self.callAllocActor(md, retsems='in', side=self.side))) ]
+ self.ctorPrologue(md, errfn=_Result.ValuError,
idexpr=_actorHId(actorhandle))
+ [ Whitespace.NL ]
@ -5028,9 +5028,9 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
])
)
def callAllocActor(self, md, retsems):
def callAllocActor(self, md, retsems, side):
return ExprCall(
_allocMethod(md.decl.type.constructedType()),
_allocMethod(md.decl.type.constructedType(), side),
args=md.makeCxxArgs(params=1, retsems=retsems, retcallsems='out',
implicit=0))