| 373 | } |
| 374 | |
| 375 | Valdi::JSValueRef QuickJSJavaScriptContext::newFunction(const Valdi::Ref<Valdi::JSFunction>& callable, |
| 376 | Valdi::JSExceptionTracker& exceptionTracker) { |
| 377 | auto guard = _threadAccessChecker.guard(); |
| 378 | // TODO(simon): Use functionName |
| 379 | |
| 380 | auto functionObject = |
| 381 | checkCallAndGetValue(exceptionTracker, JS_NewObjectProtoClass(_context, _functionPrototype, _functionClassID)); |
| 382 | if (!exceptionTracker) { |
| 383 | return Valdi::JSValueRef(); |
| 384 | } |
| 385 | |
| 386 | setObjectCallable(fromValdiJSValue(functionObject.get()), callable); |
| 387 | |
| 388 | if (!callable->getReferenceInfo().getName().isEmpty()) { |
| 389 | auto value = newStringUTF8(callable->getReferenceInfo().getName().toStringView(), exceptionTracker); |
| 390 | if (!exceptionTracker) { |
| 391 | return Valdi::JSValueRef(); |
| 392 | } |
| 393 | |
| 394 | // JS_DefinePropertyValueStr() automatically releases the given value. |
| 395 | auto retainedName = JS_DupValue(_context, fromValdiJSValue(value.get())); |
| 396 | |
| 397 | checkCall(exceptionTracker, |
| 398 | JS_DefinePropertyValueStr(_context, fromValdiJSValue(functionObject.get()), "name", retainedName, 0)); |
| 399 | |
| 400 | if (!exceptionTracker) { |
| 401 | return Valdi::JSValueRef(); |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | return functionObject; |
| 406 | } |
| 407 | |
| 408 | size_t QuickJSJavaScriptContext::associateWeakReference(const JSValue& value, |
| 409 | Valdi::JSExceptionTracker& exceptionTracker) { |
nothing calls this directly
no test coverage detected