#pragma once
#include "DataView.h"
#include "JSArrayBufferView.h"
namespace JSC {
class JSDataView final : public JSArrayBufferView {
public:
using Base = JSArrayBufferView;
static constexpr unsigned elementSize = 1;
template<typename CellType, SubspaceAccess mode>
static IsoSubspace* subspaceFor(VM& vm)
{
return vm.dataViewSpace<mode>();
}
protected:
JSDataView(VM&, ConstructionContext&, ArrayBuffer*);
public:
JS_EXPORT_PRIVATE static JSDataView* create(
JSGlobalObject*, Structure*, RefPtr<ArrayBuffer>&&, unsigned byteOffset,
unsigned byteLength);
static JSDataView* createUninitialized(JSGlobalObject*, Structure*, unsigned length);
static JSDataView* create(JSGlobalObject*, Structure*, unsigned length);
bool set(JSGlobalObject*, unsigned, JSObject*, unsigned, unsigned length);
bool setIndex(JSGlobalObject*, unsigned, JSValue);
ArrayBuffer* possiblySharedBuffer() const { return m_buffer; }
ArrayBuffer* unsharedBuffer() const
{
RELEASE_ASSERT(!m_buffer->isShared());
return m_buffer;
}
RefPtr<DataView> possiblySharedTypedImpl();
RefPtr<DataView> unsharedTypedImpl();
static const TypedArrayType TypedArrayStorageType = TypeDataView;
protected:
static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&);
static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&);
static bool defineOwnProperty(JSObject*, JSGlobalObject*, PropertyName, const PropertyDescriptor&, bool shouldThrow);
static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName);
static void getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode);
public:
static Structure* createStructure(VM&, JSGlobalObject*, JSValue prototype);
DECLARE_EXPORT_INFO;
private:
ArrayBuffer* m_buffer;
};
}