]>
Commit | Line | Data |
---|---|---|
b37bf2e1 A |
1 | // -*- c-basic-offset: 2 -*- |
2 | /* | |
3 | * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) | |
4 | * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. | |
5 | * | |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Lesser General Public | |
8 | * License as published by the Free Software Foundation; either | |
9 | * version 2 of the License, or (at your option) any later version. | |
10 | * | |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Lesser General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Lesser General Public | |
17 | * License along with this library; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | * | |
20 | */ | |
21 | ||
22 | #ifndef ARRAY_INSTANCE_H | |
23 | #define ARRAY_INSTANCE_H | |
24 | ||
25 | #include "object.h" | |
26 | ||
27 | namespace KJS { | |
28 | ||
29 | struct ArrayStorage; | |
30 | ||
31 | class ArrayInstance : public JSObject { | |
32 | public: | |
33 | ArrayInstance(JSObject* prototype, unsigned initialLength); | |
34 | ArrayInstance(JSObject* prototype, const List& initialValues); | |
35 | ~ArrayInstance(); | |
36 | ||
37 | virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); | |
38 | virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); | |
39 | virtual void put(ExecState*, const Identifier& propertyName, JSValue*, int attributes = None); | |
40 | virtual void put(ExecState*, unsigned propertyName, JSValue*, int attributes = None); | |
41 | virtual bool deleteProperty(ExecState *, const Identifier& propertyName); | |
42 | virtual bool deleteProperty(ExecState *, unsigned propertyName); | |
43 | virtual void getPropertyNames(ExecState*, PropertyNameArray&); | |
44 | ||
45 | virtual void mark(); | |
46 | ||
47 | virtual const ClassInfo* classInfo() const { return &info; } | |
48 | static const ClassInfo info; | |
49 | ||
50 | unsigned getLength() const { return m_length; } | |
51 | JSValue* getItem(unsigned) const; | |
52 | ||
53 | void sort(ExecState*); | |
54 | void sort(ExecState*, JSObject* compareFunction); | |
55 | ||
56 | private: | |
57 | static JSValue* lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); | |
58 | bool inlineGetOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); | |
59 | ||
60 | void setLength(unsigned); | |
61 | void increaseVectorLength(unsigned newLength); | |
62 | ||
63 | unsigned compactForSorting(); | |
64 | ||
65 | unsigned m_length; | |
66 | unsigned m_vectorLength; | |
67 | ArrayStorage* m_storage; | |
68 | }; | |
69 | ||
70 | } // namespace KJS | |
71 | ||
72 | #endif |