| 406 | if (!exceptionTracker) { |
| 407 | return Valdi::JSValueRef(); |
| 408 | } |
| 409 | |
| 410 | // JS_DefinePropertyValueStr() automatically releases the given value. |
| 411 | auto retainedName = JS_DupValue(_context, fromValdiJSValue(value.get())); |
| 412 | |
| 413 | checkCall(exceptionTracker, |
| 414 | JS_DefinePropertyValueStr(_context, fromValdiJSValue(functionObject.get()), "name", retainedName, 0)); |
| 415 | |
| 416 | if (!exceptionTracker) { |
| 417 | return Valdi::JSValueRef(); |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | return functionObject; |
| 422 | } |
| 423 | |
| 424 | size_t QuickJSJavaScriptContext::associateWeakReference(const JSValue& value, |
| 425 | Valdi::JSExceptionTracker& exceptionTracker) { |
| 426 | auto guard = _threadAccessChecker.guard(); |
| 427 | auto existingFinalizer = |
| 428 | checkCallAndGetValue(exceptionTracker, JS_GetProperty(_context, value, _objectFinalizerAtomKey)); |
| 429 | if (!exceptionTracker) { |
| 430 | return 0; |
| 431 | } |
| 432 | |
| 433 | auto weakReferenceId = weakReferenceIdFromJSWeakReferenceFinalizer(fromValdiJSValue(existingFinalizer.get())); |
| 434 | if (weakReferenceId != 0) { |
| 435 | return weakReferenceId; |
| 436 | } |
| 437 | |
| 438 | // Create the finalizer |
| 439 | auto finalizerObject = checkCallAndGetValue( |
| 440 | exceptionTracker, JS_NewObjectProtoClass(_context, _objectPrototype, _weakReferenceFinalizerClassID)); |
| 441 | if (!exceptionTracker) { |
| 442 | return 0; |
| 443 | } |
| 444 | |
| 445 | weakReferenceId = ++_weakReferenceSequence; |
nothing calls this directly
no test coverage detected