Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 3 files). Show all
Unified · Split
| @@ -108,6 +108,8 @@ int functionSignatureMetaID = qRegisterMetaType<QScriptEngine::FunctionSignature · 107 unmodified lines | |||
| 108 | 108 | ||
| 109 | int scriptEnginePointerMetaID = qRegisterMetaType<ScriptEnginePointer>(); | 109 | int scriptEnginePointerMetaID = qRegisterMetaType<ScriptEnginePointer>(); |
| 110 | 110 | ||
| 111 | Q_DECLARE_METATYPE(ExternalResource::Bucket); | ||
| 112 | |||
| 111 | static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) { | 113 | static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) { |
| 112 | QString message = ""; | 114 | QString message = ""; |
| 113 | for (int i = 0; i < context->argumentCount(); i++) { | 115 | for (int i = 0; i < context->argumentCount(); i++) { |
| @@ -663,6 +665,17 @@ void avatarDataFromScriptValue(const QScriptValue& object, ScriptAvatarData*& ou · 549 unmodified lines | |||
| 663 | out = nullptr; | 665 | out = nullptr; |
| 664 | } | 666 | } |
| 665 | 667 | ||
| 668 | QScriptValue externalResourceBucketToScriptValue(QScriptEngine* engine, ExternalResource::Bucket const& in) { | ||
| 669 | //return engine->newQObject(in, QScriptEngine::ScriptOwnership, DEFAULT_QOBJECT_WRAP_OPTIONS); | ||
| 670 | return QScriptValue((int)in); | ||
| 671 | } | ||
| 672 | |||
| 673 | void externalResourceBucketFromScriptValue(const QScriptValue& object, ExternalResource::Bucket& out) { | ||
| 674 | // This is not implemented because there are no slots/properties that take an AvatarSharedPointer from a script | ||
| 675 | assert(false); | ||
| 676 | out = ExternalResource::Bucket::Assets; | ||
| 677 | } | ||
| 678 | |||
| 666 | void ScriptEngine::resetModuleCache(bool deleteScriptCache) { | 679 | void ScriptEngine::resetModuleCache(bool deleteScriptCache) { |
| 667 | if (QThread::currentThread() != thread()) { | 680 | if (QThread::currentThread() != thread()) { |
| 668 | executeOnScriptThread([=]() { resetModuleCache(deleteScriptCache); }); | 681 | executeOnScriptThread([=]() { resetModuleCache(deleteScriptCache); }); |
| @@ -769,6 +782,8 @@ void ScriptEngine::init() { · 100 unmodified lines | |||
| 769 | require.setProperty("resolve", resolve, READONLY_PROP_FLAGS); | 782 | require.setProperty("resolve", resolve, READONLY_PROP_FLAGS); |
| 770 | resetModuleCache(); | 783 | resetModuleCache(); |
| 771 | } | 784 | } |
| 785 | |||
| 786 | qScriptRegisterMetaType(this, externalResourceBucketToScriptValue, externalResourceBucketFromScriptValue); | ||
| 772 | registerEnum("Script.ExternalPaths", QMetaEnum::fromType<ExternalResource::Bucket>()); | 787 | registerEnum("Script.ExternalPaths", QMetaEnum::fromType<ExternalResource::Bucket>()); |
| 773 | 788 | ||
| 774 | registerGlobalObject("Audio", DependencyManager::get<AudioScriptingInterface>().data()); | 789 | registerGlobalObject("Audio", DependencyManager::get<AudioScriptingInterface>().data()); |
| @@ -2871,6 +2886,6 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 2096 unmodified lines | |||
| 2871 | } | 2886 | } |
| 2872 | } | 2887 | } |
| 2873 | 2888 | ||
| 2874 | QString ScriptEngine::getExternalPath(ExternalResource::Bucket bucket, const QString &relative_path) { | 2889 | QString ScriptEngine::getExternalPath(ExternalResource::Bucket bucket, const QString& relativePath) { |
| 2875 | return ExternalResource::getInstance()->getUrl(bucket, relative_path); | 2890 | return ExternalResource::getInstance()->getUrl(bucket, relativePath); |
| 2876 | } | 2891 | } |