Skip to content

Commit c6c957d

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 43506f1 commit c6c957d

8 files changed

+22
-20
lines changed

src/inspector_js_api.cc

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

231231
CHECK(args[0]->IsString());
232232
Local<String> task_name = args[0].As<String>();
233-
String::Value task_name_value(task_name);
233+
String::Value task_name_value(args.GetIsolate(), task_name);
234234
StringView task_name_view(*task_name_value, task_name_value.length());
235235

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

src/node.cc

+7-5
Original file line numberDiff line numberDiff line change
@@ -1269,9 +1269,11 @@ void AppendExceptionLine(Environment* env,
12691269
ScriptOrigin origin = message->GetScriptOrigin();
12701270
node::Utf8Value filename(env->isolate(), message->GetScriptResourceName());
12711271
const char* filename_string = *filename;
1272-
int linenum = message->GetLineNumber();
1272+
int linenum = message->GetLineNumber(env->context()).FromJust();
12731273
// Print line of source code.
1274-
node::Utf8Value sourceline(env->isolate(), message->GetSourceLine());
1274+
MaybeLocal<String> source_line_maybe = message->GetSourceLine(env->context());
1275+
node::Utf8Value sourceline(env->isolate(),
1276+
source_line_maybe.ToLocalChecked());
12751277
const char* sourceline_string = *sourceline;
12761278
if (strstr(sourceline_string, "node-do-not-add-exception-line") != nullptr)
12771279
return;
@@ -1419,7 +1421,7 @@ static void ReportException(Environment* env,
14191421
name.IsEmpty() ||
14201422
name->IsUndefined()) {
14211423
// Not an error object. Just print as-is.
1422-
String::Utf8Value message(er);
1424+
String::Utf8Value message(env->isolate(), er);
14231425

14241426
PrintErrorString("%s\n", *message ? *message :
14251427
"<toString() threw exception>");
@@ -1471,13 +1473,13 @@ static Local<Value> ExecuteString(Environment* env,
14711473
exit(3);
14721474
}
14731475

1474-
Local<Value> result = script.ToLocalChecked()->Run();
1476+
MaybeLocal<Value> result = script.ToLocalChecked()->Run(env->context());
14751477
if (result.IsEmpty()) {
14761478
ReportException(env, try_catch);
14771479
exit(4);
14781480
}
14791481

1480-
return scope.Escape(result);
1482+
return scope.Escape(result.ToLocalChecked());
14811483
}
14821484

14831485

src/node_api.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3315,7 +3315,7 @@ class Work : public node::AsyncResource {
33153315
void* data = nullptr)
33163316
: AsyncResource(env->isolate,
33173317
async_resource,
3318-
*v8::String::Utf8Value(async_resource_name)),
3318+
*v8::String::Utf8Value(env->isolate, async_resource_name)),
33193319
_env(env),
33203320
_data(data),
33213321
_execute(execute),

src/node_buffer.cc

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

856856
if (enc == UCS2) {
857-
String::Value needle_value(needle);
857+
String::Value needle_value(args.GetIsolate(), needle);
858858
if (*needle_value == nullptr)
859859
return args.GetReturnValue().Set(-1);
860860

@@ -887,7 +887,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
887887
}
888888
result *= 2;
889889
} else if (enc == UTF8) {
890-
String::Utf8Value needle_value(needle);
890+
String::Utf8Value needle_value(args.GetIsolate(), needle);
891891
if (*needle_value == nullptr)
892892
return args.GetReturnValue().Set(-1);
893893

src/node_contextify.cc

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

1089-
Local<Value> result;
1089+
MaybeLocal<Value> result;
10901090
bool timed_out = false;
10911091
bool received_signal = false;
10921092
if (break_on_sigint && timeout != -1) {
10931093
Watchdog wd(env->isolate(), timeout, &timed_out);
10941094
SigintWatchdog swd(env->isolate(), &received_signal);
1095-
result = script->Run();
1095+
result = script->Run(env->context());
10961096
} else if (break_on_sigint) {
10971097
SigintWatchdog swd(env->isolate(), &received_signal);
1098-
result = script->Run();
1098+
result = script->Run(env->context());
10991099
} else if (timeout != -1) {
11001100
Watchdog wd(env->isolate(), timeout, &timed_out);
1101-
result = script->Run();
1101+
result = script->Run(env->context());
11021102
} else {
1103-
result = script->Run();
1103+
result = script->Run(env->context());
11041104
}
11051105

11061106
if (timed_out || received_signal) {
@@ -1131,7 +1131,7 @@ class ContextifyScript : public BaseObject {
11311131
return false;
11321132
}
11331133

1134-
args.GetReturnValue().Set(result);
1134+
args.GetReturnValue().Set(result.ToLocalChecked());
11351135
return true;
11361136
}
11371137

src/node_crypto.cc

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

42564256
int padding = args[2]->Uint32Value();
42574257

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

42604260
unsigned char* out_value = nullptr;
42614261
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
@@ -369,7 +369,7 @@ size_t StringBytes::Write(Isolate* isolate,
369369
auto ext = str->GetExternalOneByteStringResource();
370370
nbytes = base64_decode(buf, buflen, ext->data(), ext->length());
371371
} else {
372-
String::Value value(str);
372+
String::Value value(isolate, str);
373373
nbytes = base64_decode(buf, buflen, *value, value.length());
374374
}
375375
*chars_written = nbytes;
@@ -380,7 +380,7 @@ size_t StringBytes::Write(Isolate* isolate,
380380
auto ext = str->GetExternalOneByteStringResource();
381381
nbytes = hex_decode(buf, buflen, ext->data(), ext->length());
382382
} else {
383-
String::Value value(str);
383+
String::Value value(isolate, str);
384384
nbytes = hex_decode(buf, buflen, *value, value.length());
385385
}
386386
*chars_written = nbytes;
@@ -479,7 +479,7 @@ size_t StringBytes::Size(Isolate* isolate,
479479
return str->Length() * sizeof(uint16_t);
480480

481481
case BASE64: {
482-
String::Value value(str);
482+
String::Value value(isolate, str);
483483
return base64_decoded_size(*value, value.length());
484484
}
485485

0 commit comments

Comments
 (0)