mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
src: create fs_dir per isolate properties
PR-URL: https://github.com/nodejs/node/pull/48655 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
1 parent
5c5834190a
commit
91aa9dd23a
2 files changed
+17
-12
No files matched your search
@@ -37,6 +37,7 @@ static_assert(static_cast<int>(NM_F_LINKED) ==
|
||||
V(contextify) \
|
||||
V(encoding_binding) \
|
||||
V(fs) \
|
||||
V(fs_dir) \
|
||||
V(messaging) \
|
||||
V(mksnapshot) \
|
||||
V(performance) \
|
||||
|
||||
+16
-12
@@ -423,27 +423,29 @@ static void OpenDirSync(const FunctionCallbackInfo<Value>& args) {
|
||||
args.GetReturnValue().Set(handle->object().As<Value>());
|
||||
}
|
||||
|
||||
void Initialize(Local<Object> target,
|
||||
Local<Value> unused,
|
||||
Local<Context> context,
|
||||
void* priv) {
|
||||
Environment* env = Environment::GetCurrent(context);
|
||||
Isolate* isolate = env->isolate();
|
||||
void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||
Local<ObjectTemplate> 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<FunctionTemplate> 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<ObjectTemplate> 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<Object> target,
|
||||
Local<Value> unused,
|
||||
Local<Context> 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)
|
||||
Reference in new issue
Block a user