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
52#include "ScriptObjectQtProxy.h"52#include "ScriptObjectQtProxy.h"
53#include "ScriptProgramQtWrapper.h"53#include "ScriptProgramQtWrapper.h"
54#include "ScriptValueQtWrapper.h"54#include "ScriptValueQtWrapper.h"
55#include "ScriptContextQtAgent.h"
56 55
57static const int MAX_DEBUG_VALUE_LENGTH { 80 };56static const int MAX_DEBUG_VALUE_LENGTH { 80 };
58 57
59Q_DECLARE_METATYPE(QScriptEngine::FunctionSignature)
60int qfunctionSignatureMetaID = qRegisterMetaType<QScriptEngine::FunctionSignature>();
61
62int scriptEnginePointerMetaID = qRegisterMetaType<ScriptEngineQtScriptPointer>();
63
64bool ScriptEngineQtScript::IS_THREADSAFE_INVOCATION(const QThread* thread, const QString& method) {58bool ScriptEngineQtScript::IS_THREADSAFE_INVOCATION(const QThread* thread, const QString& method) {
65 const QThread* currentThread = QThread::currentThread();59 const QThread* currentThread = QThread::currentThread();
66 if (currentThread == thread) {60 if (currentThread == thread) {
@@ -336,13 +330,6 @@ ScriptEngineQtScript::ScriptEngineQtScript(ScriptManager* scriptManager) : · 269 unmodified lines
336 _undefinedValue = ScriptValue(new ScriptValueQtWrapper(this, std::move(undefined)));330 _undefinedValue = ScriptValue(new ScriptValueQtWrapper(this, std::move(undefined)));
337 331
338 QScriptEngine::setProcessEventsInterval(MSECS_PER_SECOND);332 QScriptEngine::setProcessEventsInterval(MSECS_PER_SECOND);
339
340 _contextAgent = new ScriptContextQtAgent(this, agent());
341 setAgent(_contextAgent);
342}
343
344ScriptEngineQtScript::~ScriptEngineQtScript() {
345 delete _contextAgent;
346}333}
347 334
348void ScriptEngineQtScript::registerEnum(const QString& enumName, QMetaEnum newEnum) {335void ScriptEngineQtScript::registerEnum(const QString& enumName, QMetaEnum newEnum) {
@@ -912,20 +899,20 @@ ScriptValue ScriptEngineQtScript::create(int type, const void* ptr) { · 563 unmodified lines
912 return ScriptValue(new ScriptValueQtWrapper(this, std::move(scriptValue)));899 return ScriptValue(new ScriptValueQtWrapper(this, std::move(scriptValue)));
913}900}
914 901
915QVariant ScriptEngineQtScript::convert(const ScriptValue& value, int type) {902QVariant ScriptEngineQtScript::convert(const ScriptValue& value, int typeId) {
916 ScriptValueQtWrapper* unwrapped = ScriptValueQtWrapper::unwrap(value);903 ScriptValueQtWrapper* unwrapped = ScriptValueQtWrapper::unwrap(value);
917 if (unwrapped == nullptr) {904 if (unwrapped == nullptr) {
918 return QVariant();905 return QVariant();
919 }906 }
920 907
921 QVariant var;908 QVariant var;
922 if (!castValueToVariant(unwrapped->toQtValue(), var, type)) {909 if (!castValueToVariant(unwrapped->toQtValue(), var, typeId)) {
923 return QVariant();910 return QVariant();
924 }911 }
925 912
926 int destType = var.userType();913 int destType = var.userType();
927 if (destType != type) {914 if (destType != typeId) {
928 var.convert(type); // if conversion fails then var is set to QVariant()915 var.convert(typeId); // if conversion fails then var is set to QVariant()
929 }916 }
930 917
931 return var;918 return var;