Changeset 440 for trunk/JavaScriptCore/kjs/PropertySlot.h
- Timestamp:
- 08/18/08 11:14:49 (5 months ago)
- Files:
-
- trunk/JavaScriptCore/kjs/PropertySlot.h (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/JavaScriptCore/kjs/PropertySlot.h
r414 r440 35 35 #define KJS_VALUE_SLOT_MARKER 0 36 36 #define KJS_REGISTER_SLOT_MARKER reinterpret_cast<GetValueFunc>(1) 37 #define KJS_NUMERIC_PROPERTY_NAME_SLOT_MARKER reinterpret_cast<GetValueFunc>(2)38 37 39 38 class PropertySlot { … … 42 41 { 43 42 clearBase(); 43 clearValue(); 44 44 } 45 45 … … 47 47 : m_slotBase(base) 48 48 { 49 clearValue(); 49 50 } 50 51 51 52 typedef JSValue* (*GetValueFunc)(ExecState*, const Identifier&, const PropertySlot&); 52 typedef JSValue* (*GetValueNumericFunc)(ExecState*, unsigned index, const PropertySlot&);53 53 54 54 JSValue* getValue(ExecState* exec, const Identifier& propertyName) const … … 58 58 if (m_getValue == KJS_REGISTER_SLOT_MARKER) 59 59 return (*m_data.registerSlot).jsValue(exec); 60 ASSERT(m_getValue != KJS_NUMERIC_PROPERTY_NAME_SLOT_MARKER);61 60 return m_getValue(exec, propertyName, *this); 62 61 } … … 66 65 if (m_getValue == KJS_VALUE_SLOT_MARKER) 67 66 return *m_data.valueSlot; 68 if (m_getValue == KJS_NUMERIC_PROPERTY_NAME_SLOT_MARKER)69 return m_data.numericFunc(exec, propertyName, *this);70 67 if (m_getValue == KJS_REGISTER_SLOT_MARKER) 71 68 return (*m_data.registerSlot).jsValue(exec); … … 91 88 } 92 89 90 void setValue(JSValue* value) 91 { 92 ASSERT(value); 93 m_getValue = KJS_VALUE_SLOT_MARKER; 94 clearBase(); 95 m_value = value; 96 m_data.valueSlot = &m_value; 97 } 98 93 99 void setRegisterSlot(Register* registerSlot) 94 100 { … … 126 132 } 127 133 128 void setCustomNumeric(JSValue* slotBase, GetValueNumericFunc getValue)129 {130 ASSERT(slotBase);131 ASSERT(getValue);132 m_slotBase = slotBase;133 m_getValue = KJS_NUMERIC_PROPERTY_NAME_SLOT_MARKER;134 m_data.numericFunc = getValue;135 }136 137 134 void setGetterSlot(JSObject* getterFunc) 138 135 { … … 145 142 { 146 143 clearBase(); 147 m_getValue = undefinedGetter;144 setValue(jsUndefined()); 148 145 } 149 146 … … 168 165 } 169 166 167 void clearValue() 168 { 169 #ifndef NDEBUG 170 m_value = 0; 171 #endif 172 } 173 170 174 const HashEntry* staticEntry() const { return m_data.staticEntry; } 171 175 unsigned index() const { return m_data.index; } 172 176 173 177 private: 174 static JSValue* undefinedGetter(ExecState*, const Identifier&, const PropertySlot&);175 178 static JSValue* functionGetter(ExecState*, const Identifier&, const PropertySlot&); 176 179 177 180 GetValueFunc m_getValue; 181 182 JSValue* m_value; 178 183 179 184 JSValue* m_slotBase; … … 184 189 const HashEntry* staticEntry; 185 190 unsigned index; 186 GetValueNumericFunc numericFunc;187 191 } m_data; 188 192 };
