property_map.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _KJS_PROPERTY_MAP_H_
00024 #define _KJS_PROPERTY_MAP_H_
00025
00026 #include "identifier.h"
00027
00028 namespace KJS {
00029
00030 class Object;
00031 class ReferenceList;
00032 class ValueImp;
00033
00034 class SavedProperty;
00035
00036 struct PropertyMapHashTable;
00037
00041 class SavedProperties {
00042 friend class PropertyMap;
00043 public:
00044 SavedProperties();
00045 ~SavedProperties();
00046
00047 private:
00048 int _count;
00049 SavedProperty *_properties;
00050
00051 SavedProperties(const SavedProperties&);
00052 SavedProperties& operator=(const SavedProperties&);
00053 };
00054
00058 struct PropertyMapHashTableEntry
00059 {
00060 PropertyMapHashTableEntry() : key(0) { }
00061 UString::Rep *key;
00062 ValueImp *value;
00063 int attributes;
00064 };
00069 class KJS_EXPORT PropertyMap {
00070 public:
00071 PropertyMap();
00072 ~PropertyMap();
00073
00074 void clear();
00075
00076 void put(const Identifier &name, ValueImp *value, int attributes);
00077 void remove(const Identifier &name);
00078 ValueImp *get(const Identifier &name) const;
00079 ValueImp *get(const Identifier &name, int &attributes) const;
00080
00081 void mark() const;
00082 void addEnumerablesToReferenceList(ReferenceList &, const Object &) const;
00083 void addSparseArrayPropertiesToReferenceList(ReferenceList &, const Object &) const;
00084
00085 void save(SavedProperties &) const;
00086 void restore(const SavedProperties &p);
00087
00088 private:
00089 int hash(const UString::Rep *) const;
00090 static bool keysMatch(const UString::Rep *, const UString::Rep *);
00091 void expand();
00092
00093 void insert(UString::Rep *, ValueImp *value, int attributes);
00094
00095 void checkConsistency();
00096
00097 typedef PropertyMapHashTableEntry Entry;
00098 typedef PropertyMapHashTable Table;
00099
00100 Table *_table;
00101
00102 Entry _singleEntry;
00103 };
00104
00105 }
00106
00107 #endif // _KJS_PROPERTY_MAP_H_
|