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 | #include <memory> | 19 | #include <memory> |
| 20 | 20 | ||
| 21 | #include <QtCore/QByteArray> | 21 | #include <QtCore/QByteArray> |
| 22 | #include <QtCore/QHash> | ||
| 22 | #include <QtCore/QMetaEnum> | 23 | #include <QtCore/QMetaEnum> |
| 24 | #include <QtCore/QMutex> | ||
| 23 | #include <QtCore/QObject> | 25 | #include <QtCore/QObject> |
| 24 | #include <QtCore/QPointer> | 26 | #include <QtCore/QPointer> |
| 25 | #include <QtCore/QString> | 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 | public: // not for public use, but I don't like how Qt strings this along with private friend functions | 151 | public: // not for public use, but I don't like how Qt strings this along with private friend functions |
| 150 | virtual ScriptValue create(int type, const void* ptr) override; | 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 | virtual void registerCustomType(int type, ScriptEngine::MarshalFunction marshalFunc, | 154 | virtual void registerCustomType(int type, ScriptEngine::MarshalFunction marshalFunc, |
| 153 | ScriptEngine::DemarshalFunction demarshalFunc, | 155 | ScriptEngine::DemarshalFunction demarshalFunc) override; |
| 154 | const ScriptValue& prototype) override; | 156 | bool castValueToVariant(const QScriptValue& val, QVariant& dest, int destType); |
| 157 | QScriptValue castVariantToValue(const QVariant& val); | ||
| 155 | 158 | ||
| 156 | protected: | 159 | protected: |
| 157 | // like `newFunction`, but allows mapping inline C++ lambdas with captures as callable QScriptValues | 160 | // like `newFunction`, but allows mapping inline C++ lambdas with captures as callable QScriptValues |
| @@ -162,9 +165,21 @@ protected: · 4 unmodified lines | |||
| 162 | const QScriptValue& data = QScriptValue(), | 165 | const QScriptValue& data = QScriptValue(), |
| 163 | const QScriptEngine::ValueOwnership& ownership = QScriptEngine::AutoOwnership); | 166 | const QScriptEngine::ValueOwnership& ownership = QScriptEngine::AutoOwnership); |
| 164 | 167 | ||
| 168 | void registerSystemTypes(); | ||
| 169 | |||
| 165 | protected: | 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 | QPointer<ScriptManager> _scriptManager; | 178 | QPointer<ScriptManager> _scriptManager; |
| 167 | 179 | ||
| 180 | mutable QMutex _customTypeProtect; | ||
| 181 | CustomMarshalMap _customTypes; | ||
| 182 | CustomPrototypeMap _customPrototypes; | ||
| 168 | int _nextCustomType = 0; | 183 | int _nextCustomType = 0; |
| 169 | ScriptValue _nullValue; | 184 | ScriptValue _nullValue; |
| 170 | ScriptValue _undefinedValue; | 185 | ScriptValue _undefinedValue; |