From 296be03c35f0f5cb48e089c1a9cc35ba72c6f5a3 Mon Sep 17 00:00:00 2001 From: js00070 <909645105@qq.com> Date: Tue, 5 Nov 2019 15:51:29 +0800 Subject: [PATCH] src: replace FIXED_ONE_BYTE_STRING call with env->something_string() replace FIXED_ONE_BYTE_STRING call with env->something_string() in src/api/environment.cc, src/api/hooks.cc and src/async_wrap.cc Fixes: https://github.com/nodejs/code-and-learn/issues/97 Refs: https://github.com/nodejs/code-and-learn/issues/97 --- src/api/environment.cc | 2 +- src/api/hooks.cc | 2 +- src/async_wrap.cc | 10 +++++----- src/env.h | 6 ++++++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/api/environment.cc b/src/api/environment.cc index 846e4a873da51c..3caaf246302b8f 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -319,7 +319,7 @@ Environment* CreateEnvironment(IsolateData* isolate_data, std::vector> parameters = { env->require_string(), - FIXED_ONE_BYTE_STRING(env->isolate(), "markBootstrapComplete")}; + env->mark_bootstrap_complete_string()}; std::vector> arguments = { env->native_module_require(), env->NewFunctionTemplate(MarkBootstrapComplete) diff --git a/src/api/hooks.cc b/src/api/hooks.cc index cec58cee00847c..89506d3137201e 100644 --- a/src/api/hooks.cc +++ b/src/api/hooks.cc @@ -47,7 +47,7 @@ int EmitExit(Environment* env) { Local process_object = env->process_object(); process_object ->Set(env->context(), - FIXED_ONE_BYTE_STRING(env->isolate(), "_exiting"), + env->exiting_string(), True(env->isolate())) .Check(); diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 8410dd2e0d8c65..eb19e977f50565 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -314,12 +314,12 @@ static void SetupHooks(const FunctionCallbackInfo& args) { { Local ctor = FunctionTemplate::New(env->isolate()); - ctor->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "PromiseWrap")); + ctor->SetClassName(env->promise_wrap_string()); Local promise_wrap_template = ctor->InstanceTemplate(); promise_wrap_template->SetInternalFieldCount( PromiseWrap::kInternalFieldCount); promise_wrap_template->SetAccessor( - FIXED_ONE_BYTE_STRING(env->isolate(), "isChainedPromise"), + env->ischained_promise_string(), PromiseWrap::getIsChainedPromise); env->set_promise_wrap_template(promise_wrap_template); } @@ -447,7 +447,7 @@ Local AsyncWrap::GetConstructorTemplate(Environment* env) { Local tmpl = env->async_wrap_ctor_template(); if (tmpl.IsEmpty()) { tmpl = env->NewFunctionTemplate(nullptr); - tmpl->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "AsyncWrap")); + tmpl->SetClassName(env->async_wrap_string()); env->SetProtoMethod(tmpl, "getAsyncId", AsyncWrap::GetAsyncId); env->SetProtoMethod(tmpl, "asyncReset", AsyncWrap::AsyncReset); env->SetProtoMethod(tmpl, "getProviderType", AsyncWrap::GetProviderType); @@ -508,7 +508,7 @@ void AsyncWrap::Initialize(Local target, env->async_hooks()->async_ids_stack().GetJSArray()).Check(); target->Set(context, - FIXED_ONE_BYTE_STRING(env->isolate(), "owner_symbol"), + env->owner_symbol_string(), env->owner_symbol()).Check(); Local constants = Object::New(isolate); @@ -552,7 +552,7 @@ void AsyncWrap::Initialize(Local target, // AsyncWrapObject::Initialize() or AsyncWrapObject::GetConstructorTemplate() // function. { - auto class_name = FIXED_ONE_BYTE_STRING(env->isolate(), "AsyncWrap"); + auto class_name = env->async_wrap_string(); auto function_template = env->NewFunctionTemplate(AsyncWrapObject::New); function_template->SetClassName(class_name); function_template->Inherit(AsyncWrap::GetConstructorTemplate(env)); diff --git a/src/env.h b/src/env.h index a649675c7cc902..2ad8a6b40c5aa4 100644 --- a/src/env.h +++ b/src/env.h @@ -174,6 +174,7 @@ constexpr size_t kFsStatsBufferLength = V(args_string, "args") \ V(asn1curve_string, "asn1Curve") \ V(async_ids_stack_string, "async_ids_stack") \ + V(async_wrap_string, "AsyncWrap") \ V(bits_string, "bits") \ V(buffer_string, "buffer") \ V(bytes_parsed_string, "bytesParsed") \ @@ -226,6 +227,7 @@ constexpr size_t kFsStatsBufferLength = V(error_string, "error") \ V(exchange_string, "exchange") \ V(exit_code_string, "exitCode") \ + V(exiting_string, "_exiting") \ V(expire_string, "expire") \ V(exponent_string, "exponent") \ V(exports_string, "exports") \ @@ -259,6 +261,7 @@ constexpr size_t kFsStatsBufferLength = V(internal_string, "internal") \ V(ipv4_string, "IPv4") \ V(ipv6_string, "IPv6") \ + V(ischained_promise_string, "isChainedPromise") \ V(isclosing_string, "isClosing") \ V(issuer_string, "issuer") \ V(issuercert_string, "issuerCertificate") \ @@ -267,6 +270,7 @@ constexpr size_t kFsStatsBufferLength = V(library_string, "library") \ V(mac_string, "mac") \ V(main_string, "main") \ + V(mark_bootstrap_complete_string, "markBootstrapComplete") \ V(max_buffer_string, "maxBuffer") \ V(message_port_constructor_string, "MessagePort") \ V(message_port_string, "messagePort") \ @@ -304,6 +308,7 @@ constexpr size_t kFsStatsBufferLength = V(options_string, "options") \ V(order_string, "order") \ V(output_string, "output") \ + V(owner_symbol_string, "owner_symbol") \ V(parse_error_string, "Parse Error") \ V(password_string, "password") \ V(path_string, "path") \ @@ -320,6 +325,7 @@ constexpr size_t kFsStatsBufferLength = V(priority_string, "priority") \ V(process_string, "process") \ V(promise_string, "promise") \ + V(promise_wrap_string, "PromiseWrap") \ V(pubkey_string, "pubkey") \ V(query_string, "query") \ V(raw_string, "raw") \