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 <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
SirR4T authored and targos committed Mar 30, 2018
1 parent 21e69d1 commit cae9ff2
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 @@ -232,7 +232,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 @@ -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<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 @@ -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 :
"<toString() threw exception>");
Expand Down Expand Up @@ -1797,13 +1799,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 @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,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 @@ -979,7 +979,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 @@ -1098,21 +1098,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 @@ -1143,7 +1143,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 @@ -4807,7 +4807,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 @@ -406,7 +406,7 @@ size_t StringBytes::Write(Isolate* isolate,
if (is_extern) {
nbytes = base64_decode(buf, buflen, data, external_nbytes);
} else {
String::Value value(str);
String::Value value(isolate, str);
nbytes = base64_decode(buf, buflen, *value, value.length());
}
if (chars_written != nullptr) {
Expand All @@ -418,7 +418,7 @@ size_t StringBytes::Write(Isolate* isolate,
if (is_extern) {
nbytes = hex_decode(buf, buflen, data, external_nbytes);
} else {
String::Value value(str);
String::Value value(isolate, str);
nbytes = hex_decode(buf, buflen, *value, value.length());
}
if (chars_written != nullptr) {
Expand Down Expand Up @@ -528,7 +528,7 @@ size_t StringBytes::Size(Isolate* isolate,
break;

case BASE64: {
String::Value value(str);
String::Value value(isolate, str);
data_size = base64_decoded_size(*value, value.length());
break;
}
Expand Down

0 comments on commit cae9ff2

Please sign in to comment.