Showing the changes to libraries/script-engine/src/qtscript/ScriptEngineQtScript.h (1 of 63 files). Show all
Unified · Split
| @@ -19,7 +19,9 @@ · 18 unmodified lines | ||
| 19 | 19 | #include <memory> |
| 20 | 20 | |
| 21 | 21 | #include <QtCore/QByteArray> |
| 22 | +#include <QtCore/QHash> | |
| 22 | 23 | #include <QtCore/QMetaEnum> |
| 24 | +#include <QtCore/QMutex> | |
| 23 | 25 | #include <QtCore/QObject> |
| 24 | 26 | #include <QtCore/QPointer> |
| 25 | 27 | #include <QtCore/QString> |
| @@ -148,10 +150,11 @@ public: // public non-interface methods for other QtScript-specific classes to u · 122 unmodified lines | ||
| 148 | 150 | |
| 149 | 151 | public: // not for public use, but I don't like how Qt strings this along with private friend functions |
| 150 | 152 | virtual ScriptValue create(int type, const void* ptr) override; |
| 151 | − virtual bool convert(const ScriptValue& value, int type, void* ptr) override; | |
| 153 | + virtual QVariant convert(const ScriptValue& value, int type) override; | |
| 152 | 154 | virtual void registerCustomType(int type, ScriptEngine::MarshalFunction marshalFunc, |
| 153 | − ScriptEngine::DemarshalFunction demarshalFunc, | |
| 154 | − const ScriptValue& prototype) override; | |
| 155 | + ScriptEngine::DemarshalFunction demarshalFunc) override; | |
| 156 | + bool castValueToVariant(const QScriptValue& val, QVariant& dest, int destType); | |
| 157 | + QScriptValue castVariantToValue(const QVariant& val); | |
| 155 | 158 | |
| 156 | 159 | protected: |
| 157 | 160 | // like `newFunction`, but allows mapping inline C++ lambdas with captures as callable QScriptValues |
| @@ -162,9 +165,21 @@ protected: · 4 unmodified lines | ||
| 162 | 165 | const QScriptValue& data = QScriptValue(), |
| 163 | 166 | const QScriptEngine::ValueOwnership& ownership = QScriptEngine::AutoOwnership); |
| 164 | 167 | |
| 168 | + void registerSystemTypes(); | |
| 169 | + | |
| 165 | 170 | protected: |
| 171 | + struct CustomMarshal { | |
| 172 | + ScriptEngine::MarshalFunction marshalFunc; | |
| 173 | + ScriptEngine::DemarshalFunction demarshalFunc; | |
| 174 | + }; | |
| 175 | + using CustomMarshalMap = QHash<int, CustomMarshal>; | |
| 176 | + using CustomPrototypeMap = QHash<int, QScriptValue>; | |
| 177 | + | |
| 166 | 178 | QPointer<ScriptManager> _scriptManager; |
| 167 | 179 | |
| 180 | + mutable QMutex _customTypeProtect; | |
| 181 | + CustomMarshalMap _customTypes; | |
| 182 | + CustomPrototypeMap _customPrototypes; | |
| 168 | 183 | int _nextCustomType = 0; |
| 169 | 184 | ScriptValue _nullValue; |
| 170 | 185 | ScriptValue _undefinedValue; |