| 762 | } |
| 763 | |
| 764 | StringBox V8JavaScriptContext::valueToString(const JSValue& value, JSExceptionTracker& exceptionTracker) { |
| 765 | v8::HandleScope handleScope(_isolate); |
| 766 | v8::Local<v8::Value> val = fromValdiJSValue(_isolate, value, exceptionTracker); |
| 767 | if (!exceptionTracker) { |
| 768 | return StringBox(); |
| 769 | } |
| 770 | v8::Local<v8::Context> context = v8::Local<v8::Context>::New(_isolate, _context); |
| 771 | v8::Local<v8::String> string; |
| 772 | if (!val->ToString(context).ToLocal(&string)) { |
| 773 | exceptionTracker.onError("Failed to convert value to string"); |
| 774 | return StringBox(); |
| 775 | } |
| 776 | |
| 777 | // TODO: we probably should use WriteUtf8 method instead |
| 778 | v8::String::Utf8Value stringValue(_isolate, string); |
| 779 | |
| 780 | auto stringData = *stringValue; |
| 781 | auto stringLength = stringValue.length(); |
| 782 | |
| 783 | return StringCache::getGlobal().makeString(stringData, stringLength); |
| 784 | } |
| 785 | |
| 786 | Ref<StaticString> V8JavaScriptContext::valueToStaticString(const JSValue& value, JSExceptionTracker& exceptionTracker) { |
| 787 | v8::HandleScope handleScope(_isolate); |
nothing calls this directly
no test coverage detected