Changeset 10076 in webkit for trunk/JavaScriptCore/kjs/string_object.cpp
- Timestamp:
- Aug 6, 2005, 11:17:49 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/string_object.cpp
r9889 r10076 51 51 } 52 52 53 bool StringInstanceImp::getOwnProperty(ExecState *exec, const Identifier& propertyName, Value& result) const 53 Value StringInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot) 54 { 55 return Value(static_cast<StringInstanceImp *>(slot.slotBase())->internalValue().toString(exec).size()); 56 } 57 58 Value StringInstanceImp::indexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot) 59 { 60 const UChar c = static_cast<StringInstanceImp *>(slot.slotBase())->internalValue().toString(exec)[slot.index()]; 61 return Value(UString(&c, 1)); 62 } 63 64 bool StringInstanceImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot) 54 65 { 55 66 if (propertyName == lengthPropertyName) { 56 result = Value(internalValue().toString(exec).size());67 slot.setCustom(this, lengthGetter); 57 68 return true; 58 69 } … … 64 75 const unsigned length = s.size(); 65 76 if (index >= length) 66 return Undefined(); 67 const UChar c = s[index]; 68 result = Value(UString(&c, 1)); 77 return false; 78 slot.setCustomIndex(this, index, indexGetter); 69 79 return true; 70 80 } 71 81 72 return ObjectImp::getOwnProperty (exec, propertyName, result);82 return ObjectImp::getOwnPropertySlot(exec, propertyName, slot); 73 83 } 74 84 … … 78 88 return; 79 89 ObjectImp::put(exec, propertyName, value, attr); 80 }81 82 bool StringInstanceImp::hasOwnProperty(ExecState *exec, const Identifier &propertyName) const83 {84 if (propertyName == lengthPropertyName)85 return true;86 87 bool ok;88 const unsigned index = propertyName.toArrayIndex(&ok);89 if (ok) {90 const unsigned length = internalValue().toString(exec).size();91 if (index < length)92 return true;93 }94 95 return ObjectImp::hasOwnProperty(exec, propertyName);96 90 } 97 91 … … 155 149 } 156 150 157 bool StringPrototypeImp::getOwnProperty (ExecState *exec, const Identifier& propertyName, Value& result) const158 { 159 return lookupGetOwnFunction<StringProtoFuncImp, StringInstanceImp>(exec, propertyName, &stringTable, this, result);151 bool StringPrototypeImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot) 152 { 153 return getStaticFunctionSlot<StringProtoFuncImp, StringInstanceImp>(exec, &stringTable, this, propertyName, slot); 160 154 } 161 155
Note:
See TracChangeset
for help on using the changeset viewer.