src: fix upcoming V8 deprecation warnings

PR-URL: https://github.com/nodejs/node/pull/19490
Fixes: https://github.com/nodejs/node/issues/18909
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
Sarat Addepalli 2018-03-20 23:29:17 +05:30 committed by Michaël Zasso
parent 43506f1013
commit c6c957d3cc
8 changed files with 22 additions and 20 deletions

View File

@ -230,7 +230,7 @@ static void AsyncTaskScheduledWrapper(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsString());
Local<String> task_name = args[0].As<String>();
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());

View File

@ -1269,9 +1269,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<String> 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;
@ -1419,7 +1421,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 :
"<toString() threw exception>");
@ -1471,13 +1473,13 @@ static Local<Value> ExecuteString(Environment* env,
exit(3);
}
Local<Value> result = script.ToLocalChecked()->Run();
MaybeLocal<Value> result = script.ToLocalChecked()->Run(env->context());
if (result.IsEmpty()) {
ReportException(env, try_catch);
exit(4);
}
return scope.Escape(result);
return scope.Escape(result.ToLocalChecked());
}

View File

@ -3315,7 +3315,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),

View File

@ -854,7 +854,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& 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);
@ -887,7 +887,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& 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);

View File

@ -1086,21 +1086,21 @@ class ContextifyScript : public BaseObject {
PersistentToLocal(env->isolate(), wrapped_script->script_);
Local<Script> script = unbound_script->BindToCurrentContext();
Local<Value> result;
MaybeLocal<Value> result;
bool timed_out = false;
bool received_signal = false;
if (break_on_sigint && timeout != -1) {
Watchdog wd(env->isolate(), timeout, &timed_out);
SigintWatchdog swd(env->isolate(), &received_signal);
result = script->Run();
result = script->Run(env->context());
} else if (break_on_sigint) {
SigintWatchdog swd(env->isolate(), &received_signal);
result = script->Run();
result = script->Run(env->context());
} else if (timeout != -1) {
Watchdog wd(env->isolate(), timeout, &timed_out);
result = script->Run();
result = script->Run(env->context());
} else {
result = script->Run();
result = script->Run(env->context());
}
if (timed_out || received_signal) {
@ -1131,7 +1131,7 @@ class ContextifyScript : public BaseObject {
return false;
}
args.GetReturnValue().Set(result);
args.GetReturnValue().Set(result.ToLocalChecked());
return true;
}

View File

@ -4255,7 +4255,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
int padding = args[2]->Uint32Value();
String::Utf8Value passphrase(args[3]);
String::Utf8Value passphrase(args.GetIsolate(), args[3]);
unsigned char* out_value = nullptr;
size_t out_len = 0;

View File

@ -114,7 +114,7 @@ void UpdateHeapSpaceStatisticsBuffer(const FunctionCallbackInfo<Value>& args) {
void SetFlagsFromString(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsString());
String::Utf8Value flags(args[0]);
String::Utf8Value flags(args.GetIsolate(), args[0]);
V8::SetFlagsFromString(*flags, flags.length());
}

View File

@ -369,7 +369,7 @@ size_t StringBytes::Write(Isolate* isolate,
auto ext = str->GetExternalOneByteStringResource();
nbytes = base64_decode(buf, buflen, ext->data(), ext->length());
} else {
String::Value value(str);
String::Value value(isolate, str);
nbytes = base64_decode(buf, buflen, *value, value.length());
}
*chars_written = nbytes;
@ -380,7 +380,7 @@ size_t StringBytes::Write(Isolate* isolate,
auto ext = str->GetExternalOneByteStringResource();
nbytes = hex_decode(buf, buflen, ext->data(), ext->length());
} else {
String::Value value(str);
String::Value value(isolate, str);
nbytes = hex_decode(buf, buflen, *value, value.length());
}
*chars_written = nbytes;
@ -479,7 +479,7 @@ size_t StringBytes::Size(Isolate* isolate,
return str->Length() * sizeof(uint16_t);
case BASE64: {
String::Value value(str);
String::Value value(isolate, str);
return base64_decoded_size(*value, value.length());
}