From 141aec956435372d26c69dce45078deb3a44370a Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 16 Oct 2018 07:53:13 +0200 Subject: [PATCH] crypto: add SET_INTEGER_CONSANT macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit introduces a SET_INTEGER_CONSANT macro to reduce some code duplication in SecureContext::Initialize. PR-URL: https://github.com/nodejs/node/pull/23687 Reviewed-By: Anna Henningsen Reviewed-By: Tobias Nießen Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani --- src/node_crypto.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 14b2dad9376c9a..989cf2d96a30cb 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -355,16 +355,16 @@ void SecureContext::Initialize(Environment* env, Local target) { env->SetProtoMethodNoSideEffect(t, "getCertificate", GetCertificate); env->SetProtoMethodNoSideEffect(t, "getIssuer", GetCertificate); - t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kTicketKeyReturnIndex"), - Integer::NewFromUnsigned(env->isolate(), kTicketKeyReturnIndex)); - t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kTicketKeyHMACIndex"), - Integer::NewFromUnsigned(env->isolate(), kTicketKeyHMACIndex)); - t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kTicketKeyAESIndex"), - Integer::NewFromUnsigned(env->isolate(), kTicketKeyAESIndex)); - t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kTicketKeyNameIndex"), - Integer::NewFromUnsigned(env->isolate(), kTicketKeyNameIndex)); - t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kTicketKeyIVIndex"), - Integer::NewFromUnsigned(env->isolate(), kTicketKeyIVIndex)); +#define SET_INTEGER_CONSTANTS(name, value) \ + t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), name), \ + Integer::NewFromUnsigned(env->isolate(), value)); + SET_INTEGER_CONSTANTS("kTicketKeyReturnIndex", kTicketKeyReturnIndex); + SET_INTEGER_CONSTANTS("kTicketKeyHMACIndex", kTicketKeyHMACIndex); + SET_INTEGER_CONSTANTS("kTicketKeyAESIndex", kTicketKeyAESIndex); + SET_INTEGER_CONSTANTS("kTicketKeyNameIndex", kTicketKeyNameIndex); + SET_INTEGER_CONSTANTS("kTicketKeyIVIndex", kTicketKeyIVIndex); + +#undef SET_INTEGER_CONSTANTS Local ctx_getter_templ = FunctionTemplate::New(env->isolate(),