History

Continued tightening and testing of the scripting engine "glue" logic - QObject wrappers will now be reused when asked to wrap the same QObject multiple times - improved error reporting when we can't form a native call from script - dropped support for having the existing QtScript logic handle Qt object transformations - assuming that our code will handle all calls into native objects - changing timer functions to use CTimer* publicly rather than casted QObject*

Heather Anderson committed 4 years ago

Commit 55b5a2c1 parent 742fa2211 files · +262 −382Browse files

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

Unified · Split

libraries/script-engine/src/qtscript/ScriptEngineQtScript.cpp+4−17
@@ -52,15 +52,9 @@ · 51 unmodified lines
5252 #include "ScriptObjectQtProxy.h"
5353 #include "ScriptProgramQtWrapper.h"
5454 #include "ScriptValueQtWrapper.h"
55−#include "ScriptContextQtAgent.h"
5655
5756 static const int MAX_DEBUG_VALUE_LENGTH { 80 };
5857
59−Q_DECLARE_METATYPE(QScriptEngine::FunctionSignature)
60−int qfunctionSignatureMetaID = qRegisterMetaType<QScriptEngine::FunctionSignature>();
61−
62−int scriptEnginePointerMetaID = qRegisterMetaType<ScriptEngineQtScriptPointer>();
63−
6458 bool ScriptEngineQtScript::IS_THREADSAFE_INVOCATION(const QThread* thread, const QString& method) {
6559 const QThread* currentThread = QThread::currentThread();
6660 if (currentThread == thread) {
@@ -336,13 +330,6 @@ ScriptEngineQtScript::ScriptEngineQtScript(ScriptManager* scriptManager) : · 269 unmodified lines
336330 _undefinedValue = ScriptValue(new ScriptValueQtWrapper(this, std::move(undefined)));
337331
338332 QScriptEngine::setProcessEventsInterval(MSECS_PER_SECOND);
339−
340− _contextAgent = new ScriptContextQtAgent(this, agent());
341− setAgent(_contextAgent);
342−}
343−
344−ScriptEngineQtScript::~ScriptEngineQtScript() {
345− delete _contextAgent;
346333 }
347334
348335 void ScriptEngineQtScript::registerEnum(const QString& enumName, QMetaEnum newEnum) {
@@ -912,20 +899,20 @@ ScriptValue ScriptEngineQtScript::create(int type, const void* ptr) { · 563 unmodified lines
912899 return ScriptValue(new ScriptValueQtWrapper(this, std::move(scriptValue)));
913900 }
914901
915−QVariant ScriptEngineQtScript::convert(const ScriptValue& value, int type) {
902+QVariant ScriptEngineQtScript::convert(const ScriptValue& value, int typeId) {
916903 ScriptValueQtWrapper* unwrapped = ScriptValueQtWrapper::unwrap(value);
917904 if (unwrapped == nullptr) {
918905 return QVariant();
919906 }
920907
921908 QVariant var;
922− if (!castValueToVariant(unwrapped->toQtValue(), var, type)) {
909+ if (!castValueToVariant(unwrapped->toQtValue(), var, typeId)) {
923910 return QVariant();
924911 }
925912
926913 int destType = var.userType();
927− if (destType != type) {
928− var.convert(type); // if conversion fails then var is set to QVariant()
914+ if (destType != typeId) {
915+ var.convert(typeId); // if conversion fails then var is set to QVariant()
929916 }
930917
931918 return var;