mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Update the WebIDL parser
This commit is contained in:
parent
4c084cefa3
commit
107b92cc62
13 changed files with 127 additions and 531 deletions
|
@ -462,8 +462,7 @@ class CGMethodCall(CGThing):
|
||||||
pickFirstSignature("%s.get().is_object() && is_array_like(cx, %s)" %
|
pickFirstSignature("%s.get().is_object() && is_array_like(cx, %s)" %
|
||||||
(distinguishingArg, distinguishingArg),
|
(distinguishingArg, distinguishingArg),
|
||||||
lambda s:
|
lambda s:
|
||||||
(s[1][distinguishingIndex].type.isArray() or
|
(s[1][distinguishingIndex].type.isSequence() or
|
||||||
s[1][distinguishingIndex].type.isSequence() or
|
|
||||||
s[1][distinguishingIndex].type.isObject()))
|
s[1][distinguishingIndex].type.isObject()))
|
||||||
|
|
||||||
# Check for Date objects
|
# Check for Date objects
|
||||||
|
@ -537,9 +536,6 @@ def typeIsSequenceOrHasSequenceMember(type):
|
||||||
type = type.inner
|
type = type.inner
|
||||||
if type.isSequence():
|
if type.isSequence():
|
||||||
return True
|
return True
|
||||||
if type.isArray():
|
|
||||||
elementType = type.inner
|
|
||||||
return typeIsSequenceOrHasSequenceMember(elementType)
|
|
||||||
if type.isDictionary():
|
if type.isDictionary():
|
||||||
return dictionaryHasSequenceMember(type.inner)
|
return dictionaryHasSequenceMember(type.inner)
|
||||||
if type.isUnion():
|
if type.isUnion():
|
||||||
|
@ -732,9 +728,6 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
|
|
||||||
assert not (isEnforceRange and isClamp) # These are mutually exclusive
|
assert not (isEnforceRange and isClamp) # These are mutually exclusive
|
||||||
|
|
||||||
if type.isArray():
|
|
||||||
raise TypeError("Can't handle array arguments yet")
|
|
||||||
|
|
||||||
if type.isSequence() or type.isMozMap():
|
if type.isSequence() or type.isMozMap():
|
||||||
innerInfo = getJSToNativeConversionInfo(innerContainerType(type),
|
innerInfo = getJSToNativeConversionInfo(innerContainerType(type),
|
||||||
descriptorProvider,
|
descriptorProvider,
|
||||||
|
@ -1309,7 +1302,7 @@ def typeNeedsCx(type, retVal=False):
|
||||||
return False
|
return False
|
||||||
if type.nullable():
|
if type.nullable():
|
||||||
type = type.inner
|
type = type.inner
|
||||||
if type.isSequence() or type.isArray():
|
if type.isSequence():
|
||||||
type = type.inner
|
type = type.inner
|
||||||
if type.isUnion():
|
if type.isUnion():
|
||||||
return any(typeNeedsCx(t) for t in type.unroll().flatMemberTypes)
|
return any(typeNeedsCx(t) for t in type.unroll().flatMemberTypes)
|
||||||
|
@ -3817,9 +3810,6 @@ class CGMemberJITInfo(CGThing):
|
||||||
if t.isVoid():
|
if t.isVoid():
|
||||||
# No return, every time
|
# No return, every time
|
||||||
return "JSVAL_TYPE_UNDEFINED"
|
return "JSVAL_TYPE_UNDEFINED"
|
||||||
if t.isArray():
|
|
||||||
# No idea yet
|
|
||||||
assert False
|
|
||||||
if t.isSequence():
|
if t.isSequence():
|
||||||
return "JSVAL_TYPE_OBJECT"
|
return "JSVAL_TYPE_OBJECT"
|
||||||
if t.isMozMap():
|
if t.isMozMap():
|
||||||
|
@ -3895,9 +3885,6 @@ class CGMemberJITInfo(CGThing):
|
||||||
if t.nullable():
|
if t.nullable():
|
||||||
# Sometimes it might return null, sometimes not
|
# Sometimes it might return null, sometimes not
|
||||||
return "JSJitInfo_ArgType::Null as i32 | %s" % CGMemberJITInfo.getJSArgType(t.inner)
|
return "JSJitInfo_ArgType::Null as i32 | %s" % CGMemberJITInfo.getJSArgType(t.inner)
|
||||||
if t.isArray():
|
|
||||||
# No idea yet
|
|
||||||
assert False
|
|
||||||
if t.isSequence():
|
if t.isSequence():
|
||||||
return "JSJitInfo_ArgType::Object as i32"
|
return "JSJitInfo_ArgType::Object as i32"
|
||||||
if t.isGeckoInterface():
|
if t.isGeckoInterface():
|
||||||
|
@ -4161,7 +4148,7 @@ class CGUnionConversionStruct(CGThing):
|
||||||
else:
|
else:
|
||||||
interfaceObject = None
|
interfaceObject = None
|
||||||
|
|
||||||
arrayObjectMemberTypes = filter(lambda t: t.isArray() or t.isSequence(), memberTypes)
|
arrayObjectMemberTypes = filter(lambda t: t.isSequence(), memberTypes)
|
||||||
if len(arrayObjectMemberTypes) > 0:
|
if len(arrayObjectMemberTypes) > 0:
|
||||||
assert len(arrayObjectMemberTypes) == 1
|
assert len(arrayObjectMemberTypes) == 1
|
||||||
typeName = arrayObjectMemberTypes[0].name
|
typeName = arrayObjectMemberTypes[0].name
|
||||||
|
|
|
@ -9,6 +9,7 @@ import re
|
||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
import math
|
import math
|
||||||
|
import string
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
# Machinery
|
# Machinery
|
||||||
|
@ -1850,7 +1851,6 @@ class IDLDictionary(IDLObjectWithScope):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if (memberType.nullable() or
|
if (memberType.nullable() or
|
||||||
memberType.isArray() or
|
|
||||||
memberType.isSequence() or
|
memberType.isSequence() or
|
||||||
memberType.isMozMap()):
|
memberType.isMozMap()):
|
||||||
return typeContainsDictionary(memberType.inner, dictionary)
|
return typeContainsDictionary(memberType.inner, dictionary)
|
||||||
|
@ -1973,8 +1973,7 @@ class IDLType(IDLObject):
|
||||||
'callback',
|
'callback',
|
||||||
'union',
|
'union',
|
||||||
'sequence',
|
'sequence',
|
||||||
'mozmap',
|
'mozmap'
|
||||||
'array'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, location, name):
|
def __init__(self, location, name):
|
||||||
|
@ -2027,9 +2026,6 @@ class IDLType(IDLObject):
|
||||||
def isMozMap(self):
|
def isMozMap(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def isArray(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def isArrayBuffer(self):
|
def isArrayBuffer(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -2255,9 +2251,6 @@ class IDLNullableType(IDLParameterizedType):
|
||||||
def isMozMap(self):
|
def isMozMap(self):
|
||||||
return self.inner.isMozMap()
|
return self.inner.isMozMap()
|
||||||
|
|
||||||
def isArray(self):
|
|
||||||
return self.inner.isArray()
|
|
||||||
|
|
||||||
def isArrayBuffer(self):
|
def isArrayBuffer(self):
|
||||||
return self.inner.isArrayBuffer()
|
return self.inner.isArrayBuffer()
|
||||||
|
|
||||||
|
@ -2360,9 +2353,6 @@ class IDLSequenceType(IDLParameterizedType):
|
||||||
def isSequence(self):
|
def isSequence(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def isArray(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def isDictionary(self):
|
def isDictionary(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -2575,106 +2565,6 @@ class IDLUnionType(IDLType):
|
||||||
return set(self.memberTypes)
|
return set(self.memberTypes)
|
||||||
|
|
||||||
|
|
||||||
class IDLArrayType(IDLType):
|
|
||||||
def __init__(self, location, parameterType):
|
|
||||||
assert not parameterType.isVoid()
|
|
||||||
if parameterType.isSequence():
|
|
||||||
raise WebIDLError("Array type cannot parameterize over a sequence type",
|
|
||||||
[location])
|
|
||||||
if parameterType.isMozMap():
|
|
||||||
raise WebIDLError("Array type cannot parameterize over a MozMap type",
|
|
||||||
[location])
|
|
||||||
if parameterType.isDictionary():
|
|
||||||
raise WebIDLError("Array type cannot parameterize over a dictionary type",
|
|
||||||
[location])
|
|
||||||
|
|
||||||
IDLType.__init__(self, location, parameterType.name)
|
|
||||||
self.inner = parameterType
|
|
||||||
self.builtin = False
|
|
||||||
|
|
||||||
def __eq__(self, other):
|
|
||||||
return isinstance(other, IDLArrayType) and self.inner == other.inner
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.inner.__str__() + "Array"
|
|
||||||
|
|
||||||
def nullable(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def isPrimitive(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def isString(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def isByteString(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def isDOMString(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def isUSVString(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def isVoid(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def isSequence(self):
|
|
||||||
assert not self.inner.isSequence()
|
|
||||||
return False
|
|
||||||
|
|
||||||
def isArray(self):
|
|
||||||
return True
|
|
||||||
|
|
||||||
def isDictionary(self):
|
|
||||||
assert not self.inner.isDictionary()
|
|
||||||
return False
|
|
||||||
|
|
||||||
def isInterface(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def isEnum(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def tag(self):
|
|
||||||
return IDLType.Tags.array
|
|
||||||
|
|
||||||
def resolveType(self, parentScope):
|
|
||||||
assert isinstance(parentScope, IDLScope)
|
|
||||||
self.inner.resolveType(parentScope)
|
|
||||||
|
|
||||||
def isComplete(self):
|
|
||||||
return self.inner.isComplete()
|
|
||||||
|
|
||||||
def complete(self, scope):
|
|
||||||
self.inner = self.inner.complete(scope)
|
|
||||||
self.name = self.inner.name
|
|
||||||
|
|
||||||
if self.inner.isDictionary():
|
|
||||||
raise WebIDLError("Array type must not contain "
|
|
||||||
"dictionary as element type.",
|
|
||||||
[self.inner.location])
|
|
||||||
|
|
||||||
assert not self.inner.isSequence()
|
|
||||||
|
|
||||||
return self
|
|
||||||
|
|
||||||
def unroll(self):
|
|
||||||
return self.inner.unroll()
|
|
||||||
|
|
||||||
def isDistinguishableFrom(self, other):
|
|
||||||
if other.isPromise():
|
|
||||||
return False
|
|
||||||
if other.isUnion():
|
|
||||||
# Just forward to the union; it'll deal
|
|
||||||
return other.isDistinguishableFrom(self)
|
|
||||||
return (other.isPrimitive() or other.isString() or other.isEnum() or
|
|
||||||
other.isDate() or other.isNonCallbackInterface())
|
|
||||||
|
|
||||||
def _getDependentObjects(self):
|
|
||||||
return self.inner._getDependentObjects()
|
|
||||||
|
|
||||||
|
|
||||||
class IDLTypedefType(IDLType):
|
class IDLTypedefType(IDLType):
|
||||||
def __init__(self, location, innerType, name):
|
def __init__(self, location, innerType, name):
|
||||||
IDLType.__init__(self, location, name)
|
IDLType.__init__(self, location, name)
|
||||||
|
@ -2720,9 +2610,6 @@ class IDLTypedefType(IDLType):
|
||||||
def isMozMap(self):
|
def isMozMap(self):
|
||||||
return self.inner.isMozMap()
|
return self.inner.isMozMap()
|
||||||
|
|
||||||
def isArray(self):
|
|
||||||
return self.inner.isArray()
|
|
||||||
|
|
||||||
def isDictionary(self):
|
def isDictionary(self):
|
||||||
return self.inner.isDictionary()
|
return self.inner.isDictionary()
|
||||||
|
|
||||||
|
@ -2838,9 +2725,6 @@ class IDLWrapperType(IDLType):
|
||||||
def isSequence(self):
|
def isSequence(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def isArray(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def isDictionary(self):
|
def isDictionary(self):
|
||||||
return isinstance(self.inner, IDLDictionary)
|
return isinstance(self.inner, IDLDictionary)
|
||||||
|
|
||||||
|
@ -2907,8 +2791,7 @@ class IDLWrapperType(IDLType):
|
||||||
if self.isEnum():
|
if self.isEnum():
|
||||||
return (other.isPrimitive() or other.isInterface() or other.isObject() or
|
return (other.isPrimitive() or other.isInterface() or other.isObject() or
|
||||||
other.isCallback() or other.isDictionary() or
|
other.isCallback() or other.isDictionary() or
|
||||||
other.isSequence() or other.isMozMap() or other.isArray() or
|
other.isSequence() or other.isMozMap() or other.isDate())
|
||||||
other.isDate())
|
|
||||||
if self.isDictionary() and other.nullable():
|
if self.isDictionary() and other.nullable():
|
||||||
return False
|
return False
|
||||||
if (other.isPrimitive() or other.isString() or other.isEnum() or
|
if (other.isPrimitive() or other.isString() or other.isEnum() or
|
||||||
|
@ -2930,7 +2813,7 @@ class IDLWrapperType(IDLType):
|
||||||
(self.isNonCallbackInterface() or
|
(self.isNonCallbackInterface() or
|
||||||
other.isNonCallbackInterface()))
|
other.isNonCallbackInterface()))
|
||||||
if (other.isDictionary() or other.isCallback() or
|
if (other.isDictionary() or other.isCallback() or
|
||||||
other.isMozMap() or other.isArray()):
|
other.isMozMap()):
|
||||||
return self.isNonCallbackInterface()
|
return self.isNonCallbackInterface()
|
||||||
|
|
||||||
# Not much else |other| can be
|
# Not much else |other| can be
|
||||||
|
@ -3140,20 +3023,17 @@ class IDLBuiltinType(IDLType):
|
||||||
return (other.isNumeric() or other.isString() or other.isEnum() or
|
return (other.isNumeric() or other.isString() or other.isEnum() or
|
||||||
other.isInterface() or other.isObject() or
|
other.isInterface() or other.isObject() or
|
||||||
other.isCallback() or other.isDictionary() or
|
other.isCallback() or other.isDictionary() or
|
||||||
other.isSequence() or other.isMozMap() or other.isArray() or
|
other.isSequence() or other.isMozMap() or other.isDate())
|
||||||
other.isDate())
|
|
||||||
if self.isNumeric():
|
if self.isNumeric():
|
||||||
return (other.isBoolean() or other.isString() or other.isEnum() or
|
return (other.isBoolean() or other.isString() or other.isEnum() or
|
||||||
other.isInterface() or other.isObject() or
|
other.isInterface() or other.isObject() or
|
||||||
other.isCallback() or other.isDictionary() or
|
other.isCallback() or other.isDictionary() or
|
||||||
other.isSequence() or other.isMozMap() or other.isArray() or
|
other.isSequence() or other.isMozMap() or other.isDate())
|
||||||
other.isDate())
|
|
||||||
if self.isString():
|
if self.isString():
|
||||||
return (other.isPrimitive() or other.isInterface() or
|
return (other.isPrimitive() or other.isInterface() or
|
||||||
other.isObject() or
|
other.isObject() or
|
||||||
other.isCallback() or other.isDictionary() or
|
other.isCallback() or other.isDictionary() or
|
||||||
other.isSequence() or other.isMozMap() or other.isArray() or
|
other.isSequence() or other.isMozMap() or other.isDate())
|
||||||
other.isDate())
|
|
||||||
if self.isAny():
|
if self.isAny():
|
||||||
# Can't tell "any" apart from anything
|
# Can't tell "any" apart from anything
|
||||||
return False
|
return False
|
||||||
|
@ -3163,7 +3043,7 @@ class IDLBuiltinType(IDLType):
|
||||||
return (other.isPrimitive() or other.isString() or other.isEnum() or
|
return (other.isPrimitive() or other.isString() or other.isEnum() or
|
||||||
other.isInterface() or other.isCallback() or
|
other.isInterface() or other.isCallback() or
|
||||||
other.isDictionary() or other.isSequence() or
|
other.isDictionary() or other.isSequence() or
|
||||||
other.isMozMap() or other.isArray())
|
other.isMozMap())
|
||||||
if self.isVoid():
|
if self.isVoid():
|
||||||
return not other.isVoid()
|
return not other.isVoid()
|
||||||
# Not much else we could be!
|
# Not much else we could be!
|
||||||
|
@ -3171,8 +3051,7 @@ class IDLBuiltinType(IDLType):
|
||||||
# Like interfaces, but we know we're not a callback
|
# Like interfaces, but we know we're not a callback
|
||||||
return (other.isPrimitive() or other.isString() or other.isEnum() or
|
return (other.isPrimitive() or other.isString() or other.isEnum() or
|
||||||
other.isCallback() or other.isDictionary() or
|
other.isCallback() or other.isDictionary() or
|
||||||
other.isSequence() or other.isMozMap() or other.isArray() or
|
other.isSequence() or other.isMozMap() or other.isDate() or
|
||||||
other.isDate() or
|
|
||||||
(other.isInterface() and (
|
(other.isInterface() and (
|
||||||
# ArrayBuffer is distinguishable from everything
|
# ArrayBuffer is distinguishable from everything
|
||||||
# that's not an ArrayBuffer or a callback interface
|
# that's not an ArrayBuffer or a callback interface
|
||||||
|
@ -3311,6 +3190,11 @@ def matchIntegerValueToType(value):
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
class NoCoercionFoundError(WebIDLError):
|
||||||
|
"""
|
||||||
|
A class we use to indicate generic coercion failures because none of the
|
||||||
|
types worked out in IDLValue.coerceToType.
|
||||||
|
"""
|
||||||
|
|
||||||
class IDLValue(IDLObject):
|
class IDLValue(IDLObject):
|
||||||
def __init__(self, location, type, value):
|
def __init__(self, location, type, value):
|
||||||
|
@ -3338,8 +3222,18 @@ class IDLValue(IDLObject):
|
||||||
# use the value's type when it is a default value of a
|
# use the value's type when it is a default value of a
|
||||||
# union, and the union cares about the exact float type.
|
# union, and the union cares about the exact float type.
|
||||||
return IDLValue(self.location, subtype, coercedValue.value)
|
return IDLValue(self.location, subtype, coercedValue.value)
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
# Make sure to propagate out WebIDLErrors that are not the
|
||||||
|
# generic "hey, we could not coerce to this type at all"
|
||||||
|
# exception, because those are specific "coercion failed for
|
||||||
|
# reason X" exceptions. Note that we want to swallow
|
||||||
|
# non-WebIDLErrors here, because those can just happen if
|
||||||
|
# "type" is not something that can have a default value at
|
||||||
|
# all.
|
||||||
|
if (isinstance(e, WebIDLError) and
|
||||||
|
not isinstance(e, NoCoercionFoundError)):
|
||||||
|
raise e
|
||||||
|
|
||||||
# If the type allows null, rerun this matching on the inner type, except
|
# If the type allows null, rerun this matching on the inner type, except
|
||||||
# nullable enums. We handle those specially, because we want our
|
# nullable enums. We handle those specially, because we want our
|
||||||
# default string values to stay strings even when assigned to a nullable
|
# default string values to stay strings even when assigned to a nullable
|
||||||
|
@ -3388,12 +3282,21 @@ class IDLValue(IDLObject):
|
||||||
assert self.type.isDOMString()
|
assert self.type.isDOMString()
|
||||||
return self
|
return self
|
||||||
elif self.type.isString() and type.isByteString():
|
elif self.type.isString() and type.isByteString():
|
||||||
# Allow ByteStrings to use default value just like
|
# Allow ByteStrings to use a default value like DOMString.
|
||||||
# DOMString. No coercion is required here.
|
# No coercion is required as Codegen.py will handle the
|
||||||
assert self.type.isDOMString()
|
# extra steps. We want to make sure that our string contains
|
||||||
return self
|
# only valid characters, so we check that here.
|
||||||
raise WebIDLError("Cannot coerce type %s to type %s." %
|
valid_ascii_lit = " " + string.ascii_letters + string.digits + string.punctuation
|
||||||
(self.type, type), [location])
|
for idx, c in enumerate(self.value):
|
||||||
|
if c not in valid_ascii_lit:
|
||||||
|
raise WebIDLError("Coercing this string literal %s to a ByteString is not supported yet. "
|
||||||
|
"Coercion failed due to an unsupported byte %d at index %d."
|
||||||
|
% (self.value.__repr__(), ord(c), idx), [location])
|
||||||
|
|
||||||
|
return IDLValue(self.location, type, self.value)
|
||||||
|
|
||||||
|
raise NoCoercionFoundError("Cannot coerce type %s to type %s." %
|
||||||
|
(self.type, type), [location])
|
||||||
|
|
||||||
def _getDependentObjects(self):
|
def _getDependentObjects(self):
|
||||||
return set()
|
return set()
|
||||||
|
@ -4568,12 +4471,6 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
|
||||||
base=IDLInterfaceMember.Special
|
base=IDLInterfaceMember.Special
|
||||||
)
|
)
|
||||||
|
|
||||||
TypeSuffixModifier = enum(
|
|
||||||
'None',
|
|
||||||
'QMark',
|
|
||||||
'Brackets'
|
|
||||||
)
|
|
||||||
|
|
||||||
NamedOrIndexed = enum(
|
NamedOrIndexed = enum(
|
||||||
'Neither',
|
'Neither',
|
||||||
'Named',
|
'Named',
|
||||||
|
@ -5743,14 +5640,6 @@ class Parser(Tokenizer):
|
||||||
booleanType = BuiltinTypes[IDLBuiltinType.Types.boolean]
|
booleanType = BuiltinTypes[IDLBuiltinType.Types.boolean]
|
||||||
p[0] = IDLValue(location, booleanType, p[1])
|
p[0] = IDLValue(location, booleanType, p[1])
|
||||||
|
|
||||||
def p_ConstValueByteString(self, p):
|
|
||||||
"""
|
|
||||||
ConstValue : BYTESTRING
|
|
||||||
"""
|
|
||||||
location = self.getLocation(p, 1)
|
|
||||||
bytestringType = BuiltinTypes[IDLBuiltinType.Types.bytestring]
|
|
||||||
p[0] = IDLValue(location, bytestringType, p[1])
|
|
||||||
|
|
||||||
def p_ConstValueInteger(self, p):
|
def p_ConstValueInteger(self, p):
|
||||||
"""
|
"""
|
||||||
ConstValue : INTEGER
|
ConstValue : INTEGER
|
||||||
|
@ -6383,9 +6272,9 @@ class Parser(Tokenizer):
|
||||||
|
|
||||||
def p_TypeUnionType(self, p):
|
def p_TypeUnionType(self, p):
|
||||||
"""
|
"""
|
||||||
Type : UnionType TypeSuffix
|
Type : UnionType Null
|
||||||
"""
|
"""
|
||||||
p[0] = self.handleModifiers(p[1], p[2])
|
p[0] = self.handleNullable(p[1], p[2])
|
||||||
|
|
||||||
def p_SingleTypeNonAnyType(self, p):
|
def p_SingleTypeNonAnyType(self, p):
|
||||||
"""
|
"""
|
||||||
|
@ -6395,9 +6284,9 @@ class Parser(Tokenizer):
|
||||||
|
|
||||||
def p_SingleTypeAnyType(self, p):
|
def p_SingleTypeAnyType(self, p):
|
||||||
"""
|
"""
|
||||||
SingleType : ANY TypeSuffixStartingWithArray
|
SingleType : ANY
|
||||||
"""
|
"""
|
||||||
p[0] = self.handleModifiers(BuiltinTypes[IDLBuiltinType.Types.any], p[2])
|
p[0] = BuiltinTypes[IDLBuiltinType.Types.any]
|
||||||
|
|
||||||
def p_UnionType(self, p):
|
def p_UnionType(self, p):
|
||||||
"""
|
"""
|
||||||
|
@ -6413,19 +6302,11 @@ class Parser(Tokenizer):
|
||||||
"""
|
"""
|
||||||
p[0] = p[1]
|
p[0] = p[1]
|
||||||
|
|
||||||
def p_UnionMemberTypeArrayOfAny(self, p):
|
|
||||||
"""
|
|
||||||
UnionMemberTypeArrayOfAny : ANY LBRACKET RBRACKET
|
|
||||||
"""
|
|
||||||
p[0] = IDLArrayType(self.getLocation(p, 2),
|
|
||||||
BuiltinTypes[IDLBuiltinType.Types.any])
|
|
||||||
|
|
||||||
def p_UnionMemberType(self, p):
|
def p_UnionMemberType(self, p):
|
||||||
"""
|
"""
|
||||||
UnionMemberType : UnionType TypeSuffix
|
UnionMemberType : UnionType Null
|
||||||
| UnionMemberTypeArrayOfAny TypeSuffix
|
|
||||||
"""
|
"""
|
||||||
p[0] = self.handleModifiers(p[1], p[2])
|
p[0] = self.handleNullable(p[1], p[2])
|
||||||
|
|
||||||
def p_UnionMemberTypes(self, p):
|
def p_UnionMemberTypes(self, p):
|
||||||
"""
|
"""
|
||||||
|
@ -6442,10 +6323,10 @@ class Parser(Tokenizer):
|
||||||
|
|
||||||
def p_NonAnyType(self, p):
|
def p_NonAnyType(self, p):
|
||||||
"""
|
"""
|
||||||
NonAnyType : PrimitiveOrStringType TypeSuffix
|
NonAnyType : PrimitiveOrStringType Null
|
||||||
| ARRAYBUFFER TypeSuffix
|
| ARRAYBUFFER Null
|
||||||
| SHAREDARRAYBUFFER TypeSuffix
|
| SHAREDARRAYBUFFER Null
|
||||||
| OBJECT TypeSuffix
|
| OBJECT Null
|
||||||
"""
|
"""
|
||||||
if p[1] == "object":
|
if p[1] == "object":
|
||||||
type = BuiltinTypes[IDLBuiltinType.Types.object]
|
type = BuiltinTypes[IDLBuiltinType.Types.object]
|
||||||
|
@ -6456,7 +6337,7 @@ class Parser(Tokenizer):
|
||||||
else:
|
else:
|
||||||
type = BuiltinTypes[p[1]]
|
type = BuiltinTypes[p[1]]
|
||||||
|
|
||||||
p[0] = self.handleModifiers(type, p[2])
|
p[0] = self.handleNullable(type, p[2])
|
||||||
|
|
||||||
def p_NonAnyTypeSequenceType(self, p):
|
def p_NonAnyTypeSequenceType(self, p):
|
||||||
"""
|
"""
|
||||||
|
@ -6464,9 +6345,7 @@ class Parser(Tokenizer):
|
||||||
"""
|
"""
|
||||||
innerType = p[3]
|
innerType = p[3]
|
||||||
type = IDLSequenceType(self.getLocation(p, 1), innerType)
|
type = IDLSequenceType(self.getLocation(p, 1), innerType)
|
||||||
if p[5]:
|
p[0] = self.handleNullable(type, p[5])
|
||||||
type = IDLNullableType(self.getLocation(p, 5), type)
|
|
||||||
p[0] = type
|
|
||||||
|
|
||||||
# Note: Promise<void> is allowed, so we want to parametrize on
|
# Note: Promise<void> is allowed, so we want to parametrize on
|
||||||
# ReturnType, not Type. Also, we want this to end up picking up
|
# ReturnType, not Type. Also, we want this to end up picking up
|
||||||
|
@ -6478,9 +6357,7 @@ class Parser(Tokenizer):
|
||||||
innerType = p[3]
|
innerType = p[3]
|
||||||
promiseIdent = IDLUnresolvedIdentifier(self.getLocation(p, 1), "Promise")
|
promiseIdent = IDLUnresolvedIdentifier(self.getLocation(p, 1), "Promise")
|
||||||
type = IDLUnresolvedType(self.getLocation(p, 1), promiseIdent, p[3])
|
type = IDLUnresolvedType(self.getLocation(p, 1), promiseIdent, p[3])
|
||||||
if p[5]:
|
p[0] = self.handleNullable(type, p[5])
|
||||||
type = IDLNullableType(self.getLocation(p, 5), type)
|
|
||||||
p[0] = type
|
|
||||||
|
|
||||||
def p_NonAnyTypeMozMapType(self, p):
|
def p_NonAnyTypeMozMapType(self, p):
|
||||||
"""
|
"""
|
||||||
|
@ -6488,13 +6365,11 @@ class Parser(Tokenizer):
|
||||||
"""
|
"""
|
||||||
innerType = p[3]
|
innerType = p[3]
|
||||||
type = IDLMozMapType(self.getLocation(p, 1), innerType)
|
type = IDLMozMapType(self.getLocation(p, 1), innerType)
|
||||||
if p[5]:
|
p[0] = self.handleNullable(type, p[5])
|
||||||
type = IDLNullableType(self.getLocation(p, 5), type)
|
|
||||||
p[0] = type
|
|
||||||
|
|
||||||
def p_NonAnyTypeScopedName(self, p):
|
def p_NonAnyTypeScopedName(self, p):
|
||||||
"""
|
"""
|
||||||
NonAnyType : ScopedName TypeSuffix
|
NonAnyType : ScopedName Null
|
||||||
"""
|
"""
|
||||||
assert isinstance(p[1], IDLUnresolvedIdentifier)
|
assert isinstance(p[1], IDLUnresolvedIdentifier)
|
||||||
|
|
||||||
|
@ -6516,29 +6391,27 @@ class Parser(Tokenizer):
|
||||||
type = IDLCallbackType(obj.location, obj)
|
type = IDLCallbackType(obj.location, obj)
|
||||||
else:
|
else:
|
||||||
type = IDLWrapperType(self.getLocation(p, 1), p[1])
|
type = IDLWrapperType(self.getLocation(p, 1), p[1])
|
||||||
p[0] = self.handleModifiers(type, p[2])
|
p[0] = self.handleNullable(type, p[2])
|
||||||
return
|
return
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
type = IDLUnresolvedType(self.getLocation(p, 1), p[1])
|
type = IDLUnresolvedType(self.getLocation(p, 1), p[1])
|
||||||
p[0] = self.handleModifiers(type, p[2])
|
p[0] = self.handleNullable(type, p[2])
|
||||||
|
|
||||||
def p_NonAnyTypeDate(self, p):
|
def p_NonAnyTypeDate(self, p):
|
||||||
"""
|
"""
|
||||||
NonAnyType : DATE TypeSuffix
|
NonAnyType : DATE Null
|
||||||
"""
|
"""
|
||||||
p[0] = self.handleModifiers(BuiltinTypes[IDLBuiltinType.Types.date],
|
p[0] = self.handleNullable(BuiltinTypes[IDLBuiltinType.Types.date],
|
||||||
p[2])
|
p[2])
|
||||||
|
|
||||||
def p_ConstType(self, p):
|
def p_ConstType(self, p):
|
||||||
"""
|
"""
|
||||||
ConstType : PrimitiveOrStringType Null
|
ConstType : PrimitiveOrStringType Null
|
||||||
"""
|
"""
|
||||||
type = BuiltinTypes[p[1]]
|
type = BuiltinTypes[p[1]]
|
||||||
if p[2]:
|
p[0] = self.handleNullable(type, p[2])
|
||||||
type = IDLNullableType(self.getLocation(p, 1), type)
|
|
||||||
p[0] = type
|
|
||||||
|
|
||||||
def p_ConstTypeIdentifier(self, p):
|
def p_ConstTypeIdentifier(self, p):
|
||||||
"""
|
"""
|
||||||
|
@ -6547,9 +6420,7 @@ class Parser(Tokenizer):
|
||||||
identifier = IDLUnresolvedIdentifier(self.getLocation(p, 1), p[1])
|
identifier = IDLUnresolvedIdentifier(self.getLocation(p, 1), p[1])
|
||||||
|
|
||||||
type = IDLUnresolvedType(self.getLocation(p, 1), identifier)
|
type = IDLUnresolvedType(self.getLocation(p, 1), identifier)
|
||||||
if p[2]:
|
p[0] = self.handleNullable(type, p[2])
|
||||||
type = IDLNullableType(self.getLocation(p, 1), type)
|
|
||||||
p[0] = type
|
|
||||||
|
|
||||||
def p_PrimitiveOrStringTypeUint(self, p):
|
def p_PrimitiveOrStringTypeUint(self, p):
|
||||||
"""
|
"""
|
||||||
|
@ -6657,48 +6528,15 @@ class Parser(Tokenizer):
|
||||||
"""
|
"""
|
||||||
p[0] = False
|
p[0] = False
|
||||||
|
|
||||||
def p_TypeSuffixBrackets(self, p):
|
|
||||||
"""
|
|
||||||
TypeSuffix : LBRACKET RBRACKET TypeSuffix
|
|
||||||
"""
|
|
||||||
p[0] = [(IDLMethod.TypeSuffixModifier.Brackets, self.getLocation(p, 1))]
|
|
||||||
p[0].extend(p[3])
|
|
||||||
|
|
||||||
def p_TypeSuffixQMark(self, p):
|
|
||||||
"""
|
|
||||||
TypeSuffix : QUESTIONMARK TypeSuffixStartingWithArray
|
|
||||||
"""
|
|
||||||
p[0] = [(IDLMethod.TypeSuffixModifier.QMark, self.getLocation(p, 1))]
|
|
||||||
p[0].extend(p[2])
|
|
||||||
|
|
||||||
def p_TypeSuffixEmpty(self, p):
|
|
||||||
"""
|
|
||||||
TypeSuffix :
|
|
||||||
"""
|
|
||||||
p[0] = []
|
|
||||||
|
|
||||||
def p_TypeSuffixStartingWithArray(self, p):
|
|
||||||
"""
|
|
||||||
TypeSuffixStartingWithArray : LBRACKET RBRACKET TypeSuffix
|
|
||||||
"""
|
|
||||||
p[0] = [(IDLMethod.TypeSuffixModifier.Brackets, self.getLocation(p, 1))]
|
|
||||||
p[0].extend(p[3])
|
|
||||||
|
|
||||||
def p_TypeSuffixStartingWithArrayEmpty(self, p):
|
|
||||||
"""
|
|
||||||
TypeSuffixStartingWithArray :
|
|
||||||
"""
|
|
||||||
p[0] = []
|
|
||||||
|
|
||||||
def p_Null(self, p):
|
def p_Null(self, p):
|
||||||
"""
|
"""
|
||||||
Null : QUESTIONMARK
|
Null : QUESTIONMARK
|
||||||
|
|
|
|
||||||
"""
|
"""
|
||||||
if len(p) > 1:
|
if len(p) > 1:
|
||||||
p[0] = True
|
p[0] = self.getLocation(p, 1)
|
||||||
else:
|
else:
|
||||||
p[0] = False
|
p[0] = None
|
||||||
|
|
||||||
def p_ReturnTypeType(self, p):
|
def p_ReturnTypeType(self, p):
|
||||||
"""
|
"""
|
||||||
|
@ -6857,15 +6695,9 @@ class Parser(Tokenizer):
|
||||||
typedef = IDLTypedef(BuiltinLocation("<builtin type>"), scope, builtin, name)
|
typedef = IDLTypedef(BuiltinLocation("<builtin type>"), scope, builtin, name)
|
||||||
|
|
||||||
@ staticmethod
|
@ staticmethod
|
||||||
def handleModifiers(type, modifiers):
|
def handleNullable(type, questionMarkLocation):
|
||||||
for (modifier, modifierLocation) in modifiers:
|
if questionMarkLocation is not None:
|
||||||
assert (modifier == IDLMethod.TypeSuffixModifier.QMark or
|
type = IDLNullableType(questionMarkLocation, type)
|
||||||
modifier == IDLMethod.TypeSuffixModifier.Brackets)
|
|
||||||
|
|
||||||
if modifier == IDLMethod.TypeSuffixModifier.QMark:
|
|
||||||
type = IDLNullableType(modifierLocation, type)
|
|
||||||
elif modifier == IDLMethod.TypeSuffixModifier.Brackets:
|
|
||||||
type = IDLArrayType(modifierLocation, type)
|
|
||||||
|
|
||||||
return type
|
return type
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
--- WebIDL.py
|
|
||||||
+++ WebIDL.py
|
|
||||||
@@ -3391,6 +3391,11 @@ class IDLValue(IDLObject):
|
|
||||||
# extra normalization step.
|
|
||||||
assert self.type.isDOMString()
|
|
||||||
return self
|
|
||||||
+ elif self.type.isString() and type.isByteString():
|
|
||||||
+ # Allow ByteStrings to use default value just like
|
|
||||||
+ # DOMString. No coercion is required here.
|
|
||||||
+ assert self.type.isDOMString()
|
|
||||||
+ return self
|
|
||||||
raise WebIDLError("Cannot coerce type %s to type %s." %
|
|
||||||
(self.type, type), [location])
|
|
||||||
|
|
||||||
@@ -5759,6 +5764,14 @@ class Parser(Tokenizer):
|
|
||||||
booleanType = BuiltinTypes[IDLBuiltinType.Types.boolean]
|
|
||||||
p[0] = IDLValue(location, booleanType, p[1])
|
|
||||||
|
|
||||||
+ def p_ConstValueByteString(self, p):
|
|
||||||
+ """
|
|
||||||
+ ConstValue : BYTESTRING
|
|
||||||
+ """
|
|
||||||
+ location = self.getLocation(p, 1)
|
|
||||||
+ bytestringType = BuiltinTypes[IDLBuiltinType.Types.bytestring]
|
|
||||||
+ p[0] = IDLValue(location, bytestringType, p[1])
|
|
||||||
+
|
|
||||||
def p_ConstValueInteger(self, p):
|
|
||||||
"""
|
|
||||||
ConstValue : INTEGER
|
|
|
@ -1,18 +0,0 @@
|
||||||
def WebIDLTest(parser, harness):
|
|
||||||
threw = False
|
|
||||||
try:
|
|
||||||
parser.parse("""
|
|
||||||
dictionary Foo {
|
|
||||||
short a;
|
|
||||||
};
|
|
||||||
|
|
||||||
dictionary Foo1 {
|
|
||||||
Foo[] b;
|
|
||||||
};
|
|
||||||
""")
|
|
||||||
results = parser.finish()
|
|
||||||
except:
|
|
||||||
threw = True
|
|
||||||
|
|
||||||
harness.ok(threw, "Array must not contain dictionary "
|
|
||||||
"as element type.")
|
|
|
@ -1,13 +0,0 @@
|
||||||
import WebIDL
|
|
||||||
|
|
||||||
def WebIDLTest(parser, harness):
|
|
||||||
parser.parse("""
|
|
||||||
interface A {
|
|
||||||
attribute long a;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface B {
|
|
||||||
attribute A[] b;
|
|
||||||
};
|
|
||||||
""");
|
|
||||||
parser.finish()
|
|
|
@ -4,37 +4,37 @@ def WebIDLTest(parser, harness):
|
||||||
parser.parse("""
|
parser.parse("""
|
||||||
interface TestArrayBuffer {
|
interface TestArrayBuffer {
|
||||||
attribute ArrayBuffer bufferAttr;
|
attribute ArrayBuffer bufferAttr;
|
||||||
void bufferMethod(ArrayBuffer arg1, ArrayBuffer? arg2, ArrayBuffer[] arg3, sequence<ArrayBuffer> arg4);
|
void bufferMethod(ArrayBuffer arg1, ArrayBuffer? arg2, sequence<ArrayBuffer> arg3);
|
||||||
|
|
||||||
attribute ArrayBufferView viewAttr;
|
attribute ArrayBufferView viewAttr;
|
||||||
void viewMethod(ArrayBufferView arg1, ArrayBufferView? arg2, ArrayBufferView[] arg3, sequence<ArrayBufferView> arg4);
|
void viewMethod(ArrayBufferView arg1, ArrayBufferView? arg2, sequence<ArrayBufferView> arg3);
|
||||||
|
|
||||||
attribute Int8Array int8ArrayAttr;
|
attribute Int8Array int8ArrayAttr;
|
||||||
void int8ArrayMethod(Int8Array arg1, Int8Array? arg2, Int8Array[] arg3, sequence<Int8Array> arg4);
|
void int8ArrayMethod(Int8Array arg1, Int8Array? arg2, sequence<Int8Array> arg3);
|
||||||
|
|
||||||
attribute Uint8Array uint8ArrayAttr;
|
attribute Uint8Array uint8ArrayAttr;
|
||||||
void uint8ArrayMethod(Uint8Array arg1, Uint8Array? arg2, Uint8Array[] arg3, sequence<Uint8Array> arg4);
|
void uint8ArrayMethod(Uint8Array arg1, Uint8Array? arg2, sequence<Uint8Array> arg3);
|
||||||
|
|
||||||
attribute Uint8ClampedArray uint8ClampedArrayAttr;
|
attribute Uint8ClampedArray uint8ClampedArrayAttr;
|
||||||
void uint8ClampedArrayMethod(Uint8ClampedArray arg1, Uint8ClampedArray? arg2, Uint8ClampedArray[] arg3, sequence<Uint8ClampedArray> arg4);
|
void uint8ClampedArrayMethod(Uint8ClampedArray arg1, Uint8ClampedArray? arg2, sequence<Uint8ClampedArray> arg3);
|
||||||
|
|
||||||
attribute Int16Array int16ArrayAttr;
|
attribute Int16Array int16ArrayAttr;
|
||||||
void int16ArrayMethod(Int16Array arg1, Int16Array? arg2, Int16Array[] arg3, sequence<Int16Array> arg4);
|
void int16ArrayMethod(Int16Array arg1, Int16Array? arg2, sequence<Int16Array> arg3);
|
||||||
|
|
||||||
attribute Uint16Array uint16ArrayAttr;
|
attribute Uint16Array uint16ArrayAttr;
|
||||||
void uint16ArrayMethod(Uint16Array arg1, Uint16Array? arg2, Uint16Array[] arg3, sequence<Uint16Array> arg4);
|
void uint16ArrayMethod(Uint16Array arg1, Uint16Array? arg2, sequence<Uint16Array> arg3);
|
||||||
|
|
||||||
attribute Int32Array int32ArrayAttr;
|
attribute Int32Array int32ArrayAttr;
|
||||||
void int32ArrayMethod(Int32Array arg1, Int32Array? arg2, Int32Array[] arg3, sequence<Int32Array> arg4);
|
void int32ArrayMethod(Int32Array arg1, Int32Array? arg2, sequence<Int32Array> arg3);
|
||||||
|
|
||||||
attribute Uint32Array uint32ArrayAttr;
|
attribute Uint32Array uint32ArrayAttr;
|
||||||
void uint32ArrayMethod(Uint32Array arg1, Uint32Array? arg2, Uint32Array[] arg3, sequence<Uint32Array> arg4);
|
void uint32ArrayMethod(Uint32Array arg1, Uint32Array? arg2, sequence<Uint32Array> arg3);
|
||||||
|
|
||||||
attribute Float32Array float32ArrayAttr;
|
attribute Float32Array float32ArrayAttr;
|
||||||
void float32ArrayMethod(Float32Array arg1, Float32Array? arg2, Float32Array[] arg3, sequence<Float32Array> arg4);
|
void float32ArrayMethod(Float32Array arg1, Float32Array? arg2, sequence<Float32Array> arg3);
|
||||||
|
|
||||||
attribute Float64Array float64ArrayAttr;
|
attribute Float64Array float64ArrayAttr;
|
||||||
void float64ArrayMethod(Float64Array arg1, Float64Array? arg2, Float64Array[] arg3, sequence<Float64Array> arg4);
|
void float64ArrayMethod(Float64Array arg1, Float64Array? arg2, sequence<Float64Array> arg3);
|
||||||
};
|
};
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ def WebIDLTest(parser, harness):
|
||||||
|
|
||||||
(retType, arguments) = method.signatures()[0]
|
(retType, arguments) = method.signatures()[0]
|
||||||
harness.ok(retType.isVoid(), "Should have a void return type")
|
harness.ok(retType.isVoid(), "Should have a void return type")
|
||||||
harness.check(len(arguments), 4, "Expect 4 arguments")
|
harness.check(len(arguments), 3, "Expect 3 arguments")
|
||||||
|
|
||||||
harness.check(str(arguments[0].type), t, "Expect an ArrayBuffer type")
|
harness.check(str(arguments[0].type), t, "Expect an ArrayBuffer type")
|
||||||
harness.ok(arguments[0].type.isSpiderMonkeyInterface(), "Should test as a js interface")
|
harness.ok(arguments[0].type.isSpiderMonkeyInterface(), "Should test as a js interface")
|
||||||
|
@ -64,12 +64,9 @@ def WebIDLTest(parser, harness):
|
||||||
harness.check(str(arguments[1].type), t + "OrNull", "Expect an ArrayBuffer type")
|
harness.check(str(arguments[1].type), t + "OrNull", "Expect an ArrayBuffer type")
|
||||||
harness.ok(arguments[1].type.inner.isSpiderMonkeyInterface(), "Should test as a js interface")
|
harness.ok(arguments[1].type.inner.isSpiderMonkeyInterface(), "Should test as a js interface")
|
||||||
|
|
||||||
harness.check(str(arguments[2].type), t + "Array", "Expect an ArrayBuffer type")
|
harness.check(str(arguments[2].type), t + "Sequence", "Expect an ArrayBuffer type")
|
||||||
harness.ok(arguments[2].type.inner.isSpiderMonkeyInterface(), "Should test as a js interface")
|
harness.ok(arguments[2].type.inner.isSpiderMonkeyInterface(), "Should test as a js interface")
|
||||||
|
|
||||||
harness.check(str(arguments[3].type), t + "Sequence", "Expect an ArrayBuffer type")
|
|
||||||
harness.ok(arguments[3].type.inner.isSpiderMonkeyInterface(), "Should test as a js interface")
|
|
||||||
|
|
||||||
|
|
||||||
checkStuff(members[0], members[1], "ArrayBuffer")
|
checkStuff(members[0], members[1], "ArrayBuffer")
|
||||||
checkStuff(members[2], members[3], "ArrayBufferView")
|
checkStuff(members[2], members[3], "ArrayBufferView")
|
||||||
|
|
|
@ -77,110 +77,6 @@ def WebIDLTest(parser, harness):
|
||||||
attribute float? f;
|
attribute float? f;
|
||||||
readonly attribute float? rf;
|
readonly attribute float? rf;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface TestAttrArray {
|
|
||||||
attribute byte[] b;
|
|
||||||
readonly attribute byte[] rb;
|
|
||||||
attribute octet[] o;
|
|
||||||
readonly attribute octet[] ro;
|
|
||||||
attribute short[] s;
|
|
||||||
readonly attribute short[] rs;
|
|
||||||
attribute unsigned short[] us;
|
|
||||||
readonly attribute unsigned short[] rus;
|
|
||||||
attribute long[] l;
|
|
||||||
readonly attribute long[] rl;
|
|
||||||
attribute unsigned long[] ul;
|
|
||||||
readonly attribute unsigned long[] rul;
|
|
||||||
attribute long long[] ll;
|
|
||||||
readonly attribute long long[] rll;
|
|
||||||
attribute unsigned long long[] ull;
|
|
||||||
readonly attribute unsigned long long[] rull;
|
|
||||||
attribute DOMString[] str;
|
|
||||||
readonly attribute DOMString[] rstr;
|
|
||||||
attribute object[] obj;
|
|
||||||
readonly attribute object[] robj;
|
|
||||||
attribute object[] _object;
|
|
||||||
attribute float[] f;
|
|
||||||
readonly attribute float[] rf;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface TestAttrNullableArray {
|
|
||||||
attribute byte[]? b;
|
|
||||||
readonly attribute byte[]? rb;
|
|
||||||
attribute octet[]? o;
|
|
||||||
readonly attribute octet[]? ro;
|
|
||||||
attribute short[]? s;
|
|
||||||
readonly attribute short[]? rs;
|
|
||||||
attribute unsigned short[]? us;
|
|
||||||
readonly attribute unsigned short[]? rus;
|
|
||||||
attribute long[]? l;
|
|
||||||
readonly attribute long[]? rl;
|
|
||||||
attribute unsigned long[]? ul;
|
|
||||||
readonly attribute unsigned long[]? rul;
|
|
||||||
attribute long long[]? ll;
|
|
||||||
readonly attribute long long[]? rll;
|
|
||||||
attribute unsigned long long[]? ull;
|
|
||||||
readonly attribute unsigned long long[]? rull;
|
|
||||||
attribute DOMString[]? str;
|
|
||||||
readonly attribute DOMString[]? rstr;
|
|
||||||
attribute object[]? obj;
|
|
||||||
readonly attribute object[]? robj;
|
|
||||||
attribute object[]? _object;
|
|
||||||
attribute float[]? f;
|
|
||||||
readonly attribute float[]? rf;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface TestAttrArrayOfNullableTypes {
|
|
||||||
attribute byte?[] b;
|
|
||||||
readonly attribute byte?[] rb;
|
|
||||||
attribute octet?[] o;
|
|
||||||
readonly attribute octet?[] ro;
|
|
||||||
attribute short?[] s;
|
|
||||||
readonly attribute short?[] rs;
|
|
||||||
attribute unsigned short?[] us;
|
|
||||||
readonly attribute unsigned short?[] rus;
|
|
||||||
attribute long?[] l;
|
|
||||||
readonly attribute long?[] rl;
|
|
||||||
attribute unsigned long?[] ul;
|
|
||||||
readonly attribute unsigned long?[] rul;
|
|
||||||
attribute long long?[] ll;
|
|
||||||
readonly attribute long long?[] rll;
|
|
||||||
attribute unsigned long long?[] ull;
|
|
||||||
readonly attribute unsigned long long?[] rull;
|
|
||||||
attribute DOMString?[] str;
|
|
||||||
readonly attribute DOMString?[] rstr;
|
|
||||||
attribute object?[] obj;
|
|
||||||
readonly attribute object?[] robj;
|
|
||||||
attribute object?[] _object;
|
|
||||||
attribute float?[] f;
|
|
||||||
readonly attribute float?[] rf;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface TestAttrNullableArrayOfNullableTypes {
|
|
||||||
attribute byte?[]? b;
|
|
||||||
readonly attribute byte?[]? rb;
|
|
||||||
attribute octet?[]? o;
|
|
||||||
readonly attribute octet?[]? ro;
|
|
||||||
attribute short?[]? s;
|
|
||||||
readonly attribute short?[]? rs;
|
|
||||||
attribute unsigned short?[]? us;
|
|
||||||
readonly attribute unsigned short?[]? rus;
|
|
||||||
attribute long?[]? l;
|
|
||||||
readonly attribute long?[]? rl;
|
|
||||||
attribute unsigned long?[]? ul;
|
|
||||||
readonly attribute unsigned long?[]? rul;
|
|
||||||
attribute long long?[]? ll;
|
|
||||||
readonly attribute long long?[]? rll;
|
|
||||||
attribute unsigned long long?[]? ull;
|
|
||||||
readonly attribute unsigned long long?[]? rull;
|
|
||||||
attribute DOMString?[]? str;
|
|
||||||
readonly attribute DOMString?[]? rstr;
|
|
||||||
attribute object?[]? obj;
|
|
||||||
readonly attribute object?[]? robj;
|
|
||||||
attribute object?[]? _object;
|
|
||||||
attribute float?[]? f;
|
|
||||||
readonly attribute float?[]? rf;
|
|
||||||
};
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
results = parser.finish()
|
results = parser.finish()
|
||||||
|
@ -197,7 +93,7 @@ def WebIDLTest(parser, harness):
|
||||||
harness.check(attr.readonly, readonly, "Attr's readonly state is correct")
|
harness.check(attr.readonly, readonly, "Attr's readonly state is correct")
|
||||||
|
|
||||||
harness.ok(True, "TestAttr interface parsed without error.")
|
harness.ok(True, "TestAttr interface parsed without error.")
|
||||||
harness.check(len(results), 6, "Should be six productions.")
|
harness.check(len(results), 2, "Should be two productions.")
|
||||||
iface = results[0]
|
iface = results[0]
|
||||||
harness.ok(isinstance(iface, WebIDL.IDLInterface),
|
harness.ok(isinstance(iface, WebIDL.IDLInterface),
|
||||||
"Should be an IDLInterface")
|
"Should be an IDLInterface")
|
||||||
|
@ -228,66 +124,6 @@ def WebIDLTest(parser, harness):
|
||||||
(QName, name, type, readonly) = data
|
(QName, name, type, readonly) = data
|
||||||
checkAttr(attr, QName % "Nullable", name, type % "OrNull", readonly)
|
checkAttr(attr, QName % "Nullable", name, type % "OrNull", readonly)
|
||||||
|
|
||||||
iface = results[2]
|
|
||||||
harness.ok(isinstance(iface, WebIDL.IDLInterface),
|
|
||||||
"Should be an IDLInterface")
|
|
||||||
harness.check(iface.identifier.QName(), "::TestAttrArray", "Interface has the right QName")
|
|
||||||
harness.check(iface.identifier.name, "TestAttrArray", "Interface has the right name")
|
|
||||||
harness.check(len(iface.members), len(testData), "Expect %s members" % len(testData))
|
|
||||||
|
|
||||||
attrs = iface.members
|
|
||||||
|
|
||||||
for i in range(len(attrs)):
|
|
||||||
data = testData[i]
|
|
||||||
attr = attrs[i]
|
|
||||||
(QName, name, type, readonly) = data
|
|
||||||
checkAttr(attr, QName % "Array", name, type % "Array", readonly)
|
|
||||||
|
|
||||||
iface = results[3]
|
|
||||||
harness.ok(isinstance(iface, WebIDL.IDLInterface),
|
|
||||||
"Should be an IDLInterface")
|
|
||||||
harness.check(iface.identifier.QName(), "::TestAttrNullableArray", "Interface has the right QName")
|
|
||||||
harness.check(iface.identifier.name, "TestAttrNullableArray", "Interface has the right name")
|
|
||||||
harness.check(len(iface.members), len(testData), "Expect %s members" % len(testData))
|
|
||||||
|
|
||||||
attrs = iface.members
|
|
||||||
|
|
||||||
for i in range(len(attrs)):
|
|
||||||
data = testData[i]
|
|
||||||
attr = attrs[i]
|
|
||||||
(QName, name, type, readonly) = data
|
|
||||||
checkAttr(attr, QName % "NullableArray", name, type % "ArrayOrNull", readonly)
|
|
||||||
|
|
||||||
iface = results[4]
|
|
||||||
harness.ok(isinstance(iface, WebIDL.IDLInterface),
|
|
||||||
"Should be an IDLInterface")
|
|
||||||
harness.check(iface.identifier.QName(), "::TestAttrArrayOfNullableTypes", "Interface has the right QName")
|
|
||||||
harness.check(iface.identifier.name, "TestAttrArrayOfNullableTypes", "Interface has the right name")
|
|
||||||
harness.check(len(iface.members), len(testData), "Expect %s members" % len(testData))
|
|
||||||
|
|
||||||
attrs = iface.members
|
|
||||||
|
|
||||||
for i in range(len(attrs)):
|
|
||||||
data = testData[i]
|
|
||||||
attr = attrs[i]
|
|
||||||
(QName, name, type, readonly) = data
|
|
||||||
checkAttr(attr, QName % "ArrayOfNullableTypes", name, type % "OrNullArray", readonly)
|
|
||||||
|
|
||||||
iface = results[5]
|
|
||||||
harness.ok(isinstance(iface, WebIDL.IDLInterface),
|
|
||||||
"Should be an IDLInterface")
|
|
||||||
harness.check(iface.identifier.QName(), "::TestAttrNullableArrayOfNullableTypes", "Interface has the right QName")
|
|
||||||
harness.check(iface.identifier.name, "TestAttrNullableArrayOfNullableTypes", "Interface has the right name")
|
|
||||||
harness.check(len(iface.members), len(testData), "Expect %s members" % len(testData))
|
|
||||||
|
|
||||||
attrs = iface.members
|
|
||||||
|
|
||||||
for i in range(len(attrs)):
|
|
||||||
data = testData[i]
|
|
||||||
attr = attrs[i]
|
|
||||||
(QName, name, type, readonly) = data
|
|
||||||
checkAttr(attr, QName % "NullableArrayOfNullableTypes", name, type % "OrNullArrayOrNull", readonly)
|
|
||||||
|
|
||||||
parser = parser.reset()
|
parser = parser.reset()
|
||||||
threw = False
|
threw = False
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -13,7 +13,7 @@ def WebIDLTest(parser, harness):
|
||||||
results = parser.finish();
|
results = parser.finish();
|
||||||
|
|
||||||
harness.ok(True, "TestByteString interface parsed without error.")
|
harness.ok(True, "TestByteString interface parsed without error.")
|
||||||
|
|
||||||
harness.check(len(results), 1, "Should be one production")
|
harness.check(len(results), 1, "Should be one production")
|
||||||
harness.ok(isinstance(results[0], WebIDL.IDLInterface),
|
harness.ok(isinstance(results[0], WebIDL.IDLInterface),
|
||||||
"Should be an IDLInterface")
|
"Should be an IDLInterface")
|
||||||
|
@ -54,10 +54,9 @@ def WebIDLTest(parser, harness):
|
||||||
""")
|
""")
|
||||||
except WebIDL.WebIDLError:
|
except WebIDL.WebIDLError:
|
||||||
threw = True
|
threw = True
|
||||||
harness.ok(threw, "Should have thrown a WebIDL error")
|
harness.ok(threw, "Should have thrown a WebIDL error for ByteString default in interface")
|
||||||
|
|
||||||
# Cannot have optional ByteStrings with default values
|
# Can have optional ByteStrings with default values
|
||||||
threw = False
|
|
||||||
try:
|
try:
|
||||||
parser.parse("""
|
parser.parse("""
|
||||||
interface OptionalByteString {
|
interface OptionalByteString {
|
||||||
|
@ -65,8 +64,36 @@ def WebIDLTest(parser, harness):
|
||||||
};
|
};
|
||||||
""")
|
""")
|
||||||
results2 = parser.finish();
|
results2 = parser.finish();
|
||||||
except WebIDL.WebIDLError:
|
except WebIDL.WebIDLError as e:
|
||||||
|
harness.ok(False,
|
||||||
|
"Should not have thrown a WebIDL error for ByteString "
|
||||||
|
"default in dictionary. " + str(e))
|
||||||
|
|
||||||
|
# Can have a default ByteString value in a dictionary
|
||||||
|
try:
|
||||||
|
parser.parse("""
|
||||||
|
dictionary OptionalByteStringDict {
|
||||||
|
ByteString item = "some string";
|
||||||
|
};
|
||||||
|
""")
|
||||||
|
results3 = parser.finish();
|
||||||
|
except WebIDL.WebIDLError as e:
|
||||||
|
harness.ok(False,
|
||||||
|
"Should not have thrown a WebIDL error for ByteString "
|
||||||
|
"default in dictionary. " + str(e))
|
||||||
|
|
||||||
|
# Don't allow control characters in ByteString literals
|
||||||
|
threw = False
|
||||||
|
try:
|
||||||
|
parser.parse("""
|
||||||
|
dictionary OptionalByteStringDict2 {
|
||||||
|
ByteString item = "\x03";
|
||||||
|
};
|
||||||
|
""")
|
||||||
|
results4 = parser.finish()
|
||||||
|
except WebIDL.WebIDLError as e:
|
||||||
threw = True
|
threw = True
|
||||||
|
|
||||||
harness.ok(threw, "Should have thrown a WebIDL error")
|
harness.ok(threw,
|
||||||
|
"Should have thrown a WebIDL error for invalid ByteString "
|
||||||
|
"default in dictionary")
|
||||||
|
|
|
@ -159,7 +159,7 @@ def WebIDLTest(parser, harness):
|
||||||
"object", "Callback", "Callback2", "optional Dict",
|
"object", "Callback", "Callback2", "optional Dict",
|
||||||
"optional Dict2", "sequence<long>", "sequence<short>",
|
"optional Dict2", "sequence<long>", "sequence<short>",
|
||||||
"MozMap<object>", "MozMap<Dict>", "MozMap<long>",
|
"MozMap<object>", "MozMap<Dict>", "MozMap<long>",
|
||||||
"long[]", "short[]", "Date", "Date?", "any",
|
"Date", "Date?", "any",
|
||||||
"Promise<any>", "Promise<any>?",
|
"Promise<any>", "Promise<any>?",
|
||||||
"USVString", "ArrayBuffer", "ArrayBufferView", "SharedArrayBuffer",
|
"USVString", "ArrayBuffer", "ArrayBufferView", "SharedArrayBuffer",
|
||||||
"Uint8Array", "Uint16Array" ]
|
"Uint8Array", "Uint16Array" ]
|
||||||
|
@ -187,7 +187,6 @@ def WebIDLTest(parser, harness):
|
||||||
"Date?", "any", "Promise<any>?"]
|
"Date?", "any", "Promise<any>?"]
|
||||||
dates = [ "Date", "Date?" ]
|
dates = [ "Date", "Date?" ]
|
||||||
sequences = [ "sequence<long>", "sequence<short>" ]
|
sequences = [ "sequence<long>", "sequence<short>" ]
|
||||||
arrays = [ "long[]", "short[]" ]
|
|
||||||
nonUserObjects = nonObjects + interfaces + dates + sequences
|
nonUserObjects = nonObjects + interfaces + dates + sequences
|
||||||
otherObjects = allBut(argTypes, nonUserObjects + ["object"])
|
otherObjects = allBut(argTypes, nonUserObjects + ["object"])
|
||||||
notRelatedInterfaces = (nonObjects + ["UnrelatedInterface"] +
|
notRelatedInterfaces = (nonObjects + ["UnrelatedInterface"] +
|
||||||
|
@ -229,14 +228,12 @@ def WebIDLTest(parser, harness):
|
||||||
setDistinguishable("optional Dict", allBut(nonUserObjects, nullables))
|
setDistinguishable("optional Dict", allBut(nonUserObjects, nullables))
|
||||||
setDistinguishable("optional Dict2", allBut(nonUserObjects, nullables))
|
setDistinguishable("optional Dict2", allBut(nonUserObjects, nullables))
|
||||||
setDistinguishable("sequence<long>",
|
setDistinguishable("sequence<long>",
|
||||||
allBut(argTypes, sequences + arrays + ["object"]))
|
allBut(argTypes, sequences + ["object"]))
|
||||||
setDistinguishable("sequence<short>",
|
setDistinguishable("sequence<short>",
|
||||||
allBut(argTypes, sequences + arrays + ["object"]))
|
allBut(argTypes, sequences + ["object"]))
|
||||||
setDistinguishable("MozMap<object>", nonUserObjects)
|
setDistinguishable("MozMap<object>", nonUserObjects)
|
||||||
setDistinguishable("MozMap<Dict>", nonUserObjects)
|
setDistinguishable("MozMap<Dict>", nonUserObjects)
|
||||||
setDistinguishable("MozMap<long>", nonUserObjects)
|
setDistinguishable("MozMap<long>", nonUserObjects)
|
||||||
setDistinguishable("long[]", allBut(nonUserObjects, sequences))
|
|
||||||
setDistinguishable("short[]", allBut(nonUserObjects, sequences))
|
|
||||||
setDistinguishable("Date", allBut(argTypes, dates + ["object"]))
|
setDistinguishable("Date", allBut(argTypes, dates + ["object"]))
|
||||||
setDistinguishable("Date?", allBut(argTypes, dates + nullables + ["object"]))
|
setDistinguishable("Date?", allBut(argTypes, dates + nullables + ["object"]))
|
||||||
setDistinguishable("any", [])
|
setDistinguishable("any", [])
|
||||||
|
|
|
@ -11,7 +11,6 @@ def WebIDLTest(parser, harness):
|
||||||
boolean basicBooleanWithSimpleArgs(boolean arg1, byte arg2, unsigned long arg3);
|
boolean basicBooleanWithSimpleArgs(boolean arg1, byte arg2, unsigned long arg3);
|
||||||
void optionalArg(optional byte? arg1, optional sequence<byte> arg2);
|
void optionalArg(optional byte? arg1, optional sequence<byte> arg2);
|
||||||
void variadicArg(byte?... arg1);
|
void variadicArg(byte?... arg1);
|
||||||
void crazyTypes(sequence<long?[]>? arg1, boolean?[][]? arg2);
|
|
||||||
object getObject();
|
object getObject();
|
||||||
void setObject(object arg1);
|
void setObject(object arg1);
|
||||||
void setAny(any arg1);
|
void setAny(any arg1);
|
||||||
|
@ -28,7 +27,7 @@ def WebIDLTest(parser, harness):
|
||||||
"Should be an IDLInterface")
|
"Should be an IDLInterface")
|
||||||
harness.check(iface.identifier.QName(), "::TestMethods", "Interface has the right QName")
|
harness.check(iface.identifier.QName(), "::TestMethods", "Interface has the right QName")
|
||||||
harness.check(iface.identifier.name, "TestMethods", "Interface has the right name")
|
harness.check(iface.identifier.name, "TestMethods", "Interface has the right name")
|
||||||
harness.check(len(iface.members), 13, "Expect 13 members")
|
harness.check(len(iface.members), 12, "Expect 12 members")
|
||||||
|
|
||||||
methods = iface.members
|
methods = iface.members
|
||||||
|
|
||||||
|
@ -98,22 +97,17 @@ def WebIDLTest(parser, harness):
|
||||||
"variadicArg",
|
"variadicArg",
|
||||||
[("Void",
|
[("Void",
|
||||||
[("::TestMethods::variadicArg::arg1", "arg1", "ByteOrNull", True, True)])])
|
[("::TestMethods::variadicArg::arg1", "arg1", "ByteOrNull", True, True)])])
|
||||||
checkMethod(methods[8], "::TestMethods::crazyTypes",
|
checkMethod(methods[8], "::TestMethods::getObject",
|
||||||
"crazyTypes",
|
|
||||||
[("Void",
|
|
||||||
[("::TestMethods::crazyTypes::arg1", "arg1", "LongOrNullArraySequenceOrNull", False, False),
|
|
||||||
("::TestMethods::crazyTypes::arg2", "arg2", "BooleanOrNullArrayArrayOrNull", False, False)])])
|
|
||||||
checkMethod(methods[9], "::TestMethods::getObject",
|
|
||||||
"getObject", [("Object", [])])
|
"getObject", [("Object", [])])
|
||||||
checkMethod(methods[10], "::TestMethods::setObject",
|
checkMethod(methods[9], "::TestMethods::setObject",
|
||||||
"setObject",
|
"setObject",
|
||||||
[("Void",
|
[("Void",
|
||||||
[("::TestMethods::setObject::arg1", "arg1", "Object", False, False)])])
|
[("::TestMethods::setObject::arg1", "arg1", "Object", False, False)])])
|
||||||
checkMethod(methods[11], "::TestMethods::setAny",
|
checkMethod(methods[10], "::TestMethods::setAny",
|
||||||
"setAny",
|
"setAny",
|
||||||
[("Void",
|
[("Void",
|
||||||
[("::TestMethods::setAny::arg1", "arg1", "Any", False, False)])])
|
[("::TestMethods::setAny::arg1", "arg1", "Any", False, False)])])
|
||||||
checkMethod(methods[12], "::TestMethods::doFloats",
|
checkMethod(methods[11], "::TestMethods::doFloats",
|
||||||
"doFloats",
|
"doFloats",
|
||||||
[("Float",
|
[("Float",
|
||||||
[("::TestMethods::doFloats::arg1", "arg1", "Float", False, False)])])
|
[("::TestMethods::doFloats::arg1", "arg1", "Float", False, False)])])
|
||||||
|
|
|
@ -53,16 +53,6 @@ def WebIDLTest(parser, harness):
|
||||||
attribute object a;
|
attribute object a;
|
||||||
attribute object? b;
|
attribute object? b;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface TestNullableEquivalency11 {
|
|
||||||
attribute double[] a;
|
|
||||||
attribute double[]? b;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface TestNullableEquivalency12 {
|
|
||||||
attribute TestNullableEquivalency9[] a;
|
|
||||||
attribute TestNullableEquivalency9[]? b;
|
|
||||||
};
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
for decl in parser.finish():
|
for decl in parser.finish():
|
||||||
|
|
|
@ -139,9 +139,6 @@ def WebIDLTest(parser, harness):
|
||||||
void method${i}(${type} arg);
|
void method${i}(${type} arg);
|
||||||
${type} returnMethod${i}();
|
${type} returnMethod${i}();
|
||||||
attribute ${type} attr${i};
|
attribute ${type} attr${i};
|
||||||
void arrayMethod${i}(${type}[] arg);
|
|
||||||
${type}[] arrayReturnMethod${i}();
|
|
||||||
attribute ${type}[] arrayAttr${i};
|
|
||||||
void optionalMethod${i}(${type}? arg);
|
void optionalMethod${i}(${type}? arg);
|
||||||
""").substitute(i=i, type=type)
|
""").substitute(i=i, type=type)
|
||||||
interface += """
|
interface += """
|
||||||
|
|
|
@ -3,7 +3,6 @@ patch < abstract.patch
|
||||||
patch < debug.patch
|
patch < debug.patch
|
||||||
patch < pref-main-thread.patch
|
patch < pref-main-thread.patch
|
||||||
patch < callback-location.patch
|
patch < callback-location.patch
|
||||||
patch < bytestring.patch
|
|
||||||
patch < union-typedef.patch
|
patch < union-typedef.patch
|
||||||
|
|
||||||
wget https://hg.mozilla.org/mozilla-central/archive/tip.tar.gz/dom/bindings/parser/tests/ -O tests.tar.gz
|
wget https://hg.mozilla.org/mozilla-central/archive/tip.tar.gz/dom/bindings/parser/tests/ -O tests.tar.gz
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue