Showing the changes to libraries/script-engine/src/v8/ScriptValueV8Wrapper.cpp (1 of 8 files). Show all
Unified · Split
| @@ -61,7 +61,8 @@ V8ScriptValue ScriptValueV8Wrapper::fullUnwrap(ScriptEngineV8* engine, const Scr · 60 unmodified lines | |||
| 61 | 61 | ||
| 62 | ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const ScriptValueList& args) { | 62 | ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const ScriptValueList& args) { |
| 63 | auto isolate = _engine->getIsolate(); | 63 | auto isolate = _engine->getIsolate(); |
| 64 | Q_ASSERT(isolate->IsCurrent()); | 64 | v8::Locker locker(isolate); |
| 65 | v8::Isolate::Scope isolateScope(isolate); | ||
| 65 | v8::HandleScope handleScope(isolate); | 66 | v8::HandleScope handleScope(isolate); |
| 66 | v8::Context::Scope contextScope(_engine->getContext()); | 67 | v8::Context::Scope contextScope(_engine->getContext()); |
| 67 | V8ScriptValue v8This = fullUnwrap(thisObject); | 68 | V8ScriptValue v8This = fullUnwrap(thisObject); |
| @@ -89,7 +90,8 @@ ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const Scri · 21 unmodified lines | |||
| 89 | 90 | ||
| 90 | ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const ScriptValue& arguments) { | 91 | ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const ScriptValue& arguments) { |
| 91 | auto isolate = _engine->getIsolate(); | 92 | auto isolate = _engine->getIsolate(); |
| 92 | Q_ASSERT(isolate->IsCurrent()); | 93 | v8::Locker locker(isolate); |
| 94 | v8::Isolate::Scope isolateScope(isolate); | ||
| 93 | v8::HandleScope handleScope(isolate); | 95 | v8::HandleScope handleScope(isolate); |
| 94 | v8::Context::Scope contextScope(_engine->getContext()); | 96 | v8::Context::Scope contextScope(_engine->getContext()); |
| 95 | V8ScriptValue v8This = fullUnwrap(thisObject); | 97 | V8ScriptValue v8This = fullUnwrap(thisObject); |
| @@ -113,7 +115,8 @@ ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const Scri · 17 unmodified lines | |||
| 113 | 115 | ||
| 114 | ScriptValue ScriptValueV8Wrapper::construct(const ScriptValueList& args) { | 116 | ScriptValue ScriptValueV8Wrapper::construct(const ScriptValueList& args) { |
| 115 | auto isolate = _engine->getIsolate(); | 117 | auto isolate = _engine->getIsolate(); |
| 116 | Q_ASSERT(isolate->IsCurrent()); | 118 | v8::Locker locker(isolate); |
| 119 | v8::Isolate::Scope isolateScope(isolate); | ||
| 117 | v8::HandleScope handleScope(isolate); | 120 | v8::HandleScope handleScope(isolate); |
| 118 | v8::Context::Scope contextScope(_engine->getContext()); | 121 | v8::Context::Scope contextScope(_engine->getContext()); |
| 119 | Q_ASSERT(args.length() <= Q_METAMETHOD_INVOKE_MAX_ARGS); | 122 | Q_ASSERT(args.length() <= Q_METAMETHOD_INVOKE_MAX_ARGS); |
| @@ -139,7 +142,8 @@ ScriptValue ScriptValueV8Wrapper::construct(const ScriptValueList& args) { · 19 unmodified lines | |||
| 139 | 142 | ||
| 140 | ScriptValue ScriptValueV8Wrapper::construct(const ScriptValue& arguments) { | 143 | ScriptValue ScriptValueV8Wrapper::construct(const ScriptValue& arguments) { |
| 141 | auto isolate = _engine->getIsolate(); | 144 | auto isolate = _engine->getIsolate(); |
| 142 | Q_ASSERT(isolate->IsCurrent()); | 145 | v8::Locker locker(isolate); |
| 146 | v8::Isolate::Scope isolateScope(isolate); | ||
| 143 | v8::HandleScope handleScope(isolate); | 147 | v8::HandleScope handleScope(isolate); |
| 144 | v8::Context::Scope contextScope(_engine->getContext()); | 148 | v8::Context::Scope contextScope(_engine->getContext()); |
| 145 | // V8TODO I'm not sure in what format arguments are yet, backtrace will show how it is used | 149 | // V8TODO I'm not sure in what format arguments are yet, backtrace will show how it is used |
| @@ -170,7 +174,8 @@ ScriptValueIteratorPointer ScriptValueV8Wrapper::newIterator() const { · 24 unmodified lines | |||
| 170 | 174 | ||
| 171 | ScriptValue ScriptValueV8Wrapper::property(const QString& name, const ScriptValue::ResolveFlags &mode) const { | 175 | ScriptValue ScriptValueV8Wrapper::property(const QString& name, const ScriptValue::ResolveFlags &mode) const { |
| 172 | auto isolate = _engine->getIsolate(); | 176 | auto isolate = _engine->getIsolate(); |
| 173 | Q_ASSERT(isolate->IsCurrent()); | 177 | v8::Locker locker(_engine->getIsolate()); |
| 178 | v8::Isolate::Scope isolateScope(_engine->getIsolate()); | ||
| 174 | v8::HandleScope handleScope(isolate); | 179 | v8::HandleScope handleScope(isolate); |
| 175 | v8::Context::Scope contextScope(_engine->getContext()); | 180 | v8::Context::Scope contextScope(_engine->getContext()); |
| 176 | if (_value.constGet()->IsObject()) { | 181 | if (_value.constGet()->IsObject()) { |
| @@ -181,6 +186,13 @@ ScriptValue ScriptValueV8Wrapper::property(const QString& name, const ScriptValu · 4 unmodified lines | |||
| 181 | if (object->Get(_value.constGetContext(), key).ToLocal(&resultLocal)) { | 186 | if (object->Get(_value.constGetContext(), key).ToLocal(&resultLocal)) { |
| 182 | V8ScriptValue result(_engine->getIsolate(), resultLocal); | 187 | V8ScriptValue result(_engine->getIsolate(), resultLocal); |
| 183 | return ScriptValue(new ScriptValueV8Wrapper(_engine, std::move(result))); | 188 | return ScriptValue(new ScriptValueV8Wrapper(_engine, std::move(result))); |
| 189 | } else { | ||
| 190 | QString parentValueQString(""); | ||
| 191 | v8::Local<v8::String> parentValueString; | ||
| 192 | if (_value.constGet()->ToDetailString(_engine->getContext()).ToLocal(&parentValueString)) { | ||
| 193 | QString(*v8::String::Utf8Value(isolate, parentValueString)); | ||
| 194 | } | ||
| 195 | qDebug() << "Failed to get property, parent of value: " << name << ", parent type: " << QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate))) << " parent value: " << parentValueQString; | ||
| 184 | } | 196 | } |
| 185 | } | 197 | } |
| 186 | qDebug() << "Failed to get property, parent of value: " << name << " is not a V8 object, reported type: " << QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate))); | 198 | qDebug() << "Failed to get property, parent of value: " << name << " is not a V8 object, reported type: " << QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate))); |
| @@ -194,7 +206,8 @@ ScriptValue ScriptValueV8Wrapper::property(const QString& name, const ScriptValu · 7 unmodified lines | |||
| 194 | 206 | ||
| 195 | ScriptValue ScriptValueV8Wrapper::property(quint32 arrayIndex, const ScriptValue::ResolveFlags& mode) const { | 207 | ScriptValue ScriptValueV8Wrapper::property(quint32 arrayIndex, const ScriptValue::ResolveFlags& mode) const { |
| 196 | auto isolate = _engine->getIsolate(); | 208 | auto isolate = _engine->getIsolate(); |
| 197 | Q_ASSERT(isolate->IsCurrent()); | 209 | v8::Locker locker(isolate); |
| 210 | v8::Isolate::Scope isolateScope(isolate); | ||
| 198 | v8::HandleScope handleScope(isolate); | 211 | v8::HandleScope handleScope(isolate); |
| 199 | v8::Context::Scope contextScope(_engine->getContext()); | 212 | v8::Context::Scope contextScope(_engine->getContext()); |
| 200 | if (_value.constGet()->IsObject()) { | 213 | if (_value.constGet()->IsObject()) { |
| @@ -215,7 +228,8 @@ ScriptValue ScriptValueV8Wrapper::property(quint32 arrayIndex, const ScriptValue · 14 unmodified lines | |||
| 215 | 228 | ||
| 216 | void ScriptValueV8Wrapper::setData(const ScriptValue& value) { | 229 | void ScriptValueV8Wrapper::setData(const ScriptValue& value) { |
| 217 | auto isolate = _engine->getIsolate(); | 230 | auto isolate = _engine->getIsolate(); |
| 218 | Q_ASSERT(isolate->IsCurrent()); | 231 | v8::Locker locker(isolate); |
| 232 | v8::Isolate::Scope isolateScope(isolate); | ||
| 219 | v8::HandleScope handleScope(isolate); | 233 | v8::HandleScope handleScope(isolate); |
| 220 | v8::Context::Scope contextScope(_engine->getContext()); | 234 | v8::Context::Scope contextScope(_engine->getContext()); |
| 221 | V8ScriptValue unwrapped = fullUnwrap(value); | 235 | V8ScriptValue unwrapped = fullUnwrap(value); |
| @@ -225,7 +239,8 @@ void ScriptValueV8Wrapper::setData(const ScriptValue& value) { · 3 unmodified lines | |||
| 225 | void ScriptValueV8Wrapper::setProperty(const QString& name, const ScriptValue& value, const ScriptValue::PropertyFlags& flags) { | 239 | void ScriptValueV8Wrapper::setProperty(const QString& name, const ScriptValue& value, const ScriptValue::PropertyFlags& flags) { |
| 226 | Q_ASSERT(flags != ScriptValue::PropertyGetter || flags != ScriptValue::PropertySetter); | 240 | Q_ASSERT(flags != ScriptValue::PropertyGetter || flags != ScriptValue::PropertySetter); |
| 227 | auto isolate = _engine->getIsolate(); | 241 | auto isolate = _engine->getIsolate(); |
| 228 | Q_ASSERT(isolate->IsCurrent()); | 242 | v8::Locker locker(_engine->getIsolate()); |
| 243 | v8::Isolate::Scope isolateScope(_engine->getIsolate()); | ||
| 229 | v8::HandleScope handleScope(isolate); | 244 | v8::HandleScope handleScope(isolate); |
| 230 | v8::Context::Scope contextScope(_engine->getContext()); | 245 | v8::Context::Scope contextScope(_engine->getContext()); |
| 231 | V8ScriptValue unwrapped = fullUnwrap(value); | 246 | V8ScriptValue unwrapped = fullUnwrap(value); |
| @@ -256,7 +271,8 @@ void ScriptValueV8Wrapper::setProperty(const QString& name, const ScriptValue& v · 24 unmodified lines | |||
| 256 | 271 | ||
| 257 | void ScriptValueV8Wrapper::setProperty(quint32 arrayIndex, const ScriptValue& value, const ScriptValue::PropertyFlags& flags) { | 272 | void ScriptValueV8Wrapper::setProperty(quint32 arrayIndex, const ScriptValue& value, const ScriptValue::PropertyFlags& flags) { |
| 258 | auto isolate = _engine->getIsolate(); | 273 | auto isolate = _engine->getIsolate(); |
| 259 | Q_ASSERT(isolate->IsCurrent()); | 274 | v8::Locker locker(isolate); |
| 275 | v8::Isolate::Scope isolateScope(isolate); | ||
| 260 | v8::HandleScope handleScope(isolate); | 276 | v8::HandleScope handleScope(isolate); |
| 261 | v8::Context::Scope contextScope(_engine->getContext()); | 277 | v8::Context::Scope contextScope(_engine->getContext()); |
| 262 | V8ScriptValue unwrapped = fullUnwrap(value); | 278 | V8ScriptValue unwrapped = fullUnwrap(value); |
| @@ -275,7 +291,8 @@ void ScriptValueV8Wrapper::setProperty(quint32 arrayIndex, const ScriptValue& va · 12 unmodified lines | |||
| 275 | 291 | ||
| 276 | void ScriptValueV8Wrapper::setPrototype(const ScriptValue& prototype) { | 292 | void ScriptValueV8Wrapper::setPrototype(const ScriptValue& prototype) { |
| 277 | auto isolate = _engine->getIsolate(); | 293 | auto isolate = _engine->getIsolate(); |
| 278 | Q_ASSERT(isolate->IsCurrent()); | 294 | v8::Locker locker(isolate); |
| 295 | v8::Isolate::Scope isolateScope(isolate); | ||
| 279 | v8::HandleScope handleScope(isolate); | 296 | v8::HandleScope handleScope(isolate); |
| 280 | v8::Context::Scope contextScope(_engine->getContext()); | 297 | v8::Context::Scope contextScope(_engine->getContext()); |
| 281 | ScriptValueV8Wrapper* unwrappedPrototype = unwrap(prototype); | 298 | ScriptValueV8Wrapper* unwrappedPrototype = unwrap(prototype); |
| @@ -294,7 +311,8 @@ void ScriptValueV8Wrapper::setPrototype(const ScriptValue& prototype) { · 12 unmodified lines | |||
| 294 | 311 | ||
| 295 | bool ScriptValueV8Wrapper::strictlyEquals(const ScriptValue& other) const { | 312 | bool ScriptValueV8Wrapper::strictlyEquals(const ScriptValue& other) const { |
| 296 | auto isolate = _engine->getIsolate(); | 313 | auto isolate = _engine->getIsolate(); |
| 297 | Q_ASSERT(isolate->IsCurrent()); | 314 | v8::Locker locker(isolate); |
| 315 | v8::Isolate::Scope isolateScope(isolate); | ||
| 298 | v8::HandleScope handleScope(isolate); | 316 | v8::HandleScope handleScope(isolate); |
| 299 | v8::Context::Scope contextScope(_engine->getContext()); | 317 | v8::Context::Scope contextScope(_engine->getContext()); |
| 300 | ScriptValueV8Wrapper* unwrappedOther = unwrap(other); | 318 | ScriptValueV8Wrapper* unwrappedOther = unwrap(other); |
| @@ -303,7 +321,8 @@ bool ScriptValueV8Wrapper::strictlyEquals(const ScriptValue& other) const { · 2 unmodified lines | |||
| 303 | 321 | ||
| 304 | bool ScriptValueV8Wrapper::toBool() const { | 322 | bool ScriptValueV8Wrapper::toBool() const { |
| 305 | auto isolate = _engine->getIsolate(); | 323 | auto isolate = _engine->getIsolate(); |
| 306 | Q_ASSERT(isolate->IsCurrent()); | 324 | v8::Locker locker(isolate); |
| 325 | v8::Isolate::Scope isolateScope(isolate); | ||
| 307 | v8::HandleScope handleScope(isolate); | 326 | v8::HandleScope handleScope(isolate); |
| 308 | v8::Context::Scope contextScope(_engine->getContext()); | 327 | v8::Context::Scope contextScope(_engine->getContext()); |
| 309 | return _value.constGet()->ToBoolean(_engine->getIsolate())->Value(); | 328 | return _value.constGet()->ToBoolean(_engine->getIsolate())->Value(); |
| @@ -311,7 +330,8 @@ bool ScriptValueV8Wrapper::toBool() const { · 1 unmodified line | |||
| 311 | 330 | ||
| 312 | qint32 ScriptValueV8Wrapper::toInt32() const { | 331 | qint32 ScriptValueV8Wrapper::toInt32() const { |
| 313 | auto isolate = _engine->getIsolate(); | 332 | auto isolate = _engine->getIsolate(); |
| 314 | Q_ASSERT(isolate->IsCurrent()); | 333 | v8::Locker locker(isolate); |
| 334 | v8::Isolate::Scope isolateScope(isolate); | ||
| 315 | v8::HandleScope handleScope(isolate); | 335 | v8::HandleScope handleScope(isolate); |
| 316 | v8::Context::Scope contextScope(_engine->getContext()); | 336 | v8::Context::Scope contextScope(_engine->getContext()); |
| 317 | v8::Local<v8::Integer> integer; | 337 | v8::Local<v8::Integer> integer; |
| @@ -323,7 +343,8 @@ qint32 ScriptValueV8Wrapper::toInt32() const { · 5 unmodified lines | |||
| 323 | 343 | ||
| 324 | double ScriptValueV8Wrapper::toInteger() const { | 344 | double ScriptValueV8Wrapper::toInteger() const { |
| 325 | auto isolate = _engine->getIsolate(); | 345 | auto isolate = _engine->getIsolate(); |
| 326 | Q_ASSERT(isolate->IsCurrent()); | 346 | v8::Locker locker(isolate); |
| 347 | v8::Isolate::Scope isolateScope(isolate); | ||
| 327 | v8::HandleScope handleScope(isolate); | 348 | v8::HandleScope handleScope(isolate); |
| 328 | v8::Context::Scope contextScope(_engine->getContext()); | 349 | v8::Context::Scope contextScope(_engine->getContext()); |
| 329 | v8::Local<v8::Integer> integer; | 350 | v8::Local<v8::Integer> integer; |
| @@ -335,7 +356,8 @@ double ScriptValueV8Wrapper::toInteger() const { · 5 unmodified lines | |||
| 335 | 356 | ||
| 336 | double ScriptValueV8Wrapper::toNumber() const { | 357 | double ScriptValueV8Wrapper::toNumber() const { |
| 337 | auto isolate = _engine->getIsolate(); | 358 | auto isolate = _engine->getIsolate(); |
| 338 | Q_ASSERT(isolate->IsCurrent()); | 359 | v8::Locker locker(isolate); |
| 360 | v8::Isolate::Scope isolateScope(isolate); | ||
| 339 | v8::HandleScope handleScope(isolate); | 361 | v8::HandleScope handleScope(isolate); |
| 340 | v8::Context::Scope contextScope(_engine->getContext()); | 362 | v8::Context::Scope contextScope(_engine->getContext()); |
| 341 | v8::Local<v8::Number> number; | 363 | v8::Local<v8::Number> number; |
| @@ -347,7 +369,8 @@ double ScriptValueV8Wrapper::toNumber() const { · 5 unmodified lines | |||
| 347 | 369 | ||
| 348 | QString ScriptValueV8Wrapper::toString() const { | 370 | QString ScriptValueV8Wrapper::toString() const { |
| 349 | auto isolate = _engine->getIsolate(); | 371 | auto isolate = _engine->getIsolate(); |
| 350 | Q_ASSERT(isolate->IsCurrent()); | 372 | v8::Locker locker(isolate); |
| 373 | v8::Isolate::Scope isolateScope(isolate); | ||
| 351 | v8::HandleScope handleScope(isolate); | 374 | v8::HandleScope handleScope(isolate); |
| 352 | v8::Context::Scope contextScope(_engine->getContext()); | 375 | v8::Context::Scope contextScope(_engine->getContext()); |
| 353 | v8::String::Utf8Value string(_engine->getIsolate(), _value.constGet()); | 376 | v8::String::Utf8Value string(_engine->getIsolate(), _value.constGet()); |
| @@ -357,7 +380,8 @@ QString ScriptValueV8Wrapper::toString() const { · 3 unmodified lines | |||
| 357 | 380 | ||
| 358 | quint16 ScriptValueV8Wrapper::toUInt16() const { | 381 | quint16 ScriptValueV8Wrapper::toUInt16() const { |
| 359 | auto isolate = _engine->getIsolate(); | 382 | auto isolate = _engine->getIsolate(); |
| 360 | Q_ASSERT(isolate->IsCurrent()); | 383 | v8::Locker locker(isolate); |
| 384 | v8::Isolate::Scope isolateScope(isolate); | ||
| 361 | v8::HandleScope handleScope(isolate); | 385 | v8::HandleScope handleScope(isolate); |
| 362 | v8::Context::Scope contextScope(_engine->getContext()); | 386 | v8::Context::Scope contextScope(_engine->getContext()); |
| 363 | v8::Local<v8::Uint32> integer; | 387 | v8::Local<v8::Uint32> integer; |
| @@ -369,7 +393,8 @@ quint16 ScriptValueV8Wrapper::toUInt16() const { · 5 unmodified lines | |||
| 369 | 393 | ||
| 370 | quint32 ScriptValueV8Wrapper::toUInt32() const { | 394 | quint32 ScriptValueV8Wrapper::toUInt32() const { |
| 371 | auto isolate = _engine->getIsolate(); | 395 | auto isolate = _engine->getIsolate(); |
| 372 | Q_ASSERT(isolate->IsCurrent()); | 396 | v8::Locker locker(isolate); |
| 397 | v8::Isolate::Scope isolateScope(isolate); | ||
| 373 | v8::HandleScope handleScope(isolate); | 398 | v8::HandleScope handleScope(isolate); |
| 374 | v8::Context::Scope contextScope(_engine->getContext()); | 399 | v8::Context::Scope contextScope(_engine->getContext()); |
| 375 | v8::Local<v8::Uint32> integer; | 400 | v8::Local<v8::Uint32> integer; |
| @@ -401,7 +426,8 @@ QObject* ScriptValueV8Wrapper::toQObject() const { · 25 unmodified lines | |||
| 401 | 426 | ||
| 402 | bool ScriptValueV8Wrapper::equals(const ScriptValue& other) const { | 427 | bool ScriptValueV8Wrapper::equals(const ScriptValue& other) const { |
| 403 | auto isolate = _engine->getIsolate(); | 428 | auto isolate = _engine->getIsolate(); |
| 404 | Q_ASSERT(isolate->IsCurrent()); | 429 | v8::Locker locker(isolate); |
| 430 | v8::Isolate::Scope isolateScope(isolate); | ||
| 405 | v8::HandleScope handleScope(isolate); | 431 | v8::HandleScope handleScope(isolate); |
| 406 | v8::Context::Scope contextScope(_engine->getContext()); | 432 | v8::Context::Scope contextScope(_engine->getContext()); |
| 407 | ScriptValueV8Wrapper* unwrappedOther = unwrap(other); | 433 | ScriptValueV8Wrapper* unwrappedOther = unwrap(other); |
| @@ -420,7 +446,8 @@ bool ScriptValueV8Wrapper::equals(const ScriptValue& other) const { · 12 unmodified lines | |||
| 420 | 446 | ||
| 421 | bool ScriptValueV8Wrapper::isArray() const { | 447 | bool ScriptValueV8Wrapper::isArray() const { |
| 422 | auto isolate = _engine->getIsolate(); | 448 | auto isolate = _engine->getIsolate(); |
| 423 | Q_ASSERT(isolate->IsCurrent()); | 449 | v8::Locker locker(isolate); |
| 450 | v8::Isolate::Scope isolateScope(isolate); | ||
| 424 | v8::HandleScope handleScope(isolate); | 451 | v8::HandleScope handleScope(isolate); |
| 425 | v8::Context::Scope contextScope(_engine->getContext()); | 452 | v8::Context::Scope contextScope(_engine->getContext()); |
| 426 | return _value.constGet()->IsArray(); | 453 | return _value.constGet()->IsArray(); |
| @@ -428,7 +455,8 @@ bool ScriptValueV8Wrapper::isArray() const { · 1 unmodified line | |||
| 428 | 455 | ||
| 429 | bool ScriptValueV8Wrapper::isBool() const { | 456 | bool ScriptValueV8Wrapper::isBool() const { |
| 430 | auto isolate = _engine->getIsolate(); | 457 | auto isolate = _engine->getIsolate(); |
| 431 | Q_ASSERT(isolate->IsCurrent()); | 458 | v8::Locker locker(isolate); |
| 459 | v8::Isolate::Scope isolateScope(isolate); | ||
| 432 | v8::HandleScope handleScope(isolate); | 460 | v8::HandleScope handleScope(isolate); |
| 433 | v8::Context::Scope contextScope(_engine->getContext()); | 461 | v8::Context::Scope contextScope(_engine->getContext()); |
| 434 | return _value.constGet()->IsBoolean(); | 462 | return _value.constGet()->IsBoolean(); |
| @@ -446,7 +474,8 @@ bool ScriptValueV8Wrapper::isError() const { · 11 unmodified lines | |||
| 446 | 474 | ||
| 447 | bool ScriptValueV8Wrapper::isFunction() const { | 475 | bool ScriptValueV8Wrapper::isFunction() const { |
| 448 | auto isolate = _engine->getIsolate(); | 476 | auto isolate = _engine->getIsolate(); |
| 449 | Q_ASSERT(isolate->IsCurrent()); | 477 | v8::Locker locker(isolate); |
| 478 | v8::Isolate::Scope isolateScope(isolate); | ||
| 450 | v8::HandleScope handleScope(isolate); | 479 | v8::HandleScope handleScope(isolate); |
| 451 | v8::Context::Scope contextScope(_engine->getContext()); | 480 | v8::Context::Scope contextScope(_engine->getContext()); |
| 452 | return _value.constGet()->IsFunction(); | 481 | return _value.constGet()->IsFunction(); |
| @@ -454,7 +483,8 @@ bool ScriptValueV8Wrapper::isFunction() const { · 1 unmodified line | |||
| 454 | 483 | ||
| 455 | bool ScriptValueV8Wrapper::isNumber() const { | 484 | bool ScriptValueV8Wrapper::isNumber() const { |
| 456 | auto isolate = _engine->getIsolate(); | 485 | auto isolate = _engine->getIsolate(); |
| 457 | Q_ASSERT(isolate->IsCurrent()); | 486 | v8::Locker locker(isolate); |
| 487 | v8::Isolate::Scope isolateScope(isolate); | ||
| 458 | v8::HandleScope handleScope(isolate); | 488 | v8::HandleScope handleScope(isolate); |
| 459 | v8::Context::Scope contextScope(_engine->getContext()); | 489 | v8::Context::Scope contextScope(_engine->getContext()); |
| 460 | return _value.constGet()->IsNumber(); | 490 | return _value.constGet()->IsNumber(); |
| @@ -462,7 +492,8 @@ bool ScriptValueV8Wrapper::isNumber() const { · 1 unmodified line | |||
| 462 | 492 | ||
| 463 | bool ScriptValueV8Wrapper::isNull() const { | 493 | bool ScriptValueV8Wrapper::isNull() const { |
| 464 | auto isolate = _engine->getIsolate(); | 494 | auto isolate = _engine->getIsolate(); |
| 465 | Q_ASSERT(isolate->IsCurrent()); | 495 | v8::Locker locker(isolate); |
| 496 | v8::Isolate::Scope isolateScope(isolate); | ||
| 466 | v8::HandleScope handleScope(isolate); | 497 | v8::HandleScope handleScope(isolate); |
| 467 | v8::Context::Scope contextScope(_engine->getContext()); | 498 | v8::Context::Scope contextScope(_engine->getContext()); |
| 468 | return _value.constGet()->IsNull(); | 499 | return _value.constGet()->IsNull(); |
| @@ -470,7 +501,8 @@ bool ScriptValueV8Wrapper::isNull() const { · 1 unmodified line | |||
| 470 | 501 | ||
| 471 | bool ScriptValueV8Wrapper::isObject() const { | 502 | bool ScriptValueV8Wrapper::isObject() const { |
| 472 | auto isolate = _engine->getIsolate(); | 503 | auto isolate = _engine->getIsolate(); |
| 473 | Q_ASSERT(isolate->IsCurrent()); | 504 | v8::Locker locker(isolate); |
| 505 | v8::Isolate::Scope isolateScope(isolate); | ||
| 474 | v8::HandleScope handleScope(isolate); | 506 | v8::HandleScope handleScope(isolate); |
| 475 | v8::Context::Scope contextScope(_engine->getContext()); | 507 | v8::Context::Scope contextScope(_engine->getContext()); |
| 476 | return _value.constGet()->IsObject(); | 508 | return _value.constGet()->IsObject(); |
| @@ -478,7 +510,8 @@ bool ScriptValueV8Wrapper::isObject() const { · 1 unmodified line | |||
| 478 | 510 | ||
| 479 | bool ScriptValueV8Wrapper::isString() const { | 511 | bool ScriptValueV8Wrapper::isString() const { |
| 480 | auto isolate = _engine->getIsolate(); | 512 | auto isolate = _engine->getIsolate(); |
| 481 | Q_ASSERT(isolate->IsCurrent()); | 513 | v8::Locker locker(isolate); |
| 514 | v8::Isolate::Scope isolateScope(isolate); | ||
| 482 | v8::HandleScope handleScope(isolate); | 515 | v8::HandleScope handleScope(isolate); |
| 483 | v8::Context::Scope contextScope(_engine->getContext()); | 516 | v8::Context::Scope contextScope(_engine->getContext()); |
| 484 | return _value.constGet()->IsString(); | 517 | return _value.constGet()->IsString(); |
| @@ -486,26 +519,30 @@ bool ScriptValueV8Wrapper::isString() const { · 1 unmodified line | |||
| 486 | 519 | ||
| 487 | bool ScriptValueV8Wrapper::isUndefined() const { | 520 | bool ScriptValueV8Wrapper::isUndefined() const { |
| 488 | auto isolate = _engine->getIsolate(); | 521 | auto isolate = _engine->getIsolate(); |
| 489 | Q_ASSERT(isolate->IsCurrent()); | 522 | v8::Locker locker(isolate); |
| 523 | v8::Isolate::Scope isolateScope(isolate); | ||
| 490 | v8::HandleScope handleScope(isolate); | 524 | v8::HandleScope handleScope(isolate); |
| 491 | v8::Context::Scope contextScope(_engine->getContext()); | 525 | v8::Context::Scope contextScope(_engine->getContext()); |
| 492 | return _value.constGet()->IsUndefined(); | 526 | return _value.constGet()->IsUndefined(); |
| 493 | } | 527 | } |
| 494 | 528 | ||
| 495 | bool ScriptValueV8Wrapper::isValid() const { | 529 | bool ScriptValueV8Wrapper::isValid() const { |
| 496 | //V8TODO | ||
| 497 | auto isolate = _engine->getIsolate(); | 530 | auto isolate = _engine->getIsolate(); |
| 498 | Q_ASSERT(isolate->IsCurrent()); | 531 | v8::Locker locker(isolate); |
| 532 | v8::Isolate::Scope isolateScope(isolate); | ||
| 499 | v8::HandleScope handleScope(isolate); | 533 | v8::HandleScope handleScope(isolate); |
| 500 | v8::Context::Scope contextScope(_engine->getContext()); | 534 | v8::Context::Scope contextScope(_engine->getContext()); |
| 535 | if (_value.constGet()->IsNullOrUndefined()) { | ||
| 536 | return false; | ||
| 537 | } | ||
| 501 | return true; | 538 | return true; |
| 502 | //return _value.constGet()->IsValid(); | ||
| 503 | } | 539 | } |
| 504 | 540 | ||
| 505 | bool ScriptValueV8Wrapper::isVariant() const { | 541 | bool ScriptValueV8Wrapper::isVariant() const { |
| 506 | //V8TODO | 542 | //V8TODO |
| 507 | auto isolate = _engine->getIsolate(); | 543 | auto isolate = _engine->getIsolate(); |
| 508 | Q_ASSERT(isolate->IsCurrent()); | 544 | v8::Locker locker(isolate); |
| 545 | v8::Isolate::Scope isolateScope(isolate); | ||
| 509 | v8::HandleScope handleScope(isolate); | 546 | v8::HandleScope handleScope(isolate); |
| 510 | v8::Context::Scope contextScope(_engine->getContext()); | 547 | v8::Context::Scope contextScope(_engine->getContext()); |
| 511 | return false; | 548 | return false; |