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
538538 return object;
539539 }
540540
541−static void scriptableResourceFromScriptValue(const ScriptValue& value, ScriptableResourceRawPtr& resource) {
541+static bool scriptableResourceFromScriptValue(const ScriptValue& value, ScriptableResourceRawPtr& resource) {
542542 resource = static_cast<ScriptableResourceRawPtr>(value.toQObject());
543+ return true;
543544 }
544545
545546 /*@jsdoc
@@ -578,8 +579,9 @@ ScriptValue externalResourceBucketToScriptValue(ScriptEngine* engine, ExternalRe · 32 unmodified lines
578579 return engine->newValue((int)in);
579580 }
580581
581−void externalResourceBucketFromScriptValue(const ScriptValue& object, ExternalResource::Bucket& out) {
582+bool externalResourceBucketFromScriptValue(const ScriptValue& object, ExternalResource::Bucket& out) {
582583 out = static_cast<ExternalResource::Bucket>(object.toInt32());
584+ return true;
583585 }
584586
585587 void ScriptManager::resetModuleCache(bool deleteScriptCache) {
@@ -722,6 +724,11 @@ void ScriptManager::init() { · 136 unmodified lines
722724 }));
723725 }
724726
727+// registers a global object by name
728+void ScriptManager::registerValue(const QString& valueName, ScriptValue value) {
729+ _engine->globalObject().setProperty(valueName, value);
730+}
731+
725732 // Unregister the handlers for this eventName and entityID.
726733 void ScriptManager::removeEventHandler(const EntityItemID& entityID, const QString& eventName, const ScriptValue& handler) {
727734 if (QThread::currentThread() != thread()) {