History

rework ScriptValue to act like a stack variable rather than a pointer

Heather Anderson committed 5 years ago

Commit 85810221 parent f209c51170 files · +2837 −2594Browse files

Showing the changes to libraries/script-engine/src/qtscript/ScriptEngineQtScript.cpp (1 of 170 files). Show all

Unified · Split

libraries/script-engine/src/qtscript/ScriptEngineQtScript.cpp+94−94
@@ -62,7 +62,7 @@ static const QScriptValue::PropertyFlags READONLY_HIDDEN_PROP_FLAGS { READONLY_P · 61 unmodified lines
6262
6363 static const bool HIFI_AUTOREFRESH_FILE_SCRIPTS { true };
6464
65−Q_DECLARE_METATYPE(ScriptValuePointer);
65+Q_DECLARE_METATYPE(ScriptValue);
6666
6767 Q_DECLARE_METATYPE(QScriptEngine::FunctionSignature)
6868 int qfunctionSignatureMetaID = qRegisterMetaType<QScriptEngine::FunctionSignature>();
@@ -120,26 +120,26 @@ QScriptValue ScriptEngineQtScript::makeError(const QScriptValue& _other, const Q · 51 unmodified lines
120120 return err;
121121 }
122122
123−ScriptValuePointer ScriptEngineQtScript::makeError(const ScriptValuePointer& _other, const QString& type) {
123+ScriptValue ScriptEngineQtScript::makeError(const ScriptValue& _other, const QString& type) {
124124 if (!IS_THREADSAFE_INVOCATION(thread(), __FUNCTION__)) {
125125 return nullValue();
126126 }
127127 ScriptValueQtWrapper* unwrapped = ScriptValueQtWrapper::unwrap(_other);
128128 QScriptValue other;
129− if (_other->isString()) {
129+ if (_other.isString()) {
130130 other = QScriptEngine::newObject();
131− other.setProperty("message", _other->toString());
131+ other.setProperty("message", _other.toString());
132132 } else if (unwrapped) {
133133 other = unwrapped->toQtValue();
134134 } else {
135− other = QScriptEngine::newVariant(_other->toVariant());
135+ other = QScriptEngine::newVariant(_other.toVariant());
136136 }
137137 QScriptValue result = makeError(other, type);
138− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
138+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
139139 }
140140
141141 // 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) {
143143 if (!IS_THREADSAFE_INVOCATION(thread(), __FUNCTION__)) {
144144 return nullValue();
145145 }
@@ -158,13 +158,13 @@ ScriptValuePointer ScriptEngineQtScript::lintScript(const QString& sourceCode, c · 12 unmodified lines
158158 const auto message = QString("[SyntaxError] %1 in %2:%3(%4)").arg(error, fileName, line, column);
159159 err.setProperty("formatted", message);
160160 }
161− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(err)));
161+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(err)));
162162 }
163163 return undefinedValue();
164164 }
165165
166166 // 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) {
168168 if (!IS_THREADSAFE_INVOCATION(thread(), __FUNCTION__)) {
169169 return nullValue();
170170 }
@@ -178,17 +178,17 @@ ScriptValuePointer ScriptEngineQtScript::cloneUncaughtException(const QString& e · 7 unmodified lines
178178 // not sure why Qt does't offer uncaughtExceptionFileName -- but the line number
179179 // on its own is often useless/wrong if arbitrarily married to a filename.
180180 // 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();
183183
184184 // the backtrace, on the other hand, seems most reliable taken from uncaughtExceptionBacktrace
185185 auto backtrace = uncaughtExceptionBacktrace();
186186 if (backtrace.isEmpty()) {
187187 // 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);
189189 }
190190 // 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();
192192 if (detail.isEmpty()) {
193193 detail = extraDetail;
194194 } else if (!extraDetail.isEmpty()) {
@@ -212,15 +212,15 @@ ScriptValuePointer ScriptEngineQtScript::cloneUncaughtException(const QString& e · 17 unmodified lines
212212 }
213213 }
214214 }
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));
219219
220220 #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());
224224 #endif
225225 return err;
226226 }
@@ -237,7 +237,7 @@ bool ScriptEngineQtScript::raiseException(const QScriptValue& exception) { · 10 unmodified lines
237237 // we are within a pure C++ stack frame (ie: being called directly by other C++ code)
238238 // in this case no context information is available so just emit the exception for reporting
239239 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))));
241241 }
242242 return false;
243243 }
@@ -383,13 +383,13 @@ static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) { · 139 unmodified lines
383383 return QScriptValue();
384384 }
385385
386−static QScriptValue ScriptValueToQScriptValue(QScriptEngine* engine, const ScriptValuePointer& src) {
386+static QScriptValue ScriptValueToQScriptValue(QScriptEngine* engine, const ScriptValue& src) {
387387 return ScriptValueQtWrapper::fullUnwrap(static_cast<ScriptEngineQtScript*>(engine), src);
388388 }
389389
390−static void ScriptValueFromQScriptValue(const QScriptValue& src, ScriptValuePointer& dest) {
390+static void ScriptValueFromQScriptValue(const QScriptValue& src, ScriptValue& dest) {
391391 ScriptEngineQtScript* engine = static_cast<ScriptEngineQtScript*>(src.engine());
392− dest = ScriptValuePointer(new ScriptValueQtWrapper(engine, src));
392+ dest = ScriptValue(new ScriptValueQtWrapper(engine, src));
393393 }
394394
395395 ScriptEngineQtScript::ScriptEngineQtScript(ScriptManager* scriptManager) :
@@ -408,17 +408,17 @@ ScriptEngineQtScript::ScriptEngineQtScript(ScriptManager* scriptManager) : · 12 unmodified lines
408408 } else {
409409 // ... but may not always be available -- so if needed we fallback to the passed exception
410410 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))));
412412 }
413413 }, Qt::DirectConnection);
414414 moveToThread(scriptManager->thread());
415415 }
416416
417417 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)));
419419
420420 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)));
422422
423423 QScriptEngine::setProcessEventsInterval(MSECS_PER_SECOND);
424424 }
@@ -478,14 +478,14 @@ void ScriptEngineQtScript::registerValue(const QString& valueName, QScriptValue · 53 unmodified lines
478478
479479 QStringList pathToValue = valueName.split(".");
480480 int partsToGo = pathToValue.length();
481− QScriptValue partObject = globalObject();
481+ QScriptValue partObject = QScriptEngine::globalObject();
482482
483483 for (const auto& pathPart : pathToValue) {
484484 partsToGo--;
485485 if (!partObject.property(pathPart).isValid()) {
486486 if (partsToGo > 0) {
487487 //QObject *object = new QObject;
488− QScriptValue partValue = newArray(); //newQObject(object, QScriptEngine::ScriptOwnership);
488+ QScriptValue partValue = QScriptEngine::newArray(); //newQObject(object, QScriptEngine::ScriptOwnership);
489489 partObject.setProperty(pathPart, partValue);
490490 } else {
491491 partObject.setProperty(pathPart, value);
@@ -554,7 +554,7 @@ void ScriptEngineQtScript::registerFunction(const QString& name, ScriptEngine::F · 62 unmodified lines
554554 #endif
555555
556556 auto scriptFun = newFunction(functionSignature, numArguments);
557− globalObject()->setProperty(name, scriptFun);
557+ globalObject().setProperty(name, scriptFun);
558558 }
559559
560560 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
594594 qCDebug(scriptengine) << "ScriptEngineQtScript::registerFunction() called on thread [" << QThread::currentThread() << "] parent:" << parent << "name:" << name;
595595 #endif
596596
597− auto object = globalObject()->property(parent);
598− if (object->isValid()) {
597+ auto object = globalObject().property(parent);
598+ if (object.isValid()) {
599599 auto scriptFun = newFunction(functionSignature, numArguments);
600− object->setProperty(name, scriptFun);
600+ object.setProperty(name, scriptFun);
601601 }
602602 }
603603
@@ -656,18 +656,18 @@ void ScriptEngineQtScript::registerGetterSetter(const QString& name, ScriptEngin · 52 unmodified lines
656656 auto getterFunction = newFunction(getter);
657657
658658 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);
663663 }
664664 } 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);
667667 }
668668 }
669669
670−ScriptValuePointer ScriptEngineQtScript::evaluateInClosure(const ScriptValuePointer& _closure,
670+ScriptValue ScriptEngineQtScript::evaluateInClosure(const ScriptValue& _closure,
671671 const ScriptProgramPointer& _program) {
672672 PROFILE_RANGE(script, "evaluateInClosure");
673673 if (!IS_THREADSAFE_INVOCATION(thread(), __FUNCTION__)) {
@@ -712,7 +712,7 @@ ScriptValuePointer ScriptEngineQtScript::evaluateInClosure(const ScriptValuePoin · 38 unmodified lines
712712 #ifdef DEBUG_JS
713713 qCDebug(shared) << QString("[%1] evaluateInClosure %2").arg(isEvaluating()).arg(shortName);
714714 #endif
715− ScriptValuePointer result;
715+ ScriptValue result;
716716 {
717717 auto qResult = QScriptEngine::evaluate(program);
718718
@@ -724,7 +724,7 @@ ScriptValuePointer ScriptEngineQtScript::evaluateInClosure(const ScriptValuePoin · 5 unmodified lines
724724 #endif
725725 result = err;
726726 } else {
727− result = ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(qResult)));
727+ result = ScriptValue(new ScriptValueQtWrapper(this, std::move(qResult)));
728728 }
729729 }
730730 #ifdef DEBUG_JS
@@ -742,19 +742,19 @@ ScriptValuePointer ScriptEngineQtScript::evaluateInClosure(const ScriptValuePoin · 11 unmodified lines
742742 return result;
743743 }
744744
745−ScriptValuePointer ScriptEngineQtScript::evaluate(const QString& sourceCode, const QString& fileName) {
745+ScriptValue ScriptEngineQtScript::evaluate(const QString& sourceCode, const QString& fileName) {
746746 if (_manager && _manager->isStopped()) {
747747 return undefinedValue(); // bail early
748748 }
749749
750750 if (QThread::currentThread() != QScriptEngine::thread()) {
751− ScriptValuePointer result;
751+ ScriptValue result;
752752 #ifdef THREAD_DEBUGGING
753753 qCDebug(scriptengine) << "*** WARNING *** ScriptEngineQtScript::evaluate() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
754754 "sourceCode:" << sourceCode << " fileName:" << fileName;
755755 #endif
756756 BLOCKING_INVOKE_METHOD(this, "evaluate",
757− Q_RETURN_ARG(ScriptValuePointer, result),
757+ Q_RETURN_ARG(ScriptValue, result),
758758 Q_ARG(const QString&, sourceCode),
759759 Q_ARG(const QString&, fileName));
760760 return result;
@@ -762,9 +762,9 @@ ScriptValuePointer ScriptEngineQtScript::evaluate(const QString& sourceCode, con · 1 unmodified line
762762
763763 // Check syntax
764764 auto syntaxError = lintScript(sourceCode, fileName);
765− if (syntaxError->isError()) {
765+ if (syntaxError.isError()) {
766766 if (!isEvaluating()) {
767− syntaxError->setProperty("detail", "evaluate");
767+ syntaxError.setProperty("detail", "evaluate");
768768 }
769769 raiseException(syntaxError);
770770 maybeEmitUncaughtException("lint");
@@ -782,22 +782,22 @@ ScriptValuePointer ScriptEngineQtScript::evaluate(const QString& sourceCode, con · 11 unmodified lines
782782 QScriptValue result = QScriptEngine::evaluate(program);
783783 maybeEmitUncaughtException("evaluate");
784784
785− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
785+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
786786 }
787787
788−Q_INVOKABLE ScriptValuePointer ScriptEngineQtScript::evaluate(const ScriptProgramPointer& program) {
788+Q_INVOKABLE ScriptValue ScriptEngineQtScript::evaluate(const ScriptProgramPointer& program) {
789789 if (_manager && _manager->isStopped()) {
790790 return undefinedValue(); // bail early
791791 }
792792
793793 if (QThread::currentThread() != QScriptEngine::thread()) {
794− ScriptValuePointer result;
794+ ScriptValue result;
795795 #ifdef THREAD_DEBUGGING
796796 qCDebug(scriptengine) << "*** WARNING *** ScriptEngineQtScript::evaluate() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
797797 "sourceCode:" << sourceCode << " fileName:" << fileName;
798798 #endif
799799 BLOCKING_INVOKE_METHOD(this, "evaluate",
800− Q_RETURN_ARG(ScriptValuePointer, result),
800+ Q_RETURN_ARG(ScriptValue, result),
801801 Q_ARG(const ScriptProgramPointer&, program));
802802 return result;
803803 }
@@ -822,7 +822,7 @@ Q_INVOKABLE ScriptValuePointer ScriptEngineQtScript::evaluate(const ScriptProgra · 18 unmodified lines
822822 QScriptValue result = QScriptEngine::evaluate(qProgram);
823823 maybeEmitUncaughtException("evaluate");
824824
825− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
825+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
826826 }
827827
828828
@@ -849,21 +849,21 @@ void ScriptEngineQtScript::print(const QString& message) { · 20 unmodified lines
849849 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
850850 // ScriptEngine implementation
851851
852−ScriptValuePointer ScriptEngineQtScript::globalObject() const {
852+ScriptValue ScriptEngineQtScript::globalObject() const {
853853 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)));
855855 }
856856
857857 ScriptManager* ScriptEngineQtScript::manager() const {
858858 return _manager;
859859 }
860860
861−ScriptValuePointer ScriptEngineQtScript::newArray(uint length) {
861+ScriptValue ScriptEngineQtScript::newArray(uint length) {
862862 QScriptValue result = QScriptEngine::newArray(length);
863− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
863+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
864864 }
865865
866−ScriptValuePointer ScriptEngineQtScript::newArrayBuffer(const QByteArray& message) {
866+ScriptValue ScriptEngineQtScript::newArrayBuffer(const QByteArray& message) {
867867 QScriptValue data = QScriptEngine::newVariant(QVariant::fromValue(message));
868868 QScriptValue ctor = QScriptEngine::globalObject().property("ArrayBuffer");
869869 auto array = qscriptvalue_cast<ArrayBufferClass*>(ctor.data());
@@ -871,12 +871,12 @@ ScriptValuePointer ScriptEngineQtScript::newArrayBuffer(const QByteArray& messag · 1 unmodified line
871871 return undefinedValue();
872872 }
873873 QScriptValue result = QScriptEngine::newObject(array, data);
874− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
874+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
875875 }
876876
877−ScriptValuePointer ScriptEngineQtScript::newObject() {
877+ScriptValue ScriptEngineQtScript::newObject() {
878878 QScriptValue result = QScriptEngine::newObject();
879− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
879+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
880880 }
881881
882882 ScriptProgramPointer ScriptEngineQtScript::newProgram(const QString& sourceCode, const QString& fileName) {
@@ -884,66 +884,66 @@ ScriptProgramPointer ScriptEngineQtScript::newProgram(const QString& sourceCode, · 1 unmodified line
884884 return ScriptProgramPointer(new ScriptProgramQtWrapper(this, result));
885885 }
886886
887−ScriptValuePointer ScriptEngineQtScript::newQObject(QObject* object,
887+ScriptValue ScriptEngineQtScript::newQObject(QObject* object,
888888 ScriptEngine::ValueOwnership ownership,
889889 const ScriptEngine::QObjectWrapOptions& options) {
890890 QScriptValue result = QScriptEngine::newQObject(object, static_cast<QScriptEngine::ValueOwnership>(ownership),
891891 (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)));
893893 }
894894
895−ScriptValuePointer ScriptEngineQtScript::newValue(bool value) {
895+ScriptValue ScriptEngineQtScript::newValue(bool value) {
896896 QScriptValue result(this, value);
897− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
897+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
898898 }
899899
900−ScriptValuePointer ScriptEngineQtScript::newValue(int value) {
900+ScriptValue ScriptEngineQtScript::newValue(int value) {
901901 QScriptValue result(this, value);
902− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
902+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
903903 }
904904
905−ScriptValuePointer ScriptEngineQtScript::newValue(uint value) {
905+ScriptValue ScriptEngineQtScript::newValue(uint value) {
906906 QScriptValue result(this, value);
907− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
907+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
908908 }
909909
910−ScriptValuePointer ScriptEngineQtScript::newValue(double value) {
910+ScriptValue ScriptEngineQtScript::newValue(double value) {
911911 QScriptValue result(this, value);
912− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
912+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
913913 }
914914
915−ScriptValuePointer ScriptEngineQtScript::newValue(const QString& value) {
915+ScriptValue ScriptEngineQtScript::newValue(const QString& value) {
916916 QScriptValue result(this, value);
917− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
917+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
918918 }
919919
920−ScriptValuePointer ScriptEngineQtScript::newValue(const QLatin1String& value) {
920+ScriptValue ScriptEngineQtScript::newValue(const QLatin1String& value) {
921921 QScriptValue result(this, value);
922− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
922+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
923923 }
924924
925−ScriptValuePointer ScriptEngineQtScript::newValue(const char* value) {
925+ScriptValue ScriptEngineQtScript::newValue(const char* value) {
926926 QScriptValue result(this, value);
927− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
927+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
928928 }
929929
930−ScriptValuePointer ScriptEngineQtScript::newVariant(const QVariant& value) {
930+ScriptValue ScriptEngineQtScript::newVariant(const QVariant& value) {
931931 QScriptValue result = QScriptEngine::newVariant(value);
932− return ScriptValuePointer(new ScriptValueQtWrapper(this, std::move(result)));
932+ return ScriptValue(new ScriptValueQtWrapper(this, std::move(result)));
933933 }
934934
935−ScriptValuePointer ScriptEngineQtScript::nullValue() {
935+ScriptValue ScriptEngineQtScript::nullValue() {
936936 return _nullValue;
937937 }
938938
939−void ScriptEngineQtScript::setDefaultPrototype(int metaTypeId, const ScriptValuePointer& prototype){
939+void ScriptEngineQtScript::setDefaultPrototype(int metaTypeId, const ScriptValue& prototype){
940940 ScriptValueQtWrapper* unwrappedPrototype = ScriptValueQtWrapper::unwrap(prototype);
941941 if (unwrappedPrototype) {
942942 QScriptEngine::setDefaultPrototype(metaTypeId, unwrappedPrototype->toQtValue());
943943 }
944944 }
945945
946−ScriptValuePointer ScriptEngineQtScript::undefinedValue() {
946+ScriptValue ScriptEngineQtScript::undefinedValue() {
947947 return _undefinedValue;
948948 }
949949
@@ -974,14 +974,14 @@ bool ScriptEngineQtScript::isEvaluating() const { · 24 unmodified lines
974974 return QScriptEngine::isEvaluating();
975975 }
976976
977−ScriptValuePointer ScriptEngineQtScript::newFunction(ScriptEngine::FunctionSignature fun, int length) {
977+ScriptValue ScriptEngineQtScript::newFunction(ScriptEngine::FunctionSignature fun, int length) {
978978 auto innerFunc = [](QScriptContext* _context, QScriptEngine* _engine) -> QScriptValue {
979979 auto callee = _context->callee();
980980 QVariant funAddr = callee.property("_func").toVariant();
981981 ScriptEngine::FunctionSignature fun = reinterpret_cast<ScriptEngine::FunctionSignature>(funAddr.toULongLong());
982982 ScriptEngineQtScript* engine = static_cast<ScriptEngineQtScript*>(_engine);
983983 ScriptContextQtWrapper context(engine, _context);
984− ScriptValuePointer result = fun(&context, engine);
984+ ScriptValue result = fun(&context, engine);
985985 ScriptValueQtWrapper* unwrapped = ScriptValueQtWrapper::unwrap(result);
986986 return unwrapped ? unwrapped->toQtValue() : QScriptValue();
987987 };
@@ -989,7 +989,7 @@ ScriptValuePointer ScriptEngineQtScript::newFunction(ScriptEngine::FunctionSigna · 1 unmodified line
989989 QScriptValue result = QScriptEngine::newFunction(innerFunc, length);
990990 auto funAddr = QScriptEngine::newVariant(QVariant(reinterpret_cast<qulonglong>(fun)));
991991 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)));
993993 }
994994
995995 void ScriptEngineQtScript::setObjectName(const QString& name) {
@@ -1012,9 +1012,9 @@ void ScriptEngineQtScript::setThread(QThread* thread) { · 16 unmodified lines
10121012 moveToThread(thread);
10131013 }
10141014
1015−ScriptValuePointer ScriptEngineQtScript::uncaughtException() const {
1015+ScriptValue ScriptEngineQtScript::uncaughtException() const {
10161016 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)));
10181018 }
10191019
10201020 QStringList ScriptEngineQtScript::uncaughtExceptionBacktrace() const {
@@ -1025,18 +1025,18 @@ int ScriptEngineQtScript::uncaughtExceptionLineNumber() const { · 4 unmodified lines
10251025 return QScriptEngine::uncaughtExceptionLineNumber();
10261026 }
10271027
1028−bool ScriptEngineQtScript::raiseException(const ScriptValuePointer& exception) {
1028+bool ScriptEngineQtScript::raiseException(const ScriptValue& exception) {
10291029 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());
10311031 return raiseException(qException);
10321032 }
10331033
1034−ScriptValuePointer ScriptEngineQtScript::create(int type, const void* ptr) {
1034+ScriptValue ScriptEngineQtScript::create(int type, const void* ptr) {
10351035 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)));
10371037 }
10381038
1039−bool ScriptEngineQtScript::convert(const ScriptValuePointer& value, int type, void* ptr) {
1039+bool ScriptEngineQtScript::convert(const ScriptValue& value, int type, void* ptr) {
10401040 ScriptValueQtWrapper* unwrapped = ScriptValueQtWrapper::unwrap(value);
10411041 if (unwrapped == nullptr) {
10421042 return false;
@@ -1052,13 +1052,13 @@ public: · 9 unmodified lines
10521052
10531053 static QScriptValue internalMarshalFunc(QScriptEngine* engine, const void* src) {
10541054 ScriptEngineQtScript* unwrappedEngine = static_cast<ScriptEngineQtScript*>(engine);
1055− ScriptValuePointer dest = marshalFunc(unwrappedEngine, src);
1055+ ScriptValue dest = marshalFunc(unwrappedEngine, src);
10561056 return ScriptValueQtWrapper::fullUnwrap(unwrappedEngine, dest);
10571057 }
10581058
10591059 static void internalDemarshalFunc(const QScriptValue& src, void* dest) {
10601060 ScriptEngineQtScript* unwrappedEngine = static_cast<ScriptEngineQtScript*>(src.engine());
1061− ScriptValuePointer wrappedSrc(new ScriptValueQtWrapper(unwrappedEngine, src));
1061+ ScriptValue wrappedSrc(new ScriptValueQtWrapper(unwrappedEngine, src));
10621062 demarshalFunc(wrappedSrc, dest);
10631063 }
10641064 };
@@ -1094,7 +1094,7 @@ ScriptEngine::DemarshalFunction CustomTypeInstance<i>::demarshalFunc; · 29 unmodified lines
10941094 void ScriptEngineQtScript::registerCustomType(int type,
10951095 ScriptEngine::MarshalFunction marshalFunc,
10961096 ScriptEngine::DemarshalFunction demarshalFunc,
1097− const ScriptValuePointer& prototype)
1097+ const ScriptValue& prototype)
10981098 {
10991099 QScriptValue unwrapped = ScriptValueQtWrapper::fullUnwrap(this, prototype);
11001100 QScriptEngine::MarshalFunction internalMarshalFunc;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t