Skip to content

Commit

Permalink
Add support for NAPI 6
Browse files Browse the repository at this point in the history
  • Loading branch information
censiscalumjohnson authored and addaleax committed Aug 11, 2020
1 parent 9b58c25 commit 6c83b0f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/ref-napi.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#ifndef REF_NAPI_H
#define REF_NAPI_H

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

// The definitions in this file are intended to be used by node-ffi-napi.
Expand Down
12 changes: 12 additions & 0 deletions src/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ using namespace Napi;

namespace {

#if !defined(NAPI_VERSION) || NAPI_VERSION < 6
napi_status napix_set_instance_data(
napi_env env, void* data, napi_finalize finalize_cb, void* finalize_hint) {
typedef napi_status (*napi_set_instance_data_fn)(
Expand All @@ -50,6 +51,17 @@ napi_status napix_get_instance_data(
return napi_generic_failure;
return napi_get_instance_data__(env, data);
}
#else // NAPI_VERSION >= 6
napi_status napix_set_instance_data(
napi_env env, void* data, napi_finalize finalize_cb, void* finalize_hint) {
return napi_set_instance_data(env, data, finalize_cb, finalize_hint);
}

napi_status napix_get_instance_data(
napi_env env, void** data) {
return napi_get_instance_data(env, data);
}
#endif

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

0 comments on commit 6c83b0f

Please sign in to comment.