Skip to content

Commit 21e2ae8

Browse files
committed
fixup! src,lib: group properties used as constants from util binding
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
1 parent 8b95729 commit 21e2ae8

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/node_util.cc

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -381,28 +381,37 @@ void Initialize(Local<Object> target,
381381
}
382382

383383
{
384-
Local<ObjectTemplate> tmpl = ObjectTemplate::New(isolate);
384+
Local<Object> constants = Object::New(env->isolate());
385385
#define V(name) \
386-
tmpl->Set(FIXED_ONE_BYTE_STRING(isolate, #name), \
387-
Integer::New(isolate, Promise::PromiseState::name));
386+
constants \
387+
->Set(context, \
388+
FIXED_ONE_BYTE_STRING(isolate, #name), \
389+
Integer::New(isolate, Promise::PromiseState::name)) \
390+
.Check();
388391

389392
V(kPending);
390393
V(kFulfilled);
391394
V(kRejected);
392395
#undef V
393396

394397
#define V(name) \
395-
tmpl->Set(FIXED_ONE_BYTE_STRING(isolate, #name), \
396-
Integer::New(isolate, Environment::ExitInfoField::name));
398+
constants \
399+
->Set(context, \
400+
FIXED_ONE_BYTE_STRING(isolate, #name), \
401+
Integer::New(isolate, Environment::ExitInfoField::name)) \
402+
.Check();
397403

398404
V(kExiting);
399405
V(kExitCode);
400406
V(kHasExitCode);
401407
#undef V
402408

403409
#define V(name) \
404-
tmpl->Set(FIXED_ONE_BYTE_STRING(isolate, #name), \
405-
Integer::New(isolate, PropertyFilter::name));
410+
constants \
411+
->Set(context, \
412+
FIXED_ONE_BYTE_STRING(isolate, #name), \
413+
Integer::New(isolate, PropertyFilter::name)) \
414+
.Check();
406415

407416
V(ALL_PROPERTIES);
408417
V(ONLY_WRITABLE);
@@ -412,11 +421,7 @@ void Initialize(Local<Object> target,
412421
V(SKIP_SYMBOLS);
413422
#undef V
414423

415-
target
416-
->Set(context,
417-
env->constants_string(),
418-
tmpl->NewInstance(context).ToLocalChecked())
419-
.Check();
424+
target->Set(context, env->constants_string(), constants).Check();
420425
}
421426

422427
SetMethodNoSideEffect(

0 commit comments

Comments
 (0)