Skip to content
Closed
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
17 changes: 10 additions & 7 deletions src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,15 @@ static void SetupHooks(const FunctionCallbackInfo<Value>& args) {

Local<Object> fn_obj = args[0].As<Object>();

#define SET_HOOK_FN(name) \
Local<Value> name##_v = fn_obj->Get( \
env->context(), \
FIXED_ONE_BYTE_STRING(env->isolate(), #name)).ToLocalChecked(); \
CHECK(name##_v->IsFunction()); \
env->set_async_hooks_##name##_function(name##_v.As<Function>());
#define SET_HOOK_FN(name) \
do { \
Local<Value> v = \
fn_obj->Get(env->context(), \
FIXED_ONE_BYTE_STRING(env->isolate(), #name)) \
.ToLocalChecked(); \
CHECK(v->IsFunction()); \
env->set_async_hooks_##name##_function(v.As<Function>()); \
} while (0)

SET_HOOK_FN(init);
SET_HOOK_FN(before);
Expand Down Expand Up @@ -502,7 +505,7 @@ void AsyncWrap::Initialize(Local<Object> target,
Local<Object> constants = Object::New(isolate);
#define SET_HOOKS_CONSTANT(name) \
FORCE_SET_TARGET_FIELD( \
constants, #name, Integer::New(isolate, AsyncHooks::name));
constants, #name, Integer::New(isolate, AsyncHooks::name))

SET_HOOKS_CONSTANT(kInit);
SET_HOOKS_CONSTANT(kBefore);
Expand Down