From af7164ebccd21d9fc5b0782e0427257f7637a4db Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 27 Jul 2018 14:35:39 +0200 Subject: lib,src: standardize `owner_symbol` for handles Instead of somtimes using an `owner` string to link from a native handle object to the corresponding JS object, standardize on a single symbol that fulfills this role. PR-URL: https://github.com/nodejs/node/pull/22002 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Jon Moss Reviewed-By: Matteo Collina Reviewed-By: Joyee Cheung Reviewed-By: Gus Caplan Reviewed-By: Minwoo Jung Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: Ali Ijaz Sheikh --- src/async_wrap.cc | 4 ++++ src/env.h | 2 +- src/tcp_wrap.cc | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 7ef3dafdf9..9d9d03b0fa 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -481,6 +481,10 @@ void AsyncWrap::Initialize(Local target, env->async_ids_stack_string(), env->async_hooks()->async_ids_stack().GetJSArray()).FromJust(); + target->Set(context, + FIXED_ONE_BYTE_STRING(env->isolate(), "owner_symbol"), + env->owner_symbol()).FromJust(); + Local constants = Object::New(isolate); #define SET_HOOKS_CONSTANT(name) \ FORCE_SET_TARGET_FIELD( \ diff --git a/src/env.h b/src/env.h index 8e6da729c4..290ac89fb5 100644 --- a/src/env.h +++ b/src/env.h @@ -111,6 +111,7 @@ struct PackageConfig { // for the sake of convenience. #define PER_ISOLATE_SYMBOL_PROPERTIES(V) \ V(handle_onclose_symbol, "handle_onclose") \ + V(owner_symbol, "owner") \ // Strings are per-isolate primitives but Environment proxies them // for the sake of convenience. Strings should be ASCII-only. @@ -234,7 +235,6 @@ struct PackageConfig { V(openssl_error_stack, "opensslErrorStack") \ V(output_string, "output") \ V(order_string, "order") \ - V(owner_string, "owner") \ V(parse_error_string, "Parse Error") \ V(password_string, "password") \ V(path_string, "path") \ diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 805e566bfa..e817087d97 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -81,7 +81,7 @@ void TCPWrap::Initialize(Local target, // Init properties t->InstanceTemplate()->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "reading"), Boolean::New(env->isolate(), false)); - t->InstanceTemplate()->Set(env->owner_string(), Null(env->isolate())); + t->InstanceTemplate()->Set(env->owner_symbol(), Null(env->isolate())); t->InstanceTemplate()->Set(env->onread_string(), Null(env->isolate())); t->InstanceTemplate()->Set(env->onconnection_string(), Null(env->isolate())); -- cgit v1.2.3