Skip to content

Commit c20bcbd

Browse files
authored
Merge pull request #518 from NickNaso/master
Fix compilation breakage on 1.7.0
2 parents 0a1380c + 6720d57 commit c20bcbd

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

napi-inl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ struct FinalizeData {
125125
Hint* hint;
126126
};
127127

128+
#if (NAPI_VERSION > 3)
128129
template <typename ContextType=void,
129130
typename Finalizer=std::function<void(Env, void*, ContextType*)>,
130131
typename FinalizerDataType=void>
@@ -196,6 +197,7 @@ struct ThreadSafeFinalize {
196197
Finalizer callback;
197198
napi_threadsafe_function* tsfn;
198199
};
200+
#endif
199201

200202
template <typename Getter, typename Setter>
201203
struct AccessorCallbackData {
@@ -3740,6 +3742,7 @@ inline void AsyncWorker::OnWorkComplete(
37403742
}
37413743
}
37423744

3745+
#if (NAPI_VERSION > 3)
37433746
////////////////////////////////////////////////////////////////////////////////
37443747
// ThreadSafeFunction class
37453748
////////////////////////////////////////////////////////////////////////////////
@@ -4058,6 +4061,7 @@ inline void ThreadSafeFunction::CallJS(napi_env env,
40584061
Function(env, jsCallback).Call({});
40594062
}
40604063
}
4064+
#endif
40614065

40624066
////////////////////////////////////////////////////////////////////////////////
40634067
// Memory Management class

napi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,7 @@ namespace Napi {
18301830
bool _suppress_destruct;
18311831
};
18321832

1833+
#if (NAPI_VERSION > 3)
18331834
class ThreadSafeFunction {
18341835
public:
18351836
// This API may only be called from the main thread.
@@ -2029,6 +2030,7 @@ namespace Napi {
20292030

20302031
std::unique_ptr<napi_threadsafe_function> _tsfn;
20312032
};
2033+
#endif
20322034

20332035
// Memory management.
20342036
class MemoryManagement {

test/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ if ((process.env.npm_config_NAPI_VERSION !== undefined) &&
6262
testModules.splice(testModules.indexOf('version_management'), 1);
6363
}
6464

65+
if ((process.env.npm_config_NAPI_VERSION !== undefined) &&
66+
(process.env.npm_config_NAPI_VERSION < 4)) {
67+
testModules.splice(testModules.indexOf('threadsafe_function/threadsafe_function'), 1);
68+
}
69+
6570
if (typeof global.gc === 'function') {
6671
console.log('Starting test suite\n');
6772

test/threadsafe_function/threadsafe_function.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include <thread>
33
#include "napi.h"
44

5+
#if (NAPI_VERSION > 3)
6+
57
using namespace Napi;
68

79
constexpr size_t ARRAY_LENGTH = 10;
@@ -177,3 +179,5 @@ Object InitThreadSafeFunction(Env env) {
177179

178180
return exports;
179181
}
182+
183+
#endif

0 commit comments

Comments
 (0)