Showing the changes to libraries/script-engine/src/ScriptValueUtils.cpp (1 of 7 files). Show all
Unified · Split
| @@ -22,6 +22,7 @@ · 21 unmodified lines | |||
| 22 | #include <AACube.h> | 22 | #include <AACube.h> |
| 23 | #include <shared/MiniPromises.h> | 23 | #include <shared/MiniPromises.h> |
| 24 | #include <RegisteredMetaTypes.h> | 24 | #include <RegisteredMetaTypes.h> |
| 25 | #include <EntityItemID.h> | ||
| 25 | 26 | ||
| 26 | #include "ScriptEngine.h" | 27 | #include "ScriptEngine.h" |
| 27 | #include "ScriptEngineCast.h" | 28 | #include "ScriptEngineCast.h" |
| @@ -885,3 +886,26 @@ void promiseFromScriptValue(const ScriptValuePointer& object, std::shared_ptr<Mi · 857 unmodified lines | |||
| 885 | ScriptValuePointer promiseToScriptValue(ScriptEngine* engine, const std::shared_ptr<MiniPromise>& promise) { | 886 | ScriptValuePointer promiseToScriptValue(ScriptEngine* engine, const std::shared_ptr<MiniPromise>& promise) { |
| 886 | return engine->newQObject(promise.get()); | 887 | return engine->newQObject(promise.get()); |
| 887 | } | 888 | } |
| 889 | |||
| 890 | ScriptValuePointer EntityItemIDtoScriptValue(ScriptEngine* engine, const EntityItemID& id) { | ||
| 891 | return quuidToScriptValue(engine, id); | ||
| 892 | } | ||
| 893 | |||
| 894 | void EntityItemIDfromScriptValue(const ScriptValuePointer &object, EntityItemID& id) { | ||
| 895 | quuidFromScriptValue(object, id); | ||
| 896 | } | ||
| 897 | |||
| 898 | QVector<EntityItemID> qVectorEntityItemIDFromScriptValue(const ScriptValuePointer& array) { | ||
| 899 | if (!array->isArray()) { | ||
| 900 | return QVector<EntityItemID>(); | ||
| 901 | } | ||
| 902 | QVector<EntityItemID> newVector; | ||
| 903 | int length = array->property("length")->toInteger(); | ||
| 904 | newVector.reserve(length); | ||
| 905 | for (int i = 0; i < length; i++) { | ||
| 906 | QString uuidAsString = array->property(i)->toString(); | ||
| 907 | EntityItemID fromString(uuidAsString); | ||
| 908 | newVector << fromString; | ||
| 909 | } | ||
| 910 | return newVector; | ||
| 911 | } | ||