Skip to content

Commit

Permalink
n-api: move cleanup_hook to version 4
Browse files Browse the repository at this point in the history
Update N-API to version 4 and move the `cleanup_hook` API into it.
  • Loading branch information
kfarnung committed Jul 16, 2018
1 parent 210fea5 commit 0d0f4d0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/node_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,10 @@ NAPI_EXTERN napi_status napi_close_callback_scope(napi_env env,

NAPI_EXTERN napi_status napi_fatal_exception(napi_env env, napi_value err);

#endif // NAPI_VERSION >= 3

#if NAPI_VERSION >= 4

NAPI_EXTERN napi_status napi_add_env_cleanup_hook(napi_env env,
void (*fun)(void* arg),
void* arg);
Expand All @@ -631,7 +635,7 @@ NAPI_EXTERN napi_status napi_remove_env_cleanup_hook(napi_env env,
void (*fun)(void* arg),
void* arg);

#endif // NAPI_VERSION >= 3
#endif // NAPI_VERSION >= 4

#ifdef NAPI_EXPERIMENTAL

Expand Down
2 changes: 1 addition & 1 deletion src/node_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@
#define NODE_MODULE_VERSION 64

// the NAPI_VERSION provided by this version of the runtime
#define NAPI_VERSION 3
#define NAPI_VERSION 4

#endif // SRC_NODE_VERSION_H_
1 change: 1 addition & 0 deletions test/addons-napi/test_cleanup_hook/binding.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define NAPI_VERSION 4
#include "node_api.h"
#include "uv.h"
#include "../common.h"
Expand Down
4 changes: 2 additions & 2 deletions test/addons-napi/test_general/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ assert.notStrictEqual(test_general.testGetPrototype(baseObject),
test_general.testGetPrototype(extendedObject));

// test version management functions
// expected version is currently 3
assert.strictEqual(test_general.testGetVersion(), 3);
// expected version is currently 4
assert.strictEqual(test_general.testGetVersion(), 4);

const [ major, minor, patch, release ] = test_general.testGetNodeVersion();
assert.strictEqual(process.version.split('-')[0],
Expand Down

0 comments on commit 0d0f4d0

Please sign in to comment.