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.h (1 of 11 files). Show all

Unified · Split

libraries/script-engine/src/qtscript/ScriptEngineQtScript.h+10−9
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #include <QtCore/QMutex>
2525 #include <QtCore/QObject>
2626 #include <QtCore/QPointer>
27+#include <QtCore/QSharedPointer>
2728 #include <QtCore/QString>
2829
2930 #include <QtScript/QScriptEngine>
@@ -34,13 +35,12 @@ · 4 unmodified lines
3435 #include "ArrayBufferClass.h"
3536
3637 class ScriptContextQtWrapper;
37−class ScriptContextQtAgent;
3838 class ScriptEngineQtScript;
3939 class ScriptManager;
40−using ScriptEngineQtScriptPointer = std::shared_ptr<ScriptEngineQtScript>;
40+class ScriptObjectQtProxy;
4141 using ScriptContextQtPointer = std::shared_ptr<ScriptContextQtWrapper>;
4242
43−Q_DECLARE_METATYPE(ScriptEngineQtScriptPointer);
43+Q_DECLARE_METATYPE(ScriptEngine::FunctionSignature)
4444
4545 /// [QtScript] Implements ScriptEngine for QtScript and translates calls for QScriptEngine
4646 class ScriptEngineQtScript final : public QScriptEngine,
@@ -50,7 +50,6 @@ class ScriptEngineQtScript final : public QScriptEngine, · 3 unmodified lines
5050
5151 public: // construction
5252 ScriptEngineQtScript(ScriptManager* scriptManager = nullptr);
53− ~ScriptEngineQtScript();
5453
5554 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5655 // NOTE - these are NOT intended to be public interfaces available to scripts, the are only Q_INVOKABLE so we can
@@ -150,11 +149,16 @@ public: // public non-interface methods for other QtScript-specific classes to u · 93 unmodified lines
150149
151150 public: // not for public use, but I don't like how Qt strings this along with private friend functions
152151 virtual ScriptValue create(int type, const void* ptr) override;
153− virtual QVariant convert(const ScriptValue& value, int type) override;
152+ virtual QVariant convert(const ScriptValue& value, int typeId) override;
154153 virtual void registerCustomType(int type, ScriptEngine::MarshalFunction marshalFunc,
155154 ScriptEngine::DemarshalFunction demarshalFunc) override;
156− bool castValueToVariant(const QScriptValue& val, QVariant& dest, int destType);
155+ bool castValueToVariant(const QScriptValue& val, QVariant& dest, int destTypeId);
157156 QScriptValue castVariantToValue(const QVariant& val);
157+ static QString valueType(const QScriptValue& val);
158+
159+ using ObjectWrapperMap = QMap<QObject*, QWeakPointer<ScriptObjectQtProxy>>;
160+ mutable QMutex _qobjectWrapperMapProtect;
161+ ObjectWrapperMap _qobjectWrapperMap;
158162
159163 protected:
160164 // like `newFunction`, but allows mapping inline C++ lambdas with captures as callable QScriptValues
@@ -180,14 +184,11 @@ protected: · 19 unmodified lines
180184 mutable QMutex _customTypeProtect;
181185 CustomMarshalMap _customTypes;
182186 CustomPrototypeMap _customPrototypes;
183− int _nextCustomType = 0;
184187 ScriptValue _nullValue;
185188 ScriptValue _undefinedValue;
186189 mutable ScriptContextQtPointer _currContext;
187190
188191 ArrayBufferClass* _arrayBufferClass;
189−
190− ScriptContextQtAgent* _contextAgent{ nullptr };
191192 };
192193
193194 // Lambda helps create callable QScriptValues out of std::functions:

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