Skip to content

Commit

Permalink
Fix compilation breakage on 1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NickNaso committed Jul 23, 2019
1 parent 0a1380c commit 37b6c18
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ struct FinalizeData {
Hint* hint;
};

#if (NAPI_VERSION > 3)
template <typename ContextType=void,
typename Finalizer=std::function<void(Env, void*, ContextType*)>,
typename FinalizerDataType=void>
Expand Down Expand Up @@ -196,6 +197,7 @@ struct ThreadSafeFinalize {
Finalizer callback;
napi_threadsafe_function* tsfn;
};
#endif

template <typename Getter, typename Setter>
struct AccessorCallbackData {
Expand Down Expand Up @@ -3740,6 +3742,7 @@ inline void AsyncWorker::OnWorkComplete(
}
}

#if (NAPI_VERSION > 3)
////////////////////////////////////////////////////////////////////////////////
// ThreadSafeFunction class
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -4058,6 +4061,7 @@ inline void ThreadSafeFunction::CallJS(napi_env env,
Function(env, jsCallback).Call({});
}
}
#endif

////////////////////////////////////////////////////////////////////////////////
// Memory Management class
Expand Down
2 changes: 2 additions & 0 deletions napi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,7 @@ namespace Napi {
bool _suppress_destruct;
};

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

std::unique_ptr<napi_threadsafe_function> _tsfn;
};
#endif

// Memory management.
class MemoryManagement {
Expand Down
5 changes: 5 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ if ((process.env.npm_config_NAPI_VERSION !== undefined) &&
testModules.splice(testModules.indexOf('version_management'), 1);
}

if ((process.env.npm_config_NAPI_VERSION !== undefined) &&
(process.env.npm_config_NAPI_VERSION < 4)) {
testModules.splice(testModules.indexOf('threadsafe_function/threadsafe_function'), 1);
}

if (typeof global.gc === 'function') {
console.log('Starting test suite\n');

Expand Down

0 comments on commit 37b6c18

Please sign in to comment.