History

first pass creating Qt <-> QtScript interface

Heather Anderson committed 4 years ago

Commit bc6eaf21 parent bd0455463 files · +1707 −294Browse files

Showing the changes to libraries/script-engine/src/qtscript/ScriptEngineQtScript.h (1 of 63 files). Show all

Unified · Split

libraries/script-engine/src/qtscript/ScriptEngineQtScript.h+18−3
@@ -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
149public: // not for public use, but I don't like how Qt strings this along with private friend functions151public: // 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
156protected:159protected:
157 // like `newFunction`, but allows mapping inline C++ lambdas with captures as callable QScriptValues160 // 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
165protected:170protected:
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;

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