From 38d6789b0db05005b4041705ba61005b3e0bf074 Mon Sep 17 00:00:00 2001 From: Cervantes Yu Date: Thu, 5 Dec 2013 20:10:04 +0800 Subject: [PATCH] Bug 938470 - Part 2: IPC actor should clone actors created on the parent side for the Nuwa process. r=bent --- ipc/ipdl/ipdl/lower.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index 972c19834362..f54fac19e701 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -3812,6 +3812,15 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): static=1)) clonemanagees.addstmt(otherstmt) + # Keep track of types created with an INOUT ctor. We need to call + # Register() or RegisterID() for them depending on the side the managee + # is created. + inoutCtorTypes = [] + for msg in p.messageDecls: + msgtype = msg.decl.type + if msgtype.isCtor() and msgtype.isInout(): + inoutCtorTypes.append(msgtype.constructedType()) + actorvar = ExprVar('actor') for managee in p.managesStmts: block = StmtBlock() @@ -3827,6 +3836,19 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): init=Param(Type.UINT32, ivar.name, ExprLiteral.ZERO), cond=ExprBinary(ivar, '<', _callCxxArrayLength(kidsvar)), update=ExprPrefixUnop(ivar, '++')) + + registerstmt = StmtExpr(ExprCall(p.registerIDMethod(), + args=[actorvar, _actorId(actorvar)])) + # Implement if (actor id > 0) then Register() else RegisterID() + if manageeipdltype in inoutCtorTypes: + registerif = StmtIf(ExprBinary(_actorId(actorvar), + '>', + ExprLiteral.ZERO)) + registerif.addifstmt(StmtExpr(ExprCall(p.registerMethod(), + args=[actorvar]))) + registerif.addelsestmt(registerstmt) + registerstmt = registerif + forstmt.addstmts([ StmtExpr(ExprAssn( actorvar, @@ -3847,8 +3869,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): p.channelForSubactor())), StmtExpr(ExprAssn(_actorState(actorvar), _actorState(ithkid))), StmtExpr(_callCxxArrayInsertSorted(manageearray, actorvar)), - StmtExpr(ExprCall(p.registerIDMethod(), - args=[actorvar, _actorId(actorvar)])), + registerstmt, StmtExpr(ExprCall( ExprSelect(actorvar, '->',