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