|
20 | 20 | #include <memory> |
21 | 21 |
|
22 | 22 | node_napi_env__::node_napi_env__(v8::Local<v8::Context> context, |
23 | | - const std::string& module_filename) |
24 | | - : napi_env__(context), filename(module_filename) { |
| 23 | + const std::string& module_filename, |
| 24 | + napi_features* features) |
| 25 | + : napi_env__(context, features), filename(module_filename) { |
25 | 26 | CHECK_NOT_NULL(node_env()); |
26 | 27 | } |
27 | 28 |
|
@@ -126,10 +127,11 @@ class BufferFinalizer : private Finalizer { |
126 | 127 | }; |
127 | 128 |
|
128 | 129 | inline napi_env NewEnv(v8::Local<v8::Context> context, |
129 | | - const std::string& module_filename) { |
| 130 | + const std::string& module_filename, |
| 131 | + napi_features* features) { |
130 | 132 | node_napi_env result; |
131 | 133 |
|
132 | | - result = new node_napi_env__(context, module_filename); |
| 134 | + result = new node_napi_env__(context, module_filename, features); |
133 | 135 | // TODO(addaleax): There was previously code that tried to delete the |
134 | 136 | // napi_env when its v8::Context was garbage collected; |
135 | 137 | // However, as long as N-API addons using this napi_env are in place, |
@@ -586,24 +588,42 @@ class AsyncContext { |
586 | 588 |
|
587 | 589 | } // end of namespace v8impl |
588 | 590 |
|
| 591 | +void napi_module_register_by_symbol_with_features( |
| 592 | + v8::Local<v8::Object> exports, |
| 593 | + v8::Local<v8::Value> module, |
| 594 | + v8::Local<v8::Context> context, |
| 595 | + napi_addon_register_func init, |
| 596 | + napi_features* features); |
| 597 | + |
589 | 598 | // Intercepts the Node-V8 module registration callback. Converts parameters |
590 | 599 | // to NAPI equivalents and then calls the registration callback specified |
591 | 600 | // by the NAPI module. |
592 | 601 | static void napi_module_register_cb(v8::Local<v8::Object> exports, |
593 | 602 | v8::Local<v8::Value> module, |
594 | 603 | v8::Local<v8::Context> context, |
595 | 604 | void* priv) { |
596 | | - napi_module_register_by_symbol( |
| 605 | + napi_module_register_by_symbol_with_features( |
597 | 606 | exports, |
598 | 607 | module, |
599 | 608 | context, |
600 | | - static_cast<const napi_module*>(priv)->nm_register_func); |
| 609 | + static_cast<const napi_module*>(priv)->nm_register_func, |
| 610 | + static_cast<const napi_module*>(priv)->nm_features); |
601 | 611 | } |
602 | 612 |
|
603 | 613 | void napi_module_register_by_symbol(v8::Local<v8::Object> exports, |
604 | 614 | v8::Local<v8::Value> module, |
605 | 615 | v8::Local<v8::Context> context, |
606 | 616 | napi_addon_register_func init) { |
| 617 | + napi_module_register_by_symbol_with_features( |
| 618 | + exports, module, context, init, nullptr); |
| 619 | +} |
| 620 | + |
| 621 | +void napi_module_register_by_symbol_with_features( |
| 622 | + v8::Local<v8::Object> exports, |
| 623 | + v8::Local<v8::Value> module, |
| 624 | + v8::Local<v8::Context> context, |
| 625 | + napi_addon_register_func init, |
| 626 | + napi_features* features) { |
607 | 627 | node::Environment* node_env = node::Environment::GetCurrent(context); |
608 | 628 | std::string module_filename = ""; |
609 | 629 | if (init == nullptr) { |
@@ -631,7 +651,7 @@ void napi_module_register_by_symbol(v8::Local<v8::Object> exports, |
631 | 651 | } |
632 | 652 |
|
633 | 653 | // Create a new napi_env for this specific module. |
634 | | - napi_env env = v8impl::NewEnv(context, module_filename); |
| 654 | + napi_env env = v8impl::NewEnv(context, module_filename, features); |
635 | 655 |
|
636 | 656 | napi_value _exports; |
637 | 657 | env->CallIntoModule([&](napi_env env) { |
|
0 commit comments