Skip to content

Commit

Permalink
src: fix upcoming V8 deprecation warnings
Browse files Browse the repository at this point in the history
PR-URL: #19490
Fixes: #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>
  • Loading branch information
SirR4T authored and targos committed Mar 23, 2018
1 parent 43506f1 commit c6c957d
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/inspector_js_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
12 changes: 7 additions & 5 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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>");
Expand Down Expand Up @@ -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());
}


Expand Down
2 changes: 1 addition & 1 deletion src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
12 changes: 6 additions & 6 deletions src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -1131,7 +1131,7 @@ class ContextifyScript : public BaseObject {
return false;
}

args.GetReturnValue().Set(result);
args.GetReturnValue().Set(result.ToLocalChecked());
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/node_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
6 changes: 3 additions & 3 deletions src/string_bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}

Expand Down

0 comments on commit c6c957d

Please sign in to comment.