| 460 | JSValueRef (JavaScriptRuntime::*function)(JSFunctionNativeCallContext&)) { |
| 461 | auto functionNameStr = STRING_LITERAL(functionName); |
| 462 | auto objectName = STRING_LITERAL("runtime"); |
| 463 | auto callable = makeShared<JavaScriptRuntimeCallable>( |
| 464 | *this, |
| 465 | function, |
| 466 | ReferenceInfoBuilder().withObject(objectName).withProperty(functionNameStr).asFunction().build()); |
| 467 | |
| 468 | auto jsFunction = jsContext.newFunction(callable, exceptionTracker); |
| 469 | if (!exceptionTracker) { |
| 470 | return; |
| 471 | } |
| 472 | |
| 473 | jsContext.setObjectProperty( |
| 474 | jsObject.get(), functionNameStr.toStringView(), jsFunction.get(), true, exceptionTracker); |
| 475 | if (!exceptionTracker) { |
| 476 | return; |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | Result<Void> JavaScriptRuntime::initializeContext() { |
| 481 | VALDI_TRACE("Valdi.createJsContext"); |
| 482 | Ref<ValdiRuntimeTweaks> runtimeTweaks; |
| 483 | if (auto listener = getListener()) { |
| 484 | runtimeTweaks = listener->getRuntimeTweaks(); |
| 485 | } |
| 486 | |
| 487 | if (runtimeTweaks != nullptr) { |
| 488 | Context::setDestroyedContextFixEnabled(runtimeTweaks->enableRenderRequestContextFix()); |
| 489 | } |
| 490 | |
| 491 | VALDI_INFO(*_logger, "Creating JSContext from engine '{}'", _javaScriptBridge.getName()); |
| 492 | |
| 493 | auto jsContext = _javaScriptBridge.createJsContext(this, *_logger); |
| 494 | |
| 495 | std::unique_ptr<JavaScriptRuntimeDeserializers> runtimeDeserializers; |
| 496 | |
| 497 | IJavaScriptContextConfig config; |
| 498 | |
| 499 | JSExceptionTracker exceptionTracker(*jsContext); |
| 500 | jsContext->initialize(config, exceptionTracker); |
| 501 | |
| 502 | if (exceptionTracker) { |
| 503 | jsContext->startDebugger(_isWorker); |
nothing calls this directly
no test coverage detected