Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: fix upcoming v8 deprecation warnings #19490

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1088,21 +1088,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 @@ -1133,7 +1133,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