diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
commit | 284837daa07b29d6a63a748544a90b1f5842ac5c (patch) | |
tree | ecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/JavaScriptCore/API | |
parent | 2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff) | |
download | qtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz |
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/JavaScriptCore/API')
-rw-r--r-- | Source/JavaScriptCore/API/JSBase.cpp | 6 | ||||
-rw-r--r-- | Source/JavaScriptCore/API/JSCallbackFunction.cpp | 2 | ||||
-rw-r--r-- | Source/JavaScriptCore/API/JSCallbackFunction.h | 4 | ||||
-rw-r--r-- | Source/JavaScriptCore/API/JSCallbackObject.h | 2 | ||||
-rw-r--r-- | Source/JavaScriptCore/API/JSCallbackObjectFunctions.h | 8 | ||||
-rw-r--r-- | Source/JavaScriptCore/API/JSClassRef.cpp | 24 | ||||
-rw-r--r-- | Source/JavaScriptCore/API/JSClassRef.h | 8 | ||||
-rw-r--r-- | Source/JavaScriptCore/API/JSContextRef.cpp | 28 | ||||
-rw-r--r-- | Source/JavaScriptCore/API/JSObjectRef.cpp | 10 | ||||
-rw-r--r-- | Source/JavaScriptCore/API/JSProfilerPrivate.cpp | 4 | ||||
-rw-r--r-- | Source/JavaScriptCore/API/JSStringRefCF.cpp | 1 | ||||
-rw-r--r-- | Source/JavaScriptCore/API/JSValueRef.cpp | 8 | ||||
-rw-r--r-- | Source/JavaScriptCore/API/OpaqueJSString.cpp | 12 | ||||
-rw-r--r-- | Source/JavaScriptCore/API/OpaqueJSString.h | 6 |
14 files changed, 54 insertions, 69 deletions
diff --git a/Source/JavaScriptCore/API/JSBase.cpp b/Source/JavaScriptCore/API/JSBase.cpp index d0ffa3114..677c68187 100644 --- a/Source/JavaScriptCore/API/JSBase.cpp +++ b/Source/JavaScriptCore/API/JSBase.cpp @@ -50,10 +50,10 @@ JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef th // evaluate sets "this" to the global object if it is NULL JSGlobalObject* globalObject = exec->dynamicGlobalObject(); - SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first())); + SourceCode source = makeSource(script->string(), sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first())); JSValue evaluationException; - JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject, &evaluationException); + JSValue returnValue = evaluate(globalObject->globalExec(), source, jsThisObject, &evaluationException); if (evaluationException) { if (exception) @@ -73,7 +73,7 @@ bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourc ExecState* exec = toJS(ctx); APIEntryShim entryShim(exec); - SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first())); + SourceCode source = makeSource(script->string(), sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first())); JSValue syntaxException; bool isValidSyntax = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source, &syntaxException); diff --git a/Source/JavaScriptCore/API/JSCallbackFunction.cpp b/Source/JavaScriptCore/API/JSCallbackFunction.cpp index 59de186b0..0f63d3c16 100644 --- a/Source/JavaScriptCore/API/JSCallbackFunction.cpp +++ b/Source/JavaScriptCore/API/JSCallbackFunction.cpp @@ -49,7 +49,7 @@ JSCallbackFunction::JSCallbackFunction(JSGlobalObject* globalObject, JSObjectCal { } -void JSCallbackFunction::finishCreation(JSGlobalData& globalData, const UString& name) +void JSCallbackFunction::finishCreation(JSGlobalData& globalData, const String& name) { Base::finishCreation(globalData, name); ASSERT(inherits(&s_info)); diff --git a/Source/JavaScriptCore/API/JSCallbackFunction.h b/Source/JavaScriptCore/API/JSCallbackFunction.h index 40bef8c48..50630b550 100644 --- a/Source/JavaScriptCore/API/JSCallbackFunction.h +++ b/Source/JavaScriptCore/API/JSCallbackFunction.h @@ -34,12 +34,12 @@ namespace JSC { class JSCallbackFunction : public InternalFunction { protected: JSCallbackFunction(JSGlobalObject*, JSObjectCallAsFunctionCallback); - void finishCreation(JSGlobalData&, const UString& name); + void finishCreation(JSGlobalData&, const String& name); public: typedef InternalFunction Base; - static JSCallbackFunction* create(ExecState* exec, JSGlobalObject* globalObject, JSObjectCallAsFunctionCallback callback, const UString& name) + static JSCallbackFunction* create(ExecState* exec, JSGlobalObject* globalObject, JSObjectCallAsFunctionCallback callback, const String& name) { JSCallbackFunction* function = new (NotNull, allocateCell<JSCallbackFunction>(*exec->heap())) JSCallbackFunction(globalObject, callback); function->finishCreation(exec->globalData(), name); diff --git a/Source/JavaScriptCore/API/JSCallbackObject.h b/Source/JavaScriptCore/API/JSCallbackObject.h index 2c3e0e859..36d7fa9c2 100644 --- a/Source/JavaScriptCore/API/JSCallbackObject.h +++ b/Source/JavaScriptCore/API/JSCallbackObject.h @@ -171,7 +171,7 @@ protected: static const unsigned StructureFlags = ProhibitsPropertyCaching | OverridesGetOwnPropertySlot | ImplementsHasInstance | OverridesHasInstance | OverridesVisitChildren | OverridesGetPropertyNames | Parent::StructureFlags; private: - static UString className(const JSObject*); + static String className(const JSObject*); static void destroy(JSCell*); diff --git a/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h b/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h index 160f48887..0691dafc3 100644 --- a/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h +++ b/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h @@ -111,10 +111,10 @@ void JSCallbackObject<Parent>::init(ExecState* exec) } template <class Parent> -UString JSCallbackObject<Parent>::className(const JSObject* object) +String JSCallbackObject<Parent>::className(const JSObject* object) { const JSCallbackObject* thisObject = jsCast<const JSCallbackObject*>(object); - UString thisClassName = thisObject->classRef()->className(); + String thisClassName = thisObject->classRef()->className(); if (!thisClassName.isEmpty()) return thisClassName; @@ -568,7 +568,7 @@ JSValue JSCallbackObject<Parent>::staticFunctionGetter(ExecState* exec, JSValue } } - return throwError(exec, createReferenceError(exec, "Static function property defined with NULL callAsFunction callback.")); + return throwError(exec, createReferenceError(exec, ASCIILiteral("Static function property defined with NULL callAsFunction callback."))); } template <class Parent> @@ -600,7 +600,7 @@ JSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, JSValue slotPa } } - return throwError(exec, createReferenceError(exec, "hasProperty callback returned true for a property that doesn't exist.")); + return throwError(exec, createReferenceError(exec, ASCIILiteral("hasProperty callback returned true for a property that doesn't exist."))); } } // namespace JSC diff --git a/Source/JavaScriptCore/API/JSClassRef.cpp b/Source/JavaScriptCore/API/JSClassRef.cpp index 134431654..a95d42e39 100644 --- a/Source/JavaScriptCore/API/JSClassRef.cpp +++ b/Source/JavaScriptCore/API/JSClassRef.cpp @@ -42,20 +42,6 @@ using namespace WTF::Unicode; const JSClassDefinition kJSClassDefinitionEmpty = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -static inline UString tryCreateStringFromUTF8(const char* string) -{ - if (!string) - return UString(); - - size_t length = strlen(string); - Vector<UChar, 1024> buffer(length); - UChar* p = buffer.data(); - if (conversionOK != convertUTF8ToUTF16(&string, string + length, &p, p + length)) - return UString(); - - return UString(buffer.data(), p - buffer.data()); -} - OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* protoClass) : parentClass(definition->parentClass) , prototypeClass(0) @@ -70,14 +56,14 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* , callAsConstructor(definition->callAsConstructor) , hasInstance(definition->hasInstance) , convertToType(definition->convertToType) - , m_className(tryCreateStringFromUTF8(definition->className)) + , m_className(String::fromUTF8(definition->className)) { initializeThreading(); if (const JSStaticValue* staticValue = definition->staticValues) { m_staticValues = adoptPtr(new OpaqueJSClassStaticValuesTable); while (staticValue->name) { - UString valueName = tryCreateStringFromUTF8(staticValue->name); + String valueName = String::fromUTF8(staticValue->name); if (!valueName.isNull()) m_staticValues->set(valueName.impl(), adoptPtr(new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes))); ++staticValue; @@ -87,7 +73,7 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* if (const JSStaticFunction* staticFunction = definition->staticFunctions) { m_staticFunctions = adoptPtr(new OpaqueJSClassStaticFunctionsTable); while (staticFunction->name) { - UString functionName = tryCreateStringFromUTF8(staticFunction->name); + String functionName = String::fromUTF8(staticFunction->name); if (!functionName.isNull()) m_staticFunctions->set(functionName.impl(), adoptPtr(new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes))); ++staticFunction; @@ -170,10 +156,10 @@ OpaqueJSClassContextData& OpaqueJSClass::contextData(ExecState* exec) return *contextData; } -UString OpaqueJSClass::className() +String OpaqueJSClass::className() { // Make a deep copy, so that the caller has no chance to put the original into IdentifierTable. - return UString(m_className.characters(), m_className.length()); + return m_className.isolatedCopy(); } OpaqueJSClassStaticValuesTable* OpaqueJSClass::staticValues(JSC::ExecState* exec) diff --git a/Source/JavaScriptCore/API/JSClassRef.h b/Source/JavaScriptCore/API/JSClassRef.h index 82c7ab3f9..44d5d11b9 100644 --- a/Source/JavaScriptCore/API/JSClassRef.h +++ b/Source/JavaScriptCore/API/JSClassRef.h @@ -31,8 +31,8 @@ #include "Weak.h" #include "JSObject.h" #include "Protect.h" -#include "UString.h" #include <wtf/HashMap.h> +#include <wtf/text/WTFString.h> struct StaticValueEntry { WTF_MAKE_FAST_ALLOCATED; @@ -89,7 +89,7 @@ struct OpaqueJSClass : public ThreadSafeRefCounted<OpaqueJSClass> { static PassRefPtr<OpaqueJSClass> createNoAutomaticPrototype(const JSClassDefinition*); ~OpaqueJSClass(); - JSC::UString className(); + String className(); OpaqueJSClassStaticValuesTable* staticValues(JSC::ExecState*); OpaqueJSClassStaticFunctionsTable* staticFunctions(JSC::ExecState*); JSC::JSObject* prototype(JSC::ExecState*); @@ -118,8 +118,8 @@ private: OpaqueJSClassContextData& contextData(JSC::ExecState*); - // UStrings in these data members should not be put into any IdentifierTable. - JSC::UString m_className; + // Strings in these data members should not be put into any IdentifierTable. + String m_className; OwnPtr<OpaqueJSClassStaticValuesTable> m_staticValues; OwnPtr<OpaqueJSClassStaticFunctionsTable> m_staticFunctions; }; diff --git a/Source/JavaScriptCore/API/JSContextRef.cpp b/Source/JavaScriptCore/API/JSContextRef.cpp index 7a57287de..7c815355b 100644 --- a/Source/JavaScriptCore/API/JSContextRef.cpp +++ b/Source/JavaScriptCore/API/JSContextRef.cpp @@ -35,7 +35,7 @@ #include "JSClassRef.h" #include "JSGlobalObject.h" #include "JSObject.h" -#include "UStringBuilder.h" +#include <wtf/text/StringBuilder.h> #include <wtf/text/StringHash.h> #if OS(DARWIN) @@ -167,15 +167,15 @@ JSStringRef JSContextCreateBacktrace(JSContextRef ctx, unsigned maxStackSize) JSLockHolder lock(exec); unsigned count = 0; - UStringBuilder builder; + StringBuilder builder; CallFrame* callFrame = exec; - UString functionName; + String functionName; if (exec->callee()) { if (asObject(exec->callee())->inherits(&InternalFunction::s_info)) { functionName = asInternalFunction(exec->callee())->name(exec); - builder.append("#0 "); + builder.appendLiteral("#0 "); builder.append(functionName); - builder.append("() "); + builder.appendLiteral("() "); count++; } } @@ -183,10 +183,10 @@ JSStringRef JSContextCreateBacktrace(JSContextRef ctx, unsigned maxStackSize) ASSERT(callFrame); int signedLineNumber; intptr_t sourceID; - UString urlString; + String urlString; JSValue function; - UString levelStr = UString::number(count); + String levelStr = String::number(count); exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function); @@ -200,20 +200,20 @@ JSStringRef JSContextCreateBacktrace(JSContextRef ctx, unsigned maxStackSize) } unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0; if (!builder.isEmpty()) - builder.append("\n"); - builder.append("#"); + builder.append('\n'); + builder.append('#'); builder.append(levelStr); - builder.append(" "); + builder.append(' '); builder.append(functionName); - builder.append("() at "); + builder.appendLiteral("() at "); builder.append(urlString); - builder.append(":"); - builder.append(UString::number(lineNumber)); + builder.append(':'); + builder.appendNumber(lineNumber); if (!function || ++count == maxStackSize) break; callFrame = callFrame->callerFrame(); } - return OpaqueJSString::create(builder.toUString()).leakRef(); + return OpaqueJSString::create(builder.toString()).leakRef(); } diff --git a/Source/JavaScriptCore/API/JSObjectRef.cpp b/Source/JavaScriptCore/API/JSObjectRef.cpp index e6c0c528a..e206cb16f 100644 --- a/Source/JavaScriptCore/API/JSObjectRef.cpp +++ b/Source/JavaScriptCore/API/JSObjectRef.cpp @@ -92,7 +92,7 @@ JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, { ExecState* exec = toJS(ctx); APIEntryShim entryShim(exec); - return toRef(JSCallbackFunction::create(exec, exec->lexicalGlobalObject(), callAsFunction, name ? name->ustring() : "anonymous")); + return toRef(JSCallbackFunction::create(exec, exec->lexicalGlobalObject(), callAsFunction, name ? name->string() : ASCIILiteral("anonymous"))); } JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor) @@ -118,10 +118,10 @@ JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned pa MarkedArgumentBuffer args; for (unsigned i = 0; i < parameterCount; i++) - args.append(jsString(exec, parameterNames[i]->ustring())); - args.append(jsString(exec, body->ustring())); + args.append(jsString(exec, parameterNames[i]->string())); + args.append(jsString(exec, body->string())); - JSObject* result = constructFunction(exec, exec->lexicalGlobalObject(), args, nameID, sourceURL->ustring(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first())); + JSObject* result = constructFunction(exec, exec->lexicalGlobalObject(), args, nameID, sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first())); if (exec->hadException()) { if (exception) *exception = toRef(exec, exec->exception()); @@ -510,7 +510,7 @@ JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef o size_t size = array.size(); propertyNames->array.reserveInitialCapacity(size); for (size_t i = 0; i < size; ++i) - propertyNames->array.append(JSRetainPtr<JSStringRef>(Adopt, OpaqueJSString::create(array[i].ustring()).leakRef())); + propertyNames->array.append(JSRetainPtr<JSStringRef>(Adopt, OpaqueJSString::create(array[i].string()).leakRef())); return JSPropertyNameArrayRetain(propertyNames); } diff --git a/Source/JavaScriptCore/API/JSProfilerPrivate.cpp b/Source/JavaScriptCore/API/JSProfilerPrivate.cpp index ea277f059..c83bc63bd 100644 --- a/Source/JavaScriptCore/API/JSProfilerPrivate.cpp +++ b/Source/JavaScriptCore/API/JSProfilerPrivate.cpp @@ -34,13 +34,13 @@ using namespace JSC; void JSStartProfiling(JSContextRef ctx, JSStringRef title) { - Profiler::profiler()->startProfiling(toJS(ctx), title->ustring()); + Profiler::profiler()->startProfiling(toJS(ctx), title->string()); } void JSEndProfiling(JSContextRef ctx, JSStringRef title) { ExecState* exec = toJS(ctx); Profiler* profiler = Profiler::profiler(); - profiler->stopProfiling(exec, title->ustring()); + profiler->stopProfiling(exec, title->string()); } diff --git a/Source/JavaScriptCore/API/JSStringRefCF.cpp b/Source/JavaScriptCore/API/JSStringRefCF.cpp index 0877a13e6..e87fd838d 100644 --- a/Source/JavaScriptCore/API/JSStringRefCF.cpp +++ b/Source/JavaScriptCore/API/JSStringRefCF.cpp @@ -30,7 +30,6 @@ #include "InitializeThreading.h" #include "JSStringRef.h" #include "OpaqueJSString.h" -#include <runtime/UString.h> #include <runtime/JSValue.h> #include <wtf/OwnArrayPtr.h> diff --git a/Source/JavaScriptCore/API/JSValueRef.cpp b/Source/JavaScriptCore/API/JSValueRef.cpp index 9b7268a2d..4c986c253 100644 --- a/Source/JavaScriptCore/API/JSValueRef.cpp +++ b/Source/JavaScriptCore/API/JSValueRef.cpp @@ -36,11 +36,11 @@ #include <runtime/LiteralParser.h> #include <runtime/Operations.h> #include <runtime/Protect.h> -#include <runtime/UString.h> #include <runtime/JSValue.h> #include <wtf/Assertions.h> #include <wtf/text/StringHash.h> +#include <wtf/text/WTFString.h> #include <algorithm> // for std::min @@ -227,14 +227,14 @@ JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string) ExecState* exec = toJS(ctx); APIEntryShim entryShim(exec); - return toRef(exec, jsString(exec, string->ustring())); + return toRef(exec, jsString(exec, string->string())); } JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string) { ExecState* exec = toJS(ctx); APIEntryShim entryShim(exec); - UString str = string->ustring(); + String str = string->string(); if (str.is8Bit()) { LiteralParser<LChar> parser(exec, str.characters8(), str.length(), StrictJSON); return toRef(exec, parser.tryLiteralParse()); @@ -248,7 +248,7 @@ JSStringRef JSValueCreateJSONString(JSContextRef ctx, JSValueRef apiValue, unsig ExecState* exec = toJS(ctx); APIEntryShim entryShim(exec); JSValue value = toJS(exec, apiValue); - UString result = JSONStringify(exec, value, indent); + String result = JSONStringify(exec, value, indent); if (exception) *exception = 0; if (exec->hadException()) { diff --git a/Source/JavaScriptCore/API/OpaqueJSString.cpp b/Source/JavaScriptCore/API/OpaqueJSString.cpp index 9a116e6b2..457cb27f7 100644 --- a/Source/JavaScriptCore/API/OpaqueJSString.cpp +++ b/Source/JavaScriptCore/API/OpaqueJSString.cpp @@ -32,18 +32,18 @@ using namespace JSC; -PassRefPtr<OpaqueJSString> OpaqueJSString::create(const UString& ustring) +PassRefPtr<OpaqueJSString> OpaqueJSString::create(const String& string) { - if (!ustring.isNull()) - return adoptRef(new OpaqueJSString(ustring.characters(), ustring.length())); + if (!string.isNull()) + return adoptRef(new OpaqueJSString(string.characters(), string.length())); return 0; } -UString OpaqueJSString::ustring() const +String OpaqueJSString::string() const { if (this && m_characters) - return UString(m_characters, m_length); - return UString(); + return String(m_characters, m_length); + return String(); } Identifier OpaqueJSString::identifier(JSGlobalData* globalData) const diff --git a/Source/JavaScriptCore/API/OpaqueJSString.h b/Source/JavaScriptCore/API/OpaqueJSString.h index 1c63150cf..35543cdd6 100644 --- a/Source/JavaScriptCore/API/OpaqueJSString.h +++ b/Source/JavaScriptCore/API/OpaqueJSString.h @@ -27,7 +27,7 @@ #define OpaqueJSString_h #include <wtf/ThreadSafeRefCounted.h> -#include <runtime/UString.h> +#include <wtf/text/WTFString.h> namespace JSC { class Identifier; @@ -46,12 +46,12 @@ struct OpaqueJSString : public ThreadSafeRefCounted<OpaqueJSString> { return adoptRef(new OpaqueJSString(characters, length)); } - JS_EXPORT_PRIVATE static PassRefPtr<OpaqueJSString> create(const JSC::UString&); + JS_EXPORT_PRIVATE static PassRefPtr<OpaqueJSString> create(const String&); UChar* characters() { return this ? m_characters : 0; } unsigned length() { return this ? m_length : 0; } - JSC::UString ustring() const; + String string() const; JSC::Identifier identifier(JSC::JSGlobalData*) const; private: |