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

Function jsArrayToValue

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

Source from the content-addressed store, hash-verified

490 }
491
492 if (output.isUndefined()) {
493 // No proxy objects found in the object, marshall as a plain map
494 return untypedJsObjectToValue(jsContext, jsValue, referenceInfoBuilder, exceptionTracker);
495 } else {
496 // Proxy object found, return it
497 return output;
498 }
499}
500
501size_t jsArrayGetLength(IJavaScriptContext& jsContext, const JSValue& jsValue, JSExceptionTracker& exceptionTracker) {
502 static auto kLength = STRING_LITERAL("length");
503
504 auto length = jsContext.getObjectProperty(jsValue, jsContext.getPropertyNameCached(kLength), exceptionTracker);
505 if (!exceptionTracker) {
506 return 0;
507 }
508
509 return static_cast<size_t>(jsContext.valueToInt(length.get(), exceptionTracker));
510}
511
512Value jsArrayToValue(IJavaScriptContext& jsContext,
513 const JSValue& jsValue,
514 const ReferenceInfoBuilder& referenceInfoBuilder,
515 JSExceptionTracker& exceptionTracker) {
516 auto arrayLength = jsArrayGetLength(jsContext, jsValue, exceptionTracker);
517 if (!exceptionTracker) {
518 return Value::undefined();
519 }
520
521 auto array = Valdi::ValueArray::make(arrayLength);
522

Callers 1

jsValueToValueFunction · 0.85

Calls 7

jsArrayGetLengthFunction · 0.85
jsValueToValueFunction · 0.85
withArrayIndexMethod · 0.80
getMethod · 0.65
ValueClass · 0.50
emplaceMethod · 0.45

Tested by

no test coverage detected