new file mode 100644
--- /dev/null
+++ b/ipc/ipdl/.flake8
@@ -0,0 +1,5 @@
+[flake8]
+# See http://pep8.readthedocs.io/en/latest/intro.html#configuration
+ignore = E121, E123, E126, E129, E133, E226, E241, E242, E704, W503, E402, E741, F405, F403
+max-line-length = 99
+
--- a/ipc/ipdl/ipdl.py
+++ b/ipc/ipdl/ipdl.py
@@ -1,26 +1,23 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
import optparse
import os
-import re
import sys
from cStringIO import StringIO
-import mozpack.path as mozpath
from ConfigParser import RawConfigParser
import ipdl
def log(minv, fmt, *args):
if _verbosity >= minv:
- print fmt % args
+ print(fmt % args)
# process command line
op = optparse.OptionParser(usage='ipdl.py [options] IPDLfiles...')
op.add_option('-I', '--include', dest='includedirs', default=[],
action='append',
help='Additional directory to search for included protocol specifications')
@@ -106,17 +103,17 @@ for f in files:
sys.exit(1)
log(2, 'checking types')
if not ipdl.typecheck(ast):
print >>sys.stderr, 'Specification is not well typed.'
sys.exit(1)
if not ipdl.checkSyncMessage(ast, syncMsgList):
- print >>sys.stderr, 'Error: New sync IPC messages must be reviewed by an IPC peer and recorded in %s' % options.syncMsgList
+ print >>sys.stderr, 'Error: New sync IPC messages must be reviewed by an IPC peer and recorded in %s' % options.syncMsgList # NOQA: E501
sys.exit(1)
if not ipdl.checkFixedSyncMessages(parser):
# Errors have alraedy been printed to stderr, just exit
sys.exit(1)
# Second pass: generate code
for f in files:
--- a/ipc/ipdl/ipdl/ast.py
+++ b/ipc/ipdl/ipdl/ast.py
@@ -1,27 +1,25 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-import sys
-
NOT_NESTED = 1
INSIDE_SYNC_NESTED = 2
INSIDE_CPOW_NESTED = 3
NORMAL_PRIORITY = 1
INPUT_PRIORITY = 2
HIGH_PRIORITY = 3
class Visitor:
def defaultVisit(self, node):
- raise Exception, "INTERNAL ERROR: no visitor for node type `%s'" % (
- node.__class__.__name__)
+ raise Exception("INTERNAL ERROR: no visitor for node type `%s'" %
+ (node.__class__.__name__))
def visitTranslationUnit(self, tu):
for cxxInc in tu.cxxIncludes:
cxxInc.accept(self)
for inc in tu.includes:
inc.accept(self)
for su in tu.structsAndUnions:
su.accept(self)
@@ -304,17 +302,17 @@ class MessageDecl(Node):
def addModifiers(self, modifiers):
for modifier in modifiers:
if modifier.startswith('compress'):
self.compress = modifier
elif modifier == 'verify':
self.verify = modifier
elif modifier != '':
- raise Exception, "Unexpected message modifier `%s'" % modifier
+ raise Exception("Unexpected message modifier `%s'" % modifier)
class Param(Node):
def __init__(self, loc, typespec, name):
Node.__init__(self, loc)
self.name = name
self.typespec = typespec
--- a/ipc/ipdl/ipdl/cgen.py
+++ b/ipc/ipdl/ipdl/cgen.py
@@ -1,13 +1,12 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-import os
import sys
from ipdl.ast import Visitor
class CodePrinter:
def __init__(self, outf=sys.stdout, indentCols=4):
self.outf = outf
@@ -38,17 +37,17 @@ Also known as pretty-printing.'''
def __init__(self, outf=sys.stdout, indentCols=4, printed=set()):
CodePrinter.__init__(self, outf, indentCols)
self.printed = printed
def visitTranslationUnit(self, tu):
self.printed.add(tu.filename)
self.println('//\n// Automatically generated by ipdlc\n//')
- CodeGen.visitTranslationUnit(self, tu)
+ CodeGen.visitTranslationUnit(self, tu) # NOQA: F821
def visitCxxInclude(self, inc):
self.println('include "' + inc.file + '";')
def visitProtocolInclude(self, inc):
self.println('include protocol "' + inc.file + '";')
if inc.tu.filename not in self.printed:
self.println('/* Included file:')
--- a/ipc/ipdl/ipdl/cxx/__init__.py
+++ b/ipc/ipdl/ipdl/cxx/__init__.py
@@ -1,6 +1,3 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-import ipdl.cxx.ast
-import ipdl.cxx.cgen
--- a/ipc/ipdl/ipdl/cxx/ast.py
+++ b/ipc/ipdl/ipdl/cxx/ast.py
@@ -1,20 +1,19 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import copy
-import sys
class Visitor:
def defaultVisit(self, node):
- raise Exception, "INTERNAL ERROR: no visitor for node type `%s'" % (
- node.__class__.__name__)
+ raise Exception("INTERNAL ERROR: no visitor for node type `%s'" %
+ (node.__class__.__name__))
def visitWhitespace(self, ws):
pass
def visitFile(self, f):
for thing in f.stuff:
thing.accept(self)
@@ -373,19 +372,16 @@ Type.AUTO = Type('auto')
class TypeArray(Node):
def __init__(self, basetype, nmemb):
'''the type |basetype DECLNAME[nmemb]|. |nmemb| is an Expr'''
self.basetype = basetype
self.nmemb = nmemb
- def __deepcopy__(self, memo):
- return TypeArray(deepcopy(self.basetype, memo), nmemb)
-
class TypeEnum(Node):
def __init__(self, name=None):
'''name can be None'''
Node.__init__(self)
self.name = name
self.idnums = [] # pairs of ('Foo', [num]) or ('Foo', None)
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -1,15 +1,13 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-import os
import re
-import sys
from copy import deepcopy
from collections import OrderedDict
import ipdl.ast
import ipdl.builtin
from ipdl.cxx.ast import *
from ipdl.type import ActorType, UnionType, TypeVisitor, builtinHeaderIncludes
@@ -1735,18 +1733,20 @@ class _GenerateProtocolCode(ipdl.ast.Vis
childpidvar = ExprVar('aChildDestPid')
parentvar = ExprVar('aParent')
childvar = ExprVar('aChild')
openfunc = MethodDefn(MethodDecl(
methodvar.name,
params=[Decl(Type('base::ProcessId'), parentpidvar.name),
Decl(Type('base::ProcessId'), childpidvar.name),
- Decl(Type('mozilla::ipc::Endpoint<' + tparent.name + '>', ptr=1), parentvar.name),
- Decl(Type('mozilla::ipc::Endpoint<' + tchild.name + '>', ptr=1), childvar.name)],
+ Decl(Type('mozilla::ipc::Endpoint<' + tparent.name + '>', ptr=1),
+ parentvar.name),
+ Decl(Type('mozilla::ipc::Endpoint<' + tchild.name + '>', ptr=1),
+ childvar.name)],
ret=rettype))
openfunc.addstmt(StmtReturn(ExprCall(
ExprVar('mozilla::ipc::CreateEndpoints'),
args=[_backstagePass(),
parentpidvar, childpidvar,
parentvar, childvar
])))
return openfunc
@@ -2024,17 +2024,18 @@ class _ParamTraits():
# IPC::WriteParam(..)
write += [ifnull,
StmtExpr(cls.write(idvar, cls.msgvar, cls.actor))]
# bool Read(..) impl
actorvar = ExprVar('actor')
read = [
- StmtDecl(Decl(Type('mozilla::Maybe', T=Type('mozilla::ipc::IProtocol', ptr=1)), actorvar.name),
+ StmtDecl(Decl(Type('mozilla::Maybe', T=Type('mozilla::ipc::IProtocol',
+ ptr=1)), actorvar.name),
init=ExprCall(ExprSelect(cls.actor, '->', 'ReadActor'),
args=[cls.msgvar,
cls.itervar,
ExprLiteral.TRUE, # XXX(nika): Do we still need this arg?
ExprLiteral.String(actortype.name()),
_protocolId(actortype)])),
]
@@ -2290,20 +2291,16 @@ def _generateCxxStruct(sd):
+ usingTypedefs
+ [Whitespace.NL, Label.PUBLIC])
constreftype = Type(sd.name, const=1, ref=1)
def fieldsAsParamList():
return [Decl(f.inType(), f.argVar().name) for f in sd.fields]
- def assignFromOther(oexpr):
- return ExprCall(assignvar,
- args=[f.initExpr(oexpr) for f in sd.fields])
-
# If this is an empty struct (no fields), then the default ctor
# and "create-with-fields" ctors are equivalent. So don't bother
# with the default ctor.
if len(sd.fields):
# Struct()
defctor = ConstructorDefn(ConstructorDecl(sd.name, force_inline=1))
# We want to explicitly default-construct every member of the struct.
@@ -2630,20 +2627,22 @@ def _generateCxxUnion(ud):
case.addstmts([
# ptr_C() = other.ptr_C()
StmtExpr(ExprAssn(c.callGetPtr(),
ExprCall(ExprSelect(othervar, '.', ExprVar(c.getPtrName())))))
])
else:
case.addstmts([
# new ... (Move(other.get_C()))
- StmtExpr(c.callCtor(ExprMove(ExprCall(ExprSelect(othervar, '.', c.getTypeName()))))),
+ StmtExpr(c.callCtor(ExprMove(ExprCall(ExprSelect(othervar, '.',
+ c.getTypeName()))))),
# other.MaybeDestroy(T__None)
StmtExpr(
- voidCast(ExprCall(ExprSelect(othervar, '.', maybedtorvar), args=[tnonevar]))),
+ voidCast(ExprCall(ExprSelect(othervar, '.', maybedtorvar),
+ args=[tnonevar]))),
])
case.addstmts([StmtBreak()])
moveswitch.addcase(CaseLabel(c.enum()), case)
moveswitch.addcase(CaseLabel(tnonevar.name),
StmtBlock([StmtBreak()]))
moveswitch.addcase(
DefaultLabel(),
StmtBlock([_logicError('unreached'), StmtReturn()]))
@@ -3426,18 +3425,19 @@ class _GenerateProtocolActorCode(ipdl.as
if hasReply:
params.append(Decl(Type('Message', ref=1, ptr=1),
replyvar.name))
method = MethodDefn(MethodDecl(name, methodspec=MethodSpec.OVERRIDE,
params=params, ret=_Result.Type()))
if not switch:
- crash = StmtExpr(ExprCall(ExprVar('MOZ_ASSERT_UNREACHABLE'),
- args=[ExprLiteral.String('message protocol not supported')]))
+ crash = StmtExpr(ExprCall(
+ ExprVar('MOZ_ASSERT_UNREACHABLE'),
+ args=[ExprLiteral.String('message protocol not supported')]))
method.addstmts([crash, StmtReturn(_Result.NotKnown)])
return method
if dispatches:
routevar = ExprVar('route__')
routedecl = StmtDecl(
Decl(_actorIdType(), routevar.name),
init=ExprCall(ExprSelect(msgvar, '.', 'routing_id')))
@@ -3465,19 +3465,21 @@ class _GenerateProtocolActorCode(ipdl.as
msgVar = ExprVar(params[0].name)
ifdying = StmtIf(ExprBinary(
ExprBinary(ExprVar('mState'), '==', self.protocol.dyingState()),
'&&',
ExprBinary(
ExprBinary(ExprCall(ExprSelect(msgVar, '.', 'is_reply')),
'!=', ExprLiteral.TRUE),
'||',
- ExprBinary(ExprCall(ExprSelect(msgVar, '.', 'is_interrupt')), '!=', ExprLiteral.TRUE))))
- ifdying.addifstmts([_fatalError('incoming message racing with actor deletion'),
- StmtReturn(_Result.Processed)])
+ ExprBinary(ExprCall(ExprSelect(msgVar, '.', 'is_interrupt')),
+ '!=', ExprLiteral.TRUE))))
+ ifdying.addifstmts([
+ _fatalError('incoming message racing with actor deletion'),
+ StmtReturn(_Result.Processed)])
method.addstmt(ifdying)
# bug 509581: don't generate the switch stmt if there
# is only the default case; MSVC doesn't like that
if switch.nr_cases > 1:
method.addstmt(switch)
else:
method.addstmt(StmtReturn(_Result.NotKnown))
@@ -3560,19 +3562,17 @@ class _GenerateProtocolActorCode(ipdl.as
# private methods
self.cls.addstmt(Label.PRIVATE)
# DestroySubtree(bool normal)
whyvar = ExprVar('why')
subtreewhyvar = ExprVar('subtreewhy')
kidsvar = ExprVar('kids')
- ivar = ExprVar('i')
itervar = ExprVar('iter')
- ithkid = ExprIndex(kidsvar, ivar)
destroysubtree = MethodDefn(MethodDecl(
destroysubtreevar.name,
params=[Decl(_DestroyReason.Type(), whyvar.name)]))
if ptype.isManaged():
destroysubtree.addstmt(
Whitespace('// Unregister from our manager.\n', indent=1))
@@ -3592,23 +3592,22 @@ class _GenerateProtocolActorCode(ipdl.as
ExprBinary(whyvar, '==',
_DestroyReason.FailedConstructor)),
_DestroyReason.AncestorDeletion, whyvar)),
Whitespace.NL
])
for managed in ptype.manages:
managedVar = p.managedVar(managed, self.side)
- lenvar = ExprVar('len')
kidvar = ExprVar('kid')
foreachdestroy = StmtRangedFor(kidvar, kidsvar)
foreachdestroy.addstmt(
- Whitespace('// Guarding against a child removing a sibling from the list during the iteration.\n', indent=1))
+ Whitespace('// Guarding against a child removing a sibling from the list during the iteration.\n', indent=1)) # NOQA: E501
ifhas = StmtIf(_callHasManagedActor(managedVar, kidvar))
ifhas.addifstmt(StmtExpr(ExprCall(
ExprSelect(kidvar, '->', destroysubtreevar.name),
args=[subtreewhyvar])))
foreachdestroy.addstmt(ifhas)
block = StmtBlock()
block.addstmts([
@@ -3690,33 +3689,21 @@ class _GenerateProtocolActorCode(ipdl.as
for managed in ptype.manages:
self.cls.addstmts([
StmtDecl(Decl(
p.managedVarType(managed, self.side),
p.managedVar(managed, self.side).name))])
def implementManagerIface(self):
p = self.protocol
- routedvar = ExprVar('aRouted')
- idvar = ExprVar('aId')
- shmemvar = ExprVar('shmem')
- rawvar = ExprVar('segment')
- sizevar = ExprVar('aSize')
- typevar = ExprVar('aType')
- unsafevar = ExprVar('aUnsafe')
protocolbase = Type('IProtocol', ptr=1)
- sourcevar = ExprVar('aSource')
- ivar = ExprVar('i')
- kidsvar = ExprVar('kids')
- ithkid = ExprIndex(kidsvar, ivar)
methods = []
if p.decl.type.isToplevel():
- tmpvar = ExprVar('tmp')
# "private" message that passes shmem mappings from one process
# to the other
if p.subtreeUsesShmem():
self.asyncSwitch.addcase(
CaseLabel('SHMEM_CREATED_MESSAGE_TYPE'),
self.genShmemCreatedHandler())
self.asyncSwitch.addcase(
@@ -3728,19 +3715,16 @@ class _GenerateProtocolActorCode(ipdl.as
_fatalError('this protocol tree does not use shmem'),
StmtReturn(_Result.NotKnown)
])
self.asyncSwitch.addcase(
CaseLabel('SHMEM_CREATED_MESSAGE_TYPE'), abort)
self.asyncSwitch.addcase(
CaseLabel('SHMEM_DESTROYED_MESSAGE_TYPE'), abort)
- othervar = ExprVar('other')
- managertype = Type(_actorName(p.name, self.side), ptr=1)
-
# Keep track of types created with an INOUT ctor. We need to call
# Register() or RegisterID() for them depending on the side the managee
# is created.
inoutCtorTypes = []
for msg in p.messageDecls:
msgtype = msg.decl.type
if msgtype.isCtor() and msgtype.isInout():
inoutCtorTypes.append(msgtype.constructedType())
@@ -3830,17 +3814,16 @@ class _GenerateProtocolActorCode(ipdl.as
# received messages.
##
def visitMessageDecl(self, md):
isctor = md.decl.type.isCtor()
isdtor = md.decl.type.isDtor()
decltype = md.decl.type
sendmethod = None
promisesendmethod = None
- helpermethod = None
recvlbl, recvcase = None, None
def addRecvCase(lbl, case):
if decltype.isAsync():
self.asyncSwitch.addcase(lbl, case)
elif decltype.isSync():
self.syncSwitch.addcase(lbl, case)
elif decltype.isInterrupt():
@@ -3966,17 +3949,16 @@ class _GenerateProtocolActorCode(ipdl.as
self.side),
actorvar)),
StmtExpr(ExprAssn(_actorState(actorvar),
_startState(md.decl.type.cdtype.hasReentrantDelete)))
]
def failCtorIf(self, md, cond):
actorvar = md.actorDecl().var()
- type = md.decl.type.constructedType()
failif = StmtIf(cond)
if self.side == 'child':
# in the child process this should not fail
failif.addifstmt(_fatalError('constructor for actor failed'))
else:
failif.addifstmts(self.destroyActor(md, actorvar,
why=_DestroyReason.FailedConstructor))
@@ -4301,17 +4283,16 @@ class _GenerateProtocolActorCode(ipdl.as
if routingId is None:
routingId = self.protocol.routingId()
if not md.decl.type.isAsync() or not md.hasReply():
return []
sendok = ExprVar('sendok__')
seqno = ExprVar('seqno__')
resolve = ExprVar('resolve__')
- reason = ExprVar('reason__')
resolvertype = Type(md.resolverName())
failifsendok = StmtIf(ExprNot(sendok))
failifsendok.addifstmt(_printWarningMessage('Error sending reply'))
sendmsg = (self.setMessageFlags(md, self.replyvar, seqno=seqno)
+ [self.logMessage(md, self.replyvar, 'Sending reply '),
StmtDecl(Decl(Type.BOOL, sendok.name),
init=ExprCall(
ExprSelect(self.protocol.callGetChannel(),
@@ -4324,22 +4305,24 @@ class _GenerateProtocolActorCode(ipdl.as
'aParam')
destructexpr = ExprCall(ExprVar('Tie'),
args=[p.var() for p in md.returns])
else:
resolvedecl = Decl(md.returns[0].moveType(self.side), 'aParam')
destructexpr = md.returns[0].var()
selfvar = ExprVar('self__')
ifactorisdead = StmtIf(ExprNot(selfvar))
- ifactorisdead.addifstmts([_printWarningMessage("Not resolving response because actor is dead."),
- StmtReturn()])
+ ifactorisdead.addifstmts([
+ _printWarningMessage("Not resolving response because actor is dead."),
+ StmtReturn()])
ifactorisdestroyed = StmtIf(ExprBinary(self.protocol.stateVar(), '==',
self.protocol.deadState()))
- ifactorisdestroyed.addifstmts([_printWarningMessage("Not resolving response because actor is destroyed."),
- StmtReturn()])
+ ifactorisdestroyed.addifstmts([
+ _printWarningMessage("Not resolving response because actor is destroyed."),
+ StmtReturn()])
returnifactorisdead = [ifactorisdead,
ifactorisdestroyed]
resolverfn = ExprLambda([ExprVar.THIS, selfvar, routingId, seqno],
[resolvedecl])
resolverfn.addstmts(returnifactorisdead
+ [StmtDecl(Decl(Type.BOOL, resolve.name),
init=ExprLiteral.TRUE)]
+ [StmtDecl(Decl(p.bareType(self.side), p.var().name))
@@ -4572,17 +4555,16 @@ class _GenerateProtocolActorCode(ipdl.as
return stmts
def sendAsync(self, md, msgexpr, actor=None):
sendok = ExprVar('sendok__')
resolvefn = ExprVar('aResolve')
rejectfn = ExprVar('aReject')
- sendargs = [msgexpr]
stmts = [Whitespace.NL,
self.logMessage(md, msgexpr, 'Sending ', actor),
self.profilerLabel(md)] + self.transition(md, actor, errorfn=errfnUnreachable)
stmts.append(Whitespace.NL)
# Generate the actual call expression.
send = ExprSelect(self.protocol.callGetChannel(actor), '->', 'Send')
if md.returns:
@@ -4606,22 +4588,24 @@ class _GenerateProtocolActorCode(ipdl.as
self.logMessage(md, msgexpr, 'Sending ', actor),
self.profilerLabel(md)]
+ self.transition(md, actor, errorfn=errfnUnreachable)
+ [Whitespace.NL,
StmtDecl(Decl(Type.BOOL, sendok.name)),
StmtBlock([
StmtExpr(ExprCall(ExprVar('AUTO_PROFILER_TRACING'),
[ExprLiteral.String("IPC"),
- ExprLiteral.String(self.protocol.name + "::" + md.prettyMsgName())])),
+ ExprLiteral.String(self.protocol.name + "::" +
+ md.prettyMsgName())])),
StmtExpr(ExprAssn(sendok,
- ExprCall(ExprSelect(self.protocol.callGetChannel(actor),
- '->',
- _sendPrefix(md.decl.type)),
- args=[msgexpr, ExprAddrOf(replyexpr)]))),
+ ExprCall(
+ ExprSelect(self.protocol.callGetChannel(actor),
+ '->',
+ _sendPrefix(md.decl.type)),
+ args=[msgexpr, ExprAddrOf(replyexpr)]))),
])
])
)
def sendAsyncWithPromise(self, md):
# Create a new promise, and forward to the callback send overload.
retpromise = ExprVar('promise__')
promise = _makePromise(md.returns, self.side, resolver=True)
--- a/ipc/ipdl/ipdl/parser.py
+++ b/ipc/ipdl/ipdl/parser.py
@@ -1,14 +1,13 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
-import sys
from ply import lex, yacc
from ipdl.ast import *
# -----------------------------------------------------------------------------
class ParseError(Exception):
@@ -368,17 +367,18 @@ def p_ProtocolDefn(p):
protocol = p[5]
protocol.loc = locFromTok(p, 2)
protocol.name = p[3]
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.')
+ _error(protocol.loc,
+ 'can\'t define a protocol in a header. Do it in a protocol spec instead.')
def p_ProtocolBody(p):
"""ProtocolBody : ManagersStmtOpt"""
p[0] = p[1]
# --------------------
@@ -671,17 +671,17 @@ def p_BasicType(p):
def p_MaybeNullable(p):
"""MaybeNullable : NULLABLE
| """
p[0] = (2 == len(p))
# --------------------
-## C++ stuff
+# C++ stuff
def p_CxxType(p):
"""CxxType : QualifiedID
| CxxID"""
if isinstance(p[1], QualifiedId):
p[0] = TypeSpec(p[1].loc, p[1])
else:
--- a/ipc/ipdl/ipdl/type.py
+++ b/ipc/ipdl/ipdl/type.py
@@ -16,18 +16,18 @@ import ipdl.builtin as builtin
_DELETE_MSG = '__delete__'
class TypeVisitor:
def __init__(self):
self.visited = set()
def defaultVisit(self, node, *args):
- raise Exception, "INTERNAL ERROR: no visitor for node type `%s'" % (
- node.__class__.__name__)
+ raise Exception("INTERNAL ERROR: no visitor for node type `%s'" %
+ (node.__class__.__name__))
def visitVoidType(self, v, *args):
pass
def visitImportedCxxType(self, t, *args):
pass
def visitMessageType(self, m, *args):
@@ -683,17 +683,17 @@ class GatherDecls(TcheckVisitor):
# match
basefilename = os.path.basename(tu.filename)
expectedfilename = '%s.ipdl' % (tu.name)
if not tu.protocol:
# header
expectedfilename += 'h'
if basefilename != expectedfilename:
self.error(tu.loc,
- "expected file for translation unit `%s' to be named `%s'; instead it's named `%s'",
+ "expected file for translation unit `%s' to be named `%s'; instead it's named `%s'", # NOQA: E501
tu.name, expectedfilename, basefilename)
if tu.protocol:
assert tu.name == tu.protocol.name
p = tu.protocol
# FIXME/cjones: it's a little weird and counterintuitive
@@ -903,17 +903,17 @@ class GatherDecls(TcheckVisitor):
for managed in p.managesStmts:
mgdname = managed.name
ctordecl = self.symtab.lookup(mgdname + 'Constructor')
if not (ctordecl and ctordecl.type.isCtor()):
self.error(
managed.loc,
- "constructor declaration required for managed protocol `%s' (managed by protocol `%s')",
+ "constructor declaration required for managed protocol `%s' (managed by protocol `%s')", # NOQA: E501
mgdname, p.name)
# FIXME/cjones declare all the little C++ thingies that will
# be generated. they're not relevant to IPDL itself, but
# those ("invisible") symbols can clash with others in the
# IPDL spec, and we'd like to catch those before C++ compilers
# are allowed to obfuscate the error
@@ -930,17 +930,17 @@ class GatherDecls(TcheckVisitor):
if mgrdecl is None:
self.error(
loc,
"protocol `%s' referenced as |manager| of `%s' has not been declared",
mgrname, pname)
elif not isinstance(mgrdecl.type, ProtocolType):
self.error(
loc,
- "entity `%s' referenced as |manager| of `%s' is not of `protocol' type; instead it is of type `%s'",
+ "entity `%s' referenced as |manager| of `%s' is not of `protocol' type; instead it is of type `%s'", # NOQA: E501
mgrname, pname, mgrdecl.type.typename())
else:
mgr.decl = mgrdecl
pdecl.type.addManager(mgrdecl.type)
def visitManagesStmt(self, mgs):
mgsdecl = self.symtab.lookup(mgs.name)
pdecl = mgs.manager.decl
@@ -1143,17 +1143,17 @@ class CheckTypes(TcheckVisitor):
# check that we require no more "power" than our manager protocols
ptype, pname = p.decl.type, p.decl.shortname
for mgrtype in ptype.managers:
if mgrtype is not None and ptype.needsMoreJuiceThan(mgrtype):
self.error(
p.decl.loc,
- "protocol `%s' requires more powerful send semantics than its manager `%s' provides",
+ "protocol `%s' requires more powerful send semantics than its manager `%s' provides", # NOQA: E501
pname, mgrtype.name())
if ptype.isToplevel():
cycles = checkcycles(p.decl.type)
if cycles:
self.error(
p.decl.loc,
"cycle(s) detected in manager/manages hierarchy: %s",
@@ -1178,17 +1178,17 @@ class CheckTypes(TcheckVisitor):
# we added this information; sanity check it
assert ptype.isManagerOf(mgstype)
# check that the "managed" protocol agrees
if not mgstype.isManagedBy(ptype):
self.error(
loc,
- "|manages| declaration in protocol `%s' does not match any |manager| declaration in protocol `%s'",
+ "|manages| declaration in protocol `%s' does not match any |manager| declaration in protocol `%s'", # NOQA: E501
pname, mgsname)
def visitManager(self, mgr):
pdecl = mgr.of.decl
ptype, pname = pdecl.type, pdecl.shortname
mgrdecl = mgr.decl
mgrtype, mgrname = mgrdecl.type, mgrdecl.shortname
@@ -1197,17 +1197,17 @@ class CheckTypes(TcheckVisitor):
assert ptype.isManagedBy(mgrtype)
loc = mgr.loc
# check that the "manager" protocol agrees
if not mgrtype.isManagerOf(ptype):
self.error(
loc,
- "|manager| declaration in protocol `%s' does not match any |manages| declaration in protocol `%s'",
+ "|manager| declaration in protocol `%s' does not match any |manages| declaration in protocol `%s'", # NOQA: E501
pname, mgrname)
def visitMessageDecl(self, md):
mtype, mname = md.decl.type, md.decl.progname
ptype, pname = md.protocolDecl.type, md.protocolDecl.shortname
loc = md.decl.loc
@@ -1215,48 +1215,48 @@ class CheckTypes(TcheckVisitor):
self.error(
loc,
"inside_sync nested messages must be sync (here, message `%s' in protocol `%s')",
mname, pname)
if mtype.nested == INSIDE_CPOW_NESTED and (mtype.isOut() or mtype.isInout()):
self.error(
loc,
- "inside_cpow nested parent-to-child messages are verboten (here, message `%s' in protocol `%s')",
+ "inside_cpow nested parent-to-child messages are verboten (here, message `%s' in protocol `%s')", # NOQA: E501
mname, pname)
# We allow inside_sync messages that are themselves sync to be sent from the
# parent. Normal and inside_cpow nested messages that are sync can only come from
# the child.
if mtype.isSync() and mtype.nested == NOT_NESTED and (mtype.isOut() or mtype.isInout()):
self.error(
loc,
"sync parent-to-child messages are verboten (here, message `%s' in protocol `%s')",
mname, pname)
if mtype.needsMoreJuiceThan(ptype):
self.error(
loc,
- "message `%s' requires more powerful send semantics than its protocol `%s' provides",
+ "message `%s' requires more powerful send semantics than its protocol `%s' provides", # NOQA: E501
mname, pname)
if (mtype.isCtor() or mtype.isDtor()) and mtype.isAsync() and mtype.returns:
self.error(loc,
"asynchronous ctor/dtor message `%s' declares return values",
mname)
if (mtype.compress and
(not mtype.isAsync() or mtype.isCtor() or mtype.isDtor())):
if mtype.isCtor() or mtype.isDtor():
message_type = "constructor" if mtype.isCtor() else "destructor"
error_message = ("%s messages can't use compression (here, in protocol `%s')" %
(message_type, pname))
else:
- error_message = ("message `%s' in protocol `%s' requests compression but is not async" %
+ error_message = ("message `%s' in protocol `%s' requests compression but is not async" % # NOQA: E501
(mname, pname))
self.error(loc, error_message)
if mtype.isCtor() and not ptype.isManagerOf(mtype.constructedType()):
self.error(
loc,
"ctor for protocol `%s', which is not managed by protocol `%s'",
--- a/ipc/ipdl/test/ipdl/IPDLCompile.py
+++ b/ipc/ipdl/test/ipdl/IPDLCompile.py
@@ -1,13 +1,12 @@
import copy
import re
import os
import subprocess
-import sys
import tempfile
# We test the compiler indirectly, rather than reaching into the ipdl/
# module, to make the testing framework as general as possible.
class IPDLCompile:
def __init__(self, specfilename, ipdlargv=['python', 'ipdl.py']):
--- a/ipc/pull-chromium.py
+++ b/ipc/pull-chromium.py
@@ -31,16 +31,17 @@ check_call(['gclient', 'sync', '--force'
chromiumsrc = os.path.join(topsrcdir, 'ipc/chromium/src')
os.path.exists(chromiumsrc) and rmtree(chromiumsrc)
def doexport(svnpath):
localpath = os.path.join(chromiumsrc, svnpath)
os.makedirs(os.path.dirname(localpath))
- check_call(['svn', 'export', '-r', 'BASE', os.path.join(chromiumtree, 'src', svnpath), localpath])
+ check_call(['svn', 'export', '-r', 'BASE', os.path.join(chromiumtree, 'src', svnpath),
+ localpath])
doexport('base')
doexport('chrome/common')
doexport('build/build_config.h')
doexport('testing/gtest/include')
doexport('third_party/libevent')