#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; }
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 pushUndefinedObjectsToEnd(ExecState *exec);
void resizeStorage(unsigned);
unsigned length;
unsigned storageLength;
unsigned capacity;
JSValue **storage;
};
}
#endif