Skip to content

Commit cae9ff2

Browse files
SirR4Ttargos
authored andcommitted
src: fix upcoming V8 deprecation warnings
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]>
1 parent 21e69d1 commit cae9ff2

8 files changed

+22
-20
lines changed

src/inspector_js_api.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static void AsyncTaskScheduledWrapper(const FunctionCallbackInfo<Value>& args) {
232232

233233
CHECK(args[0]->IsString());
234234
Local<String> task_name = args[0].As<String>();
235-
String::Value task_name_value(task_name);
235+
String::Value task_name_value(args.GetIsolate(), task_name);
236236
StringView task_name_view(*task_name_value, task_name_value.length());
237237

238238
CHECK(args[1]->IsNumber());

src/node.cc

+7-5
Original file line numberDiff line numberDiff line change
@@ -1595,9 +1595,11 @@ void AppendExceptionLine(Environment* env,
15951595
ScriptOrigin origin = message->GetScriptOrigin();
15961596
node::Utf8Value filename(env->isolate(), message->GetScriptResourceName());
15971597
const char* filename_string = *filename;
1598-
int linenum = message->GetLineNumber();
1598+
int linenum = message->GetLineNumber(env->context()).FromJust();
15991599
// Print line of source code.
1600-
node::Utf8Value sourceline(env->isolate(), message->GetSourceLine());
1600+
MaybeLocal<String> source_line_maybe = message->GetSourceLine(env->context());
1601+
node::Utf8Value sourceline(env->isolate(),
1602+
source_line_maybe.ToLocalChecked());
16011603
const char* sourceline_string = *sourceline;
16021604
if (strstr(sourceline_string, "node-do-not-add-exception-line") != nullptr)
16031605
return;
@@ -1745,7 +1747,7 @@ static void ReportException(Environment* env,
17451747
name.IsEmpty() ||
17461748
name->IsUndefined()) {
17471749
// Not an error object. Just print as-is.
1748-
String::Utf8Value message(er);
1750+
String::Utf8Value message(env->isolate(), er);
17491751

17501752
PrintErrorString("%s\n", *message ? *message :
17511753
"<toString() threw exception>");
@@ -1797,13 +1799,13 @@ static Local<Value> ExecuteString(Environment* env,
17971799
exit(3);
17981800
}
17991801

1800-
Local<Value> result = script.ToLocalChecked()->Run();
1802+
MaybeLocal<Value> result = script.ToLocalChecked()->Run(env->context());
18011803
if (result.IsEmpty()) {
18021804
ReportException(env, try_catch);
18031805
exit(4);
18041806
}
18051807

1806-
return scope.Escape(result);
1808+
return scope.Escape(result.ToLocalChecked());
18071809
}
18081810

18091811

src/node_api.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3325,7 +3325,7 @@ class Work : public node::AsyncResource {
33253325
void* data = nullptr)
33263326
: AsyncResource(env->isolate,
33273327
async_resource,
3328-
*v8::String::Utf8Value(async_resource_name)),
3328+
*v8::String::Utf8Value(env->isolate, async_resource_name)),
33293329
_env(env),
33303330
_data(data),
33313331
_execute(execute),

src/node_buffer.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
946946
size_t result = haystack_length;
947947

948948
if (enc == UCS2) {
949-
String::Value needle_value(needle);
949+
String::Value needle_value(args.GetIsolate(), needle);
950950
if (*needle_value == nullptr)
951951
return args.GetReturnValue().Set(-1);
952952

@@ -979,7 +979,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
979979
}
980980
result *= 2;
981981
} else if (enc == UTF8) {
982-
String::Utf8Value needle_value(needle);
982+
String::Utf8Value needle_value(args.GetIsolate(), needle);
983983
if (*needle_value == nullptr)
984984
return args.GetReturnValue().Set(-1);
985985

src/node_contextify.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -1098,21 +1098,21 @@ class ContextifyScript : public BaseObject {
10981098
PersistentToLocal(env->isolate(), wrapped_script->script_);
10991099
Local<Script> script = unbound_script->BindToCurrentContext();
11001100

1101-
Local<Value> result;
1101+
MaybeLocal<Value> result;
11021102
bool timed_out = false;
11031103
bool received_signal = false;
11041104
if (break_on_sigint && timeout != -1) {
11051105
Watchdog wd(env->isolate(), timeout, &timed_out);
11061106
SigintWatchdog swd(env->isolate(), &received_signal);
1107-
result = script->Run();
1107+
result = script->Run(env->context());
11081108
} else if (break_on_sigint) {
11091109
SigintWatchdog swd(env->isolate(), &received_signal);
1110-
result = script->Run();
1110+
result = script->Run(env->context());
11111111
} else if (timeout != -1) {
11121112
Watchdog wd(env->isolate(), timeout, &timed_out);
1113-
result = script->Run();
1113+
result = script->Run(env->context());
11141114
} else {
1115-
result = script->Run();
1115+
result = script->Run(env->context());
11161116
}
11171117

11181118
if (timed_out || received_signal) {
@@ -1143,7 +1143,7 @@ class ContextifyScript : public BaseObject {
11431143
return false;
11441144
}
11451145

1146-
args.GetReturnValue().Set(result);
1146+
args.GetReturnValue().Set(result.ToLocalChecked());
11471147
return true;
11481148
}
11491149

src/node_crypto.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -4807,7 +4807,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
48074807

48084808
int padding = args[2]->Uint32Value();
48094809

4810-
String::Utf8Value passphrase(args[3]);
4810+
String::Utf8Value passphrase(args.GetIsolate(), args[3]);
48114811

48124812
unsigned char* out_value = nullptr;
48134813
size_t out_len = 0;

src/node_v8.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void UpdateHeapSpaceStatisticsBuffer(const FunctionCallbackInfo<Value>& args) {
114114

115115
void SetFlagsFromString(const FunctionCallbackInfo<Value>& args) {
116116
CHECK(args[0]->IsString());
117-
String::Utf8Value flags(args[0]);
117+
String::Utf8Value flags(args.GetIsolate(), args[0]);
118118
V8::SetFlagsFromString(*flags, flags.length());
119119
}
120120

src/string_bytes.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ size_t StringBytes::Write(Isolate* isolate,
406406
if (is_extern) {
407407
nbytes = base64_decode(buf, buflen, data, external_nbytes);
408408
} else {
409-
String::Value value(str);
409+
String::Value value(isolate, str);
410410
nbytes = base64_decode(buf, buflen, *value, value.length());
411411
}
412412
if (chars_written != nullptr) {
@@ -418,7 +418,7 @@ size_t StringBytes::Write(Isolate* isolate,
418418
if (is_extern) {
419419
nbytes = hex_decode(buf, buflen, data, external_nbytes);
420420
} else {
421-
String::Value value(str);
421+
String::Value value(isolate, str);
422422
nbytes = hex_decode(buf, buflen, *value, value.length());
423423
}
424424
if (chars_written != nullptr) {
@@ -528,7 +528,7 @@ size_t StringBytes::Size(Isolate* isolate,
528528
break;
529529

530530
case BASE64: {
531-
String::Value value(str);
531+
String::Value value(isolate, str);
532532
data_size = base64_decoded_size(*value, value.length());
533533
break;
534534
}

0 commit comments

Comments
 (0)