diff --git a/src/node_binding.h b/src/node_binding.h index b09b8a5e521b18..2901231090cce3 100644 --- a/src/node_binding.h +++ b/src/node_binding.h @@ -37,6 +37,7 @@ static_assert(static_cast(NM_F_LINKED) == V(contextify) \ V(encoding_binding) \ V(fs) \ + V(fs_dir) \ V(messaging) \ V(mksnapshot) \ V(performance) \ diff --git a/src/node_dir.cc b/src/node_dir.cc index 10cde6067899c7..21d5b880ccee98 100644 --- a/src/node_dir.cc +++ b/src/node_dir.cc @@ -423,27 +423,29 @@ static void OpenDirSync(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(handle->object().As()); } -void Initialize(Local target, - Local unused, - Local context, - void* priv) { - Environment* env = Environment::GetCurrent(context); - Isolate* isolate = env->isolate(); +void CreatePerIsolateProperties(IsolateData* isolate_data, + Local target) { + Isolate* isolate = isolate_data->isolate(); - SetMethod(context, target, "opendir", OpenDir); - SetMethod(context, target, "opendirSync", OpenDirSync); + SetMethod(isolate, target, "opendir", OpenDir); + SetMethod(isolate, target, "opendirSync", OpenDirSync); // Create FunctionTemplate for DirHandle Local dir = NewFunctionTemplate(isolate, DirHandle::New); - dir->Inherit(AsyncWrap::GetConstructorTemplate(env)); + dir->Inherit(AsyncWrap::GetConstructorTemplate(isolate_data)); SetProtoMethod(isolate, dir, "read", DirHandle::Read); SetProtoMethod(isolate, dir, "close", DirHandle::Close); Local dirt = dir->InstanceTemplate(); dirt->SetInternalFieldCount(DirHandle::kInternalFieldCount); - SetConstructorFunction(context, target, "DirHandle", dir); - env->set_dir_instance_template(dirt); + SetConstructorFunction(isolate, target, "DirHandle", dir); + isolate_data->set_dir_instance_template(dirt); } +void CreatePerContextProperties(Local target, + Local unused, + Local context, + void* priv) {} + void RegisterExternalReferences(ExternalReferenceRegistry* registry) { registry->Register(OpenDir); registry->Register(OpenDirSync); @@ -456,6 +458,8 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) { } // end namespace node -NODE_BINDING_CONTEXT_AWARE_INTERNAL(fs_dir, node::fs_dir::Initialize) +NODE_BINDING_CONTEXT_AWARE_INTERNAL(fs_dir, + node::fs_dir::CreatePerContextProperties) +NODE_BINDING_PER_ISOLATE_INIT(fs_dir, node::fs_dir::CreatePerIsolateProperties) NODE_BINDING_EXTERNAL_REFERENCE(fs_dir, node::fs_dir::RegisterExternalReferences)