Bug 1720422 - Convert the JS_Is(type)Array APIs r=jonco

Differential Revision: https://phabricator.services.mozilla.com/D119860
This commit is contained in:
Steve Fink 2021-08-12 20:44:17 +00:00
Родитель 42286d6cfa
Коммит df50b89bfe
2 изменённых файлов: 13 добавлений и 18 удалений

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

@ -114,20 +114,6 @@ extern JS_PUBLIC_API bool JS_IsTypedArrayObject(JSObject* obj);
*/
extern JS_PUBLIC_API bool JS_IsArrayBufferViewObject(JSObject* obj);
/*
* Test for specific typed array types (ArrayBufferView subtypes)
*/
extern JS_PUBLIC_API bool JS_IsInt8Array(JSObject* obj);
extern JS_PUBLIC_API bool JS_IsUint8Array(JSObject* obj);
extern JS_PUBLIC_API bool JS_IsUint8ClampedArray(JSObject* obj);
extern JS_PUBLIC_API bool JS_IsInt16Array(JSObject* obj);
extern JS_PUBLIC_API bool JS_IsUint16Array(JSObject* obj);
extern JS_PUBLIC_API bool JS_IsInt32Array(JSObject* obj);
extern JS_PUBLIC_API bool JS_IsUint32Array(JSObject* obj);
extern JS_PUBLIC_API bool JS_IsFloat32Array(JSObject* obj);
extern JS_PUBLIC_API bool JS_IsFloat64Array(JSObject* obj);
/**
* Return the isShared flag of a typed array, which denotes whether
* the underlying buffer is a SharedArrayBuffer.
@ -617,4 +603,17 @@ JS_FOR_EACH_TYPED_ARRAY(JS_DECLARE_CLASS_ALIAS)
} // namespace JS
/*
* JS_Is(type)Array(JSObject* maybeWrapped)
*
* Test for specific typed array types.
*/
#define DECLARE_IS_ARRAY_TEST(_1, _2, Name) \
inline JS_PUBLIC_API bool JS_Is##Name##Array(JSObject* maybeWrapped) { \
return JS::TypedArray<js::Scalar::Name>::unwrap(maybeWrapped).asObject(); \
}
JS_FOR_EACH_TYPED_ARRAY(DECLARE_IS_ARRAY_TEST)
#undef DECLARE_IS_ARRAY_TEST
#endif // js_experimental_TypedData_h

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

@ -2643,10 +2643,6 @@ bool js::DefineTypedArrayElement(JSContext* cx, Handle<TypedArrayObject*> obj,
return obj; \
} \
\
JS_PUBLIC_API bool JS_Is##Name##Array(JSObject* obj) { \
return js::Unwrap##Name##Array(obj) != nullptr; \
} \
\
JS_PUBLIC_API ExternalType* JS_Get##Name##ArrayLengthAndData( \
JSObject* obj, size_t* length, bool* isSharedMemory, \
const JS::AutoRequireNoGC& nogc) { \