36 static void MakeUtf8String(Isolate* isolate,
39 Local<String>
string = value->ToString(isolate);
43 const size_t storage = StringBytes::StorageSize(isolate,
string,
UTF8) + 1;
44 target->AllocateSufficientStorage(storage);
46 String::NO_NULL_TERMINATION | String::REPLACE_INVALID_UTF8;
47 const int length =
string->WriteUtf8(target->out(), storage, 0, flags);
48 target->SetLengthAndZeroTerminate(length);
51 Utf8Value::Utf8Value(Isolate* isolate, Local<Value> value) {
55 MakeUtf8String(isolate, value,
this);
59 TwoByteValue::TwoByteValue(Isolate* isolate, Local<Value> value) {
60 if (value.IsEmpty()) {
64 Local<String>
string = value->ToString(isolate);
69 const size_t storage =
string->Length() + 1;
70 AllocateSufficientStorage(storage);
72 const int flags = String::NO_NULL_TERMINATION;
73 const int length =
string->Write(out(), 0, storage, flags);
74 SetLengthAndZeroTerminate(length);
77 BufferValue::BufferValue(Isolate* isolate, Local<Value> value) {
81 if (value.IsEmpty()) {
87 if (value->IsString()) {
88 MakeUtf8String(isolate, value,
this);
92 AllocateSufficientStorage(len + 1);
94 SetLengthAndZeroTerminate(len);
102 auto isolate = v8::Isolate::GetCurrent();
103 if (isolate !=
nullptr) {
104 isolate->LowMemoryNotification();
bool HasInstance(Local< Value > val)
size_t Length(Local< Value > val)
char * Data(Local< Value > val)
void LowMemoryNotification()