Skip to content
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: add a constructor overload for CallbackScope #39768

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/api/async_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ async_id AsyncResource::get_trigger_async_id() const {
return async_context_.trigger_async_id;
}

// TODO(addaleax): We shouldn’t need to use env_->isolate() if we’re just going
// to end up using the Isolate* to figure out the Environment* again.
AsyncResource::CallbackScope::CallbackScope(AsyncResource* res)
: node::CallbackScope(res->env_->isolate(),
: node::CallbackScope(res->env_,
res->resource_.Get(res->env_->isolate()),
res->async_context_) {}

Expand Down
9 changes: 7 additions & 2 deletions src/api/callback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ using v8::String;
using v8::Value;

CallbackScope::CallbackScope(Isolate* isolate,
Local<Object> object,
async_context async_context)
: CallbackScope(Environment::GetCurrent(isolate), object, async_context) {}

CallbackScope::CallbackScope(Environment* env,
RaisinTen marked this conversation as resolved.
Show resolved Hide resolved
Local<Object> object,
async_context asyncContext)
: private_(new InternalCallbackScope(Environment::GetCurrent(isolate),
: private_(new InternalCallbackScope(env,
object,
asyncContext)),
try_catch_(isolate) {
try_catch_(env->isolate()) {
try_catch_.SetVerbose(true);
}

Expand Down
3 changes: 3 additions & 0 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,9 @@ class NODE_EXTERN CallbackScope {
CallbackScope(v8::Isolate* isolate,
v8::Local<v8::Object> resource,
async_context asyncContext);
CallbackScope(Environment* env,
RaisinTen marked this conversation as resolved.
Show resolved Hide resolved
v8::Local<v8::Object> resource,
async_context asyncContext);
~CallbackScope();

void operator=(const CallbackScope&) = delete;
Expand Down
2 changes: 1 addition & 1 deletion src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ class AsyncContext {
class CallbackScope : public node::CallbackScope {
public:
explicit CallbackScope(AsyncContext* async_context)
: node::CallbackScope(async_context->node_env()->isolate(),
: node::CallbackScope(async_context->node_env(),
async_context->resource_.Get(
async_context->node_env()->isolate()),
async_context->async_context()) {}
Expand Down