Skip to content

Commit

Permalink
fixup! src,lib: group properties used as constants from util binding
Browse files Browse the repository at this point in the history
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
  • Loading branch information
daeyeon committed Nov 23, 2022
1 parent 8b95729 commit 21e2ae8
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/node_util.cc
Expand Up @@ -381,28 +381,37 @@ void Initialize(Local<Object> target,
}

{
Local<ObjectTemplate> tmpl = ObjectTemplate::New(isolate);
Local<Object> constants = Object::New(env->isolate());
#define V(name) \
tmpl->Set(FIXED_ONE_BYTE_STRING(isolate, #name), \
Integer::New(isolate, Promise::PromiseState::name));
constants \
->Set(context, \
FIXED_ONE_BYTE_STRING(isolate, #name), \
Integer::New(isolate, Promise::PromiseState::name)) \
.Check();

V(kPending);
V(kFulfilled);
V(kRejected);
#undef V

#define V(name) \
tmpl->Set(FIXED_ONE_BYTE_STRING(isolate, #name), \
Integer::New(isolate, Environment::ExitInfoField::name));
constants \
->Set(context, \
FIXED_ONE_BYTE_STRING(isolate, #name), \
Integer::New(isolate, Environment::ExitInfoField::name)) \
.Check();

V(kExiting);
V(kExitCode);
V(kHasExitCode);
#undef V

#define V(name) \
tmpl->Set(FIXED_ONE_BYTE_STRING(isolate, #name), \
Integer::New(isolate, PropertyFilter::name));
constants \
->Set(context, \
FIXED_ONE_BYTE_STRING(isolate, #name), \
Integer::New(isolate, PropertyFilter::name)) \
.Check();

V(ALL_PROPERTIES);
V(ONLY_WRITABLE);
Expand All @@ -412,11 +421,7 @@ void Initialize(Local<Object> target,
V(SKIP_SYMBOLS);
#undef V

target
->Set(context,
env->constants_string(),
tmpl->NewInstance(context).ToLocalChecked())
.Check();
target->Set(context, env->constants_string(), constants).Check();
}

SetMethodNoSideEffect(
Expand Down

0 comments on commit 21e2ae8

Please sign in to comment.