Update the WebIDL parser

This commit is contained in:
Anthony Ramine 2018-04-03 14:06:07 +02:00
parent 866a523914
commit 938f1362e7
12 changed files with 104 additions and 244 deletions

View file

@ -4800,7 +4800,7 @@ class CGProxySpecialOperation(CGPerSignatureCall):
False, descriptor, operation, False, descriptor, operation,
len(arguments)) len(arguments))
if operation.isSetter() or operation.isCreator(): if operation.isSetter():
# arguments[0] is the index or name of the item that we're setting. # arguments[0] is the index or name of the item that we're setting.
argument = arguments[1] argument = arguments[1]
info = getJSToNativeConversionInfo( info = getJSToNativeConversionInfo(

View file

@ -279,8 +279,6 @@ class Descriptor(DescriptorProvider):
addIndexedOrNamedOperation('Getter', m) addIndexedOrNamedOperation('Getter', m)
if m.isSetter(): if m.isSetter():
addIndexedOrNamedOperation('Setter', m) addIndexedOrNamedOperation('Setter', m)
if m.isCreator():
addIndexedOrNamedOperation('Creator', m)
if m.isDeleter(): if m.isDeleter():
addIndexedOrNamedOperation('Deleter', m) addIndexedOrNamedOperation('Deleter', m)

View file

@ -1095,12 +1095,12 @@ class IDLInterfaceOrNamespace(IDLObjectWithScope, IDLExposureMixins):
testInterface = testInterface.parent testInterface = testInterface.parent
# Ensure that there's at most one of each {named,indexed} # Ensure that there's at most one of each {named,indexed}
# {getter,setter,creator,deleter}, at most one stringifier, # {getter,setter,deleter}, at most one stringifier,
# and at most one legacycaller. Note that this last is not # and at most one legacycaller. Note that this last is not
# quite per spec, but in practice no one overloads # quite per spec, but in practice no one overloads
# legacycallers. Also note that in practice we disallow # legacycallers. Also note that in practice we disallow
# indexed deleters, but it simplifies some other code to # indexed deleters, but it simplifies some other code to
# treat deleter analogously to getter/setter/creator by # treat deleter analogously to getter/setter by
# prefixing it with "named". # prefixing it with "named".
specialMembersSeen = {} specialMembersSeen = {}
for member in self.members: for member in self.members:
@ -1111,8 +1111,6 @@ class IDLInterfaceOrNamespace(IDLObjectWithScope, IDLExposureMixins):
memberType = "getters" memberType = "getters"
elif member.isSetter(): elif member.isSetter():
memberType = "setters" memberType = "setters"
elif member.isCreator():
memberType = "creators"
elif member.isDeleter(): elif member.isDeleter():
memberType = "deleters" memberType = "deleters"
elif member.isStringifier(): elif member.isStringifier():
@ -1158,8 +1156,8 @@ class IDLInterfaceOrNamespace(IDLObjectWithScope, IDLExposureMixins):
ancestor = ancestor.parent ancestor = ancestor.parent
if self._isOnGlobalProtoChain: if self._isOnGlobalProtoChain:
# Make sure we have no named setters, creators, or deleters # Make sure we have no named setters or deleters
for memberType in ["setter", "creator", "deleter"]: for memberType in ["setter", "deleter"]:
memberId = "named " + memberType + "s" memberId = "named " + memberType + "s"
if memberId in specialMembersSeen: if memberId in specialMembersSeen:
raise WebIDLError("Interface with [Global] has a named %s" % raise WebIDLError("Interface with [Global] has a named %s" %
@ -1183,6 +1181,22 @@ class IDLInterfaceOrNamespace(IDLObjectWithScope, IDLExposureMixins):
parent = parent.parent parent = parent.parent
def validate(self): def validate(self):
def checkDuplicateNames(member, name, attributeName):
for m in self.members:
if m.identifier.name == name:
raise WebIDLError("[%s=%s] has same name as interface member" %
(attributeName, name),
[member.location, m.location])
if m.isMethod() and m != member and name in m.aliases:
raise WebIDLError("conflicting [%s=%s] definitions" %
(attributeName, name),
[member.location, m.location])
if m.isAttr() and m != member and name in m.bindingAliases:
raise WebIDLError("conflicting [%s=%s] definitions" %
(attributeName, name),
[member.location, m.location])
# We don't support consequential unforgeable interfaces. Need to check # We don't support consequential unforgeable interfaces. Need to check
# this here, because in finish() an interface might not know yet that # this here, because in finish() an interface might not know yet that
# it's consequential. # it's consequential.
@ -1295,15 +1309,15 @@ class IDLInterfaceOrNamespace(IDLObjectWithScope, IDLExposureMixins):
raise WebIDLError("[Alias] must not be used on an " raise WebIDLError("[Alias] must not be used on an "
"[Unforgeable] operation", "[Unforgeable] operation",
[member.location]) [member.location])
for m in self.members:
if m.identifier.name == alias: checkDuplicateNames(member, alias, "Alias")
raise WebIDLError("[Alias=%s] has same name as "
"interface member" % alias, # Check that the name of a [BindingAlias] doesn't conflict with an
[member.location, m.location]) # interface member.
if m.isMethod() and m != member and alias in m.aliases: if member.isAttr():
raise WebIDLError("duplicate [Alias=%s] definitions" % for bindingAlias in member.bindingAliases:
alias, checkDuplicateNames(member, bindingAlias, "BindingAlias")
[member.location, m.location])
# Conditional exposure makes no sense for interfaces with no # Conditional exposure makes no sense for interfaces with no
# interface object, unless they're navigator properties. # interface object, unless they're navigator properties.
@ -1720,10 +1734,10 @@ class IDLInterface(IDLInterfaceOrNamespace):
identifier == "OverrideBuiltins" or identifier == "OverrideBuiltins" or
identifier == "ChromeOnly" or identifier == "ChromeOnly" or
identifier == "Unforgeable" or identifier == "Unforgeable" or
identifier == "UnsafeInPrerendering" or
identifier == "LegacyEventInit" or identifier == "LegacyEventInit" or
identifier == "ProbablyShortLivingWrapper" or identifier == "ProbablyShortLivingWrapper" or
identifier == "LegacyUnenumerableNamedProperties" or identifier == "LegacyUnenumerableNamedProperties" or
identifier == "RunConstructorInCallerCompartment" or
identifier == "NonOrdinaryGetPrototypeOf" or identifier == "NonOrdinaryGetPrototypeOf" or
identifier == "Abstract" or identifier == "Abstract" or
identifier == "Inline"): identifier == "Inline"):
@ -1780,10 +1794,16 @@ class IDLNamespace(IDLInterfaceOrNamespace):
if not attr.hasValue(): if not attr.hasValue():
raise WebIDLError("[%s] must have a value" % identifier, raise WebIDLError("[%s] must have a value" % identifier,
[attr.location]) [attr.location])
elif identifier == "ProtoObjectHack": elif (identifier == "ProtoObjectHack" or
identifier == "ChromeOnly"):
if not attr.noArguments(): if not attr.noArguments():
raise WebIDLError("[%s] must not have arguments" % identifier, raise WebIDLError("[%s] must not have arguments" % identifier,
[attr.location]) [attr.location])
elif identifier == "Pref":
# Known extended attributes that take a string value
if not attr.hasValue():
raise WebIDLError("[%s] must have a value" % identifier,
[attr.location])
else: else:
raise WebIDLError("Unknown extended attribute %s on namespace" % raise WebIDLError("Unknown extended attribute %s on namespace" %
identifier, identifier,
@ -3581,6 +3601,11 @@ class IDLInterfaceMember(IDLObjectWithIdentifier, IDLExposureMixins):
[self.location]) [self.location])
self.aliases.append(alias) self.aliases.append(alias)
def _addBindingAlias(self, bindingAlias):
if bindingAlias in self.bindingAliases:
raise WebIDLError("Duplicate [BindingAlias=%s] on attribute" % bindingAlias,
[self.location])
self.bindingAliases.append(bindingAlias)
class IDLMaplikeOrSetlikeOrIterableBase(IDLInterfaceMember): class IDLMaplikeOrSetlikeOrIterableBase(IDLInterfaceMember):
@ -3701,6 +3726,11 @@ class IDLMaplikeOrSetlikeOrIterableBase(IDLInterfaceMember):
if isIteratorAlias: if isIteratorAlias:
method.addExtendedAttributes( method.addExtendedAttributes(
[IDLExtendedAttribute(self.location, ("Alias", "@@iterator"))]) [IDLExtendedAttribute(self.location, ("Alias", "@@iterator"))])
# Methods generated for iterables should be enumerable, but the ones for
# maplike/setlike should not be.
if not self.isIterable():
method.addExtendedAttributes(
[IDLExtendedAttribute(self.location, ("NonEnumerable",))])
members.append(method) members.append(method)
def resolve(self, parentScope): def resolve(self, parentScope):
@ -3824,11 +3854,15 @@ class IDLMaplikeOrSetlike(IDLMaplikeOrSetlikeOrIterableBase):
specification during parsing. specification during parsing.
""" """
# Both maplike and setlike have a size attribute # Both maplike and setlike have a size attribute
members.append(IDLAttribute(self.location, sizeAttr = IDLAttribute(self.location,
IDLUnresolvedIdentifier(BuiltinLocation("<auto-generated-identifier>"), "size"), IDLUnresolvedIdentifier(BuiltinLocation("<auto-generated-identifier>"), "size"),
BuiltinTypes[IDLBuiltinType.Types.unsigned_long], BuiltinTypes[IDLBuiltinType.Types.unsigned_long],
True, True,
maplikeOrSetlike=self)) maplikeOrSetlike=self)
# This should be non-enumerable.
sizeAttr.addExtendedAttributes(
[IDLExtendedAttribute(self.location, ("NonEnumerable",))])
members.append(sizeAttr)
self.reserved_ro_names = ["size"] self.reserved_ro_names = ["size"]
self.disallowedMemberNames.append("size") self.disallowedMemberNames.append("size")
@ -3964,7 +3998,9 @@ class IDLConst(IDLInterfaceMember):
elif (identifier == "Pref" or elif (identifier == "Pref" or
identifier == "ChromeOnly" or identifier == "ChromeOnly" or
identifier == "Func" or identifier == "Func" or
identifier == "SecureContext"): identifier == "SecureContext" or
identifier == "NonEnumerable" or
identifier == "NeedsWindowsUndef"):
# Known attributes that we don't need to do anything with here # Known attributes that we don't need to do anything with here
pass pass
else: else:
@ -4000,6 +4036,7 @@ class IDLAttribute(IDLInterfaceMember):
self.dependsOn = "Everything" self.dependsOn = "Everything"
self.affects = "Everything" self.affects = "Everything"
self.navigatorObjectGetter = navigatorObjectGetter self.navigatorObjectGetter = navigatorObjectGetter
self.bindingAliases = []
if static and identifier.name == "prototype": if static and identifier.name == "prototype":
raise WebIDLError("The identifier of a static attribute must not be 'prototype'", raise WebIDLError("The identifier of a static attribute must not be 'prototype'",
@ -4138,11 +4175,17 @@ class IDLAttribute(IDLInterfaceMember):
def handleExtendedAttribute(self, attr): def handleExtendedAttribute(self, attr):
identifier = attr.identifier() identifier = attr.identifier()
if ((identifier == "SetterThrows" or identifier == "SetterCanOOM") if ((identifier == "SetterThrows" or identifier == "SetterCanOOM" or
identifier == "SetterNeedsSubjectPrincipal")
and self.readonly): and self.readonly):
raise WebIDLError("Readonly attributes must not be flagged as " raise WebIDLError("Readonly attributes must not be flagged as "
"[%s]" % identifier, "[%s]" % identifier,
[self.location]) [self.location])
elif identifier == "BindingAlias":
if not attr.hasValue():
raise WebIDLError("[BindingAlias] takes an identifier or string",
[attr.location])
self._addBindingAlias(attr.value())
elif (((identifier == "Throws" or identifier == "GetterThrows" or elif (((identifier == "Throws" or identifier == "GetterThrows" or
identifier == "CanOOM" or identifier == "GetterCanOOM") and identifier == "CanOOM" or identifier == "GetterCanOOM") and
self.getExtendedAttribute("StoreInSlot")) or self.getExtendedAttribute("StoreInSlot")) or
@ -4338,11 +4381,13 @@ class IDLAttribute(IDLInterfaceMember):
identifier == "SecureContext" or identifier == "SecureContext" or
identifier == "Frozen" or identifier == "Frozen" or
identifier == "NewObject" or identifier == "NewObject" or
identifier == "UnsafeInPrerendering" or
identifier == "NeedsSubjectPrincipal" or identifier == "NeedsSubjectPrincipal" or
identifier == "SetterNeedsSubjectPrincipal" or
identifier == "GetterNeedsSubjectPrincipal" or
identifier == "NeedsCallerType" or identifier == "NeedsCallerType" or
identifier == "ReturnValueNeedsContainsHack" or identifier == "ReturnValueNeedsContainsHack" or
identifier == "BinaryName"): identifier == "BinaryName" or
identifier == "NonEnumerable"):
# Known attributes that we don't need to do anything with here # Known attributes that we don't need to do anything with here
pass pass
else: else:
@ -4606,7 +4651,6 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
Special = enum( Special = enum(
'Getter', 'Getter',
'Setter', 'Setter',
'Creator',
'Deleter', 'Deleter',
'LegacyCaller', 'LegacyCaller',
base=IDLInterfaceMember.Special base=IDLInterfaceMember.Special
@ -4619,7 +4663,7 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
) )
def __init__(self, location, identifier, returnType, arguments, def __init__(self, location, identifier, returnType, arguments,
static=False, getter=False, setter=False, creator=False, static=False, getter=False, setter=False,
deleter=False, specialType=NamedOrIndexed.Neither, deleter=False, specialType=NamedOrIndexed.Neither,
legacycaller=False, stringifier=False, jsonifier=False, legacycaller=False, stringifier=False, jsonifier=False,
maplikeOrSetlikeOrIterable=None, htmlConstructor=False): maplikeOrSetlikeOrIterable=None, htmlConstructor=False):
@ -4640,8 +4684,6 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
self._getter = getter self._getter = getter
assert isinstance(setter, bool) assert isinstance(setter, bool)
self._setter = setter self._setter = setter
assert isinstance(creator, bool)
self._creator = creator
assert isinstance(deleter, bool) assert isinstance(deleter, bool)
self._deleter = deleter self._deleter = deleter
assert isinstance(legacycaller, bool) assert isinstance(legacycaller, bool)
@ -4682,7 +4724,7 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
assert not arguments[0].optional and not arguments[0].variadic assert not arguments[0].optional and not arguments[0].variadic
assert not self._getter or not overload.returnType.isVoid() assert not self._getter or not overload.returnType.isVoid()
if self._setter or self._creator: if self._setter:
assert len(self._overloads) == 1 assert len(self._overloads) == 1
arguments = self._overloads[0].arguments arguments = self._overloads[0].arguments
assert len(arguments) == 2 assert len(arguments) == 2
@ -4715,9 +4757,6 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
def isSetter(self): def isSetter(self):
return self._setter return self._setter
def isCreator(self):
return self._creator
def isDeleter(self): def isDeleter(self):
return self._deleter return self._deleter
@ -4750,7 +4789,6 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
def isSpecial(self): def isSpecial(self):
return (self.isGetter() or return (self.isGetter() or
self.isSetter() or self.isSetter() or
self.isCreator() or
self.isDeleter() or self.isDeleter() or
self.isLegacycaller() or self.isLegacycaller() or
self.isStringifier() or self.isStringifier() or
@ -4806,8 +4844,6 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
assert not method.isGetter() assert not method.isGetter()
assert not self.isSetter() assert not self.isSetter()
assert not method.isSetter() assert not method.isSetter()
assert not self.isCreator()
assert not method.isCreator()
assert not self.isDeleter() assert not self.isDeleter()
assert not method.isDeleter() assert not method.isDeleter()
assert not self.isStringifier() assert not self.isStringifier()
@ -4984,7 +5020,9 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
if (identifier == "GetterThrows" or if (identifier == "GetterThrows" or
identifier == "SetterThrows" or identifier == "SetterThrows" or
identifier == "GetterCanOOM" or identifier == "GetterCanOOM" or
identifier == "SetterCanOOM"): identifier == "SetterCanOOM" or
identifier == "SetterNeedsSubjectPrincipal" or
identifier == "GetterNeedsSubjectPrincipal"):
raise WebIDLError("Methods must not be flagged as " raise WebIDLError("Methods must not be flagged as "
"[%s]" % identifier, "[%s]" % identifier,
[attr.location, self.location]) [attr.location, self.location])
@ -5071,7 +5109,6 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
identifier == "CanOOM" or identifier == "CanOOM" or
identifier == "NewObject" or identifier == "NewObject" or
identifier == "ChromeOnly" or identifier == "ChromeOnly" or
identifier == "UnsafeInPrerendering" or
identifier == "Pref" or identifier == "Pref" or
identifier == "Deprecated" or identifier == "Deprecated" or
identifier == "Func" or identifier == "Func" or
@ -5079,7 +5116,8 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
identifier == "BinaryName" or identifier == "BinaryName" or
identifier == "NeedsSubjectPrincipal" or identifier == "NeedsSubjectPrincipal" or
identifier == "NeedsCallerType" or identifier == "NeedsCallerType" or
identifier == "StaticClassOverride"): identifier == "StaticClassOverride" or
identifier == "NonEnumerable"):
# Known attributes that we don't need to do anything with here # Known attributes that we don't need to do anything with here
pass pass
else: else:
@ -5262,7 +5300,6 @@ class Tokenizer(object):
"static": "STATIC", "static": "STATIC",
"getter": "GETTER", "getter": "GETTER",
"setter": "SETTER", "setter": "SETTER",
"creator": "CREATOR",
"deleter": "DELETER", "deleter": "DELETER",
"legacycaller": "LEGACYCALLER", "legacycaller": "LEGACYCALLER",
"optional": "OPTIONAL", "optional": "OPTIONAL",
@ -5977,13 +6014,12 @@ class Parser(Tokenizer):
getter = True if IDLMethod.Special.Getter in p[1] else False getter = True if IDLMethod.Special.Getter in p[1] else False
setter = True if IDLMethod.Special.Setter in p[1] else False setter = True if IDLMethod.Special.Setter in p[1] else False
creator = True if IDLMethod.Special.Creator in p[1] else False
deleter = True if IDLMethod.Special.Deleter in p[1] else False deleter = True if IDLMethod.Special.Deleter in p[1] else False
legacycaller = True if IDLMethod.Special.LegacyCaller in p[1] else False legacycaller = True if IDLMethod.Special.LegacyCaller in p[1] else False
if getter or deleter: if getter or deleter:
if setter or creator: if setter:
raise WebIDLError("getter and deleter are incompatible with setter and creator", raise WebIDLError("getter and deleter are incompatible with setter",
[self.getLocation(p, 1)]) [self.getLocation(p, 1)])
(returnType, identifier, arguments) = p[2] (returnType, identifier, arguments) = p[2]
@ -6018,10 +6054,9 @@ class Parser(Tokenizer):
if returnType.isVoid(): if returnType.isVoid():
raise WebIDLError("getter cannot have void return type", raise WebIDLError("getter cannot have void return type",
[self.getLocation(p, 2)]) [self.getLocation(p, 2)])
if setter or creator: if setter:
if len(arguments) != 2: if len(arguments) != 2:
raise WebIDLError("%s has wrong number of arguments" % raise WebIDLError("setter has wrong number of arguments",
("setter" if setter else "creator"),
[self.getLocation(p, 2)]) [self.getLocation(p, 2)])
argType = arguments[0].type argType = arguments[0].type
if argType == BuiltinTypes[IDLBuiltinType.Types.domstring]: if argType == BuiltinTypes[IDLBuiltinType.Types.domstring]:
@ -6029,18 +6064,15 @@ class Parser(Tokenizer):
elif argType == BuiltinTypes[IDLBuiltinType.Types.unsigned_long]: elif argType == BuiltinTypes[IDLBuiltinType.Types.unsigned_long]:
specialType = IDLMethod.NamedOrIndexed.Indexed specialType = IDLMethod.NamedOrIndexed.Indexed
else: else:
raise WebIDLError("%s has wrong argument type (must be DOMString or UnsignedLong)" % raise WebIDLError("settter has wrong argument type (must be DOMString or UnsignedLong)",
("setter" if setter else "creator"),
[arguments[0].location]) [arguments[0].location])
if arguments[0].optional or arguments[0].variadic: if arguments[0].optional or arguments[0].variadic:
raise WebIDLError("%s cannot have %s argument" % raise WebIDLError("setter cannot have %s argument" %
("setter" if setter else "creator", ("optional" if arguments[0].optional else "variadic"),
"optional" if arguments[0].optional else "variadic"),
[arguments[0].location]) [arguments[0].location])
if arguments[1].optional or arguments[1].variadic: if arguments[1].optional or arguments[1].variadic:
raise WebIDLError("%s cannot have %s argument" % raise WebIDLError("setter cannot have %s argument" %
("setter" if setter else "creator", ("optional" if arguments[1].optional else "variadic"),
"optional" if arguments[1].optional else "variadic"),
[arguments[1].location]) [arguments[1].location])
if stringifier: if stringifier:
@ -6053,7 +6085,7 @@ class Parser(Tokenizer):
# identifier might be None. This is only permitted for special methods. # identifier might be None. This is only permitted for special methods.
if not identifier: if not identifier:
if (not getter and not setter and not creator and if (not getter and not setter and
not deleter and not legacycaller and not stringifier): not deleter and not legacycaller and not stringifier):
raise WebIDLError("Identifier required for non-special methods", raise WebIDLError("Identifier required for non-special methods",
[self.getLocation(p, 2)]) [self.getLocation(p, 2)])
@ -6061,19 +6093,18 @@ class Parser(Tokenizer):
location = BuiltinLocation("<auto-generated-identifier>") location = BuiltinLocation("<auto-generated-identifier>")
identifier = IDLUnresolvedIdentifier( identifier = IDLUnresolvedIdentifier(
location, location,
"__%s%s%s%s%s%s%s" % "__%s%s%s%s%s%s" %
("named" if specialType == IDLMethod.NamedOrIndexed.Named else ("named" if specialType == IDLMethod.NamedOrIndexed.Named else
"indexed" if specialType == IDLMethod.NamedOrIndexed.Indexed else "", "indexed" if specialType == IDLMethod.NamedOrIndexed.Indexed else "",
"getter" if getter else "", "getter" if getter else "",
"setter" if setter else "", "setter" if setter else "",
"deleter" if deleter else "", "deleter" if deleter else "",
"creator" if creator else "",
"legacycaller" if legacycaller else "", "legacycaller" if legacycaller else "",
"stringifier" if stringifier else ""), "stringifier" if stringifier else ""),
allowDoubleUnderscore=True) allowDoubleUnderscore=True)
method = IDLMethod(self.getLocation(p, 2), identifier, returnType, arguments, method = IDLMethod(self.getLocation(p, 2), identifier, returnType, arguments,
static=static, getter=getter, setter=setter, creator=creator, static=static, getter=getter, setter=setter,
deleter=deleter, specialType=specialType, deleter=deleter, specialType=specialType,
legacycaller=legacycaller, stringifier=stringifier) legacycaller=legacycaller, stringifier=stringifier)
p[0] = method p[0] = method
@ -6149,12 +6180,6 @@ class Parser(Tokenizer):
""" """
p[0] = IDLMethod.Special.Setter p[0] = IDLMethod.Special.Setter
def p_SpecialCreator(self, p):
"""
Special : CREATOR
"""
p[0] = IDLMethod.Special.Creator
def p_SpecialDeleter(self, p): def p_SpecialDeleter(self, p):
""" """
Special : DELETER Special : DELETER
@ -6246,7 +6271,6 @@ class Parser(Tokenizer):
| ATTRIBUTE | ATTRIBUTE
| CALLBACK | CALLBACK
| CONST | CONST
| CREATOR
| DELETER | DELETER
| DICTIONARY | DICTIONARY
| ENUM | ENUM
@ -6396,7 +6420,6 @@ class Parser(Tokenizer):
| BYTE | BYTE
| LEGACYCALLER | LEGACYCALLER
| CONST | CONST
| CREATOR
| DELETER | DELETER
| DOUBLE | DOUBLE
| EXCEPTION | EXCEPTION

View file

@ -1,9 +1,9 @@
--- WebIDL.py --- WebIDL.py
+++ WebIDL.py +++ WebIDL.py
@@ -1416,7 +1416,8 @@ @@ -1744,7 +1744,8 @@
identifier == "LegacyEventInit" or identifier == "ProbablyShortLivingWrapper" or
identifier == "ProbablyShortLivingObject" or
identifier == "LegacyUnenumerableNamedProperties" or identifier == "LegacyUnenumerableNamedProperties" or
identifier == "RunConstructorInCallerCompartment" or
- identifier == "NonOrdinaryGetPrototypeOf"): - identifier == "NonOrdinaryGetPrototypeOf"):
+ identifier == "NonOrdinaryGetPrototypeOf" or + identifier == "NonOrdinaryGetPrototypeOf" or
+ identifier == "Abstract"): + identifier == "Abstract"):

View file

@ -101,21 +101,6 @@ def WebIDLTest(parser, harness):
harness.ok(threw, harness.ok(threw,
"Should have thrown for [CEReactions] used on a named getter") "Should have thrown for [CEReactions] used on a named getter")
parser = parser.reset()
threw = False
try:
parser.parse("""
interface Foo {
[CEReactions] creator boolean (DOMString name, boolean value);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should have thrown for [CEReactions] used on a named creator")
parser = parser.reset() parser = parser.reset()
threw = False threw = False
try: try:

View file

@ -11,7 +11,7 @@ def WebIDLTest(parser, harness):
harness.check(argument.variadic, variadic, "Argument has the right variadic value") harness.check(argument.variadic, variadic, "Argument has the right variadic value")
def checkMethod(method, QName, name, signatures, def checkMethod(method, QName, name, signatures,
static=True, getter=False, setter=False, creator=False, static=True, getter=False, setter=False,
deleter=False, legacycaller=False, stringifier=False, deleter=False, legacycaller=False, stringifier=False,
chromeOnly=False, htmlConstructor=False): chromeOnly=False, htmlConstructor=False):
harness.ok(isinstance(method, WebIDL.IDLMethod), harness.ok(isinstance(method, WebIDL.IDLMethod),
@ -24,7 +24,6 @@ def WebIDLTest(parser, harness):
harness.check(method.isStatic(), static, "Method has the correct static value") harness.check(method.isStatic(), static, "Method has the correct static value")
harness.check(method.isGetter(), getter, "Method has the correct getter value") harness.check(method.isGetter(), getter, "Method has the correct getter value")
harness.check(method.isSetter(), setter, "Method has the correct setter value") harness.check(method.isSetter(), setter, "Method has the correct setter value")
harness.check(method.isCreator(), creator, "Method has the correct creator value")
harness.check(method.isDeleter(), deleter, "Method has the correct deleter value") harness.check(method.isDeleter(), deleter, "Method has the correct deleter value")
harness.check(method.isLegacycaller(), legacycaller, "Method has the correct legacycaller value") harness.check(method.isLegacycaller(), legacycaller, "Method has the correct legacycaller value")
harness.check(method.isStringifier(), stringifier, "Method has the correct stringifier value") harness.check(method.isStringifier(), stringifier, "Method has the correct stringifier value")

View file

@ -27,20 +27,6 @@ def WebIDLTest(parser, harness):
harness.ok(threw, "Should have thrown.") harness.ok(threw, "Should have thrown.")
threw = False
try:
parser.parse("""
interface DuplicateQualifiers3 {
creator creator byte foo(unsigned long index, byte value);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")
threw = False threw = False
try: try:
parser.parse(""" parser.parse("""
@ -68,17 +54,3 @@ def WebIDLTest(parser, harness):
threw = True threw = True
harness.ok(threw, "Should have thrown.") harness.ok(threw, "Should have thrown.")
threw = False
try:
results = parser.parse("""
interface DuplicateQualifiers6 {
creator setter creator byte foo(unsigned long index, byte value);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")

View file

@ -32,24 +32,6 @@ def WebIDLTest(parser, harness):
"Should have thrown for [Global] used on an interface with a " "Should have thrown for [Global] used on an interface with a "
"named setter") "named setter")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Global]
interface Foo {
getter any(DOMString name);
creator void(DOMString name, any arg);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should have thrown for [Global] used on an interface with a "
"named creator")
parser = parser.reset() parser = parser.reset()
threw = False threw = False
try: try:

View file

@ -41,7 +41,7 @@ def WebIDLTest(parser, harness):
harness.check(argument.variadic, variadic, "Argument has the right variadic value") harness.check(argument.variadic, variadic, "Argument has the right variadic value")
def checkMethod(method, QName, name, signatures, def checkMethod(method, QName, name, signatures,
static=False, getter=False, setter=False, creator=False, static=False, getter=False, setter=False,
deleter=False, legacycaller=False, stringifier=False): deleter=False, legacycaller=False, stringifier=False):
harness.ok(isinstance(method, WebIDL.IDLMethod), harness.ok(isinstance(method, WebIDL.IDLMethod),
"Should be an IDLMethod") "Should be an IDLMethod")
@ -53,7 +53,6 @@ def WebIDLTest(parser, harness):
harness.check(method.isStatic(), static, "Method has the correct static value") harness.check(method.isStatic(), static, "Method has the correct static value")
harness.check(method.isGetter(), getter, "Method has the correct getter value") harness.check(method.isGetter(), getter, "Method has the correct getter value")
harness.check(method.isSetter(), setter, "Method has the correct setter value") harness.check(method.isSetter(), setter, "Method has the correct setter value")
harness.check(method.isCreator(), creator, "Method has the correct creator value")
harness.check(method.isDeleter(), deleter, "Method has the correct deleter value") harness.check(method.isDeleter(), deleter, "Method has the correct deleter value")
harness.check(method.isLegacycaller(), legacycaller, "Method has the correct legacycaller value") harness.check(method.isLegacycaller(), legacycaller, "Method has the correct legacycaller value")
harness.check(method.isStringifier(), stringifier, "Method has the correct stringifier value") harness.check(method.isStringifier(), stringifier, "Method has the correct stringifier value")

View file

@ -222,73 +222,3 @@ def WebIDLTest(parser, harness):
threw = True threw = True
harness.ok(threw, "Should have thrown.") harness.ok(threw, "Should have thrown.")
threw = False
try:
parser.parse("""
interface SpecialMethodSignatureMismatch20 {
creator long long foo(long index, long long value);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")
threw = False
try:
parser.parse("""
interface SpecialMethodSignatureMismatch22 {
creator boolean foo(unsigned long index, boolean value, long long extraArg);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")
threw = False
try:
parser.parse("""
interface SpecialMethodSignatureMismatch23 {
creator boolean foo(unsigned long index, boolean... value);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")
threw = False
try:
parser.parse("""
interface SpecialMethodSignatureMismatch24 {
creator boolean foo(unsigned long index, optional boolean value);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")
threw = False
try:
parser.parse("""
interface SpecialMethodSignatureMismatch25 {
creator boolean foo();
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")

View file

@ -5,25 +5,21 @@ def WebIDLTest(parser, harness):
interface SpecialMethods { interface SpecialMethods {
getter long long (unsigned long index); getter long long (unsigned long index);
setter long long (unsigned long index, long long value); setter long long (unsigned long index, long long value);
creator long long (unsigned long index, long long value);
getter boolean (DOMString name); getter boolean (DOMString name);
setter boolean (DOMString name, boolean value); setter boolean (DOMString name, boolean value);
creator boolean (DOMString name, boolean value);
deleter boolean (DOMString name); deleter boolean (DOMString name);
readonly attribute unsigned long length; readonly attribute unsigned long length;
}; };
interface SpecialMethodsCombination { interface SpecialMethodsCombination {
setter creator long long (unsigned long index, long long value);
getter deleter boolean (DOMString name); getter deleter boolean (DOMString name);
setter creator boolean (DOMString name, boolean value);
}; };
""") """)
results = parser.finish() results = parser.finish()
def checkMethod(method, QName, name, def checkMethod(method, QName, name,
static=False, getter=False, setter=False, creator=False, static=False, getter=False, setter=False,
deleter=False, legacycaller=False, stringifier=False): deleter=False, legacycaller=False, stringifier=False):
harness.ok(isinstance(method, WebIDL.IDLMethod), harness.ok(isinstance(method, WebIDL.IDLMethod),
"Should be an IDLMethod") "Should be an IDLMethod")
@ -32,7 +28,6 @@ def WebIDLTest(parser, harness):
harness.check(method.isStatic(), static, "Method has the correct static value") harness.check(method.isStatic(), static, "Method has the correct static value")
harness.check(method.isGetter(), getter, "Method has the correct getter value") harness.check(method.isGetter(), getter, "Method has the correct getter value")
harness.check(method.isSetter(), setter, "Method has the correct setter value") harness.check(method.isSetter(), setter, "Method has the correct setter value")
harness.check(method.isCreator(), creator, "Method has the correct creator value")
harness.check(method.isDeleter(), deleter, "Method has the correct deleter value") harness.check(method.isDeleter(), deleter, "Method has the correct deleter value")
harness.check(method.isLegacycaller(), legacycaller, "Method has the correct legacycaller value") harness.check(method.isLegacycaller(), legacycaller, "Method has the correct legacycaller value")
harness.check(method.isStringifier(), stringifier, "Method has the correct stringifier value") harness.check(method.isStringifier(), stringifier, "Method has the correct stringifier value")
@ -40,32 +35,24 @@ def WebIDLTest(parser, harness):
harness.check(len(results), 2, "Expect 2 interfaces") harness.check(len(results), 2, "Expect 2 interfaces")
iface = results[0] iface = results[0]
harness.check(len(iface.members), 8, "Expect 8 members") harness.check(len(iface.members), 6, "Expect 6 members")
checkMethod(iface.members[0], "::SpecialMethods::__indexedgetter", "__indexedgetter", checkMethod(iface.members[0], "::SpecialMethods::__indexedgetter", "__indexedgetter",
getter=True) getter=True)
checkMethod(iface.members[1], "::SpecialMethods::__indexedsetter", "__indexedsetter", checkMethod(iface.members[1], "::SpecialMethods::__indexedsetter", "__indexedsetter",
setter=True) setter=True)
checkMethod(iface.members[2], "::SpecialMethods::__indexedcreator", "__indexedcreator", checkMethod(iface.members[2], "::SpecialMethods::__namedgetter", "__namedgetter",
creator=True)
checkMethod(iface.members[3], "::SpecialMethods::__namedgetter", "__namedgetter",
getter=True) getter=True)
checkMethod(iface.members[4], "::SpecialMethods::__namedsetter", "__namedsetter", checkMethod(iface.members[3], "::SpecialMethods::__namedsetter", "__namedsetter",
setter=True) setter=True)
checkMethod(iface.members[5], "::SpecialMethods::__namedcreator", "__namedcreator", checkMethod(iface.members[4], "::SpecialMethods::__nameddeleter", "__nameddeleter",
creator=True)
checkMethod(iface.members[6], "::SpecialMethods::__nameddeleter", "__nameddeleter",
deleter=True) deleter=True)
iface = results[1] iface = results[1]
harness.check(len(iface.members), 3, "Expect 3 members") harness.check(len(iface.members), 1, "Expect 1 member")
checkMethod(iface.members[0], "::SpecialMethodsCombination::__indexedsettercreator", checkMethod(iface.members[0], "::SpecialMethodsCombination::__namedgetterdeleter",
"__indexedsettercreator", setter=True, creator=True)
checkMethod(iface.members[1], "::SpecialMethodsCombination::__namedgetterdeleter",
"__namedgetterdeleter", getter=True, deleter=True) "__namedgetterdeleter", getter=True, deleter=True)
checkMethod(iface.members[2], "::SpecialMethodsCombination::__namedsettercreator",
"__namedsettercreator", setter=True, creator=True)
parser = parser.reset(); parser = parser.reset();

View file

@ -31,27 +31,12 @@ def WebIDLTest(parser, harness):
harness.ok(threw, "Should have thrown.") harness.ok(threw, "Should have thrown.")
threw = False
try:
parser.parse("""
interface SpecialMethodUniqueness1 {
setter creator boolean (DOMString name);
creator boolean (DOMString name);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")
threw = False threw = False
try: try:
parser.parse(""" parser.parse("""
interface SpecialMethodUniqueness1 { interface SpecialMethodUniqueness1 {
setter boolean (DOMString name); setter boolean (DOMString name);
creator setter boolean (DOMString name); setter boolean (DOMString name);
}; };
""") """)