Skip to content

Commit

Permalink
src: refactor call js wrapper (#1242)
Browse files Browse the repository at this point in the history
* src: Refactor CallJsWrapper to workaround vs-17
  • Loading branch information
JckXia committed Dec 12, 2022
1 parent 39267ba commit ad7ff92
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,20 @@ struct ThreadSafeFinalize {
};

template <typename ContextType, typename DataType, typename CallJs, CallJs call>
typename std::enable_if<call != nullptr>::type static inline CallJsWrapper(
napi_env env, napi_value jsCallback, void* context, void* data) {
inline typename std::enable_if<call != static_cast<CallJs>(nullptr)>::type
CallJsWrapper(napi_env env, napi_value jsCallback, void* context, void* data) {
call(env,
Function(env, jsCallback),
static_cast<ContextType*>(context),
static_cast<DataType*>(data));
}

template <typename ContextType, typename DataType, typename CallJs, CallJs call>
typename std::enable_if<call == nullptr>::type static inline CallJsWrapper(
napi_env env, napi_value jsCallback, void* /*context*/, void* /*data*/) {
inline typename std::enable_if<call == static_cast<CallJs>(nullptr)>::type
CallJsWrapper(napi_env env,
napi_value jsCallback,
void* /*context*/,
void* /*data*/) {
if (jsCallback != nullptr) {
Function(env, jsCallback).Call(0, nullptr);
}
Expand Down

0 comments on commit ad7ff92

Please sign in to comment.