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

Function jsObjectToValue

valdi/src/valdi/runtime/JavaScript/JavaScriptUtils.cpp:457–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455}
456
457Value jsObjectToValue(IJavaScriptContext& jsContext,
458 const JSValue& jsValue,
459 const ReferenceInfoBuilder& referenceInfoBuilder,
460 JSExceptionTracker& exceptionTracker) {
461 auto* valueMarshaller = jsContext.getValueMarshaller();
462
463 if (valueMarshaller == nullptr) {
464 return untypedJsObjectToValue(jsContext, jsValue, referenceInfoBuilder, exceptionTracker);
465 }
466
467 auto output = valueMarshaller->tryUnwrap(jsValue, exceptionTracker);
468 if (!exceptionTracker) {
469 return output;
470 }
471
472 if (output.isUndefined()) {
473 // No proxy objects found in the object, marshall as a plain map
474 return untypedJsObjectToValue(jsContext, jsValue, referenceInfoBuilder, exceptionTracker);
475 } else {
476 // Proxy object found, return it
477 return output;
478 }
479}
480
481size_t jsArrayGetLength(IJavaScriptContext& jsContext, const JSValue& jsValue, JSExceptionTracker& exceptionTracker) {
482 static auto kLength = STRING_LITERAL("length");

Callers 1

jsValueToValueFunction · 0.85

Calls 4

untypedJsObjectToValueFunction · 0.85
tryUnwrapMethod · 0.80
getValueMarshallerMethod · 0.45
isUndefinedMethod · 0.45

Tested by

no test coverage detected