| 826 | } |
| 827 | |
| 828 | Ref<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 | |
| 846 | bool HermesJavaScriptContext::valueToBool(const JSValue& value, JSExceptionTracker& exceptionTracker) { |
| 847 | hermes::vm::GCScope gcScope(*_runtime); |