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

Method runtimeLoadModule

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

Source from the content-addressed store, hash-verified

1301 return callContext.getContext().newUndefined();
1302}
1303
1304JSValueRef JavaScriptRuntime::runtimeProtectNativeRefs(JSFunctionNativeCallContext& callContext) {
1305 auto contextId = getParameterAsContextId(callContext, 0);
1306 CHECK_CALL_CONTEXT(callContext);
1307
1308 Ref<Context> context;
1309 if (contextId == ContextIdNull) {
1310 context = Context::currentRoot();
1311 } else {
1312 auto result = getContextForId(contextId);
1313 if (!result) {
1314 return callContext.throwError(result.moveError());
1315 }
1316 context = result.moveValue();
1317 }
1318
1319 context->retainDisposables();
1320
1321 auto releaseLambda =
1322 makeShared<JSFunctionWithCallable>(ReferenceInfoBuilder(callContext.getReferenceInfo()).withReturnValue(),
1323 [context](JSFunctionNativeCallContext& callContext) -> JSValueRef {
1324 context->releaseDisposables();
1325 return callContext.getContext().newUndefined();
1326 });
1327
1328 return callContext.getContext().newFunction(releaseLambda, callContext.getExceptionTracker());
1329}
1330
1331JSValueRef JavaScriptRuntime::runtimeGetFrameForViewId(JSFunctionNativeCallContext& callContext) {
1332 return handleViewNodeSpecificActionSync(
1333 callContext, [](ViewNode& viewNode) { return Valdi::Value(viewNode.getDirectionAgnosticFrame().toMap()); });
1334}
1335
1336JSValueRef JavaScriptRuntime::runtimeGetNativeViewForViewId(JSFunctionNativeCallContext& callContext) {
1337 return handleViewNodeSpecificActionSync(callContext,
1338 [](ViewNode& viewNode) { return viewNode.toPlaformRepresentation(true); });
1339}
1340
1341JSValueRef JavaScriptRuntime::runtimeGetLayoutDebugInfo(JSFunctionNativeCallContext& callContext) {
1342 return handleViewNodeSpecificActionSync(
1343 callContext, [](ViewNode& viewNode) { return Value(viewNode.getLayoutDebugDescription()); });
1344}
1345
1346JSValueRef JavaScriptRuntime::runtimeGetNativeNodeForElementId(JSFunctionNativeCallContext& callContext) {
1347 auto contextId = getParameterAsContextId(callContext, 0);
1348 CHECK_CALL_CONTEXT(callContext);
1349
1350 auto nodeId = static_cast<RawViewNodeId>(callContext.getParameterAsInt(1));
1351 CHECK_CALL_CONTEXT(callContext);
1352
1353 auto context = _contextManager->getContext(contextId);
1354 if (context == nullptr) {

Callers

nothing calls this directly

Calls 15

getParameterMethod · 0.80
newUndefinedMethod · 0.80
withParameterMethod · 0.80
loadModuleAsyncMethod · 0.80
getJsValueMethod · 0.80
toStringMethod · 0.65
errorMethod · 0.65
getParameterAsStringMethod · 0.45
isValueUndefinedMethod · 0.45

Tested by

no test coverage detected