Bug 743820. Update to the changes to WebIDL that made interfaces with indexed properties distinguishable from array and sequence. r=khuey

There are two parts to this change:
1)  Sequences and arrays are now distinguishable from all non-callback interfaces.
2)  To handle that change, overload resolution first tries to convert to the exact
    interface, and only if that fails tries to convert things with indexed properties
    to sequences or arrays.
This commit is contained in:
Boris Zbarsky 2012-04-13 13:52:21 -04:00
Родитель 4994b76f7b
Коммит 5863d6acd1
2 изменённых файлов: 15 добавлений и 25 удалений

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

@ -1895,16 +1895,6 @@ class CGMethodCall(CGThing):
pickFirstSignature("%s.isNullOrUndefined()" % distinguishingArg,
lambda s: s[1][distinguishingIndex].type.nullable())
# XXXbz Now we're supposed to check for distinguishingArg being
# an array or a platform object that supports indexed
# properties... skip that last for now. It's a bit of a pain.
pickFirstSignature("%s.isObject() && IsArrayLike(cx, &%s.toObject()" %
(distinguishingArg, distinguishingArg),
lambda s:
(s[1][distinguishingIndex].type.isArray() or
s[1][distinguishingIndex].type.isSequence() or
s[1][distinguishingIndex].type.isObject()))
# Now check for distinguishingArg being a platform object.
# We can actually check separately for array buffers and
# other things.
@ -1993,6 +1983,16 @@ class CGMethodCall(CGThing):
caseBody.append(CGGeneric("}"))
# XXXbz Now we're supposed to check for distinguishingArg being
# an array or a platform object that supports indexed
# properties... skip that last for now. It's a bit of a pain.
pickFirstSignature("%s.isObject() && IsArrayLike(cx, &%s.toObject()" %
(distinguishingArg, distinguishingArg),
lambda s:
(s[1][distinguishingIndex].type.isArray() or
s[1][distinguishingIndex].type.isSequence() or
s[1][distinguishingIndex].type.isObject()))
# Check for Date objects
# XXXbz Do we need to worry about security wrappers around the Date?
pickFirstSignature("%s.isObject() && JS_ObjectIsDate(cx, &%s.toObject())" %

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

@ -859,10 +859,7 @@ class IDLSequenceType(IDLType):
def isDistinguishableFrom(self, other):
return (other.isPrimitive() or other.isString() or other.isEnum() or
other.isDictionary() or other.isDate() or
# XXXbz we should also be checking for indexed
# properties on interfaces
(other.isInterface() and not other.isCallback() and
not other.isArrayBuffer()))
(other.isInterface() and not other.isCallback()))
class IDLArrayType(IDLType):
def __init__(self, location, parameterType):
@ -935,10 +932,7 @@ class IDLArrayType(IDLType):
def isDistinguishableFrom(self, other):
return (other.isPrimitive() or other.isString() or other.isEnum() or
other.isDictionary() or other.isDate() or
# XXXbz we should also be checking for indexed
# properties on interfaces
(other.isInterface() and not other.isCallback() and
not other.isArrayBuffer()))
(other.isInterface() and not other.isCallback()))
class IDLTypedefType(IDLType, IDLObjectWithIdentifier):
def __init__(self, location, innerType, name):
@ -1068,8 +1062,6 @@ class IDLWrapperType(IDLType):
if other.isDictionary() or other.isCallback():
return not self.isCallback()
if other.isSequence() or other.isArray():
# XXXbz should also check self for enumerated properties
# and the like
return not self.isCallback()
class IDLBuiltinType(IDLType):
@ -1168,12 +1160,10 @@ class IDLBuiltinType(IDLType):
return not other.isVoid()
# Not much else we could be!
assert self.isArrayBuffer()
# Like interfaces, but we know we're not a callback and we
# know that we have indexed properties.
# XXXbz this should be checking for indexed properties on
# other when other.isInterface()
# Like interfaces, but we know we're not a callback
return (other.isPrimitive() or other.isString() or other.isEnum() or
other.isCallback() or other.isDictionary() or other.isDate() or
other.isCallback() or other.isDictionary() or
other.isSequence() or other.isArray() or other.isDate() or
(other.isInterface() and not other.isArrayBuffer()))
BuiltinTypes = {