#ifndef RUNTIME_ARRAY_H_
#define RUNTIME_ARRAY_H_
#include "BridgeJSC.h"
#include "JSDOMBinding.h"
#include <JavaScriptCore/ArrayPrototype.h>
namespace JSC {
class RuntimeArray : public JSArray {
public:
typedef JSArray Base;
static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesGetPropertyNames;
static RuntimeArray* create(ExecState* exec, Bindings::Array* array)
{
VM& vm = exec->vm();
Structure* domStructure = WebCore::deprecatedGetDOMStructure<RuntimeArray>(exec);
RuntimeArray* runtimeArray = new (NotNull, allocateCell<RuntimeArray>(vm.heap)) RuntimeArray(exec, domStructure);
runtimeArray->finishCreation(vm, array);
exec->vm().heap.addFinalizer(runtimeArray, destroy);
return runtimeArray;
}
typedef Bindings::Array BindingsArray;
~RuntimeArray();
static void destroy(JSCell*);
static const bool needsDestruction = false;
static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
static bool getOwnPropertySlotByIndex(JSObject*, ExecState*, unsigned, PropertySlot&);
static bool put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
static bool putByIndex(JSCell*, ExecState*, unsigned propertyName, JSValue, bool shouldThrow);
static bool deleteProperty(JSCell*, ExecState*, PropertyName);
static bool deletePropertyByIndex(JSCell*, ExecState*, 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);
}
protected:
void finishCreation(VM&, Bindings::Array*);
private:
RuntimeArray(ExecState*, Structure*);
static EncodedJSValue lengthGetter(ExecState*, EncodedJSValue, PropertyName);
BindingsArray* m_array;
};
}
#endif // RUNTIME_ARRAY_H_