зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1096487 - part 2 - make ipdl message constructors take their routing id; r=bent
Similarly to part, there's no need to say we don't know the routing id when constructing a message, and then turn around and set the routing id immediately afterwards. Just let the constructor do its work.
This commit is contained in:
Родитель
357e2a0e8c
Коммит
3f89e62115
|
@ -1840,10 +1840,11 @@ def _generateMessageClass(clsname, msgid, priority, prettyName, compress):
|
|||
else:
|
||||
assert priority == ipdl.ast.URGENT_PRIORITY
|
||||
priorityEnum = 'IPC::Message::PRIORITY_URGENT'
|
||||
routingId = ExprVar('routingId')
|
||||
ctor = ConstructorDefn(
|
||||
ConstructorDecl(clsname),
|
||||
ConstructorDecl(clsname, params=[ Decl(Type('int32_t'), routingId.name) ]),
|
||||
memberinits=[ ExprMemberInit(ExprVar('IPC::Message'),
|
||||
[ ExprVar('MSG_ROUTING_NONE'),
|
||||
[ routingId,
|
||||
ExprVar('ID'),
|
||||
ExprVar(priorityEnum),
|
||||
compression,
|
||||
|
@ -5165,17 +5166,19 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
|||
if md.decl.type.isDtor(): this = md.actorDecl().var()
|
||||
|
||||
stmts = ([ StmtDecl(Decl(Type(md.pqMsgClass(), ptr=1), msgvar.name),
|
||||
init=ExprNew(Type(md.pqMsgClass()))) ]
|
||||
init=ExprNew(Type(md.pqMsgClass()),
|
||||
args=[ routingId ])) ]
|
||||
+ [ Whitespace.NL ]
|
||||
+ [ StmtExpr(self.write(p.ipdltype, p.var(), msgvar, this))
|
||||
for p in md.params ]
|
||||
+ [ Whitespace.NL ]
|
||||
+ self.setMessageFlags(md, msgvar, reply=0,
|
||||
routingId=routingId))
|
||||
+ self.setMessageFlags(md, msgvar, reply=0))
|
||||
return msgvar, stmts
|
||||
|
||||
|
||||
def makeReply(self, md, errfn, routingId):
|
||||
if routingId is None:
|
||||
routingId = self.protocol.routingId()
|
||||
# TODO special cases for async ctor/dtor replies
|
||||
if not md.decl.type.hasReply():
|
||||
return [ ]
|
||||
|
@ -5183,21 +5186,16 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
|||
replyvar = self.replyvar
|
||||
return (
|
||||
[ StmtExpr(ExprAssn(
|
||||
replyvar, ExprNew(Type(md.pqReplyClass()), args=[ ]))),
|
||||
replyvar, ExprNew(Type(md.pqReplyClass()), args=[ routingId ]))),
|
||||
Whitespace.NL ]
|
||||
+ [ StmtExpr(self.write(r.ipdltype, r.var(), replyvar))
|
||||
for r in md.returns ]
|
||||
+ self.setMessageFlags(md, replyvar, reply=1, routingId=routingId)
|
||||
+ self.setMessageFlags(md, replyvar, reply=1)
|
||||
+ [ self.logMessage(md, md.replyCast(replyvar), 'Sending reply ') ])
|
||||
|
||||
|
||||
def setMessageFlags(self, md, var, reply, routingId=None):
|
||||
if routingId is None:
|
||||
routingId = self.protocol.routingId()
|
||||
|
||||
stmts = [ StmtExpr(ExprCall(
|
||||
ExprSelect(var, '->', 'set_routing_id'),
|
||||
args=[ routingId ])) ]
|
||||
def setMessageFlags(self, md, var, reply):
|
||||
stmts = [ ]
|
||||
|
||||
if md.decl.type.isSync():
|
||||
stmts.append(StmtExpr(ExprCall(
|
||||
|
|
Загрузка…
Ссылка в новой задаче