summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUjjwal Sharma <usharma1998@gmail.com>2018-08-29 15:39:09 +0200
committerMichaƫl Zasso <targos@protonmail.com>2018-09-06 08:53:57 +0200
commitee237e3e55cbe0a9eccf993c54e1fa60a79278a3 (patch)
treec5b0fe4fa79b4d00bb433887d18122458e67ace1
parentb9c0d5e349801e681a7b1f03cc1a46244069259d (diff)
downloadnode-new-ee237e3e55cbe0a9eccf993c54e1fa60a79278a3.tar.gz
src: remove calls to deprecated v8 functions (ToString)
Remove all calls to deprecated v8 functions (here: Value::ToString) inside the code (src directory only). PR-URL: https://github.com/nodejs/node/pull/21935 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
-rw-r--r--src/spawn_sync.cc10
-rw-r--r--src/string_bytes.cc6
-rw-r--r--src/util.cc10
3 files changed, 16 insertions, 10 deletions
diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc
index 1e966e42c6..ba29aaeef0 100644
--- a/src/spawn_sync.cc
+++ b/src/spawn_sync.cc
@@ -981,7 +981,8 @@ int SyncProcessRunner::CopyJsString(Local<Value> js_value,
if (js_value->IsString())
js_string = js_value.As<String>();
else
- js_string = js_value->ToString(env()->isolate());
+ js_string = js_value->ToString(env()->isolate()->GetCurrentContext())
+ .ToLocalChecked();
// Include space for null terminator byte.
size = StringBytes::StorageSize(isolate, js_string, UTF8) + 1;
@@ -1025,7 +1026,12 @@ int SyncProcessRunner::CopyJsStringArray(Local<Value> js_value,
auto value = js_array->Get(context, i).ToLocalChecked();
if (!value->IsString())
- js_array->Set(context, i, value->ToString(env()->isolate())).FromJust();
+ js_array
+ ->Set(context,
+ i,
+ value->ToString(env()->isolate()->GetCurrentContext())
+ .ToLocalChecked())
+ .FromJust();
data_size += StringBytes::StorageSize(isolate, value, UTF8) + 1;
data_size = ROUND_UP(data_size, sizeof(void*));
diff --git a/src/string_bytes.cc b/src/string_bytes.cc
index b7f009fe1f..82d699db9a 100644
--- a/src/string_bytes.cc
+++ b/src/string_bytes.cc
@@ -410,7 +410,8 @@ size_t StringBytes::StorageSize(Isolate* isolate,
return Buffer::Length(val);
}
- Local<String> str = val->ToString(isolate);
+ Local<String> str =
+ val->ToString(isolate->GetCurrentContext()).ToLocalChecked();
switch (encoding) {
case ASCII:
@@ -456,7 +457,8 @@ size_t StringBytes::Size(Isolate* isolate,
if (Buffer::HasInstance(val) && (encoding == BUFFER || encoding == LATIN1))
return Buffer::Length(val);
- Local<String> str = val->ToString(isolate);
+ Local<String> str =
+ val->ToString(isolate->GetCurrentContext()).ToLocalChecked();
switch (encoding) {
case ASCII:
diff --git a/src/util.cc b/src/util.cc
index c36ea5169d..44c47f0f91 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -37,9 +37,8 @@ template <typename T>
static void MakeUtf8String(Isolate* isolate,
Local<Value> value,
T* target) {
- Local<String> string = value->ToString(isolate);
- if (string.IsEmpty())
- return;
+ Local<String> string;
+ if (!value->ToString(isolate->GetCurrentContext()).ToLocal(&string)) return;
const size_t storage = StringBytes::StorageSize(isolate, string, UTF8) + 1;
target->AllocateSufficientStorage(storage);
@@ -63,9 +62,8 @@ TwoByteValue::TwoByteValue(Isolate* isolate, Local<Value> value) {
return;
}
- Local<String> string = value->ToString(isolate);
- if (string.IsEmpty())
- return;
+ Local<String> string;
+ if (!value->ToString(isolate->GetCurrentContext()).ToLocal(&string)) return;
// Allocate enough space to include the null terminator
const size_t storage = string->Length() + 1;