diff options
author | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2009-08-18 09:01:33 (GMT) |
---|---|---|
committer | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2009-08-18 09:15:11 (GMT) |
commit | 60ad9486a959ac1beb9b850be18fbb787173cfa0 (patch) | |
tree | a9b080f78861ed9d9bcb745d84e320bcc57326a4 /src/script | |
parent | 4d92ed2203ced87802e3e91e530209619d7d2e71 (diff) | |
download | Qt-60ad9486a959ac1beb9b850be18fbb787173cfa0.zip Qt-60ad9486a959ac1beb9b850be18fbb787173cfa0.tar.gz Qt-60ad9486a959ac1beb9b850be18fbb787173cfa0.tar.bz2 |
Clean up.
Get rid of conversion functions QScript::qtStringFromJSCUString and
QScript::qtStringToJSCUString. Code was moved to cast operators.
Reviewed-by: Kent Hansen
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/qscriptcontext.cpp | 4 | ||||
-rw-r--r-- | src/script/api/qscriptcontextinfo.cpp | 11 | ||||
-rw-r--r-- | src/script/api/qscriptengine.cpp | 68 | ||||
-rw-r--r-- | src/script/api/qscriptengine_p.h | 2 | ||||
-rw-r--r-- | src/script/api/qscriptengineagent_p.h | 2 | ||||
-rw-r--r-- | src/script/api/qscriptstring.cpp | 6 | ||||
-rw-r--r-- | src/script/api/qscriptvalue.cpp | 20 | ||||
-rw-r--r-- | src/script/api/qscriptvalueiterator.cpp | 2 | ||||
-rw-r--r-- | src/script/bridge/qscriptclassobject.cpp | 10 | ||||
-rw-r--r-- | src/script/bridge/qscriptqobject.cpp | 56 | ||||
-rw-r--r-- | src/script/bridge/qscriptvariant.cpp | 4 |
11 files changed, 81 insertions, 104 deletions
diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp index e213f3b..229c8ab 100644 --- a/src/script/api/qscriptcontext.cpp +++ b/src/script/api/qscriptcontext.cpp @@ -221,7 +221,7 @@ QScriptValue QScriptContext::throwError(Error error, const QString &text) jscError = JSC::URIError; break; } - JSC::JSObject *result = JSC::throwError(frame, jscError, QScript::qtStringToJSCUString(text)); + JSC::JSObject *result = JSC::throwError(frame, jscError, text); return QScript::scriptEngineFromExec(frame)->scriptValueFromJSCValue(result); } @@ -236,7 +236,7 @@ QScriptValue QScriptContext::throwError(Error error, const QString &text) QScriptValue QScriptContext::throwError(const QString &text) { JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this); - JSC::JSObject *result = JSC::throwError(frame, JSC::GeneralError, QScript::qtStringToJSCUString(text)); + JSC::JSObject *result = JSC::throwError(frame, JSC::GeneralError, text); return QScript::scriptEngineFromExec(frame)->scriptValueFromJSCValue(result); } diff --git a/src/script/api/qscriptcontextinfo.cpp b/src/script/api/qscriptcontextinfo.cpp index 294c48a..bd121a1 100644 --- a/src/script/api/qscriptcontextinfo.cpp +++ b/src/script/api/qscriptcontextinfo.cpp @@ -97,11 +97,6 @@ QT_BEGIN_NAMESPACE \value NativeFunction The function is a built-in Qt Script function, or it was defined through a call to QScriptEngine::newFunction(). */ -namespace QScript -{ -QString qtStringFromJSCUString(const JSC::UString &str); -} - class QScriptContextInfoPrivate { Q_DECLARE_PUBLIC(QScriptContextInfo) @@ -187,13 +182,13 @@ QScriptContextInfoPrivate::QScriptContextInfoPrivate(const QScriptContext *conte if (codeBlock) { JSC::SourceProvider *source = codeBlock->source(); scriptId = source->asID(); - fileName = QScript::qtStringFromJSCUString(source->url()); + fileName = source->url(); } // Get the others informations: JSC::JSObject *callee = frame->callee(); if (callee && callee->isObject(&JSC::InternalFunction::info)) - functionName = QScript::qtStringFromJSCUString(JSC::asInternalFunction(callee)->name(&frame->globalData())); + functionName = JSC::asInternalFunction(callee)->name(&frame->globalData()); if (callee && callee->isObject(&JSC::JSFunction::info)) { functionType = QScriptContextInfo::ScriptFunction; JSC::FunctionBodyNode *body = JSC::asFunction(callee)->body(); @@ -201,7 +196,7 @@ QScriptContextInfoPrivate::QScriptContextInfoPrivate(const QScriptContext *conte functionEndLineNumber = body->lastLine(); const JSC::Identifier* params = body->parameters(); for (size_t i = 0; i < body->parameterCount(); ++i) - parameterNames.append(QScript::qtStringFromJSCUString(params[i].ustring())); + parameterNames.append(params[i].ustring()); // ### get the function name from the AST } else if (callee && callee->isObject(&QScript::QtFunction::info)) { functionType = QScriptContextInfo::QtFunction; diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index eef0b5d..63041db 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -452,16 +452,6 @@ qsreal integerFromString(const QString &str, int radix) return integerFromString(ba.constData(), ba.size(), radix); } -JSC::UString qtStringToJSCUString(const QString &str) -{ - return JSC::UString(reinterpret_cast<const UChar*>(str.constData()), str.length()); -} - -QString qtStringFromJSCUString(const JSC::UString &str) -{ - return QString(reinterpret_cast<const QChar*>(str.data()), str.size()); -} - QScriptEnginePrivate *scriptEngineFromExec(const JSC::ExecState *exec) { return static_cast<GlobalClientData*>(exec->globalData().clientData)->engine; @@ -501,7 +491,7 @@ JSC::JSValue JSC_HOST_CALL functionDisconnect(JSC::ExecState *exec, JSC::JSObjec QString message = QString::fromLatin1("Function.prototype.disconnect: %0::%1 is not a signal") .arg(QLatin1String(qtSignal->metaObject()->className())) .arg(QLatin1String(sig.signature())); - return JSC::throwError(exec, JSC::TypeError, QScript::qtStringToJSCUString(message)); + return JSC::throwError(exec, JSC::TypeError, message); } QScriptEnginePrivate *engine = scriptEngineFromExec(exec); @@ -519,7 +509,7 @@ JSC::JSValue JSC_HOST_CALL functionDisconnect(JSC::ExecState *exec, JSC::JSObjec else { // ### don't go via QScriptValue QScriptValue tmp = engine->scriptValueFromJSCValue(arg0); - QString propertyName = QScript::qtStringFromJSCUString(arg1.toString(exec)); + QString propertyName(arg1.toString(exec)); slot = engine->scriptValueToJSCValue(tmp.property(propertyName, QScriptValue::ResolvePrototype)); } } @@ -533,7 +523,7 @@ JSC::JSValue JSC_HOST_CALL functionDisconnect(JSC::ExecState *exec, JSC::JSObjec QString message = QString::fromLatin1("Function.prototype.disconnect: failed to disconnect from %0::%1") .arg(QLatin1String(qtSignal->metaObject()->className())) .arg(QLatin1String(sig.signature())); - return JSC::throwError(exec, JSC::GeneralError, qtStringToJSCUString(message)); + return JSC::throwError(exec, JSC::GeneralError, message); } return JSC::jsUndefined(); #else @@ -566,7 +556,7 @@ JSC::JSValue JSC_HOST_CALL functionConnect(JSC::ExecState *exec, JSC::JSObject * QString message = QString::fromLatin1("Function.prototype.connect: %0::%1 is not a signal") .arg(QLatin1String(qtSignal->metaObject()->className())) .arg(QLatin1String(sig.signature())); - return JSC::throwError(exec, JSC::TypeError, QScript::qtStringToJSCUString(message)); + return JSC::throwError(exec, JSC::TypeError, message); } { @@ -583,7 +573,7 @@ JSC::JSValue JSC_HOST_CALL functionConnect(JSC::ExecState *exec, JSC::JSObject * } message.append(QString::fromLatin1("Use e.g. object['%0'].connect() to connect to a particular overload") .arg(QLatin1String(signature))); - return JSC::throwError(exec, JSC::GeneralError, qtStringToJSCUString(message)); + return JSC::throwError(exec, JSC::GeneralError, message); } } @@ -602,7 +592,7 @@ JSC::JSValue JSC_HOST_CALL functionConnect(JSC::ExecState *exec, JSC::JSObject * else { // ### don't go via QScriptValue QScriptValue tmp = engine->scriptValueFromJSCValue(arg0); - QString propertyName = QScript::qtStringFromJSCUString(arg1.toString(exec)); + QString propertyName = arg1.toString(exec); slot = engine->scriptValueToJSCValue(tmp.property(propertyName, QScriptValue::ResolvePrototype)); } } @@ -616,7 +606,7 @@ JSC::JSValue JSC_HOST_CALL functionConnect(JSC::ExecState *exec, JSC::JSObject * QString message = QString::fromLatin1("Function.prototype.connect: failed to connect to %0::%1") .arg(QLatin1String(qtSignal->metaObject()->className())) .arg(QLatin1String(sig.signature())); - return JSC::throwError(exec, JSC::GeneralError, qtStringToJSCUString(message)); + return JSC::throwError(exec, JSC::GeneralError, message); } return JSC::jsUndefined(); #else @@ -637,7 +627,7 @@ JSC::JSValue JSC_HOST_CALL functionPrint(JSC::ExecState* exec, JSC::JSObject*, J for (unsigned i = 0; i < args.size(); ++i) { if (i != 0) result.append(QLatin1Char(' ')); - QString s = QScript::qtStringFromJSCUString(args.at(i).toString(exec)); + QString s(args.at(i).toString(exec)); if (exec->hadException()) break; result.append(s); @@ -680,22 +670,22 @@ JSC::JSValue JSC_HOST_CALL functionQsTranslate(JSC::ExecState *exec, JSC::JSObje if ((args.size() > 4) && !args.at(4).isNumber()) return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): fifth argument (n) must be a number"); #ifndef QT_NO_QOBJECT - QString context = qtStringFromJSCUString(args.at(0).toString(exec)); + QString context(args.at(0).toString(exec)); #endif - QString text = qtStringFromJSCUString(args.at(1).toString(exec)); + QString text(args.at(1).toString(exec)); #ifndef QT_NO_QOBJECT QString comment; if (args.size() > 2) - comment = qtStringFromJSCUString(args.at(2).toString(exec)); + comment = args.at(2).toString(exec); QCoreApplication::Encoding encoding = QCoreApplication::CodecForTr; if (args.size() > 3) { - QString encStr = qtStringFromJSCUString(args.at(3).toString(exec)); + QString encStr(args.at(3).toString(exec)); if (encStr == QLatin1String("CodecForTr")) encoding = QCoreApplication::CodecForTr; else if (encStr == QLatin1String("UnicodeUTF8")) encoding = QCoreApplication::UnicodeUTF8; else - return JSC::throwError(exec, JSC::GeneralError, qtStringToJSCUString(QString::fromLatin1("qsTranslate(): invalid encoding '%s'").arg(encStr))); + return JSC::throwError(exec, JSC::GeneralError, QString::fromLatin1("qsTranslate(): invalid encoding '%s'").arg(encStr)); } int n = -1; if (args.size() > 4) @@ -710,7 +700,7 @@ JSC::JSValue JSC_HOST_CALL functionQsTranslate(JSC::ExecState *exec, JSC::JSObje #else result = text; #endif - return JSC::jsString(exec, qtStringToJSCUString(result)); + return JSC::jsString(exec, result); } JSC::JSValue JSC_HOST_CALL functionQsTranslateNoOp(JSC::ExecState *, JSC::JSObject*, JSC::JSValue, const JSC::ArgList &args) @@ -736,11 +726,11 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS // if (ctx->parentContext()) // context = QFileInfo(ctx->parentContext()->fileName()).baseName(); #endif - QString text = qtStringFromJSCUString(args.at(0).toString(exec)); + QString text(args.at(0).toString(exec)); #ifndef QT_NO_QOBJECT QString comment; if (args.size() > 1) - comment = qtStringFromJSCUString(args.at(1).toString(exec)); + comment = args.at(1).toString(exec); int n = -1; if (args.size() > 2) n = args.at(2).toInt32(exec); @@ -754,7 +744,7 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS #else result = text; #endif - return JSC::jsString(exec, qtStringToJSCUString(result)); + return JSC::jsString(exec, result); } JSC::JSValue JSC_HOST_CALL functionQsTrNoOp(JSC::ExecState *, JSC::JSObject*, JSC::JSValue, const JSC::ArgList &args) @@ -768,14 +758,14 @@ static JSC::JSValue JSC_HOST_CALL stringProtoFuncArg(JSC::ExecState*, JSC::JSObj JSC::JSValue JSC_HOST_CALL stringProtoFuncArg(JSC::ExecState *exec, JSC::JSObject*, JSC::JSValue thisObject, const JSC::ArgList &args) { - QString value = qtStringFromJSCUString(thisObject.toString(exec)); + QString value(thisObject.toString(exec)); JSC::JSValue arg = (args.size() != 0) ? args.at(0) : JSC::jsUndefined(); QString result; if (arg.isString()) - result = value.arg(qtStringFromJSCUString(arg.toString(exec))); + result = value.arg(arg.toString(exec)); else if (arg.isNumber()) result = value.arg(arg.toNumber(exec)); - return JSC::jsString(exec, qtStringToJSCUString(result)); + return JSC::jsString(exec, result); } @@ -874,7 +864,7 @@ JSC::JSValue QScriptEnginePrivate::scriptValueToJSCValue(const QScriptValue &val if (vv->type == QScriptValuePrivate::Number) { vv->initFromJSCValue(JSC::jsNumber(currentFrame, vv->numberValue)); } else { //QScriptValuePrivate::String - vv->initFromJSCValue(JSC::jsString(currentFrame, QScript::qtStringToJSCUString(vv->stringValue))); + vv->initFromJSCValue(JSC::jsString(currentFrame, vv->stringValue)); } } return vv->jscValue; @@ -933,7 +923,7 @@ JSC::JSValue QScriptEnginePrivate::jscValueFromVariant(const QVariant &v) case QScriptValuePrivate::Number: return JSC::jsNumber(currentFrame, p->numberValue); case QScriptValuePrivate::String: { - JSC::UString str = QScript::qtStringToJSCUString(p->stringValue); + JSC::UString str = p->stringValue; return JSC::jsString(currentFrame, str); } } @@ -1599,11 +1589,11 @@ QScriptValue QScriptEngine::newRegExp(const QRegExp ®exp) pattern = ecmaPattern; } - JSC::UString jscPattern = QScript::qtStringToJSCUString(pattern); + JSC::UString jscPattern = pattern; QString flags; if (regexp.caseSensitivity() == Qt::CaseInsensitive) flags.append(QLatin1Char('i')); - JSC::UString jscFlags = QScript::qtStringToJSCUString(flags); + JSC::UString jscFlags = flags; buf[0] = JSC::jsString(exec, jscPattern); buf[1] = JSC::jsString(exec, jscFlags); JSC::JSObject* result = JSC::constructRegExp(exec, args); @@ -1916,7 +1906,7 @@ QScriptValue QScriptEngine::newRegExp(const QString &pattern, const QString &fla JSC::ExecState* exec = d->currentFrame; JSC::JSValue buf[2]; JSC::ArgList args(buf, sizeof(buf)); - JSC::UString jscPattern = QScript::qtStringToJSCUString(pattern); + JSC::UString jscPattern = pattern; QString strippedFlags; if (flags.contains(QLatin1Char('i'))) strippedFlags += QLatin1Char('i'); @@ -1924,7 +1914,7 @@ QScriptValue QScriptEngine::newRegExp(const QString &pattern, const QString &fla strippedFlags += QLatin1Char('m'); if (flags.contains(QLatin1Char('g'))) strippedFlags += QLatin1Char('g'); - JSC::UString jscFlags = QScript::qtStringToJSCUString(strippedFlags); + JSC::UString jscFlags = strippedFlags; buf[0] = JSC::jsString(exec, jscPattern); buf[1] = JSC::jsString(exec, jscFlags); JSC::JSObject* result = JSC::constructRegExp(exec, args); @@ -2153,8 +2143,8 @@ QScriptValue QScriptEngine::evaluate(const QString &program, const QString &file JSC::JSLock lock(false); // ### hmmm currentContext()->activationObject(); //force the creation of a context for native function; - JSC::UString jscProgram = QScript::qtStringToJSCUString(program); - JSC::UString jscFileName = QScript::qtStringToJSCUString(fileName); + JSC::UString jscProgram = program; + JSC::UString jscFileName = fileName; JSC::ExecState* exec = d->currentFrame; JSC::SourceCode source = JSC::makeSource(jscProgram, jscFileName, lineNumber); @@ -3648,7 +3638,7 @@ QScriptString QScriptEngine::toStringHandle(const QString &str) { Q_D(QScriptEngine); QScriptString ss; - QScriptStringPrivate::init(ss, this, JSC::Identifier(d->currentFrame, QScript::qtStringToJSCUString(str))); + QScriptStringPrivate::init(ss, this, JSC::Identifier(d->currentFrame, str)); return ss; } diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index 1f59d36..53972a2 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -97,8 +97,6 @@ namespace QScript class TimeoutCheckerProxy; //some conversion helper functions - JSC::UString qtStringToJSCUString(const QString &str); - QString qtStringFromJSCUString(const JSC::UString &str); QScriptEnginePrivate *scriptEngineFromExec(const JSC::ExecState *exec); bool isFunction(const JSC::JSValue &value); } diff --git a/src/script/api/qscriptengineagent_p.h b/src/script/api/qscriptengineagent_p.h index 20b4925..6f400c8 100644 --- a/src/script/api/qscriptengineagent_p.h +++ b/src/script/api/qscriptengineagent_p.h @@ -91,7 +91,7 @@ public: virtual void scriptLoad(qint64 id, const JSC::UString &program, const JSC::UString &fileName, int baseLineNumber) { - q_ptr->scriptLoad(id,program.toQString(), fileName.toQString(), baseLineNumber); + q_ptr->scriptLoad(id,program, fileName, baseLineNumber); }; //exceptions diff --git a/src/script/api/qscriptstring.cpp b/src/script/api/qscriptstring.cpp index 0ded562..c5fd83b 100644 --- a/src/script/api/qscriptstring.cpp +++ b/src/script/api/qscriptstring.cpp @@ -46,10 +46,6 @@ QT_BEGIN_NAMESPACE -namespace QScript -{ - QString qtStringFromJSCUString(const JSC::UString &str); -} /*! \since 4.4 @@ -194,7 +190,7 @@ QString QScriptString::toString() const Q_D(const QScriptString); if (!d || !d->engine) return QString(); - return QScript::qtStringFromJSCUString(d->identifier.ustring()); + return d->identifier.ustring(); } /*! diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 3a8e544..6a8227a 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -353,8 +353,7 @@ QScriptValue QScriptValuePrivate::property(const QString &name, int resolveMode) { QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine); JSC::ExecState *exec = eng_p->currentFrame; - JSC::UString jscName = QScript::qtStringToJSCUString(name); - return property(JSC::Identifier(exec, jscName), resolveMode); + return property(JSC::Identifier(exec, name), resolveMode); } QScriptValue QScriptValuePrivate::property(const JSC::Identifier &id, int resolveMode) const @@ -594,8 +593,7 @@ QScriptValue::QScriptValue(QScriptEngine *engine, const QString &val) if (engine) { QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine); JSC::ExecState *exec = eng_p->currentFrame; - JSC::UString jscVal = QScript::qtStringToJSCUString(val); - d_ptr->initFromJSCValue(JSC::jsString(exec, jscVal)); + d_ptr->initFromJSCValue(JSC::jsString(exec, val)); } else { d_ptr->initFromString(val); } @@ -1276,10 +1274,10 @@ QString QScriptValue::toString() const } if (savedException) QScriptValuePrivate::restoreException(exec, savedException); - return QScript::qtStringFromJSCUString(str); + return str; } case QScriptValuePrivate::Number: - return QScript::qtStringFromJSCUString(JSC::UString::from(d->numberValue)); + return JSC::UString::from(d->numberValue); case QScriptValuePrivate::String: return d->stringValue; } @@ -1316,7 +1314,7 @@ qsreal QScriptValue::toNumber() const case QScriptValuePrivate::Number: return d->numberValue; case QScriptValuePrivate::String: - return QScript::qtStringToJSCUString(d->stringValue).toDouble(); + return ((JSC::UString)d->stringValue).toDouble(); } return 0; } @@ -1416,7 +1414,7 @@ qint32 QScriptValue::toInt32() const case QScriptValuePrivate::Number: return QScript::ToInt32(d->numberValue); case QScriptValuePrivate::String: - return QScript::ToInt32(QScript::qtStringToJSCUString(d->stringValue).toDouble()); + return QScript::ToInt32(((JSC::UString)d->stringValue).toDouble()); } return 0; } @@ -1451,7 +1449,7 @@ quint32 QScriptValue::toUInt32() const case QScriptValuePrivate::Number: return QScript::ToUint32(d->numberValue); case QScriptValuePrivate::String: - return QScript::ToUint32(QScript::qtStringToJSCUString(d->stringValue).toDouble()); + return QScript::ToUint32(((JSC::UString)d->stringValue).toDouble()); } return 0; } @@ -1481,7 +1479,7 @@ quint16 QScriptValue::toUInt16() const case QScriptValuePrivate::Number: return QScript::ToUint16(d->numberValue); case QScriptValuePrivate::String: - return QScript::ToUint16(QScript::qtStringToJSCUString(d->stringValue).toDouble()); + return QScript::ToUint16(((JSC::UString)d->stringValue).toDouble()); } return 0; } @@ -1516,7 +1514,7 @@ qsreal QScriptValue::toInteger() const case QScriptValuePrivate::Number: return QScript::ToInteger(d->numberValue); case QScriptValuePrivate::String: - return QScript::ToInteger(QScript::qtStringToJSCUString(d->stringValue).toDouble()); + return QScript::ToInteger(((JSC::UString)d->stringValue).toDouble()); } return 0; } diff --git a/src/script/api/qscriptvalueiterator.cpp b/src/script/api/qscriptvalueiterator.cpp index 984dea1..607570d 100644 --- a/src/script/api/qscriptvalueiterator.cpp +++ b/src/script/api/qscriptvalueiterator.cpp @@ -265,7 +265,7 @@ QString QScriptValueIterator::name() const Q_D(const QScriptValueIterator); if (!d || !d->initialized) return QString(); - return QScript::qtStringFromJSCUString(*d->current); + return *d->current; } /*! diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp index 504742a..bf886b0 100644 --- a/src/script/bridge/qscriptclassobject.cpp +++ b/src/script/bridge/qscriptclassobject.cpp @@ -97,7 +97,7 @@ bool ClassObjectDelegate::getOwnPropertySlot(QScriptObject* object, QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); - QString name = qtStringFromJSCUString(propertyName.ustring()); + QString name(propertyName.ustring()); QScriptString scriptName = QScriptEnginePrivate::get(engine)->toStringHandle(name); uint id = 0; QScriptClass::QueryFlags flags = m_scriptClass->queryProperty( @@ -116,7 +116,7 @@ void ClassObjectDelegate::put(QScriptObject* object, JSC::ExecState *exec, { QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); - QString name = qtStringFromJSCUString(propertyName.ustring()); + QString name(propertyName.ustring()); QScriptString scriptName = QScriptEnginePrivate::get(engine)->toStringHandle(name); uint id = 0; QScriptClass::QueryFlags flags = m_scriptClass->queryProperty( @@ -135,7 +135,7 @@ bool ClassObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState * // ### avoid duplication of put() QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); - QString name = qtStringFromJSCUString(propertyName.ustring()); + QString name(propertyName.ustring()); QScriptString scriptName = QScriptEnginePrivate::get(engine)->toStringHandle(name); uint id = 0; QScriptClass::QueryFlags flags = m_scriptClass->queryProperty( @@ -155,7 +155,7 @@ bool ClassObjectDelegate::getPropertyAttributes(const QScriptObject* object, JSC { QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); - QString name = qtStringFromJSCUString(propertyName.ustring()); + QString name(propertyName.ustring()); QScriptString scriptName = QScriptEnginePrivate::get(engine)->toStringHandle(name); uint id = 0; QScriptClass::QueryFlags flags = m_scriptClass->queryProperty( @@ -190,7 +190,7 @@ void ClassObjectDelegate::getPropertyNames(QScriptObject* object, JSC::ExecState while (it->hasNext()) { it->next(); QString name = it->name().toString(); - propertyNames.add(JSC::Identifier(exec, qtStringToJSCUString(name))); + propertyNames.add(JSC::Identifier(exec, name)); } delete it; } diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index ffb5d1a..e98ec8a 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -867,7 +867,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c QMetaMethod mtd = metaMethod(meta, callType, conversionFailed.at(i)); message += QString::fromLatin1(" %0").arg(QString::fromLatin1(mtd.signature())); } - result = JSC::throwError(exec, JSC::TypeError, qtStringToJSCUString(message)); + result = JSC::throwError(exec, JSC::TypeError, message); } else if (!unresolved.isEmpty()) { QScriptMetaArguments argsInstance = unresolved.first(); int unresolvedIndex = argsInstance.method.firstUnresolvedIndex(); @@ -884,7 +884,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c .arg(unresolvedTypeName)); } message.append(QString::fromLatin1(" (register the type with qScriptRegisterMetaType())")); - result = JSC::throwError(exec, JSC::TypeError, qtStringToJSCUString(message)); + result = JSC::throwError(exec, JSC::TypeError, message); } else { QString message = QString::fromLatin1("too few arguments in call to %0(); candidates are\n") .arg(QLatin1String(funName)); @@ -894,7 +894,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c QMetaMethod mtd = metaMethod(meta, callType, tooFewArgs.at(i)); message += QString::fromLatin1(" %0").arg(QString::fromLatin1(mtd.signature())); } - result = JSC::throwError(exec, JSC::SyntaxError, qtStringToJSCUString(message)); + result = JSC::throwError(exec, JSC::SyntaxError, message); } } else { if (chosenIndex == -1) { @@ -911,7 +911,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c QMetaMethod mtd = metaMethod(meta, callType, candidates.at(i).index); message += QString::fromLatin1(" %0").arg(QString::fromLatin1(mtd.signature())); } - result = JSC::throwError(exec, JSC::TypeError, qtStringToJSCUString(message)); + result = JSC::throwError(exec, JSC::TypeError, message); } else { chosenMethod = metaArgs.method; chosenIndex = metaArgs.index; @@ -1120,7 +1120,7 @@ JSC::JSValue QtPropertyFunction::execute(JSC::ExecState *exec, && !engine->hasDemarshalFunction(prop.userType())) { // give QMetaProperty::write() a chance to convert from // string to enum value - v = qtStringFromJSCUString(arg.toString(exec)); + v = (QString)arg.toString(exec); } else { // ### don't go via QScriptValue QScriptValue tmp = engine->scriptValueFromJSCValue(arg); @@ -1190,12 +1190,12 @@ bool QObjectDelegate::getOwnPropertySlot(QScriptObject *object, JSC::ExecState * const JSC::Identifier &propertyName, JSC::PropertySlot &slot) { - QByteArray name = qtStringFromJSCUString(propertyName.ustring()).toLatin1(); + QByteArray name = QString(propertyName.ustring()).toLatin1(); QObject *qobject = data->value; if (!qobject) { QString message = QString::fromLatin1("cannot access member `%0' of deleted QObject") .arg(QString::fromLatin1(name)); - slot.setValue(JSC::throwError(exec, JSC::GeneralError, qtStringToJSCUString(message))); + slot.setValue(JSC::throwError(exec, JSC::GeneralError, message)); return true; } @@ -1286,7 +1286,7 @@ bool QObjectDelegate::getOwnPropertySlot(QScriptObject *object, JSC::ExecState * QList<QObject*> children = qobject->children(); for (index = 0; index < children.count(); ++index) { QObject *child = children.at(index); - if (child->objectName() == qtStringFromJSCUString(propertyName.ustring())) { + if (child->objectName() == QString(propertyName.ustring())) { QScriptEngine::QObjectWrapOptions opt = QScriptEngine::PreferExistingWrapperObject; QScriptValue tmp = QScriptEnginePrivate::get(eng)->newQObject(child, QScriptEngine::QtOwnership, opt); slot.setValue(eng->scriptValueToJSCValue(tmp)); @@ -1302,12 +1302,12 @@ void QObjectDelegate::put(QScriptObject *object, JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue value, JSC::PutPropertySlot &slot) { - QByteArray name = qtStringFromJSCUString(propertyName.ustring()).toLatin1(); + QByteArray name = ((QString)propertyName.ustring()).toLatin1(); QObject *qobject = data->value; if (!qobject) { QString message = QString::fromLatin1("cannot access member `%0' of deleted QObject") .arg(QString::fromLatin1(name)); - JSC::throwError(exec, JSC::GeneralError, qtStringToJSCUString(message)); + JSC::throwError(exec, JSC::GeneralError, message); return; } @@ -1362,7 +1362,7 @@ void QObjectDelegate::put(QScriptObject *object, JSC::ExecState* exec, && !eng->hasDemarshalFunction(prop.userType())) { // give QMetaProperty::write() a chance to convert from // string to enum value - v = qtStringFromJSCUString(value.toString(exec)); + v = (QString)value.toString(exec); } else { v = eng->jscValueToVariant(value, prop.userType()); } @@ -1398,12 +1398,12 @@ bool QObjectDelegate::deleteProperty(QScriptObject *object, JSC::ExecState *exec const JSC::Identifier& propertyName, bool checkDontDelete) { - QByteArray name = qtStringFromJSCUString(propertyName.ustring()).toLatin1(); + QByteArray name = ((QString)propertyName.ustring()).toLatin1(); QObject *qobject = data->value; if (!qobject) { QString message = QString::fromLatin1("cannot access member `%0' of deleted QObject") .arg(QString::fromLatin1(name)); - JSC::throwError(exec, JSC::GeneralError, qtStringToJSCUString(message)); + JSC::throwError(exec, JSC::GeneralError, message); return false; } @@ -1444,7 +1444,7 @@ bool QObjectDelegate::getPropertyAttributes(const QScriptObject *object, unsigned &attributes) const { // ### try to avoid duplicating logic from getOwnPropertySlot() - QByteArray name = qtStringFromJSCUString(propertyName.ustring()).toLatin1(); + QByteArray name = ((QString)propertyName.ustring()).toLatin1(); QObject *qobject = data->value; if (!qobject) return false; @@ -1503,7 +1503,7 @@ bool QObjectDelegate::getPropertyAttributes(const QScriptObject *object, QList<QObject*> children = qobject->children(); for (index = 0; index < children.count(); ++index) { QObject *child = children.at(index); - if (child->objectName() == qtStringFromJSCUString(propertyName.ustring())) { + if (child->objectName() == (QString)(propertyName.ustring())) { attributes = JSC::ReadOnly | JSC::DontDelete | JSC::DontEnum; return true; } @@ -1520,7 +1520,7 @@ void QObjectDelegate::getPropertyNames(QScriptObject *object, JSC::ExecState *ex QObject *qobject = data->value; if (!qobject) { QString message = QString::fromLatin1("cannot get property names of deleted QObject"); - JSC::throwError(exec, JSC::GeneralError, qtStringToJSCUString(message)); + JSC::throwError(exec, JSC::GeneralError, message); return; } @@ -1533,7 +1533,7 @@ void QObjectDelegate::getPropertyNames(QScriptObject *object, JSC::ExecState *ex QMetaProperty prop = meta->property(i); if (isEnumerableMetaProperty(prop, meta, i)) { QString name = QString::fromLatin1(prop.name()); - propertyNames.add(JSC::Identifier(exec, qtStringToJSCUString(name))); + propertyNames.add(JSC::Identifier(exec, name)); } } } @@ -1542,7 +1542,7 @@ void QObjectDelegate::getPropertyNames(QScriptObject *object, JSC::ExecState *ex QList<QByteArray> dpNames = qobject->dynamicPropertyNames(); for (int i = 0; i < dpNames.size(); ++i) { QString name = QString::fromLatin1(dpNames.at(i)); - propertyNames.add(JSC::Identifier(exec, qtStringToJSCUString(name))); + propertyNames.add(JSC::Identifier(exec, name)); } } @@ -1554,7 +1554,7 @@ void QObjectDelegate::getPropertyNames(QScriptObject *object, JSC::ExecState *ex if (hasMethodAccess(method, i, opt)) { QMetaMethod method = meta->method(i); QString sig = QString::fromLatin1(method.signature()); - propertyNames.add(JSC::Identifier(exec, qtStringToJSCUString(sig))); + propertyNames.add(JSC::Identifier(exec, sig)); } } } @@ -1588,7 +1588,7 @@ static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncFindChild(JSC::ExecState *exec QObject *obj = static_cast<QObjectDelegate*>(delegate)->value(); QString name; if (args.size() != 0) - name = QScript::qtStringFromJSCUString(args.at(0).toString(exec)); + name = args.at(0).toString(exec); QObject *child = qFindChild<QObject*>(obj, name); QScriptEngine::QObjectWrapOptions opt = QScriptEngine::PreferExistingWrapperObject; return engine->newQObject(child, QScriptEngine::QtOwnership, opt); @@ -1620,7 +1620,7 @@ static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncFindChildren(JSC::ExecState *e const int allChildrenCount = allChildren.size(); for (int i = 0; i < allChildrenCount; ++i) { QObject *const child = allChildren.at(i); - const JSC::UString childName = qtStringToJSCUString(child->objectName()); + const JSC::UString childName = child->objectName(); JSC::RegExpConstructor* regExpConstructor = engine->originalGlobalObject()->regExpConstructor(); int position; int length; @@ -1629,7 +1629,7 @@ static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncFindChildren(JSC::ExecState *e children.append(child); } } else { - const QString name = QScript::qtStringFromJSCUString(args.at(0).toString(exec)); + const QString name(args.at(0).toString(exec)); children = qFindChildren<QObject*>(obj, name); } } else { @@ -1663,7 +1663,7 @@ static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncToString(JSC::ExecState *exec, QString name = obj ? obj->objectName() : QString::fromUtf8("unnamed"); QString str = QString::fromUtf8("%0(name = \"%1\")") .arg(QLatin1String(meta->className())).arg(name); - return JSC::jsString(exec, qtStringToJSCUString(str)); + return JSC::jsString(exec, str); } QObjectPrototype::QObjectPrototype(JSC::ExecState* exec, WTF::PassRefPtr<JSC::Structure> structure, @@ -1713,7 +1713,7 @@ bool QMetaObjectWrapperObject::getOwnPropertySlot( return true; } - QByteArray name = qtStringFromJSCUString(propertyName.ustring()).toLatin1(); + QByteArray name = QString(propertyName.ustring()).toLatin1(); for (int i = 0; i < meta->enumeratorCount(); ++i) { QMetaEnum e = meta->enumerator(i); @@ -1741,7 +1741,7 @@ void QMetaObjectWrapperObject::put(JSC::ExecState* exec, const JSC::Identifier& } const QMetaObject *meta = data->value; if (meta) { - QByteArray name = qtStringFromJSCUString(propertyName.ustring()).toLatin1(); + QByteArray name = QString(propertyName.ustring()).toLatin1(); for (int i = 0; i < meta->enumeratorCount(); ++i) { QMetaEnum e = meta->enumerator(i); for (int j = 0; j < e.keyCount(); ++j) { @@ -1761,7 +1761,7 @@ bool QMetaObjectWrapperObject::deleteProperty( return false; const QMetaObject *meta = data->value; if (meta) { - QByteArray name = qtStringFromJSCUString(propertyName.ustring()).toLatin1(); + QByteArray name = QString(propertyName.ustring()).toLatin1(); for (int i = 0; i < meta->enumeratorCount(); ++i) { QMetaEnum e = meta->enumerator(i); for (int j = 0; j < e.keyCount(); ++j) { @@ -1783,7 +1783,7 @@ bool QMetaObjectWrapperObject::getPropertyAttributes(JSC::ExecState *exec, } const QMetaObject *meta = data->value; if (meta) { - QByteArray name = qtStringFromJSCUString(propertyName.ustring()).toLatin1(); + QByteArray name = QString(propertyName.ustring()).toLatin1(); for (int i = 0; i < meta->enumeratorCount(); ++i) { QMetaEnum e = meta->enumerator(i); for (int j = 0; j < e.keyCount(); ++j) { @@ -1900,7 +1900,7 @@ JSC::JSValue QMetaObjectWrapperObject::execute(JSC::ExecState *exec, } else { QString message = QString::fromLatin1("no constructor for %0") .arg(QLatin1String(meta->className())); - return JSC::throwError(exec, JSC::TypeError, qtStringToJSCUString(message)); + return JSC::throwError(exec, JSC::TypeError, message); } } } diff --git a/src/script/bridge/qscriptvariant.cpp b/src/script/bridge/qscriptvariant.cpp index d352a98..ee59e4f 100644 --- a/src/script/bridge/qscriptvariant.cpp +++ b/src/script/bridge/qscriptvariant.cpp @@ -98,7 +98,7 @@ static JSC::JSValue JSC_HOST_CALL variantProtoFuncValueOf(JSC::ExecState *exec, case QVariant::Invalid: return JSC::jsUndefined(); case QVariant::String: - return JSC::jsString(exec, QScript::qtStringToJSCUString(v.toString())); + return JSC::jsString(exec, v.toString()); case QVariant::Int: return JSC::jsNumber(exec, v.toInt()); @@ -135,7 +135,7 @@ static JSC::JSValue JSC_HOST_CALL variantProtoFuncToString(JSC::ExecState *exec, JSC::UString result; JSC::JSValue value = variantProtoFuncValueOf(exec, callee, thisValue, args); if (value.isObject()) { - result = QScript::qtStringToJSCUString(v.toString()); + result = v.toString(); if (result.isEmpty()) { result = "QVariant("; result += v.typeName(); |