mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 13:55:43 +00:00
Bug 1451363 - part 4 - consolidate generated code into IProtocol; r=mccr8
lower.py generates repetitious: SetManager(...); Register(...); // Or RegisterID. SetIPCChannel(...); calls, which are moderately sized, given that the above call sequence requires virtual calls in several places. Instead of codegenning this sequence, let's consolidate the sequence into IProtocol and change the code generator to call into the consolidated function instead.
This commit is contained in:
parent
9eac324691
commit
e77f1868f1
@ -529,6 +529,30 @@ IProtocol::SetManager(IProtocol* aManager)
|
||||
mManager = aManager;
|
||||
}
|
||||
|
||||
void
|
||||
IProtocol::SetManagerAndRegister(IProtocol* aManager)
|
||||
{
|
||||
// Set the manager prior to registering so registering properly inherits
|
||||
// the manager's event target.
|
||||
SetManager(aManager);
|
||||
|
||||
aManager->Register(this);
|
||||
|
||||
SetIPCChannel(aManager->GetIPCChannel());
|
||||
}
|
||||
|
||||
void
|
||||
IProtocol::SetManagerAndRegister(IProtocol* aManager, int32_t aId)
|
||||
{
|
||||
// Set the manager prior to registering so registering properly inherits
|
||||
// the manager's event target.
|
||||
SetManager(aManager);
|
||||
|
||||
aManager->RegisterID(this, aId);
|
||||
|
||||
SetIPCChannel(aManager->GetIPCChannel());
|
||||
}
|
||||
|
||||
void
|
||||
IProtocol::SetEventTargetForActor(IProtocol* aActor, nsIEventTarget* aEventTarget)
|
||||
{
|
||||
|
@ -314,7 +314,16 @@ protected:
|
||||
|
||||
void SetId(int32_t aId) { mId = aId; }
|
||||
void ResetManager() { mManager = nullptr; }
|
||||
// We have separate functions because the accessibility code manually
|
||||
// calls SetManager.
|
||||
void SetManager(IProtocol* aManager);
|
||||
|
||||
// Sets the manager for the protocol and registers the protocol with
|
||||
// its manager, setting up channels for the protocol as well. Not
|
||||
// for use outside of IPDL.
|
||||
void SetManagerAndRegister(IProtocol* aManager);
|
||||
void SetManagerAndRegister(IProtocol* aManager, int32_t aId);
|
||||
|
||||
void SetIPCChannel(MessageChannel* aChannel) { mChannel = aChannel; }
|
||||
|
||||
static const int32_t kNullActorId = 0;
|
||||
|
@ -3917,19 +3917,15 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
actortype = ipdl.type.ActorType(actorproto)
|
||||
|
||||
if idexpr is None:
|
||||
registerexpr = ExprCall(self.protocol.registerMethod(),
|
||||
args=[ actorvar ])
|
||||
setManagerArgs = [ExprVar.THIS]
|
||||
else:
|
||||
registerexpr = ExprCall(self.protocol.registerIDMethod(),
|
||||
args=[ actorvar, idexpr ])
|
||||
setManagerArgs = [ExprVar.THIS, idexpr]
|
||||
setmanager = ExprCall(ExprSelect(actorvar, '->', 'SetManagerAndRegister'),
|
||||
args=setManagerArgs)
|
||||
|
||||
return [
|
||||
self.failIfNullActor(actorvar, errfn, msg="Error constructing actor %s" % actortype.name() + self.side.capitalize()),
|
||||
# set manager in prior to register to inherit EventTarget from manager.
|
||||
StmtExpr(ExprCall(ExprSelect(actorvar, '->', 'SetManager'), args=[ExprVar.THIS])),
|
||||
StmtExpr(registerexpr),
|
||||
StmtExpr(ExprCall(ExprSelect(actorvar, '->', 'SetIPCChannel'),
|
||||
args=[self.protocol.callGetChannel()])),
|
||||
StmtExpr(setmanager),
|
||||
StmtExpr(_callInsertManagedActor(
|
||||
self.protocol.managedVar(md.decl.type.constructedType(),
|
||||
self.side),
|
||||
|
Loading…
Reference in New Issue
Block a user