Skip to content

Commit a97e79c

Browse files
danbevMylesBorins
authored andcommitted
crypto: add SET_INTEGER_CONSANT macro
This commit introduces a SET_INTEGER_CONSANT macro to reduce some code duplication in SecureContext::Initialize. PR-URL: #23687 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent 1747e47 commit a97e79c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/node_crypto.cc

+10-10
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,16 @@ void SecureContext::Initialize(Environment* env, Local<Object> target) {
353353
env->SetProtoMethodNoSideEffect(t, "getCertificate", GetCertificate<true>);
354354
env->SetProtoMethodNoSideEffect(t, "getIssuer", GetCertificate<false>);
355355

356-
t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kTicketKeyReturnIndex"),
357-
Integer::NewFromUnsigned(env->isolate(), kTicketKeyReturnIndex));
358-
t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kTicketKeyHMACIndex"),
359-
Integer::NewFromUnsigned(env->isolate(), kTicketKeyHMACIndex));
360-
t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kTicketKeyAESIndex"),
361-
Integer::NewFromUnsigned(env->isolate(), kTicketKeyAESIndex));
362-
t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kTicketKeyNameIndex"),
363-
Integer::NewFromUnsigned(env->isolate(), kTicketKeyNameIndex));
364-
t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kTicketKeyIVIndex"),
365-
Integer::NewFromUnsigned(env->isolate(), kTicketKeyIVIndex));
356+
#define SET_INTEGER_CONSTANTS(name, value) \
357+
t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), name), \
358+
Integer::NewFromUnsigned(env->isolate(), value));
359+
SET_INTEGER_CONSTANTS("kTicketKeyReturnIndex", kTicketKeyReturnIndex);
360+
SET_INTEGER_CONSTANTS("kTicketKeyHMACIndex", kTicketKeyHMACIndex);
361+
SET_INTEGER_CONSTANTS("kTicketKeyAESIndex", kTicketKeyAESIndex);
362+
SET_INTEGER_CONSTANTS("kTicketKeyNameIndex", kTicketKeyNameIndex);
363+
SET_INTEGER_CONSTANTS("kTicketKeyIVIndex", kTicketKeyIVIndex);
364+
365+
#undef SET_INTEGER_CONSTANTS
366366

367367
Local<FunctionTemplate> ctx_getter_templ =
368368
FunctionTemplate::New(env->isolate(),

0 commit comments

Comments
 (0)