#pragma once
#include "DataView.h"
#include "JSArrayBufferView.h"
namespace JSC {
class JSDataView final : public JSArrayBufferView {
public:
typedef JSArrayBufferView Base;
static const unsigned elementSize = 1;
protected:
JSDataView(VM&, ConstructionContext&, ArrayBuffer*);
public:
JS_EXPORT_PRIVATE static JSDataView* create(
ExecState*, Structure*, RefPtr<ArrayBuffer>&&, unsigned byteOffset,
unsigned byteLength);
static JSDataView* createUninitialized(ExecState*, Structure*, unsigned length);
static JSDataView* create(ExecState*, Structure*, unsigned length);
bool set(ExecState*, unsigned, JSObject*, unsigned, unsigned length);
bool setIndex(ExecState*, 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*, ExecState*, PropertyName, PropertySlot&);
static bool put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&, bool shouldThrow);
static bool deleteProperty(JSCell*, ExecState*, PropertyName);
static void getOwnNonIndexPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
public:
static Structure* createStructure(VM&, JSGlobalObject*, JSValue prototype);
DECLARE_EXPORT_INFO;
private:
ArrayBuffer* m_buffer;
};
}