From 499605618bcbadb5544a6a6f514ed836c03dc590 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 c3779c07cccb74..d0e17717d9c2cb 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -469,16 +469,16 @@ void SecureContext::Initialize(Environment* env, Local target) { env->SetProtoMethod(t, "getCertificate", SecureContext::GetCertificate); env->SetProtoMethod(t, "getIssuer", SecureContext::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(),