#ifndef ARRAY_INSTANCE_H
#define ARRAY_INSTANCE_H
#include "object.h"
namespace KJS {
class ArrayInstance : public JSObject {
public:
ArrayInstance(JSObject *proto, unsigned initialLength);
ArrayInstance(JSObject *proto, const List &initialValues);
~ArrayInstance();
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState *, unsigned, PropertySlot&);
virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
virtual void put(ExecState *exec, unsigned propertyName, JSValue *value, int attr = None);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
virtual void mark();
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
unsigned getLength() const { return length; }
JSValue* getItem(unsigned) const;
void sort(ExecState *exec);
void sort(ExecState *exec, JSObject *compareFunction);
private:
static JSValue *lengthGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
void setLength(unsigned newLength, ExecState *exec);
unsigned compactForSorting();
void resizeStorage(unsigned);
size_t capacity() { return storage ? reinterpret_cast<size_t>(storage[-1]) : 0; }
unsigned length;
unsigned storageLength;
JSValue **storage;
};
}
#endif