From 81f8bea03853f54b1a0560b9c9a5c0a54e53813a Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sun, 3 Jun 2018 07:28:29 -0700 Subject: [PATCH 1/2] src: cleanup beforeExit for consistency --- src/env.h | 1 + src/node.cc | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/env.h b/src/env.h index 96252fa12a1397..f35da57f685225 100644 --- a/src/env.h +++ b/src/env.h @@ -114,6 +114,7 @@ struct PackageConfig { V(args_string, "args") \ V(async, "async") \ V(async_ids_stack_string, "async_ids_stack") \ + V(before_exit_string, "beforeExit") \ V(buffer_string, "buffer") \ V(bytes_string, "bytes") \ V(bytes_parsed_string, "bytesParsed") \ diff --git a/src/node.cc b/src/node.cc index bf3aae2d35f773..2f3aaee2e17fd1 100644 --- a/src/node.cc +++ b/src/node.cc @@ -4075,9 +4075,9 @@ 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"), + env->before_exit_string(), process_object->Get(exit_code)->ToInteger(env->context()).ToLocalChecked() }; MakeCallback(env->isolate(), @@ -4093,8 +4093,8 @@ int EmitExit(Environment* env) { Local process_object = env->process_object(); process_object->Set(env->exiting_string(), 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(exit_code)->Int32Value(); Local args[] = { env->exit_string(), @@ -4106,7 +4106,7 @@ 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(exit_code)->Int32Value(); } From 87084c1097f2695f9fadcce0b947880af723b543 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sun, 3 Jun 2018 08:43:59 -0700 Subject: [PATCH 2/2] [Squash] nits --- src/env.h | 3 --- src/node.cc | 16 ++++++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/env.h b/src/env.h index f35da57f685225..5fc3cba4b7de4d 100644 --- a/src/env.h +++ b/src/env.h @@ -114,7 +114,6 @@ struct PackageConfig { V(args_string, "args") \ V(async, "async") \ V(async_ids_stack_string, "async_ids_stack") \ - V(before_exit_string, "beforeExit") \ V(buffer_string, "buffer") \ V(bytes_string, "bytes") \ V(bytes_parsed_string, "bytesParsed") \ @@ -152,9 +151,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 2f3aaee2e17fd1..eeee230450d03a 100644 --- a/src/node.cc +++ b/src/node.cc @@ -4077,8 +4077,9 @@ void EmitBeforeExit(Environment* env) { Local process_object = env->process_object(); Local exit_code = env->exit_code_string(); Local args[] = { - env->before_exit_string(), - process_object->Get(exit_code)->ToInteger(env->context()).ToLocalChecked() + FIXED_ONE_BYTE_STRING(env->isolate(), "beforeExit"), + process_object->Get(env->context(), exit_code).ToLocalChecked() + ->ToInteger(env->context()).ToLocalChecked() }; MakeCallback(env->isolate(), process_object, "emit", arraysize(args), args, @@ -4091,13 +4092,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 exit_code = env->exit_code_string(); - int code = process_object->Get(exit_code)->Int32Value(); + 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) }; @@ -4106,7 +4109,8 @@ int EmitExit(Environment* env) { {0, 0}).ToLocalChecked(); // Reload exit code, it may be changed by `emit('exit')` - return process_object->Get(exit_code)->Int32Value(); + return process_object->Get(env->context(), exit_code).ToLocalChecked() + ->Int32Value(env->context()).ToChecked(); }