mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 809652 - Add gross one-off predicates to jsfriendapi. r=jorendorff
This commit is contained in:
parent
60185d18f7
commit
c769a0aaa2
@ -3241,3 +3241,50 @@ js_DateGetMsecSinceEpoch(RawObject obj)
|
||||
return obj->isDate() ? obj->getDateUTCTime().toNumber() : 0;
|
||||
}
|
||||
|
||||
|
||||
static const NativeImpl sReadOnlyDateMethods[] = {
|
||||
date_getTime_impl,
|
||||
date_getYear_impl,
|
||||
date_getFullYear_impl,
|
||||
date_getUTCFullYear_impl,
|
||||
date_getMonth_impl,
|
||||
date_getUTCMonth_impl,
|
||||
date_getDate_impl,
|
||||
date_getUTCDate_impl,
|
||||
date_getDay_impl,
|
||||
date_getUTCDay_impl,
|
||||
date_getHours_impl,
|
||||
date_getUTCHours_impl,
|
||||
date_getMinutes_impl,
|
||||
date_getUTCMinutes_impl,
|
||||
date_getUTCSeconds_impl,
|
||||
date_getUTCMilliseconds_impl,
|
||||
date_getTimezoneOffset_impl,
|
||||
date_toGMTString_impl,
|
||||
date_toISOString_impl,
|
||||
date_toLocaleString_impl,
|
||||
date_toLocaleDateString_impl,
|
||||
date_toLocaleTimeString_impl,
|
||||
date_toLocaleFormat_impl,
|
||||
date_toTimeString_impl,
|
||||
date_toDateString_impl,
|
||||
date_toSource_impl,
|
||||
date_toString_impl,
|
||||
date_valueOf_impl
|
||||
};
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
js::IsReadOnlyDateMethod(IsAcceptableThis test, NativeImpl method)
|
||||
{
|
||||
/* Avoid a linear search in the common case by checking the |this| test. */
|
||||
if (test != IsDate)
|
||||
return false;
|
||||
|
||||
/* Linear search, comparing function pointers. */
|
||||
unsigned max = sizeof(sReadOnlyDateMethods) / sizeof(sReadOnlyDateMethods[0]);
|
||||
for (unsigned i = 0; i < max; ++i) {
|
||||
if (method == sReadOnlyDateMethods[i])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1549,6 +1549,12 @@ IdToJsval(jsid id)
|
||||
return IdToValue(id);
|
||||
}
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
IsReadOnlyDateMethod(JS::IsAcceptableThis test, JS::NativeImpl method);
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
IsTypedArrayThisCheck(JS::IsAcceptableThis test);
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
#endif /* jsfriendapi_h___ */
|
||||
|
@ -3424,6 +3424,23 @@ Class TypedArray::protoClasses[TYPE_MAX] = {
|
||||
IMPL_TYPED_ARRAY_PROTO_CLASS(Uint8ClampedArray)
|
||||
};
|
||||
|
||||
#define CHECK(t, a) { if (t == a::IsThisClass) return true; }
|
||||
JS_FRIEND_API(bool)
|
||||
js::IsTypedArrayThisCheck(JS::IsAcceptableThis test)
|
||||
{
|
||||
CHECK(test, Int8Array);
|
||||
CHECK(test, Uint8Array);
|
||||
CHECK(test, Int16Array);
|
||||
CHECK(test, Uint16Array);
|
||||
CHECK(test, Int32Array);
|
||||
CHECK(test, Uint32Array);
|
||||
CHECK(test, Float32Array);
|
||||
CHECK(test, Float64Array);
|
||||
CHECK(test, Uint8ClampedArray);
|
||||
return false;
|
||||
}
|
||||
#undef CHECK
|
||||
|
||||
static JSObject *
|
||||
InitArrayBufferClass(JSContext *cx)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user