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/ScriptManager.cpp (1 of 63 files). Show all

Unified · Split

libraries/script-engine/src/ScriptManager.cpp+9−2
@@ -538,8 +538,9 @@ static ScriptValue scriptableResourceToScriptValue(ScriptEngine* engine, · 537 unmodified lines
538 return object;538 return object;
539}539}
540 540
541static void scriptableResourceFromScriptValue(const ScriptValue& value, ScriptableResourceRawPtr& resource) {541static bool scriptableResourceFromScriptValue(const ScriptValue& value, ScriptableResourceRawPtr& resource) {
542 resource = static_cast<ScriptableResourceRawPtr>(value.toQObject());542 resource = static_cast<ScriptableResourceRawPtr>(value.toQObject());
543 return true;
543}544}
544 545
545/*@jsdoc546/*@jsdoc
@@ -578,8 +579,9 @@ ScriptValue externalResourceBucketToScriptValue(ScriptEngine* engine, ExternalRe · 32 unmodified lines
578 return engine->newValue((int)in);579 return engine->newValue((int)in);
579}580}
580 581
581void externalResourceBucketFromScriptValue(const ScriptValue& object, ExternalResource::Bucket& out) {582bool externalResourceBucketFromScriptValue(const ScriptValue& object, ExternalResource::Bucket& out) {
582 out = static_cast<ExternalResource::Bucket>(object.toInt32());583 out = static_cast<ExternalResource::Bucket>(object.toInt32());
584 return true;
583}585}
584 586
585void ScriptManager::resetModuleCache(bool deleteScriptCache) {587void ScriptManager::resetModuleCache(bool deleteScriptCache) {
@@ -722,6 +724,11 @@ void ScriptManager::init() { · 136 unmodified lines
722 }));724 }));
723}725}
724 726
727// registers a global object by name
728void ScriptManager::registerValue(const QString& valueName, ScriptValue value) {
729 _engine->globalObject().setProperty(valueName, value);
730}
731
725// Unregister the handlers for this eventName and entityID.732// Unregister the handlers for this eventName and entityID.
726void ScriptManager::removeEventHandler(const EntityItemID& entityID, const QString& eventName, const ScriptValue& handler) {733void ScriptManager::removeEventHandler(const EntityItemID& entityID, const QString& eventName, const ScriptValue& handler) {
727 if (QThread::currentThread() != thread()) {734 if (QThread::currentThread() != thread()) {