Bug 1142609 - Fix PEP 8 E3xx warnings in dom/bindings's Python code. r=peterv

--HG--
extra : rebase_source : 32812b0bd734e49848099c128b12bade345848af
This commit is contained in:
Samy Dindane 2015-08-10 18:57:39 +02:00
Родитель 45094ca5ae
Коммит 9d7320f826
3 изменённых файлов: 100 добавлений и 5 удалений

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

@ -113,6 +113,7 @@ def memoize(fn):
grows without bound.
"""
cache = {}
@functools.wraps(fn)
def wrapper(arg):
retval = cache.get(arg)
@ -121,6 +122,7 @@ def memoize(fn):
return retval
return wrapper
@memoize
def dedent(s):
"""
@ -595,6 +597,7 @@ def InterfacePrototypeObjectProtoGetter(descriptor):
return (protoGetter, protoHandleGetter)
class CGPrototypeJSClass(CGThing):
def __init__(self, descriptor, properties):
CGThing.__init__(self)
@ -656,6 +659,7 @@ def NeedsGeneratedHasInstance(descriptor):
assert descriptor.interface.hasInterfaceObject()
return descriptor.hasXPConnectImpls or descriptor.interface.isConsequential()
def InterfaceObjectProtoGetter(descriptor):
"""
Returns a tuple with two elements:
@ -679,6 +683,7 @@ def InterfaceObjectProtoGetter(descriptor):
protoHandleGetter = None
return (protoGetter, protoHandleGetter)
class CGInterfaceObjectJSClass(CGThing):
def __init__(self, descriptor, properties):
CGThing.__init__(self)
@ -1214,6 +1219,7 @@ def SortedDictValues(d):
"""
return [v for k, v in sorted(d.items())]
def UnionsForFile(config, webIDLFile):
"""
Returns a list of tuples each containing two elements (type and descriptor)
@ -1223,6 +1229,7 @@ def UnionsForFile(config, webIDLFile):
"""
return config.unionsPerFilename.get(webIDLFile, [])
def UnionTypes(unionTypes, config):
"""
The unionTypes argument should be a list of tuples, each containing two
@ -1322,6 +1329,7 @@ def UnionTypes(unionTypes, config):
SortedDictValues(traverseMethods), SortedDictValues(unlinkMethods),
SortedDictValues(unionStructs))
def UnionConversions(unionTypes, config):
"""
The unionTypes argument should be a list of tuples, each containing two
@ -1339,6 +1347,7 @@ def UnionConversions(unionTypes, config):
if name not in unionConversions:
providers = getRelevantProviders(descriptor, config)
unionConversions[name] = CGUnionConversionStruct(t, providers[0])
def addHeadersForType(f, providers):
f = f.unroll()
if f.isInterface():
@ -2107,6 +2116,7 @@ def isMaybeExposedIn(member, descriptor):
# and member is not exposed in any worker, then it's not exposed.
return not descriptor.workers or member.isExposedInAnyWorker()
def clearableCachedAttrs(descriptor):
return (m for m in descriptor.interface.members if
m.isAttr() and
@ -2114,12 +2124,15 @@ def clearableCachedAttrs(descriptor):
m.dependsOn != "Nothing" and
m.slotIndex is not None)
def MakeClearCachedValueNativeName(member):
return "ClearCached%sValue" % MakeNativeName(member.identifier.name)
def MakeJSImplClearCachedValueNativeName(member):
return "_" + MakeClearCachedValueNativeName(member)
def IDLToCIdentifier(name):
return name.replace("-", "_")
@ -2606,6 +2619,7 @@ class CGNativeProperties(CGList):
def define(self):
return CGList.define(self)
class CGJsonifyAttributesMethod(CGAbstractMethod):
"""
Generate the JsonifyAttributes method for an interface descriptor
@ -2638,6 +2652,7 @@ class CGJsonifyAttributesMethod(CGAbstractMethod):
ret += 'return true;\n'
return ret
class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
"""
Generate the CreateInterfaceObjects method for an interface descriptor.
@ -3000,6 +3015,7 @@ class CGGetProtoObjectMethod(CGAbstractMethod):
def definition_body(self):
return "return GetProtoObjectHandle(aCx, aGlobal);\n"
class CGGetConstructorObjectHandleMethod(CGGetPerInterfaceObject):
"""
A method for getting the interface constructor object.
@ -3017,6 +3033,7 @@ class CGGetConstructorObjectHandleMethod(CGGetPerInterfaceObject):
""") + CGGetPerInterfaceObject.definition_body(self)
class CGGetConstructorObjectMethod(CGAbstractMethod):
"""
A method for getting the interface constructor object.
@ -3030,6 +3047,7 @@ class CGGetConstructorObjectMethod(CGAbstractMethod):
def definition_body(self):
return "return GetConstructorObjectHandle(aCx, aGlobal);\n"
class CGGetNamedPropertiesObjectMethod(CGAbstractStaticMethod):
def __init__(self, descriptor):
args = [Argument('JSContext*', 'aCx'),
@ -3294,6 +3312,7 @@ def InitUnforgeablePropertiesOnHolder(descriptor, properties, failureCode):
return CGWrapper(CGList(unforgeables), pre="\n")
def CopyUnforgeablePropertiesToInstance(descriptor, wrapperCache):
"""
Copy the unforgeable properties from the unforgeable holder for
@ -6656,6 +6675,7 @@ class MethodNotNewObjectError(Exception):
sequenceWrapLevel = 0
mapWrapLevel = 0
def wrapTypeIntoCurrentCompartment(type, value, isMember=True):
"""
Take the thing named by "value" and if it contains "any",
@ -7619,6 +7639,7 @@ class FakeIdentifier():
def __init__(self, name):
self.name = name
class FakeArgument():
"""
A class that quacks like an IDLArgument. This is used to make
@ -7816,6 +7837,7 @@ class CGGenericMethod(CGAbstractBindingMethod):
return ok;
"""))
class CGGenericPromiseReturningMethod(CGAbstractBindingMethod):
"""
A class for generating the C++ code for an IDL method that returns a Promise.
@ -7860,7 +7882,6 @@ class CGGenericPromiseReturningMethod(CGAbstractBindingMethod):
"""))
class CGSpecializedMethod(CGAbstractStaticMethod):
"""
A class for generating the C++ code for a specialized method that the JIT
@ -9503,6 +9524,7 @@ class CGUnionConversionStruct(CGThing):
def define(self):
return ""
def deps(self):
return set()
@ -11298,7 +11320,6 @@ class CGDOMJSProxyHandler(CGClass):
explicit=True)
]
if descriptor.supportsIndexedProperties():
methods.append(CGDOMJSProxyHandler_getElements(descriptor))
if (descriptor.operations['IndexedSetter'] is not None or
@ -11349,6 +11370,7 @@ def stripTrailingWhitespace(text):
lines = text.splitlines()
return '\n'.join(line.rstrip() for line in lines) + tail
class MemberProperties:
def __init__(self):
self.isGenericMethod = False
@ -11362,6 +11384,7 @@ class MemberProperties:
self.isCrossOriginSetter = False
self.isJsonifier = False
def memberProperties(m, descriptor):
props = MemberProperties()
if m.isMethod():
@ -11404,6 +11427,7 @@ def memberProperties(m, descriptor):
return props
class CGDescriptor(CGThing):
def __init__(self, descriptor):
CGThing.__init__(self)
@ -11749,6 +11773,7 @@ class CGNamespacedEnum(CGThing):
def define(self):
return ""
def initIdsClassMethod(identifiers, atomCacheName):
idinit = ['!atomsCache->%s.init(cx, "%s")' %
(CGDictionary.makeIdName(id),
@ -11772,6 +11797,7 @@ def initIdsClassMethod(identifiers, atomCacheName):
Argument("%s*" % atomCacheName, "atomsCache")
], static=True, body=body, visibility="private")
class CGDictionary(CGThing):
def __init__(self, dictionary, descriptorProvider):
self.dictionary = dictionary
@ -15241,7 +15267,6 @@ class CGMaplikeOrSetlikeHelperFunctionGenerator(CallbackMember):
return " false"
return ""
def getCall(self):
return CGMaplikeOrSetlikeMethodGenerator(self.descriptorProvider,
self.maplikeOrSetlike,
@ -15318,6 +15343,7 @@ class GlobalGenRoots():
binaryMemberName = binaryNameFor(m.identifier.name)
return ClassMember(CGDictionary.makeIdName(binaryMemberName),
"PinnedStringId", visibility="public")
def buildAtomCacheStructure(idlobj, binaryNameFor, members):
classMembers = [memberToAtomCacheMember(binaryNameFor, m)
for m in members]
@ -15648,6 +15674,7 @@ class GlobalGenRoots():
return curr
# Code generator for simple events
class CGEventGetter(CGNativeMember):
def __init__(self, descriptor, attr):
@ -15750,7 +15777,6 @@ class CGEventMethod(CGNativeMember):
if not allowed:
raise TypeError("Event code generator does not support methods!")
def getArgs(self, returnType, argList):
args = [self.getArg(arg) for arg in argList]
return args

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

@ -8,6 +8,7 @@ from collections import defaultdict
autogenerated_comment = "/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n"
class Configuration:
"""
Represents global configuration state based on IDL parse data and
@ -182,6 +183,7 @@ class Configuration:
def getInterface(self, ifname):
return self.interfaces[ifname]
def getDescriptors(self, **filters):
"""Gets the descriptors that match the given filters."""
curr = self.descriptors
@ -226,6 +228,7 @@ class Configuration:
for f in tofilter:
curr = filter(lambda x: f[0](x) == f[1], curr)
return curr
def getEnums(self, webIDLFile):
return filter(lambda e: e.filename() == webIDLFile, self.enums)
@ -243,8 +246,10 @@ class Configuration:
else:
assert(0) # Unknown key
return items
def getDictionaries(self, **filters):
return self._filterForFileAndWorkers(self.dictionaries, filters)
def getCallbacks(self, **filters):
return self._filterForFileAndWorkers(self.callbacks, filters)
@ -272,6 +277,7 @@ class Configuration:
"Bindings.conf annotation." % interfaceName)
raise NoSuchDescriptorError("For " + interfaceName + " found no matches");
def getDescriptorProvider(self, workers):
"""
Gets a descriptor provider that can provide descriptors as needed,
@ -279,10 +285,12 @@ class Configuration:
"""
return DescriptorProvider(self, workers)
class NoSuchDescriptorError(TypeError):
def __init__(self, str):
TypeError.__init__(self, str)
class DescriptorProvider:
"""
A way of getting descriptors for interface names
@ -299,6 +307,7 @@ class DescriptorProvider:
"""
return self.config.getDescriptor(interfaceName, self.workers)
def methodReturnsJSObject(method):
assert method.isMethod()
if method.returnsPromise():
@ -415,6 +424,7 @@ class Descriptor(DescriptorProvider):
'LegacyCaller': None,
'Jsonifier': None
}
# Stringifiers and jsonifiers need to be set up whether an interface is
# concrete or not, because they're actually prototype methods and hence
# can apply to instances of descendant interfaces. Legacy callers and
@ -758,6 +768,7 @@ class Descriptor(DescriptorProvider):
return (self.interface.getExtendedAttribute("Global") or
self.interface.getExtendedAttribute("PrimaryGlobal"))
# Some utility methods
def getTypesFromDescriptor(descriptor):
"""
@ -778,6 +789,7 @@ def getTypesFromDescriptor(descriptor):
types.extend(a.type for a in members if a.isAttr())
return types
def getFlatTypes(types):
retval = set()
for type in types:
@ -788,6 +800,7 @@ def getFlatTypes(types):
retval.add(type)
return retval
def getTypesFromDictionary(dictionary):
"""
Get all member types for this dictionary
@ -799,6 +812,7 @@ def getTypesFromDictionary(dictionary):
curDict = curDict.parent
return types
def getTypesFromCallback(callback):
"""
Get the types this callback depends on: its return type and the
@ -809,6 +823,7 @@ def getTypesFromCallback(callback):
types.extend(arg.type for arg in sig[1]) # Arguments
return types
def findCallbacksAndDictionaries(inputTypes):
"""
Ensure that all callbacks and dictionaries reachable from types end up in
@ -838,6 +853,7 @@ def findCallbacksAndDictionaries(inputTypes):
doFindCallbacksAndDictionaries(inputTypes, retCallbacks, retDictionaries)
return (retCallbacks, retDictionaries)
def getAllTypes(descriptors, dictionaries, callbacks):
"""
Generate all the types we're dealing with. For each type, a tuple

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

@ -13,6 +13,7 @@ from collections import defaultdict
# Machinery
def parseInt(literal):
string = literal
sign = 0
@ -37,6 +38,7 @@ def parseInt(literal):
value = int(string, base)
return value * sign
# Magic for creating enums
def M_add_class_attribs(attribs, start):
def foo(name, bases, dict_):
@ -47,6 +49,7 @@ def M_add_class_attribs(attribs, start):
return type(name, bases, dict_)
return foo
def enum(*names, **kw):
if len(kw) == 1:
base = kw['base'].__class__
@ -55,12 +58,15 @@ def enum(*names, **kw):
assert len(kw) == 0
base = object
start = 0
class Foo(base):
__metaclass__ = M_add_class_attribs(names, start)
def __setattr__(self, name, value): # this makes it read-only
raise NotImplementedError
return Foo()
class WebIDLError(Exception):
def __init__(self, message, locations, warning=False):
self.message = message
@ -73,6 +79,7 @@ class WebIDLError(Exception):
", " if len(self.locations) != 0 else "",
"\n".join(self.locations))
class Location(object):
def __init__(self, lexer, lineno, lexpos, filename):
self._line = None
@ -115,6 +122,7 @@ class Location(object):
return "%s line %s:%s\n%s\n%s" % (self._file, self._lineno, self._colno,
self._line, self._pointerline())
class BuiltinLocation(object):
def __init__(self, text):
self.msg = text + "\n"
@ -138,6 +146,7 @@ class BuiltinLocation(object):
# Data Model
class IDLObject(object):
def __init__(self, location):
self.location = location
@ -211,6 +220,7 @@ class IDLObject(object):
return deps
class IDLScope(IDLObject):
def __init__(self, location, parentScope, identifier):
IDLObject.__init__(self, location)
@ -313,6 +323,7 @@ class IDLScope(IDLObject):
assert identifier.scope == self
return self._lookupIdentifier(identifier)
class IDLIdentifier(IDLObject):
def __init__(self, location, scope, name):
IDLObject.__init__(self, location)
@ -336,6 +347,7 @@ class IDLIdentifier(IDLObject):
def object(self):
return self.scope.lookupIdentifier(self)
class IDLUnresolvedIdentifier(IDLObject):
def __init__(self, location, name, allowDoubleUnderscore=False,
allowForbidden=False):
@ -381,6 +393,7 @@ class IDLUnresolvedIdentifier(IDLObject):
def finish(self):
assert False # Should replace with a resolved identifier first.
class IDLObjectWithIdentifier(IDLObject):
def __init__(self, location, parentScope, identifier):
IDLObject.__init__(self, location)
@ -434,6 +447,7 @@ class IDLObjectWithIdentifier(IDLObject):
return unhandledAttrs
class IDLObjectWithScope(IDLObjectWithIdentifier, IDLScope):
def __init__(self, location, parentScope, identifier):
assert isinstance(identifier, IDLUnresolvedIdentifier)
@ -441,6 +455,7 @@ class IDLObjectWithScope(IDLObjectWithIdentifier, IDLScope):
IDLObjectWithIdentifier.__init__(self, location, parentScope, identifier)
IDLScope.__init__(self, location, parentScope, self.identifier)
class IDLIdentifierPlaceholder(IDLObjectWithIdentifier):
def __init__(self, location, identifier):
assert isinstance(identifier, IDLUnresolvedIdentifier)
@ -456,6 +471,7 @@ class IDLIdentifierPlaceholder(IDLObjectWithIdentifier):
obj = self.identifier.resolve(scope, None)
return scope.lookupIdentifier(obj)
class IDLExposureMixins():
def __init__(self, location):
# _exposureGlobalNames are the global names listed in our [Exposed]
@ -551,6 +567,7 @@ class IDLExternalInterface(IDLObjectWithIdentifier, IDLExposureMixins):
def _getDependentObjects(self):
return set()
class IDLPartialInterface(IDLObject):
def __init__(self, location, name, members, nonPartialInterface):
assert isinstance(name, IDLUnresolvedIdentifier)
@ -605,10 +622,12 @@ def convertExposedAttrToGlobalNameSet(exposedAttr, targetSet):
assert exposedAttr.hasArgs()
targetSet.update(exposedAttr.args())
def globalNameSetToExposureSet(globalScope, nameSet, exposureSet):
for name in nameSet:
exposureSet.update(globalScope.globalNameMapping[name])
class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
def __init__(self, location, parentScope, name, parent, members,
isKnownNonPartial):
@ -1522,6 +1541,7 @@ class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
self.getExtendedAttribute("CheckAnyPermissions") or
self.getExtendedAttribute("CheckAllPermissions"))
class IDLDictionary(IDLObjectWithScope):
def __init__(self, location, parentScope, name, parent, members):
assert isinstance(parentScope, IDLScope)
@ -1669,6 +1689,7 @@ class IDLDictionary(IDLObjectWithScope):
deps.add(self.parent)
return deps
class IDLEnum(IDLObjectWithIdentifier):
def __init__(self, location, parentScope, name, values):
assert isinstance(parentScope, IDLScope)
@ -1699,6 +1720,7 @@ class IDLEnum(IDLObjectWithIdentifier):
def _getDependentObjects(self):
return set()
class IDLType(IDLObject):
Tags = enum(
# The integer types
@ -1892,6 +1914,7 @@ class IDLType(IDLObject):
def isExposedInAllOf(self, exposureSet):
return True
class IDLUnresolvedType(IDLType):
"""
Unresolved types are interface types
@ -1936,6 +1959,7 @@ class IDLUnresolvedType(IDLType):
raise TypeError("Can't tell whether an unresolved type is or is not "
"distinguishable from other things")
class IDLNullableType(IDLType):
def __init__(self, location, innerType):
assert not innerType.isVoid()
@ -2085,6 +2109,7 @@ class IDLNullableType(IDLType):
def _getDependentObjects(self):
return self.inner._getDependentObjects()
class IDLSequenceType(IDLType):
def __init__(self, location, parameterType):
assert not parameterType.isVoid()
@ -2177,6 +2202,7 @@ class IDLSequenceType(IDLType):
def _getDependentObjects(self):
return self.inner._getDependentObjects()
class IDLMozMapType(IDLType):
# XXXbz This is pretty similar to IDLSequenceType in various ways.
# And maybe to IDLNullableType. Should we have a superclass for
@ -2240,6 +2266,7 @@ class IDLMozMapType(IDLType):
def _getDependentObjects(self):
return self.inner._getDependentObjects()
class IDLUnionType(IDLType):
def __init__(self, location, memberTypes):
IDLType.__init__(self, location, "")
@ -2365,6 +2392,7 @@ class IDLUnionType(IDLType):
def _getDependentObjects(self):
return set(self.memberTypes)
class IDLArrayType(IDLType):
def __init__(self, location, parameterType):
assert not parameterType.isVoid()
@ -2464,6 +2492,7 @@ class IDLArrayType(IDLType):
def _getDependentObjects(self):
return self.inner._getDependentObjects()
class IDLTypedefType(IDLType):
def __init__(self, location, innerType, name):
IDLType.__init__(self, location, name)
@ -2565,6 +2594,7 @@ class IDLTypedefType(IDLType):
def _getDependentObjects(self):
return self.inner._getDependentObjects()
class IDLTypedef(IDLObjectWithIdentifier):
def __init__(self, location, parentScope, innerType, name):
identifier = IDLUnresolvedIdentifier(location, name)
@ -2590,6 +2620,7 @@ class IDLTypedef(IDLObjectWithIdentifier):
def _getDependentObjects(self):
return self.innerType._getDependentObjects()
class IDLWrapperType(IDLType):
def __init__(self, location, inner, promiseInnerType=None):
IDLType.__init__(self, location, inner.identifier.name)
@ -2768,6 +2799,7 @@ class IDLWrapperType(IDLType):
return set([self.inner])
return set()
class IDLBuiltinType(IDLType):
Types = enum(
@ -3157,6 +3189,7 @@ integerTypeSizes = {
IDLBuiltinType.Types.unsigned_long_long: (0, 18446744073709551615)
}
def matchIntegerValueToType(value):
for type, extremes in integerTypeSizes.items():
(min, max) = extremes
@ -3165,6 +3198,7 @@ def matchIntegerValueToType(value):
return None
class IDLValue(IDLObject):
def __init__(self, location, type, value):
IDLObject.__init__(self, location)
@ -3247,6 +3281,7 @@ class IDLValue(IDLObject):
def _getDependentObjects(self):
return set()
class IDLNullValue(IDLObject):
def __init__(self, location):
IDLObject.__init__(self, location)
@ -3276,6 +3311,7 @@ class IDLNullValue(IDLObject):
def _getDependentObjects(self):
return set()
class IDLEmptySequenceValue(IDLObject):
def __init__(self, location):
IDLObject.__init__(self, location)
@ -3304,6 +3340,7 @@ class IDLEmptySequenceValue(IDLObject):
def _getDependentObjects(self):
return set()
class IDLUndefinedValue(IDLObject):
def __init__(self, location):
IDLObject.__init__(self, location)
@ -3322,6 +3359,7 @@ class IDLUndefinedValue(IDLObject):
def _getDependentObjects(self):
return set()
class IDLInterfaceMember(IDLObjectWithIdentifier, IDLExposureMixins):
Tags = enum(
@ -3642,7 +3680,6 @@ class IDLMaplikeOrSetlike(IDLInterfaceMember):
IDLUnresolvedIdentifier(self.location, "value"),
self.valueType)
if not self.readonly:
addMethod("set", True, BuiltinTypes[IDLBuiltinType.Types.object],
[getKeyArg(), getValueArg()])
@ -3680,6 +3717,7 @@ class IDLMaplikeOrSetlike(IDLInterfaceMember):
def _getDependentObjects(self):
return set([self.keyType, self.valueType])
class IDLConst(IDLInterfaceMember):
def __init__(self, location, identifier, type, value):
IDLInterfaceMember.__init__(self, location, identifier,
@ -3742,6 +3780,7 @@ class IDLConst(IDLInterfaceMember):
def _getDependentObjects(self):
return set([self.type, self.value])
class IDLAttribute(IDLInterfaceMember):
def __init__(self, location, identifier, type, readonly, inherit=False,
static=False, stringifier=False, maplikeOrSetlike=None):
@ -4034,6 +4073,7 @@ class IDLAttribute(IDLInterfaceMember):
def _getDependentObjects(self):
return set([self.type])
class IDLArgument(IDLObjectWithIdentifier):
def __init__(self, location, identifier, type, optional=False, defaultValue=None, variadic=False, dictionaryMember=False):
IDLObjectWithIdentifier.__init__(self, location, None, identifier)
@ -4134,6 +4174,7 @@ class IDLArgument(IDLObjectWithIdentifier):
def canHaveMissingValue(self):
return self.optional and not self.defaultValue
class IDLCallback(IDLObjectWithScope):
def __init__(self, location, parentScope, identifier, returnType, arguments):
assert isinstance(returnType, IDLType)
@ -4198,6 +4239,7 @@ class IDLCallback(IDLObjectWithScope):
def _getDependentObjects(self):
return set([self._returnType] + self._arguments)
class IDLCallbackType(IDLType):
def __init__(self, location, callback):
IDLType.__init__(self, location, callback.identifier.name)
@ -4222,6 +4264,7 @@ class IDLCallbackType(IDLType):
def _getDependentObjects(self):
return self.callback._getDependentObjects()
class IDLMethodOverload:
"""
A class that represents a single overload of a WebIDL method. This is not
@ -4242,6 +4285,7 @@ class IDLMethodOverload:
deps.add(self.returnType)
return deps
class IDLMethod(IDLInterfaceMember, IDLScope):
Special = enum(
@ -4700,6 +4744,7 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
deps.update(overload._getDependentObjects())
return deps
class IDLImplementsStatement(IDLObject):
def __init__(self, location, implementor, implementee):
IDLObject.__init__(self, location)
@ -4743,6 +4788,7 @@ class IDLImplementsStatement(IDLObject):
def addExtendedAttributes(self, attrs):
assert len(attrs) == 0
class IDLExtendedAttribute(IDLObject):
"""
A class to represent IDL extended attributes so we can give them locations
@ -4781,6 +4827,7 @@ class IDLExtendedAttribute(IDLObject):
# Parser
class Tokenizer(object):
tokens = [
"INTEGER",
@ -4920,6 +4967,7 @@ class Tokenizer(object):
lextab='webidllex',
reflags=re.DOTALL)
class SqueakyCleanLogger(object):
errorWhitelist = [
# Web IDL defines the WHITESPACE token, but doesn't actually
@ -4937,11 +4985,14 @@ class SqueakyCleanLogger(object):
# Which means the Other symbol is unreachable.
"Symbol 'Other' is unreachable",
]
def __init__(self):
self.errors = []
def debug(self, msg, *args, **kwargs):
pass
info = debug
def warning(self, msg, *args, **kwargs):
if msg == "%s:%d: Rule '%s' defined, but not used":
# Munge things so we don't have to hardcode filenames and
@ -4959,6 +5010,7 @@ class SqueakyCleanLogger(object):
if self.errors:
raise WebIDLError("\n".join(self.errors), [])
class Parser(Tokenizer):
def getLocation(self, p, i):
return Location(self.lexer, p.lineno(i), p.lexpos(i), self._filename)
@ -6442,6 +6494,7 @@ class Parser(Tokenizer):
typedef (SharedArrayBufferView or SharedArrayBuffer) SharedBufferSource;
"""
def main():
# Parse arguments.
from optparse import OptionParser