src: allow top-level calls into JSStream
Allow `JSStream` instances to be used more flexibly by explicitly enabling calls that have no JS stack below them. PR-URL: https://github.com/nodejs/node/pull/16269 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
ba4a0a6f5f
commit
127f83ab8d
@ -45,6 +45,8 @@ AsyncWrap* JSStream::GetAsyncWrap() {
|
|||||||
|
|
||||||
|
|
||||||
bool JSStream::IsAlive() {
|
bool JSStream::IsAlive() {
|
||||||
|
HandleScope scope(env()->isolate());
|
||||||
|
Context::Scope context_scope(env()->context());
|
||||||
v8::Local<v8::Value> fn = object()->Get(env()->isalive_string());
|
v8::Local<v8::Value> fn = object()->Get(env()->isalive_string());
|
||||||
if (!fn->IsFunction())
|
if (!fn->IsFunction())
|
||||||
return false;
|
return false;
|
||||||
@ -54,18 +56,24 @@ bool JSStream::IsAlive() {
|
|||||||
|
|
||||||
|
|
||||||
bool JSStream::IsClosing() {
|
bool JSStream::IsClosing() {
|
||||||
|
HandleScope scope(env()->isolate());
|
||||||
|
Context::Scope context_scope(env()->context());
|
||||||
return MakeCallback(env()->isclosing_string(), 0, nullptr)
|
return MakeCallback(env()->isclosing_string(), 0, nullptr)
|
||||||
.ToLocalChecked()->IsTrue();
|
.ToLocalChecked()->IsTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int JSStream::ReadStart() {
|
int JSStream::ReadStart() {
|
||||||
|
HandleScope scope(env()->isolate());
|
||||||
|
Context::Scope context_scope(env()->context());
|
||||||
return MakeCallback(env()->onreadstart_string(), 0, nullptr)
|
return MakeCallback(env()->onreadstart_string(), 0, nullptr)
|
||||||
.ToLocalChecked()->Int32Value();
|
.ToLocalChecked()->Int32Value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int JSStream::ReadStop() {
|
int JSStream::ReadStop() {
|
||||||
|
HandleScope scope(env()->isolate());
|
||||||
|
Context::Scope context_scope(env()->context());
|
||||||
return MakeCallback(env()->onreadstop_string(), 0, nullptr)
|
return MakeCallback(env()->onreadstop_string(), 0, nullptr)
|
||||||
.ToLocalChecked()->Int32Value();
|
.ToLocalChecked()->Int32Value();
|
||||||
}
|
}
|
||||||
@ -73,6 +81,7 @@ int JSStream::ReadStop() {
|
|||||||
|
|
||||||
int JSStream::DoShutdown(ShutdownWrap* req_wrap) {
|
int JSStream::DoShutdown(ShutdownWrap* req_wrap) {
|
||||||
HandleScope scope(env()->isolate());
|
HandleScope scope(env()->isolate());
|
||||||
|
Context::Scope context_scope(env()->context());
|
||||||
|
|
||||||
Local<Value> argv[] = {
|
Local<Value> argv[] = {
|
||||||
req_wrap->object()
|
req_wrap->object()
|
||||||
@ -93,6 +102,7 @@ int JSStream::DoWrite(WriteWrap* w,
|
|||||||
CHECK_EQ(send_handle, nullptr);
|
CHECK_EQ(send_handle, nullptr);
|
||||||
|
|
||||||
HandleScope scope(env()->isolate());
|
HandleScope scope(env()->isolate());
|
||||||
|
Context::Scope context_scope(env()->context());
|
||||||
|
|
||||||
Local<Array> bufs_arr = Array::New(env()->isolate(), count);
|
Local<Array> bufs_arr = Array::New(env()->isolate(), count);
|
||||||
Local<Object> buf;
|
Local<Object> buf;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user