| 352 | case ValueType::Function: { |
| 353 | auto func = value.getFunctionRef(); |
| 354 | |
| 355 | auto jsValue = unwrapJSValueIfNeeded(jsContext, func.get(), nullptr, exceptionTracker); |
| 356 | if (!exceptionTracker) { |
| 357 | return jsContext.newUndefined(); |
| 358 | } |
| 359 | |
| 360 | if (jsValue) { |
| 361 | // Unwrap the original JS function. |
| 362 | return JSValueRef::makeRetained(jsContext, jsValue.value()); |
| 363 | } |
| 364 | |
| 365 | auto callable = makeShared<JSFunctionWithUntypedValueFunction>(std::move(func), |
| 366 | referenceInfoBuilder.asFunction().build()); |
| 367 | return jsContext.newFunction(callable, exceptionTracker); |
| 368 | } |
| 369 | } |
| 370 | SC_ASSERT_FAIL("This should not happen"); |
| 371 | } |
| 372 | |
| 373 | JSValueRef valueToJSValue(IJavaScriptContext& jsContext, |
| 374 | const Valdi::Value& value, |
| 375 | const ReferenceInfoBuilder& referenceInfoBuilder, |
| 376 | JSExceptionTracker& exceptionTracker) { |
| 377 | return valueToJSValue(jsContext, value, nullptr, referenceInfoBuilder, exceptionTracker); |
| 378 | } |
| 379 | |
| 380 | StringBox nameFromJSFunction(IJavaScriptContext& jsContext, const JSValue& jsValue) { |
| 381 | static auto kNameKey = STRING_LITERAL("name"); |
| 382 | static auto kAnonymousFunction = STRING_LITERAL("<anon>"); |
| 383 | static auto kAnonymousBoundFunction = STRING_LITERAL("bound <anon>"); |
| 384 | static auto kNameWhenBoundAnonymous = STRING_LITERAL("bound "); |
| 385 | |
| 386 | JSExceptionTracker exceptionTracker(jsContext); |
no test coverage detected