History

added custom type support

Heather Anderson committed 5 years ago

Commit 5f2b2c91 parent 45ef4582 files · +64 −8Browse files

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

Unified · Split

libraries/script-engine/src/qtscript/ScriptEngineQtScript.h+12−1
@@ -382,7 +382,8 @@ signals: · 381 unmodified lines
382public: // not for public use, but I don't like how Qt strings this along with private friend functions382public: // not for public use, but I don't like how Qt strings this along with private friend functions
383 virtual ScriptValuePointer create(int type, const void* ptr);383 virtual ScriptValuePointer create(int type, const void* ptr);
384 virtual bool convert(const ScriptValuePointer& value, int type, void* ptr);384 virtual bool convert(const ScriptValuePointer& value, int type, void* ptr);
385 virtual void registerCustomType(int type, ScriptEngine::MarshalFunction mf, ScriptEngine::DemarshalFunction df, const ScriptValuePointer& prototype);385 virtual void registerCustomType(int type, ScriptEngine::MarshalFunction marshalFunc,
386 ScriptEngine::DemarshalFunction demarshalFunc, const ScriptValuePointer& prototype);
386 387
387protected:388protected:
388 // like `newFunction`, but allows mapping inline C++ lambdas with captures as callable QScriptValues389 // like `newFunction`, but allows mapping inline C++ lambdas with captures as callable QScriptValues
@@ -403,6 +404,16 @@ protected: · 14 unmodified lines
403 */404 */
404 Q_INVOKABLE void executeOnScriptThread(std::function<void()> function, const Qt::ConnectionType& type = Qt::QueuedConnection );405 Q_INVOKABLE void executeOnScriptThread(std::function<void()> function, const Qt::ConnectionType& type = Qt::QueuedConnection );
405 406
407 // store for handling custom type marshaling/demarshaling
408 struct CustomTypeInfo {
409 ScriptEngine::MarshalFunction marshalFunc;
410 ScriptEngine::DemarshalFunction demarshalFunc;
411 ScriptValuePointer prototype;
412 };
413 typedef std::map<int, CustomTypeInfo> TCustomTypeMap;
414 TCustomTypeMap _customTypes;
415 std::mutex _customTypeProtect;
416
406 QPointer<ScriptManager> _manager;417 QPointer<ScriptManager> _manager;
407 418
408 ScriptValuePointer _nullValue;419 ScriptValuePointer _nullValue;

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