diff options
author | legendecas <legendecas@gmail.com> | 2022-08-01 19:01:02 +0300 |
---|---|---|
committer | legendecas <legendecas@gmail.com> | 2022-08-01 19:01:02 +0300 |
commit | a7e5b413efd5f98d4b9acf39ff5e87ddbd8c63ff (patch) | |
tree | b3ae111dcfe5ab8db74df9d355aa009a9ea024c7 /src/README.md | |
parent | 7f7a899fa5f3b192d4f503f6602f24f7ff4ec57a (diff) |
src: split property helpers from node::Environment
PR-URL: https://github.com/nodejs/node/pull/44056
Refs: https://github.com/nodejs/node/issues/42528
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Feng Yu <F3n67u@outlook.com>
Diffstat (limited to 'src/README.md')
-rw-r--r-- | src/README.md | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/README.md b/src/README.md index 8162deecb3c..314cd343418 100644 --- a/src/README.md +++ b/src/README.md @@ -390,32 +390,33 @@ void Initialize(Local<Object> target, void* priv) { Environment* env = Environment::GetCurrent(context); - env->SetMethod(target, "getaddrinfo", GetAddrInfo); - env->SetMethod(target, "getnameinfo", GetNameInfo); + SetMethod(context, target, "getaddrinfo", GetAddrInfo); + SetMethod(context, target, "getnameinfo", GetNameInfo); // 'SetMethodNoSideEffect' means that debuggers can safely execute this // function for e.g. previews. - env->SetMethodNoSideEffect(target, "canonicalizeIP", CanonicalizeIP); + SetMethodNoSideEffect(context, target, "canonicalizeIP", CanonicalizeIP); // ... more code ... + Isolate* isolate = env->isolate(); // Building the `ChannelWrap` class for JS: Local<FunctionTemplate> channel_wrap = - env->NewFunctionTemplate(ChannelWrap::New); + NewFunctionTemplate(isolate, ChannelWrap::New); // Allow for 1 internal field, see `BaseObject` for details on this: channel_wrap->InstanceTemplate()->SetInternalFieldCount(1); channel_wrap->Inherit(AsyncWrap::GetConstructorTemplate(env)); // Set various methods on the class (i.e. on the prototype): - env->SetProtoMethod(channel_wrap, "queryAny", Query<QueryAnyWrap>); - env->SetProtoMethod(channel_wrap, "queryA", Query<QueryAWrap>); + SetProtoMethod(isolate, channel_wrap, "queryAny", Query<QueryAnyWrap>); + SetProtoMethod(isolate, channel_wrap, "queryA", Query<QueryAWrap>); // ... - env->SetProtoMethod(channel_wrap, "querySoa", Query<QuerySoaWrap>); - env->SetProtoMethod(channel_wrap, "getHostByAddr", Query<GetHostByAddrWrap>); + SetProtoMethod(isolate, channel_wrap, "querySoa", Query<QuerySoaWrap>); + SetProtoMethod(isolate, channel_wrap, "getHostByAddr", Query<GetHostByAddrWrap>); - env->SetProtoMethodNoSideEffect(channel_wrap, "getServers", GetServers); + SetProtoMethodNoSideEffect(isolate, channel_wrap, "getServers", GetServers); - env->SetConstructorFunction(target, "ChannelWrap", channel_wrap); + SetConstructorFunction(context, target, "ChannelWrap", channel_wrap); } // Run the `Initialize` function when loading this module through |