GeezerVison is showing github.com — n-api: remove n-api module loading flag · Qard/ayo@c859a10
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: doc/api/cli.md -9Lines changed: 0 additions & 9 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -178,14 +178,6 @@ added: v8.4.0 | 178 | 178 |
| 179 | 179 | Enable the experimental `'http2'` module. | 180 | 180 |
| 181 | | -### `--napi-modules` | 182 | | -<!-- YAML | 183 | | -added: v8.0.0 | 184 | | ---> | 185 | | - | 186 | | -Enable loading native modules compiled with the ABI-stable Node.js API (N-API) | 187 | | -(experimental). | 188 | | - | 189 | 181 | ### `--abort-on-uncaught-exception` | 190 | 182 | <!-- YAML | 191 | 183 | added: v0.10 | @@ -453,7 +445,6 @@ Node options that are allowed are: | 453 | 445 | - `--inspect-brk` | 454 | 446 | - `--inspect-port` | 455 | 447 | - `--inspect` | 456 | | -- `--napi-modules` | 457 | 448 | - `--no-deprecation` | 458 | 449 | - `--no-warnings` | 459 | 450 | - `--openssl-config` | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/n-api.md -8Lines changed: 0 additions & 8 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -63,14 +63,6 @@ For example: | 63 | 63 | #include <node_api.h> | 64 | 64 | ``` | 65 | 65 |
| 66 | | -As the feature is experimental it must be enabled with the | 67 | | -following command line | 68 | | -[option](https://nodejs.org/dist/latest-v8.x/docs/api/cli.html#cli_napi_modules): | 69 | | - | 70 | | -```bash | 71 | | ---napi-modules | 72 | | -``` | 73 | | - | 74 | 66 | ## Basic N-API Data Types | 75 | 67 |
| 76 | 68 | N-API exposes the following fundamental datatypes as abstractions that are | |
Collapse file Copy file name to clipboardExpand all lines: src/env-inl.h +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -288,6 +288,7 @@ inline Environment::Environment(IsolateData* isolate_data, | 288 | 288 | printed_error_(false), | 289 | 289 | trace_sync_io_(false), | 290 | 290 | abort_on_uncaught_exception_(false), | | 291 | + emit_napi_warning_(true), | 291 | 292 | makecallback_cntr_(0), | 292 | 293 | #if HAVE_INSPECTOR | 293 | 294 | inspector_agent_(this), | |
Collapse file Copy file name to clipboardExpand all lines: src/env.cc +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -213,6 +213,12 @@ bool Environment::RemovePromiseHook(promise_hook_func fn, void* arg) { | 213 | 213 | return true; | 214 | 214 | } | 215 | 215 |
| | 216 | +bool Environment::EmitNapiWarning() { | | 217 | + bool current_value = emit_napi_warning_; | | 218 | + emit_napi_warning_ = false; | | 219 | + return current_value; | | 220 | +} | | 221 | + | 216 | 222 | void Environment::EnvPromiseHook(v8::PromiseHookType type, | 217 | 223 | v8::Local<v8::Promise> promise, | 218 | 224 | v8::Local<v8::Value> parent) { | |
Collapse file Copy file name to clipboardExpand all lines: src/env.h +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -669,6 +669,7 @@ class Environment { | 669 | 669 |
| 670 | 670 | void AddPromiseHook(promise_hook_func fn, void* arg); | 671 | 671 | bool RemovePromiseHook(promise_hook_func fn, void* arg); | | 672 | + bool EmitNapiWarning(); | 672 | 673 |
| 673 | 674 | private: | 674 | 675 | inline void ThrowError(v8::Local<v8::Value> (*fun)(v8::Local<v8::String>), | @@ -690,6 +691,7 @@ class Environment { | 690 | 691 | bool printed_error_; | 691 | 692 | bool trace_sync_io_; | 692 | 693 | bool abort_on_uncaught_exception_; | | 694 | + bool emit_napi_warning_; | 693 | 695 | size_t makecallback_cntr_; | 694 | 696 | std::vector<double> destroy_ids_list_; | 695 | 697 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/node.cc +18-30Lines changed: 18 additions & 30 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -197,9 +197,6 @@ unsigned int reverted = 0; | 197 | 197 | std::string icu_data_dir; // NOLINT(runtime/string) | 198 | 198 | #endif | 199 | 199 |
| 200 | | -// N-API is in experimental state, disabled by default. | 201 | | -bool load_napi_modules = false; | 202 | | - | 203 | 200 | // used by C++ modules as well | 204 | 201 | bool no_deprecation = false; | 205 | 202 |
| @@ -2703,27 +2700,22 @@ static void DLOpen(const FunctionCallbackInfo<Value>& args) { | 2703 | 2700 | env->ThrowError("Module did not self-register."); | 2704 | 2701 | return; | 2705 | 2702 | } | 2706 | | - if (mp->nm_version != NODE_MODULE_VERSION) { | 2707 | | - char errmsg[1024]; | 2708 | | - if (mp->nm_version == -1) { | 2709 | | - snprintf(errmsg, | 2710 | | - sizeof(errmsg), | 2711 | | - "The module '%s'" | 2712 | | - "\nwas compiled against the ABI-stable Node.js API (N-API)." | 2713 | | - "\nThis feature is experimental and must be enabled on the " | 2714 | | - "\ncommand-line by adding --napi-modules.", | 2715 | | - *filename); | 2716 | | - } else { | 2717 | | - snprintf(errmsg, | 2718 | | - sizeof(errmsg), | 2719 | | - "The module '%s'" | 2720 | | - "\nwas compiled against a different Node.js version using" | 2721 | | - "\nNODE_MODULE_VERSION %d. This version of Node.js requires" | 2722 | | - "\nNODE_MODULE_VERSION %d. Please try re-compiling or " | 2723 | | - "re-installing\nthe module (for instance, using `npm rebuild` " | 2724 | | - "or `npm install`).", | 2725 | | - *filename, mp->nm_version, NODE_MODULE_VERSION); | | 2703 | + if (mp->nm_version == -1) { | | 2704 | + if (env->EmitNapiWarning()) { | | 2705 | + ProcessEmitWarning(env, "N-API is an experimental feature and could " | | 2706 | + "change at any time."); | 2726 | 2707 | } | | 2708 | + } else if (mp->nm_version != NODE_MODULE_VERSION) { | | 2709 | + char errmsg[1024]; | | 2710 | + snprintf(errmsg, | | 2711 | + sizeof(errmsg), | | 2712 | + "The module '%s'" | | 2713 | + "\nwas compiled against a different Node.js version using" | | 2714 | + "\nNODE_MODULE_VERSION %d. This version of Node.js requires" | | 2715 | + "\nNODE_MODULE_VERSION %d. Please try re-compiling or " | | 2716 | + "re-installing\nthe module (for instance, using `npm rebuild` " | | 2717 | + "or `npm install`).", | | 2718 | + *filename, mp->nm_version, NODE_MODULE_VERSION); | 2727 | 2719 |
| 2728 | 2720 | // NOTE: `mp` is allocated inside of the shared library's memory, calling | 2729 | 2721 | // `dlclose` will deallocate it | @@ -3822,7 +3814,8 @@ static void PrintHelp() { | 3822 | 3814 | " --throw-deprecation throw an exception on deprecations\n" | 3823 | 3815 | " --pending-deprecation emit pending deprecation warnings\n" | 3824 | 3816 | " --no-warnings silence all process warnings\n" | 3825 | | - " --napi-modules load N-API modules\n" | | 3817 | + " --napi-modules load N-API modules (no-op - option\n" | | 3818 | + " kept for compatibility)\n" | 3826 | 3819 | " --abort-on-uncaught-exception\n" | 3827 | 3820 | " aborting instead of exiting causes a\n" | 3828 | 3821 | " core file to be generated for analysis\n" | @@ -4080,7 +4073,7 @@ static void ParseArgs(int* argc, | 4080 | 4073 | } else if (strcmp(arg, "--no-deprecation") == 0) { | 4081 | 4074 | no_deprecation = true; | 4082 | 4075 | } else if (strcmp(arg, "--napi-modules") == 0) { | 4083 | | - load_napi_modules = true; | | 4076 | + // no-op | 4084 | 4077 | } else if (strcmp(arg, "--no-warnings") == 0) { | 4085 | 4078 | no_process_warnings = true; | 4086 | 4079 | } else if (strcmp(arg, "--trace-warnings") == 0) { | @@ -4735,11 +4728,6 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data, | 4735 | 4728 |
| 4736 | 4729 | env.set_trace_sync_io(trace_sync_io); | 4737 | 4730 |
| 4738 | | - if (load_napi_modules) { | 4739 | | - ProcessEmitWarning(&env, "N-API is an experimental feature " | 4740 | | - "and could change at any time."); | 4741 | | - } | 4742 | | - | 4743 | 4731 | { | 4744 | 4732 | SealHandleScope seal(isolate); | 4745 | 4733 | bool more; | |
Collapse file Copy file name to clipboardExpand all lines: src/node_api.cc +1-19Lines changed: 1 addition & 19 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -841,28 +841,10 @@ void napi_module_register_cb(v8::Local<v8::Object> exports, | 841 | 841 |
| 842 | 842 | } // end of anonymous namespace | 843 | 843 |
| 844 | | -#ifndef EXTERNAL_NAPI | 845 | | -namespace node { | 846 | | - // Indicates whether NAPI was enabled/disabled via the node command-line. | 847 | | - extern bool load_napi_modules; | 848 | | -} | 849 | | -#endif // EXTERNAL_NAPI | 850 | | - | 851 | 844 | // Registers a NAPI module. | 852 | 845 | void napi_module_register(napi_module* mod) { | 853 | | - // NAPI modules always work with the current node version. | 854 | | - int module_version = NODE_MODULE_VERSION; | 855 | | - | 856 | | -#ifndef EXTERNAL_NAPI | 857 | | - if (!node::load_napi_modules) { | 858 | | - // NAPI is disabled, so set the module version to -1 to cause the module | 859 | | - // to be unloaded. | 860 | | - module_version = -1; | 861 | | - } | 862 | | -#endif // EXTERNAL_NAPI | 863 | | - | 864 | 846 | node::node_module* nm = new node::node_module { | 865 | | - module_version, | | 847 | + -1, | 866 | 848 | mod->nm_flags, | 867 | 849 | nullptr, | 868 | 850 | mod->nm_filename, | |
Collapse file Copy file name to clipboardExpand all lines: test/addons-napi/test_async/test.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,7 @@ if (process.argv[2] === 'child') { | 15 | 15 | return; | 16 | 16 | } | 17 | 17 | const p = child_process.spawnSync( | 18 | | - process.execPath, [ '--napi-modules', __filename, 'child' ]); | | 18 | + process.execPath, [ __filename, 'child' ]); | 19 | 19 | assert.ifError(p.error); | 20 | 20 | assert.ok(p.stderr.toString().includes(testException)); | 21 | 21 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/addons-napi/test_fatal/test.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,7 +12,7 @@ if (process.argv[2] === 'child') { | 12 | 12 | } | 13 | 13 |
| 14 | 14 | const p = child_process.spawnSync( | 15 | | - process.execPath, [ '--napi-modules', __filename, 'child' ]); | | 15 | + process.execPath, [ __filename, 'child' ]); | 16 | 16 | assert.ifError(p.error); | 17 | 17 | assert.ok(p.stderr.toString().includes( | 18 | 18 | 'FATAL ERROR: test_fatal::Test fatal message')); |
Collapse file Copy file name to clipboardExpand all lines: test/addons-napi/test_function/test_function.c +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,7 +26,9 @@ napi_value TestCallFunction(napi_env env, napi_callback_info info) { | 26 | 26 | return result; | 27 | 27 | } | 28 | 28 |
| 29 | | -void TestFunctionName(napi_env env, napi_callback_info info) {} | | 29 | +napi_value TestFunctionName(napi_env env, napi_callback_info info) { | | 30 | + return NULL; | | 31 | +} | 30 | 32 |
| 31 | 33 | napi_value Init(napi_env env, napi_value exports) { | 32 | 34 | napi_value fn1; | |
|