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

Method valueToTypedArray

valdi/src/valdi/hermes/HermesJavaScriptContext.cpp:967–998  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

965 const auto* hermesValue = toPinnedHermesValue(object);
966
967 if (!hermes::vm::vmisa<hermes::vm::Callable>(*hermesValue)) {
968 callContext.getExceptionTracker().onError("Value is not a function");
969 return newUndefined();
970 }
971
972 auto handle = hermes::vm::Handle<hermes::vm::Callable>::vmcast(hermesValue);
973
974 auto thisRes = hermes::vm::Callable::createThisForConstruct_RJS(handle, *_runtime);
975 auto objHandle = _runtime->makeHandle<hermes::vm::JSObject>(std::move(*thisRes));
976
977 hermes::vm::ScopedNativeCallFrame callFrame(*_runtime,
978 static_cast<uint32_t>(callContext.getParameterSize()),
979 handle.getHermesValue(),
980 handle.getHermesValue(),
981 objHandle.getHermesValue());
982
983 auto callResult = doCall(callFrame, handle, callContext);
984
985 if (!checkException(callResult.getStatus(), callContext.getExceptionTracker())) {
986 return newUndefined();
987 }
988
989 auto resultValue = callResult->get();
990 return toJSValueRef(resultValue.isObject() ? resultValue : objHandle.getHermesValue());
991}
992
993void HermesJavaScriptContext::visitObjectPropertyNames(const JSValue& object,
994 JSExceptionTracker& exceptionTracker,
995 IJavaScriptPropertyNamesVisitor& visitor) {
996 hermes::vm::GCScope gcScope(*_runtime);
997 auto jsObject = toJSObject(object, exceptionTracker);
998 if (!jsObject) {
999 return;
1000 }
1001

Callers

nothing calls this directly

Calls 6

JSTypedArrayClass · 0.85
getTypedArrayTypeFunction · 0.70
onErrorMethod · 0.65
attachedMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected