JSGenericTypedArrayViewConstructor.h [plain text]
#pragma once
#include "InternalFunction.h"
namespace JSC {
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callInt8Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callInt16Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callInt32Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callUint8Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callUint8ClampedArray);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callUint16Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callUint32Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callFloat32Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callFloat64Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callDataView);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructInt8Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructInt16Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructInt32Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructUint8Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructUint8ClampedArray);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructUint16Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructUint32Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructFloat32Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructFloat64Array);
JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructDataView);
template<typename ViewClass>
class JSGenericTypedArrayViewConstructor final : public InternalFunction {
public:
using Base = InternalFunction;
static JSGenericTypedArrayViewConstructor* create(
VM&, JSGlobalObject*, Structure*, JSObject* prototype, const String& name);
IGNORE_CLANG_WARNINGS_BEGIN("undefined-var-template")
DECLARE_INFO;
IGNORE_CLANG_WARNINGS_END
static Structure* createStructure(VM&, JSGlobalObject*, JSValue prototype);
static constexpr RawNativeFunction callConstructor()
{
switch (ViewClass::TypedArrayStorageType) {
case TypeInt8:
return callInt8Array;
case TypeInt16:
return callInt16Array;
case TypeInt32:
return callInt32Array;
case TypeUint8:
return callUint8Array;
case TypeUint8Clamped:
return callUint8ClampedArray;
case TypeUint16:
return callUint16Array;
case TypeUint32:
return callUint32Array;
case TypeFloat32:
return callFloat32Array;
case TypeFloat64:
return callFloat64Array;
case TypeDataView:
return callDataView;
default:
CRASH_UNDER_CONSTEXPR_CONTEXT();
return nullptr;
}
}
static constexpr RawNativeFunction constructConstructor()
{
switch (ViewClass::TypedArrayStorageType) {
case TypeInt8:
return constructInt8Array;
case TypeInt16:
return constructInt16Array;
case TypeInt32:
return constructInt32Array;
case TypeUint8:
return constructUint8Array;
case TypeUint8Clamped:
return constructUint8ClampedArray;
case TypeUint16:
return constructUint16Array;
case TypeUint32:
return constructUint32Array;
case TypeFloat32:
return constructFloat32Array;
case TypeFloat64:
return constructFloat64Array;
case TypeDataView:
return constructDataView;
default:
CRASH_UNDER_CONSTEXPR_CONTEXT();
return nullptr;
}
}
private:
JSGenericTypedArrayViewConstructor(VM&, Structure*);
void finishCreation(VM&, JSGlobalObject*, JSObject* prototype, const String& name);
};
}