Skip to content

Commit

Permalink
src: replace FIXED_ONE_BYTE_STRING call with env->something_string()
Browse files Browse the repository at this point in the history
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: nodejs/code-and-learn#97
Refs: nodejs/code-and-learn#97
  • Loading branch information
js00070 committed Nov 5, 2019
1 parent 3a076ba commit 296be03
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ Environment* CreateEnvironment(IsolateData* isolate_data,

std::vector<Local<String>> parameters = {
env->require_string(),
FIXED_ONE_BYTE_STRING(env->isolate(), "markBootstrapComplete")};
env->mark_bootstrap_complete_string()};
std::vector<Local<Value>> arguments = {
env->native_module_require(),
env->NewFunctionTemplate(MarkBootstrapComplete)
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int EmitExit(Environment* env) {
Local<Object> process_object = env->process_object();
process_object
->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "_exiting"),
env->exiting_string(),
True(env->isolate()))
.Check();

Expand Down
10 changes: 5 additions & 5 deletions src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,12 @@ static void SetupHooks(const FunctionCallbackInfo<Value>& args) {
{
Local<FunctionTemplate> ctor =
FunctionTemplate::New(env->isolate());
ctor->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "PromiseWrap"));
ctor->SetClassName(env->promise_wrap_string());
Local<ObjectTemplate> 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);
}
Expand Down Expand Up @@ -447,7 +447,7 @@ Local<FunctionTemplate> AsyncWrap::GetConstructorTemplate(Environment* env) {
Local<FunctionTemplate> 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);
Expand Down Expand Up @@ -508,7 +508,7 @@ void AsyncWrap::Initialize(Local<Object> 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<Object> constants = Object::New(isolate);
Expand Down Expand Up @@ -552,7 +552,7 @@ void AsyncWrap::Initialize(Local<Object> 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));
Expand Down
6 changes: 6 additions & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -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") \
Expand Down Expand Up @@ -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") \
Expand Down Expand Up @@ -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") \
Expand All @@ -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") \
Expand Down Expand Up @@ -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") \
Expand All @@ -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") \
Expand Down

0 comments on commit 296be03

Please sign in to comment.