From cd7d7b15c1eeccfe2facdf9a671034d93b6bf467 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Fri, 9 Mar 2018 12:07:37 -0500 Subject: [PATCH] n-api: take n-api out of experimental MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Take n-api out of experimental as per: https://github.com/nodejs/TSC/issues/501 PR-URL: https://github.com/nodejs/node/pull/19262 Reviewed-By: Matteo Collina Reviewed-By: Colin Ihrig Reviewed-By: Michaƫl Zasso Reviewed-By: Gus Caplan Reviewed-By: James M Snell Reviewed-By: Franziska Hinkelmann --- doc/api/n-api.md | 2 +- src/env.cc | 7 ------- src/env.h | 2 -- src/node.cc | 11 ++--------- src/node_api.cc | 10 ---------- src/node_api.h | 9 --------- test/addons-napi/test_warning/binding.gyp | 12 ------------ test/addons-napi/test_warning/test.js | 16 ---------------- test/addons-napi/test_warning/test_warning.c | 11 ----------- test/addons-napi/test_warning/test_warning2.c | 11 ----------- 10 files changed, 3 insertions(+), 88 deletions(-) delete mode 100644 test/addons-napi/test_warning/binding.gyp delete mode 100644 test/addons-napi/test_warning/test.js delete mode 100644 test/addons-napi/test_warning/test_warning.c delete mode 100644 test/addons-napi/test_warning/test_warning2.c diff --git a/doc/api/n-api.md b/doc/api/n-api.md index d67d4280517824..5b36479caea15b 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -2,7 +2,7 @@ -> Stability: 1 - Experimental +> Stability: 2 - Stable N-API (pronounced N as in the letter, followed by API) is an API for building native Addons. It is independent from diff --git a/src/env.cc b/src/env.cc index 913f0e865beb1d..36a3612a780731 100644 --- a/src/env.cc +++ b/src/env.cc @@ -95,7 +95,6 @@ Environment::Environment(IsolateData* isolate_data, printed_error_(false), trace_sync_io_(false), abort_on_uncaught_exception_(false), - emit_napi_warning_(true), emit_env_nonstring_warning_(true), makecallback_cntr_(0), should_abort_on_uncaught_toggle_(isolate_, 1), @@ -350,12 +349,6 @@ bool Environment::RemovePromiseHook(promise_hook_func fn, void* arg) { return true; } -bool Environment::EmitNapiWarning() { - bool current_value = emit_napi_warning_; - emit_napi_warning_ = false; - return current_value; -} - void Environment::EnvPromiseHook(v8::PromiseHookType type, v8::Local promise, v8::Local parent) { diff --git a/src/env.h b/src/env.h index e6060b9e6faab9..c778e7ba112340 100644 --- a/src/env.h +++ b/src/env.h @@ -725,7 +725,6 @@ class Environment { void AddPromiseHook(promise_hook_func fn, void* arg); bool RemovePromiseHook(promise_hook_func fn, void* arg); - bool EmitNapiWarning(); inline bool EmitProcessEnvWarning() { bool current_value = emit_env_nonstring_warning_; emit_env_nonstring_warning_ = false; @@ -784,7 +783,6 @@ class Environment { bool printed_error_; bool trace_sync_io_; bool abort_on_uncaught_exception_; - bool emit_napi_warning_; bool emit_env_nonstring_warning_; size_t makecallback_cntr_; std::vector destroy_async_id_list_; diff --git a/src/node.cc b/src/node.cc index c03c753c37cf09..ede831492425b7 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2286,15 +2286,8 @@ static void DLOpen(const FunctionCallbackInfo& args) { return; } - if (mp->nm_version == -1) { - if (env->EmitNapiWarning()) { - if (ProcessEmitWarning(env, "N-API is an experimental feature and could " - "change at any time.").IsNothing()) { - dlib.Close(); - return; - } - } - } else if (mp->nm_version != NODE_MODULE_VERSION) { + // -1 is used for N-API modules + if ((mp->nm_version != -1) && (mp->nm_version != NODE_MODULE_VERSION)) { char errmsg[1024]; snprintf(errmsg, sizeof(errmsg), diff --git a/src/node_api.cc b/src/node_api.cc index 63ce1d8e86955e..bb027822f14db9 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -1,13 +1,3 @@ -/****************************************************************************** - * Experimental prototype for demonstrating VM agnostic and ABI stable API - * for native modules to use instead of using Nan and V8 APIs directly. - * - * The current status is "Experimental" and should not be used for - * production applications. The API is still subject to change - * and as an experimental feature is NOT subject to semver. - * - ******************************************************************************/ - #include #include #include // INT_MAX diff --git a/src/node_api.h b/src/node_api.h index e9b3645e404530..791a8f8725d268 100644 --- a/src/node_api.h +++ b/src/node_api.h @@ -1,12 +1,3 @@ -/****************************************************************************** - * Experimental prototype for demonstrating VM agnostic and ABI stable API - * for native modules to use instead of using Nan and V8 APIs directly. - * - * The current status is "Experimental" and should not be used for - * production applications. The API is still subject to change - * and as an experimental feature is NOT subject to semver. - * - ******************************************************************************/ #ifndef SRC_NODE_API_H_ #define SRC_NODE_API_H_ diff --git a/test/addons-napi/test_warning/binding.gyp b/test/addons-napi/test_warning/binding.gyp deleted file mode 100644 index a44593e2518c24..00000000000000 --- a/test/addons-napi/test_warning/binding.gyp +++ /dev/null @@ -1,12 +0,0 @@ -{ - "targets": [ - { - "target_name": "test_warning", - "sources": [ "test_warning.c" ] - }, - { - "target_name": "test_warning2", - "sources": [ "test_warning2.c" ] - } - ] -} diff --git a/test/addons-napi/test_warning/test.js b/test/addons-napi/test_warning/test.js deleted file mode 100644 index c82008435fd8fd..00000000000000 --- a/test/addons-napi/test_warning/test.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -if (process.argv[2] === 'child') { - const common = require('../../common'); - console.log(require(`./build/${common.buildType}/test_warning`)); - console.log(require(`./build/${common.buildType}/test_warning2`)); -} else { - const run = require('child_process').spawnSync; - const assert = require('assert'); - const warning = 'Warning: N-API is an experimental feature and could ' + - 'change at any time.'; - - const result = run(process.execPath, [__filename, 'child']); - assert.deepStrictEqual(result.stdout.toString().match(/\S+/g), ['42', '1337']); - assert.deepStrictEqual(result.stderr.toString().split(warning).length, 2); -} diff --git a/test/addons-napi/test_warning/test_warning.c b/test/addons-napi/test_warning/test_warning.c deleted file mode 100644 index d0821be1f2268d..00000000000000 --- a/test/addons-napi/test_warning/test_warning.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include "../common.h" - -napi_value Init(napi_env env, napi_value exports) { - napi_value result; - NAPI_CALL(env, - napi_create_uint32(env, 42, &result)); - return result; -} - -NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) diff --git a/test/addons-napi/test_warning/test_warning2.c b/test/addons-napi/test_warning/test_warning2.c deleted file mode 100644 index 3c8ee9db01390b..00000000000000 --- a/test/addons-napi/test_warning/test_warning2.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include "../common.h" - -napi_value Init(napi_env env, napi_value exports) { - napi_value result; - NAPI_CALL(env, - napi_create_uint32(env, 1337, &result)); - return result; -} - -NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)