mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1306708 - Add prio() for message priority to IPDL (r=dvander)
This commit is contained in:
parent
f478d1188c
commit
1f13f73c7f
@ -8,6 +8,9 @@ NOT_NESTED = 1
|
||||
INSIDE_SYNC_NESTED = 2
|
||||
INSIDE_CPOW_NESTED = 3
|
||||
|
||||
NORMAL_PRIORITY = 1
|
||||
HIGH_PRIORITY = 2
|
||||
|
||||
class Visitor:
|
||||
def defaultVisit(self, node):
|
||||
raise Exception, "INTERNAL ERROR: no visitor for node type `%s'"% (
|
||||
@ -297,6 +300,7 @@ class MessageDecl(Node):
|
||||
self.name = None
|
||||
self.sendSemantics = ASYNC
|
||||
self.nested = NOT_NESTED
|
||||
self.prio = NORMAL_PRIORITY
|
||||
self.direction = None
|
||||
self.inParams = [ ]
|
||||
self.outParams = [ ]
|
||||
|
@ -1686,6 +1686,7 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
|
||||
mfDecl, mfDefn = _splitFuncDeclDefn(
|
||||
_generateMessageConstructor(md.msgCtorFunc(), md.msgId(),
|
||||
md.decl.type.nested,
|
||||
md.decl.type.prio,
|
||||
md.prettyMsgName(p.name+'::'),
|
||||
md.decl.type.compress))
|
||||
decls.append(mfDecl)
|
||||
@ -1696,6 +1697,7 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
|
||||
_generateMessageConstructor(
|
||||
md.replyCtorFunc(), md.replyId(),
|
||||
md.decl.type.nested,
|
||||
md.decl.type.prio,
|
||||
md.prettyReplyName(p.name+'::'),
|
||||
md.decl.type.compress))
|
||||
decls.append(rfDecl)
|
||||
@ -1926,7 +1928,7 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
|
||||
|
||||
##--------------------------------------------------
|
||||
|
||||
def _generateMessageConstructor(clsname, msgid, nested, prettyName, compress):
|
||||
def _generateMessageConstructor(clsname, msgid, nested, prio, prettyName, compress):
|
||||
routingId = ExprVar('routingId')
|
||||
|
||||
func = FunctionDefn(FunctionDecl(
|
||||
@ -1950,12 +1952,18 @@ def _generateMessageConstructor(clsname, msgid, nested, prettyName, compress):
|
||||
assert nested == ipdl.ast.INSIDE_CPOW_NESTED
|
||||
nestedEnum = 'IPC::Message::NESTED_INSIDE_CPOW'
|
||||
|
||||
if prio == ipdl.ast.NORMAL_PRIORITY:
|
||||
prioEnum = 'IPC::Message::NORMAL_PRIORITY'
|
||||
else:
|
||||
assert prio == ipdl.ast.HIGH_PRIORITY
|
||||
prioEnum = 'IPC::Message::HIGH_PRIORITY'
|
||||
|
||||
func.addstmt(
|
||||
StmtReturn(ExprNew(Type('IPC::Message'),
|
||||
args=[ routingId,
|
||||
ExprVar(msgid),
|
||||
ExprVar(nestedEnum),
|
||||
ExprVar('IPC::Message::NORMAL_PRIORITY'),
|
||||
ExprVar(prioEnum),
|
||||
compression,
|
||||
ExprLiteral.String(prettyName) ])))
|
||||
|
||||
|
@ -138,6 +138,7 @@ reserved = set((
|
||||
'opens',
|
||||
'or',
|
||||
'parent',
|
||||
'prio',
|
||||
'protocol',
|
||||
'recv',
|
||||
'returns',
|
||||
@ -500,7 +501,8 @@ def p_MessageDecl(p):
|
||||
"""MessageDecl : SendSemanticsQual MessageBody"""
|
||||
msg = p[2]
|
||||
msg.nested = p[1][0]
|
||||
msg.sendSemantics = p[1][1]
|
||||
msg.prio = p[1][1]
|
||||
msg.sendSemantics = p[1][2]
|
||||
|
||||
if Parser.current.direction is None:
|
||||
_error(msg.loc, 'missing message direction')
|
||||
@ -646,27 +648,48 @@ def p_Nested(p):
|
||||
if p[1] not in kinds:
|
||||
_error(locFromTok(p, 1), "Expected not, inside_sync, or inside_cpow for nested()")
|
||||
|
||||
p[0] = kinds[p[1]]
|
||||
p[0] = { 'nested': kinds[p[1]] }
|
||||
|
||||
def p_Priority(p):
|
||||
"""Priority : ID"""
|
||||
kinds = {'normal': 1,
|
||||
'high': 2}
|
||||
if p[1] not in kinds:
|
||||
_error(locFromTok(p, 1), "Expected normal or high for prio()")
|
||||
|
||||
p[0] = { 'prio': kinds[p[1]] }
|
||||
|
||||
def p_SendQualifier(p):
|
||||
"""SendQualifier : NESTED '(' Nested ')'
|
||||
| PRIO '(' Priority ')'"""
|
||||
p[0] = p[3]
|
||||
|
||||
def p_SendQualifierList(p):
|
||||
"""SendQualifierList : SendQualifier SendQualifierList
|
||||
| """
|
||||
if len(p) > 1:
|
||||
p[0] = p[1]
|
||||
p[0].update(p[2])
|
||||
else:
|
||||
p[0] = {}
|
||||
|
||||
def p_SendSemanticsQual(p):
|
||||
"""SendSemanticsQual : ASYNC
|
||||
| SYNC
|
||||
| NESTED '(' Nested ')' ASYNC
|
||||
| NESTED '(' Nested ')' SYNC
|
||||
"""SendSemanticsQual : SendQualifierList ASYNC
|
||||
| SendQualifierList SYNC
|
||||
| INTR"""
|
||||
if p[1] == 'nested':
|
||||
mtype = p[5]
|
||||
nested = p[3]
|
||||
quals = {}
|
||||
if len(p) == 3:
|
||||
quals = p[1]
|
||||
mtype = p[2]
|
||||
else:
|
||||
mtype = p[1]
|
||||
nested = NOT_NESTED
|
||||
mtype = 'intr'
|
||||
|
||||
if mtype == 'async': mtype = ASYNC
|
||||
elif mtype == 'sync': mtype = SYNC
|
||||
elif mtype == 'intr': mtype = INTR
|
||||
else: assert 0
|
||||
|
||||
p[0] = [ nested, mtype ]
|
||||
p[0] = [ quals.get('nested', NOT_NESTED), quals.get('prio', NORMAL_PRIORITY), mtype ]
|
||||
|
||||
def p_OptionalProtocolSendSemanticsQual(p):
|
||||
"""OptionalProtocolSendSemanticsQual : ProtocolSendSemanticsQual
|
||||
|
@ -251,13 +251,14 @@ class StateType(IPDLType):
|
||||
return self.name()
|
||||
|
||||
class MessageType(IPDLType):
|
||||
def __init__(self, nested, sendSemantics, direction,
|
||||
def __init__(self, nested, prio, sendSemantics, direction,
|
||||
ctor=False, dtor=False, cdtype=None, compress=False,
|
||||
verify=False):
|
||||
assert not (ctor and dtor)
|
||||
assert not (ctor or dtor) or type is not None
|
||||
|
||||
self.nested = nested
|
||||
self.prio = prio
|
||||
self.nestedRange = (nested, nested)
|
||||
self.sendSemantics = sendSemantics
|
||||
self.direction = direction
|
||||
@ -1125,7 +1126,7 @@ class GatherDecls(TcheckVisitor):
|
||||
# enter message scope
|
||||
self.symtab.enterScope(md)
|
||||
|
||||
msgtype = MessageType(md.nested, md.sendSemantics, md.direction,
|
||||
msgtype = MessageType(md.nested, md.prio, md.sendSemantics, md.direction,
|
||||
ctor=isctor, dtor=isdtor, cdtype=cdtype,
|
||||
compress=md.compress, verify=md.verify)
|
||||
|
||||
|
14
ipc/ipdl/test/cxx/PTestPriority.ipdl
Normal file
14
ipc/ipdl/test/cxx/PTestPriority.ipdl
Normal file
@ -0,0 +1,14 @@
|
||||
namespace mozilla {
|
||||
namespace _ipdltest {
|
||||
|
||||
sync protocol PTestPriority {
|
||||
parent:
|
||||
prio(high) async Msg1();
|
||||
prio(high) sync Msg2();
|
||||
|
||||
child:
|
||||
prio(high) async Msg3();
|
||||
};
|
||||
|
||||
} // namespace _ipdltest
|
||||
} // namespace mozilla
|
@ -107,6 +107,7 @@ IPDL_SOURCES += [
|
||||
'PTestNestedLoops.ipdl',
|
||||
'PTestOpens.ipdl',
|
||||
'PTestOpensOpened.ipdl',
|
||||
'PTestPriority.ipdl',
|
||||
'PTestRaceDeadlock.ipdl',
|
||||
'PTestRaceDeferral.ipdl',
|
||||
'PTestRacyInterruptReplies.ipdl',
|
||||
|
Loading…
Reference in New Issue
Block a user