From 5863d6acd10e5eab114e7bee955afcf432daeda0 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 13 Apr 2012 13:52:21 -0400 Subject: [PATCH] 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. --- dom/bindings/Codegen.py | 20 ++++++++++---------- dom/bindings/parser/WebIDL.py | 20 +++++--------------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index fe4aaa2bd4b5..eb5e68f68037 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -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())" % diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py index 38d1f65dff31..932263d16414 100644 --- a/dom/bindings/parser/WebIDL.py +++ b/dom/bindings/parser/WebIDL.py @@ -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 = {