From 120c51e8f3ed76f82fcb078894264210bca04267 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 This commit introduces a SET_INTEGER_CONSANT macro to reduce some code duplication in SecureContext::Initialize. --- 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 7d2cba22576a72..e1546ebd5d0e70 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -348,16 +348,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(),