Showing the changes to libraries/script-engine/src/ScriptValueUtils.cpp (1 of 170 files). Show all
Unified · Split
| @@ -28,19 +28,19 @@ · 27 unmodified lines | ||
| 28 | 28 | #include "ScriptEngineCast.h" |
| 29 | 29 | #include "ScriptValueIterator.h" |
| 30 | 30 | |
| 31 | −bool isListOfStrings(const ScriptValuePointer& arg) { | |
| 32 | − if (!arg->isArray()) { | |
| 31 | +bool isListOfStrings(const ScriptValue& arg) { | |
| 32 | + if (!arg.isArray()) { | |
| 33 | 33 | return false; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | − auto lengthProperty = arg->property("length"); | |
| 37 | − if (!lengthProperty->isNumber()) { | |
| 36 | + auto lengthProperty = arg.property("length"); | |
| 37 | + if (!lengthProperty.isNumber()) { | |
| 38 | 38 | return false; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | − int length = lengthProperty->toInt32(); | |
| 41 | + int length = lengthProperty.toInt32(); | |
| 42 | 42 | for (int i = 0; i < length; i++) { |
| 43 | − if (!arg->property(i)->isString()) { | |
| 43 | + if (!arg.property(i).isString()) { | |
| 44 | 44 | return false; |
| 45 | 45 | } |
| 46 | 46 | } |
| @@ -80,9 +80,9 @@ void registerMetaTypes(ScriptEngine* engine) { · 33 unmodified lines | ||
| 80 | 80 | scriptRegisterSequenceMetaType<QVector<unsigned int>>(engine); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | −ScriptValuePointer vec2ToScriptValue(ScriptEngine* engine, const glm::vec2& vec2) { | |
| 84 | − auto prototype = engine->globalObject()->property("__hifi_vec2__"); | |
| 85 | − if (!prototype->property("defined")->toBool()) { | |
| 83 | +ScriptValue vec2ToScriptValue(ScriptEngine* engine, const glm::vec2& vec2) { | |
| 84 | + auto prototype = engine->globalObject().property("__hifi_vec2__"); | |
| 85 | + if (!prototype.property("defined").toBool()) { | |
| 86 | 86 | prototype = engine->evaluate( |
| 87 | 87 | "__hifi_vec2__ = Object.defineProperties({}, { " |
| 88 | 88 | "defined: { value: true }," |
| @@ -92,41 +92,41 @@ ScriptValuePointer vec2ToScriptValue(ScriptEngine* engine, const glm::vec2& vec2 · 3 unmodified lines | ||
| 92 | 92 | "v: { set: function(nv) { return this.y = nv; }, get: function() { return this.y; } }" |
| 93 | 93 | "})"); |
| 94 | 94 | } |
| 95 | − ScriptValuePointer value = engine->newObject(); | |
| 96 | − value->setProperty("x", vec2.x); | |
| 97 | − value->setProperty("y", vec2.y); | |
| 98 | − value->setPrototype(prototype); | |
| 95 | + ScriptValue value = engine->newObject(); | |
| 96 | + value.setProperty("x", vec2.x); | |
| 97 | + value.setProperty("y", vec2.y); | |
| 98 | + value.setPrototype(prototype); | |
| 99 | 99 | return value; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | −void vec2FromScriptValue(const ScriptValuePointer& object, glm::vec2& vec2) { | |
| 103 | − if (object->isNumber()) { | |
| 104 | − vec2 = glm::vec2(object->toVariant().toFloat()); | |
| 105 | − } else if (object->isArray()) { | |
| 106 | − QVariantList list = object->toVariant().toList(); | |
| 102 | +void vec2FromScriptValue(const ScriptValue& object, glm::vec2& vec2) { | |
| 103 | + if (object.isNumber()) { | |
| 104 | + vec2 = glm::vec2(object.toVariant().toFloat()); | |
| 105 | + } else if (object.isArray()) { | |
| 106 | + QVariantList list = object.toVariant().toList(); | |
| 107 | 107 | if (list.length() == 2) { |
| 108 | 108 | vec2.x = list[0].toFloat(); |
| 109 | 109 | vec2.y = list[1].toFloat(); |
| 110 | 110 | } |
| 111 | 111 | } else { |
| 112 | − ScriptValuePointer x = object->property("x"); | |
| 113 | − if (!x->isValid()) { | |
| 114 | − x = object->property("u"); | |
| 112 | + ScriptValue x = object.property("x"); | |
| 113 | + if (!x.isValid()) { | |
| 114 | + x = object.property("u"); | |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | − ScriptValuePointer y = object->property("y"); | |
| 118 | − if (!y->isValid()) { | |
| 119 | − y = object->property("v"); | |
| 117 | + ScriptValue y = object.property("y"); | |
| 118 | + if (!y.isValid()) { | |
| 119 | + y = object.property("v"); | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | − vec2.x = x->toVariant().toFloat(); | |
| 123 | − vec2.y = y->toVariant().toFloat(); | |
| 122 | + vec2.x = x.toVariant().toFloat(); | |
| 123 | + vec2.y = y.toVariant().toFloat(); | |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | −ScriptValuePointer vec3ToScriptValue(ScriptEngine* engine, const glm::vec3& vec3) { | |
| 128 | − auto prototype = engine->globalObject()->property("__hifi_vec3__"); | |
| 129 | − if (!prototype->property("defined")->toBool()) { | |
| 127 | +ScriptValue vec3ToScriptValue(ScriptEngine* engine, const glm::vec3& vec3) { | |
| 128 | + auto prototype = engine->globalObject().property("__hifi_vec3__"); | |
| 129 | + if (!prototype.property("defined").toBool()) { | |
| 130 | 130 | prototype = engine->evaluate( |
| 131 | 131 | "__hifi_vec3__ = Object.defineProperties({}, { " |
| 132 | 132 | "defined: { value: true }," |
| @@ -141,17 +141,17 @@ ScriptValuePointer vec3ToScriptValue(ScriptEngine* engine, const glm::vec3& vec3 · 8 unmodified lines | ||
| 141 | 141 | "blue: { set: function(nv) { return this.z = nv; }, get: function() { return this.z; } }" |
| 142 | 142 | "})"); |
| 143 | 143 | } |
| 144 | − ScriptValuePointer value = engine->newObject(); | |
| 145 | − value->setProperty("x", vec3.x); | |
| 146 | − value->setProperty("y", vec3.y); | |
| 147 | − value->setProperty("z", vec3.z); | |
| 148 | − value->setPrototype(prototype); | |
| 144 | + ScriptValue value = engine->newObject(); | |
| 145 | + value.setProperty("x", vec3.x); | |
| 146 | + value.setProperty("y", vec3.y); | |
| 147 | + value.setProperty("z", vec3.z); | |
| 148 | + value.setPrototype(prototype); | |
| 149 | 149 | return value; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | −ScriptValuePointer vec3ColorToScriptValue(ScriptEngine* engine, const glm::vec3& vec3) { | |
| 153 | − auto prototype = engine->globalObject()->property("__hifi_vec3_color__"); | |
| 154 | − if (!prototype->property("defined")->toBool()) { | |
| 152 | +ScriptValue vec3ColorToScriptValue(ScriptEngine* engine, const glm::vec3& vec3) { | |
| 153 | + auto prototype = engine->globalObject().property("__hifi_vec3_color__"); | |
| 154 | + if (!prototype.property("defined").toBool()) { | |
| 155 | 155 | prototype = engine->evaluate( |
| 156 | 156 | "__hifi_vec3_color__ = Object.defineProperties({}, { " |
| 157 | 157 | "defined: { value: true }," |
| @@ -166,65 +166,65 @@ ScriptValuePointer vec3ColorToScriptValue(ScriptEngine* engine, const glm::vec3& · 8 unmodified lines | ||
| 166 | 166 | "z: { set: function(nv) { return this.blue = nv; }, get: function() { return this.blue; } }" |
| 167 | 167 | "})"); |
| 168 | 168 | } |
| 169 | − ScriptValuePointer value = engine->newObject(); | |
| 170 | − value->setProperty("red", vec3.x); | |
| 171 | − value->setProperty("green", vec3.y); | |
| 172 | − value->setProperty("blue", vec3.z); | |
| 173 | − value->setPrototype(prototype); | |
| 169 | + ScriptValue value = engine->newObject(); | |
| 170 | + value.setProperty("red", vec3.x); | |
| 171 | + value.setProperty("green", vec3.y); | |
| 172 | + value.setProperty("blue", vec3.z); | |
| 173 | + value.setPrototype(prototype); | |
| 174 | 174 | return value; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | −void vec3FromScriptValue(const ScriptValuePointer& object, glm::vec3& vec3) { | |
| 178 | − if (object->isNumber()) { | |
| 179 | − vec3 = glm::vec3(object->toVariant().toFloat()); | |
| 180 | − } else if (object->isString()) { | |
| 181 | − QColor qColor(object->toString()); | |
| 177 | +void vec3FromScriptValue(const ScriptValue& object, glm::vec3& vec3) { | |
| 178 | + if (object.isNumber()) { | |
| 179 | + vec3 = glm::vec3(object.toVariant().toFloat()); | |
| 180 | + } else if (object.isString()) { | |
| 181 | + QColor qColor(object.toString()); | |
| 182 | 182 | if (qColor.isValid()) { |
| 183 | 183 | vec3.x = qColor.red(); |
| 184 | 184 | vec3.y = qColor.green(); |
| 185 | 185 | vec3.z = qColor.blue(); |
| 186 | 186 | } |
| 187 | − } else if (object->isArray()) { | |
| 188 | − QVariantList list = object->toVariant().toList(); | |
| 187 | + } else if (object.isArray()) { | |
| 188 | + QVariantList list = object.toVariant().toList(); | |
| 189 | 189 | if (list.length() == 3) { |
| 190 | 190 | vec3.x = list[0].toFloat(); |
| 191 | 191 | vec3.y = list[1].toFloat(); |
| 192 | 192 | vec3.z = list[2].toFloat(); |
| 193 | 193 | } |
| 194 | 194 | } else { |
| 195 | − ScriptValuePointer x = object->property("x"); | |
| 196 | − if (!x->isValid()) { | |
| 197 | − x = object->property("r"); | |
| 195 | + ScriptValue x = object.property("x"); | |
| 196 | + if (!x.isValid()) { | |
| 197 | + x = object.property("r"); | |
| 198 | 198 | } |
| 199 | − if (!x->isValid()) { | |
| 200 | − x = object->property("red"); | |
| 199 | + if (!x.isValid()) { | |
| 200 | + x = object.property("red"); | |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | − ScriptValuePointer y = object->property("y"); | |
| 204 | − if (!y->isValid()) { | |
| 205 | − y = object->property("g"); | |
| 203 | + ScriptValue y = object.property("y"); | |
| 204 | + if (!y.isValid()) { | |
| 205 | + y = object.property("g"); | |
| 206 | 206 | } |
| 207 | − if (!y->isValid()) { | |
| 208 | − y = object->property("green"); | |
| 207 | + if (!y.isValid()) { | |
| 208 | + y = object.property("green"); | |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | − ScriptValuePointer z = object->property("z"); | |
| 212 | − if (!z->isValid()) { | |
| 213 | − z = object->property("b"); | |
| 211 | + ScriptValue z = object.property("z"); | |
| 212 | + if (!z.isValid()) { | |
| 213 | + z = object.property("b"); | |
| 214 | 214 | } |
| 215 | − if (!z->isValid()) { | |
| 216 | − z = object->property("blue"); | |
| 215 | + if (!z.isValid()) { | |
| 216 | + z = object.property("blue"); | |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | − vec3.x = x->toVariant().toFloat(); | |
| 220 | − vec3.y = y->toVariant().toFloat(); | |
| 221 | − vec3.z = z->toVariant().toFloat(); | |
| 219 | + vec3.x = x.toVariant().toFloat(); | |
| 220 | + vec3.y = y.toVariant().toFloat(); | |
| 221 | + vec3.z = z.toVariant().toFloat(); | |
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | −ScriptValuePointer u8vec3ToScriptValue(ScriptEngine* engine, const glm::u8vec3& vec3) { | |
| 226 | − auto prototype = engine->globalObject()->property("__hifi_u8vec3__"); | |
| 227 | − if (!prototype->property("defined")->toBool()) { | |
| 225 | +ScriptValue u8vec3ToScriptValue(ScriptEngine* engine, const glm::u8vec3& vec3) { | |
| 226 | + auto prototype = engine->globalObject().property("__hifi_u8vec3__"); | |
| 227 | + if (!prototype.property("defined").toBool()) { | |
| 228 | 228 | prototype = engine->evaluate( |
| 229 | 229 | "__hifi_u8vec3__ = Object.defineProperties({}, { " |
| 230 | 230 | "defined: { value: true }," |
| @@ -239,17 +239,17 @@ ScriptValuePointer u8vec3ToScriptValue(ScriptEngine* engine, const glm::u8vec3& · 8 unmodified lines | ||
| 239 | 239 | "blue: { set: function(nv) { return this.z = nv; }, get: function() { return this.z; } }" |
| 240 | 240 | "})"); |
| 241 | 241 | } |
| 242 | − ScriptValuePointer value = engine->newObject(); | |
| 243 | − value->setProperty("x", vec3.x); | |
| 244 | − value->setProperty("y", vec3.y); | |
| 245 | − value->setProperty("z", vec3.z); | |
| 246 | − value->setPrototype(prototype); | |
| 242 | + ScriptValue value = engine->newObject(); | |
| 243 | + value.setProperty("x", vec3.x); | |
| 244 | + value.setProperty("y", vec3.y); | |
| 245 | + value.setProperty("z", vec3.z); | |
| 246 | + value.setPrototype(prototype); | |
| 247 | 247 | return value; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | −ScriptValuePointer u8vec3ColorToScriptValue(ScriptEngine* engine, const glm::u8vec3& vec3) { | |
| 251 | − auto prototype = engine->globalObject()->property("__hifi_u8vec3_color__"); | |
| 252 | − if (!prototype->property("defined")->toBool()) { | |
| 250 | +ScriptValue u8vec3ColorToScriptValue(ScriptEngine* engine, const glm::u8vec3& vec3) { | |
| 251 | + auto prototype = engine->globalObject().property("__hifi_u8vec3_color__"); | |
| 252 | + if (!prototype.property("defined").toBool()) { | |
| 253 | 253 | prototype = engine->evaluate( |
| 254 | 254 | "__hifi_u8vec3_color__ = Object.defineProperties({}, { " |
| 255 | 255 | "defined: { value: true }," |
| @@ -264,174 +264,174 @@ ScriptValuePointer u8vec3ColorToScriptValue(ScriptEngine* engine, const glm::u8v · 8 unmodified lines | ||
| 264 | 264 | "z: { set: function(nv) { return this.blue = nv; }, get: function() { return this.blue; } }" |
| 265 | 265 | "})"); |
| 266 | 266 | } |
| 267 | − ScriptValuePointer value = engine->newObject(); | |
| 268 | − value->setProperty("red", vec3.x); | |
| 269 | − value->setProperty("green", vec3.y); | |
| 270 | − value->setProperty("blue", vec3.z); | |
| 271 | − value->setPrototype(prototype); | |
| 267 | + ScriptValue value = engine->newObject(); | |
| 268 | + value.setProperty("red", vec3.x); | |
| 269 | + value.setProperty("green", vec3.y); | |
| 270 | + value.setProperty("blue", vec3.z); | |
| 271 | + value.setPrototype(prototype); | |
| 272 | 272 | return value; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | −void u8vec3FromScriptValue(const ScriptValuePointer& object, glm::u8vec3& vec3) { | |
| 276 | − if (object->isNumber()) { | |
| 277 | − vec3 = glm::vec3(object->toVariant().toUInt()); | |
| 278 | − } else if (object->isString()) { | |
| 279 | − QColor qColor(object->toString()); | |
| 275 | +void u8vec3FromScriptValue(const ScriptValue& object, glm::u8vec3& vec3) { | |
| 276 | + if (object.isNumber()) { | |
| 277 | + vec3 = glm::vec3(object.toVariant().toUInt()); | |
| 278 | + } else if (object.isString()) { | |
| 279 | + QColor qColor(object.toString()); | |
| 280 | 280 | if (qColor.isValid()) { |
| 281 | 281 | vec3.x = (uint8_t)qColor.red(); |
| 282 | 282 | vec3.y = (uint8_t)qColor.green(); |
| 283 | 283 | vec3.z = (uint8_t)qColor.blue(); |
| 284 | 284 | } |
| 285 | − } else if (object->isArray()) { | |
| 286 | − QVariantList list = object->toVariant().toList(); | |
| 285 | + } else if (object.isArray()) { | |
| 286 | + QVariantList list = object.toVariant().toList(); | |
| 287 | 287 | if (list.length() == 3) { |
| 288 | 288 | vec3.x = list[0].toUInt(); |
| 289 | 289 | vec3.y = list[1].toUInt(); |
| 290 | 290 | vec3.z = list[2].toUInt(); |
| 291 | 291 | } |
| 292 | 292 | } else { |
| 293 | − ScriptValuePointer x = object->property("x"); | |
| 294 | − if (!x->isValid()) { | |
| 295 | − x = object->property("r"); | |
| 293 | + ScriptValue x = object.property("x"); | |
| 294 | + if (!x.isValid()) { | |
| 295 | + x = object.property("r"); | |
| 296 | 296 | } |
| 297 | − if (!x->isValid()) { | |
| 298 | − x = object->property("red"); | |
| 297 | + if (!x.isValid()) { | |
| 298 | + x = object.property("red"); | |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | − ScriptValuePointer y = object->property("y"); | |
| 302 | − if (!y->isValid()) { | |
| 303 | − y = object->property("g"); | |
| 301 | + ScriptValue y = object.property("y"); | |
| 302 | + if (!y.isValid()) { | |
| 303 | + y = object.property("g"); | |
| 304 | 304 | } |
| 305 | − if (!y->isValid()) { | |
| 306 | − y = object->property("green"); | |
| 305 | + if (!y.isValid()) { | |
| 306 | + y = object.property("green"); | |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | − ScriptValuePointer z = object->property("z"); | |
| 310 | − if (!z->isValid()) { | |
| 311 | − z = object->property("b"); | |
| 309 | + ScriptValue z = object.property("z"); | |
| 310 | + if (!z.isValid()) { | |
| 311 | + z = object.property("b"); | |
| 312 | 312 | } |
| 313 | − if (!z->isValid()) { | |
| 314 | − z = object->property("blue"); | |
| 313 | + if (!z.isValid()) { | |
| 314 | + z = object.property("blue"); | |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | − vec3.x = x->toVariant().toUInt(); | |
| 318 | − vec3.y = y->toVariant().toUInt(); | |
| 319 | − vec3.z = z->toVariant().toUInt(); | |
| 317 | + vec3.x = x.toVariant().toUInt(); | |
| 318 | + vec3.y = y.toVariant().toUInt(); | |
| 319 | + vec3.z = z.toVariant().toUInt(); | |
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | −ScriptValuePointer vec4toScriptValue(ScriptEngine* engine, const glm::vec4& vec4) { | |
| 324 | − ScriptValuePointer obj = engine->newObject(); | |
| 325 | − obj->setProperty("x", vec4.x); | |
| 326 | − obj->setProperty("y", vec4.y); | |
| 327 | − obj->setProperty("z", vec4.z); | |
| 328 | − obj->setProperty("w", vec4.w); | |
| 323 | +ScriptValue vec4toScriptValue(ScriptEngine* engine, const glm::vec4& vec4) { | |
| 324 | + ScriptValue obj = engine->newObject(); | |
| 325 | + obj.setProperty("x", vec4.x); | |
| 326 | + obj.setProperty("y", vec4.y); | |
| 327 | + obj.setProperty("z", vec4.z); | |
| 328 | + obj.setProperty("w", vec4.w); | |
| 329 | 329 | return obj; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | −void vec4FromScriptValue(const ScriptValuePointer& object, glm::vec4& vec4) { | |
| 333 | − vec4.x = object->property("x")->toVariant().toFloat(); | |
| 334 | − vec4.y = object->property("y")->toVariant().toFloat(); | |
| 335 | − vec4.z = object->property("z")->toVariant().toFloat(); | |
| 336 | − vec4.w = object->property("w")->toVariant().toFloat(); | |
| 337 | −} | |
| 338 | − | |
| 339 | −ScriptValuePointer mat4toScriptValue(ScriptEngine* engine, const glm::mat4& mat4) { | |
| 340 | − ScriptValuePointer obj = engine->newObject(); | |
| 341 | − obj->setProperty("r0c0", mat4[0][0]); | |
| 342 | − obj->setProperty("r1c0", mat4[0][1]); | |
| 343 | − obj->setProperty("r2c0", mat4[0][2]); | |
| 344 | − obj->setProperty("r3c0", mat4[0][3]); | |
| 345 | − obj->setProperty("r0c1", mat4[1][0]); | |
| 346 | − obj->setProperty("r1c1", mat4[1][1]); | |
| 347 | − obj->setProperty("r2c1", mat4[1][2]); | |
| 348 | − obj->setProperty("r3c1", mat4[1][3]); | |
| 349 | − obj->setProperty("r0c2", mat4[2][0]); | |
| 350 | − obj->setProperty("r1c2", mat4[2][1]); | |
| 351 | − obj->setProperty("r2c2", mat4[2][2]); | |
| 352 | − obj->setProperty("r3c2", mat4[2][3]); | |
| 353 | − obj->setProperty("r0c3", mat4[3][0]); | |
| 354 | − obj->setProperty("r1c3", mat4[3][1]); | |
| 355 | − obj->setProperty("r2c3", mat4[3][2]); | |
| 356 | − obj->setProperty("r3c3", mat4[3][3]); | |
| 332 | +void vec4FromScriptValue(const ScriptValue& object, glm::vec4& vec4) { | |
| 333 | + vec4.x = object.property("x").toVariant().toFloat(); | |
| 334 | + vec4.y = object.property("y").toVariant().toFloat(); | |
| 335 | + vec4.z = object.property("z").toVariant().toFloat(); | |
| 336 | + vec4.w = object.property("w").toVariant().toFloat(); | |
| 337 | +} | |
| 338 | + | |
| 339 | +ScriptValue mat4toScriptValue(ScriptEngine* engine, const glm::mat4& mat4) { | |
| 340 | + ScriptValue obj = engine->newObject(); | |
| 341 | + obj.setProperty("r0c0", mat4[0][0]); | |
| 342 | + obj.setProperty("r1c0", mat4[0][1]); | |
| 343 | + obj.setProperty("r2c0", mat4[0][2]); | |
| 344 | + obj.setProperty("r3c0", mat4[0][3]); | |
| 345 | + obj.setProperty("r0c1", mat4[1][0]); | |
| 346 | + obj.setProperty("r1c1", mat4[1][1]); | |
| 347 | + obj.setProperty("r2c1", mat4[1][2]); | |
| 348 | + obj.setProperty("r3c1", mat4[1][3]); | |
| 349 | + obj.setProperty("r0c2", mat4[2][0]); | |
| 350 | + obj.setProperty("r1c2", mat4[2][1]); | |
| 351 | + obj.setProperty("r2c2", mat4[2][2]); | |
| 352 | + obj.setProperty("r3c2", mat4[2][3]); | |
| 353 | + obj.setProperty("r0c3", mat4[3][0]); | |
| 354 | + obj.setProperty("r1c3", mat4[3][1]); | |
| 355 | + obj.setProperty("r2c3", mat4[3][2]); | |
| 356 | + obj.setProperty("r3c3", mat4[3][3]); | |
| 357 | 357 | return obj; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | −void mat4FromScriptValue(const ScriptValuePointer& object, glm::mat4& mat4) { | |
| 361 | − mat4[0][0] = object->property("r0c0")->toVariant().toFloat(); | |
| 362 | − mat4[0][1] = object->property("r1c0")->toVariant().toFloat(); | |
| 363 | − mat4[0][2] = object->property("r2c0")->toVariant().toFloat(); | |
| 364 | − mat4[0][3] = object->property("r3c0")->toVariant().toFloat(); | |
| 365 | − mat4[1][0] = object->property("r0c1")->toVariant().toFloat(); | |
| 366 | − mat4[1][1] = object->property("r1c1")->toVariant().toFloat(); | |
| 367 | − mat4[1][2] = object->property("r2c1")->toVariant().toFloat(); | |
| 368 | − mat4[1][3] = object->property("r3c1")->toVariant().toFloat(); | |
| 369 | − mat4[2][0] = object->property("r0c2")->toVariant().toFloat(); | |
| 370 | − mat4[2][1] = object->property("r1c2")->toVariant().toFloat(); | |
| 371 | − mat4[2][2] = object->property("r2c2")->toVariant().toFloat(); | |
| 372 | − mat4[2][3] = object->property("r3c2")->toVariant().toFloat(); | |
| 373 | − mat4[3][0] = object->property("r0c3")->toVariant().toFloat(); | |
| 374 | − mat4[3][1] = object->property("r1c3")->toVariant().toFloat(); | |
| 375 | − mat4[3][2] = object->property("r2c3")->toVariant().toFloat(); | |
| 376 | − mat4[3][3] = object->property("r3c3")->toVariant().toFloat(); | |
| 377 | −} | |
| 378 | − | |
| 379 | −ScriptValuePointer qVectorVec3ColorToScriptValue(ScriptEngine* engine, const QVector<glm::vec3>& vector) { | |
| 380 | − ScriptValuePointer array = engine->newArray(); | |
| 360 | +void mat4FromScriptValue(const ScriptValue& object, glm::mat4& mat4) { | |
| 361 | + mat4[0][0] = object.property("r0c0").toVariant().toFloat(); | |
| 362 | + mat4[0][1] = object.property("r1c0").toVariant().toFloat(); | |
| 363 | + mat4[0][2] = object.property("r2c0").toVariant().toFloat(); | |
| 364 | + mat4[0][3] = object.property("r3c0").toVariant().toFloat(); | |
| 365 | + mat4[1][0] = object.property("r0c1").toVariant().toFloat(); | |
| 366 | + mat4[1][1] = object.property("r1c1").toVariant().toFloat(); | |
| 367 | + mat4[1][2] = object.property("r2c1").toVariant().toFloat(); | |
| 368 | + mat4[1][3] = object.property("r3c1").toVariant().toFloat(); | |
| 369 | + mat4[2][0] = object.property("r0c2").toVariant().toFloat(); | |
| 370 | + mat4[2][1] = object.property("r1c2").toVariant().toFloat(); | |
| 371 | + mat4[2][2] = object.property("r2c2").toVariant().toFloat(); | |
| 372 | + mat4[2][3] = object.property("r3c2").toVariant().toFloat(); | |
| 373 | + mat4[3][0] = object.property("r0c3").toVariant().toFloat(); | |
| 374 | + mat4[3][1] = object.property("r1c3").toVariant().toFloat(); | |
| 375 | + mat4[3][2] = object.property("r2c3").toVariant().toFloat(); | |
| 376 | + mat4[3][3] = object.property("r3c3").toVariant().toFloat(); | |
| 377 | +} | |
| 378 | + | |
| 379 | +ScriptValue qVectorVec3ColorToScriptValue(ScriptEngine* engine, const QVector<glm::vec3>& vector) { | |
| 380 | + ScriptValue array = engine->newArray(); | |
| 381 | 381 | for (int i = 0; i < vector.size(); i++) { |
| 382 | − array->setProperty(i, vec3ColorToScriptValue(engine, vector.at(i))); | |
| 382 | + array.setProperty(i, vec3ColorToScriptValue(engine, vector.at(i))); | |
| 383 | 383 | } |
| 384 | 384 | return array; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | −ScriptValuePointer qVectorVec3ToScriptValue(ScriptEngine* engine, const QVector<glm::vec3>& vector) { | |
| 388 | − ScriptValuePointer array = engine->newArray(); | |
| 387 | +ScriptValue qVectorVec3ToScriptValue(ScriptEngine* engine, const QVector<glm::vec3>& vector) { | |
| 388 | + ScriptValue array = engine->newArray(); | |
| 389 | 389 | for (int i = 0; i < vector.size(); i++) { |
| 390 | − array->setProperty(i, vec3ToScriptValue(engine, vector.at(i))); | |
| 390 | + array.setProperty(i, vec3ToScriptValue(engine, vector.at(i))); | |
| 391 | 391 | } |
| 392 | 392 | return array; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | −QVector<glm::vec3> qVectorVec3FromScriptValue(const ScriptValuePointer& array) { | |
| 395 | +QVector<glm::vec3> qVectorVec3FromScriptValue(const ScriptValue& array) { | |
| 396 | 396 | QVector<glm::vec3> newVector; |
| 397 | − int length = array->property("length")->toInteger(); | |
| 397 | + int length = array.property("length").toInteger(); | |
| 398 | 398 | |
| 399 | 399 | for (int i = 0; i < length; i++) { |
| 400 | 400 | glm::vec3 newVec3 = glm::vec3(); |
| 401 | − vec3FromScriptValue(array->property(i), newVec3); | |
| 401 | + vec3FromScriptValue(array.property(i), newVec3); | |
| 402 | 402 | newVector << newVec3; |
| 403 | 403 | } |
| 404 | 404 | return newVector; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | −void qVectorVec3FromScriptValue(const ScriptValuePointer& array, QVector<glm::vec3>& vector) { | |
| 408 | − int length = array->property("length")->toInteger(); | |
| 407 | +void qVectorVec3FromScriptValue(const ScriptValue& array, QVector<glm::vec3>& vector) { | |
| 408 | + int length = array.property("length").toInteger(); | |
| 409 | 409 | |
| 410 | 410 | for (int i = 0; i < length; i++) { |
| 411 | 411 | glm::vec3 newVec3 = glm::vec3(); |
| 412 | − vec3FromScriptValue(array->property(i), newVec3); | |
| 412 | + vec3FromScriptValue(array.property(i), newVec3); | |
| 413 | 413 | vector << newVec3; |
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | −ScriptValuePointer quatToScriptValue(ScriptEngine* engine, const glm::quat& quat) { | |
| 418 | − ScriptValuePointer obj = engine->newObject(); | |
| 417 | +ScriptValue quatToScriptValue(ScriptEngine* engine, const glm::quat& quat) { | |
| 418 | + ScriptValue obj = engine->newObject(); | |
| 419 | 419 | if (quat.x != quat.x || quat.y != quat.y || quat.z != quat.z || quat.w != quat.w) { |
| 420 | 420 | // if quat contains a NaN don't try to convert it |
| 421 | 421 | return obj; |
| 422 | 422 | } |
| 423 | − obj->setProperty("x", quat.x); | |
| 424 | − obj->setProperty("y", quat.y); | |
| 425 | − obj->setProperty("z", quat.z); | |
| 426 | − obj->setProperty("w", quat.w); | |
| 423 | + obj.setProperty("x", quat.x); | |
| 424 | + obj.setProperty("y", quat.y); | |
| 425 | + obj.setProperty("z", quat.z); | |
| 426 | + obj.setProperty("w", quat.w); | |
| 427 | 427 | return obj; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | −void quatFromScriptValue(const ScriptValuePointer& object, glm::quat& quat) { | |
| 431 | − quat.x = object->property("x")->toVariant().toFloat(); | |
| 432 | − quat.y = object->property("y")->toVariant().toFloat(); | |
| 433 | − quat.z = object->property("z")->toVariant().toFloat(); | |
| 434 | − quat.w = object->property("w")->toVariant().toFloat(); | |
| 430 | +void quatFromScriptValue(const ScriptValue& object, glm::quat& quat) { | |
| 431 | + quat.x = object.property("x").toVariant().toFloat(); | |
| 432 | + quat.y = object.property("y").toVariant().toFloat(); | |
| 433 | + quat.z = object.property("z").toVariant().toFloat(); | |
| 434 | + quat.w = object.property("w").toVariant().toFloat(); | |
| 435 | 435 | |
| 436 | 436 | // enforce normalized quaternion |
| 437 | 437 | float length = glm::length(quat); |
| @@ -442,181 +442,181 @@ void quatFromScriptValue(const ScriptValuePointer& object, glm::quat& quat) { · 4 unmodified lines | ||
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | −ScriptValuePointer qVectorQuatToScriptValue(ScriptEngine* engine, const QVector<glm::quat>& vector) { | |
| 446 | − ScriptValuePointer array = engine->newArray(); | |
| 445 | +ScriptValue qVectorQuatToScriptValue(ScriptEngine* engine, const QVector<glm::quat>& vector) { | |
| 446 | + ScriptValue array = engine->newArray(); | |
| 447 | 447 | for (int i = 0; i < vector.size(); i++) { |
| 448 | − array->setProperty(i, quatToScriptValue(engine, vector.at(i))); | |
| 448 | + array.setProperty(i, quatToScriptValue(engine, vector.at(i))); | |
| 449 | 449 | } |
| 450 | 450 | return array; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | −ScriptValuePointer qVectorBoolToScriptValue(ScriptEngine* engine, const QVector<bool>& vector) { | |
| 454 | − ScriptValuePointer array = engine->newArray(); | |
| 453 | +ScriptValue qVectorBoolToScriptValue(ScriptEngine* engine, const QVector<bool>& vector) { | |
| 454 | + ScriptValue array = engine->newArray(); | |
| 455 | 455 | for (int i = 0; i < vector.size(); i++) { |
| 456 | − array->setProperty(i, vector.at(i)); | |
| 456 | + array.setProperty(i, vector.at(i)); | |
| 457 | 457 | } |
| 458 | 458 | return array; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | −QVector<float> qVectorFloatFromScriptValue(const ScriptValuePointer& array) { | |
| 462 | − if (!array->isArray()) { | |
| 461 | +QVector<float> qVectorFloatFromScriptValue(const ScriptValue& array) { | |
| 462 | + if (!array.isArray()) { | |
| 463 | 463 | return QVector<float>(); |
| 464 | 464 | } |
| 465 | 465 | QVector<float> newVector; |
| 466 | − int length = array->property("length")->toInteger(); | |
| 466 | + int length = array.property("length").toInteger(); | |
| 467 | 467 | newVector.reserve(length); |
| 468 | 468 | for (int i = 0; i < length; i++) { |
| 469 | − if (array->property(i)->isNumber()) { | |
| 470 | − newVector << array->property(i)->toNumber(); | |
| 469 | + if (array.property(i).isNumber()) { | |
| 470 | + newVector << array.property(i).toNumber(); | |
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | return newVector; |
| 475 | 475 | } |
| 476 | 476 | |
| 477 | −ScriptValuePointer qVectorQUuidToScriptValue(ScriptEngine* engine, const QVector<QUuid>& vector) { | |
| 478 | − ScriptValuePointer array = engine->newArray(); | |
| 477 | +ScriptValue qVectorQUuidToScriptValue(ScriptEngine* engine, const QVector<QUuid>& vector) { | |
| 478 | + ScriptValue array = engine->newArray(); | |
| 479 | 479 | for (int i = 0; i < vector.size(); i++) { |
| 480 | − array->setProperty(i, quuidToScriptValue(engine, vector.at(i))); | |
| 480 | + array.setProperty(i, quuidToScriptValue(engine, vector.at(i))); | |
| 481 | 481 | } |
| 482 | 482 | return array; |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | −void qVectorQUuidFromScriptValue(const ScriptValuePointer& array, QVector<QUuid>& vector) { | |
| 486 | − int length = array->property("length")->toInteger(); | |
| 485 | +void qVectorQUuidFromScriptValue(const ScriptValue& array, QVector<QUuid>& vector) { | |
| 486 | + int length = array.property("length").toInteger(); | |
| 487 | 487 | |
| 488 | 488 | for (int i = 0; i < length; i++) { |
| 489 | − vector << array->property(i)->toVariant().toUuid(); | |
| 489 | + vector << array.property(i).toVariant().toUuid(); | |
| 490 | 490 | } |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | −QVector<QUuid> qVectorQUuidFromScriptValue(const ScriptValuePointer& array) { | |
| 494 | − if (!array->isArray()) { | |
| 493 | +QVector<QUuid> qVectorQUuidFromScriptValue(const ScriptValue& array) { | |
| 494 | + if (!array.isArray()) { | |
| 495 | 495 | return QVector<QUuid>(); |
| 496 | 496 | } |
| 497 | 497 | QVector<QUuid> newVector; |
| 498 | − int length = array->property("length")->toInteger(); | |
| 498 | + int length = array.property("length").toInteger(); | |
| 499 | 499 | newVector.reserve(length); |
| 500 | 500 | for (int i = 0; i < length; i++) { |
| 501 | − QString uuidAsString = array->property(i)->toString(); | |
| 501 | + QString uuidAsString = array.property(i).toString(); | |
| 502 | 502 | QUuid fromString(uuidAsString); |
| 503 | 503 | newVector << fromString; |
| 504 | 504 | } |
| 505 | 505 | return newVector; |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | −ScriptValuePointer qVectorFloatToScriptValue(ScriptEngine* engine, const QVector<float>& vector) { | |
| 509 | − ScriptValuePointer array = engine->newArray(); | |
| 508 | +ScriptValue qVectorFloatToScriptValue(ScriptEngine* engine, const QVector<float>& vector) { | |
| 509 | + ScriptValue array = engine->newArray(); | |
| 510 | 510 | for (int i = 0; i < vector.size(); i++) { |
| 511 | 511 | float num = vector.at(i); |
| 512 | − array->setProperty(i, engine->newValue(num)); | |
| 512 | + array.setProperty(i, engine->newValue(num)); | |
| 513 | 513 | } |
| 514 | 514 | return array; |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | −ScriptValuePointer qVectorIntToScriptValue(ScriptEngine* engine, const QVector<uint32_t>& vector) { | |
| 518 | − ScriptValuePointer array = engine->newArray(); | |
| 517 | +ScriptValue qVectorIntToScriptValue(ScriptEngine* engine, const QVector<uint32_t>& vector) { | |
| 518 | + ScriptValue array = engine->newArray(); | |
| 519 | 519 | for (int i = 0; i < vector.size(); i++) { |
| 520 | 520 | int num = vector.at(i); |
| 521 | − array->setProperty(i, engine->newValue(num)); | |
| 521 | + array.setProperty(i, engine->newValue(num)); | |
| 522 | 522 | } |
| 523 | 523 | return array; |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | −void qVectorFloatFromScriptValue(const ScriptValuePointer& array, QVector<float>& vector) { | |
| 527 | − int length = array->property("length")->toInteger(); | |
| 526 | +void qVectorFloatFromScriptValue(const ScriptValue& array, QVector<float>& vector) { | |
| 527 | + int length = array.property("length").toInteger(); | |
| 528 | 528 | |
| 529 | 529 | for (int i = 0; i < length; i++) { |
| 530 | − vector << array->property(i)->toVariant().toFloat(); | |
| 530 | + vector << array.property(i).toVariant().toFloat(); | |
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | −void qVectorIntFromScriptValue(const ScriptValuePointer& array, QVector<uint32_t>& vector) { | |
| 535 | − int length = array->property("length")->toInteger(); | |
| 534 | +void qVectorIntFromScriptValue(const ScriptValue& array, QVector<uint32_t>& vector) { | |
| 535 | + int length = array.property("length").toInteger(); | |
| 536 | 536 | |
| 537 | 537 | for (int i = 0; i < length; i++) { |
| 538 | − vector << array->property(i)->toVariant().toInt(); | |
| 538 | + vector << array.property(i).toVariant().toInt(); | |
| 539 | 539 | } |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | −QVector<glm::quat> qVectorQuatFromScriptValue(const ScriptValuePointer& array) { | |
| 542 | +QVector<glm::quat> qVectorQuatFromScriptValue(const ScriptValue& array) { | |
| 543 | 543 | QVector<glm::quat> newVector; |
| 544 | − int length = array->property("length")->toInteger(); | |
| 544 | + int length = array.property("length").toInteger(); | |
| 545 | 545 | |
| 546 | 546 | for (int i = 0; i < length; i++) { |
| 547 | 547 | glm::quat newQuat = glm::quat(); |
| 548 | − quatFromScriptValue(array->property(i), newQuat); | |
| 548 | + quatFromScriptValue(array.property(i), newQuat); | |
| 549 | 549 | newVector << newQuat; |
| 550 | 550 | } |
| 551 | 551 | return newVector; |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | −void qVectorQuatFromScriptValue(const ScriptValuePointer& array, QVector<glm::quat>& vector) { | |
| 555 | − int length = array->property("length")->toInteger(); | |
| 554 | +void qVectorQuatFromScriptValue(const ScriptValue& array, QVector<glm::quat>& vector) { | |
| 555 | + int length = array.property("length").toInteger(); | |
| 556 | 556 | |
| 557 | 557 | for (int i = 0; i < length; i++) { |
| 558 | 558 | glm::quat newQuat = glm::quat(); |
| 559 | − quatFromScriptValue(array->property(i), newQuat); | |
| 559 | + quatFromScriptValue(array.property(i), newQuat); | |
| 560 | 560 | vector << newQuat; |
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | −QVector<bool> qVectorBoolFromScriptValue(const ScriptValuePointer& array) { | |
| 564 | +QVector<bool> qVectorBoolFromScriptValue(const ScriptValue& array) { | |
| 565 | 565 | QVector<bool> newVector; |
| 566 | − int length = array->property("length")->toInteger(); | |
| 566 | + int length = array.property("length").toInteger(); | |
| 567 | 567 | |
| 568 | 568 | for (int i = 0; i < length; i++) { |
| 569 | − newVector << array->property(i)->toBool(); | |
| 569 | + newVector << array.property(i).toBool(); | |
| 570 | 570 | } |
| 571 | 571 | return newVector; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | −void qVectorBoolFromScriptValue(const ScriptValuePointer& array, QVector<bool>& vector) { | |
| 575 | − int length = array->property("length")->toInteger(); | |
| 574 | +void qVectorBoolFromScriptValue(const ScriptValue& array, QVector<bool>& vector) { | |
| 575 | + int length = array.property("length").toInteger(); | |
| 576 | 576 | |
| 577 | 577 | for (int i = 0; i < length; i++) { |
| 578 | − vector << array->property(i)->toBool(); | |
| 578 | + vector << array.property(i).toBool(); | |
| 579 | 579 | } |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | −ScriptValuePointer qRectToScriptValue(ScriptEngine* engine, const QRect& rect) { | |
| 583 | − ScriptValuePointer obj = engine->newObject(); | |
| 584 | − obj->setProperty("x", rect.x()); | |
| 585 | − obj->setProperty("y", rect.y()); | |
| 586 | − obj->setProperty("width", rect.width()); | |
| 587 | − obj->setProperty("height", rect.height()); | |
| 582 | +ScriptValue qRectToScriptValue(ScriptEngine* engine, const QRect& rect) { | |
| 583 | + ScriptValue obj = engine->newObject(); | |
| 584 | + obj.setProperty("x", rect.x()); | |
| 585 | + obj.setProperty("y", rect.y()); | |
| 586 | + obj.setProperty("width", rect.width()); | |
| 587 | + obj.setProperty("height", rect.height()); | |
| 588 | 588 | return obj; |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | −void qRectFromScriptValue(const ScriptValuePointer& object, QRect& rect) { | |
| 592 | − rect.setX(object->property("x")->toVariant().toInt()); | |
| 593 | − rect.setY(object->property("y")->toVariant().toInt()); | |
| 594 | − rect.setWidth(object->property("width")->toVariant().toInt()); | |
| 595 | − rect.setHeight(object->property("height")->toVariant().toInt()); | |
| 591 | +void qRectFromScriptValue(const ScriptValue& object, QRect& rect) { | |
| 592 | + rect.setX(object.property("x").toVariant().toInt()); | |
| 593 | + rect.setY(object.property("y").toVariant().toInt()); | |
| 594 | + rect.setWidth(object.property("width").toVariant().toInt()); | |
| 595 | + rect.setHeight(object.property("height").toVariant().toInt()); | |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | −ScriptValuePointer qRectFToScriptValue(ScriptEngine* engine, const QRectF& rect) { | |
| 599 | − ScriptValuePointer obj = engine->newObject(); | |
| 600 | − obj->setProperty("x", rect.x()); | |
| 601 | − obj->setProperty("y", rect.y()); | |
| 602 | − obj->setProperty("width", rect.width()); | |
| 603 | − obj->setProperty("height", rect.height()); | |
| 598 | +ScriptValue qRectFToScriptValue(ScriptEngine* engine, const QRectF& rect) { | |
| 599 | + ScriptValue obj = engine->newObject(); | |
| 600 | + obj.setProperty("x", rect.x()); | |
| 601 | + obj.setProperty("y", rect.y()); | |
| 602 | + obj.setProperty("width", rect.width()); | |
| 603 | + obj.setProperty("height", rect.height()); | |
| 604 | 604 | return obj; |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | −void qRectFFromScriptValue(const ScriptValuePointer& object, QRectF& rect) { | |
| 608 | − rect.setX(object->property("x")->toVariant().toFloat()); | |
| 609 | − rect.setY(object->property("y")->toVariant().toFloat()); | |
| 610 | − rect.setWidth(object->property("width")->toVariant().toFloat()); | |
| 611 | − rect.setHeight(object->property("height")->toVariant().toFloat()); | |
| 607 | +void qRectFFromScriptValue(const ScriptValue& object, QRectF& rect) { | |
| 608 | + rect.setX(object.property("x").toVariant().toFloat()); | |
| 609 | + rect.setY(object.property("y").toVariant().toFloat()); | |
| 610 | + rect.setWidth(object.property("width").toVariant().toFloat()); | |
| 611 | + rect.setHeight(object.property("height").toVariant().toFloat()); | |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | −ScriptValuePointer qColorToScriptValue(ScriptEngine* engine, const QColor& color) { | |
| 615 | − ScriptValuePointer object = engine->newObject(); | |
| 616 | − object->setProperty("red", color.red()); | |
| 617 | − object->setProperty("green", color.green()); | |
| 618 | − object->setProperty("blue", color.blue()); | |
| 619 | − object->setProperty("alpha", color.alpha()); | |
| 614 | +ScriptValue qColorToScriptValue(ScriptEngine* engine, const QColor& color) { | |
| 615 | + ScriptValue object = engine->newObject(); | |
| 616 | + object.setProperty("red", color.red()); | |
| 617 | + object.setProperty("green", color.green()); | |
| 618 | + object.setProperty("blue", color.blue()); | |
| 619 | + object.setProperty("alpha", color.alpha()); | |
| 620 | 620 | return object; |
| 621 | 621 | } |
| 622 | 622 | |
| @@ -629,78 +629,78 @@ ScriptValuePointer qColorToScriptValue(ScriptEngine* engine, const QColor& color · 6 unmodified lines | ||
| 629 | 629 | * @property {number} z - Z coordinate of the brn corner of the cube. |
| 630 | 630 | * @property {number} scale - The dimensions of each side of the cube. |
| 631 | 631 | */ |
| 632 | −ScriptValuePointer aaCubeToScriptValue(ScriptEngine* engine, const AACube& aaCube) { | |
| 633 | − ScriptValuePointer obj = engine->newObject(); | |
| 632 | +ScriptValue aaCubeToScriptValue(ScriptEngine* engine, const AACube& aaCube) { | |
| 633 | + ScriptValue obj = engine->newObject(); | |
| 634 | 634 | const glm::vec3& corner = aaCube.getCorner(); |
| 635 | − obj->setProperty("x", corner.x); | |
| 636 | − obj->setProperty("y", corner.y); | |
| 637 | − obj->setProperty("z", corner.z); | |
| 638 | − obj->setProperty("scale", aaCube.getScale()); | |
| 635 | + obj.setProperty("x", corner.x); | |
| 636 | + obj.setProperty("y", corner.y); | |
| 637 | + obj.setProperty("z", corner.z); | |
| 638 | + obj.setProperty("scale", aaCube.getScale()); | |
| 639 | 639 | return obj; |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | −void aaCubeFromScriptValue(const ScriptValuePointer& object, AACube& aaCube) { | |
| 642 | +void aaCubeFromScriptValue(const ScriptValue& object, AACube& aaCube) { | |
| 643 | 643 | glm::vec3 corner; |
| 644 | − corner.x = object->property("x")->toVariant().toFloat(); | |
| 645 | − corner.y = object->property("y")->toVariant().toFloat(); | |
| 646 | − corner.z = object->property("z")->toVariant().toFloat(); | |
| 647 | − float scale = object->property("scale")->toVariant().toFloat(); | |
| 644 | + corner.x = object.property("x").toVariant().toFloat(); | |
| 645 | + corner.y = object.property("y").toVariant().toFloat(); | |
| 646 | + corner.z = object.property("z").toVariant().toFloat(); | |
| 647 | + float scale = object.property("scale").toVariant().toFloat(); | |
| 648 | 648 | |
| 649 | 649 | aaCube.setBox(corner, scale); |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | −void qColorFromScriptValue(const ScriptValuePointer& object, QColor& color) { | |
| 653 | − if (object->isNumber()) { | |
| 654 | − color.setRgb(object->toUInt32()); | |
| 652 | +void qColorFromScriptValue(const ScriptValue& object, QColor& color) { | |
| 653 | + if (object.isNumber()) { | |
| 654 | + color.setRgb(object.toUInt32()); | |
| 655 | 655 | |
| 656 | − } else if (object->isString()) { | |
| 657 | − color.setNamedColor(object->toString()); | |
| 656 | + } else if (object.isString()) { | |
| 657 | + color.setNamedColor(object.toString()); | |
| 658 | 658 | |
| 659 | 659 | } else { |
| 660 | − ScriptValuePointer alphaValue = object->property("alpha"); | |
| 661 | − color.setRgb(object->property("red")->toInt32(), object->property("green")->toInt32(), object->property("blue")->toInt32(), | |
| 662 | − alphaValue->isNumber() ? alphaValue->toInt32() : 255); | |
| 660 | + ScriptValue alphaValue = object.property("alpha"); | |
| 661 | + color.setRgb(object.property("red").toInt32(), object.property("green").toInt32(), object.property("blue").toInt32(), | |
| 662 | + alphaValue.isNumber() ? alphaValue.toInt32() : 255); | |
| 663 | 663 | } |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | −ScriptValuePointer qURLToScriptValue(ScriptEngine* engine, const QUrl& url) { | |
| 666 | +ScriptValue qURLToScriptValue(ScriptEngine* engine, const QUrl& url) { | |
| 667 | 667 | return engine->newValue(url.toString()); |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | −void qURLFromScriptValue(const ScriptValuePointer& object, QUrl& url) { | |
| 671 | − url = object->toString(); | |
| 670 | +void qURLFromScriptValue(const ScriptValue& object, QUrl& url) { | |
| 671 | + url = object.toString(); | |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | −ScriptValuePointer pickRayToScriptValue(ScriptEngine* engine, const PickRay& pickRay) { | |
| 675 | − ScriptValuePointer obj = engine->newObject(); | |
| 676 | − ScriptValuePointer origin = vec3ToScriptValue(engine, pickRay.origin); | |
| 677 | − obj->setProperty("origin", origin); | |
| 678 | − ScriptValuePointer direction = vec3ToScriptValue(engine, pickRay.direction); | |
| 679 | − obj->setProperty("direction", direction); | |
| 674 | +ScriptValue pickRayToScriptValue(ScriptEngine* engine, const PickRay& pickRay) { | |
| 675 | + ScriptValue obj = engine->newObject(); | |
| 676 | + ScriptValue origin = vec3ToScriptValue(engine, pickRay.origin); | |
| 677 | + obj.setProperty("origin", origin); | |
| 678 | + ScriptValue direction = vec3ToScriptValue(engine, pickRay.direction); | |
| 679 | + obj.setProperty("direction", direction); | |
| 680 | 680 | return obj; |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | −void pickRayFromScriptValue(const ScriptValuePointer& object, PickRay& pickRay) { | |
| 684 | − ScriptValuePointer originValue = object->property("origin"); | |
| 685 | − if (originValue->isValid()) { | |
| 686 | − auto x = originValue->property("x"); | |
| 687 | − auto y = originValue->property("y"); | |
| 688 | − auto z = originValue->property("z"); | |
| 689 | − if (x->isValid() && y->isValid() && z->isValid()) { | |
| 690 | − pickRay.origin.x = x->toVariant().toFloat(); | |
| 691 | − pickRay.origin.y = y->toVariant().toFloat(); | |
| 692 | − pickRay.origin.z = z->toVariant().toFloat(); | |
| 683 | +void pickRayFromScriptValue(const ScriptValue& object, PickRay& pickRay) { | |
| 684 | + ScriptValue originValue = object.property("origin"); | |
| 685 | + if (originValue.isValid()) { | |
| 686 | + auto x = originValue.property("x"); | |
| 687 | + auto y = originValue.property("y"); | |
| 688 | + auto z = originValue.property("z"); | |
| 689 | + if (x.isValid() && y.isValid() && z.isValid()) { | |
| 690 | + pickRay.origin.x = x.toVariant().toFloat(); | |
| 691 | + pickRay.origin.y = y.toVariant().toFloat(); | |
| 692 | + pickRay.origin.z = z.toVariant().toFloat(); | |
| 693 | 693 | } |
| 694 | 694 | } |
| 695 | − ScriptValuePointer directionValue = object->property("direction"); | |
| 696 | − if (directionValue->isValid()) { | |
| 697 | − auto x = directionValue->property("x"); | |
| 698 | − auto y = directionValue->property("y"); | |
| 699 | − auto z = directionValue->property("z"); | |
| 700 | − if (x->isValid() && y->isValid() && z->isValid()) { | |
| 701 | − pickRay.direction.x = x->toVariant().toFloat(); | |
| 702 | − pickRay.direction.y = y->toVariant().toFloat(); | |
| 703 | − pickRay.direction.z = z->toVariant().toFloat(); | |
| 695 | + ScriptValue directionValue = object.property("direction"); | |
| 696 | + if (directionValue.isValid()) { | |
| 697 | + auto x = directionValue.property("x"); | |
| 698 | + auto y = directionValue.property("y"); | |
| 699 | + auto z = directionValue.property("z"); | |
| 700 | + if (x.isValid() && y.isValid() && z.isValid()) { | |
| 701 | + pickRay.direction.x = x.toVariant().toFloat(); | |
| 702 | + pickRay.direction.y = y.toVariant().toFloat(); | |
| 703 | + pickRay.direction.z = z.toVariant().toFloat(); | |
| 704 | 704 | } |
| 705 | 705 | } |
| 706 | 706 | } |
| @@ -715,35 +715,35 @@ void pickRayFromScriptValue(const ScriptValuePointer& object, PickRay& pickRay) · 8 unmodified lines | ||
| 715 | 715 | * @property {Vec3} contactPoint - The point of contact. |
| 716 | 716 | * @property {Vec3} velocityChange - The change in relative velocity of the two items, in m/s. |
| 717 | 717 | */ |
| 718 | −ScriptValuePointer collisionToScriptValue(ScriptEngine* engine, const Collision& collision) { | |
| 719 | − ScriptValuePointer obj = engine->newObject(); | |
| 720 | − obj->setProperty("type", collision.type); | |
| 721 | − obj->setProperty("idA", quuidToScriptValue(engine, collision.idA)); | |
| 722 | − obj->setProperty("idB", quuidToScriptValue(engine, collision.idB)); | |
| 723 | − obj->setProperty("penetration", vec3ToScriptValue(engine, collision.penetration)); | |
| 724 | − obj->setProperty("contactPoint", vec3ToScriptValue(engine, collision.contactPoint)); | |
| 725 | − obj->setProperty("velocityChange", vec3ToScriptValue(engine, collision.velocityChange)); | |
| 718 | +ScriptValue collisionToScriptValue(ScriptEngine* engine, const Collision& collision) { | |
| 719 | + ScriptValue obj = engine->newObject(); | |
| 720 | + obj.setProperty("type", collision.type); | |
| 721 | + obj.setProperty("idA", quuidToScriptValue(engine, collision.idA)); | |
| 722 | + obj.setProperty("idB", quuidToScriptValue(engine, collision.idB)); | |
| 723 | + obj.setProperty("penetration", vec3ToScriptValue(engine, collision.penetration)); | |
| 724 | + obj.setProperty("contactPoint", vec3ToScriptValue(engine, collision.contactPoint)); | |
| 725 | + obj.setProperty("velocityChange", vec3ToScriptValue(engine, collision.velocityChange)); | |
| 726 | 726 | return obj; |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | −void collisionFromScriptValue(const ScriptValuePointer& object, Collision& collision) { | |
| 729 | +void collisionFromScriptValue(const ScriptValue& object, Collision& collision) { | |
| 730 | 730 | // TODO: implement this when we know what it means to accept collision events from JS |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | −ScriptValuePointer quuidToScriptValue(ScriptEngine* engine, const QUuid& uuid) { | |
| 733 | +ScriptValue quuidToScriptValue(ScriptEngine* engine, const QUuid& uuid) { | |
| 734 | 734 | if (uuid.isNull()) { |
| 735 | 735 | return engine->nullValue(); |
| 736 | 736 | } |
| 737 | − ScriptValuePointer obj(engine->newValue(uuid.toString())); | |
| 737 | + ScriptValue obj(engine->newValue(uuid.toString())); | |
| 738 | 738 | return obj; |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | −void quuidFromScriptValue(const ScriptValuePointer& object, QUuid& uuid) { | |
| 741 | +void quuidFromScriptValue(const ScriptValue& object, QUuid& uuid) { | |
| 742 | 742 | if (object.isNull()) { |
| 743 | 743 | uuid = QUuid(); |
| 744 | 744 | return; |
| 745 | 745 | } |
| 746 | − QString uuidAsString = object->toVariant().toString(); | |
| 746 | + QString uuidAsString = object.toVariant().toString(); | |
| 747 | 747 | QUuid fromString(uuidAsString); |
| 748 | 748 | uuid = fromString; |
| 749 | 749 | } |
| @@ -754,16 +754,16 @@ void quuidFromScriptValue(const ScriptValuePointer& object, QUuid& uuid) { · 4 unmodified lines | ||
| 754 | 754 | * @property {number} height - The height value. |
| 755 | 755 | * @property {number} width - The width value. |
| 756 | 756 | */ |
| 757 | −ScriptValuePointer qSizeFToScriptValue(ScriptEngine* engine, const QSizeF& qSizeF) { | |
| 758 | − ScriptValuePointer obj = engine->newObject(); | |
| 759 | − obj->setProperty("width", qSizeF.width()); | |
| 760 | − obj->setProperty("height", qSizeF.height()); | |
| 757 | +ScriptValue qSizeFToScriptValue(ScriptEngine* engine, const QSizeF& qSizeF) { | |
| 758 | + ScriptValue obj = engine->newObject(); | |
| 759 | + obj.setProperty("width", qSizeF.width()); | |
| 760 | + obj.setProperty("height", qSizeF.height()); | |
| 761 | 761 | return obj; |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | −void qSizeFFromScriptValue(const ScriptValuePointer& object, QSizeF& qSizeF) { | |
| 765 | − qSizeF.setWidth(object->property("width")->toVariant().toFloat()); | |
| 766 | − qSizeF.setHeight(object->property("height")->toVariant().toFloat()); | |
| 764 | +void qSizeFFromScriptValue(const ScriptValue& object, QSizeF& qSizeF) { | |
| 765 | + qSizeF.setWidth(object.property("width").toVariant().toFloat()); | |
| 766 | + qSizeF.setHeight(object.property("height").toVariant().toFloat()); | |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | /**jsdoc |
| @@ -785,47 +785,47 @@ void qSizeFFromScriptValue(const ScriptValuePointer& object, QSizeF& qSizeF) { · 15 unmodified lines | ||
| 785 | 785 | * @property {boolean} startAutomatically - <em>Not used.</em> |
| 786 | 786 | * @property {boolean} allowTranslation - <em>Not used.</em> |
| 787 | 787 | */ |
| 788 | −ScriptValuePointer animationDetailsToScriptValue(ScriptEngine* engine, const AnimationDetails& details) { | |
| 789 | − ScriptValuePointer obj = engine->newObject(); | |
| 790 | − obj->setProperty("role", details.role); | |
| 791 | − obj->setProperty("url", details.url.toString()); | |
| 792 | − obj->setProperty("fps", details.fps); | |
| 793 | − obj->setProperty("priority", details.priority); | |
| 794 | − obj->setProperty("loop", details.loop); | |
| 795 | − obj->setProperty("hold", details.hold); | |
| 796 | − obj->setProperty("startAutomatically", details.startAutomatically); | |
| 797 | − obj->setProperty("firstFrame", details.firstFrame); | |
| 798 | − obj->setProperty("lastFrame", details.lastFrame); | |
| 799 | − obj->setProperty("running", details.running); | |
| 800 | − obj->setProperty("currentFrame", details.currentFrame); | |
| 801 | − obj->setProperty("allowTranslation", details.allowTranslation); | |
| 788 | +ScriptValue animationDetailsToScriptValue(ScriptEngine* engine, const AnimationDetails& details) { | |
| 789 | + ScriptValue obj = engine->newObject(); | |
| 790 | + obj.setProperty("role", details.role); | |
| 791 | + obj.setProperty("url", details.url.toString()); | |
| 792 | + obj.setProperty("fps", details.fps); | |
| 793 | + obj.setProperty("priority", details.priority); | |
| 794 | + obj.setProperty("loop", details.loop); | |
| 795 | + obj.setProperty("hold", details.hold); | |
| 796 | + obj.setProperty("startAutomatically", details.startAutomatically); | |
| 797 | + obj.setProperty("firstFrame", details.firstFrame); | |
| 798 | + obj.setProperty("lastFrame", details.lastFrame); | |
| 799 | + obj.setProperty("running", details.running); | |
| 800 | + obj.setProperty("currentFrame", details.currentFrame); | |
| 801 | + obj.setProperty("allowTranslation", details.allowTranslation); | |
| 802 | 802 | return obj; |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | −void animationDetailsFromScriptValue(const ScriptValuePointer& object, AnimationDetails& details) { | |
| 805 | +void animationDetailsFromScriptValue(const ScriptValue& object, AnimationDetails& details) { | |
| 806 | 806 | // nothing for now... |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | −ScriptValuePointer meshToScriptValue(ScriptEngine* engine, MeshProxy* const& in) { | |
| 809 | +ScriptValue meshToScriptValue(ScriptEngine* engine, MeshProxy* const& in) { | |
| 810 | 810 | return engine->newQObject(in, ScriptEngine::QtOwnership); |
| 811 | 811 | } |
| 812 | 812 | |
| 813 | −void meshFromScriptValue(const ScriptValuePointer& value, MeshProxy*& out) { | |
| 814 | − out = qobject_cast<MeshProxy*>(value->toQObject()); | |
| 813 | +void meshFromScriptValue(const ScriptValue& value, MeshProxy*& out) { | |
| 814 | + out = qobject_cast<MeshProxy*>(value.toQObject()); | |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | −ScriptValuePointer meshesToScriptValue(ScriptEngine* engine, const MeshProxyList& in) { | |
| 817 | +ScriptValue meshesToScriptValue(ScriptEngine* engine, const MeshProxyList& in) { | |
| 818 | 818 | // ScriptValueList result; |
| 819 | − ScriptValuePointer result = engine->newArray(); | |
| 819 | + ScriptValue result = engine->newArray(); | |
| 820 | 820 | int i = 0; |
| 821 | − foreach (MeshProxy* const meshProxy, in) { result->setProperty(i++, meshToScriptValue(engine, meshProxy)); } | |
| 821 | + foreach (MeshProxy* const meshProxy, in) { result.setProperty(i++, meshToScriptValue(engine, meshProxy)); } | |
| 822 | 822 | return result; |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | −void meshesFromScriptValue(const ScriptValuePointer& value, MeshProxyList& out) { | |
| 826 | − ScriptValueIteratorPointer itr(value->newIterator()); | |
| 825 | +void meshesFromScriptValue(const ScriptValue& value, MeshProxyList& out) { | |
| 826 | + ScriptValueIteratorPointer itr(value.newIterator()); | |
| 827 | 827 | |
| 828 | − qDebug() << "in meshesFromScriptValue, value.length =" << value->property("length")->toInt32(); | |
| 828 | + qDebug() << "in meshesFromScriptValue, value.length =" << value.property("length").toInt32(); | |
| 829 | 829 | |
| 830 | 830 | while (itr->hasNext()) { |
| 831 | 831 | itr->next(); |
| @@ -843,67 +843,67 @@ void meshesFromScriptValue(const ScriptValuePointer& value, MeshProxyList& out) · 11 unmodified lines | ||
| 843 | 843 | * @typedef {object} MeshFace |
| 844 | 844 | * @property {number[]} vertices - The indexes of the three vertices that make up the face. |
| 845 | 845 | */ |
| 846 | −ScriptValuePointer meshFaceToScriptValue(ScriptEngine* engine, const MeshFace& meshFace) { | |
| 847 | − ScriptValuePointer obj = engine->newObject(); | |
| 848 | − obj->setProperty("vertices", qVectorIntToScriptValue(engine, meshFace.vertexIndices)); | |
| 846 | +ScriptValue meshFaceToScriptValue(ScriptEngine* engine, const MeshFace& meshFace) { | |
| 847 | + ScriptValue obj = engine->newObject(); | |
| 848 | + obj.setProperty("vertices", qVectorIntToScriptValue(engine, meshFace.vertexIndices)); | |
| 849 | 849 | return obj; |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | −void meshFaceFromScriptValue(const ScriptValuePointer& object, MeshFace& meshFaceResult) { | |
| 853 | − qVectorIntFromScriptValue(object->property("vertices"), meshFaceResult.vertexIndices); | |
| 852 | +void meshFaceFromScriptValue(const ScriptValue& object, MeshFace& meshFaceResult) { | |
| 853 | + qVectorIntFromScriptValue(object.property("vertices"), meshFaceResult.vertexIndices); | |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | −ScriptValuePointer qVectorMeshFaceToScriptValue(ScriptEngine* engine, const QVector<MeshFace>& vector) { | |
| 857 | − ScriptValuePointer array = engine->newArray(); | |
| 856 | +ScriptValue qVectorMeshFaceToScriptValue(ScriptEngine* engine, const QVector<MeshFace>& vector) { | |
| 857 | + ScriptValue array = engine->newArray(); | |
| 858 | 858 | for (int i = 0; i < vector.size(); i++) { |
| 859 | − array->setProperty(i, meshFaceToScriptValue(engine, vector.at(i))); | |
| 859 | + array.setProperty(i, meshFaceToScriptValue(engine, vector.at(i))); | |
| 860 | 860 | } |
| 861 | 861 | return array; |
| 862 | 862 | } |
| 863 | 863 | |
| 864 | −void qVectorMeshFaceFromScriptValue(const ScriptValuePointer& array, QVector<MeshFace>& result) { | |
| 865 | − int length = array->property("length")->toInteger(); | |
| 864 | +void qVectorMeshFaceFromScriptValue(const ScriptValue& array, QVector<MeshFace>& result) { | |
| 865 | + int length = array.property("length").toInteger(); | |
| 866 | 866 | result.clear(); |
| 867 | 867 | |
| 868 | 868 | for (int i = 0; i < length; i++) { |
| 869 | 869 | MeshFace meshFace = MeshFace(); |
| 870 | − meshFaceFromScriptValue(array->property(i), meshFace); | |
| 870 | + meshFaceFromScriptValue(array.property(i), meshFace); | |
| 871 | 871 | result << meshFace; |
| 872 | 872 | } |
| 873 | 873 | } |
| 874 | 874 | |
| 875 | −ScriptValuePointer stencilMaskModeToScriptValue(ScriptEngine* engine, const StencilMaskMode& stencilMode) { | |
| 875 | +ScriptValue stencilMaskModeToScriptValue(ScriptEngine* engine, const StencilMaskMode& stencilMode) { | |
| 876 | 876 | return engine->newValue((int)stencilMode); |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | −void stencilMaskModeFromScriptValue(const ScriptValuePointer& object, StencilMaskMode& stencilMode) { | |
| 880 | − stencilMode = StencilMaskMode(object->toVariant().toInt()); | |
| 879 | +void stencilMaskModeFromScriptValue(const ScriptValue& object, StencilMaskMode& stencilMode) { | |
| 880 | + stencilMode = StencilMaskMode(object.toVariant().toInt()); | |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | −void promiseFromScriptValue(const ScriptValuePointer& object, std::shared_ptr<MiniPromise>& promise) { | |
| 883 | +void promiseFromScriptValue(const ScriptValue& object, std::shared_ptr<MiniPromise>& promise) { | |
| 884 | 884 | Q_ASSERT(false); |
| 885 | 885 | } |
| 886 | −ScriptValuePointer promiseToScriptValue(ScriptEngine* engine, const std::shared_ptr<MiniPromise>& promise) { | |
| 886 | +ScriptValue promiseToScriptValue(ScriptEngine* engine, const std::shared_ptr<MiniPromise>& promise) { | |
| 887 | 887 | return engine->newQObject(promise.get()); |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | −ScriptValuePointer EntityItemIDtoScriptValue(ScriptEngine* engine, const EntityItemID& id) { | |
| 890 | +ScriptValue EntityItemIDtoScriptValue(ScriptEngine* engine, const EntityItemID& id) { | |
| 891 | 891 | return quuidToScriptValue(engine, id); |
| 892 | 892 | } |
| 893 | 893 | |
| 894 | −void EntityItemIDfromScriptValue(const ScriptValuePointer &object, EntityItemID& id) { | |
| 894 | +void EntityItemIDfromScriptValue(const ScriptValue &object, EntityItemID& id) { | |
| 895 | 895 | quuidFromScriptValue(object, id); |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | −QVector<EntityItemID> qVectorEntityItemIDFromScriptValue(const ScriptValuePointer& array) { | |
| 899 | − if (!array->isArray()) { | |
| 898 | +QVector<EntityItemID> qVectorEntityItemIDFromScriptValue(const ScriptValue& array) { | |
| 899 | + if (!array.isArray()) { | |
| 900 | 900 | return QVector<EntityItemID>(); |
| 901 | 901 | } |
| 902 | 902 | QVector<EntityItemID> newVector; |
| 903 | − int length = array->property("length")->toInteger(); | |
| 903 | + int length = array.property("length").toInteger(); | |
| 904 | 904 | newVector.reserve(length); |
| 905 | 905 | for (int i = 0; i < length; i++) { |
| 906 | − QString uuidAsString = array->property(i)->toString(); | |
| 906 | + QString uuidAsString = array.property(i).toString(); | |
| 907 | 907 | EntityItemID fromString(uuidAsString); |
| 908 | 908 | newVector << fromString; |
| 909 | 909 | } |