1 // -*- c-basic-offset: 2 -*-
3 * This file is part of the KDE libraries
4 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library 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.
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 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 #ifndef KJS_PROPERTY_MAP_H_
24 #define KJS_PROPERTY_MAP_H_
26 #include "identifier.h"
27 #include <kxmlcore/OwnArrayPtr.h>
31 class PropertyNameArray
;
37 struct PropertyMapHashTable
;
42 class SavedProperties
{
43 friend class PropertyMap
;
50 OwnArrayPtr
<SavedProperty
> _properties
;
54 * A hashtable entry for the @ref PropertyMap.
56 struct PropertyMapHashTableEntry
58 PropertyMapHashTableEntry() : key(0) { }
62 short globalGetterSetterFlag
;
67 * Javascript Property Map.
69 class KJS_EXPORT PropertyMap
{
76 void put(const Identifier
&name
, JSValue
*value
, int attributes
, bool roCheck
= false);
77 void remove(const Identifier
&name
);
78 JSValue
*get(const Identifier
&name
) const;
79 JSValue
*get(const Identifier
&name
, unsigned &attributes
) const;
80 JSValue
**getLocation(const Identifier
&name
);
83 void getEnumerablePropertyNames(PropertyNameArray
&) const;
84 void getSparseArrayPropertyNames(PropertyNameArray
&) const;
86 void save(SavedProperties
&) const;
87 void restore(const SavedProperties
&p
);
91 bool hasGetterSetterProperties() const { return (_singleEntry
.globalGetterSetterFlag
!= 0); }
92 void setHasGetterSetterProperties(bool f
) { _singleEntry
.globalGetterSetterFlag
= f
; }
94 bool containsGettersOrSetters() const;
96 static bool keysMatch(const UString::Rep
*, const UString::Rep
*);
99 void rehash(int newTableSize
);
101 void insert(UString::Rep
*, JSValue
*value
, int attributes
, int index
);
103 void checkConsistency();
105 typedef PropertyMapHashTableEntry Entry
;
106 typedef PropertyMapHashTable Table
;
113 inline PropertyMap::PropertyMap() : _table(0)
115 _singleEntry
.globalGetterSetterFlag
= 0;
120 #endif // _KJS_PROPERTY_MAP_H_