From 69cc26a8bae4f7d21fbe85ead840111141844373 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sun, 3 Jun 2018 07:28:29 -0700 Subject: [PATCH] src: cleanup beforeExit for consistency PR-URL: https://github.com/nodejs/node/pull/21113 Reviewed-By: Anna Henningsen --- src/env.h | 2 -- src/node.cc | 18 +++++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/env.h b/src/env.h index 9ad316c063ea72..12cf5b8855b4c1 100644 --- a/src/env.h +++ b/src/env.h @@ -160,9 +160,7 @@ struct PackageConfig { V(env_pairs_string, "envPairs") \ V(errno_string, "errno") \ V(error_string, "error") \ - V(exiting_string, "_exiting") \ V(exit_code_string, "exitCode") \ - V(exit_string, "exit") \ V(expire_string, "expire") \ V(exponent_string, "exponent") \ V(exports_string, "exports") \ diff --git a/src/node.cc b/src/node.cc index 927ec6023d0b6d..5d9b611b336c60 100644 --- a/src/node.cc +++ b/src/node.cc @@ -4135,10 +4135,11 @@ void EmitBeforeExit(Environment* env) { HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); Local process_object = env->process_object(); - Local exit_code = FIXED_ONE_BYTE_STRING(env->isolate(), "exitCode"); + Local exit_code = env->exit_code_string(); Local args[] = { FIXED_ONE_BYTE_STRING(env->isolate(), "beforeExit"), - process_object->Get(exit_code)->ToInteger(env->context()).ToLocalChecked() + process_object->Get(env->context(), exit_code).ToLocalChecked() + ->ToInteger(env->context()).ToLocalChecked() }; MakeCallback(env->isolate(), process_object, "emit", arraysize(args), args, @@ -4151,13 +4152,15 @@ int EmitExit(Environment* env) { HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); Local process_object = env->process_object(); - process_object->Set(env->exiting_string(), True(env->isolate())); + process_object->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "_exiting"), + True(env->isolate())); - Local exitCode = env->exit_code_string(); - int code = process_object->Get(exitCode)->Int32Value(); + Local exit_code = env->exit_code_string(); + int code = process_object->Get(env->context(), exit_code).ToLocalChecked() + ->Int32Value(env->context()).ToChecked(); Local args[] = { - env->exit_string(), + FIXED_ONE_BYTE_STRING(env->isolate(), "exit"), Integer::New(env->isolate(), code) }; @@ -4166,7 +4169,8 @@ int EmitExit(Environment* env) { {0, 0}).ToLocalChecked(); // Reload exit code, it may be changed by `emit('exit')` - return process_object->Get(exitCode)->Int32Value(); + return process_object->Get(env->context(), exit_code).ToLocalChecked() + ->Int32Value(env->context()).ToChecked(); }