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

Method valueToStaticString

valdi/src/valdi/hermes/HermesJavaScriptContext.cpp:828–844  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

826}
827
828Ref<StaticString> HermesJavaScriptContext::valueToStaticString(const JSValue& value,
829 JSExceptionTracker& exceptionTracker) {
830 hermes::vm::GCScope gcScope(*_runtime);
831 auto result = toString(*_runtime, toHermesValue(value));
832
833 if (!checkException(result.getStatus(), exceptionTracker)) {
834 return nullptr;
835 }
836
837 auto stringView =
838 hermes::vm::StringPrimitive::createStringView(*_runtime, _runtime->makeHandle(std::move(result.getValue())));
839 if (stringView.isASCII()) {
840 return StaticString::makeUTF8(stringView.castToCharPtr(), stringView.length());
841 } else {
842 return StaticString::makeUTF16(stringView.castToChar16Ptr(), stringView.length());
843 }
844}
845
846bool HermesJavaScriptContext::valueToBool(const JSValue& value, JSExceptionTracker& exceptionTracker) {
847 hermes::vm::GCScope gcScope(*_runtime);

Callers

nothing calls this directly

Calls 4

getStatusMethod · 0.80
toStringFunction · 0.70
getValueMethod · 0.65
lengthMethod · 0.45

Tested by

no test coverage detected