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

Method doCall

valdi/src/valdi/runtime/JavaScript/JSFunctionWithValueFunction.cpp:75–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73 : JSFunctionWithValueFunction(std::move(function), false, referenceInfo) {}
74
75JSValueRef JSFunctionWithUntypedValueFunction::doCall(const Ref<ValueFunction>& function,
76 const StringBox* precomputedFunctionIdentifier,
77 JSFunctionNativeCallContext& callContext) const {
78 auto referenceInfoBuilder = ReferenceInfoBuilder(getReferenceInfo());
79 Valdi::SmallVector<Value, 8> outParameters;
80 {
81 VALDI_TRACE("Valdi.jsParametersToCpp");
82
83 for (size_t i = 0, size = callContext.getParameterSize(); i < size; i++) {
84 auto jsValue = callContext.getParameter(i);
85
86 auto convertedParameterResult = jsValueToValue(callContext.getContext(),
87 jsValue,
88 referenceInfoBuilder.withParameter(i),
89 callContext.getExceptionTracker());
90 if (!callContext.getExceptionTracker()) {
91 return callContext.getContext().newUndefined();
92 }
93
94 outParameters.emplace_back(std::move(convertedParameterResult));
95 }
96 }
97
98 ValueFunctionCallContext innerCallContext(
99 ValueFunctionFlagsNone, outParameters.data(), outParameters.size(), callContext.getExceptionTracker());
100 innerCallContext.setFunctionIdentifier(precomputedFunctionIdentifier);
101
102 auto outValue = (*function)(innerCallContext);
103
104 VALDI_TRACE("Valdi.cppToJs");
105 return valueToJSValue(
106 callContext.getContext(), outValue, referenceInfoBuilder.withReturnValue(), callContext.getExceptionTracker());
107}
108
109} // namespace Valdi

Callers

nothing calls this directly

Calls 12

jsValueToValueFunction · 0.85
valueToJSValueFunction · 0.85
getParameterSizeMethod · 0.80
getParameterMethod · 0.80
withParameterMethod · 0.80
newUndefinedMethod · 0.80
setFunctionIdentifierMethod · 0.80
withReturnValueMethod · 0.80
getContextMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected