Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2020-12-15 22:52:17 +0300
committerJames M Snell <jasnell@gmail.com>2021-01-03 23:58:09 +0300
commit28fe1ef63512acd40cfd1dd15918db494c92f45f (patch)
treefb65e10e0c966e2484a3f2151870738499d575b7 /src/node_http2.cc
parent7cfa1bee418696c1c97c1f2466520ab4f4cc8791 (diff)
src: reduce duplicated boilerplate with new env utility fn
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: https://github.com/nodejs/node/pull/36536 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/node_http2.cc')
-rw-r--r--src/node_http2.cc14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/node_http2.cc b/src/node_http2.cc
index 1e2da918bf5..930167418e1 100644
--- a/src/node_http2.cc
+++ b/src/node_http2.cc
@@ -3054,9 +3054,6 @@ void Initialize(Local<Object> target,
env->SetMethod(target, "packSettings", PackSettings);
env->SetMethod(target, "setCallbackFunctions", SetCallbackFunctions);
- Local<String> http2SessionClassName =
- FIXED_ONE_BYTE_STRING(isolate, "Http2Session");
-
Local<FunctionTemplate> ping = FunctionTemplate::New(env->isolate());
ping->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Http2Ping"));
ping->Inherit(AsyncWrap::GetConstructorTemplate(env));
@@ -3065,14 +3062,12 @@ void Initialize(Local<Object> target,
env->set_http2ping_constructor_template(pingt);
Local<FunctionTemplate> setting = FunctionTemplate::New(env->isolate());
- setting->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Http2Setting"));
setting->Inherit(AsyncWrap::GetConstructorTemplate(env));
Local<ObjectTemplate> settingt = setting->InstanceTemplate();
settingt->SetInternalFieldCount(AsyncWrap::kInternalFieldCount);
env->set_http2settings_constructor_template(settingt);
Local<FunctionTemplate> stream = FunctionTemplate::New(env->isolate());
- stream->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Http2Stream"));
env->SetProtoMethod(stream, "id", Http2Stream::GetID);
env->SetProtoMethod(stream, "destroy", Http2Stream::Destroy);
env->SetProtoMethod(stream, "priority", Http2Stream::Priority);
@@ -3087,13 +3082,10 @@ void Initialize(Local<Object> target,
Local<ObjectTemplate> streamt = stream->InstanceTemplate();
streamt->SetInternalFieldCount(StreamBase::kInternalFieldCount);
env->set_http2stream_constructor_template(streamt);
- target->Set(context,
- FIXED_ONE_BYTE_STRING(env->isolate(), "Http2Stream"),
- stream->GetFunction(env->context()).ToLocalChecked()).Check();
+ env->SetConstructorFunction(target, "Http2Stream", stream);
Local<FunctionTemplate> session =
env->NewFunctionTemplate(Http2Session::New);
- session->SetClassName(http2SessionClassName);
session->InstanceTemplate()->SetInternalFieldCount(
Http2Session::kInternalFieldCount);
session->Inherit(AsyncWrap::GetConstructorTemplate(env));
@@ -3119,9 +3111,7 @@ void Initialize(Local<Object> target,
env->SetProtoMethod(
session, "remoteSettings",
Http2Session::RefreshSettings<nghttp2_session_get_remote_settings>);
- target->Set(context,
- http2SessionClassName,
- session->GetFunction(env->context()).ToLocalChecked()).Check();
+ env->SetConstructorFunction(target, "Http2Session", session);
Local<Object> constants = Object::New(isolate);