[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
barraclough at apple.com
barraclough at apple.com
Wed Dec 22 11:56:13 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit c2527d6451e9ac9b479e40c3e89ac3b668417b72
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Aug 11 19:52:41 2010 +0000
Rubber stamps by Darin Adler & Sam Weinig.
Bug 43867 - Some UString cleanup
Change JSC::UString data(), size(), and from(), to characters(), length(), and number() to match WTF::String.
Move string concatenation methods to a new header to simplify down UString.h. Remove is8Bit().
JavaScriptCore:
* API/JSClassRef.cpp:
(OpaqueJSClass::~OpaqueJSClass):
(OpaqueJSClass::className):
* API/OpaqueJSString.cpp:
(OpaqueJSString::create):
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecode/CodeBlock.cpp:
(JSC::constantName):
(JSC::idName):
(JSC::CodeBlock::registerName):
(JSC::regexpName):
* bytecode/EvalCodeCache.h:
(JSC::EvalCodeCache::get):
* bytecompiler/NodesCodegen.cpp:
(JSC::ResolveNode::emitBytecode):
(JSC::FunctionCallResolveNode::emitBytecode):
(JSC::ReadModifyResolveNode::emitBytecode):
(JSC::processClauseList):
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createRegex):
* parser/ParserArena.h:
(JSC::IdentifierArena::makeNumericIdentifier):
* parser/SourceProvider.h:
(JSC::UStringSourceProvider::data):
(JSC::UStringSourceProvider::length):
* profiler/Profiler.cpp:
* runtime/Arguments.cpp:
(JSC::Arguments::getOwnPropertySlot):
(JSC::Arguments::getOwnPropertyNames):
(JSC::Arguments::put):
(JSC::Arguments::deleteProperty):
* runtime/ArrayPrototype.cpp:
(JSC::arrayProtoFuncToString):
* runtime/DatePrototype.cpp:
(JSC::formatLocaleDate):
* runtime/ExceptionHelpers.cpp:
* runtime/FunctionConstructor.cpp:
* runtime/FunctionPrototype.cpp:
(JSC::insertSemicolonIfNeeded):
* runtime/Identifier.h:
(JSC::Identifier::characters):
(JSC::Identifier::length):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::decode):
(JSC::parseInt):
(JSC::parseFloat):
(JSC::globalFuncEscape):
(JSC::globalFuncUnescape):
* runtime/JSNumberCell.cpp:
(JSC::JSNumberCell::toString):
* runtime/JSONObject.cpp:
(JSC::gap):
(JSC::Stringifier::appendQuotedString):
(JSC::Stringifier::appendStringifiedValue):
(JSC::Stringifier::indent):
(JSC::Stringifier::unindent):
(JSC::Walker::walk):
* runtime/JSString.cpp:
(JSC::JSString::replaceCharacter):
(JSC::JSString::getIndexSlowCase):
* runtime/JSString.h:
(JSC::RopeBuilder::JSString):
(JSC::RopeBuilder::appendValueInConstructAndIncrementLength):
(JSC::RopeBuilder::fiberCount):
(JSC::jsSingleCharacterSubstring):
(JSC::jsNontrivialString):
(JSC::JSString::getIndex):
(JSC::jsString):
(JSC::jsStringWithFinalizer):
(JSC::jsSubstring):
(JSC::jsOwnedString):
* runtime/JSStringBuilder.h:
(JSC::JSStringBuilder::append):
* runtime/LiteralParser.h:
(JSC::LiteralParser::Lexer::Lexer):
* runtime/NumberPrototype.cpp:
(JSC::numberProtoFuncToString):
(JSC::numberProtoFuncToFixed):
(JSC::numberProtoFuncToExponential):
(JSC::numberProtoFuncToPrecision):
* runtime/NumericStrings.h:
(JSC::NumericStrings::add):
(JSC::NumericStrings::lookupSmallString):
* runtime/Operations.h:
(JSC::jsString):
* runtime/RegExp.cpp:
(JSC::RegExp::match):
* runtime/RegExpCache.cpp:
(JSC::RegExpCache::lookupOrCreate):
(JSC::RegExpCache::create):
* runtime/RegExpConstructor.cpp:
(JSC::RegExpConstructor::getRightContext):
* runtime/RegExpObject.cpp:
(JSC::RegExpObject::match):
* runtime/RegExpPrototype.cpp:
(JSC::regExpProtoFuncToString):
* runtime/StringBuilder.h:
(JSC::StringBuilder::append):
* runtime/StringConcatenate.h: Copied from JavaScriptCore/runtime/UString.h.
(JSC::):
(JSC::sumWithOverflow):
(JSC::tryMakeString):
(JSC::makeString):
* runtime/StringObject.cpp:
(JSC::StringObject::getOwnPropertyNames):
* runtime/StringPrototype.cpp:
(JSC::substituteBackreferencesSlow):
(JSC::localeCompare):
(JSC::jsSpliceSubstringsWithSeparators):
(JSC::stringProtoFuncReplace):
(JSC::stringProtoFuncCharAt):
(JSC::stringProtoFuncCharCodeAt):
(JSC::stringProtoFuncIndexOf):
(JSC::stringProtoFuncLastIndexOf):
(JSC::stringProtoFuncSlice):
(JSC::stringProtoFuncSplit):
(JSC::stringProtoFuncSubstr):
(JSC::stringProtoFuncSubstring):
(JSC::stringProtoFuncToLowerCase):
(JSC::stringProtoFuncToUpperCase):
(JSC::stringProtoFuncFontsize):
(JSC::stringProtoFuncLink):
(JSC::trimString):
* runtime/UString.cpp:
(JSC::UString::number):
(JSC::UString::ascii):
(JSC::UString::operator[]):
(JSC::UString::toDouble):
(JSC::UString::find):
(JSC::UString::rfind):
(JSC::UString::substr):
(JSC::operator==):
(JSC::operator<):
(JSC::operator>):
(JSC::UString::UTF8String):
* runtime/UString.h:
(JSC::UString::UString):
(JSC::UString::adopt):
(JSC::UString::length):
(JSC::UString::characters):
(JSC::UString::isNull):
(JSC::UString::isEmpty):
(JSC::UString::impl):
(JSC::UString::cost):
(JSC::operator==):
(JSC::operator!=):
(JSC::codePointCompare):
(JSC::UString::toArrayIndex):
(JSC::IdentifierRepHash::hash):
(WTF::):
* yarr/RegexJIT.cpp:
(JSC::Yarr::jitCompileRegex):
* yarr/RegexParser.h:
(JSC::Yarr::Parser::Parser):
JavaScriptGlue:
* JSUtils.cpp:
(UStringToCFString):
(KJSValueToCFTypeInternal):
* JavaScriptGlue.xcodeproj/project.pbxproj:
WebCore:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::hasCSSPropertyNamePrefix):
(WebCore::cssPropertyName):
* bindings/js/JSLocationCustom.cpp:
(WebCore::JSLocation::setPort):
* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::dispatchDidParseSource):
* bindings/js/ScriptString.h:
(WebCore::ScriptString::size):
* bindings/js/ScriptValue.cpp:
(WebCore::jsToInspectorValue):
* bindings/objc/WebScriptObject.mm:
(+[WebScriptObject _convertValueToObjcValue:originRootObject:rootObject:]):
* bridge/jni/jni_jsobject.mm:
(JavaJSObject::convertValueToJObject):
* bridge/jni/jsc/JNIUtilityPrivate.cpp:
(JSC::Bindings::convertArrayInstanceToJavaArray):
(JSC::Bindings::convertValueToJValue):
* bridge/objc/objc_runtime.mm:
(JSC::Bindings::callObjCFallbackObject):
WebKit/mac:
* WebView/WebScriptDebugger.mm:
(toNSString):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65177 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/API/JSClassRef.cpp b/JavaScriptCore/API/JSClassRef.cpp
index 60d1bce..decf493 100644
--- a/JavaScriptCore/API/JSClassRef.cpp
+++ b/JavaScriptCore/API/JSClassRef.cpp
@@ -113,7 +113,7 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass*
OpaqueJSClass::~OpaqueJSClass()
{
// The empty string is shared across threads & is an identifier, in all other cases we should have done a deep copy in className(), below.
- ASSERT(!m_className.size() || !m_className.impl()->isIdentifier());
+ ASSERT(!m_className.length() || !m_className.impl()->isIdentifier());
if (m_staticValues) {
OpaqueJSClassStaticValuesTable::const_iterator end = m_staticValues->end();
@@ -216,7 +216,7 @@ OpaqueJSClassContextData& OpaqueJSClass::contextData(ExecState* exec)
UString OpaqueJSClass::className()
{
// Make a deep copy, so that the caller has no chance to put the original into IdentifierTable.
- return UString(m_className.data(), m_className.size());
+ return UString(m_className.characters(), m_className.length());
}
OpaqueJSClassStaticValuesTable* OpaqueJSClass::staticValues(JSC::ExecState* exec)
diff --git a/JavaScriptCore/API/OpaqueJSString.cpp b/JavaScriptCore/API/OpaqueJSString.cpp
index c14f343..9a116e6 100644
--- a/JavaScriptCore/API/OpaqueJSString.cpp
+++ b/JavaScriptCore/API/OpaqueJSString.cpp
@@ -35,7 +35,7 @@ using namespace JSC;
PassRefPtr<OpaqueJSString> OpaqueJSString::create(const UString& ustring)
{
if (!ustring.isNull())
- return adoptRef(new OpaqueJSString(ustring.data(), ustring.size()));
+ return adoptRef(new OpaqueJSString(ustring.characters(), ustring.length()));
return 0;
}
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index a3e88eb..829bf3c 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,169 @@
+2010-08-11 Gavin Barraclough <barraclough at apple.com>
+
+ Rubber stamps by Darin Adler & Sam Weinig.
+
+ Bug 43867 - Some UString cleanup
+
+ Change JSC::UString data(), size(), and from(), to characters(), length(), and number() to match WTF::String.
+ Move string concatenation methods to a new header to simplify down UString.h. Remove is8Bit().
+
+ * API/JSClassRef.cpp:
+ (OpaqueJSClass::~OpaqueJSClass):
+ (OpaqueJSClass::className):
+ * API/OpaqueJSString.cpp:
+ (OpaqueJSString::create):
+ * JavaScriptCore.exp:
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * bytecode/CodeBlock.cpp:
+ (JSC::constantName):
+ (JSC::idName):
+ (JSC::CodeBlock::registerName):
+ (JSC::regexpName):
+ * bytecode/EvalCodeCache.h:
+ (JSC::EvalCodeCache::get):
+ * bytecompiler/NodesCodegen.cpp:
+ (JSC::ResolveNode::emitBytecode):
+ (JSC::FunctionCallResolveNode::emitBytecode):
+ (JSC::ReadModifyResolveNode::emitBytecode):
+ (JSC::processClauseList):
+ * parser/ASTBuilder.h:
+ (JSC::ASTBuilder::createRegex):
+ * parser/ParserArena.h:
+ (JSC::IdentifierArena::makeNumericIdentifier):
+ * parser/SourceProvider.h:
+ (JSC::UStringSourceProvider::data):
+ (JSC::UStringSourceProvider::length):
+ * profiler/Profiler.cpp:
+ * runtime/Arguments.cpp:
+ (JSC::Arguments::getOwnPropertySlot):
+ (JSC::Arguments::getOwnPropertyNames):
+ (JSC::Arguments::put):
+ (JSC::Arguments::deleteProperty):
+ * runtime/ArrayPrototype.cpp:
+ (JSC::arrayProtoFuncToString):
+ * runtime/DatePrototype.cpp:
+ (JSC::formatLocaleDate):
+ * runtime/ExceptionHelpers.cpp:
+ * runtime/FunctionConstructor.cpp:
+ * runtime/FunctionPrototype.cpp:
+ (JSC::insertSemicolonIfNeeded):
+ * runtime/Identifier.h:
+ (JSC::Identifier::characters):
+ (JSC::Identifier::length):
+ * runtime/JSGlobalObjectFunctions.cpp:
+ (JSC::decode):
+ (JSC::parseInt):
+ (JSC::parseFloat):
+ (JSC::globalFuncEscape):
+ (JSC::globalFuncUnescape):
+ * runtime/JSNumberCell.cpp:
+ (JSC::JSNumberCell::toString):
+ * runtime/JSONObject.cpp:
+ (JSC::gap):
+ (JSC::Stringifier::appendQuotedString):
+ (JSC::Stringifier::appendStringifiedValue):
+ (JSC::Stringifier::indent):
+ (JSC::Stringifier::unindent):
+ (JSC::Walker::walk):
+ * runtime/JSString.cpp:
+ (JSC::JSString::replaceCharacter):
+ (JSC::JSString::getIndexSlowCase):
+ * runtime/JSString.h:
+ (JSC::RopeBuilder::JSString):
+ (JSC::RopeBuilder::appendValueInConstructAndIncrementLength):
+ (JSC::RopeBuilder::fiberCount):
+ (JSC::jsSingleCharacterSubstring):
+ (JSC::jsNontrivialString):
+ (JSC::JSString::getIndex):
+ (JSC::jsString):
+ (JSC::jsStringWithFinalizer):
+ (JSC::jsSubstring):
+ (JSC::jsOwnedString):
+ * runtime/JSStringBuilder.h:
+ (JSC::JSStringBuilder::append):
+ * runtime/LiteralParser.h:
+ (JSC::LiteralParser::Lexer::Lexer):
+ * runtime/NumberPrototype.cpp:
+ (JSC::numberProtoFuncToString):
+ (JSC::numberProtoFuncToFixed):
+ (JSC::numberProtoFuncToExponential):
+ (JSC::numberProtoFuncToPrecision):
+ * runtime/NumericStrings.h:
+ (JSC::NumericStrings::add):
+ (JSC::NumericStrings::lookupSmallString):
+ * runtime/Operations.h:
+ (JSC::jsString):
+ * runtime/RegExp.cpp:
+ (JSC::RegExp::match):
+ * runtime/RegExpCache.cpp:
+ (JSC::RegExpCache::lookupOrCreate):
+ (JSC::RegExpCache::create):
+ * runtime/RegExpConstructor.cpp:
+ (JSC::RegExpConstructor::getRightContext):
+ * runtime/RegExpObject.cpp:
+ (JSC::RegExpObject::match):
+ * runtime/RegExpPrototype.cpp:
+ (JSC::regExpProtoFuncToString):
+ * runtime/StringBuilder.h:
+ (JSC::StringBuilder::append):
+ * runtime/StringConcatenate.h: Copied from JavaScriptCore/runtime/UString.h.
+ (JSC::):
+ (JSC::sumWithOverflow):
+ (JSC::tryMakeString):
+ (JSC::makeString):
+ * runtime/StringObject.cpp:
+ (JSC::StringObject::getOwnPropertyNames):
+ * runtime/StringPrototype.cpp:
+ (JSC::substituteBackreferencesSlow):
+ (JSC::localeCompare):
+ (JSC::jsSpliceSubstringsWithSeparators):
+ (JSC::stringProtoFuncReplace):
+ (JSC::stringProtoFuncCharAt):
+ (JSC::stringProtoFuncCharCodeAt):
+ (JSC::stringProtoFuncIndexOf):
+ (JSC::stringProtoFuncLastIndexOf):
+ (JSC::stringProtoFuncSlice):
+ (JSC::stringProtoFuncSplit):
+ (JSC::stringProtoFuncSubstr):
+ (JSC::stringProtoFuncSubstring):
+ (JSC::stringProtoFuncToLowerCase):
+ (JSC::stringProtoFuncToUpperCase):
+ (JSC::stringProtoFuncFontsize):
+ (JSC::stringProtoFuncLink):
+ (JSC::trimString):
+ * runtime/UString.cpp:
+ (JSC::UString::number):
+ (JSC::UString::ascii):
+ (JSC::UString::operator[]):
+ (JSC::UString::toDouble):
+ (JSC::UString::find):
+ (JSC::UString::rfind):
+ (JSC::UString::substr):
+ (JSC::operator==):
+ (JSC::operator<):
+ (JSC::operator>):
+ (JSC::UString::UTF8String):
+ * runtime/UString.h:
+ (JSC::UString::UString):
+ (JSC::UString::adopt):
+ (JSC::UString::length):
+ (JSC::UString::characters):
+ (JSC::UString::isNull):
+ (JSC::UString::isEmpty):
+ (JSC::UString::impl):
+ (JSC::UString::cost):
+ (JSC::operator==):
+ (JSC::operator!=):
+ (JSC::codePointCompare):
+ (JSC::UString::toArrayIndex):
+ (JSC::IdentifierRepHash::hash):
+ (WTF::):
+ * yarr/RegexJIT.cpp:
+ (JSC::Yarr::jitCompileRegex):
+ * yarr/RegexParser.h:
+ (JSC::Yarr::Parser::Parser):
+
2010-08-11 Gabor Loki <loki at webkit.org>
Qt build fix (ARMv7).
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index 241ed5c..66201cd 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -251,10 +251,10 @@ __ZN3JSC7Profile10restoreAllEv
__ZN3JSC7Profile5focusEPKNS_11ProfileNodeE
__ZN3JSC7Profile7excludeEPKNS_11ProfileNodeE
__ZN3JSC7Profile7forEachEMNS_11ProfileNodeEFvvE
-__ZN3JSC7UString4fromEd
-__ZN3JSC7UString4fromEi
-__ZN3JSC7UString4fromEj
-__ZN3JSC7UString4fromEl
+__ZN3JSC7UString6numberEd
+__ZN3JSC7UString6numberEi
+__ZN3JSC7UString6numberEj
+__ZN3JSC7UString6numberEl
__ZN3JSC7UStringC1EPKc
__ZN3JSC7UStringC1EPKtj
__ZN3JSC8Debugger23recompileAllJSFunctionsEPNS_12JSGlobalDataE
@@ -511,7 +511,6 @@ __ZNK3JSC7JSValue9toIntegerEPNS_9ExecStateE
__ZNK3JSC7UString10UTF8StringEb
__ZNK3JSC7UString14toStrictUInt32EPb
__ZNK3JSC7UString5asciiEv
-__ZNK3JSC7UString6is8BitEv
__ZNK3JSC7UString6substrEjj
__ZNK3JSC7UString8toUInt32EPb
__ZNK3JSC7UString8toUInt32EPbb
diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
index 90fd3ad..f67e85e 100644
--- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
+++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
@@ -146,9 +146,9 @@ EXPORTS
?free at WeakGCHandlePool@JSC@@QAEXPAVWeakGCHandle at 2@@Z
?from at Identifier@JSC@@SA?AV12 at PAVExecState@2 at H@Z
?from at Identifier@JSC@@SA?AV12 at PAVExecState@2 at I@Z
- ?from at UString@JSC@@SA?AV12 at H@Z
- ?from at UString@JSC@@SA?AV12 at I@Z
- ?from at UString@JSC@@SA?AV12 at N@Z
+ ?number at UString@JSC@@SA?AV12 at H@Z
+ ?number at UString@JSC@@SA?AV12 at I@Z
+ ?number at UString@JSC@@SA?AV12 at N@Z
?functionGetter at PropertySlot@JSC@@ABE?AVJSValue at 2@PAVExecState at 2@@Z
?functionName at DebuggerCallFrame@JSC@@QBEPBVUString at 2@XZ
?get at Structure@JSC@@QAEIPBVStringImpl at WTF@@AAIAAPAVJSCell at 2@@Z
diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
index 0873d6d..e59fc7a 100644
--- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
@@ -221,6 +221,7 @@
86A90ED00EE7D51F00AB350D /* JITArithmetic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86A90ECF0EE7D51F00AB350D /* JITArithmetic.cpp */; };
86ADD1450FDDEA980006EEC2 /* ARMv7Assembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 86ADD1430FDDEA980006EEC2 /* ARMv7Assembler.h */; };
86ADD1460FDDEA980006EEC2 /* MacroAssemblerARMv7.h in Headers */ = {isa = PBXBuildFile; fileRef = 86ADD1440FDDEA980006EEC2 /* MacroAssemblerARMv7.h */; };
+ 86B6DA0212132B9A000D316F /* StringConcatenate.h in Headers */ = {isa = PBXBuildFile; fileRef = 86B6DA0112132B9A000D316F /* StringConcatenate.h */; };
86B99AB8117E391E00DF5A90 /* RopeImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86B99AB6117E391E00DF5A90 /* RopeImpl.cpp */; };
86B99AB9117E391E00DF5A90 /* RopeImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 86B99AB7117E391E00DF5A90 /* RopeImpl.h */; settings = {ATTRIBUTES = (Private, ); }; };
86B99AE3117E578100DF5A90 /* StringBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 86B99AE1117E578100DF5A90 /* StringBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -808,6 +809,7 @@
86A90ECF0EE7D51F00AB350D /* JITArithmetic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITArithmetic.cpp; sourceTree = "<group>"; };
86ADD1430FDDEA980006EEC2 /* ARMv7Assembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARMv7Assembler.h; sourceTree = "<group>"; };
86ADD1440FDDEA980006EEC2 /* MacroAssemblerARMv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerARMv7.h; sourceTree = "<group>"; };
+ 86B6DA0112132B9A000D316F /* StringConcatenate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringConcatenate.h; sourceTree = "<group>"; };
86B99AB6117E391E00DF5A90 /* RopeImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RopeImpl.cpp; sourceTree = "<group>"; };
86B99AB7117E391E00DF5A90 /* RopeImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RopeImpl.h; sourceTree = "<group>"; };
86B99AE1117E578100DF5A90 /* StringBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringBuffer.h; path = text/StringBuffer.h; sourceTree = "<group>"; };
@@ -1751,6 +1753,7 @@
93303FE80E6A72B500786E6A /* SmallStrings.cpp */,
93303FEA0E6A72C000786E6A /* SmallStrings.h */,
8698B86810D44D9400D8D01B /* StringBuilder.h */,
+ 86B6DA0112132B9A000D316F /* StringConcatenate.h */,
BC18C3C00E16EE3300B34460 /* StringConstructor.cpp */,
BC18C3C10E16EE3300B34460 /* StringConstructor.h */,
BC18C3C20E16EE3300B34460 /* StringObject.cpp */,
@@ -2229,6 +2232,7 @@
DD2724691208D1FF00F9ABE7 /* AlignedMemoryAllocator.h in Headers */,
DDE82AD81209D955005C1756 /* GCHandle.h in Headers */,
86F38859121130CA007A7CE3 /* AtomicStringHash.h in Headers */,
+ 86B6DA0212132B9A000D316F /* StringConcatenate.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/JavaScriptCore/bytecode/CodeBlock.cpp b/JavaScriptCore/bytecode/CodeBlock.cpp
index 9a8c332..7d846d9 100644
--- a/JavaScriptCore/bytecode/CodeBlock.cpp
+++ b/JavaScriptCore/bytecode/CodeBlock.cpp
@@ -30,13 +30,14 @@
#include "config.h"
#include "CodeBlock.h"
-#include "JIT.h"
-#include "JSValue.h"
+#include "BytecodeGenerator.h"
+#include "Debugger.h"
#include "Interpreter.h"
+#include "JIT.h"
#include "JSFunction.h"
#include "JSStaticScopeObject.h"
-#include "Debugger.h"
-#include "BytecodeGenerator.h"
+#include "JSValue.h"
+#include "StringConcatenate.h"
#include <stdio.h>
#include <wtf/StringExtras.h>
@@ -70,12 +71,12 @@ static UString valueToSourceString(ExecState* exec, JSValue val)
static CString constantName(ExecState* exec, int k, JSValue value)
{
- return makeString(valueToSourceString(exec, value), "(@k", UString::from(k - FirstConstantRegisterIndex), ")").UTF8String();
+ return makeString(valueToSourceString(exec, value), "(@k", UString::number(k - FirstConstantRegisterIndex), ")").UTF8String();
}
static CString idName(int id0, const Identifier& ident)
{
- return makeString(ident.ustring(), "(@id", UString::from(id0), ")").UTF8String();
+ return makeString(ident.ustring(), "(@id", UString::number(id0), ")").UTF8String();
}
CString CodeBlock::registerName(ExecState* exec, int r) const
@@ -86,7 +87,7 @@ CString CodeBlock::registerName(ExecState* exec, int r) const
if (isConstantRegisterIndex(r))
return constantName(exec, r, getConstant(r));
- return makeString("r", UString::from(r)).UTF8String();
+ return makeString("r", UString::number(r)).UTF8String();
}
static UString regexpToSourceString(RegExp* regExp)
@@ -105,7 +106,7 @@ static UString regexpToSourceString(RegExp* regExp)
static CString regexpName(int re, RegExp* regexp)
{
- return makeString(regexpToSourceString(regexp), "(@re", UString::from(re), ")").UTF8String();
+ return makeString(regexpToSourceString(regexp), "(@re", UString::number(re), ")").UTF8String();
}
static UString pointerToSourceString(void* p)
diff --git a/JavaScriptCore/bytecode/EvalCodeCache.h b/JavaScriptCore/bytecode/EvalCodeCache.h
index 5607152..7c4cb33 100644
--- a/JavaScriptCore/bytecode/EvalCodeCache.h
+++ b/JavaScriptCore/bytecode/EvalCodeCache.h
@@ -47,7 +47,7 @@ namespace JSC {
{
RefPtr<EvalExecutable> evalExecutable;
- if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject())
+ if (evalSource.length() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject())
evalExecutable = m_cacheMap.get(evalSource.impl());
if (!evalExecutable) {
@@ -56,7 +56,7 @@ namespace JSC {
if (exceptionValue)
return 0;
- if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries)
+ if (evalSource.length() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries)
m_cacheMap.set(evalSource.impl(), evalExecutable);
}
diff --git a/JavaScriptCore/bytecompiler/NodesCodegen.cpp b/JavaScriptCore/bytecompiler/NodesCodegen.cpp
index 6c28746..dadf3f7 100644
--- a/JavaScriptCore/bytecompiler/NodesCodegen.cpp
+++ b/JavaScriptCore/bytecompiler/NodesCodegen.cpp
@@ -42,6 +42,7 @@
#include "RegExpCache.h"
#include "RegExpObject.h"
#include "SamplingTool.h"
+#include "StringConcatenate.h"
#include <wtf/Assertions.h>
#include <wtf/RefCountedLeakCounter.h>
#include <wtf/Threading.h>
@@ -177,7 +178,7 @@ RegisterID* ResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID*
return generator.moveToDestinationIfNeeded(dst, local);
}
- generator.emitExpressionInfo(m_startOffset + m_ident.size(), m_ident.size(), 0);
+ generator.emitExpressionInfo(m_startOffset + m_ident.length(), m_ident.length(), 0);
return generator.emitResolve(generator.finalDestination(dst), m_ident);
}
@@ -381,7 +382,7 @@ RegisterID* FunctionCallResolveNode::emitBytecode(BytecodeGenerator& generator,
RefPtr<RegisterID> func = generator.newTemporary();
CallArguments callArguments(generator, m_args);
int identifierStart = divot() - startOffset();
- generator.emitExpressionInfo(identifierStart + m_ident.size(), m_ident.size(), 0);
+ generator.emitExpressionInfo(identifierStart + m_ident.length(), m_ident.length(), 0);
generator.emitResolveWithBase(callArguments.thisRegister(), func.get(), m_ident);
return generator.emitCall(generator.finalDestinationOrIgnored(dst, func.get()), func.get(), callArguments, divot(), startOffset(), endOffset());
}
@@ -1183,7 +1184,7 @@ RegisterID* ReadModifyResolveNode::emitBytecode(BytecodeGenerator& generator, Re
}
RefPtr<RegisterID> src1 = generator.tempDestination(dst);
- generator.emitExpressionInfo(divot() - startOffset() + m_ident.size(), m_ident.size(), 0);
+ generator.emitExpressionInfo(divot() - startOffset() + m_ident.length(), m_ident.length(), 0);
RefPtr<RegisterID> base = generator.emitResolveWithBase(generator.newTemporary(), src1.get(), m_ident);
RegisterID* result = emitReadModifyAssignment(generator, generator.finalDestination(dst, src1.get()), src1.get(), m_right, m_operator, OperandTypes(ResultType::unknownType(), m_right->resultDescriptor()), this);
return generator.emitPutById(base.get(), m_ident, result);
@@ -1747,7 +1748,7 @@ static void processClauseList(ClauseListNode* list, Vector<ExpressionNode*, 8>&
break;
}
const UString& value = static_cast<StringNode*>(clauseExpression)->value().ustring();
- if (singleCharacterSwitch &= value.size() == 1) {
+ if (singleCharacterSwitch &= value.length() == 1) {
int32_t intVal = value.impl()->characters()[0];
if (intVal < min_num)
min_num = intVal;
diff --git a/JavaScriptCore/parser/ASTBuilder.h b/JavaScriptCore/parser/ASTBuilder.h
index f627756..dbf3c07 100644
--- a/JavaScriptCore/parser/ASTBuilder.h
+++ b/JavaScriptCore/parser/ASTBuilder.h
@@ -210,7 +210,7 @@ public:
ExpressionNode* createRegex(const Identifier& pattern, const Identifier& flags, int start)
{
RegExpNode* node = new (m_globalData) RegExpNode(m_globalData, pattern, flags);
- int size = pattern.size() + 2; // + 2 for the two /'s
+ int size = pattern.length() + 2; // + 2 for the two /'s
setExceptionLocation(node, start, start + size, start + size);
return node;
}
diff --git a/JavaScriptCore/parser/ParserArena.h b/JavaScriptCore/parser/ParserArena.h
index eef8e93..7c1809e 100644
--- a/JavaScriptCore/parser/ParserArena.h
+++ b/JavaScriptCore/parser/ParserArena.h
@@ -55,7 +55,7 @@ namespace JSC {
inline const Identifier& IdentifierArena::makeNumericIdentifier(JSGlobalData* globalData, double number)
{
- m_identifiers.append(Identifier(globalData, UString::from(number)));
+ m_identifiers.append(Identifier(globalData, UString::number(number)));
return m_identifiers.last();
}
diff --git a/JavaScriptCore/parser/SourceProvider.h b/JavaScriptCore/parser/SourceProvider.h
index 5a57542..d1b2bbb 100644
--- a/JavaScriptCore/parser/SourceProvider.h
+++ b/JavaScriptCore/parser/SourceProvider.h
@@ -69,8 +69,8 @@ namespace JSC {
{
return m_source.substr(start, end - start);
}
- const UChar* data() const { return m_source.data(); }
- int length() const { return m_source.size(); }
+ const UChar* data() const { return m_source.characters(); }
+ int length() const { return m_source.length(); }
private:
UStringSourceProvider(const UString& source, const UString& url)
diff --git a/JavaScriptCore/profiler/Profiler.cpp b/JavaScriptCore/profiler/Profiler.cpp
index 94e46a4..021ecff 100644
--- a/JavaScriptCore/profiler/Profiler.cpp
+++ b/JavaScriptCore/profiler/Profiler.cpp
@@ -39,6 +39,7 @@
#include "Profile.h"
#include "ProfileGenerator.h"
#include "ProfileNode.h"
+#include "StringConcatenate.h"
#include <stdio.h>
namespace JSC {
diff --git a/JavaScriptCore/runtime/Arguments.cpp b/JavaScriptCore/runtime/Arguments.cpp
index bb30e3b..916aac3 100644
--- a/JavaScriptCore/runtime/Arguments.cpp
+++ b/JavaScriptCore/runtime/Arguments.cpp
@@ -151,7 +151,7 @@ bool Arguments::getOwnPropertySlot(ExecState* exec, unsigned i, PropertySlot& sl
return true;
}
- return JSObject::getOwnPropertySlot(exec, Identifier(exec, UString::from(i)), slot);
+ return JSObject::getOwnPropertySlot(exec, Identifier(exec, UString::number(i)), slot);
}
bool Arguments::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
@@ -209,7 +209,7 @@ void Arguments::getOwnPropertyNames(ExecState* exec, PropertyNameArray& property
if (mode == IncludeDontEnumProperties) {
for (unsigned i = 0; i < d->numArguments; ++i) {
if (!d->deletedArguments || !d->deletedArguments[i])
- propertyNames.add(Identifier(exec, UString::from(i)));
+ propertyNames.add(Identifier(exec, UString::number(i)));
}
propertyNames.add(exec->propertyNames().callee);
propertyNames.add(exec->propertyNames().length);
@@ -227,7 +227,7 @@ void Arguments::put(ExecState* exec, unsigned i, JSValue value, PutPropertySlot&
return;
}
- JSObject::put(exec, Identifier(exec, UString::from(i)), value, slot);
+ JSObject::put(exec, Identifier(exec, UString::number(i)), value, slot);
}
void Arguments::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
@@ -270,7 +270,7 @@ bool Arguments::deleteProperty(ExecState* exec, unsigned i)
}
}
- return JSObject::deleteProperty(exec, Identifier(exec, UString::from(i)));
+ return JSObject::deleteProperty(exec, Identifier(exec, UString::number(i)));
}
bool Arguments::deleteProperty(ExecState* exec, const Identifier& propertyName)
diff --git a/JavaScriptCore/runtime/ArrayPrototype.cpp b/JavaScriptCore/runtime/ArrayPrototype.cpp
index 9d49eeb..e49ca28 100644
--- a/JavaScriptCore/runtime/ArrayPrototype.cpp
+++ b/JavaScriptCore/runtime/ArrayPrototype.cpp
@@ -179,7 +179,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec)
UString str = element.toString(exec);
strBuffer[k] = str.impl();
- totalSize += str.size();
+ totalSize += str.length();
if (!strBuffer.data()) {
throwOutOfMemoryError(exec);
diff --git a/JavaScriptCore/runtime/DatePrototype.cpp b/JavaScriptCore/runtime/DatePrototype.cpp
index 9dec33b..249f427 100644
--- a/JavaScriptCore/runtime/DatePrototype.cpp
+++ b/JavaScriptCore/runtime/DatePrototype.cpp
@@ -170,7 +170,7 @@ static JSCell* formatLocaleDate(ExecState* exec, DateInstance*, double timeInMil
CFRelease(locale);
if (useCustomFormat) {
- CFStringRef customFormatCFString = CFStringCreateWithCharacters(0, customFormatString.data(), customFormatString.size());
+ CFStringRef customFormatCFString = CFStringCreateWithCharacters(0, customFormatString.characters(), customFormatString.length());
CFDateFormatterSetFormat(formatter, customFormatCFString);
CFRelease(customFormatCFString);
}
diff --git a/JavaScriptCore/runtime/ExceptionHelpers.cpp b/JavaScriptCore/runtime/ExceptionHelpers.cpp
index 3e0b70c..871b2d5 100644
--- a/JavaScriptCore/runtime/ExceptionHelpers.cpp
+++ b/JavaScriptCore/runtime/ExceptionHelpers.cpp
@@ -36,6 +36,7 @@
#include "JSNotAnObject.h"
#include "Interpreter.h"
#include "Nodes.h"
+#include "StringConcatenate.h"
namespace JSC {
diff --git a/JavaScriptCore/runtime/FunctionConstructor.cpp b/JavaScriptCore/runtime/FunctionConstructor.cpp
index a036eef..f72a273 100644
--- a/JavaScriptCore/runtime/FunctionConstructor.cpp
+++ b/JavaScriptCore/runtime/FunctionConstructor.cpp
@@ -31,6 +31,7 @@
#include "Nodes.h"
#include "Parser.h"
#include "StringBuilder.h"
+#include "StringConcatenate.h"
namespace JSC {
diff --git a/JavaScriptCore/runtime/FunctionPrototype.cpp b/JavaScriptCore/runtime/FunctionPrototype.cpp
index fb2f627..a55d90a 100644
--- a/JavaScriptCore/runtime/FunctionPrototype.cpp
+++ b/JavaScriptCore/runtime/FunctionPrototype.cpp
@@ -71,13 +71,13 @@ CallType FunctionPrototype::getCallData(CallData& callData)
static inline void insertSemicolonIfNeeded(UString& functionBody)
{
ASSERT(functionBody[0] == '{');
- ASSERT(functionBody[functionBody.size() - 1] == '}');
+ ASSERT(functionBody[functionBody.length() - 1] == '}');
- for (size_t i = functionBody.size() - 2; i > 0; --i) {
+ for (size_t i = functionBody.length() - 2; i > 0; --i) {
UChar ch = functionBody[i];
if (!Lexer::isWhiteSpace(ch) && !Lexer::isLineTerminator(ch)) {
if (ch != ';' && ch != '}')
- functionBody = makeString(functionBody.substr(0, i + 1), ";", functionBody.substr(i + 1, functionBody.size() - (i + 1)));
+ functionBody = makeString(functionBody.substr(0, i + 1), ";", functionBody.substr(i + 1, functionBody.length() - (i + 1)));
return;
}
}
diff --git a/JavaScriptCore/runtime/Identifier.h b/JavaScriptCore/runtime/Identifier.h
index 69cf1fb..25535a4 100644
--- a/JavaScriptCore/runtime/Identifier.h
+++ b/JavaScriptCore/runtime/Identifier.h
@@ -50,8 +50,8 @@ namespace JSC {
const UString& ustring() const { return m_string; }
StringImpl* impl() const { return m_string.impl(); }
- const UChar* data() const { return m_string.data(); }
- int size() const { return m_string.size(); }
+ const UChar* characters() const { return m_string.characters(); }
+ int length() const { return m_string.length(); }
const char* ascii() const { return m_string.ascii(); }
diff --git a/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp b/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
index d88d6a9..5b111fa 100644
--- a/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
+++ b/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
@@ -77,8 +77,8 @@ static JSValue decode(ExecState* exec, const char* doNotUnescape, bool strict)
JSStringBuilder builder;
UString str = exec->argument(0).toString(exec);
int k = 0;
- int len = str.size();
- const UChar* d = str.data();
+ int len = str.length();
+ const UChar* d = str.characters();
UChar u = 0;
while (k < len) {
const UChar* p = d + k;
@@ -220,8 +220,8 @@ double parseIntOverflow(const UChar* s, int length, int radix)
static double parseInt(const UString& s, int radix)
{
- int length = s.size();
- const UChar* data = s.data();
+ int length = s.length();
+ const UChar* data = s.characters();
int p = 0;
while (p < length && isStrWhiteSpace(data[p]))
@@ -280,8 +280,8 @@ static double parseFloat(const UString& s)
{
// Check for 0x prefix here, because toDouble allows it, but we must treat it as 0.
// Need to skip any whitespace and then one + or - sign.
- int length = s.size();
- const UChar* data = s.data();
+ int length = s.length();
+ const UChar* data = s.characters();
int p = 0;
while (p < length && isStrWhiteSpace(data[p]))
++p;
@@ -404,8 +404,8 @@ EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec)
JSStringBuilder builder;
UString str = exec->argument(0).toString(exec);
- const UChar* c = str.data();
- for (unsigned k = 0; k < str.size(); k++, c++) {
+ const UChar* c = str.characters();
+ for (unsigned k = 0; k < str.length(); k++, c++) {
int u = c[0];
if (u > 255) {
char tmp[7];
@@ -428,9 +428,9 @@ EncodedJSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec)
StringBuilder builder;
UString str = exec->argument(0).toString(exec);
int k = 0;
- int len = str.size();
+ int len = str.length();
while (k < len) {
- const UChar* c = str.data() + k;
+ const UChar* c = str.characters() + k;
UChar u;
if (c[0] == '%' && k <= len - 6 && c[1] == 'u') {
if (isASCIIHexDigit(c[2]) && isASCIIHexDigit(c[3]) && isASCIIHexDigit(c[4]) && isASCIIHexDigit(c[5])) {
diff --git a/JavaScriptCore/runtime/JSNumberCell.cpp b/JavaScriptCore/runtime/JSNumberCell.cpp
index a61c751..77388e0 100644
--- a/JavaScriptCore/runtime/JSNumberCell.cpp
+++ b/JavaScriptCore/runtime/JSNumberCell.cpp
@@ -54,7 +54,7 @@ double JSNumberCell::toNumber(ExecState*) const
UString JSNumberCell::toString(ExecState*) const
{
- return UString::from(m_value);
+ return UString::number(m_value);
}
JSObject* JSNumberCell::toObject(ExecState* exec) const
diff --git a/JavaScriptCore/runtime/JSONObject.cpp b/JavaScriptCore/runtime/JSONObject.cpp
index ccfd43a..628e619 100644
--- a/JavaScriptCore/runtime/JSONObject.cpp
+++ b/JavaScriptCore/runtime/JSONObject.cpp
@@ -35,6 +35,7 @@
#include "Lookup.h"
#include "PropertyNameArray.h"
#include "StringBuilder.h"
+#include "StringConcatenate.h"
#include <wtf/MathExtras.h>
namespace JSC {
@@ -163,7 +164,7 @@ static inline UString gap(ExecState* exec, JSValue space)
// If the space value is a string, use it as the gap string, otherwise use no gap string.
UString spaces = space.getString(exec);
- if (spaces.size() > maxGapLength) {
+ if (spaces.length() > maxGapLength) {
spaces = spaces.substr(0, maxGapLength);
}
return spaces;
@@ -280,14 +281,14 @@ JSValue Stringifier::stringify(JSValue value)
void Stringifier::appendQuotedString(StringBuilder& builder, const UString& value)
{
- int length = value.size();
+ int length = value.length();
// String length plus 2 for quote marks plus 8 so we can accomodate a few escaped characters.
builder.reserveCapacity(builder.size() + length + 2 + 8);
builder.append('"');
- const UChar* data = value.data();
+ const UChar* data = value.characters();
for (int i = 0; i < length; ++i) {
int start = i;
while (i < length && (data[i] > 0x1F && data[i] != '"' && data[i] != '\\'))
@@ -405,7 +406,7 @@ Stringifier::StringifyResult Stringifier::appendStringifiedValue(StringBuilder&
if (!isfinite(numericValue))
builder.append("null");
else
- builder.append(UString::from(numericValue));
+ builder.append(UString::number(numericValue));
return StringifySucceeded;
}
@@ -463,17 +464,17 @@ inline bool Stringifier::willIndent() const
inline void Stringifier::indent()
{
// Use a single shared string, m_repeatedGap, so we don't keep allocating new ones as we indent and unindent.
- unsigned newSize = m_indent.size() + m_gap.size();
- if (newSize > m_repeatedGap.size())
+ unsigned newSize = m_indent.length() + m_gap.length();
+ if (newSize > m_repeatedGap.length())
m_repeatedGap = makeString(m_repeatedGap, m_gap);
- ASSERT(newSize <= m_repeatedGap.size());
+ ASSERT(newSize <= m_repeatedGap.length());
m_indent = m_repeatedGap.substr(0, newSize);
}
inline void Stringifier::unindent()
{
- ASSERT(m_indent.size() >= m_gap.size());
- m_indent = m_repeatedGap.substr(0, m_indent.size() - m_gap.size());
+ ASSERT(m_indent.length() >= m_gap.length());
+ m_indent = m_repeatedGap.substr(0, m_indent.length() - m_gap.length());
}
inline void Stringifier::startNewLine(StringBuilder& builder) const
@@ -722,7 +723,7 @@ NEVER_INLINE JSValue Walker::walk(JSValue unfiltered)
}
case ArrayEndVisitMember: {
JSArray* array = arrayStack.last();
- JSValue filteredValue = callReviver(array, jsString(m_exec, UString::from(indexStack.last())), outValue);
+ JSValue filteredValue = callReviver(array, jsString(m_exec, UString::number(indexStack.last())), outValue);
if (filteredValue.isUndefined())
array->deleteProperty(m_exec, indexStack.last());
else {
diff --git a/JavaScriptCore/runtime/JSString.cpp b/JavaScriptCore/runtime/JSString.cpp
index dab1de9..4e6efc9 100644
--- a/JavaScriptCore/runtime/JSString.cpp
+++ b/JavaScriptCore/runtime/JSString.cpp
@@ -135,7 +135,7 @@ JSValue JSString::replaceCharacter(ExecState* exec, UChar character, const UStri
if (!matchString)
return this;
- RopeBuilder builder(replacement.size() ? fiberCount + 2 : fiberCount + 1);
+ RopeBuilder builder(replacement.length() ? fiberCount + 2 : fiberCount + 1);
if (UNLIKELY(builder.isOutOfMemory()))
return throwOutOfMemoryError(exec);
@@ -147,7 +147,7 @@ JSValue JSString::replaceCharacter(ExecState* exec, UChar character, const UStri
}
builder.append(UString(string).substr(0, matchPosition));
- if (replacement.size())
+ if (replacement.length())
builder.append(replacement);
builder.append(UString(string).substr(matchPosition + 1));
matchString = 0;
@@ -165,7 +165,7 @@ JSString* JSString::getIndexSlowCase(ExecState* exec, unsigned i)
if (exec->exception())
return jsString(exec, "");
ASSERT(!isRope());
- ASSERT(i < m_value.size());
+ ASSERT(i < m_value.length());
return jsSingleCharacterSubstring(exec, m_value, i);
}
diff --git a/JavaScriptCore/runtime/JSString.h b/JavaScriptCore/runtime/JSString.h
index 6e48af2..499da89 100644
--- a/JavaScriptCore/runtime/JSString.h
+++ b/JavaScriptCore/runtime/JSString.h
@@ -186,7 +186,7 @@ namespace JSC {
ALWAYS_INLINE JSString(JSGlobalData* globalData, const UString& value)
: JSCell(globalData->stringStructure.get())
- , m_length(value.size())
+ , m_length(value.length())
, m_value(value)
, m_fiberCount(0)
{
@@ -197,7 +197,7 @@ namespace JSC {
enum HasOtherOwnerType { HasOtherOwner };
JSString(JSGlobalData* globalData, const UString& value, HasOtherOwnerType)
: JSCell(globalData->stringStructure.get())
- , m_length(value.size())
+ , m_length(value.length())
, m_value(value)
, m_fiberCount(0)
{
@@ -235,7 +235,7 @@ namespace JSC {
// This should only be called with fiberCount <= 3.
JSString(JSGlobalData* globalData, unsigned fiberCount, JSString* s1, const UString& u2)
: JSCell(globalData->stringStructure.get())
- , m_length(s1->length() + u2.size())
+ , m_length(s1->length() + u2.length())
, m_fiberCount(fiberCount)
{
ASSERT(fiberCount <= s_maxInternalRopeLength);
@@ -248,7 +248,7 @@ namespace JSC {
// This should only be called with fiberCount <= 3.
JSString(JSGlobalData* globalData, unsigned fiberCount, const UString& u1, JSString* s2)
: JSCell(globalData->stringStructure.get())
- , m_length(u1.size() + s2->length())
+ , m_length(u1.length() + s2->length())
, m_fiberCount(fiberCount)
{
ASSERT(fiberCount <= s_maxInternalRopeLength);
@@ -276,7 +276,7 @@ namespace JSC {
// This constructor constructs a new string by concatenating u1 & u2.
JSString(JSGlobalData* globalData, const UString& u1, const UString& u2)
: JSCell(globalData->stringStructure.get())
- , m_length(u1.size() + u2.size())
+ , m_length(u1.length() + u2.length())
, m_fiberCount(2)
{
unsigned index = 0;
@@ -288,7 +288,7 @@ namespace JSC {
// This constructor constructs a new string by concatenating u1, u2 & u3.
JSString(JSGlobalData* globalData, const UString& u1, const UString& u2, const UString& u3)
: JSCell(globalData->stringStructure.get())
- , m_length(u1.size() + u2.size() + u3.size())
+ , m_length(u1.length() + u2.length() + u3.length())
, m_fiberCount(s_maxInternalRopeLength)
{
unsigned index = 0;
@@ -300,7 +300,7 @@ namespace JSC {
JSString(JSGlobalData* globalData, const UString& value, JSStringFinalizerCallback finalizer, void* context)
: JSCell(globalData->stringStructure.get())
- , m_length(value.size())
+ , m_length(value.length())
, m_value(value)
, m_fiberCount(0)
{
@@ -381,7 +381,7 @@ namespace JSC {
if (v.isString()) {
ASSERT(asCell(v)->isString());
JSString* s = static_cast<JSString*>(asCell(v));
- ASSERT(s->size() == 1);
+ ASSERT(s->fiberCount() == 1);
appendStringInConstruct(index, s);
m_length += s->length();
} else {
@@ -389,7 +389,7 @@ namespace JSC {
StringImpl* impl = u.impl();
impl->ref();
m_other.m_fibers[index++] = impl;
- m_length += u.size();
+ m_length += u.length();
}
}
@@ -427,7 +427,7 @@ namespace JSC {
bool isRope() const { return m_fiberCount; }
UString& string() { ASSERT(!isRope()); return m_value; }
- unsigned size() { return m_fiberCount ? m_fiberCount : 1; }
+ unsigned fiberCount() { return m_fiberCount ? m_fiberCount : 1; }
friend JSValue jsString(ExecState* exec, JSString* s1, JSString* s2);
friend JSValue jsString(ExecState* exec, const UString& u1, JSString* s2);
@@ -470,8 +470,8 @@ namespace JSC {
inline JSString* jsSingleCharacterSubstring(ExecState* exec, const UString& s, unsigned offset)
{
JSGlobalData* globalData = &exec->globalData();
- ASSERT(offset < static_cast<unsigned>(s.size()));
- UChar c = s.data()[offset];
+ ASSERT(offset < static_cast<unsigned>(s.length()));
+ UChar c = s.characters()[offset];
if (c <= 0xFF)
return globalData->smallStrings.singleCharacterString(globalData, c);
return fixupVPtr(globalData, new (globalData) JSString(globalData, UString(StringImpl::create(s.impl(), offset, 1))));
@@ -487,7 +487,7 @@ namespace JSC {
inline JSString* jsNontrivialString(JSGlobalData* globalData, const UString& s)
{
- ASSERT(s.size() > 1);
+ ASSERT(s.length() > 1);
return fixupVPtr(globalData, new (globalData) JSString(globalData, s));
}
@@ -496,17 +496,17 @@ namespace JSC {
ASSERT(canGetIndex(i));
if (isRope())
return getIndexSlowCase(exec, i);
- ASSERT(i < m_value.size());
+ ASSERT(i < m_value.length());
return jsSingleCharacterSubstring(exec, m_value, i);
}
inline JSString* jsString(JSGlobalData* globalData, const UString& s)
{
- int size = s.size();
+ int size = s.length();
if (!size)
return globalData->smallStrings.emptyString(globalData);
if (size == 1) {
- UChar c = s.data()[0];
+ UChar c = s.characters()[0];
if (c <= 0xFF)
return globalData->smallStrings.singleCharacterString(globalData, c);
}
@@ -515,20 +515,20 @@ namespace JSC {
inline JSString* jsStringWithFinalizer(ExecState* exec, const UString& s, JSStringFinalizerCallback callback, void* context)
{
- ASSERT(s.size() && (s.size() > 1 || s.data()[0] > 0xFF));
+ ASSERT(s.length() && (s.length() > 1 || s.characters()[0] > 0xFF));
JSGlobalData* globalData = &exec->globalData();
return fixupVPtr(globalData, new (globalData) JSString(globalData, s, callback, context));
}
inline 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()));
+ ASSERT(offset <= static_cast<unsigned>(s.length()));
+ ASSERT(length <= static_cast<unsigned>(s.length()));
+ ASSERT(offset + length <= static_cast<unsigned>(s.length()));
if (!length)
return globalData->smallStrings.emptyString(globalData);
if (length == 1) {
- UChar c = s.data()[offset];
+ UChar c = s.characters()[offset];
if (c <= 0xFF)
return globalData->smallStrings.singleCharacterString(globalData, c);
}
@@ -537,11 +537,11 @@ namespace JSC {
inline JSString* jsOwnedString(JSGlobalData* globalData, const UString& s)
{
- int size = s.size();
+ int size = s.length();
if (!size)
return globalData->smallStrings.emptyString(globalData);
if (size == 1) {
- UChar c = s.data()[0];
+ UChar c = s.characters()[0];
if (c <= 0xFF)
return globalData->smallStrings.singleCharacterString(globalData, c);
}
diff --git a/JavaScriptCore/runtime/JSStringBuilder.h b/JavaScriptCore/runtime/JSStringBuilder.h
index 406353c..25fe685 100644
--- a/JavaScriptCore/runtime/JSStringBuilder.h
+++ b/JavaScriptCore/runtime/JSStringBuilder.h
@@ -28,6 +28,7 @@
#include "ExceptionHelpers.h"
#include "JSString.h"
+#include "StringConcatenate.h"
#include "Vector.h"
namespace JSC {
@@ -65,7 +66,7 @@ public:
void append(const UString& str)
{
- m_okay &= buffer.tryAppend(str.data(), str.size());
+ m_okay &= buffer.tryAppend(str.characters(), str.length());
}
JSValue build(ExecState* exec)
diff --git a/JavaScriptCore/runtime/LiteralParser.h b/JavaScriptCore/runtime/LiteralParser.h
index 0f8072b..6df5d06 100644
--- a/JavaScriptCore/runtime/LiteralParser.h
+++ b/JavaScriptCore/runtime/LiteralParser.h
@@ -72,8 +72,8 @@ namespace JSC {
Lexer(const UString& s, ParserMode mode)
: m_string(s)
, m_mode(mode)
- , m_ptr(s.data())
- , m_end(s.data() + s.size())
+ , m_ptr(s.characters())
+ , m_end(s.characters() + s.length())
{
}
diff --git a/JavaScriptCore/runtime/NumberPrototype.cpp b/JavaScriptCore/runtime/NumberPrototype.cpp
index e338d7c..7be8c73 100644
--- a/JavaScriptCore/runtime/NumberPrototype.cpp
+++ b/JavaScriptCore/runtime/NumberPrototype.cpp
@@ -179,7 +179,7 @@ EncodedJSValue JSC_HOST_CALL numberProtoFuncToString(ExecState* exec)
const char* lastCharInString = s + sizeof(s) - 1;
double x = v.uncheckedGetNumber();
if (isnan(x) || isinf(x))
- return JSValue::encode(jsString(exec, UString::from(x)));
+ return JSValue::encode(jsString(exec, UString::number(x)));
bool isNegative = x < 0.0;
if (isNegative)
@@ -271,7 +271,7 @@ EncodedJSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState* exec)
}
if (x >= pow(10.0, 21.0))
- return JSValue::encode(jsString(exec, makeString(s, UString::from(x))));
+ return JSValue::encode(jsString(exec, makeString(s, UString::number(x))));
const double tenToTheF = pow(10.0, f);
double n = floor(x * tenToTheF);
@@ -280,7 +280,7 @@ EncodedJSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState* exec)
UString m = integerPartNoExp(n);
- int k = m.size();
+ int k = m.length();
if (k <= f) {
StringBuilder z;
for (int i = 0; i < f + 1 - k; i++)
@@ -288,11 +288,11 @@ EncodedJSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState* exec)
z.append(m);
m = z.build();
k = f + 1;
- ASSERT(k == static_cast<int>(m.size()));
+ ASSERT(k == static_cast<int>(m.length()));
}
int kMinusf = k - f;
- if (kMinusf < static_cast<int>(m.size()))
+ if (kMinusf < static_cast<int>(m.length()))
return JSValue::encode(jsString(exec, makeString(s, m.substr(0, kMinusf), ".", m.substr(kMinusf))));
return JSValue::encode(jsString(exec, makeString(s, m.substr(0, kMinusf))));
}
@@ -345,7 +345,7 @@ EncodedJSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState* exec)
double x = v.uncheckedGetNumber();
if (isnan(x) || isinf(x))
- return JSValue::encode(jsString(exec, UString::from(x)));
+ return JSValue::encode(jsString(exec, UString::number(x)));
JSValue fractionalDigitsValue = exec->argument(0);
double df = fractionalDigitsValue.toInteger(exec);
@@ -455,11 +455,11 @@ EncodedJSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState* exec)
m = integerPartNoExp(n);
if (e < -6 || e >= precision) {
- if (m.size() > 1)
+ if (m.length() > 1)
m = makeString(m.substr(0, 1), ".", m.substr(1));
if (e >= 0)
- return JSValue::encode(jsMakeNontrivialString(exec, s, m, "e+", UString::from(e)));
- return JSValue::encode(jsMakeNontrivialString(exec, s, m, "e-", UString::from(-e)));
+ return JSValue::encode(jsMakeNontrivialString(exec, s, m, "e+", UString::number(e)));
+ return JSValue::encode(jsMakeNontrivialString(exec, s, m, "e-", UString::number(-e)));
}
} else {
m = charSequence('0', precision);
@@ -469,7 +469,7 @@ EncodedJSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState* exec)
if (e == precision - 1)
return JSValue::encode(jsString(exec, makeString(s, m)));
if (e >= 0) {
- if (e + 1 < static_cast<int>(m.size()))
+ if (e + 1 < static_cast<int>(m.length()))
return JSValue::encode(jsString(exec, makeString(s, m.substr(0, e + 1), ".", m.substr(e + 1))));
return JSValue::encode(jsString(exec, makeString(s, m)));
}
diff --git a/JavaScriptCore/runtime/NumericStrings.h b/JavaScriptCore/runtime/NumericStrings.h
index 47fbbb2..d65f142 100644
--- a/JavaScriptCore/runtime/NumericStrings.h
+++ b/JavaScriptCore/runtime/NumericStrings.h
@@ -40,7 +40,7 @@ namespace JSC {
if (d == entry.key && !entry.value.isNull())
return entry.value;
entry.key = d;
- entry.value = UString::from(d);
+ entry.value = UString::number(d);
return entry.value;
}
@@ -52,7 +52,7 @@ namespace JSC {
if (i == entry.key && !entry.value.isNull())
return entry.value;
entry.key = i;
- entry.value = UString::from(i);
+ entry.value = UString::number(i);
return entry.value;
}
@@ -64,7 +64,7 @@ namespace JSC {
if (i == entry.key && !entry.value.isNull())
return entry.value;
entry.key = i;
- entry.value = UString::from(i);
+ entry.value = UString::number(i);
return entry.value;
}
private:
@@ -83,7 +83,7 @@ namespace JSC {
{
ASSERT(i < cacheSize);
if (smallIntCache[i].isNull())
- smallIntCache[i] = UString::from(i);
+ smallIntCache[i] = UString::number(i);
return smallIntCache[i];
}
diff --git a/JavaScriptCore/runtime/Operations.h b/JavaScriptCore/runtime/Operations.h
index bd6c205..eed1f16 100644
--- a/JavaScriptCore/runtime/Operations.h
+++ b/JavaScriptCore/runtime/Operations.h
@@ -46,7 +46,7 @@ namespace JSC {
if ((length1 + length2) < length1)
return throwOutOfMemoryError(exec);
- unsigned fiberCount = s1->size() + s2->size();
+ unsigned fiberCount = s1->fiberCount() + s2->fiberCount();
JSGlobalData* globalData = &exec->globalData();
if (fiberCount <= JSString::s_maxInternalRopeLength)
@@ -62,7 +62,7 @@ namespace JSC {
ALWAYS_INLINE JSValue jsString(ExecState* exec, const UString& u1, JSString* s2)
{
- unsigned length1 = u1.size();
+ unsigned length1 = u1.length();
if (!length1)
return s2;
unsigned length2 = s2->length();
@@ -71,7 +71,7 @@ namespace JSC {
if ((length1 + length2) < length1)
return throwOutOfMemoryError(exec);
- unsigned fiberCount = 1 + s2->size();
+ unsigned fiberCount = 1 + s2->fiberCount();
JSGlobalData* globalData = &exec->globalData();
if (fiberCount <= JSString::s_maxInternalRopeLength)
@@ -90,13 +90,13 @@ namespace JSC {
unsigned length1 = s1->length();
if (!length1)
return jsString(exec, u2);
- unsigned length2 = u2.size();
+ unsigned length2 = u2.length();
if (!length2)
return s1;
if ((length1 + length2) < length1)
return throwOutOfMemoryError(exec);
- unsigned fiberCount = s1->size() + 1;
+ unsigned fiberCount = s1->fiberCount() + 1;
JSGlobalData* globalData = &exec->globalData();
if (fiberCount <= JSString::s_maxInternalRopeLength)
@@ -112,10 +112,10 @@ namespace JSC {
ALWAYS_INLINE JSValue jsString(ExecState* exec, const UString& u1, const UString& u2)
{
- unsigned length1 = u1.size();
+ unsigned length1 = u1.length();
if (!length1)
return jsString(exec, u2);
- unsigned length2 = u2.size();
+ unsigned length2 = u2.length();
if (!length2)
return jsString(exec, u1);
if ((length1 + length2) < length1)
@@ -127,9 +127,9 @@ namespace JSC {
ALWAYS_INLINE JSValue jsString(ExecState* exec, const UString& u1, const UString& u2, const UString& u3)
{
- unsigned length1 = u1.size();
- unsigned length2 = u2.size();
- unsigned length3 = u3.size();
+ unsigned length1 = u1.length();
+ unsigned length2 = u2.length();
+ unsigned length3 = u3.length();
if (!length1)
return jsString(exec, u2, u3);
if (!length2)
@@ -154,7 +154,7 @@ namespace JSC {
for (unsigned i = 0; i < count; ++i) {
JSValue v = strings[i].jsValue();
if (LIKELY(v.isString()))
- fiberCount += asString(v)->size();
+ fiberCount += asString(v)->fiberCount();
else
++fiberCount;
}
@@ -193,13 +193,13 @@ namespace JSC {
{
unsigned fiberCount = 0;
if (LIKELY(thisValue.isString()))
- fiberCount += asString(thisValue)->size();
+ fiberCount += asString(thisValue)->fiberCount();
else
++fiberCount;
for (unsigned i = 0; i < exec->argumentCount(); ++i) {
JSValue v = exec->argument(i);
if (LIKELY(v.isString()))
- fiberCount += asString(v)->size();
+ fiberCount += asString(v)->fiberCount();
else
++fiberCount;
}
diff --git a/JavaScriptCore/runtime/RegExp.cpp b/JavaScriptCore/runtime/RegExp.cpp
index c674ead..32836fc 100644
--- a/JavaScriptCore/runtime/RegExp.cpp
+++ b/JavaScriptCore/runtime/RegExp.cpp
@@ -96,7 +96,7 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
if (ovector)
ovector->resize(0);
- if (static_cast<unsigned>(startOffset) > s.size() || s.isNull()) {
+ if (static_cast<unsigned>(startOffset) > s.length() || s.isNull()) {
m_lastMatchString = UString();
m_lastMatchStart = -1;
m_lastOVector.shrink(0);
@@ -136,9 +136,9 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
offsetVector[j] = -1;
#if ENABLE(YARR_JIT)
- int result = Yarr::executeRegex(m_regExpJITCode, s.data(), startOffset, s.size(), offsetVector, offsetVectorSize);
+ int result = Yarr::executeRegex(m_regExpJITCode, s.characters(), startOffset, s.length(), offsetVector, offsetVectorSize);
#else
- int result = Yarr::interpretRegex(m_regExpBytecode.get(), s.data(), startOffset, s.size(), offsetVector);
+ int result = Yarr::interpretRegex(m_regExpBytecode.get(), s.characters(), startOffset, s.length(), offsetVector);
#endif
if (result < 0) {
diff --git a/JavaScriptCore/runtime/RegExpCache.cpp b/JavaScriptCore/runtime/RegExpCache.cpp
index 9ab8cee..d101758 100644
--- a/JavaScriptCore/runtime/RegExpCache.cpp
+++ b/JavaScriptCore/runtime/RegExpCache.cpp
@@ -33,7 +33,7 @@ namespace JSC {
PassRefPtr<RegExp> RegExpCache::lookupOrCreate(const UString& patternString, const UString& flags)
{
- if (patternString.size() < maxCacheablePatternLength) {
+ if (patternString.length() < maxCacheablePatternLength) {
pair<RegExpCacheMap::iterator, bool> result = m_cacheMap.add(RegExpKey(flags, patternString), 0);
if (!result.second)
return result.first->second;
@@ -47,7 +47,7 @@ PassRefPtr<RegExp> RegExpCache::create(const UString& patternString, const UStri
{
RefPtr<RegExp> regExp = RegExp::create(m_globalData, patternString, flags);
- if (patternString.size() >= maxCacheablePatternLength)
+ if (patternString.length() >= maxCacheablePatternLength)
return regExp;
RegExpKey key = RegExpKey(flags, patternString);
diff --git a/JavaScriptCore/runtime/RegExpConstructor.cpp b/JavaScriptCore/runtime/RegExpConstructor.cpp
index aff83e7..214e528 100644
--- a/JavaScriptCore/runtime/RegExpConstructor.cpp
+++ b/JavaScriptCore/runtime/RegExpConstructor.cpp
@@ -35,6 +35,7 @@
#include "RegExpPrototype.h"
#include "RegExp.h"
#include "RegExpCache.h"
+#include "StringConcatenate.h"
#include <wtf/PassOwnPtr.h>
namespace JSC {
@@ -185,7 +186,7 @@ JSValue RegExpConstructor::getLeftContext(ExecState* exec) const
JSValue RegExpConstructor::getRightContext(ExecState* exec) const
{
if (!d->lastOvector().isEmpty())
- return jsSubstring(exec, d->lastInput, d->lastOvector()[1], d->lastInput.size() - d->lastOvector()[1]);
+ return jsSubstring(exec, d->lastInput, d->lastOvector()[1], d->lastInput.length() - d->lastOvector()[1]);
return jsEmptyString(exec);
}
diff --git a/JavaScriptCore/runtime/RegExpObject.cpp b/JavaScriptCore/runtime/RegExpObject.cpp
index 0f2c1e1..4462879 100644
--- a/JavaScriptCore/runtime/RegExpObject.cpp
+++ b/JavaScriptCore/runtime/RegExpObject.cpp
@@ -29,6 +29,7 @@
#include "Lookup.h"
#include "RegExpConstructor.h"
#include "RegExpPrototype.h"
+#include "StringConcatenate.h"
#include <wtf/PassOwnPtr.h>
namespace JSC {
@@ -156,7 +157,7 @@ bool RegExpObject::match(ExecState* exec)
return position >= 0;
}
- if (d->lastIndex < 0 || d->lastIndex > input.size()) {
+ if (d->lastIndex < 0 || d->lastIndex > input.length()) {
d->lastIndex = 0;
return false;
}
diff --git a/JavaScriptCore/runtime/RegExpPrototype.cpp b/JavaScriptCore/runtime/RegExpPrototype.cpp
index ac215ec..d66f5d7 100644
--- a/JavaScriptCore/runtime/RegExpPrototype.cpp
+++ b/JavaScriptCore/runtime/RegExpPrototype.cpp
@@ -120,7 +120,7 @@ EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec)
postfix[index] = 'm';
UString source = asRegExpObject(thisValue)->get(exec, exec->propertyNames().source).toString(exec);
// If source is empty, use "/(?:)/" to avoid colliding with comment syntax
- return JSValue::encode(jsMakeNontrivialString(exec, "/", source.size() ? source : UString("(?:)"), postfix));
+ return JSValue::encode(jsMakeNontrivialString(exec, "/", source.length() ? source : UString("(?:)"), postfix));
}
} // namespace JSC
diff --git a/JavaScriptCore/runtime/StringBuilder.h b/JavaScriptCore/runtime/StringBuilder.h
index 59b01e0..a26b94c 100644
--- a/JavaScriptCore/runtime/StringBuilder.h
+++ b/JavaScriptCore/runtime/StringBuilder.h
@@ -56,7 +56,7 @@ public:
void append(const UString& str)
{
- buffer.append(str.data(), str.size());
+ buffer.append(str.characters(), str.length());
}
bool isEmpty() { return buffer.isEmpty(); }
diff --git a/JavaScriptCore/runtime/StringConcatenate.h b/JavaScriptCore/runtime/StringConcatenate.h
new file mode 100644
index 0000000..18a52ef
--- /dev/null
+++ b/JavaScriptCore/runtime/StringConcatenate.h
@@ -0,0 +1,428 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef StringConcatenate_h
+#define StringConcatenate_h
+
+#include "UString.h"
+
+namespace JSC {
+
+template<typename StringType>
+class StringTypeAdapter {
+};
+
+template<>
+class StringTypeAdapter<char*> {
+public:
+ StringTypeAdapter<char*>(char* buffer)
+ : m_buffer((unsigned char*)buffer)
+ , m_length(strlen(buffer))
+ {
+ }
+
+ unsigned length() { return m_length; }
+
+ void writeTo(UChar* destination)
+ {
+ for (unsigned i = 0; i < m_length; ++i)
+ destination[i] = m_buffer[i];
+ }
+
+private:
+ const unsigned char* m_buffer;
+ unsigned m_length;
+};
+
+template<>
+class StringTypeAdapter<const char*> {
+public:
+ StringTypeAdapter<const char*>(const char* buffer)
+ : m_buffer((unsigned char*)buffer)
+ , m_length(strlen(buffer))
+ {
+ }
+
+ unsigned length() { return m_length; }
+
+ void writeTo(UChar* destination)
+ {
+ for (unsigned i = 0; i < m_length; ++i)
+ destination[i] = m_buffer[i];
+ }
+
+private:
+ const unsigned char* m_buffer;
+ unsigned m_length;
+};
+
+template<>
+class StringTypeAdapter<UString> {
+public:
+ StringTypeAdapter<UString>(UString& string)
+ : m_data(string.characters())
+ , m_length(string.length())
+ {
+ }
+
+ unsigned length() { return m_length; }
+
+ void writeTo(UChar* destination)
+ {
+ for (unsigned i = 0; i < m_length; ++i)
+ destination[i] = m_data[i];
+ }
+
+private:
+ const UChar* m_data;
+ unsigned m_length;
+};
+
+inline void sumWithOverflow(unsigned& total, unsigned addend, bool& overflow)
+{
+ unsigned oldTotal = total;
+ total = oldTotal + addend;
+ if (total < oldTotal)
+ overflow = true;
+}
+
+template<typename StringType1, typename StringType2>
+PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2)
+{
+ StringTypeAdapter<StringType1> adapter1(string1);
+ StringTypeAdapter<StringType2> adapter2(string2);
+
+ UChar* buffer;
+ bool overflow = false;
+ unsigned length = adapter1.length();
+ sumWithOverflow(length, adapter2.length(), overflow);
+ if (overflow)
+ return 0;
+ PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
+ if (!resultImpl)
+ return 0;
+
+ UChar* result = buffer;
+ adapter1.writeTo(result);
+ result += adapter1.length();
+ adapter2.writeTo(result);
+
+ return resultImpl;
+}
+
+template<typename StringType1, typename StringType2, typename StringType3>
+PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2, StringType3 string3)
+{
+ StringTypeAdapter<StringType1> adapter1(string1);
+ StringTypeAdapter<StringType2> adapter2(string2);
+ StringTypeAdapter<StringType3> adapter3(string3);
+
+ UChar* buffer = 0;
+ bool overflow = false;
+ unsigned length = adapter1.length();
+ sumWithOverflow(length, adapter2.length(), overflow);
+ sumWithOverflow(length, adapter3.length(), overflow);
+ if (overflow)
+ return 0;
+ PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
+ if (!resultImpl)
+ return 0;
+
+ UChar* result = buffer;
+ adapter1.writeTo(result);
+ result += adapter1.length();
+ adapter2.writeTo(result);
+ result += adapter2.length();
+ adapter3.writeTo(result);
+
+ return resultImpl;
+}
+
+template<typename StringType1, typename StringType2, typename StringType3, typename StringType4>
+PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4)
+{
+ StringTypeAdapter<StringType1> adapter1(string1);
+ StringTypeAdapter<StringType2> adapter2(string2);
+ StringTypeAdapter<StringType3> adapter3(string3);
+ StringTypeAdapter<StringType4> adapter4(string4);
+
+ UChar* buffer;
+ bool overflow = false;
+ unsigned length = adapter1.length();
+ sumWithOverflow(length, adapter2.length(), overflow);
+ sumWithOverflow(length, adapter3.length(), overflow);
+ sumWithOverflow(length, adapter4.length(), overflow);
+ if (overflow)
+ return 0;
+ PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
+ if (!resultImpl)
+ return 0;
+
+ UChar* result = buffer;
+ adapter1.writeTo(result);
+ result += adapter1.length();
+ adapter2.writeTo(result);
+ result += adapter2.length();
+ adapter3.writeTo(result);
+ result += adapter3.length();
+ adapter4.writeTo(result);
+
+ return resultImpl;
+}
+
+template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5>
+PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5)
+{
+ StringTypeAdapter<StringType1> adapter1(string1);
+ StringTypeAdapter<StringType2> adapter2(string2);
+ StringTypeAdapter<StringType3> adapter3(string3);
+ StringTypeAdapter<StringType4> adapter4(string4);
+ StringTypeAdapter<StringType5> adapter5(string5);
+
+ UChar* buffer;
+ bool overflow = false;
+ unsigned length = adapter1.length();
+ sumWithOverflow(length, adapter2.length(), overflow);
+ sumWithOverflow(length, adapter3.length(), overflow);
+ sumWithOverflow(length, adapter4.length(), overflow);
+ sumWithOverflow(length, adapter5.length(), overflow);
+ if (overflow)
+ return 0;
+ PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
+ if (!resultImpl)
+ return 0;
+
+ UChar* result = buffer;
+ adapter1.writeTo(result);
+ result += adapter1.length();
+ adapter2.writeTo(result);
+ result += adapter2.length();
+ adapter3.writeTo(result);
+ result += adapter3.length();
+ adapter4.writeTo(result);
+ result += adapter4.length();
+ adapter5.writeTo(result);
+
+ return resultImpl;
+}
+
+template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6>
+PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5, StringType6 string6)
+{
+ StringTypeAdapter<StringType1> adapter1(string1);
+ StringTypeAdapter<StringType2> adapter2(string2);
+ StringTypeAdapter<StringType3> adapter3(string3);
+ StringTypeAdapter<StringType4> adapter4(string4);
+ StringTypeAdapter<StringType5> adapter5(string5);
+ StringTypeAdapter<StringType6> adapter6(string6);
+
+ UChar* buffer;
+ bool overflow = false;
+ unsigned length = adapter1.length();
+ sumWithOverflow(length, adapter2.length(), overflow);
+ sumWithOverflow(length, adapter3.length(), overflow);
+ sumWithOverflow(length, adapter4.length(), overflow);
+ sumWithOverflow(length, adapter5.length(), overflow);
+ sumWithOverflow(length, adapter6.length(), overflow);
+ if (overflow)
+ return 0;
+ PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
+ if (!resultImpl)
+ return 0;
+
+ UChar* result = buffer;
+ adapter1.writeTo(result);
+ result += adapter1.length();
+ adapter2.writeTo(result);
+ result += adapter2.length();
+ adapter3.writeTo(result);
+ result += adapter3.length();
+ adapter4.writeTo(result);
+ result += adapter4.length();
+ adapter5.writeTo(result);
+ result += adapter5.length();
+ adapter6.writeTo(result);
+
+ return resultImpl;
+}
+
+template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6, typename StringType7>
+PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5, StringType6 string6, StringType7 string7)
+{
+ StringTypeAdapter<StringType1> adapter1(string1);
+ StringTypeAdapter<StringType2> adapter2(string2);
+ StringTypeAdapter<StringType3> adapter3(string3);
+ StringTypeAdapter<StringType4> adapter4(string4);
+ StringTypeAdapter<StringType5> adapter5(string5);
+ StringTypeAdapter<StringType6> adapter6(string6);
+ StringTypeAdapter<StringType7> adapter7(string7);
+
+ UChar* buffer;
+ bool overflow = false;
+ unsigned length = adapter1.length();
+ sumWithOverflow(length, adapter2.length(), overflow);
+ sumWithOverflow(length, adapter3.length(), overflow);
+ sumWithOverflow(length, adapter4.length(), overflow);
+ sumWithOverflow(length, adapter5.length(), overflow);
+ sumWithOverflow(length, adapter6.length(), overflow);
+ sumWithOverflow(length, adapter7.length(), overflow);
+ if (overflow)
+ return 0;
+ PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
+ if (!resultImpl)
+ return 0;
+
+ UChar* result = buffer;
+ adapter1.writeTo(result);
+ result += adapter1.length();
+ adapter2.writeTo(result);
+ result += adapter2.length();
+ adapter3.writeTo(result);
+ result += adapter3.length();
+ adapter4.writeTo(result);
+ result += adapter4.length();
+ adapter5.writeTo(result);
+ result += adapter5.length();
+ adapter6.writeTo(result);
+ result += adapter6.length();
+ adapter7.writeTo(result);
+
+ return resultImpl;
+}
+
+template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6, typename StringType7, typename StringType8>
+PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5, StringType6 string6, StringType7 string7, StringType8 string8)
+{
+ StringTypeAdapter<StringType1> adapter1(string1);
+ StringTypeAdapter<StringType2> adapter2(string2);
+ StringTypeAdapter<StringType3> adapter3(string3);
+ StringTypeAdapter<StringType4> adapter4(string4);
+ StringTypeAdapter<StringType5> adapter5(string5);
+ StringTypeAdapter<StringType6> adapter6(string6);
+ StringTypeAdapter<StringType7> adapter7(string7);
+ StringTypeAdapter<StringType8> adapter8(string8);
+
+ UChar* buffer;
+ bool overflow = false;
+ unsigned length = adapter1.length();
+ sumWithOverflow(length, adapter2.length(), overflow);
+ sumWithOverflow(length, adapter3.length(), overflow);
+ sumWithOverflow(length, adapter4.length(), overflow);
+ sumWithOverflow(length, adapter5.length(), overflow);
+ sumWithOverflow(length, adapter6.length(), overflow);
+ sumWithOverflow(length, adapter7.length(), overflow);
+ sumWithOverflow(length, adapter8.length(), overflow);
+ if (overflow)
+ return 0;
+ PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
+ if (!resultImpl)
+ return 0;
+
+ UChar* result = buffer;
+ adapter1.writeTo(result);
+ result += adapter1.length();
+ adapter2.writeTo(result);
+ result += adapter2.length();
+ adapter3.writeTo(result);
+ result += adapter3.length();
+ adapter4.writeTo(result);
+ result += adapter4.length();
+ adapter5.writeTo(result);
+ result += adapter5.length();
+ adapter6.writeTo(result);
+ result += adapter6.length();
+ adapter7.writeTo(result);
+ result += adapter7.length();
+ adapter8.writeTo(result);
+
+ return resultImpl;
+}
+
+template<typename StringType1, typename StringType2>
+UString makeString(StringType1 string1, StringType2 string2)
+{
+ PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2);
+ if (!resultImpl)
+ CRASH();
+ return resultImpl;
+}
+
+template<typename StringType1, typename StringType2, typename StringType3>
+UString makeString(StringType1 string1, StringType2 string2, StringType3 string3)
+{
+ PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2, string3);
+ if (!resultImpl)
+ CRASH();
+ return resultImpl;
+}
+
+template<typename StringType1, typename StringType2, typename StringType3, typename StringType4>
+UString makeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4)
+{
+ PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2, string3, string4);
+ if (!resultImpl)
+ CRASH();
+ return resultImpl;
+}
+
+template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5>
+UString makeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5)
+{
+ PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2, string3, string4, string5);
+ if (!resultImpl)
+ CRASH();
+ return resultImpl;
+}
+
+template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6>
+UString makeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5, StringType6 string6)
+{
+ PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2, string3, string4, string5, string6);
+ if (!resultImpl)
+ CRASH();
+ return resultImpl;
+}
+
+template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6, typename StringType7>
+UString makeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5, StringType6 string6, StringType7 string7)
+{
+ PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2, string3, string4, string5, string6, string7);
+ if (!resultImpl)
+ CRASH();
+ return resultImpl;
+}
+
+template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6, typename StringType7, typename StringType8>
+UString makeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5, StringType6 string6, StringType7 string7, StringType8 string8)
+{
+ PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2, string3, string4, string5, string6, string7, string8);
+ if (!resultImpl)
+ CRASH();
+ return resultImpl;
+}
+
+} // namespace JSC
+
+#endif
diff --git a/JavaScriptCore/runtime/StringObject.cpp b/JavaScriptCore/runtime/StringObject.cpp
index f8e0e87..c8cac35 100644
--- a/JavaScriptCore/runtime/StringObject.cpp
+++ b/JavaScriptCore/runtime/StringObject.cpp
@@ -90,7 +90,7 @@ void StringObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& prope
{
int size = internalValue()->length();
for (int i = 0; i < size; ++i)
- propertyNames.add(Identifier(exec, UString::from(i)));
+ propertyNames.add(Identifier(exec, UString::number(i)));
if (mode == IncludeDontEnumProperties)
propertyNames.add(exec->propertyNames().length);
return JSObject::getOwnPropertyNames(exec, propertyNames, mode);
diff --git a/JavaScriptCore/runtime/StringPrototype.cpp b/JavaScriptCore/runtime/StringPrototype.cpp
index 00a0be3..7e9131e 100644
--- a/JavaScriptCore/runtime/StringPrototype.cpp
+++ b/JavaScriptCore/runtime/StringPrototype.cpp
@@ -156,14 +156,14 @@ static NEVER_INLINE UString substituteBackreferencesSlow(const UString& replacem
Vector<UChar> substitutedReplacement;
int offset = 0;
do {
- if (i + 1 == replacement.size())
+ if (i + 1 == replacement.length())
break;
UChar ref = replacement[i + 1];
if (ref == '$') {
// "$$" -> "$"
++i;
- substitutedReplacement.append(replacement.data() + offset, i - offset);
+ substitutedReplacement.append(replacement.characters() + offset, i - offset);
offset = i + 1;
continue;
}
@@ -179,13 +179,13 @@ static NEVER_INLINE UString substituteBackreferencesSlow(const UString& replacem
backrefLength = ovector[0];
} else if (ref == '\'') {
backrefStart = ovector[1];
- backrefLength = source.size() - backrefStart;
+ backrefLength = source.length() - backrefStart;
} else if (reg && ref >= '0' && ref <= '9') {
// 1- and 2-digit back references are allowed
unsigned backrefIndex = ref - '0';
if (backrefIndex > reg->numSubpatterns())
continue;
- if (replacement.size() > i + 2) {
+ if (replacement.length() > i + 2) {
ref = replacement[i + 2];
if (ref >= '0' && ref <= '9') {
backrefIndex = 10 * backrefIndex + ref - '0';
@@ -203,14 +203,14 @@ static NEVER_INLINE UString substituteBackreferencesSlow(const UString& replacem
continue;
if (i - offset)
- substitutedReplacement.append(replacement.data() + offset, i - offset);
+ substitutedReplacement.append(replacement.characters() + offset, i - offset);
i += 1 + advance;
offset = i + 1;
- substitutedReplacement.append(source.data() + backrefStart, backrefLength);
+ substitutedReplacement.append(source.characters() + backrefStart, backrefLength);
} while ((i = replacement.find('$', i + 1)) != UString::NotFound);
- if (replacement.size() - offset)
- substitutedReplacement.append(replacement.data() + offset, replacement.size() - offset);
+ if (replacement.length() - offset)
+ substitutedReplacement.append(replacement.characters() + offset, replacement.length() - offset);
substitutedReplacement.shrinkToFit();
return UString::adopt(substitutedReplacement);
@@ -226,7 +226,7 @@ static inline UString substituteBackreferences(const UString& replacement, const
static inline int localeCompare(const UString& a, const UString& b)
{
- return Collator::userDefault()->collate(reinterpret_cast<const ::UChar*>(a.data()), a.size(), reinterpret_cast<const ::UChar*>(b.data()), b.size());
+ return Collator::userDefault()->collate(reinterpret_cast<const ::UChar*>(a.characters()), a.length(), reinterpret_cast<const ::UChar*>(b.characters()), b.length());
}
struct StringRange {
@@ -248,7 +248,7 @@ public:
static ALWAYS_INLINE JSValue jsSpliceSubstringsWithSeparators(ExecState* exec, JSString* sourceVal, const UString& source, const StringRange* substringRanges, int rangeCount, const UString* separators, int separatorCount)
{
if (rangeCount == 1 && separatorCount == 0) {
- int sourceSize = source.size();
+ int sourceSize = source.length();
int position = substringRanges[0].position;
int length = substringRanges[0].length;
if (position <= 0 && length >= sourceSize)
@@ -261,7 +261,7 @@ static ALWAYS_INLINE JSValue jsSpliceSubstringsWithSeparators(ExecState* exec, J
for (int i = 0; i < rangeCount; i++)
totalLength += substringRanges[i].length;
for (int i = 0; i < separatorCount; i++)
- totalLength += separators[i].size();
+ totalLength += separators[i].length();
if (totalLength == 0)
return jsString(exec, "");
@@ -275,12 +275,12 @@ static ALWAYS_INLINE JSValue jsSpliceSubstringsWithSeparators(ExecState* exec, J
int bufferPos = 0;
for (int i = 0; i < maxCount; i++) {
if (i < rangeCount) {
- StringImpl::copyChars(buffer + bufferPos, source.data() + substringRanges[i].position, substringRanges[i].length);
+ StringImpl::copyChars(buffer + bufferPos, source.characters() + substringRanges[i].position, substringRanges[i].length);
bufferPos += substringRanges[i].length;
}
if (i < separatorCount) {
- StringImpl::copyChars(buffer + bufferPos, separators[i].data(), separators[i].size());
- bufferPos += separators[i].size();
+ StringImpl::copyChars(buffer + bufferPos, separators[i].characters(), separators[i].length());
+ bufferPos += separators[i].length();
}
}
@@ -363,7 +363,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec)
// special case of empty match
if (matchLen == 0) {
startPosition++;
- if (startPosition > source.size())
+ if (startPosition > source.length())
break;
}
}
@@ -407,7 +407,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec)
// special case of empty match
if (matchLen == 0) {
startPosition++;
- if (startPosition > source.size())
+ if (startPosition > source.length())
break;
}
} while (global);
@@ -416,8 +416,8 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec)
if (!lastIndex && replacements.isEmpty())
return JSValue::encode(sourceVal);
- if (static_cast<unsigned>(lastIndex) < source.size())
- sourceRanges.append(StringRange(lastIndex, source.size() - lastIndex));
+ if (static_cast<unsigned>(lastIndex) < source.length())
+ sourceRanges.append(StringRange(lastIndex, source.length() - lastIndex));
return JSValue::encode(jsSpliceSubstringsWithSeparators(exec, sourceVal, source, sourceRanges.data(), sourceRanges.size(), replacements.data(), replacements.size()));
}
@@ -425,7 +425,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec)
// Not a regular expression, so treat the pattern as a string.
UString patternString = pattern.toString(exec);
- if (patternString.size() == 1 && callType == CallTypeNone)
+ if (patternString.length() == 1 && callType == CallTypeNone)
return JSValue::encode(sourceVal->replaceCharacter(exec, patternString[0], replacementString));
const UString& source = sourceVal->value(exec);
@@ -434,7 +434,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec)
if (matchPos == UString::NotFound)
return JSValue::encode(sourceVal);
- int matchLen = patternString.size();
+ int matchLen = patternString.length();
if (callType != CallTypeNone) {
MarkedArgumentBuffer args;
args.append(jsSubstring(exec, source, matchPos, matchLen));
@@ -469,7 +469,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState* exec)
if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
return throwVMTypeError(exec);
UString s = thisValue.toThisString(exec);
- unsigned len = s.size();
+ unsigned len = s.length();
JSValue a0 = exec->argument(0);
if (a0.isUInt32()) {
uint32_t i = a0.asUInt32();
@@ -489,12 +489,12 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState* exec)
if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
return throwVMTypeError(exec);
UString s = thisValue.toThisString(exec);
- unsigned len = s.size();
+ unsigned len = s.length();
JSValue a0 = exec->argument(0);
if (a0.isUInt32()) {
uint32_t i = a0.asUInt32();
if (i < len)
- return JSValue::encode(jsNumber(exec, s.data()[i]));
+ return JSValue::encode(jsNumber(exec, s.characters()[i]));
return JSValue::encode(jsNaN(exec));
}
double dpos = a0.toInteger(exec);
@@ -523,7 +523,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState* exec)
if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
return throwVMTypeError(exec);
UString s = thisValue.toThisString(exec);
- int len = s.size();
+ int len = s.length();
JSValue a0 = exec->argument(0);
JSValue a1 = exec->argument(1);
@@ -554,7 +554,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState* exec)
if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
return throwVMTypeError(exec);
UString s = thisValue.toThisString(exec);
- int len = s.size();
+ int len = s.length();
JSValue a0 = exec->argument(0);
JSValue a1 = exec->argument(1);
@@ -665,7 +665,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState* exec)
if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
return throwVMTypeError(exec);
UString s = thisValue.toThisString(exec);
- int len = s.size();
+ int len = s.length();
JSValue a0 = exec->argument(0);
JSValue a1 = exec->argument(1);
@@ -707,7 +707,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState* exec)
return JSValue::encode(result);
}
unsigned pos = 0;
- while (i != limit && pos < s.size()) {
+ while (i != limit && pos < s.length()) {
Vector<int, 32> ovector;
int mpos = reg->match(s, pos, &ovector);
if (mpos < 0)
@@ -733,21 +733,21 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState* exec)
// empty separator matches empty string -> empty array
return JSValue::encode(result);
}
- while (i != limit && p0 < s.size() - 1)
+ while (i != limit && p0 < s.length() - 1)
result->put(exec, i++, jsSingleCharacterSubstring(exec, s, p0++));
} else {
unsigned pos;
while (i != limit && (pos = s.find(u2, p0)) != UString::NotFound) {
result->put(exec, i++, jsSubstring(exec, s, p0, pos - p0));
- p0 = pos + u2.size();
+ p0 = pos + u2.length();
}
}
}
// add remaining string
if (i != limit)
- result->put(exec, i++, jsSubstring(exec, s, p0, s.size() - p0));
+ result->put(exec, i++, jsSubstring(exec, s, p0, s.length() - p0));
return JSValue::encode(result);
}
@@ -758,7 +758,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState* exec)
if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
return throwVMTypeError(exec);
UString s = thisValue.toThisString(exec);
- int len = s.size();
+ int len = s.length();
JSValue a0 = exec->argument(0);
JSValue a1 = exec->argument(1);
@@ -783,7 +783,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState* exec)
if (thisValue.isUndefinedOrNull()) // CheckObjectCoercible
return throwVMTypeError(exec);
UString s = thisValue.toThisString(exec);
- int len = s.size();
+ int len = s.length();
JSValue a0 = exec->argument(0);
JSValue a1 = exec->argument(1);
@@ -819,11 +819,11 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState* exec)
JSString* sVal = thisValue.toThisJSString(exec);
const UString& s = sVal->value(exec);
- int sSize = s.size();
+ int sSize = s.length();
if (!sSize)
return JSValue::encode(sVal);
- const UChar* sData = s.data();
+ const UChar* sData = s.characters();
Vector<UChar> buffer(sSize);
UChar ored = 0;
@@ -859,11 +859,11 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState* exec)
JSString* sVal = thisValue.toThisJSString(exec);
const UString& s = sVal->value(exec);
- int sSize = s.size();
+ int sSize = s.length();
if (!sSize)
return JSValue::encode(sVal);
- const UChar* sData = s.data();
+ const UChar* sData = s.characters();
Vector<UChar> buffer(sSize);
UChar ored = 0;
@@ -984,7 +984,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec)
uint32_t smallInteger;
if (a0.getUInt32(smallInteger) && smallInteger <= 9) {
- unsigned stringSize = s.size();
+ unsigned stringSize = s.length();
unsigned bufferSize = 22 + stringSize;
UChar* buffer;
PassRefPtr<StringImpl> impl = StringImpl::tryCreateUninitialized(bufferSize, buffer);
@@ -1005,7 +1005,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec)
buffer[12] = '0' + smallInteger;
buffer[13] = '"';
buffer[14] = '>';
- memcpy(&buffer[15], s.data(), stringSize * sizeof(UChar));
+ memcpy(&buffer[15], s.characters(), stringSize * sizeof(UChar));
buffer[15 + stringSize] = '<';
buffer[16 + stringSize] = '/';
buffer[17 + stringSize] = 'f';
@@ -1034,8 +1034,8 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec)
JSValue a0 = exec->argument(0);
UString linkText = a0.toString(exec);
- unsigned linkTextSize = linkText.size();
- unsigned stringSize = s.size();
+ unsigned linkTextSize = linkText.length();
+ unsigned stringSize = s.length();
unsigned bufferSize = 15 + linkTextSize + stringSize;
UChar* buffer;
PassRefPtr<StringImpl> impl = StringImpl::tryCreateUninitialized(bufferSize, buffer);
@@ -1050,10 +1050,10 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec)
buffer[6] = 'f';
buffer[7] = '=';
buffer[8] = '"';
- memcpy(&buffer[9], linkText.data(), linkTextSize * sizeof(UChar));
+ memcpy(&buffer[9], linkText.characters(), linkTextSize * sizeof(UChar));
buffer[9 + linkTextSize] = '"';
buffer[10 + linkTextSize] = '>';
- memcpy(&buffer[11 + linkTextSize], s.data(), stringSize * sizeof(UChar));
+ memcpy(&buffer[11 + linkTextSize], s.characters(), stringSize * sizeof(UChar));
buffer[11 + linkTextSize + stringSize] = '<';
buffer[12 + linkTextSize + stringSize] = '/';
buffer[13 + linkTextSize + stringSize] = 'a';
@@ -1078,17 +1078,17 @@ static inline JSValue trimString(ExecState* exec, JSValue thisValue, int trimKin
UString str = thisValue.toThisString(exec);
unsigned left = 0;
if (trimKind & TrimLeft) {
- while (left < str.size() && isTrimWhitespace(str[left]))
+ while (left < str.length() && isTrimWhitespace(str[left]))
left++;
}
- unsigned right = str.size();
+ unsigned right = str.length();
if (trimKind & TrimRight) {
while (right > left && isTrimWhitespace(str[right - 1]))
right--;
}
// Don't gc allocate a new string if we don't have to.
- if (left == 0 && right == str.size() && thisValue.isString())
+ if (left == 0 && right == str.length() && thisValue.isString())
return thisValue;
return jsString(exec, str.substr(left, right - left));
diff --git a/JavaScriptCore/runtime/UString.cpp b/JavaScriptCore/runtime/UString.cpp
index 608639b..32305db 100644
--- a/JavaScriptCore/runtime/UString.cpp
+++ b/JavaScriptCore/runtime/UString.cpp
@@ -71,7 +71,7 @@ UString::UString(const UChar* c, unsigned length)
{
}
-UString UString::from(int i)
+UString UString::number(int i)
{
UChar buf[1 + sizeof(i) * 3];
UChar* end = buf + sizeof(buf) / sizeof(UChar);
@@ -100,7 +100,7 @@ UString UString::from(int i)
return UString(p, static_cast<unsigned>(end - p));
}
-UString UString::from(long long i)
+UString UString::number(long long i)
{
UChar buf[1 + sizeof(i) * 3];
UChar* end = buf + sizeof(buf) / sizeof(UChar);
@@ -133,7 +133,7 @@ UString UString::from(long long i)
return UString(p, static_cast<unsigned>(end - p));
}
-UString UString::from(unsigned u)
+UString UString::number(unsigned u)
{
UChar buf[sizeof(u) * 3];
UChar* end = buf + sizeof(buf) / sizeof(UChar);
@@ -151,7 +151,7 @@ UString UString::from(unsigned u)
return UString(p, static_cast<unsigned>(end - p));
}
-UString UString::from(long l)
+UString UString::number(long l)
{
UChar buf[1 + sizeof(l) * 3];
UChar* end = buf + sizeof(buf) / sizeof(UChar);
@@ -180,7 +180,7 @@ UString UString::from(long l)
return UString(p, end - p);
}
-UString UString::from(double d)
+UString UString::number(double d)
{
DtoaBuffer buffer;
unsigned length;
@@ -192,14 +192,14 @@ char* UString::ascii() const
{
static char* asciiBuffer = 0;
- unsigned length = size();
- unsigned neededSize = length + 1;
+ unsigned len = length();
+ unsigned neededSize = len + 1;
delete[] asciiBuffer;
asciiBuffer = new char[neededSize];
- const UChar* p = data();
+ const UChar* p = characters();
char* q = asciiBuffer;
- const UChar* limit = p + length;
+ const UChar* limit = p + len;
while (p != limit) {
*q = static_cast<char>(p[0]);
++p;
@@ -210,24 +210,11 @@ char* UString::ascii() const
return asciiBuffer;
}
-bool UString::is8Bit() const
-{
- const UChar* u = data();
- const UChar* limit = u + size();
- while (u < limit) {
- if (u[0] > 0xFF)
- return false;
- ++u;
- }
-
- return true;
-}
-
UChar UString::operator[](unsigned pos) const
{
- if (pos >= size())
+ if (pos >= length())
return '\0';
- return data()[pos];
+ return characters()[pos];
}
static inline bool isInfinity(double number)
@@ -250,10 +237,10 @@ static bool isInfinity(const UChar* data, const UChar* end)
double UString::toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const
{
- unsigned size = this->size();
+ unsigned size = this->length();
if (size == 1) {
- UChar c = data()[0];
+ UChar c = characters()[0];
if (isASCIIDigit(c))
return c - '0';
if (isStrWhiteSpace(c) && tolerateEmptyString)
@@ -272,7 +259,7 @@ double UString::toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) co
// need to skip all StrWhiteSpace. The isStrWhiteSpace function does the
// right thing but requires UChar, not char, for its argument.
- const UChar* data = this->data();
+ const UChar* data = this->characters();
const UChar* end = data + size;
// Skip leading white space.
@@ -452,31 +439,31 @@ uint32_t UString::toStrictUInt32(bool* ok) const
unsigned UString::find(const UString& f, unsigned pos) const
{
- unsigned fsz = f.size();
+ unsigned fsz = f.length();
if (fsz == 1) {
UChar ch = f[0];
- const UChar* end = data() + size();
- for (const UChar* c = data() + pos; c < end; c++) {
+ const UChar* end = characters() + length();
+ for (const UChar* c = characters() + pos; c < end; c++) {
if (*c == ch)
- return static_cast<unsigned>(c - data());
+ return static_cast<unsigned>(c - characters());
}
return NotFound;
}
- unsigned sz = size();
+ unsigned sz = length();
if (sz < fsz)
return NotFound;
if (fsz == 0)
return pos;
- const UChar* end = data() + sz - fsz;
+ const UChar* end = characters() + sz - fsz;
unsigned fsizeminusone = (fsz - 1) * sizeof(UChar);
- const UChar* fdata = f.data();
+ const UChar* fdata = f.characters();
unsigned short fchar = fdata[0];
++fdata;
- for (const UChar* c = data() + pos; c <= end; c++) {
+ for (const UChar* c = characters() + pos; c <= end; c++) {
if (c[0] == fchar && !memcmp(c + 1, fdata, fsizeminusone))
- return static_cast<unsigned>(c - data());
+ return static_cast<unsigned>(c - characters());
}
return NotFound;
@@ -484,10 +471,10 @@ unsigned UString::find(const UString& f, unsigned pos) const
unsigned UString::find(UChar ch, unsigned pos) const
{
- const UChar* end = data() + size();
- for (const UChar* c = data() + pos; c < end; c++) {
+ const UChar* end = characters() + length();
+ for (const UChar* c = characters() + pos; c < end; c++) {
if (*c == ch)
- return static_cast<unsigned>(c - data());
+ return static_cast<unsigned>(c - characters());
}
return NotFound;
@@ -495,8 +482,8 @@ unsigned UString::find(UChar ch, unsigned pos) const
unsigned UString::rfind(const UString& f, unsigned pos) const
{
- unsigned sz = size();
- unsigned fsz = f.size();
+ unsigned sz = length();
+ unsigned fsz = f.length();
if (sz < fsz)
return NotFound;
if (pos > sz - fsz)
@@ -504,10 +491,10 @@ unsigned UString::rfind(const UString& f, unsigned pos) const
if (fsz == 0)
return pos;
unsigned fsizeminusone = (fsz - 1) * sizeof(UChar);
- const UChar* fdata = f.data();
- for (const UChar* c = data() + pos; c >= data(); c--) {
+ const UChar* fdata = f.characters();
+ for (const UChar* c = characters() + pos; c >= characters(); c--) {
if (*c == *fdata && !memcmp(c + 1, fdata + 1, fsizeminusone))
- return static_cast<unsigned>(c - data());
+ return static_cast<unsigned>(c - characters());
}
return NotFound;
@@ -517,11 +504,11 @@ unsigned UString::rfind(UChar ch, unsigned pos) const
{
if (isEmpty())
return NotFound;
- if (pos + 1 >= size())
- pos = size() - 1;
- for (const UChar* c = data() + pos; c >= data(); c--) {
+ if (pos + 1 >= length())
+ pos = length() - 1;
+ for (const UChar* c = characters() + pos; c >= characters(); c--) {
if (*c == ch)
- return static_cast<unsigned>(c - data());
+ return static_cast<unsigned>(c - characters());
}
return NotFound;
@@ -529,7 +516,7 @@ unsigned UString::rfind(UChar ch, unsigned pos) const
UString UString::substr(unsigned pos, unsigned len) const
{
- unsigned s = size();
+ unsigned s = length();
if (pos >= s)
pos = s;
@@ -548,8 +535,8 @@ bool operator==(const UString& s1, const char *s2)
if (s2 == 0)
return s1.isEmpty();
- const UChar* u = s1.data();
- const UChar* uend = u + s1.size();
+ const UChar* u = s1.characters();
+ const UChar* uend = u + s1.length();
while (u != uend && *s2) {
if (u[0] != (unsigned char)*s2)
return false;
@@ -562,11 +549,11 @@ bool operator==(const UString& s1, const char *s2)
bool operator<(const UString& s1, const UString& s2)
{
- const unsigned l1 = s1.size();
- const unsigned l2 = s2.size();
+ const unsigned l1 = s1.length();
+ const unsigned l2 = s2.length();
const unsigned lmin = l1 < l2 ? l1 : l2;
- const UChar* c1 = s1.data();
- const UChar* c2 = s2.data();
+ const UChar* c1 = s1.characters();
+ const UChar* c2 = s2.characters();
unsigned l = 0;
while (l < lmin && *c1 == *c2) {
c1++;
@@ -581,11 +568,11 @@ bool operator<(const UString& s1, const UString& s2)
bool operator>(const UString& s1, const UString& s2)
{
- const unsigned l1 = s1.size();
- const unsigned l2 = s2.size();
+ const unsigned l1 = s1.length();
+ const unsigned l2 = s2.length();
const unsigned lmin = l1 < l2 ? l1 : l2;
- const UChar* c1 = s1.data();
- const UChar* c2 = s2.data();
+ const UChar* c1 = s1.characters();
+ const UChar* c2 = s2.characters();
unsigned l = 0;
while (l < lmin && *c1 == *c2) {
c1++;
@@ -601,13 +588,13 @@ bool operator>(const UString& s1, const UString& s2)
CString UString::UTF8String(bool strict) const
{
// Allocate a buffer big enough to hold all the characters.
- const unsigned length = size();
- Vector<char, 1024> buffer(length * 3);
+ const unsigned len = length();
+ Vector<char, 1024> buffer(len * 3);
// Convert to runs of 8-bit characters.
char* p = buffer.data();
- const UChar* d = reinterpret_cast<const UChar*>(&data()[0]);
- ConversionResult result = convertUTF16ToUTF8(&d, d + length, &p, p + buffer.size(), strict);
+ const UChar* d = reinterpret_cast<const UChar*>(&characters()[0]);
+ ConversionResult result = convertUTF16ToUTF8(&d, d + len, &p, p + buffer.size(), strict);
if (result != conversionOK)
return CString();
diff --git a/JavaScriptCore/runtime/UString.h b/JavaScriptCore/runtime/UString.h
index f8e383e..ecc00ba 100644
--- a/JavaScriptCore/runtime/UString.h
+++ b/JavaScriptCore/runtime/UString.h
@@ -38,630 +38,230 @@
namespace JSC {
- using WTF::PlacementNewAdoptType;
- using WTF::PlacementNewAdopt;
-
- class UString {
- friend class JIT;
-
- public:
- UString() {}
- UString(const char*); // Constructor for null-terminated string.
- UString(const char*, unsigned length);
- UString(const UChar*, unsigned length);
- UString(const Vector<UChar>& buffer);
-
- UString(const UString& s)
- : m_impl(s.m_impl)
- {
- }
-
- // Special constructor for cases where we overwrite an object in place.
- UString(PlacementNewAdoptType)
- : m_impl(PlacementNewAdopt)
- {
- }
-
- template<size_t inlineCapacity>
- static PassRefPtr<StringImpl> adopt(Vector<UChar, inlineCapacity>& vector)
- {
- return StringImpl::adopt(vector);
- }
-
- static UString from(int);
- static UString from(long long);
- static UString from(unsigned);
- static UString from(long);
- static UString from(double);
-
- // NOTE: This method should only be used for *debugging* purposes as it
- // is neither Unicode safe nor free from side effects nor thread-safe.
- char* ascii() const;
-
- /**
- * Convert the string to UTF-8, assuming it is UTF-16 encoded.
- * In non-strict mode, this function is tolerant of badly formed UTF-16, it
- * can create UTF-8 strings that are invalid because they have characters in
- * the range U+D800-U+DDFF, U+FFFE, or U+FFFF, but the UTF-8 string is
- * guaranteed to be otherwise valid.
- * In strict mode, error is returned as null CString.
- */
- CString UTF8String(bool strict = false) const;
-
- const UChar* data() const
- {
- if (!m_impl)
- return 0;
- return m_impl->characters();
- }
-
- unsigned size() const
- {
- if (!m_impl)
- return 0;
- return m_impl->length();
- }
-
- bool isNull() const { return !m_impl; }
- bool isEmpty() const { return !m_impl || !m_impl->length(); }
-
- bool is8Bit() const;
-
- UChar operator[](unsigned pos) const;
-
- double toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const;
- double toDouble(bool tolerateTrailingJunk) const;
- double toDouble() const;
-
- uint32_t toUInt32(bool* ok = 0) const;
- uint32_t toUInt32(bool* ok, bool tolerateEmptyString) const;
- uint32_t toStrictUInt32(bool* ok = 0) const;
-
- unsigned toArrayIndex(bool* ok = 0) const;
-
- static const unsigned NotFound = 0xFFFFFFFFu;
- unsigned find(const UString& f, unsigned pos = 0) const;
- unsigned find(UChar, unsigned pos = 0) const;
- unsigned rfind(const UString& f, unsigned pos) const;
- unsigned rfind(UChar, unsigned pos) const;
-
- UString substr(unsigned pos = 0, unsigned len = 0xFFFFFFFF) const;
-
- StringImpl* impl() const { return m_impl.get(); }
-
- UString(PassRefPtr<StringImpl> r)
- : m_impl(r)
- {
- }
-
- size_t cost() const
- {
- if (!m_impl)
- return 0;
- return m_impl->cost();
- }
-
- ALWAYS_INLINE ~UString() { }
- private:
- RefPtr<StringImpl> m_impl;
-
- friend bool operator==(const UString&, const UString&);
- };
-
- ALWAYS_INLINE bool operator==(const UString& s1, const UString& s2)
+using WTF::PlacementNewAdoptType;
+using WTF::PlacementNewAdopt;
+
+class UString {
+public:
+ UString() {}
+ UString(const char*); // Constructor for null-terminated string.
+ UString(const char*, unsigned length);
+ UString(const UChar*, unsigned length);
+ UString(const Vector<UChar>& buffer);
+
+ UString(const UString& s)
+ : m_impl(s.m_impl)
{
- StringImpl* rep1 = s1.impl();
- StringImpl* rep2 = s2.impl();
- unsigned size1 = 0;
- unsigned size2 = 0;
-
- if (rep1 == rep2) // If they're the same rep, they're equal.
- return true;
-
- if (rep1)
- size1 = rep1->length();
-
- if (rep2)
- size2 = rep2->length();
-
- if (size1 != size2) // If the lengths are not the same, we're done.
- return false;
-
- if (!size1)
- return true;
-
- // At this point we know
- // (a) that the strings are the same length and
- // (b) that they are greater than zero length.
- const UChar* d1 = rep1->characters();
- const UChar* d2 = rep2->characters();
-
- if (d1 == d2) // Check to see if the data pointers are the same.
- return true;
-
- // Do quick checks for sizes 1 and 2.
- switch (size1) {
- case 1:
- return d1[0] == d2[0];
- case 2:
- return (d1[0] == d2[0]) & (d1[1] == d2[1]);
- default:
- return memcmp(d1, d2, size1 * sizeof(UChar)) == 0;
- }
- }
-
-
- inline bool operator!=(const UString& s1, const UString& s2)
- {
- return !JSC::operator==(s1, s2);
}
- bool operator<(const UString& s1, const UString& s2);
- bool operator>(const UString& s1, const UString& s2);
-
- bool operator==(const UString& s1, const char* s2);
-
- inline bool operator!=(const UString& s1, const char* s2)
- {
- return !JSC::operator==(s1, s2);
- }
-
- inline bool operator==(const char *s1, const UString& s2)
+ // Special constructor for cases where we overwrite an object in place.
+ UString(PlacementNewAdoptType)
+ : m_impl(PlacementNewAdopt)
{
- return operator==(s2, s1);
}
- inline bool operator!=(const char *s1, const UString& s2)
+ template<size_t inlineCapacity>
+ static PassRefPtr<StringImpl> adopt(Vector<UChar, inlineCapacity>& vector)
{
- return !JSC::operator==(s1, s2);
+ return StringImpl::adopt(vector);
}
- inline int codePointCompare(const UString& s1, const UString& s2)
+ static UString number(int);
+ static UString number(long long);
+ static UString number(unsigned);
+ static UString number(long);
+ static UString number(double);
+
+ // NOTE: This method should only be used for *debugging* purposes as it
+ // is neither Unicode safe nor free from side effects nor thread-safe.
+ char* ascii() const;
+
+ /**
+ * Convert the string to UTF-8, assuming it is UTF-16 encoded.
+ * In non-strict mode, this function is tolerant of badly formed UTF-16, it
+ * can create UTF-8 strings that are invalid because they have characters in
+ * the range U+D800-U+DDFF, U+FFFE, or U+FFFF, but the UTF-8 string is
+ * guaranteed to be otherwise valid.
+ * In strict mode, error is returned as null CString.
+ */
+ CString UTF8String(bool strict = false) const;
+
+ ALWAYS_INLINE unsigned length() const
{
- return codePointCompare(s1.impl(), s2.impl());
- }
-
- // Rule from ECMA 15.2 about what an array index is.
- // Must exactly match string form of an unsigned integer, and be less than 2^32 - 1.
- inline unsigned UString::toArrayIndex(bool* ok) const
- {
- unsigned i = toStrictUInt32(ok);
- if (ok && i >= 0xFFFFFFFFU)
- *ok = false;
- return i;
- }
-
- // We'd rather not do shared substring append for small strings, since
- // this runs too much risk of a tiny initial string holding down a
- // huge buffer.
- static const unsigned minShareSize = Heap::minExtraCost / sizeof(UChar);
-
- struct IdentifierRepHash : PtrHash<RefPtr<StringImpl> > {
- static unsigned hash(const RefPtr<StringImpl>& key) { return key->existingHash(); }
- static unsigned hash(StringImpl* key) { return key->existingHash(); }
- };
-
- template<typename StringType>
- class StringTypeAdapter {
- };
-
- template<>
- class StringTypeAdapter<char*> {
- public:
- StringTypeAdapter<char*>(char* buffer)
- : m_buffer((unsigned char*)buffer)
- , m_length(strlen(buffer))
- {
- }
-
- unsigned length() { return m_length; }
-
- void writeTo(UChar* destination)
- {
- for (unsigned i = 0; i < m_length; ++i)
- destination[i] = m_buffer[i];
- }
-
- private:
- const unsigned char* m_buffer;
- unsigned m_length;
- };
-
- template<>
- class StringTypeAdapter<const char*> {
- public:
- StringTypeAdapter<const char*>(const char* buffer)
- : m_buffer((unsigned char*)buffer)
- , m_length(strlen(buffer))
- {
- }
-
- unsigned length() { return m_length; }
-
- void writeTo(UChar* destination)
- {
- for (unsigned i = 0; i < m_length; ++i)
- destination[i] = m_buffer[i];
- }
-
- private:
- const unsigned char* m_buffer;
- unsigned m_length;
- };
-
- template<>
- class StringTypeAdapter<UString> {
- public:
- StringTypeAdapter<UString>(UString& string)
- : m_data(string.data())
- , m_length(string.size())
- {
- }
-
- unsigned length() { return m_length; }
-
- void writeTo(UChar* destination)
- {
- for (unsigned i = 0; i < m_length; ++i)
- destination[i] = m_data[i];
- }
-
- private:
- const UChar* m_data;
- unsigned m_length;
- };
-
- inline void sumWithOverflow(unsigned& total, unsigned addend, bool& overflow)
- {
- unsigned oldTotal = total;
- total = oldTotal + addend;
- if (total < oldTotal)
- overflow = true;
- }
-
- template<typename StringType1, typename StringType2>
- PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2)
- {
- StringTypeAdapter<StringType1> adapter1(string1);
- StringTypeAdapter<StringType2> adapter2(string2);
-
- UChar* buffer;
- bool overflow = false;
- unsigned length = adapter1.length();
- sumWithOverflow(length, adapter2.length(), overflow);
- if (overflow)
- return 0;
- PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
- if (!resultImpl)
+ if (!m_impl)
return 0;
-
- UChar* result = buffer;
- adapter1.writeTo(result);
- result += adapter1.length();
- adapter2.writeTo(result);
-
- return resultImpl;
+ return m_impl->length();
}
- template<typename StringType1, typename StringType2, typename StringType3>
- PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2, StringType3 string3)
+ const UChar* characters() const
{
- StringTypeAdapter<StringType1> adapter1(string1);
- StringTypeAdapter<StringType2> adapter2(string2);
- StringTypeAdapter<StringType3> adapter3(string3);
-
- UChar* buffer = 0;
- bool overflow = false;
- unsigned length = adapter1.length();
- sumWithOverflow(length, adapter2.length(), overflow);
- sumWithOverflow(length, adapter3.length(), overflow);
- if (overflow)
- return 0;
- PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
- if (!resultImpl)
+ if (!m_impl)
return 0;
-
- UChar* result = buffer;
- adapter1.writeTo(result);
- result += adapter1.length();
- adapter2.writeTo(result);
- result += adapter2.length();
- adapter3.writeTo(result);
-
- return resultImpl;
+ return m_impl->characters();
}
- template<typename StringType1, typename StringType2, typename StringType3, typename StringType4>
- PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4)
- {
- StringTypeAdapter<StringType1> adapter1(string1);
- StringTypeAdapter<StringType2> adapter2(string2);
- StringTypeAdapter<StringType3> adapter3(string3);
- StringTypeAdapter<StringType4> adapter4(string4);
-
- UChar* buffer;
- bool overflow = false;
- unsigned length = adapter1.length();
- sumWithOverflow(length, adapter2.length(), overflow);
- sumWithOverflow(length, adapter3.length(), overflow);
- sumWithOverflow(length, adapter4.length(), overflow);
- if (overflow)
- return 0;
- PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
- if (!resultImpl)
- return 0;
+ UChar operator[](unsigned pos) const;
- UChar* result = buffer;
- adapter1.writeTo(result);
- result += adapter1.length();
- adapter2.writeTo(result);
- result += adapter2.length();
- adapter3.writeTo(result);
- result += adapter3.length();
- adapter4.writeTo(result);
+ double toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const;
+ double toDouble(bool tolerateTrailingJunk) const;
+ double toDouble() const;
- return resultImpl;
- }
+ uint32_t toUInt32(bool* ok = 0) const;
+ uint32_t toUInt32(bool* ok, bool tolerateEmptyString) const;
+ uint32_t toStrictUInt32(bool* ok = 0) const;
- template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5>
- PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5)
- {
- StringTypeAdapter<StringType1> adapter1(string1);
- StringTypeAdapter<StringType2> adapter2(string2);
- StringTypeAdapter<StringType3> adapter3(string3);
- StringTypeAdapter<StringType4> adapter4(string4);
- StringTypeAdapter<StringType5> adapter5(string5);
-
- UChar* buffer;
- bool overflow = false;
- unsigned length = adapter1.length();
- sumWithOverflow(length, adapter2.length(), overflow);
- sumWithOverflow(length, adapter3.length(), overflow);
- sumWithOverflow(length, adapter4.length(), overflow);
- sumWithOverflow(length, adapter5.length(), overflow);
- if (overflow)
- return 0;
- PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
- if (!resultImpl)
- return 0;
+ unsigned toArrayIndex(bool* ok = 0) const;
- UChar* result = buffer;
- adapter1.writeTo(result);
- result += adapter1.length();
- adapter2.writeTo(result);
- result += adapter2.length();
- adapter3.writeTo(result);
- result += adapter3.length();
- adapter4.writeTo(result);
- result += adapter4.length();
- adapter5.writeTo(result);
-
- return resultImpl;
- }
+ static const unsigned NotFound = 0xFFFFFFFFu;
+ unsigned find(const UString& f, unsigned pos = 0) const;
+ unsigned find(UChar, unsigned pos = 0) const;
+ unsigned rfind(const UString& f, unsigned pos) const;
+ unsigned rfind(UChar, unsigned pos) const;
- template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6>
- PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5, StringType6 string6)
- {
- StringTypeAdapter<StringType1> adapter1(string1);
- StringTypeAdapter<StringType2> adapter2(string2);
- StringTypeAdapter<StringType3> adapter3(string3);
- StringTypeAdapter<StringType4> adapter4(string4);
- StringTypeAdapter<StringType5> adapter5(string5);
- StringTypeAdapter<StringType6> adapter6(string6);
-
- UChar* buffer;
- bool overflow = false;
- unsigned length = adapter1.length();
- sumWithOverflow(length, adapter2.length(), overflow);
- sumWithOverflow(length, adapter3.length(), overflow);
- sumWithOverflow(length, adapter4.length(), overflow);
- sumWithOverflow(length, adapter5.length(), overflow);
- sumWithOverflow(length, adapter6.length(), overflow);
- if (overflow)
- return 0;
- PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
- if (!resultImpl)
- return 0;
-
- UChar* result = buffer;
- adapter1.writeTo(result);
- result += adapter1.length();
- adapter2.writeTo(result);
- result += adapter2.length();
- adapter3.writeTo(result);
- result += adapter3.length();
- adapter4.writeTo(result);
- result += adapter4.length();
- adapter5.writeTo(result);
- result += adapter5.length();
- adapter6.writeTo(result);
-
- return resultImpl;
- }
-
- template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6, typename StringType7>
- PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5, StringType6 string6, StringType7 string7)
- {
- StringTypeAdapter<StringType1> adapter1(string1);
- StringTypeAdapter<StringType2> adapter2(string2);
- StringTypeAdapter<StringType3> adapter3(string3);
- StringTypeAdapter<StringType4> adapter4(string4);
- StringTypeAdapter<StringType5> adapter5(string5);
- StringTypeAdapter<StringType6> adapter6(string6);
- StringTypeAdapter<StringType7> adapter7(string7);
-
- UChar* buffer;
- bool overflow = false;
- unsigned length = adapter1.length();
- sumWithOverflow(length, adapter2.length(), overflow);
- sumWithOverflow(length, adapter3.length(), overflow);
- sumWithOverflow(length, adapter4.length(), overflow);
- sumWithOverflow(length, adapter5.length(), overflow);
- sumWithOverflow(length, adapter6.length(), overflow);
- sumWithOverflow(length, adapter7.length(), overflow);
- if (overflow)
- return 0;
- PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
- if (!resultImpl)
- return 0;
+ UString substr(unsigned pos = 0, unsigned len = 0xFFFFFFFF) const;
- UChar* result = buffer;
- adapter1.writeTo(result);
- result += adapter1.length();
- adapter2.writeTo(result);
- result += adapter2.length();
- adapter3.writeTo(result);
- result += adapter3.length();
- adapter4.writeTo(result);
- result += adapter4.length();
- adapter5.writeTo(result);
- result += adapter5.length();
- adapter6.writeTo(result);
- result += adapter6.length();
- adapter7.writeTo(result);
-
- return resultImpl;
- }
+ bool isNull() const { return !m_impl; }
+ ALWAYS_INLINE bool isEmpty() const { return !m_impl || !m_impl->length(); }
- template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6, typename StringType7, typename StringType8>
- PassRefPtr<StringImpl> tryMakeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5, StringType6 string6, StringType7 string7, StringType8 string8)
- {
- StringTypeAdapter<StringType1> adapter1(string1);
- StringTypeAdapter<StringType2> adapter2(string2);
- StringTypeAdapter<StringType3> adapter3(string3);
- StringTypeAdapter<StringType4> adapter4(string4);
- StringTypeAdapter<StringType5> adapter5(string5);
- StringTypeAdapter<StringType6> adapter6(string6);
- StringTypeAdapter<StringType7> adapter7(string7);
- StringTypeAdapter<StringType8> adapter8(string8);
-
- UChar* buffer;
- bool overflow = false;
- unsigned length = adapter1.length();
- sumWithOverflow(length, adapter2.length(), overflow);
- sumWithOverflow(length, adapter3.length(), overflow);
- sumWithOverflow(length, adapter4.length(), overflow);
- sumWithOverflow(length, adapter5.length(), overflow);
- sumWithOverflow(length, adapter6.length(), overflow);
- sumWithOverflow(length, adapter7.length(), overflow);
- sumWithOverflow(length, adapter8.length(), overflow);
- if (overflow)
- return 0;
- PassRefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer);
- if (!resultImpl)
- return 0;
-
- UChar* result = buffer;
- adapter1.writeTo(result);
- result += adapter1.length();
- adapter2.writeTo(result);
- result += adapter2.length();
- adapter3.writeTo(result);
- result += adapter3.length();
- adapter4.writeTo(result);
- result += adapter4.length();
- adapter5.writeTo(result);
- result += adapter5.length();
- adapter6.writeTo(result);
- result += adapter6.length();
- adapter7.writeTo(result);
- result += adapter7.length();
- adapter8.writeTo(result);
-
- return resultImpl;
- }
-
- template<typename StringType1, typename StringType2>
- UString makeString(StringType1 string1, StringType2 string2)
- {
- PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2);
- if (!resultImpl)
- CRASH();
- return resultImpl;
- }
-
- template<typename StringType1, typename StringType2, typename StringType3>
- UString makeString(StringType1 string1, StringType2 string2, StringType3 string3)
- {
- PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2, string3);
- if (!resultImpl)
- CRASH();
- return resultImpl;
- }
+ StringImpl* impl() const { return m_impl.get(); }
- template<typename StringType1, typename StringType2, typename StringType3, typename StringType4>
- UString makeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4)
+ UString(PassRefPtr<StringImpl> r)
+ : m_impl(r)
{
- PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2, string3, string4);
- if (!resultImpl)
- CRASH();
- return resultImpl;
}
- template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5>
- UString makeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5)
+ size_t cost() const
{
- PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2, string3, string4, string5);
- if (!resultImpl)
- CRASH();
- return resultImpl;
+ if (!m_impl)
+ return 0;
+ return m_impl->cost();
}
- template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6>
- UString makeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5, StringType6 string6)
- {
- PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2, string3, string4, string5, string6);
- if (!resultImpl)
- CRASH();
- return resultImpl;
- }
+private:
+ RefPtr<StringImpl> m_impl;
+};
- template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6, typename StringType7>
- UString makeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5, StringType6 string6, StringType7 string7)
- {
- PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2, string3, string4, string5, string6, string7);
- if (!resultImpl)
- CRASH();
- return resultImpl;
- }
+ALWAYS_INLINE bool operator==(const UString& s1, const UString& s2)
+{
+ StringImpl* rep1 = s1.impl();
+ StringImpl* rep2 = s2.impl();
+ unsigned size1 = 0;
+ unsigned size2 = 0;
- template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6, typename StringType7, typename StringType8>
- UString makeString(StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5, StringType6 string6, StringType7 string7, StringType8 string8)
- {
- PassRefPtr<StringImpl> resultImpl = tryMakeString(string1, string2, string3, string4, string5, string6, string7, string8);
- if (!resultImpl)
- CRASH();
- return resultImpl;
+ if (rep1 == rep2) // If they're the same rep, they're equal.
+ return true;
+
+ if (rep1)
+ size1 = rep1->length();
+
+ if (rep2)
+ size2 = rep2->length();
+
+ if (size1 != size2) // If the lengths are not the same, we're done.
+ return false;
+
+ if (!size1)
+ return true;
+
+ // At this point we know
+ // (a) that the strings are the same length and
+ // (b) that they are greater than zero length.
+ const UChar* d1 = rep1->characters();
+ const UChar* d2 = rep2->characters();
+
+ if (d1 == d2) // Check to see if the data pointers are the same.
+ return true;
+
+ // Do quick checks for sizes 1 and 2.
+ switch (size1) {
+ case 1:
+ return d1[0] == d2[0];
+ case 2:
+ return (d1[0] == d2[0]) & (d1[1] == d2[1]);
+ default:
+ return memcmp(d1, d2, size1 * sizeof(UChar)) == 0;
}
+}
+
+
+inline bool operator!=(const UString& s1, const UString& s2)
+{
+ return !JSC::operator==(s1, s2);
+}
+
+bool operator<(const UString& s1, const UString& s2);
+bool operator>(const UString& s1, const UString& s2);
+
+bool operator==(const UString& s1, const char* s2);
+
+inline bool operator!=(const UString& s1, const char* s2)
+{
+ return !JSC::operator==(s1, s2);
+}
+
+inline bool operator==(const char *s1, const UString& s2)
+{
+ return operator==(s2, s1);
+}
+
+inline bool operator!=(const char *s1, const UString& s2)
+{
+ return !JSC::operator==(s1, s2);
+}
+
+inline int codePointCompare(const UString& s1, const UString& s2)
+{
+ return codePointCompare(s1.impl(), s2.impl());
+}
+
+// Rule from ECMA 15.2 about what an array index is.
+// Must exactly match string form of an unsigned integer, and be less than 2^32 - 1.
+inline unsigned UString::toArrayIndex(bool* ok) const
+{
+ unsigned i = toStrictUInt32(ok);
+ if (ok && i >= 0xFFFFFFFFU)
+ *ok = false;
+ return i;
+}
+
+// We'd rather not do shared substring append for small strings, since
+// this runs too much risk of a tiny initial string holding down a
+// huge buffer.
+static const unsigned minShareSize = Heap::minExtraCost / sizeof(UChar);
+
+struct IdentifierRepHash : PtrHash<RefPtr<StringImpl> > {
+ static unsigned hash(const RefPtr<StringImpl>& key) { return key->existingHash(); }
+ static unsigned hash(StringImpl* key) { return key->existingHash(); }
+};
} // namespace JSC
namespace WTF {
- template<typename T> struct DefaultHash;
- template<typename T> struct StrHash;
-
- template<> struct StrHash<StringImpl*> {
- static unsigned hash(const StringImpl* key) { return key->hash(); }
- static bool equal(const StringImpl* a, const StringImpl* b) { return ::equal(a, b); }
- static const bool safeToCompareToEmptyOrDeleted = false;
- };
-
- template<> struct StrHash<RefPtr<StringImpl> > : public StrHash<StringImpl*> {
- using StrHash<StringImpl*>::hash;
- static unsigned hash(const RefPtr<StringImpl>& key) { return key->hash(); }
- using StrHash<StringImpl*>::equal;
- static bool equal(const RefPtr<StringImpl>& a, const RefPtr<StringImpl>& b) { return ::equal(a.get(), b.get()); }
- static bool equal(const StringImpl* a, const RefPtr<StringImpl>& b) { return ::equal(a, b.get()); }
- static bool equal(const RefPtr<StringImpl>& a, const StringImpl* b) { return ::equal(a.get(), b); }
-
- static const bool safeToCompareToEmptyOrDeleted = false;
- };
-
- template <> struct VectorTraits<JSC::UString> : SimpleClassVectorTraits
- {
- static const bool canInitializeWithMemset = true;
- };
+template<typename T> struct DefaultHash;
+template<typename T> struct StrHash;
+
+template<> struct StrHash<StringImpl*> {
+ static unsigned hash(const StringImpl* key) { return key->hash(); }
+ static bool equal(const StringImpl* a, const StringImpl* b) { return ::equal(a, b); }
+ static const bool safeToCompareToEmptyOrDeleted = false;
+};
+
+template<> struct StrHash<RefPtr<StringImpl> > : public StrHash<StringImpl*> {
+ using StrHash<StringImpl*>::hash;
+ static unsigned hash(const RefPtr<StringImpl>& key) { return key->hash(); }
+ using StrHash<StringImpl*>::equal;
+ static bool equal(const RefPtr<StringImpl>& a, const RefPtr<StringImpl>& b) { return ::equal(a.get(), b.get()); }
+ static bool equal(const StringImpl* a, const RefPtr<StringImpl>& b) { return ::equal(a, b.get()); }
+ static bool equal(const RefPtr<StringImpl>& a, const StringImpl* b) { return ::equal(a.get(), b); }
+
+ static const bool safeToCompareToEmptyOrDeleted = false;
+};
+
+template <> struct VectorTraits<JSC::UString> : SimpleClassVectorTraits
+{
+ static const bool canInitializeWithMemset = true;
+};
} // namespace WTF
diff --git a/JavaScriptCore/yarr/RegexJIT.cpp b/JavaScriptCore/yarr/RegexJIT.cpp
index 5a53ced..e158f8f 100644
--- a/JavaScriptCore/yarr/RegexJIT.cpp
+++ b/JavaScriptCore/yarr/RegexJIT.cpp
@@ -1511,7 +1511,7 @@ void jitCompileRegex(JSGlobalData* globalData, RegexCodeBlock& jitObject, const
JSRegExpIgnoreCaseOption ignoreCaseOption = ignoreCase ? JSRegExpIgnoreCase : JSRegExpDoNotIgnoreCase;
JSRegExpMultilineOption multilineOption = multiline ? JSRegExpMultiline : JSRegExpSingleLine;
- jitObject.setFallback(jsRegExpCompile(reinterpret_cast<const UChar*>(patternString.data()), patternString.size(), ignoreCaseOption, multilineOption, &numSubpatterns, &error));
+ jitObject.setFallback(jsRegExpCompile(reinterpret_cast<const UChar*>(patternString.characters()), patternString.length(), ignoreCaseOption, multilineOption, &numSubpatterns, &error));
}
}}
diff --git a/JavaScriptCore/yarr/RegexParser.h b/JavaScriptCore/yarr/RegexParser.h
index c946c2e..8a5eeba 100644
--- a/JavaScriptCore/yarr/RegexParser.h
+++ b/JavaScriptCore/yarr/RegexParser.h
@@ -193,8 +193,8 @@ private:
: m_delegate(delegate)
, m_backReferenceLimit(backReferenceLimit)
, m_err(NoError)
- , m_data(pattern.data())
- , m_size(pattern.size())
+ , m_data(pattern.characters())
+ , m_size(pattern.length())
, m_index(0)
, m_parenthesesNestingDepth(0)
{
diff --git a/JavaScriptGlue/ChangeLog b/JavaScriptGlue/ChangeLog
index 9301542..3b56156 100644
--- a/JavaScriptGlue/ChangeLog
+++ b/JavaScriptGlue/ChangeLog
@@ -1,3 +1,17 @@
+2010-08-11 Gavin Barraclough <barraclough at apple.com>
+
+ Rubber stamps by Darin Adler & Sam Weinig.
+
+ Bug 43867 - Some UString cleanup
+
+ Change JSC::UString data(), size(), and from(), to characters(), length(), and number() to match WTF::String.
+ Move string concatenation methods to a new header to simplify down UString.h. Remove is8Bit().
+
+ * JSUtils.cpp:
+ (UStringToCFString):
+ (KJSValueToCFTypeInternal):
+ * JavaScriptGlue.xcodeproj/project.pbxproj:
+
2010-08-04 Gavin Barraclough <barraclough at apple.com>
Reviewed by Sam Weinig.
diff --git a/JavaScriptGlue/JSUtils.cpp b/JavaScriptGlue/JSUtils.cpp
index b83ac52..5c85475 100644
--- a/JavaScriptGlue/JSUtils.cpp
+++ b/JavaScriptGlue/JSUtils.cpp
@@ -74,7 +74,7 @@ UString CFStringToUString(CFStringRef inCFString)
// Caller is responsible for releasing the returned CFStringRef
CFStringRef UStringToCFString(const UString& inUString)
{
- return CFStringCreateWithCharacters(0, (const UniChar*)inUString.data(), inUString.size());
+ return CFStringCreateWithCharacters(0, (const UniChar*)inUString.characters(), inUString.length());
}
@@ -284,8 +284,8 @@ CFTypeRef KJSValueToCFTypeInternal(JSValue inValue, ExecState *exec, ObjectImpLi
{
Identifier propName = *iter;
UString ustr = propName.ustring();
- const UniChar* uniChars = (const UniChar*)ustr.data();
- int size = ustr.size();
+ const UniChar* uniChars = (const UniChar*)ustr.characters();
+ int size = ustr.length();
while (size--) {
if (uniChars[size] < '0' || uniChars[size] > '9') {
isArray = false;
diff --git a/JavaScriptGlue/JavaScriptGlue.xcodeproj/project.pbxproj b/JavaScriptGlue/JavaScriptGlue.xcodeproj/project.pbxproj
index f33bf97..cec8b14 100644
--- a/JavaScriptGlue/JavaScriptGlue.xcodeproj/project.pbxproj
+++ b/JavaScriptGlue/JavaScriptGlue.xcodeproj/project.pbxproj
@@ -287,7 +287,14 @@
isa = PBXProject;
buildConfigurationList = 14AC662B08CE7791006915A8 /* Build configuration list for PBXProject "JavaScriptGlue" */;
compatibilityVersion = "Xcode 2.4";
+ developmentRegion = English;
hasScannedForEncodings = 1;
+ knownRegions = (
+ English,
+ Japanese,
+ French,
+ German,
+ );
mainGroup = 0867D691FE84028FC02AAC07 /* JavaScriptGlue */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index be8ae90..6a182b1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,34 @@
+2010-08-11 Gavin Barraclough <barraclough at apple.com>
+
+ Rubber stamps by Darin Adler & Sam Weinig.
+
+ Bug 43867 - Some UString cleanup
+
+ Change JSC::UString data(), size(), and from(), to characters(), length(), and number() to match WTF::String.
+ Move string concatenation methods to a new header to simplify down UString.h. Remove is8Bit().
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSCSSStyleDeclarationCustom.cpp:
+ (WebCore::hasCSSPropertyNamePrefix):
+ (WebCore::cssPropertyName):
+ * bindings/js/JSLocationCustom.cpp:
+ (WebCore::JSLocation::setPort):
+ * bindings/js/ScriptDebugServer.cpp:
+ (WebCore::ScriptDebugServer::dispatchDidParseSource):
+ * bindings/js/ScriptString.h:
+ (WebCore::ScriptString::size):
+ * bindings/js/ScriptValue.cpp:
+ (WebCore::jsToInspectorValue):
+ * bindings/objc/WebScriptObject.mm:
+ (+[WebScriptObject _convertValueToObjcValue:originRootObject:rootObject:]):
+ * bridge/jni/jni_jsobject.mm:
+ (JavaJSObject::convertValueToJObject):
+ * bridge/jni/jsc/JNIUtilityPrivate.cpp:
+ (JSC::Bindings::convertArrayInstanceToJavaArray):
+ (JSC::Bindings::convertValueToJValue):
+ * bridge/objc/objc_runtime.mm:
+ (JSC::Bindings::callObjCFallbackObject):
+
2010-08-10 David Hyatt <hyatt at apple.com>
Reviewed by Dan Bernstein.
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 90e53ab..0ba10c2 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -20201,6 +20201,7 @@
isa = PBXProject;
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
compatibilityVersion = "Xcode 2.4";
+ developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
diff --git a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
index d0097e8..3b3465e 100644
--- a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
+++ b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
@@ -66,17 +66,17 @@ static bool hasCSSPropertyNamePrefix(const Identifier& propertyName, const char*
ASSERT(*prefix);
for (const char* p = prefix; *p; ++p)
ASSERT(isASCIILower(*p));
- ASSERT(propertyName.size());
+ ASSERT(propertyName.length());
#endif
- if (toASCIILower(propertyName.data()[0]) != prefix[0])
+ if (toASCIILower(propertyName.characters()[0]) != prefix[0])
return false;
- unsigned length = propertyName.size();
+ unsigned length = propertyName.length();
for (unsigned i = 1; i < length; ++i) {
if (!prefix[i])
- return isASCIIUpper(propertyName.data()[i]);
- if (propertyName.data()[i] != prefix[i])
+ return isASCIIUpper(propertyName.characters()[i]);
+ if (propertyName.characters()[i] != prefix[i])
return false;
}
return false;
@@ -87,7 +87,7 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo
if (hadPixelOrPosPrefix)
*hadPixelOrPosPrefix = false;
- unsigned length = propertyName.size();
+ unsigned length = propertyName.length();
if (!length)
return String();
@@ -111,14 +111,14 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo
|| hasCSSPropertyNamePrefix(propertyName, "apple"))
name.append('-');
else {
- if (isASCIIUpper(propertyName.data()[0]))
+ if (isASCIIUpper(propertyName.characters()[0]))
return String();
}
- name.append(toASCIILower(propertyName.data()[i++]));
+ name.append(toASCIILower(propertyName.characters()[i++]));
for (; i < length; ++i) {
- UChar c = propertyName.data()[i];
+ UChar c = propertyName.characters()[i];
if (!isASCIIUpper(c))
name.append(c);
else {
diff --git a/WebCore/bindings/js/JSLocationCustom.cpp b/WebCore/bindings/js/JSLocationCustom.cpp
index 943d8fa..99166cd 100644
--- a/WebCore/bindings/js/JSLocationCustom.cpp
+++ b/WebCore/bindings/js/JSLocationCustom.cpp
@@ -253,7 +253,7 @@ void JSLocation::setPort(ExecState* exec, JSValue value)
KURL url = frame->loader()->url();
// FIXME: Could make this a little less ugly if String provided a toUnsignedShort function.
const UString& portString = value.toString(exec);
- int port = charactersToInt(portString.data(), portString.size());
+ int port = charactersToInt(portString.characters(), portString.length());
if (port < 0 || port > 0xFFFF)
url.removePort();
else
diff --git a/WebCore/bindings/js/ScriptDebugServer.cpp b/WebCore/bindings/js/ScriptDebugServer.cpp
index d71034b..8d47b78 100644
--- a/WebCore/bindings/js/ScriptDebugServer.cpp
+++ b/WebCore/bindings/js/ScriptDebugServer.cpp
@@ -268,7 +268,7 @@ void ScriptDebugServer::dispatchDidContinue(ScriptDebugListener* listener)
void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, ScriptWorldType worldType)
{
- String sourceID = ustringToString(JSC::UString::from(source.provider()->asID()));
+ String sourceID = ustringToString(JSC::UString::number(source.provider()->asID()));
String url = ustringToString(source.provider()->url());
String data = ustringToString(JSC::UString(source.data(), source.length()));
int firstLine = source.firstLine();
diff --git a/WebCore/bindings/js/ScriptString.h b/WebCore/bindings/js/ScriptString.h
index 558ad33..7401818 100644
--- a/WebCore/bindings/js/ScriptString.h
+++ b/WebCore/bindings/js/ScriptString.h
@@ -51,7 +51,7 @@ public:
const JSC::UString& ustring() const { return m_str; }
bool isNull() const { return m_str.isNull(); }
- size_t size() const { return m_str.size(); }
+ size_t size() const { return m_str.length(); }
ScriptString& operator=(const char* s)
{
diff --git a/WebCore/bindings/js/ScriptValue.cpp b/WebCore/bindings/js/ScriptValue.cpp
index 23934cd..b4dda12 100644
--- a/WebCore/bindings/js/ScriptValue.cpp
+++ b/WebCore/bindings/js/ScriptValue.cpp
@@ -109,7 +109,7 @@ static PassRefPtr<InspectorValue> jsToInspectorValue(ScriptState* scriptState, J
return InspectorBasicValue::create(value.uncheckedGetNumber());
if (value.isString()) {
UString s = value.getString(scriptState);
- return InspectorString::create(String(s.data(), s.size()));
+ return InspectorString::create(String(s.characters(), s.length()));
}
if (value.isObject()) {
if (isJSArray(&scriptState->globalData(), value)) {
@@ -139,7 +139,7 @@ static PassRefPtr<InspectorValue> jsToInspectorValue(ScriptState* scriptState, J
ASSERT_NOT_REACHED();
inspectorValue = InspectorValue::null();
}
- inspectorObject->set(String(name.data(), name.size()), inspectorValue);
+ inspectorObject->set(String(name.characters(), name.length()), inspectorValue);
}
return inspectorObject;
}
diff --git a/WebCore/bindings/objc/WebScriptObject.mm b/WebCore/bindings/objc/WebScriptObject.mm
index 37874ac..a26c315 100644
--- a/WebCore/bindings/objc/WebScriptObject.mm
+++ b/WebCore/bindings/objc/WebScriptObject.mm
@@ -557,7 +557,7 @@ static void getListFromNSArray(ExecState *exec, NSArray *array, RootObject* root
if (value.isString()) {
ExecState* exec = rootObject->globalObject()->globalExec();
const UString& u = asString(value)->value(exec);
- return [NSString stringWithCharacters:u.data() length:u.size()];
+ return [NSString stringWithCharacters:u.characters() length:u.length()];
}
if (value.isNumber())
diff --git a/WebCore/bridge/jni/jni_jsobject.mm b/WebCore/bridge/jni/jni_jsobject.mm
index 7793070..4406c3c 100644
--- a/WebCore/bridge/jni/jni_jsobject.mm
+++ b/WebCore/bridge/jni/jni_jsobject.mm
@@ -500,7 +500,7 @@ jobject JavaJSObject::convertValueToJObject(JSValue value) const
} else if (value.isString()) {
UString stringValue = value.toString(exec);
JNIEnv *env = getJNIEnv();
- result = env->NewString ((const jchar *)stringValue.data(), stringValue.size());
+ result = env->NewString ((const jchar *)stringValue.characters(), stringValue.length());
} else if (value.isBoolean()) {
jclass JSObjectClass = env->FindClass ("java/lang/Boolean");
jmethodID constructorID = env->GetMethodID (JSObjectClass, "<init>", "(Z)V");
diff --git a/WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp b/WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp
index 2048d8e..2fb72e9 100644
--- a/WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp
+++ b/WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp
@@ -63,7 +63,7 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
JSValue item = jsArray->get(exec, i);
UString stringValue = item.toString(exec);
env->SetObjectArrayElement(jarray, i,
- env->functions->NewString(env, (const jchar *)stringValue.data(), stringValue.size()));
+ env->functions->NewString(env, (const jchar *)stringValue.characters(), stringValue.length()));
}
}
break;
@@ -98,8 +98,8 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
JSValue item = jsArray->get(exec, i);
UString stringValue = item.toString(exec);
jchar value = 0;
- if (stringValue.size() > 0)
- value = ((const jchar*)stringValue.data())[0];
+ if (stringValue.length() > 0)
+ value = ((const jchar*)stringValue.characters())[0];
env->SetCharArrayRegion((jcharArray)jarray, (jsize)i, (jsize)1, &value);
}
break;
@@ -218,7 +218,7 @@ jvalue convertValueToJValue(ExecState* exec, RootObject* rootObject, JSValue val
if (value.isString()) {
UString stringValue = asString(value)->value(exec);
JNIEnv* env = getJNIEnv();
- jobject javaString = env->functions->NewString(env, (const jchar*)stringValue.data(), stringValue.size());
+ jobject javaString = env->functions->NewString(env, (const jchar*)stringValue.characters(), stringValue.length());
result.l = javaString;
} else if (value.isNumber()) {
double doubleValue = value.uncheckedGetNumber();
@@ -237,7 +237,7 @@ jvalue convertValueToJValue(ExecState* exec, RootObject* rootObject, JSValue val
} else if (value.isUndefined()) {
UString stringValue = "undefined";
JNIEnv* env = getJNIEnv();
- jobject javaString = env->functions->NewString(env, (const jchar*)stringValue.data(), stringValue.size());
+ jobject javaString = env->functions->NewString(env, (const jchar*)stringValue.characters(), stringValue.length());
result.l = javaString;
}
}
@@ -248,7 +248,7 @@ jvalue convertValueToJValue(ExecState* exec, RootObject* rootObject, JSValue val
if (!value.isNull()) {
UString stringValue = value.toString(exec);
JNIEnv* env = getJNIEnv();
- jobject javaString = env->functions->NewString(env, (const jchar*)stringValue.data(), stringValue.size());
+ jobject javaString = env->functions->NewString(env, (const jchar*)stringValue.characters(), stringValue.length());
result.l = javaString;
}
}
diff --git a/WebCore/bridge/objc/objc_runtime.mm b/WebCore/bridge/objc/objc_runtime.mm
index e86cb1e..3c4ba23 100644
--- a/WebCore/bridge/objc/objc_runtime.mm
+++ b/WebCore/bridge/objc/objc_runtime.mm
@@ -237,7 +237,7 @@ static EncodedJSValue JSC_HOST_CALL callObjCFallbackObject(ExecState* exec)
ObjcClass* objcClass = static_cast<ObjcClass*>(objcInstance->getClass());
OwnPtr<ObjcMethod> fallbackMethod(new ObjcMethod(objcClass->isa(), @selector(invokeUndefinedMethodFromWebScript:withArguments:)));
const Identifier& nameIdentifier = static_cast<ObjcFallbackObjectImp*>(exec->callee())->propertyName();
- RetainPtr<CFStringRef> name(AdoptCF, CFStringCreateWithCharacters(0, nameIdentifier.data(), nameIdentifier.size()));
+ RetainPtr<CFStringRef> name(AdoptCF, CFStringCreateWithCharacters(0, nameIdentifier.characters(), nameIdentifier.length()));
fallbackMethod->setJavaScriptName(name.get());
result = objcInstance->invokeObjcMethod(exec, fallbackMethod.get());
}
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 4e1c101..3344c76 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,15 @@
+2010-08-11 Gavin Barraclough <barraclough at apple.com>
+
+ Rubber stamps by Darin Adler & Sam Weinig.
+
+ Bug 43867 - Some UString cleanup
+
+ Change JSC::UString data(), size(), and from(), to characters(), length(), and number() to match WTF::String.
+ Move string concatenation methods to a new header to simplify down UString.h. Remove is8Bit().
+
+ * WebView/WebScriptDebugger.mm:
+ (toNSString):
+
2010-08-10 David Hyatt <hyatt at apple.com>
Reviewed by Dan Bernstein.
diff --git a/WebKit/mac/WebView/WebScriptDebugger.mm b/WebKit/mac/WebView/WebScriptDebugger.mm
index c5e0ac8..f67b46f 100644
--- a/WebKit/mac/WebView/WebScriptDebugger.mm
+++ b/WebKit/mac/WebView/WebScriptDebugger.mm
@@ -54,7 +54,7 @@ NSString *toNSString(const UString& s)
{
if (s.isEmpty())
return nil;
- return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(s.data()) length:s.size()];
+ return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(s.characters()) length:s.length()];
}
static NSString *toNSString(const SourceCode& s)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list