From 2c1190a93d841e03f2516d0741691a900a96c4d3 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Tue, 10 Apr 2018 17:45:35 -0400 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 Backport-PR-URL: https://github.com/nodejs/node/pull/19447 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 --- src/env-inl.h | 1 - src/env.cc | 6 ------ src/env.h | 3 --- src/node.cc | 9 +++------ 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(+), 85 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/src/env-inl.h b/src/env-inl.h index 9b4000d75b180d..a5e2e176c11df3 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -223,7 +223,6 @@ inline Environment::Environment(v8::Local context, using_domains_(false), printed_error_(false), trace_sync_io_(false), - emit_napi_warning_(true), makecallback_cntr_(0), async_wrap_uid_(0), debugger_agent_(this), diff --git a/src/env.cc b/src/env.cc index 0b31afdf2eaf23..5090475499dcaf 100644 --- a/src/env.cc +++ b/src/env.cc @@ -61,10 +61,4 @@ void Environment::PrintSyncTrace() const { fflush(stderr); } -bool Environment::EmitNapiWarning() { - bool current_value = emit_napi_warning_; - emit_napi_warning_ = false; - return current_value; -} - } // namespace node diff --git a/src/env.h b/src/env.h index 593f38964c7839..19c6e84642a963 100644 --- a/src/env.h +++ b/src/env.h @@ -537,8 +537,6 @@ class Environment { static const int kContextEmbedderDataIndex = NODE_CONTEXT_EMBEDDER_DATA_INDEX; - bool EmitNapiWarning(); - private: inline void ThrowError(v8::Local (*fun)(v8::Local), const char* errmsg); @@ -570,7 +568,6 @@ class Environment { bool using_domains_; bool printed_error_; bool trace_sync_io_; - bool emit_napi_warning_; size_t makecallback_cntr_; int64_t async_wrap_uid_; std::vector destroy_ids_list_; diff --git a/src/node.cc b/src/node.cc index 05f34be823d9cf..3f4c02413c9aa7 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2500,12 +2500,9 @@ void DLOpen(const FunctionCallbackInfo& args) { env->ThrowError("Module did not self-register."); return; } - if (mp->nm_version == -1) { - if (env->EmitNapiWarning()) { - ProcessEmitWarning(env, "N-API is an experimental feature and could " - "change at any time."); - } - } 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 a5902db0454eba..8c454d6425889d 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 3b741c27b976ae..c5b8a2a30cfe15 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)