Skip to content

Commit bb8a836

Browse files
committed
Revert "Revert "Add support for NAPI 6""
This reverts commit 3887480.
1 parent fc6fd00 commit bb8a836

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/ref-napi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#ifndef REF_NAPI_H
22
#define REF_NAPI_H
33

4+
#if !defined(NAPI_VERSION) || NAPI_VERSION < 6
45
#include <get-symbol-from-current-process.h>
6+
#endif
57
#include "napi.h"
68

79
// The definitions in this file are intended to be used by node-ffi-napi.

src/binding.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ using namespace Napi;
2424

2525
namespace {
2626

27+
#if !defined(NAPI_VERSION) || NAPI_VERSION < 6
2728
napi_status napix_set_instance_data(
2829
napi_env env, void* data, napi_finalize finalize_cb, void* finalize_hint) {
2930
typedef napi_status (*napi_set_instance_data_fn)(
@@ -50,6 +51,17 @@ napi_status napix_get_instance_data(
5051
return napi_generic_failure;
5152
return napi_get_instance_data__(env, data);
5253
}
54+
#else // NAPI_VERSION >= 6
55+
napi_status napix_set_instance_data(
56+
napi_env env, void* data, napi_finalize finalize_cb, void* finalize_hint) {
57+
return napi_set_instance_data(env, data, finalize_cb, finalize_hint);
58+
}
59+
60+
napi_status napix_get_instance_data(
61+
napi_env env, void** data) {
62+
return napi_get_instance_data(env, data);
63+
}
64+
#endif
5365

5466
// used by the Int64 functions to determine whether to return a Number
5567
// or String based on whether or not a Number will lose precision.

0 commit comments

Comments
 (0)