n-api: take n-api out of experimental

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 <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
This commit is contained in:
Michael Dawson 2018-03-09 12:07:37 -05:00
parent 040dd244de
commit cd7d7b15c1
10 changed files with 3 additions and 88 deletions

View File

@ -2,7 +2,7 @@
<!--introduced_in=v7.10.0-->
> 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

View File

@ -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<v8::Promise> promise,
v8::Local<v8::Value> parent) {

View File

@ -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<double> destroy_async_id_list_;

View File

@ -2286,15 +2286,8 @@ static void DLOpen(const FunctionCallbackInfo<Value>& 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),

View File

@ -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 <node_buffer.h>
#include <node_object_wrap.h>
#include <limits.h> // INT_MAX

View File

@ -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_

View File

@ -1,12 +0,0 @@
{
"targets": [
{
"target_name": "test_warning",
"sources": [ "test_warning.c" ]
},
{
"target_name": "test_warning2",
"sources": [ "test_warning2.c" ]
}
]
}

View File

@ -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);
}

View File

@ -1,11 +0,0 @@
#include <node_api.h>
#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)

View File

@ -1,11 +0,0 @@
#include <node_api.h>
#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)