Bug 1338592 - Use .nested, not .nestedRange on Protocol. r=billm
The parser always sets the first value of the tuple .nestedRange to
NOT_NESTED, so there's no need to actually store it. Instead, we
create a range when we're creating the ProtocolType. This makes it
clearer what is happening. The range is needed for the type because
the nesting pair is compared with those from messages, where the first
element can be something else.
Prior to
bug 1306708, the lower range could be specified in the IPDL
file, but all uses were NOT_NESTED, so I suppose that is why it was
eliminated.
Note that the constructor for Protocol sets .nested to NOT_NESTED, but
prior to my patch, the field was never used. The constructor also
never initialized .nestedRange, but the parser always sets it so that
isn't much of an issue.
MozReview-Commit-ID: FMnoZRrkfoA
--- a/ipc/ipdl/ipdl/parser.py
+++ b/ipc/ipdl/ipdl/parser.py
@@ -332,17 +332,17 @@ def p_ComponentTypes(p):
p[1].append(p[2])
p[0] = p[1]
def p_ProtocolDefn(p):
"""ProtocolDefn : OptionalProtocolSendSemanticsQual PROTOCOL ID '{' ProtocolBody '}' ';'"""
protocol = p[5]
protocol.loc = locFromTok(p, 2)
protocol.name = p[3]
- protocol.nestedRange = p[1][0]
+ protocol.nested = p[1][0]
protocol.sendSemantics = p[1][1]
p[0] = protocol
if Parser.current.type == 'header':
_error(protocol.loc, 'can\'t define a protocol in a header. Do it in a protocol spec instead.')
def p_ProtocolBody(p):
@@ -551,30 +551,30 @@ def p_SendSemanticsQual(p):
else: assert 0
p[0] = [ quals.get('nested', NOT_NESTED), quals.get('prio', NORMAL_PRIORITY), mtype ]
def p_OptionalProtocolSendSemanticsQual(p):
"""OptionalProtocolSendSemanticsQual : ProtocolSendSemanticsQual
| """
if 2 == len(p): p[0] = p[1]
- else: p[0] = [ (NOT_NESTED, NOT_NESTED), ASYNC ]
+ else: p[0] = [ NOT_NESTED, ASYNC ]
def p_ProtocolSendSemanticsQual(p):
"""ProtocolSendSemanticsQual : ASYNC
| SYNC
| NESTED '(' UPTO Nested ')' ASYNC
| NESTED '(' UPTO Nested ')' SYNC
| INTR"""
if p[1] == 'nested':
mtype = p[6]
- nested = (NOT_NESTED, p[4])
+ nested = p[4]
else:
mtype = p[1]
- nested = (NOT_NESTED, NOT_NESTED)
+ nested = NOT_NESTED
if mtype == 'async': mtype = ASYNC
elif mtype == 'sync': mtype = SYNC
elif mtype == 'intr': mtype = INTR
else: assert 0
p[0] = [ nested, mtype ]
--- a/ipc/ipdl/ipdl/type.py
+++ b/ipc/ipdl/ipdl/type.py
@@ -208,19 +208,19 @@ class MessageType(IPDLType):
def isIn(self): return self.direction is IN
def isOut(self): return self.direction is OUT
def isInout(self): return self.direction is INOUT
def hasImplicitActorParam(self):
return self.isCtor() or self.isDtor()
class ProtocolType(IPDLType):
- def __init__(self, qname, nestedRange, sendSemantics):
+ def __init__(self, qname, nested, sendSemantics):
self.qname = qname
- self.nestedRange = nestedRange
+ self.nestedRange = (NOT_NESTED, nested)
self.sendSemantics = sendSemantics
self.managers = [] # ProtocolType
self.manages = [ ]
self.hasDelete = False
self.hasReentrantDelete = False
def isProtocol(self): return True
def name(self):
@@ -582,17 +582,17 @@ class GatherDecls(TcheckVisitor):
# to put both the namespace and non-namespaced name in the
# global scope. try to figure out something better; maybe
# a type-neutral |using| that works for C++ and protocol
# types?
qname = p.qname()
fullname = str(qname)
p.decl = self.declare(
loc=p.loc,
- type=ProtocolType(qname, p.nestedRange, p.sendSemantics),
+ type=ProtocolType(qname, p.nested, p.sendSemantics),
shortname=p.name,
fullname=None if 0 == len(qname.quals) else fullname)
p.parentEndpointDecl = self.declare(
loc=p.loc,
type=EndpointType(QualifiedId(p.loc, 'Endpoint<' + fullname + 'Parent>', ['mozilla', 'ipc'])),
shortname='Endpoint<' + p.name + 'Parent>')
p.childEndpointDecl = self.declare(