| 1301 | |
| 1302 | auto callContext = |
| 1303 | JSFunctionCallContext(entryParameters.jsContext, &jsResult, 1, entryParameters.exceptionTracker); |
| 1304 | |
| 1305 | entryParameters.jsContext.callObjectAsFunction(jsValue, callContext); |
| 1306 | }); |
| 1307 | } |
| 1308 | |
| 1309 | JSValueRef JavaScriptRuntime::handleViewNodeSpecificAction( |
| 1310 | JSFunctionNativeCallContext& callContext, |
| 1311 | Function<void(ViewNode&, Function<void(const Value&)>)>&& handleViewNode) { |
| 1312 | auto contextId = getParameterAsContextId(callContext, 0); |
| 1313 | CHECK_CALL_CONTEXT(callContext); |
| 1314 | |
| 1315 | auto nodeId = static_cast<RawViewNodeId>(callContext.getParameterAsInt(1)); |
| 1316 | CHECK_CALL_CONTEXT(callContext); |
| 1317 | |
| 1318 | auto callbackParameterIndex = callContext.getParameterSize() - 1; |
| 1319 | |
| 1320 | auto callbackRef = JSValueRefHolder::makeRetainedCallback( |
| 1321 | callContext.getContext(), |
| 1322 | callContext.getParameter(callbackParameterIndex), |
| 1323 | ReferenceInfoBuilder(callContext.getReferenceInfo()).withParameter(callbackParameterIndex), |
| 1324 | callContext.getExceptionTracker()); |
| 1325 | |
| 1326 | auto context = _contextManager->getContext(contextId); |
| 1327 | if (context == nullptr) { |
| 1328 | return callContext.throwError(Valdi::Error(STRING_FORMAT("Could not resolve Context {}", contextId))); |
| 1329 | } |
| 1330 | |
| 1331 | auto listener = getListener(); |
| 1332 | if (!listener) { |
| 1333 | return callContext.throwError( |
| 1334 | Valdi::Error(STRING_FORMAT("No runtime listener to resolve ViewNodeTree of Context {}", contextId))); |
| 1335 | } |
| 1336 | |
| 1337 | listener->resolveViewNodeTree( |
| 1338 | context, |
| 1339 | true, |
| 1340 | true, |
| 1341 | [self = strongSmallRef(this), callbackRef, nodeId, contextId, handleViewNode = std::move(handleViewNode)]( |
| 1342 | const SharedViewNodeTree& viewNodeTree) { |
| 1343 | if (viewNodeTree == nullptr) { |
| 1344 | [[maybe_unused]] auto capturedContextId = contextId; |
| 1345 | VALDI_ERROR(*self->_logger, "Could not resolve ViewNodeTree of Context {}", capturedContextId); |
| 1346 | return; |
| 1347 | } |
| 1348 | |
| 1349 | viewNodeTree->withLock([&]() { |
| 1350 | auto viewNode = viewNodeTree->getViewNode(nodeId); |
| 1351 | if (viewNode != nullptr) { |
| 1352 | handleViewNode(*viewNode, [self, callbackRef](const auto& result) { |
| 1353 | self->callViewNodeActionCallback(callbackRef, result); |
| 1354 | }); |
nothing calls this directly
no test coverage detected