diff options
author | James M Snell <jasnell@gmail.com> | 2020-02-26 01:37:33 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2020-03-02 21:58:36 +0300 |
commit | 0fac393d263fc7e2f4f054c9d4aab0c1c3cf00c8 (patch) | |
tree | f11f3380bc282709feed38b957e38ad3adf2a4a5 /src/node_http2.cc | |
parent | 68e36ade3de2205c583f2cc6a2d2ec192b75cc95 (diff) |
src: improve handling of internal field counting
Change suggested by bnoordhuis.
Improve handing of internal field counting by using enums.
Helps protect against future possible breakage if field
indexes are ever changed or added to.
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/31960
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/node_http2.cc')
-rw-r--r-- | src/node_http2.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/node_http2.cc b/src/node_http2.cc index c21adcfeb56..075d1b505e5 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -3025,14 +3025,14 @@ void Initialize(Local<Object> target, ping->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Http2Ping")); ping->Inherit(AsyncWrap::GetConstructorTemplate(env)); Local<ObjectTemplate> pingt = ping->InstanceTemplate(); - pingt->SetInternalFieldCount(1); + pingt->SetInternalFieldCount(Http2Session::Http2Ping::kInternalFieldCount); 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(1); + settingt->SetInternalFieldCount(AsyncWrap::kInternalFieldCount); env->set_http2settings_constructor_template(settingt); Local<FunctionTemplate> stream = FunctionTemplate::New(env->isolate()); @@ -3049,7 +3049,7 @@ void Initialize(Local<Object> target, stream->Inherit(AsyncWrap::GetConstructorTemplate(env)); StreamBase::AddMethods(env, stream); Local<ObjectTemplate> streamt = stream->InstanceTemplate(); - streamt->SetInternalFieldCount(StreamBase::kStreamBaseFieldCount); + streamt->SetInternalFieldCount(StreamBase::kInternalFieldCount); env->set_http2stream_constructor_template(streamt); target->Set(context, FIXED_ONE_BYTE_STRING(env->isolate(), "Http2Stream"), @@ -3058,7 +3058,8 @@ void Initialize(Local<Object> target, Local<FunctionTemplate> session = env->NewFunctionTemplate(Http2Session::New); session->SetClassName(http2SessionClassName); - session->InstanceTemplate()->SetInternalFieldCount(1); + session->InstanceTemplate()->SetInternalFieldCount( + Http2Session::kInternalFieldCount); session->Inherit(AsyncWrap::GetConstructorTemplate(env)); env->SetProtoMethod(session, "origin", Http2Session::Origin); env->SetProtoMethod(session, "altsvc", Http2Session::AltSvc); |