summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-12-07 13:55:23 +0100
committerAlexis Menard <alexis.menard@nokia.com>2009-12-07 13:55:23 +0100
commit211c0a1dd5c10c60c3383748b13e17e6bdeaea54 (patch)
tree268920a5f40744663dd4bf8d405d35d324926f95 /src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp
parentfd44f52df9275e717292f5c7e90015fc9bf14603 (diff)
parent35a740fa663d4669a45ada9c37c46546e59bbb82 (diff)
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt into widgets-ng
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp')
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp66
1 files changed, 26 insertions, 40 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp
index 86f95e0db..20ba8684f 100644
--- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp
@@ -103,54 +103,40 @@ bool JSString::getOwnPropertySlot(ExecState* exec, const Identifier& propertyNam
return true;
}
-bool JSString::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
+bool JSString::getStringPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
- // The semantics here are really getPropertySlot, not getOwnPropertySlot.
- // This function should only be called by JSValue::get.
- if (getStringPropertySlot(exec, propertyName, slot))
+ if (propertyName == exec->propertyNames().length) {
+ descriptor.setDescriptor(jsNumber(exec, m_value.size()), DontEnum | DontDelete | ReadOnly);
return true;
- return JSString::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
-}
-
-JSString* jsString(JSGlobalData* globalData, const UString& s)
-{
- int size = s.size();
- if (!size)
- return globalData->smallStrings.emptyString(globalData);
- if (size == 1) {
- UChar c = s.data()[0];
- if (c <= 0xFF)
- return globalData->smallStrings.singleCharacterString(globalData, c);
}
- return new (globalData) JSString(globalData, s);
-}
-JSString* jsSubstring(JSGlobalData* globalData, const UString& s, unsigned offset, unsigned length)
-{
- ASSERT(offset <= static_cast<unsigned>(s.size()));
- ASSERT(length <= static_cast<unsigned>(s.size()));
- ASSERT(offset + length <= static_cast<unsigned>(s.size()));
- if (!length)
- return globalData->smallStrings.emptyString(globalData);
- if (length == 1) {
- UChar c = s.data()[offset];
- if (c <= 0xFF)
- return globalData->smallStrings.singleCharacterString(globalData, c);
+ bool isStrictUInt32;
+ unsigned i = propertyName.toStrictUInt32(&isStrictUInt32);
+ if (isStrictUInt32 && i < static_cast<unsigned>(m_value.size())) {
+ descriptor.setDescriptor(jsSingleCharacterSubstring(exec, m_value, i), DontDelete | ReadOnly);
+ return true;
}
- return new (globalData) JSString(globalData, UString::Rep::create(s.rep(), offset, length));
+
+ return false;
}
-JSString* jsOwnedString(JSGlobalData* globalData, const UString& s)
+bool JSString::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
- int size = s.size();
- if (!size)
- return globalData->smallStrings.emptyString(globalData);
- if (size == 1) {
- UChar c = s.data()[0];
- if (c <= 0xFF)
- return globalData->smallStrings.singleCharacterString(globalData, c);
- }
- return new (globalData) JSString(globalData, s, JSString::HasOtherOwner);
+ if (getStringPropertyDescriptor(exec, propertyName, descriptor))
+ return true;
+ if (propertyName != exec->propertyNames().underscoreProto)
+ return false;
+ descriptor.setDescriptor(exec->lexicalGlobalObject()->stringPrototype(), DontEnum);
+ return true;
+}
+
+bool JSString::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
+{
+ // The semantics here are really getPropertySlot, not getOwnPropertySlot.
+ // This function should only be called by JSValue::get.
+ if (getStringPropertySlot(exec, propertyName, slot))
+ return true;
+ return JSString::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
}
} // namespace JSC