From cae9ff256be348101ff3655c4a420945970baa19 Mon Sep 17 00:00:00 2001 From: Sarat Addepalli Date: Tue, 20 Mar 2018 23:29:17 +0530 Subject: [PATCH] src: fix upcoming V8 deprecation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/19490 Fixes: https://github.com/nodejs/node/issues/18909 Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: Daniel Bevenius Reviewed-By: Michaƫl Zasso --- src/inspector_js_api.cc | 2 +- src/node.cc | 12 +++++++----- src/node_api.cc | 2 +- src/node_buffer.cc | 4 ++-- src/node_contextify.cc | 12 ++++++------ src/node_crypto.cc | 2 +- src/node_v8.cc | 2 +- src/string_bytes.cc | 6 +++--- 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index 1cced9420aea6c..e727410202b119 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -232,7 +232,7 @@ static void AsyncTaskScheduledWrapper(const FunctionCallbackInfo& args) { CHECK(args[0]->IsString()); Local task_name = args[0].As(); - String::Value task_name_value(task_name); + String::Value task_name_value(args.GetIsolate(), task_name); StringView task_name_view(*task_name_value, task_name_value.length()); CHECK(args[1]->IsNumber()); diff --git a/src/node.cc b/src/node.cc index 35a1d5cb598d5b..a180f97cd4140e 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1595,9 +1595,11 @@ void AppendExceptionLine(Environment* env, ScriptOrigin origin = message->GetScriptOrigin(); node::Utf8Value filename(env->isolate(), message->GetScriptResourceName()); const char* filename_string = *filename; - int linenum = message->GetLineNumber(); + int linenum = message->GetLineNumber(env->context()).FromJust(); // Print line of source code. - node::Utf8Value sourceline(env->isolate(), message->GetSourceLine()); + MaybeLocal source_line_maybe = message->GetSourceLine(env->context()); + node::Utf8Value sourceline(env->isolate(), + source_line_maybe.ToLocalChecked()); const char* sourceline_string = *sourceline; if (strstr(sourceline_string, "node-do-not-add-exception-line") != nullptr) return; @@ -1745,7 +1747,7 @@ static void ReportException(Environment* env, name.IsEmpty() || name->IsUndefined()) { // Not an error object. Just print as-is. - String::Utf8Value message(er); + String::Utf8Value message(env->isolate(), er); PrintErrorString("%s\n", *message ? *message : ""); @@ -1797,13 +1799,13 @@ static Local ExecuteString(Environment* env, exit(3); } - Local result = script.ToLocalChecked()->Run(); + MaybeLocal result = script.ToLocalChecked()->Run(env->context()); if (result.IsEmpty()) { ReportException(env, try_catch); exit(4); } - return scope.Escape(result); + return scope.Escape(result.ToLocalChecked()); } diff --git a/src/node_api.cc b/src/node_api.cc index ea6bccef3f77de..d1e99495b45ddb 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -3325,7 +3325,7 @@ class Work : public node::AsyncResource { void* data = nullptr) : AsyncResource(env->isolate, async_resource, - *v8::String::Utf8Value(async_resource_name)), + *v8::String::Utf8Value(env->isolate, async_resource_name)), _env(env), _data(data), _execute(execute), diff --git a/src/node_buffer.cc b/src/node_buffer.cc index f9a807602f612c..773b3341821f82 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -946,7 +946,7 @@ void IndexOfString(const FunctionCallbackInfo& args) { size_t result = haystack_length; if (enc == UCS2) { - String::Value needle_value(needle); + String::Value needle_value(args.GetIsolate(), needle); if (*needle_value == nullptr) return args.GetReturnValue().Set(-1); @@ -979,7 +979,7 @@ void IndexOfString(const FunctionCallbackInfo& args) { } result *= 2; } else if (enc == UTF8) { - String::Utf8Value needle_value(needle); + String::Utf8Value needle_value(args.GetIsolate(), needle); if (*needle_value == nullptr) return args.GetReturnValue().Set(-1); diff --git a/src/node_contextify.cc b/src/node_contextify.cc index f49a2362769bc2..e7f956e9882689 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -1098,21 +1098,21 @@ class ContextifyScript : public BaseObject { PersistentToLocal(env->isolate(), wrapped_script->script_); Local