Skip to content

Commit e41c511

Browse files
committed
src: replace ->To*(isolate) with ->To*(context).ToLocalChecked()
See #17244
1 parent 4ca4db0 commit e41c511

8 files changed

+21
-17
lines changed

Diff for: src/node.cc

+10-7
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ Local<Value> ErrnoException(Isolate* isolate,
589589
}
590590
e = Exception::Error(cons);
591591

592-
Local<Object> obj = e->ToObject(env->isolate());
592+
Local<Object> obj = e->ToObject(env->context()).ToLocalChecked();
593593
obj->Set(env->errno_string(), Integer::New(env->isolate(), errorno));
594594
obj->Set(env->code_string(), estring);
595595

@@ -751,7 +751,7 @@ Local<Value> WinapiErrnoException(Isolate* isolate,
751751
e = Exception::Error(message);
752752
}
753753

754-
Local<Object> obj = e->ToObject(env->isolate());
754+
Local<Object> obj = e->ToObject(env->context()).ToLocalChecked();
755755
obj->Set(env->errno_string(), Integer::New(isolate, errorno));
756756

757757
if (path != nullptr) {
@@ -1482,7 +1482,7 @@ static void ReportException(Environment* env,
14821482
if (er->IsUndefined() || er->IsNull()) {
14831483
trace_value = Undefined(env->isolate());
14841484
} else {
1485-
Local<Object> err_obj = er->ToObject(env->isolate());
1485+
Local<Object> err_obj = er->ToObject(env->context()).ToLocalChecked();
14861486

14871487
trace_value = err_obj->Get(env->stack_string());
14881488
arrow =
@@ -2301,7 +2301,8 @@ static void DLOpen(const FunctionCallbackInfo<Value>& args) {
23012301
return env->ThrowTypeError("flag argument must be an integer.");
23022302
}
23032303

2304-
Local<Object> module = args[0]->ToObject(env->isolate()); // Cast
2304+
Local<Object> module =
2305+
args[0]->ToObject(env->context()).ToLocalChecked(); // Cast
23052306
node::Utf8Value filename(env->isolate(), args[1]); // Cast
23062307
DLib dlib;
23072308
dlib.filename_ = *filename;
@@ -2319,7 +2320,8 @@ static void DLOpen(const FunctionCallbackInfo<Value>& args) {
23192320
dlib.Close();
23202321
#ifdef _WIN32
23212322
// Windows needs to add the filename into the error message
2322-
errmsg = String::Concat(errmsg, args[1]->ToString(env->isolate()));
2323+
errmsg = String::Concat(errmsg,
2324+
args[1]->ToString(env->context()).ToLocalChecked());
23232325
#endif // _WIN32
23242326
env->isolate()->ThrowException(Exception::Error(errmsg));
23252327
return;
@@ -2364,7 +2366,8 @@ static void DLOpen(const FunctionCallbackInfo<Value>& args) {
23642366
modlist_addon = mp;
23652367

23662368
Local<String> exports_string = env->exports_string();
2367-
Local<Object> exports = module->Get(exports_string)->ToObject(env->isolate());
2369+
Local<Object> exports =
2370+
module->Get(exports_string)->ToObject(env->context()).ToLocalChecked();
23682371

23692372
if (mp->nm_context_register_func != nullptr) {
23702373
mp->nm_context_register_func(exports, module, env->context(), mp->nm_priv);
@@ -4337,7 +4340,7 @@ void EmitBeforeExit(Environment* env) {
43374340
Local<String> exit_code = FIXED_ONE_BYTE_STRING(env->isolate(), "exitCode");
43384341
Local<Value> args[] = {
43394342
FIXED_ONE_BYTE_STRING(env->isolate(), "beforeExit"),
4340-
process_object->Get(exit_code)->ToInteger(env->isolate())
4343+
process_object->Get(exit_code)->ToInteger(env->context()).ToLocalChecked()
43414344
};
43424345
MakeCallback(env->isolate(),
43434346
process_object, "emit", arraysize(args), args,

Diff for: src/node_buffer.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ void Fill(const FunctionCallbackInfo<Value>& args) {
606606
return;
607607
}
608608

609-
str_obj = args[1]->ToString(env->isolate());
609+
str_obj = args[1]->ToString(env->context()).ToLocalChecked();
610610
enc = ParseEncoding(env->isolate(), args[4], UTF8);
611611
str_length =
612612
enc == UTF8 ? str_obj->Utf8Length() :
@@ -677,7 +677,7 @@ void StringWrite(const FunctionCallbackInfo<Value>& args) {
677677
if (!args[0]->IsString())
678678
return env->ThrowTypeError("Argument must be a string");
679679

680-
Local<String> str = args[0]->ToString(env->isolate());
680+
Local<String> str = args[0]->ToString(env->context()).ToLocalChecked();
681681

682682
size_t offset;
683683
size_t max_length;

Diff for: src/node_contextify.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ class ContextifyScript : public BaseObject {
621621
new ContextifyScript(env, args.This());
622622

623623
TryCatch try_catch(env->isolate());
624-
Local<String> code = args[0]->ToString(env->isolate());
624+
Local<String> code = args[0]->ToString(env->context()).ToLocalChecked();
625625

626626
Local<Value> options = args[1];
627627
MaybeLocal<String> filename = GetFilenameArg(env, options);

Diff for: src/node_file.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ static void Read(const FunctionCallbackInfo<Value>& args) {
12191219

12201220
char * buf = nullptr;
12211221

1222-
Local<Object> buffer_obj = args[1]->ToObject(env->isolate());
1222+
Local<Object> buffer_obj = args[1]->ToObject(env->context()).ToLocalChecked();
12231223
char *buffer_data = Buffer::Data(buffer_obj);
12241224
size_t buffer_length = Buffer::Length(buffer_obj);
12251225

Diff for: src/node_http_parser.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ class Parser : public AsyncWrap {
466466
enum http_errno err = HTTP_PARSER_ERRNO(&parser->parser_);
467467

468468
Local<Value> e = Exception::Error(env->parse_error_string());
469-
Local<Object> obj = e->ToObject(env->isolate());
469+
Local<Object> obj = e->ToObject(env->context()).ToLocalChecked();
470470
obj->Set(env->bytes_parsed_string(), Integer::New(env->isolate(), 0));
471471
obj->Set(env->code_string(),
472472
OneByteString(env->isolate(), http_errno_name(err)));

Diff for: src/node_zlib.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class ZCtx : public AsyncWrap {
178178
} else {
179179
CHECK(Buffer::HasInstance(args[1]));
180180
Local<Object> in_buf;
181-
in_buf = args[1]->ToObject(env->isolate());
181+
in_buf = args[1]->ToObject(env->context()).ToLocalChecked();
182182
in_off = args[2]->Uint32Value();
183183
in_len = args[3]->Uint32Value();
184184

@@ -187,7 +187,7 @@ class ZCtx : public AsyncWrap {
187187
}
188188

189189
CHECK(Buffer::HasInstance(args[4]));
190-
Local<Object> out_buf = args[4]->ToObject(env->isolate());
190+
Local<Object> out_buf = args[4]->ToObject(env->context()).ToLocalChecked();
191191
out_off = args[5]->Uint32Value();
192192
out_len = args[6]->Uint32Value();
193193
CHECK(Buffer::IsWithinBounds(out_off, out_len, Buffer::Length(out_buf)));

Diff for: src/process_wrap.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ class ProcessWrap : public HandleWrap {
143143
ProcessWrap* wrap;
144144
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
145145

146-
Local<Object> js_options = args[0]->ToObject(env->isolate());
146+
Local<Object> js_options =
147+
args[0]->ToObject(env->context()).ToLocalChecked();
147148

148149
uv_process_options_t options;
149150
memset(&options, 0, sizeof(uv_process_options_t));

Diff for: src/stream_base.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) {
127127
// Buffer chunk, no additional storage required
128128

129129
// String chunk
130-
Local<String> string = chunk->ToString(env->isolate());
130+
Local<String> string = chunk->ToString(env->context()).ToLocalChecked();
131131
enum encoding encoding = ParseEncoding(env->isolate(),
132132
chunks->Get(i * 2 + 1));
133133
size_t chunk_size;
@@ -179,7 +179,7 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) {
179179
char* str_storage = req_wrap->Extra(offset);
180180
size_t str_size = storage_size - offset;
181181

182-
Local<String> string = chunk->ToString(env->isolate());
182+
Local<String> string = chunk->ToString(env->context()).ToLocalChecked();
183183
enum encoding encoding = ParseEncoding(env->isolate(),
184184
chunks->Get(i * 2 + 1));
185185
str_size = StringBytes::Write(env->isolate(),

0 commit comments

Comments
 (0)