#ifndef RUNTIME_ARRAY_H_
#define RUNTIME_ARRAY_H_
#include "BridgeJSC.h"
#include "JSDOMBinding.h"
#include <JavaScriptCore/ArrayPrototype.h>
namespace JSC {
class RuntimeArray final : public JSArray {
public:
using Base = JSArray;
static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesAnyFormOfGetPropertyNames;
static constexpr bool needsDestruction = true;
template<typename CellType, JSC::SubspaceAccess>
static JSC::IsoSubspace* subspaceFor(JSC::VM& vm)
{
return subspaceForImpl(vm);
}
static RuntimeArray* create(JSGlobalObject* lexicalGlobalObject, Bindings::Array* array)
{
VM& vm = lexicalGlobalObject->vm();
Structure* domStructure = WebCore::deprecatedGetDOMStructure<RuntimeArray>(lexicalGlobalObject);
RuntimeArray* runtimeArray = new (NotNull, allocateCell<RuntimeArray>(vm.heap)) RuntimeArray(vm, domStructure);
runtimeArray->finishCreation(vm, array);
return runtimeArray;
}
typedef Bindings::Array BindingsArray;
~RuntimeArray();
static void destroy(JSCell*);
static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode);
static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&);
static bool getOwnPropertySlotByIndex(JSObject*, JSGlobalObject*, unsigned, PropertySlot&);
static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&);
static bool putByIndex(JSCell*, JSGlobalObject*, unsigned propertyName, JSValue, bool shouldThrow);
static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&);
static bool deletePropertyByIndex(JSCell*, JSGlobalObject*, unsigned propertyName);
unsigned getLength() const { return m_array->getLength(); }
Bindings::Array* getConcreteArray() const { return m_array; }
DECLARE_INFO;
static ArrayPrototype* createPrototype(VM&, JSGlobalObject& globalObject)
{
return globalObject.arrayPrototype();
}
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(vm, globalObject, prototype, TypeInfo(DerivedArrayType, StructureFlags), info(), ArrayClass);
}
private:
RuntimeArray(VM&, Structure*);
void finishCreation(VM&, Bindings::Array*);
static EncodedJSValue lengthGetter(JSGlobalObject*, EncodedJSValue, PropertyName);
static JSC::IsoSubspace* subspaceForImpl(JSC::VM&);
BindingsArray* m_array;
};
}
#endif // RUNTIME_ARRAY_H_