Bug 1397823 - part 1 - move work into _generateMessageConstructor; r=kanru

_generateMessageConstructor takes a lot of `md.FOO`-style parameters,
which could be derived inside the function by simply passing `md`.
Especially with the upcoming changes to calculate things like reply-ness
of messages, sync-ness, etc, we'd be wanting to pass even more
parameters like `md.FOO`.  So let's just pass `md` in, and then we can
make all the necessary future changes in a single place.
This commit is contained in:
Nathan Froyd 2017-09-15 08:06:11 -04:00
Родитель 558383f150
Коммит f4a054ab8d
1 изменённых файлов: 17 добавлений и 14 удалений

Просмотреть файл

@ -1597,24 +1597,14 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
segmentcapacity = self.segmentcapacitydict.get(name, 0)
mfDecl, mfDefn = _splitFuncDeclDefn(
_generateMessageConstructor(md.msgCtorFunc(), md.msgId(),
segmentcapacity,
md.decl.type.nested,
md.decl.type.prio,
md.prettyMsgName(p.name+'::'),
md.decl.type.compress))
_generateMessageConstructor(md, segmentcapacity, p,
forReply=False))
decls.append(mfDecl)
self.funcDefns.append(mfDefn)
if md.hasReply():
rfDecl, rfDefn = _splitFuncDeclDefn(
_generateMessageConstructor(
md.replyCtorFunc(), md.replyId(),
0,
md.decl.type.nested,
md.decl.type.prio,
md.prettyReplyName(p.name+'::'),
md.decl.type.compress))
_generateMessageConstructor(md, 0, p, forReply=True))
decls.append(rfDecl)
self.funcDefns.append(rfDefn)
@ -1711,7 +1701,20 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
##--------------------------------------------------
def _generateMessageConstructor(clsname, msgid, segmentSize, nested, prio, prettyName, compress):
def _generateMessageConstructor(md, segmentSize, protocol, forReply=False):
if forReply:
clsname = md.replyCtorFunc()
msgid = md.replyId()
prettyName = md.prettyReplyName(protocol.name+'::')
else:
clsname = md.msgCtorFunc()
msgid = md.msgId()
prettyName = md.prettyMsgName(protocol.name+'::')
nested = md.decl.type.nested
prio = md.decl.type.prio
compress = md.decl.type.compress
routingId = ExprVar('routingId')
func = FunctionDefn(FunctionDecl(