зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1315135. Remove the RegExp (and some Date) special casing from our dictionary conversions and Web IDL overload resolution. r=peterv
This commit is contained in:
Родитель
55195fe393
Коммит
099ef6f007
|
@ -236,50 +236,10 @@ UnwrapObject(JSObject* obj, U& value)
|
||||||
PrototypeTraits<PrototypeID>::Depth);
|
PrototypeTraits<PrototypeID>::Depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
|
||||||
IsNotDateOrRegExp(JSContext* cx, JS::Handle<JSObject*> obj,
|
|
||||||
bool* notDateOrRegExp)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(obj);
|
|
||||||
|
|
||||||
js::ESClass cls;
|
|
||||||
if (!js::GetBuiltinClass(cx, obj, &cls)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*notDateOrRegExp = cls != js::ESClass::Date && cls != js::ESClass::RegExp;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_ALWAYS_INLINE bool
|
MOZ_ALWAYS_INLINE bool
|
||||||
IsObjectValueConvertibleToDictionary(JSContext* cx,
|
IsConvertibleToDictionary(JS::Handle<JS::Value> val)
|
||||||
JS::Handle<JS::Value> objVal,
|
|
||||||
bool* convertible)
|
|
||||||
{
|
{
|
||||||
JS::Rooted<JSObject*> obj(cx, &objVal.toObject());
|
return val.isNullOrUndefined() || val.isObject();
|
||||||
return IsNotDateOrRegExp(cx, obj, convertible);
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_ALWAYS_INLINE bool
|
|
||||||
IsConvertibleToDictionary(JSContext* cx, JS::Handle<JS::Value> val,
|
|
||||||
bool* convertible)
|
|
||||||
{
|
|
||||||
if (val.isNullOrUndefined()) {
|
|
||||||
*convertible = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!val.isObject()) {
|
|
||||||
*convertible = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return IsObjectValueConvertibleToDictionary(cx, val, convertible);
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_ALWAYS_INLINE bool
|
|
||||||
IsConvertibleToCallbackInterface(JSContext* cx, JS::Handle<JSObject*> obj,
|
|
||||||
bool* convertible)
|
|
||||||
{
|
|
||||||
return IsNotDateOrRegExp(cx, obj, convertible);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The items in the protoAndIfaceCache are indexed by the prototypes::id::ID,
|
// The items in the protoAndIfaceCache are indexed by the prototypes::id::ID,
|
||||||
|
|
|
@ -5783,30 +5783,24 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
exceptionCode=exceptionCode)
|
exceptionCode=exceptionCode)
|
||||||
|
|
||||||
if failureCode is not None:
|
if failureCode is not None:
|
||||||
if isDefinitelyObject:
|
# This means we're part of an overload or union conversion, and
|
||||||
dictionaryTest = "IsObjectValueConvertibleToDictionary"
|
# should simply skip stuff if our value is not convertible to
|
||||||
|
# dictionary, instead of trying and throwing. If we're either
|
||||||
|
# isDefinitelyObject or isNullOrUndefined then we're convertible to
|
||||||
|
# dictionary and don't need to check here.
|
||||||
|
if isDefinitelyObject or isNullOrUndefined:
|
||||||
|
template = conversionCode
|
||||||
else:
|
else:
|
||||||
dictionaryTest = "IsConvertibleToDictionary"
|
template = fill(
|
||||||
|
"""
|
||||||
template = fill("""
|
if (!IsConvertibleToDictionary(${val})) {
|
||||||
{ // scope for isConvertible
|
$*{failureCode}
|
||||||
bool isConvertible;
|
}
|
||||||
if (!${testConvertible}(cx, ${val}, &isConvertible)) {
|
$*{conversionCode}
|
||||||
$*{exceptionCode}
|
""",
|
||||||
}
|
val=val,
|
||||||
if (!isConvertible) {
|
failureCode=failureCode,
|
||||||
$*{failureCode}
|
conversionCode=conversionCode)
|
||||||
}
|
|
||||||
|
|
||||||
$*{conversionCode}
|
|
||||||
}
|
|
||||||
|
|
||||||
""",
|
|
||||||
testConvertible=dictionaryTest,
|
|
||||||
val=val,
|
|
||||||
exceptionCode=exceptionCode,
|
|
||||||
failureCode=failureCode,
|
|
||||||
conversionCode=conversionCode)
|
|
||||||
else:
|
else:
|
||||||
template = conversionCode
|
template = conversionCode
|
||||||
|
|
||||||
|
@ -8030,12 +8024,12 @@ class CGMethodCall(CGThing):
|
||||||
# 1) A platform object that's not a platform array object, being
|
# 1) A platform object that's not a platform array object, being
|
||||||
# passed to an interface or "object" arg.
|
# passed to an interface or "object" arg.
|
||||||
# 2) A Date object being passed to a Date or "object" arg.
|
# 2) A Date object being passed to a Date or "object" arg.
|
||||||
# 3) A RegExp object being passed to a RegExp or "object" arg.
|
# XXXbz This is actually gone from the spec now, but we still
|
||||||
# 4) A callable object being passed to a callback or "object" arg.
|
# have some APIs using Date.
|
||||||
# 5) An iterable object being passed to a sequence arg.
|
# 3) A callable object being passed to a callback or "object" arg.
|
||||||
# 6) Any non-Date and non-RegExp object being passed to a
|
# 4) An iterable object being passed to a sequence arg.
|
||||||
# array or callback interface or dictionary or
|
# 5) Any object being passed to a array or callback interface or
|
||||||
# "object" arg.
|
# dictionary or "object" arg.
|
||||||
|
|
||||||
# First grab all the overloads that have a non-callback interface
|
# First grab all the overloads that have a non-callback interface
|
||||||
# (which includes typed arrays and arraybuffers) at the
|
# (which includes typed arrays and arraybuffers) at the
|
||||||
|
@ -12591,14 +12585,8 @@ class CGDictionary(CGThing):
|
||||||
else:
|
else:
|
||||||
body += dedent(
|
body += dedent(
|
||||||
"""
|
"""
|
||||||
{ // scope for isConvertible
|
if (!IsConvertibleToDictionary(val)) {
|
||||||
bool isConvertible;
|
return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
|
||||||
if (!IsConvertibleToDictionary(cx, val, &isConvertible)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isConvertible) {
|
|
||||||
return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
""")
|
""")
|
||||||
|
|
|
@ -163,7 +163,8 @@ def WebIDLTest(parser, harness):
|
||||||
"Promise<any>", "Promise<any>?",
|
"Promise<any>", "Promise<any>?",
|
||||||
"USVString", "ArrayBuffer", "ArrayBufferView", "SharedArrayBuffer",
|
"USVString", "ArrayBuffer", "ArrayBufferView", "SharedArrayBuffer",
|
||||||
"Uint8Array", "Uint16Array" ]
|
"Uint8Array", "Uint16Array" ]
|
||||||
# When we can parse Date and RegExp, we need to add them here.
|
# When we can parse Date, we need to add it here.
|
||||||
|
# XXXbz we can, and should really do that...
|
||||||
|
|
||||||
# Try to categorize things a bit to keep list lengths down
|
# Try to categorize things a bit to keep list lengths down
|
||||||
def allBut(list1, list2):
|
def allBut(list1, list2):
|
||||||
|
|
|
@ -44,9 +44,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=882653
|
||||||
[ 'document.createTreeWalker(document, 0xFFFFFFFF, { acceptNode: 5 }).nextNode()',
|
[ 'document.createTreeWalker(document, 0xFFFFFFFF, { acceptNode: 5 }).nextNode()',
|
||||||
"Property 'acceptNode' is not callable.",
|
"Property 'acceptNode' is not callable.",
|
||||||
"non-callable callback interface operation property" ],
|
"non-callable callback interface operation property" ],
|
||||||
[ '(new TextDecoder).decode(new Uint8Array(), new RegExp())',
|
[ '(new TextDecoder).decode(new Uint8Array(), 5)',
|
||||||
"Argument 2 of TextDecoder.decode can't be converted to a dictionary.",
|
"Argument 2 of TextDecoder.decode can't be converted to a dictionary.",
|
||||||
"regexp passed for a dictionary" ],
|
"primitive passed for a dictionary" ],
|
||||||
[ 'URL.createObjectURL(null, null)',
|
[ 'URL.createObjectURL(null, null)',
|
||||||
"Argument 1 is not valid for any of the 2-argument overloads of URL.createObjectURL.",
|
"Argument 1 is not valid for any of the 2-argument overloads of URL.createObjectURL.",
|
||||||
"overload resolution failure" ],
|
"overload resolution failure" ],
|
||||||
|
|
Загрузка…
Ссылка в новой задаче