Skip to content

Commit af07964

Browse files
SirR4Tblattersturm
authored andcommitted
src: fix upcoming V8 deprecation warnings
PR-URL: nodejs#19490 Fixes: nodejs#18909 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent a14e56b commit af07964

8 files changed

+23
-27
lines changed

src/inspector_js_api.cc

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

239239
CHECK(args[0]->IsString());
240240
Local<String> task_name = args[0].As<String>();
241-
String::Value task_name_value(task_name);
241+
String::Value task_name_value(args.GetIsolate(), task_name);
242242
StringView task_name_view(*task_name_value, task_name_value.length());
243243

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

src/node.cc

+7-5
Original file line numberDiff line numberDiff line change
@@ -1606,9 +1606,11 @@ void AppendExceptionLine(Environment* env,
16061606
ScriptOrigin origin = message->GetScriptOrigin();
16071607
node::Utf8Value filename(env->isolate(), message->GetScriptResourceName());
16081608
const char* filename_string = *filename;
1609-
int linenum = message->GetLineNumber();
1609+
int linenum = message->GetLineNumber(env->context()).FromJust();
16101610
// Print line of source code.
1611-
node::Utf8Value sourceline(env->isolate(), message->GetSourceLine());
1611+
MaybeLocal<String> source_line_maybe = message->GetSourceLine(env->context());
1612+
node::Utf8Value sourceline(env->isolate(),
1613+
source_line_maybe.ToLocalChecked());
16121614
const char* sourceline_string = *sourceline;
16131615

16141616
// Because of how node modules work, all scripts are wrapped with a
@@ -1752,7 +1754,7 @@ static void ReportException(Environment* env,
17521754
name.IsEmpty() ||
17531755
name->IsUndefined()) {
17541756
// Not an error object. Just print as-is.
1755-
String::Utf8Value message(er);
1757+
String::Utf8Value message(env->isolate(), er);
17561758

17571759
PrintErrorString("%s\n", *message ? *message :
17581760
"<toString() threw exception>");
@@ -1800,13 +1802,13 @@ static Local<Value> ExecuteString(Environment* env,
18001802
exit(3);
18011803
}
18021804

1803-
Local<Value> result = script.ToLocalChecked()->Run();
1805+
MaybeLocal<Value> result = script.ToLocalChecked()->Run(env->context());
18041806
if (result.IsEmpty()) {
18051807
ReportException(env, try_catch);
18061808
exit(4);
18071809
}
18081810

1809-
return scope.Escape(result);
1811+
return scope.Escape(result.ToLocalChecked());
18101812
}
18111813

18121814

src/node_api.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3359,7 +3359,7 @@ class Work : public node::AsyncResource {
33593359
void* data = nullptr)
33603360
: AsyncResource(env->isolate,
33613361
async_resource,
3362-
*v8::String::Utf8Value(async_resource_name)),
3362+
*v8::String::Utf8Value(env->isolate, async_resource_name)),
33633363
_env(env),
33643364
_data(data),
33653365
_execute(execute),

src/node_buffer.cc

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

10041004
if (enc == UCS2) {
1005-
String::Value needle_value(needle);
1005+
String::Value needle_value(args.GetIsolate(), needle);
10061006
if (*needle_value == nullptr)
10071007
return args.GetReturnValue().Set(-1);
10081008

@@ -1035,7 +1035,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
10351035
}
10361036
result *= 2;
10371037
} else if (enc == UTF8) {
1038-
String::Utf8Value needle_value(needle);
1038+
String::Utf8Value needle_value(args.GetIsolate(), needle);
10391039
if (*needle_value == nullptr)
10401040
return args.GetReturnValue().Set(-1);
10411041

src/node_contextify.cc

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

982-
Local<Value> result;
982+
MaybeLocal<Value> result;
983983
bool timed_out = false;
984984
bool received_signal = false;
985985
if (break_on_sigint && timeout != -1) {
986986
Watchdog wd(env->isolate(), timeout, &timed_out);
987987
SigintWatchdog swd(env->isolate(), &received_signal);
988-
result = script->Run();
988+
result = script->Run(env->context());
989989
} else if (break_on_sigint) {
990990
SigintWatchdog swd(env->isolate(), &received_signal);
991-
result = script->Run();
991+
result = script->Run(env->context());
992992
} else if (timeout != -1) {
993993
Watchdog wd(env->isolate(), timeout, &timed_out);
994-
result = script->Run();
994+
result = script->Run(env->context());
995995
} else {
996-
result = script->Run();
996+
result = script->Run(env->context());
997997
}
998998

999999
if (timed_out || received_signal) {
@@ -1024,7 +1024,7 @@ class ContextifyScript : public BaseObject {
10241024
return false;
10251025
}
10261026

1027-
args.GetReturnValue().Set(result);
1027+
args.GetReturnValue().Set(result.ToLocalChecked());
10281028
return true;
10291029
}
10301030

src/node_crypto.cc

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

47424742
int padding = args[2]->Uint32Value();
47434743

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

47464746
unsigned char* out_value = nullptr;
47474747
size_t out_len = 0;

src/node_v8.cc

+2-8
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,8 @@ void UpdateHeapSpaceStatisticsBuffer(const FunctionCallbackInfo<Value>& args) {
113113

114114

115115
void SetFlagsFromString(const FunctionCallbackInfo<Value>& args) {
116-
Environment* env = Environment::GetCurrent(args);
117-
118-
if (args.Length() < 1)
119-
return env->ThrowTypeError("v8 flag is required");
120-
if (!args[0]->IsString())
121-
return env->ThrowTypeError("v8 flag must be a string");
122-
123-
String::Utf8Value flags(args[0]);
116+
CHECK(args[0]->IsString());
117+
String::Utf8Value flags(args.GetIsolate(), args[0]);
124118
V8::SetFlagsFromString(*flags, flags.length());
125119
}
126120

src/string_bytes.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ size_t StringBytes::Write(Isolate* isolate,
410410
if (is_extern) {
411411
nbytes = base64_decode(buf, buflen, data, external_nbytes);
412412
} else {
413-
String::Value value(str);
413+
String::Value value(isolate, str);
414414
nbytes = base64_decode(buf, buflen, *value, value.length());
415415
}
416416
if (chars_written != nullptr) {
@@ -422,7 +422,7 @@ size_t StringBytes::Write(Isolate* isolate,
422422
if (is_extern) {
423423
nbytes = hex_decode(buf, buflen, data, external_nbytes);
424424
} else {
425-
String::Value value(str);
425+
String::Value value(isolate, str);
426426
nbytes = hex_decode(buf, buflen, *value, value.length());
427427
}
428428
if (chars_written != nullptr) {
@@ -532,7 +532,7 @@ size_t StringBytes::Size(Isolate* isolate,
532532
break;
533533

534534
case BASE64: {
535-
String::Value value(str);
535+
String::Value value(isolate, str);
536536
data_size = base64_decoded_size(*value, value.length());
537537
break;
538538
}

0 commit comments

Comments
 (0)