1 | // -*- mode: c++; c-basic-offset: 4 -*-
|
---|
2 | /*
|
---|
3 | * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
|
---|
4 | *
|
---|
5 | * This library is free software; you can redistribute it and/or
|
---|
6 | * modify it under the terms of the GNU Library General Public
|
---|
7 | * License as published by the Free Software Foundation; either
|
---|
8 | * version 2 of the License, or (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This library is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
13 | * Library General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU Library General Public License
|
---|
16 | * along with this library; see the file COPYING.LIB. If not, write to
|
---|
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
---|
18 | * Boston, MA 02110-1301, USA.
|
---|
19 | *
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef PropertyMap_h
|
---|
23 | #define PropertyMap_h
|
---|
24 |
|
---|
25 | #include "identifier.h"
|
---|
26 | #include "protect.h"
|
---|
27 | #include <wtf/OwnArrayPtr.h>
|
---|
28 |
|
---|
29 | namespace KJS {
|
---|
30 |
|
---|
31 | class JSObject;
|
---|
32 | class JSValue;
|
---|
33 | class PropertyNameArray;
|
---|
34 |
|
---|
35 | struct PropertyMapEntry;
|
---|
36 | struct PropertyMapHashTable;
|
---|
37 |
|
---|
38 | class PropertyMap : Noncopyable {
|
---|
39 | public:
|
---|
40 | PropertyMap();
|
---|
41 | ~PropertyMap();
|
---|
42 |
|
---|
43 | void clear();
|
---|
44 |
|
---|
45 | void put(const Identifier&, JSValue*, unsigned attributes, bool checkReadOnly = false);
|
---|
46 | void remove(const Identifier&);
|
---|
47 | JSValue* get(const Identifier&) const;
|
---|
48 | JSValue* get(const Identifier&, unsigned& attributes) const;
|
---|
49 | JSValue** getLocation(const Identifier& name);
|
---|
50 | JSValue** getLocation(const Identifier& name, bool& isWriteable);
|
---|
51 |
|
---|
52 | void mark() const;
|
---|
53 | void getEnumerablePropertyNames(PropertyNameArray&) const;
|
---|
54 |
|
---|
55 | bool hasGetterSetterProperties() const { return m_getterSetterFlag; }
|
---|
56 | void setHasGetterSetterProperties(bool f) { m_getterSetterFlag = f; }
|
---|
57 |
|
---|
58 | bool containsGettersOrSetters() const;
|
---|
59 |
|
---|
60 | private:
|
---|
61 | typedef PropertyMapEntry Entry;
|
---|
62 | typedef PropertyMapHashTable Table;
|
---|
63 |
|
---|
64 | static bool keysMatch(const UString::Rep*, const UString::Rep*);
|
---|
65 | void expand();
|
---|
66 | void rehash();
|
---|
67 | void rehash(unsigned newTableSize);
|
---|
68 | void createTable();
|
---|
69 |
|
---|
70 | void insert(const Entry&);
|
---|
71 |
|
---|
72 | void checkConsistency();
|
---|
73 |
|
---|
74 | UString::Rep* m_singleEntryKey;
|
---|
75 | union {
|
---|
76 | JSValue* singleEntryValue;
|
---|
77 | Table* table;
|
---|
78 | } m_u;
|
---|
79 |
|
---|
80 | short m_singleEntryAttributes;
|
---|
81 | bool m_getterSetterFlag : 1;
|
---|
82 | bool m_usingTable : 1;
|
---|
83 | };
|
---|
84 |
|
---|
85 | inline PropertyMap::PropertyMap()
|
---|
86 | : m_singleEntryKey(0)
|
---|
87 | , m_getterSetterFlag(false)
|
---|
88 | , m_usingTable(false)
|
---|
89 |
|
---|
90 | {
|
---|
91 | }
|
---|
92 | } // namespace
|
---|
93 |
|
---|
94 | #endif // _KJS_PROPERTY_MAP_H_
|
---|