Skip to content

Commit

Permalink
node-api: define version 8
Browse files Browse the repository at this point in the history
Mark as stable the APIs that define Node-API version 8.

PR-URL: #37652
Backport-PR-URL: #37796
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
  • Loading branch information
gabrielschulhof authored and richardlau committed Mar 19, 2021
1 parent 1872625 commit 93dd799
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 26 deletions.
18 changes: 6 additions & 12 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ For more details, review the [Object lifetime management][].
#### napi_type_tag
<!-- YAML
added: v12.19.0
napiVersion: 8
-->

A 128-bit value stored as two unsigned 64-bit integers. It serves as a UUID
Expand Down Expand Up @@ -1620,10 +1621,9 @@ changes:
- version: v12.19.0
pr-url: https://github.com/nodejs/node/pull/34819
description: Changed signature of the `hook` callback.
napiVersion: 8
-->

> Stability: 1 - Experimental

```c
NAPI_EXTERN napi_status napi_add_async_cleanup_hook(
napi_env env,
Expand Down Expand Up @@ -1661,8 +1661,6 @@ changes:
description: Removed `env` parameter.
-->

> Stability: 1 - Experimental

```c
NAPI_EXTERN napi_status napi_remove_async_cleanup_hook(
napi_async_cleanup_hook_handle remove_handle);
Expand Down Expand Up @@ -4095,10 +4093,9 @@ specification).
#### napi_object_freeze
<!-- YAML
added: v12.20.0
napiVersion: 8
-->

> Stability: 1 - Experimental

```c
napi_status napi_object_freeze(napi_env env,
napi_value object);
Expand All @@ -4120,10 +4117,9 @@ ECMA-262 specification.
#### napi_object_seal
<!-- YAML
added: v12.20.0
napiVersion: 8
-->

> Stability: 1 - Experimental

```c
napi_status napi_object_seal(napi_env env,
napi_value object);
Expand Down Expand Up @@ -4776,10 +4772,9 @@ JavaScript object becomes garbage-collected.
### napi_type_tag_object
<!-- YAML
added: v12.19.0
napiVersion: 8
-->

> Stability: 1 - Experimental

```c
napi_status napi_type_tag_object(napi_env env,
napi_value js_object,
Expand All @@ -4803,10 +4798,9 @@ If the object already has an associated type tag, this API will return
### napi_check_object_type_tag
<!-- YAML
added: v12.19.0
napiVersion: 8
-->

> Stability: 1 - Experimental

```c
napi_status napi_check_object_type_tag(napi_env env,
napi_value js_object,
Expand Down
6 changes: 3 additions & 3 deletions src/js_native_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// functions available in a new version of N-API that is not yet ported in all
// LTS versions, they can set NAPI_VERSION knowing that they have specifically
// depended on that version.
#define NAPI_VERSION 7
#define NAPI_VERSION 8
#endif
#endif

Expand Down Expand Up @@ -539,7 +539,7 @@ NAPI_EXTERN napi_status napi_is_detached_arraybuffer(napi_env env,
bool* result);
#endif // NAPI_VERSION >= 7

#ifdef NAPI_EXPERIMENTAL
#if NAPI_VERSION >= 8
// Type tagging
NAPI_EXTERN napi_status napi_type_tag_object(napi_env env,
napi_value value,
Expand All @@ -554,7 +554,7 @@ NAPI_EXTERN napi_status napi_object_freeze(napi_env env,
napi_value object);
NAPI_EXTERN napi_status napi_object_seal(napi_env env,
napi_value object);
#endif // NAPI_EXPERIMENTAL
#endif // NAPI_VERSION >= 8

EXTERN_C_END

Expand Down
8 changes: 4 additions & 4 deletions src/js_native_api_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ typedef enum {
// from instance properties. Ignored by napi_define_properties.
napi_static = 1 << 10,

#ifdef NAPI_EXPERIMENTAL
#if NAPI_VERSION >= 8
// Default for class methods.
napi_default_method = napi_writable | napi_configurable,

// Default for object properties, like in JS obj[prop].
napi_default_jsproperty = napi_writable |
napi_enumerable |
napi_configurable,
#endif // NAPI_EXPERIMENTAL
#endif // NAPI_VERSION >= 8
} napi_property_attributes;

typedef enum {
Expand Down Expand Up @@ -146,11 +146,11 @@ typedef enum {
} napi_key_conversion;
#endif // NAPI_VERSION >= 6

#ifdef NAPI_EXPERIMENTAL
#if NAPI_VERSION >= 8
typedef struct {
uint64_t lower;
uint64_t upper;
} napi_type_tag;
#endif // NAPI_EXPERIMENTAL
#endif // NAPI_VERSION >= 8

#endif // SRC_JS_NATIVE_API_TYPES_H_
6 changes: 5 additions & 1 deletion src/node_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func);

#endif // NAPI_VERSION >= 4

#ifdef NAPI_EXPERIMENTAL
#if NAPI_VERSION >= 8

NAPI_EXTERN napi_status napi_add_async_cleanup_hook(
napi_env env,
Expand All @@ -261,6 +261,10 @@ NAPI_EXTERN napi_status napi_add_async_cleanup_hook(
NAPI_EXTERN napi_status napi_remove_async_cleanup_hook(
napi_async_cleanup_hook_handle remove_handle);

#endif // NAPI_VERSION >= 8

#ifdef NAPI_EXPERIMENTAL

NAPI_EXTERN napi_status
node_api_get_module_file_name(napi_env env, const char** result);

Expand Down
4 changes: 2 additions & 2 deletions src/node_api_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ typedef struct {
const char* release;
} napi_node_version;

#ifdef NAPI_EXPERIMENTAL
#if NAPI_VERSION >= 8
typedef struct napi_async_cleanup_hook_handle__* napi_async_cleanup_hook_handle;
typedef void (*napi_async_cleanup_hook)(napi_async_cleanup_hook_handle handle,
void* data);
#endif // NAPI_EXPERIMENTAL
#endif // NAPI_VERSION >= 8

#endif // SRC_NODE_API_TYPES_H_
2 changes: 1 addition & 1 deletion src/node_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@

// The NAPI_VERSION provided by this version of the runtime. This is the version
// which the Node binary being built supports.
#define NAPI_VERSION 7
#define NAPI_VERSION 8

#endif // SRC_NODE_VERSION_H_
2 changes: 1 addition & 1 deletion test/js-native-api/test_general/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ assert.notStrictEqual(test_general.testGetPrototype(baseObject),
test_general.testGetPrototype(extendedObject));

// Test version management functions
assert.strictEqual(test_general.testGetVersion(), 7);
assert.strictEqual(test_general.testGetVersion(), 8);

[
123,
Expand Down
1 change: 0 additions & 1 deletion test/js-native-api/test_object/test_object.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define NAPI_EXPERIMENTAL
#include <js_native_api.h>
#include "../common.h"
#include <string.h>
Expand Down
1 change: 0 additions & 1 deletion test/node-api/test_async_cleanup_hook/binding.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define NAPI_EXPERIMENTAL
#include "node_api.h"
#include "assert.h"
#include "uv.h"
Expand Down

0 comments on commit 93dd799

Please sign in to comment.