Showing the changes to libraries/script-engine/src/qtscript/ScriptEngineQtScript.cpp (1 of 170 files). Show all
Unified · Split
| @@ -62,7 +62,7 @@ static const QScriptValue::PropertyFlags READONLY_HIDDEN_PROP_FLAGS { READONLY_P · 61 unmodified lines | ||
| 62 | 62 | |
| 63 | 63 | static const bool HIFI_AUTOREFRESH_FILE_SCRIPTS { true }; |
| 64 | 64 | |
| 65 | −Q_DECLARE_METATYPE(ScriptValuePointer); | |
| 65 | +Q_DECLARE_METATYPE(ScriptValue); | |
| 66 | 66 | |
| 67 | 67 | Q_DECLARE_METATYPE(QScriptEngine::FunctionSignature) |
| 68 | 68 | int qfunctionSignatureMetaID = qRegisterMetaType<QScriptEngine::FunctionSignature>(); |
| @@ -120,26 +120,26 @@ QScriptValue ScriptEngineQtScript::makeError(const QScriptValue& _other, const Q · 51 unmodified lines | ||
| 120 | 120 | return err; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | −ScriptValuePointer ScriptEngineQtScript::makeError(const ScriptValuePointer& _other, const QString& type) { | |
| 123 | +ScriptValue ScriptEngineQtScript::makeError(const ScriptValue& _other, const QString& type) { | |
| 124 | 124 | if (!IS_THREADSAFE_INVOCATION(thread(), __FUNCTION__)) { |
| 125 | 125 | return nullValue(); |
| 126 | 126 | } |
| 127 | 127 | ScriptValueQtWrapper* unwrapped = ScriptValueQtWrapper::unwrap(_other); |
| 128 | 128 | QScriptValue other; |
| 129 | − if (_other->isString()) { | |
| 129 | + if (_other.isString()) { | |
| 130 | 130 | other = QScriptEngine::newObject(); |
| 131 | − other.setProperty("message", _other->toString()); | |
| 131 | + other.setProperty("message", _other.toString()); | |
| 132 | 132 | } else if (unwrapped) { |
| 133 | 133 | other = unwrapped->toQtValue(); |
| 134 | 134 | } else { |
| 135 | − other = QScriptEngine::newVariant(_other->toVariant()); | |
| 135 | + other = QScriptEngine::newVariant(_other.toVariant()); | |
| 136 | 136 | } |
| 137 | 137 | QScriptValue result = makeError(other, type); |
| 138 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 138 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // check syntax and when there are issues returns an actual "SyntaxError" with the details |
| 142 | −ScriptValuePointer ScriptEngineQtScript::lintScript(const QString& sourceCode, const QString& fileName, const int lineNumber) { | |
| 142 | +ScriptValue ScriptEngineQtScript::lintScript(const QString& sourceCode, const QString& fileName, const int lineNumber) { | |
| 143 | 143 | if (!IS_THREADSAFE_INVOCATION(thread(), __FUNCTION__)) { |
| 144 | 144 | return nullValue(); |
| 145 | 145 | } |
| @@ -158,13 +158,13 @@ ScriptValuePointer ScriptEngineQtScript::lintScript(const QString& sourceCode, c · 12 unmodified lines | ||
| 158 | 158 | const auto message = QString("[SyntaxError] %1 in %2:%3(%4)").arg(error, fileName, line, column); |
| 159 | 159 | err.setProperty("formatted", message); |
| 160 | 160 | } |
| 161 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(err))); | |
| 161 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(err))); | |
| 162 | 162 | } |
| 163 | 163 | return undefinedValue(); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // this pulls from the best available information to create a detailed snapshot of the current exception |
| 167 | −ScriptValuePointer ScriptEngineQtScript::cloneUncaughtException(const QString& extraDetail) { | |
| 167 | +ScriptValue ScriptEngineQtScript::cloneUncaughtException(const QString& extraDetail) { | |
| 168 | 168 | if (!IS_THREADSAFE_INVOCATION(thread(), __FUNCTION__)) { |
| 169 | 169 | return nullValue(); |
| 170 | 170 | } |
| @@ -178,17 +178,17 @@ ScriptValuePointer ScriptEngineQtScript::cloneUncaughtException(const QString& e · 7 unmodified lines | ||
| 178 | 178 | // not sure why Qt does't offer uncaughtExceptionFileName -- but the line number |
| 179 | 179 | // on its own is often useless/wrong if arbitrarily married to a filename. |
| 180 | 180 | // when the error object already has this info, it seems to be the most reliable |
| 181 | − auto fileName = exception->property("fileName")->toString(); | |
| 182 | − auto lineNumber = exception->property("lineNumber")->toInt32(); | |
| 181 | + auto fileName = exception.property("fileName").toString(); | |
| 182 | + auto lineNumber = exception.property("lineNumber").toInt32(); | |
| 183 | 183 | |
| 184 | 184 | // the backtrace, on the other hand, seems most reliable taken from uncaughtExceptionBacktrace |
| 185 | 185 | auto backtrace = uncaughtExceptionBacktrace(); |
| 186 | 186 | if (backtrace.isEmpty()) { |
| 187 | 187 | // fallback to the error object |
| 188 | − backtrace = exception->property("stack")->toString().split(ScriptManager::SCRIPT_BACKTRACE_SEP); | |
| 188 | + backtrace = exception.property("stack").toString().split(ScriptManager::SCRIPT_BACKTRACE_SEP); | |
| 189 | 189 | } |
| 190 | 190 | // the ad hoc "detail" property can be used now to embed additional clues |
| 191 | − auto detail = exception->property("detail")->toString(); | |
| 191 | + auto detail = exception.property("detail").toString(); | |
| 192 | 192 | if (detail.isEmpty()) { |
| 193 | 193 | detail = extraDetail; |
| 194 | 194 | } else if (!extraDetail.isEmpty()) { |
| @@ -212,15 +212,15 @@ ScriptValuePointer ScriptEngineQtScript::cloneUncaughtException(const QString& e · 17 unmodified lines | ||
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | − err->setProperty("fileName", fileName); | |
| 216 | − err->setProperty("lineNumber", lineNumber); | |
| 217 | − err->setProperty("detail", detail); | |
| 218 | − err->setProperty("stack", backtrace.join(ScriptManager::SCRIPT_BACKTRACE_SEP)); | |
| 215 | + err.setProperty("fileName", fileName); | |
| 216 | + err.setProperty("lineNumber", lineNumber); | |
| 217 | + err.setProperty("detail", detail); | |
| 218 | + err.setProperty("stack", backtrace.join(ScriptManager::SCRIPT_BACKTRACE_SEP)); | |
| 219 | 219 | |
| 220 | 220 | #ifdef DEBUG_JS_EXCEPTIONS |
| 221 | − err->setProperty("_fileName", exception.property("fileName").toString()); | |
| 222 | − err->setProperty("_stack", uncaughtExceptionBacktrace().join(SCRIPT_BACKTRACE_SEP)); | |
| 223 | − err->setProperty("_lineNumber", uncaughtExceptionLineNumber()); | |
| 221 | + err.setProperty("_fileName", exception.property("fileName").toString()); | |
| 222 | + err.setProperty("_stack", uncaughtExceptionBacktrace().join(SCRIPT_BACKTRACE_SEP)); | |
| 223 | + err.setProperty("_lineNumber", uncaughtExceptionLineNumber()); | |
| 224 | 224 | #endif |
| 225 | 225 | return err; |
| 226 | 226 | } |
| @@ -237,7 +237,7 @@ bool ScriptEngineQtScript::raiseException(const QScriptValue& exception) { · 10 unmodified lines | ||
| 237 | 237 | // we are within a pure C++ stack frame (ie: being called directly by other C++ code) |
| 238 | 238 | // in this case no context information is available so just emit the exception for reporting |
| 239 | 239 | QScriptValue thrown = makeError(exception); |
| 240 | − emit _manager->unhandledException(ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(thrown)))); | |
| 240 | + emit _manager->unhandledException(ScriptValue(new ScriptValueQtWrapper(this, std::move(thrown)))); | |
| 241 | 241 | } |
| 242 | 242 | return false; |
| 243 | 243 | } |
| @@ -383,13 +383,13 @@ static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) { · 139 unmodified lines | ||
| 383 | 383 | return QScriptValue(); |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | −static QScriptValue ScriptValueToQScriptValue(QScriptEngine* engine, const ScriptValuePointer& src) { | |
| 386 | +static QScriptValue ScriptValueToQScriptValue(QScriptEngine* engine, const ScriptValue& src) { | |
| 387 | 387 | return ScriptValueQtWrapper::fullUnwrap(static_cast<ScriptEngineQtScript*>(engine), src); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | −static void ScriptValueFromQScriptValue(const QScriptValue& src, ScriptValuePointer& dest) { | |
| 390 | +static void ScriptValueFromQScriptValue(const QScriptValue& src, ScriptValue& dest) { | |
| 391 | 391 | ScriptEngineQtScript* engine = static_cast<ScriptEngineQtScript*>(src.engine()); |
| 392 | − dest = ScriptValuePointer(new ScriptValueQtWrapper(engine, src)); | |
| 392 | + dest = ScriptValue(new ScriptValueQtWrapper(engine, src)); | |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | ScriptEngineQtScript::ScriptEngineQtScript(ScriptManager* scriptManager) : |
| @@ -408,17 +408,17 @@ ScriptEngineQtScript::ScriptEngineQtScript(ScriptManager* scriptManager) : · 12 unmodified lines | ||
| 408 | 408 | } else { |
| 409 | 409 | // ... but may not always be available -- so if needed we fallback to the passed exception |
| 410 | 410 | QScriptValue thrown = makeError(exception); |
| 411 | − emit _manager->unhandledException(ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(thrown)))); | |
| 411 | + emit _manager->unhandledException(ScriptValue(new ScriptValueQtWrapper(this, std::move(thrown)))); | |
| 412 | 412 | } |
| 413 | 413 | }, Qt::DirectConnection); |
| 414 | 414 | moveToThread(scriptManager->thread()); |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | QScriptValue null = QScriptEngine::nullValue(); |
| 418 | − _nullValue = ScriptValuePointer(new ScriptValueQtWrapper(const_cast<ScriptEngineQtScript*>(this), std::move(null))); | |
| 418 | + _nullValue = ScriptValue(new ScriptValueQtWrapper(const_cast<ScriptEngineQtScript*>(this), std::move(null))); | |
| 419 | 419 | |
| 420 | 420 | QScriptValue undefined = QScriptEngine::undefinedValue(); |
| 421 | − _undefinedValue = ScriptValuePointer(new ScriptValueQtWrapper(const_cast<ScriptEngineQtScript*>(this), std::move(undefined))); | |
| 421 | + _undefinedValue = ScriptValue(new ScriptValueQtWrapper(const_cast<ScriptEngineQtScript*>(this), std::move(undefined))); | |
| 422 | 422 | |
| 423 | 423 | QScriptEngine::setProcessEventsInterval(MSECS_PER_SECOND); |
| 424 | 424 | } |
| @@ -478,14 +478,14 @@ void ScriptEngineQtScript::registerValue(const QString& valueName, QScriptValue · 53 unmodified lines | ||
| 478 | 478 | |
| 479 | 479 | QStringList pathToValue = valueName.split("."); |
| 480 | 480 | int partsToGo = pathToValue.length(); |
| 481 | − QScriptValue partObject = globalObject(); | |
| 481 | + QScriptValue partObject = QScriptEngine::globalObject(); | |
| 482 | 482 | |
| 483 | 483 | for (const auto& pathPart : pathToValue) { |
| 484 | 484 | partsToGo--; |
| 485 | 485 | if (!partObject.property(pathPart).isValid()) { |
| 486 | 486 | if (partsToGo > 0) { |
| 487 | 487 | //QObject *object = new QObject; |
| 488 | − QScriptValue partValue = newArray(); //newQObject(object, QScriptEngine::ScriptOwnership); | |
| 488 | + QScriptValue partValue = QScriptEngine::newArray(); //newQObject(object, QScriptEngine::ScriptOwnership); | |
| 489 | 489 | partObject.setProperty(pathPart, partValue); |
| 490 | 490 | } else { |
| 491 | 491 | partObject.setProperty(pathPart, value); |
| @@ -554,7 +554,7 @@ void ScriptEngineQtScript::registerFunction(const QString& name, ScriptEngine::F · 62 unmodified lines | ||
| 554 | 554 | #endif |
| 555 | 555 | |
| 556 | 556 | auto scriptFun = newFunction(functionSignature, numArguments); |
| 557 | − globalObject()->setProperty(name, scriptFun); | |
| 557 | + globalObject().setProperty(name, scriptFun); | |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | void ScriptEngineQtScript::registerFunction(const QString& parent, const QString& name, QScriptEngine::FunctionSignature functionSignature, int numArguments) { |
| @@ -594,10 +594,10 @@ void ScriptEngineQtScript::registerFunction(const QString& parent, const QString · 33 unmodified lines | ||
| 594 | 594 | qCDebug(scriptengine) << "ScriptEngineQtScript::registerFunction() called on thread [" << QThread::currentThread() << "] parent:" << parent << "name:" << name; |
| 595 | 595 | #endif |
| 596 | 596 | |
| 597 | − auto object = globalObject()->property(parent); | |
| 598 | − if (object->isValid()) { | |
| 597 | + auto object = globalObject().property(parent); | |
| 598 | + if (object.isValid()) { | |
| 599 | 599 | auto scriptFun = newFunction(functionSignature, numArguments); |
| 600 | − object->setProperty(name, scriptFun); | |
| 600 | + object.setProperty(name, scriptFun); | |
| 601 | 601 | } |
| 602 | 602 | } |
| 603 | 603 | |
| @@ -656,18 +656,18 @@ void ScriptEngineQtScript::registerGetterSetter(const QString& name, ScriptEngin · 52 unmodified lines | ||
| 656 | 656 | auto getterFunction = newFunction(getter); |
| 657 | 657 | |
| 658 | 658 | if (!parent.isNull() && !parent.isEmpty()) { |
| 659 | − auto object = globalObject()->property(parent); | |
| 660 | − if (object->isValid()) { | |
| 661 | − object->setProperty(name, setterFunction, ScriptValue::PropertySetter); | |
| 662 | − object->setProperty(name, getterFunction, ScriptValue::PropertyGetter); | |
| 659 | + auto object = globalObject().property(parent); | |
| 660 | + if (object.isValid()) { | |
| 661 | + object.setProperty(name, setterFunction, ScriptValue::PropertySetter); | |
| 662 | + object.setProperty(name, getterFunction, ScriptValue::PropertyGetter); | |
| 663 | 663 | } |
| 664 | 664 | } else { |
| 665 | − globalObject()->setProperty(name, setterFunction, ScriptValue::PropertySetter); | |
| 666 | − globalObject()->setProperty(name, getterFunction, ScriptValue::PropertyGetter); | |
| 665 | + globalObject().setProperty(name, setterFunction, ScriptValue::PropertySetter); | |
| 666 | + globalObject().setProperty(name, getterFunction, ScriptValue::PropertyGetter); | |
| 667 | 667 | } |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | −ScriptValuePointer ScriptEngineQtScript::evaluateInClosure(const ScriptValuePointer& _closure, | |
| 670 | +ScriptValue ScriptEngineQtScript::evaluateInClosure(const ScriptValue& _closure, | |
| 671 | 671 | const ScriptProgramPointer& _program) { |
| 672 | 672 | PROFILE_RANGE(script, "evaluateInClosure"); |
| 673 | 673 | if (!IS_THREADSAFE_INVOCATION(thread(), __FUNCTION__)) { |
| @@ -712,7 +712,7 @@ ScriptValuePointer ScriptEngineQtScript::evaluateInClosure(const ScriptValuePoin · 38 unmodified lines | ||
| 712 | 712 | #ifdef DEBUG_JS |
| 713 | 713 | qCDebug(shared) << QString("[%1] evaluateInClosure %2").arg(isEvaluating()).arg(shortName); |
| 714 | 714 | #endif |
| 715 | − ScriptValuePointer result; | |
| 715 | + ScriptValue result; | |
| 716 | 716 | { |
| 717 | 717 | auto qResult = QScriptEngine::evaluate(program); |
| 718 | 718 | |
| @@ -724,7 +724,7 @@ ScriptValuePointer ScriptEngineQtScript::evaluateInClosure(const ScriptValuePoin · 5 unmodified lines | ||
| 724 | 724 | #endif |
| 725 | 725 | result = err; |
| 726 | 726 | } else { |
| 727 | − result = ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(qResult))); | |
| 727 | + result = ScriptValue(new ScriptValueQtWrapper(this, std::move(qResult))); | |
| 728 | 728 | } |
| 729 | 729 | } |
| 730 | 730 | #ifdef DEBUG_JS |
| @@ -742,19 +742,19 @@ ScriptValuePointer ScriptEngineQtScript::evaluateInClosure(const ScriptValuePoin · 11 unmodified lines | ||
| 742 | 742 | return result; |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | −ScriptValuePointer ScriptEngineQtScript::evaluate(const QString& sourceCode, const QString& fileName) { | |
| 745 | +ScriptValue ScriptEngineQtScript::evaluate(const QString& sourceCode, const QString& fileName) { | |
| 746 | 746 | if (_manager && _manager->isStopped()) { |
| 747 | 747 | return undefinedValue(); // bail early |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | if (QThread::currentThread() != QScriptEngine::thread()) { |
| 751 | − ScriptValuePointer result; | |
| 751 | + ScriptValue result; | |
| 752 | 752 | #ifdef THREAD_DEBUGGING |
| 753 | 753 | qCDebug(scriptengine) << "*** WARNING *** ScriptEngineQtScript::evaluate() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " |
| 754 | 754 | "sourceCode:" << sourceCode << " fileName:" << fileName; |
| 755 | 755 | #endif |
| 756 | 756 | BLOCKING_INVOKE_METHOD(this, "evaluate", |
| 757 | − Q_RETURN_ARG(ScriptValuePointer, result), | |
| 757 | + Q_RETURN_ARG(ScriptValue, result), | |
| 758 | 758 | Q_ARG(const QString&, sourceCode), |
| 759 | 759 | Q_ARG(const QString&, fileName)); |
| 760 | 760 | return result; |
| @@ -762,9 +762,9 @@ ScriptValuePointer ScriptEngineQtScript::evaluate(const QString& sourceCode, con · 1 unmodified line | ||
| 762 | 762 | |
| 763 | 763 | // Check syntax |
| 764 | 764 | auto syntaxError = lintScript(sourceCode, fileName); |
| 765 | − if (syntaxError->isError()) { | |
| 765 | + if (syntaxError.isError()) { | |
| 766 | 766 | if (!isEvaluating()) { |
| 767 | − syntaxError->setProperty("detail", "evaluate"); | |
| 767 | + syntaxError.setProperty("detail", "evaluate"); | |
| 768 | 768 | } |
| 769 | 769 | raiseException(syntaxError); |
| 770 | 770 | maybeEmitUncaughtException("lint"); |
| @@ -782,22 +782,22 @@ ScriptValuePointer ScriptEngineQtScript::evaluate(const QString& sourceCode, con · 11 unmodified lines | ||
| 782 | 782 | QScriptValue result = QScriptEngine::evaluate(program); |
| 783 | 783 | maybeEmitUncaughtException("evaluate"); |
| 784 | 784 | |
| 785 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 785 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | −Q_INVOKABLE ScriptValuePointer ScriptEngineQtScript::evaluate(const ScriptProgramPointer& program) { | |
| 788 | +Q_INVOKABLE ScriptValue ScriptEngineQtScript::evaluate(const ScriptProgramPointer& program) { | |
| 789 | 789 | if (_manager && _manager->isStopped()) { |
| 790 | 790 | return undefinedValue(); // bail early |
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | if (QThread::currentThread() != QScriptEngine::thread()) { |
| 794 | − ScriptValuePointer result; | |
| 794 | + ScriptValue result; | |
| 795 | 795 | #ifdef THREAD_DEBUGGING |
| 796 | 796 | qCDebug(scriptengine) << "*** WARNING *** ScriptEngineQtScript::evaluate() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " |
| 797 | 797 | "sourceCode:" << sourceCode << " fileName:" << fileName; |
| 798 | 798 | #endif |
| 799 | 799 | BLOCKING_INVOKE_METHOD(this, "evaluate", |
| 800 | − Q_RETURN_ARG(ScriptValuePointer, result), | |
| 800 | + Q_RETURN_ARG(ScriptValue, result), | |
| 801 | 801 | Q_ARG(const ScriptProgramPointer&, program)); |
| 802 | 802 | return result; |
| 803 | 803 | } |
| @@ -822,7 +822,7 @@ Q_INVOKABLE ScriptValuePointer ScriptEngineQtScript::evaluate(const ScriptProgra · 18 unmodified lines | ||
| 822 | 822 | QScriptValue result = QScriptEngine::evaluate(qProgram); |
| 823 | 823 | maybeEmitUncaughtException("evaluate"); |
| 824 | 824 | |
| 825 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 825 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | |
| @@ -849,21 +849,21 @@ void ScriptEngineQtScript::print(const QString& message) { · 20 unmodified lines | ||
| 849 | 849 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 850 | 850 | // ScriptEngine implementation |
| 851 | 851 | |
| 852 | −ScriptValuePointer ScriptEngineQtScript::globalObject() const { | |
| 852 | +ScriptValue ScriptEngineQtScript::globalObject() const { | |
| 853 | 853 | QScriptValue global = QScriptEngine::globalObject(); // can't cache the value as it may change |
| 854 | − return ScriptValuePointer(new ScriptValueQtWrapper(const_cast < ScriptEngineQtScript*>(this), std::move(global))); | |
| 854 | + return ScriptValue(new ScriptValueQtWrapper(const_cast < ScriptEngineQtScript*>(this), std::move(global))); | |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | ScriptManager* ScriptEngineQtScript::manager() const { |
| 858 | 858 | return _manager; |
| 859 | 859 | } |
| 860 | 860 | |
| 861 | −ScriptValuePointer ScriptEngineQtScript::newArray(uint length) { | |
| 861 | +ScriptValue ScriptEngineQtScript::newArray(uint length) { | |
| 862 | 862 | QScriptValue result = QScriptEngine::newArray(length); |
| 863 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 863 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | −ScriptValuePointer ScriptEngineQtScript::newArrayBuffer(const QByteArray& message) { | |
| 866 | +ScriptValue ScriptEngineQtScript::newArrayBuffer(const QByteArray& message) { | |
| 867 | 867 | QScriptValue data = QScriptEngine::newVariant(QVariant::fromValue(message)); |
| 868 | 868 | QScriptValue ctor = QScriptEngine::globalObject().property("ArrayBuffer"); |
| 869 | 869 | auto array = qscriptvalue_cast<ArrayBufferClass*>(ctor.data()); |
| @@ -871,12 +871,12 @@ ScriptValuePointer ScriptEngineQtScript::newArrayBuffer(const QByteArray& messag · 1 unmodified line | ||
| 871 | 871 | return undefinedValue(); |
| 872 | 872 | } |
| 873 | 873 | QScriptValue result = QScriptEngine::newObject(array, data); |
| 874 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 874 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 875 | 875 | } |
| 876 | 876 | |
| 877 | −ScriptValuePointer ScriptEngineQtScript::newObject() { | |
| 877 | +ScriptValue ScriptEngineQtScript::newObject() { | |
| 878 | 878 | QScriptValue result = QScriptEngine::newObject(); |
| 879 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 879 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | ScriptProgramPointer ScriptEngineQtScript::newProgram(const QString& sourceCode, const QString& fileName) { |
| @@ -884,66 +884,66 @@ ScriptProgramPointer ScriptEngineQtScript::newProgram(const QString& sourceCode, · 1 unmodified line | ||
| 884 | 884 | return ScriptProgramPointer(new ScriptProgramQtWrapper(this, result)); |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | −ScriptValuePointer ScriptEngineQtScript::newQObject(QObject* object, | |
| 887 | +ScriptValue ScriptEngineQtScript::newQObject(QObject* object, | |
| 888 | 888 | ScriptEngine::ValueOwnership ownership, |
| 889 | 889 | const ScriptEngine::QObjectWrapOptions& options) { |
| 890 | 890 | QScriptValue result = QScriptEngine::newQObject(object, static_cast<QScriptEngine::ValueOwnership>(ownership), |
| 891 | 891 | (QScriptEngine::QObjectWrapOptions)((int)options | DEFAULT_QOBJECT_WRAP_OPTIONS)); |
| 892 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 892 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | −ScriptValuePointer ScriptEngineQtScript::newValue(bool value) { | |
| 895 | +ScriptValue ScriptEngineQtScript::newValue(bool value) { | |
| 896 | 896 | QScriptValue result(this, value); |
| 897 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 897 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 898 | 898 | } |
| 899 | 899 | |
| 900 | −ScriptValuePointer ScriptEngineQtScript::newValue(int value) { | |
| 900 | +ScriptValue ScriptEngineQtScript::newValue(int value) { | |
| 901 | 901 | QScriptValue result(this, value); |
| 902 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 902 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | −ScriptValuePointer ScriptEngineQtScript::newValue(uint value) { | |
| 905 | +ScriptValue ScriptEngineQtScript::newValue(uint value) { | |
| 906 | 906 | QScriptValue result(this, value); |
| 907 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 907 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 908 | 908 | } |
| 909 | 909 | |
| 910 | −ScriptValuePointer ScriptEngineQtScript::newValue(double value) { | |
| 910 | +ScriptValue ScriptEngineQtScript::newValue(double value) { | |
| 911 | 911 | QScriptValue result(this, value); |
| 912 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 912 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | −ScriptValuePointer ScriptEngineQtScript::newValue(const QString& value) { | |
| 915 | +ScriptValue ScriptEngineQtScript::newValue(const QString& value) { | |
| 916 | 916 | QScriptValue result(this, value); |
| 917 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 917 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 918 | 918 | } |
| 919 | 919 | |
| 920 | −ScriptValuePointer ScriptEngineQtScript::newValue(const QLatin1String& value) { | |
| 920 | +ScriptValue ScriptEngineQtScript::newValue(const QLatin1String& value) { | |
| 921 | 921 | QScriptValue result(this, value); |
| 922 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 922 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 923 | 923 | } |
| 924 | 924 | |
| 925 | −ScriptValuePointer ScriptEngineQtScript::newValue(const char* value) { | |
| 925 | +ScriptValue ScriptEngineQtScript::newValue(const char* value) { | |
| 926 | 926 | QScriptValue result(this, value); |
| 927 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 927 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 928 | 928 | } |
| 929 | 929 | |
| 930 | −ScriptValuePointer ScriptEngineQtScript::newVariant(const QVariant& value) { | |
| 930 | +ScriptValue ScriptEngineQtScript::newVariant(const QVariant& value) { | |
| 931 | 931 | QScriptValue result = QScriptEngine::newVariant(value); |
| 932 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 932 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 933 | 933 | } |
| 934 | 934 | |
| 935 | −ScriptValuePointer ScriptEngineQtScript::nullValue() { | |
| 935 | +ScriptValue ScriptEngineQtScript::nullValue() { | |
| 936 | 936 | return _nullValue; |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | −void ScriptEngineQtScript::setDefaultPrototype(int metaTypeId, const ScriptValuePointer& prototype){ | |
| 939 | +void ScriptEngineQtScript::setDefaultPrototype(int metaTypeId, const ScriptValue& prototype){ | |
| 940 | 940 | ScriptValueQtWrapper* unwrappedPrototype = ScriptValueQtWrapper::unwrap(prototype); |
| 941 | 941 | if (unwrappedPrototype) { |
| 942 | 942 | QScriptEngine::setDefaultPrototype(metaTypeId, unwrappedPrototype->toQtValue()); |
| 943 | 943 | } |
| 944 | 944 | } |
| 945 | 945 | |
| 946 | −ScriptValuePointer ScriptEngineQtScript::undefinedValue() { | |
| 946 | +ScriptValue ScriptEngineQtScript::undefinedValue() { | |
| 947 | 947 | return _undefinedValue; |
| 948 | 948 | } |
| 949 | 949 | |
| @@ -974,14 +974,14 @@ bool ScriptEngineQtScript::isEvaluating() const { · 24 unmodified lines | ||
| 974 | 974 | return QScriptEngine::isEvaluating(); |
| 975 | 975 | } |
| 976 | 976 | |
| 977 | −ScriptValuePointer ScriptEngineQtScript::newFunction(ScriptEngine::FunctionSignature fun, int length) { | |
| 977 | +ScriptValue ScriptEngineQtScript::newFunction(ScriptEngine::FunctionSignature fun, int length) { | |
| 978 | 978 | auto innerFunc = [](QScriptContext* _context, QScriptEngine* _engine) -> QScriptValue { |
| 979 | 979 | auto callee = _context->callee(); |
| 980 | 980 | QVariant funAddr = callee.property("_func").toVariant(); |
| 981 | 981 | ScriptEngine::FunctionSignature fun = reinterpret_cast<ScriptEngine::FunctionSignature>(funAddr.toULongLong()); |
| 982 | 982 | ScriptEngineQtScript* engine = static_cast<ScriptEngineQtScript*>(_engine); |
| 983 | 983 | ScriptContextQtWrapper context(engine, _context); |
| 984 | − ScriptValuePointer result = fun(&context, engine); | |
| 984 | + ScriptValue result = fun(&context, engine); | |
| 985 | 985 | ScriptValueQtWrapper* unwrapped = ScriptValueQtWrapper::unwrap(result); |
| 986 | 986 | return unwrapped ? unwrapped->toQtValue() : QScriptValue(); |
| 987 | 987 | }; |
| @@ -989,7 +989,7 @@ ScriptValuePointer ScriptEngineQtScript::newFunction(ScriptEngine::FunctionSigna · 1 unmodified line | ||
| 989 | 989 | QScriptValue result = QScriptEngine::newFunction(innerFunc, length); |
| 990 | 990 | auto funAddr = QScriptEngine::newVariant(QVariant(reinterpret_cast<qulonglong>(fun))); |
| 991 | 991 | result.setProperty("_func", funAddr, QScriptValue::PropertyFlags(QScriptValue::ReadOnly + QScriptValue::Undeletable + QScriptValue::SkipInEnumeration)); |
| 992 | − return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result))); | |
| 992 | + return ScriptValue(new ScriptValueQtWrapper(this, std::move(result))); | |
| 993 | 993 | } |
| 994 | 994 | |
| 995 | 995 | void ScriptEngineQtScript::setObjectName(const QString& name) { |
| @@ -1012,9 +1012,9 @@ void ScriptEngineQtScript::setThread(QThread* thread) { · 16 unmodified lines | ||
| 1012 | 1012 | moveToThread(thread); |
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | −ScriptValuePointer ScriptEngineQtScript::uncaughtException() const { | |
| 1015 | +ScriptValue ScriptEngineQtScript::uncaughtException() const { | |
| 1016 | 1016 | QScriptValue result = QScriptEngine::uncaughtException(); |
| 1017 | − return ScriptValuePointer(new ScriptValueQtWrapper(const_cast<ScriptEngineQtScript*>(this), std::move(result))); | |
| 1017 | + return ScriptValue(new ScriptValueQtWrapper(const_cast<ScriptEngineQtScript*>(this), std::move(result))); | |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | QStringList ScriptEngineQtScript::uncaughtExceptionBacktrace() const { |
| @@ -1025,18 +1025,18 @@ int ScriptEngineQtScript::uncaughtExceptionLineNumber() const { · 4 unmodified lines | ||
| 1025 | 1025 | return QScriptEngine::uncaughtExceptionLineNumber(); |
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | −bool ScriptEngineQtScript::raiseException(const ScriptValuePointer& exception) { | |
| 1028 | +bool ScriptEngineQtScript::raiseException(const ScriptValue& exception) { | |
| 1029 | 1029 | ScriptValueQtWrapper* unwrapped = ScriptValueQtWrapper::unwrap(exception); |
| 1030 | − QScriptValue qException = unwrapped ? unwrapped->toQtValue() : QScriptEngine::newVariant(exception->toVariant()); | |
| 1030 | + QScriptValue qException = unwrapped ? unwrapped->toQtValue() : QScriptEngine::newVariant(exception.toVariant()); | |
| 1031 | 1031 | return raiseException(qException); |
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | −ScriptValuePointer ScriptEngineQtScript::create(int type, const void* ptr) { | |
| 1034 | +ScriptValue ScriptEngineQtScript::create(int type, const void* ptr) { | |
| 1035 | 1035 | QScriptValue result = qScriptValueFromValue_helper(this, type, ptr); |
| 1036 | − return ScriptValuePointer(new ScriptValueQtWrapper(const_cast<ScriptEngineQtScript*>(this), std::move(result))); | |
| 1036 | + return ScriptValue(new ScriptValueQtWrapper(const_cast<ScriptEngineQtScript*>(this), std::move(result))); | |
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | −bool ScriptEngineQtScript::convert(const ScriptValuePointer& value, int type, void* ptr) { | |
| 1039 | +bool ScriptEngineQtScript::convert(const ScriptValue& value, int type, void* ptr) { | |
| 1040 | 1040 | ScriptValueQtWrapper* unwrapped = ScriptValueQtWrapper::unwrap(value); |
| 1041 | 1041 | if (unwrapped == nullptr) { |
| 1042 | 1042 | return false; |
| @@ -1052,13 +1052,13 @@ public: · 9 unmodified lines | ||
| 1052 | 1052 | |
| 1053 | 1053 | static QScriptValue internalMarshalFunc(QScriptEngine* engine, const void* src) { |
| 1054 | 1054 | ScriptEngineQtScript* unwrappedEngine = static_cast<ScriptEngineQtScript*>(engine); |
| 1055 | − ScriptValuePointer dest = marshalFunc(unwrappedEngine, src); | |
| 1055 | + ScriptValue dest = marshalFunc(unwrappedEngine, src); | |
| 1056 | 1056 | return ScriptValueQtWrapper::fullUnwrap(unwrappedEngine, dest); |
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | static void internalDemarshalFunc(const QScriptValue& src, void* dest) { |
| 1060 | 1060 | ScriptEngineQtScript* unwrappedEngine = static_cast<ScriptEngineQtScript*>(src.engine()); |
| 1061 | − ScriptValuePointer wrappedSrc(new ScriptValueQtWrapper(unwrappedEngine, src)); | |
| 1061 | + ScriptValue wrappedSrc(new ScriptValueQtWrapper(unwrappedEngine, src)); | |
| 1062 | 1062 | demarshalFunc(wrappedSrc, dest); |
| 1063 | 1063 | } |
| 1064 | 1064 | }; |
| @@ -1094,7 +1094,7 @@ ScriptEngine::DemarshalFunction CustomTypeInstance<i>::demarshalFunc; · 29 unmodified lines | ||
| 1094 | 1094 | void ScriptEngineQtScript::registerCustomType(int type, |
| 1095 | 1095 | ScriptEngine::MarshalFunction marshalFunc, |
| 1096 | 1096 | ScriptEngine::DemarshalFunction demarshalFunc, |
| 1097 | − const ScriptValuePointer& prototype) | |
| 1097 | + const ScriptValue& prototype) | |
| 1098 | 1098 | { |
| 1099 | 1099 | QScriptValue unwrapped = ScriptValueQtWrapper::fullUnwrap(this, prototype); |
| 1100 | 1100 | QScriptEngine::MarshalFunction internalMarshalFunc; |