| 784 | } |
| 785 | |
| 786 | Ref<StaticString> V8JavaScriptContext::valueToStaticString(const JSValue& value, JSExceptionTracker& exceptionTracker) { |
| 787 | v8::HandleScope handleScope(_isolate); |
| 788 | v8::Local<v8::Value> val = fromValdiJSValue(_isolate, value, exceptionTracker); |
| 789 | if (!exceptionTracker) { |
| 790 | return nullptr; |
| 791 | } |
| 792 | v8::Local<v8::Context> context = v8::Local<v8::Context>::New(_isolate, _context); |
| 793 | v8::Local<v8::String> string; |
| 794 | if (!val->ToString(context).ToLocal(&string)) { |
| 795 | exceptionTracker.onError("Failed to convert value to static string"); |
| 796 | return nullptr; |
| 797 | } |
| 798 | |
| 799 | const int length = string->Utf8Length(_isolate); |
| 800 | Ref<StaticString> str = StaticString::makeUTF8(length); |
| 801 | string->WriteUtf8(_isolate, str->utf8Data(), length); |
| 802 | |
| 803 | return str; |
| 804 | } |
| 805 | |
| 806 | bool V8JavaScriptContext::valueToBool(const JSValue& value, JSExceptionTracker& exceptionTracker) { |
| 807 | v8::HandleScope handleScope(_isolate); |
no test coverage detected