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
1919 #include <memory>
2020
2121 #include <QtCore/QByteArray>
22+#include <QtCore/QHash>
2223 #include <QtCore/QMetaEnum>
24+#include <QtCore/QMutex>
2325 #include <QtCore/QObject>
2426 #include <QtCore/QPointer>
2527 #include <QtCore/QString>
@@ -148,10 +150,11 @@ public: // public non-interface methods for other QtScript-specific classes to u · 122 unmodified lines
148150
149151 public: // not for public use, but I don't like how Qt strings this along with private friend functions
150152 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;
152154 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);
155158
156159 protected:
157160 // like `newFunction`, but allows mapping inline C++ lambdas with captures as callable QScriptValues
@@ -162,9 +165,21 @@ protected: · 4 unmodified lines
162165 const QScriptValue& data = QScriptValue(),
163166 const QScriptEngine::ValueOwnership& ownership = QScriptEngine::AutoOwnership);
164167
168+ void registerSystemTypes();
169+
165170 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+
166178 QPointer<ScriptManager> _scriptManager;
167179
180+ mutable QMutex _customTypeProtect;
181+ CustomMarshalMap _customTypes;
182+ CustomPrototypeMap _customPrototypes;
168183 int _nextCustomType = 0;
169184 ScriptValue _nullValue;
170185 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