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
966 uint32_t beginIndex;
967 uint32_t endIndex;
968 auto result = hermes::vm::getForInPropertyNames(*_runtime, std::move(jsObject), beginIndex, endIndex);
969 if (!checkException(result.getStatus(), exceptionTracker)) {
970 return;
971 }
972
973 const auto& propertyNames = *result;
974 for (uint32_t i = beginIndex; i < endIndex; i++) {
975 hermes::vm::GCScope innerGCScope(*_runtime);
976
977 auto name = propertyNames->at(*_runtime, i);
978
979 JSPropertyNameRef propertyName;
980
981 if (name.isString()) {
982 auto symbolId = hermes::vm::stringToSymbolID(*_runtime, hermes::vm::createPseudoHandle(name.getString()));
983 if (!checkException(symbolId.getStatus(), exceptionTracker)) {
984 return;
985 }
986 propertyName = toPropertyNameRef(symbolId.getValue());
987 } else if (name.isNumber()) {
988 auto strResult = hermes::vm::toString_RJS(*_runtime, _runtime->makeHandle(name));
989 if (!checkException(strResult.getStatus(), exceptionTracker)) {
990 return;
991 }
992 auto symbolId = hermes::vm::stringToSymbolID(*_runtime, std::move(strResult.getValue()));
993 if (!checkException(symbolId.getStatus(), exceptionTracker)) {
994 return;
995 }
996
997 propertyName = toPropertyNameRef(symbolId.getValue());
998 }
999
1000 if (!propertyName.empty()) {
1001 if (!visitor.visitPropertyName(*this, object, propertyName.get(), exceptionTracker)) {

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