MCPcopy Create free account
hub / github.com/Snapchat/Valdi / callModuleFunction

Method callModuleFunction

valdi/src/valdi/runtime/JavaScript/JavaScriptRuntime.cpp:2520–2554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2518 workerRuntime->registerTypeConverter(typeConverter.typeName, typeConverter.functionPath);
2519 }
2520 auto worker = makeShared<JavaScriptWorker>(strongSmallRef(this), workerRuntime, url);
2521 worker->postInit();
2522 CHECK_CALL_CONTEXT(callContext);
2523 // worker->init(); // call outside of ctor so that shared_from_this() is available
2524 auto workerJSValue = callContext.getContext().newWrappedObject(worker, callContext.getExceptionTracker());
2525 CHECK_CALL_CONTEXT(callContext);
2526 bindRuntimeFunction(callContext.getContext(),
2527 callContext.getExceptionTracker(),
2528 workerJSValue,
2529 "setOnMessage",
2530 &JavaScriptRuntime::workerSetOnMessage);
2531 CHECK_CALL_CONTEXT(callContext);
2532 bindRuntimeFunction(callContext.getContext(),
2533 callContext.getExceptionTracker(),
2534 workerJSValue,
2535 "postMessage",
2536 &JavaScriptRuntime::workerPostMessage);
2537 CHECK_CALL_CONTEXT(callContext);
2538 bindRuntimeFunction(callContext.getContext(),
2539 callContext.getExceptionTracker(),
2540 workerJSValue,
2541 "terminate",
2542 &JavaScriptRuntime::workerTerminate);
2543 CHECK_CALL_CONTEXT(callContext);
2544 {
2545 std::lock_guard<Mutex> guard(_jsWorkersMutex);
2546 _jsWorkers.emplace_back(weakRef(workerRuntime.get()));
2547 }
2548 // A worker created by a task already running when this runtime was marked joined _jsWorkers too late for
2549 // markWorkersHostTornDown(). Checked after the append, so either that pass saw it or this sees the flag.
2550 if (_hostTornDown) {
2551 workerRuntime->markHostTornDown();
2552 }
2553 return workerJSValue;
2554}
2555
2556JSValueRef JavaScriptRuntime::queueMicrotask(JSFunctionNativeCallContext& callContext) {
2557 callContext.getContext().enqueueMicrotask(callContext.getParameter(0), callContext.getExceptionTracker());

Callers

nothing calls this directly

Calls 10

importModuleMethod · 0.95
valueToJSValueFunction · 0.85
getJsValueMethod · 0.80
ensureRetainedValueMethod · 0.80
callObjectPropertyMethod · 0.80
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
toStringViewMethod · 0.45

Tested by

no test coverage detected