#ifndef ARRAY_INSTANCE_H
#define ARRAY_INSTANCE_H
#include "object.h"
namespace KJS {
class ArrayInstanceImp : public ObjectImp {
public:
ArrayInstanceImp(ObjectImp *proto, unsigned initialLength);
ArrayInstanceImp(ObjectImp *proto, const List &initialValues);
~ArrayInstanceImp();
virtual Value get(ExecState *exec, const Identifier &propertyName) const;
virtual Value get(ExecState *exec, unsigned propertyName) const;
virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
virtual void put(ExecState *exec, unsigned propertyName, const Value &value, int attr = None);
virtual bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
virtual bool hasProperty(ExecState *exec, unsigned propertyName) const;
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
virtual ReferenceList propList(ExecState *exec, bool recursive);
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, Object &compareFunction);
private:
void setLength(unsigned newLength, ExecState *exec);
unsigned pushUndefinedObjectsToEnd(ExecState *exec);
void resizeStorage(unsigned);
unsigned length;
unsigned storageLength;
unsigned capacity;
ValueImp **storage;
};
};
#endif