-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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: replace ->To*(isolate) with ->To*(context).ToLocalChecked() #17343
Changes from 1 commit
e41c511
f9107cc
60f4711
19a1b2e
1926bcf
096cbbf
dbee7b0
d7cc341
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
See #17244
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -589,7 +589,7 @@ Local<Value> ErrnoException(Isolate* isolate, | |||||||
} | ||||||||
e = Exception::Error(cons); | ||||||||
|
||||||||
Local<Object> obj = e->ToObject(env->isolate()); | ||||||||
Local<Object> obj = e->ToObject(env->context()).ToLocalChecked(); | ||||||||
obj->Set(env->errno_string(), Integer::New(env->isolate(), errorno)); | ||||||||
obj->Set(env->code_string(), estring); | ||||||||
|
||||||||
|
@@ -751,7 +751,7 @@ Local<Value> WinapiErrnoException(Isolate* isolate, | |||||||
e = Exception::Error(message); | ||||||||
} | ||||||||
|
||||||||
Local<Object> obj = e->ToObject(env->isolate()); | ||||||||
Local<Object> obj = e->ToObject(env->context()).ToLocalChecked(); | ||||||||
obj->Set(env->errno_string(), Integer::New(isolate, errorno)); | ||||||||
|
||||||||
if (path != nullptr) { | ||||||||
|
@@ -1482,7 +1482,7 @@ static void ReportException(Environment* env, | |||||||
if (er->IsUndefined() || er->IsNull()) { | ||||||||
trace_value = Undefined(env->isolate()); | ||||||||
} else { | ||||||||
Local<Object> err_obj = er->ToObject(env->isolate()); | ||||||||
Local<Object> err_obj = er->ToObject(env->context()).ToLocalChecked(); | ||||||||
|
||||||||
trace_value = err_obj->Get(env->stack_string()); | ||||||||
arrow = | ||||||||
|
@@ -2301,7 +2301,8 @@ static void DLOpen(const FunctionCallbackInfo<Value>& args) { | |||||||
return env->ThrowTypeError("flag argument must be an integer."); | ||||||||
} | ||||||||
|
||||||||
Local<Object> module = args[0]->ToObject(env->isolate()); // Cast | ||||||||
Local<Object> module = | ||||||||
args[0]->ToObject(env->context()).ToLocalChecked(); // Cast | ||||||||
node::Utf8Value filename(env->isolate(), args[1]); // Cast | ||||||||
DLib dlib; | ||||||||
dlib.filename_ = *filename; | ||||||||
|
@@ -2319,7 +2320,8 @@ static void DLOpen(const FunctionCallbackInfo<Value>& args) { | |||||||
dlib.Close(); | ||||||||
#ifdef _WIN32 | ||||||||
// Windows needs to add the filename into the error message | ||||||||
errmsg = String::Concat(errmsg, args[1]->ToString(env->isolate())); | ||||||||
errmsg = String::Concat(errmsg, | ||||||||
args[1]->ToString(env->context()).ToLocalChecked()); | ||||||||
#endif // _WIN32 | ||||||||
env->isolate()->ThrowException(Exception::Error(errmsg)); | ||||||||
return; | ||||||||
|
@@ -2364,7 +2366,8 @@ static void DLOpen(const FunctionCallbackInfo<Value>& args) { | |||||||
modlist_addon = mp; | ||||||||
|
||||||||
Local<String> exports_string = env->exports_string(); | ||||||||
Local<Object> exports = module->Get(exports_string)->ToObject(env->isolate()); | ||||||||
Local<Object> exports = | ||||||||
module->Get(exports_string)->ToObject(env->context()).ToLocalChecked(); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're already here, you can feel free to also change the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I didn’t understand what you said. Local<Object> exports = module->Get(exports_string).As<Object>(); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you look at v8.h, you’ll see that there are two overloads of Lines 3166 to 3168 in cbaf59c
At some point, we’re going to use the latter here instead of If you want to see an example of how these conversions look like, you can take a look at #16247. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for detailed information.
I will check the header file properly after this. I update to add |
||||||||
|
||||||||
if (mp->nm_context_register_func != nullptr) { | ||||||||
mp->nm_context_register_func(exports, module, env->context(), mp->nm_priv); | ||||||||
|
@@ -4337,7 +4340,7 @@ void EmitBeforeExit(Environment* env) { | |||||||
Local<String> exit_code = FIXED_ONE_BYTE_STRING(env->isolate(), "exitCode"); | ||||||||
Local<Value> args[] = { | ||||||||
FIXED_ONE_BYTE_STRING(env->isolate(), "beforeExit"), | ||||||||
process_object->Get(exit_code)->ToInteger(env->isolate()) | ||||||||
process_object->Get(exit_code)->ToInteger(env->context()).ToLocalChecked() | ||||||||
}; | ||||||||
MakeCallback(env->isolate(), | ||||||||
process_object, "emit", arraysize(args), args, | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -621,7 +621,7 @@ class ContextifyScript : public BaseObject { | |
new ContextifyScript(env, args.This()); | ||
|
||
TryCatch try_catch(env->isolate()); | ||
Local<String> code = args[0]->ToString(env->isolate()); | ||
Local<String> code = args[0]->ToString(env->context()).ToLocalChecked(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is actually incorrect, I think (didn't try this out yet, so I might be wrong): new vm.Script({
toString() {
throw new Error();
}
}); would make So I think the two options are:
Either way, it would be nice if you could add a test that the code snippet above doesn't crash the process :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes it is.
So I added test case and fix it. |
||
|
||
Local<Value> options = args[1]; | ||
MaybeLocal<String> filename = GetFilenameArg(env, options); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1219,7 +1219,7 @@ static void Read(const FunctionCallbackInfo<Value>& args) { | |
|
||
char * buf = nullptr; | ||
|
||
Local<Object> buffer_obj = args[1]->ToObject(env->isolate()); | ||
Local<Object> buffer_obj = args[1]->ToObject(env->context()).ToLocalChecked(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean I should update as follow: Local<Object> buffer_obj = args[1]->ToObject(env->context()).ToLocalChecked(); to Local<Object> buffer_obj = args[1].As<Object>(); It is OK ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, exactly. If you know that something is an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for confirmation.
I didn't know that ! Thanks for letting me know. |
||
char *buffer_data = Buffer::Data(buffer_obj); | ||
size_t buffer_length = Buffer::Length(buffer_obj); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
Exception::Error
always returns an object, soe.As<Object>()
should also work fine (and is a bit simpler/a bit more performant)(This applies to a lot of other places in the PR too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review.
I see.
I didn't know that you could do it like that!