| 372 | |
| 373 | Valdi::JSValueRef JavaScriptCoreContext::newFunction(const Valdi::Ref<Valdi::JSFunction>& callable, |
| 374 | Valdi::JSExceptionTracker& exceptionTracker) { |
| 375 | auto context = getJSGlobalContext(); |
| 376 | |
| 377 | auto functionData = Valdi::makeShared<JSFunctionData>(*this, callable); |
| 378 | auto object = JSObjectMake(context, getNativeFunctionClassRef(), Valdi::unsafeBridgeRetain(functionData.get())); |
| 379 | |
| 380 | if (!callable->getReferenceInfo().getName().isEmpty()) { |
| 381 | static auto kName = JSStringCreateWithUTF8CString("name"); |
| 382 | auto value = newStringUTF8(callable->getReferenceInfo().getName().toStringView(), exceptionTracker); |
| 383 | if (!exceptionTracker) { |
| 384 | return Valdi::JSValueRef(); |
| 385 | } |
| 386 | JSObjectSetProperty( |
| 387 | context, object, kName, fromValdiJSValue(value.get()).valueRef, kJSPropertyAttributeNone, nullptr); |
| 388 | } |
| 389 | |
| 390 | JSObjectSetPrototype(context, object, _functionPrototype); |
| 391 | return returnJSValueRef(object, kJSTypeObject); |
nothing calls this directly
no test coverage detected