Showing the changes to libraries/script-engine/src/qtscript/ScriptEngineQtScript.h (1 of 11 files). Show all
Unified · Split
| @@ -24,6 +24,7 @@ · 23 unmodified lines | |||
| 24 | #include <QtCore/QMutex> | 24 | #include <QtCore/QMutex> |
| 25 | #include <QtCore/QObject> | 25 | #include <QtCore/QObject> |
| 26 | #include <QtCore/QPointer> | 26 | #include <QtCore/QPointer> |
| 27 | #include <QtCore/QSharedPointer> | ||
| 27 | #include <QtCore/QString> | 28 | #include <QtCore/QString> |
| 28 | 29 | ||
| 29 | #include <QtScript/QScriptEngine> | 30 | #include <QtScript/QScriptEngine> |
| @@ -34,13 +35,12 @@ · 4 unmodified lines | |||
| 34 | #include "ArrayBufferClass.h" | 35 | #include "ArrayBufferClass.h" |
| 35 | 36 | ||
| 36 | class ScriptContextQtWrapper; | 37 | class ScriptContextQtWrapper; |
| 37 | class ScriptContextQtAgent; | ||
| 38 | class ScriptEngineQtScript; | 38 | class ScriptEngineQtScript; |
| 39 | class ScriptManager; | 39 | class ScriptManager; |
| 40 | using ScriptEngineQtScriptPointer = std::shared_ptr<ScriptEngineQtScript>; | 40 | class ScriptObjectQtProxy; |
| 41 | using ScriptContextQtPointer = std::shared_ptr<ScriptContextQtWrapper>; | 41 | using ScriptContextQtPointer = std::shared_ptr<ScriptContextQtWrapper>; |
| 42 | 42 | ||
| 43 | Q_DECLARE_METATYPE(ScriptEngineQtScriptPointer); | 43 | Q_DECLARE_METATYPE(ScriptEngine::FunctionSignature) |
| 44 | 44 | ||
| 45 | /// [QtScript] Implements ScriptEngine for QtScript and translates calls for QScriptEngine | 45 | /// [QtScript] Implements ScriptEngine for QtScript and translates calls for QScriptEngine |
| 46 | class ScriptEngineQtScript final : public QScriptEngine, | 46 | class ScriptEngineQtScript final : public QScriptEngine, |
| @@ -50,7 +50,6 @@ class ScriptEngineQtScript final : public QScriptEngine, · 3 unmodified lines | |||
| 50 | 50 | ||
| 51 | public: // construction | 51 | public: // construction |
| 52 | ScriptEngineQtScript(ScriptManager* scriptManager = nullptr); | 52 | ScriptEngineQtScript(ScriptManager* scriptManager = nullptr); |
| 53 | ~ScriptEngineQtScript(); | ||
| 54 | 53 | ||
| 55 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 54 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 56 | // NOTE - these are NOT intended to be public interfaces available to scripts, the are only Q_INVOKABLE so we can | 55 | // 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 | |||
| 150 | 149 | ||
| 151 | public: // not for public use, but I don't like how Qt strings this along with private friend functions | 150 | public: // not for public use, but I don't like how Qt strings this along with private friend functions |
| 152 | virtual ScriptValue create(int type, const void* ptr) override; | 151 | 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; |
| 154 | virtual void registerCustomType(int type, ScriptEngine::MarshalFunction marshalFunc, | 153 | virtual void registerCustomType(int type, ScriptEngine::MarshalFunction marshalFunc, |
| 155 | ScriptEngine::DemarshalFunction demarshalFunc) override; | 154 | ScriptEngine::DemarshalFunction demarshalFunc) override; |
| 156 | bool castValueToVariant(const QScriptValue& val, QVariant& dest, int destType); | 155 | bool castValueToVariant(const QScriptValue& val, QVariant& dest, int destTypeId); |
| 157 | QScriptValue castVariantToValue(const QVariant& val); | 156 | 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; | ||
| 158 | 162 | ||
| 159 | protected: | 163 | protected: |
| 160 | // like `newFunction`, but allows mapping inline C++ lambdas with captures as callable QScriptValues | 164 | // like `newFunction`, but allows mapping inline C++ lambdas with captures as callable QScriptValues |
| @@ -180,14 +184,11 @@ protected: · 19 unmodified lines | |||
| 180 | mutable QMutex _customTypeProtect; | 184 | mutable QMutex _customTypeProtect; |
| 181 | CustomMarshalMap _customTypes; | 185 | CustomMarshalMap _customTypes; |
| 182 | CustomPrototypeMap _customPrototypes; | 186 | CustomPrototypeMap _customPrototypes; |
| 183 | int _nextCustomType = 0; | ||
| 184 | ScriptValue _nullValue; | 187 | ScriptValue _nullValue; |
| 185 | ScriptValue _undefinedValue; | 188 | ScriptValue _undefinedValue; |
| 186 | mutable ScriptContextQtPointer _currContext; | 189 | mutable ScriptContextQtPointer _currContext; |
| 187 | 190 | ||
| 188 | ArrayBufferClass* _arrayBufferClass; | 191 | ArrayBufferClass* _arrayBufferClass; |
| 189 | |||
| 190 | ScriptContextQtAgent* _contextAgent{ nullptr }; | ||
| 191 | }; | 192 | }; |
| 192 | 193 | ||
| 193 | // Lambda helps create callable QScriptValues out of std::functions: | 194 | // Lambda helps create callable QScriptValues out of std::functions: |