Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: use NAPI_NOEXCEPT macro instead of noexcept. #864

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,19 @@ TemplatedInstanceVoidCallback(napi_env env,

template <typename T, typename Finalizer, typename Hint = void>
struct FinalizeData {
static inline
void Wrapper(napi_env env, void* data, void* finalizeHint) noexcept {
static inline void Wrapper(napi_env env,
void* data,
void* finalizeHint) NAPI_NOEXCEPT {
WrapVoidCallback([&] {
FinalizeData* finalizeData = static_cast<FinalizeData*>(finalizeHint);
finalizeData->callback(Env(env), static_cast<T*>(data));
delete finalizeData;
});
}

static inline
void WrapperWithHint(napi_env env, void* data, void* finalizeHint) noexcept {
static inline void WrapperWithHint(napi_env env,
void* data,
void* finalizeHint) NAPI_NOEXCEPT {
WrapVoidCallback([&] {
FinalizeData* finalizeData = static_cast<FinalizeData*>(finalizeHint);
finalizeData->callback(Env(env), static_cast<T*>(data), finalizeData->hint);
Expand Down Expand Up @@ -3562,7 +3564,8 @@ inline napi_value InstanceWrap<T>::InstanceSetterCallbackWrapper(

template <typename T>
template <typename InstanceWrap<T>::InstanceSetterCallback method>
inline napi_value InstanceWrap<T>::WrappedMethod(napi_env env, napi_callback_info info) noexcept {
inline napi_value InstanceWrap<T>::WrappedMethod(
napi_env env, napi_callback_info info) NAPI_NOEXCEPT {
return details::WrapCallback([&] {
const CallbackInfo cbInfo(env, info);
T* instance = T::Unwrap(cbInfo.This().As<Object>());
Expand Down Expand Up @@ -4024,7 +4027,8 @@ inline void ObjectWrap<T>::FinalizeCallback(napi_env env, void* data, void* /*hi

template <typename T>
template <typename ObjectWrap<T>::StaticSetterCallback method>
inline napi_value ObjectWrap<T>::WrappedMethod(napi_env env, napi_callback_info info) noexcept {
inline napi_value ObjectWrap<T>::WrappedMethod(
napi_env env, napi_callback_info info) NAPI_NOEXCEPT {
return details::WrapCallback([&] {
const CallbackInfo cbInfo(env, info);
method(cbInfo, cbInfo[0]);
Expand Down
24 changes: 18 additions & 6 deletions napi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1747,13 +1747,18 @@ namespace Napi {
static napi_value InstanceSetterCallbackWrapper(napi_env env, napi_callback_info info);

template <InstanceSetterCallback method>
static napi_value WrappedMethod(napi_env env, napi_callback_info info) noexcept;
static napi_value WrappedMethod(napi_env env,
napi_callback_info info) NAPI_NOEXCEPT;

template <InstanceSetterCallback setter> struct SetterTag {};

template <InstanceSetterCallback setter>
static napi_callback WrapSetter(SetterTag<setter>) noexcept { return &This::WrappedMethod<setter>; }
static napi_callback WrapSetter(SetterTag<nullptr>) noexcept { return nullptr; }
static napi_callback WrapSetter(SetterTag<setter>) NAPI_NOEXCEPT {
return &This::WrappedMethod<setter>;
}
static napi_callback WrapSetter(SetterTag<nullptr>) NAPI_NOEXCEPT {
return nullptr;
}
};

/// Base class to be extended by C++ classes exposed to JavaScript; each C++ class instance gets
Expand Down Expand Up @@ -1886,13 +1891,20 @@ namespace Napi {
StaticSetterCallback> StaticAccessorCallbackData;

template <StaticSetterCallback method>
static napi_value WrappedMethod(napi_env env, napi_callback_info info) noexcept;
static napi_value WrappedMethod(napi_env env,
napi_callback_info info) NAPI_NOEXCEPT;

template <StaticSetterCallback setter> struct StaticSetterTag {};

template <StaticSetterCallback setter>
static napi_callback WrapStaticSetter(StaticSetterTag<setter>) noexcept { return &This::WrappedMethod<setter>; }
static napi_callback WrapStaticSetter(StaticSetterTag<nullptr>) noexcept { return nullptr; }
static napi_callback WrapStaticSetter(StaticSetterTag<setter>)
NAPI_NOEXCEPT {
return &This::WrappedMethod<setter>;
}
static napi_callback WrapStaticSetter(StaticSetterTag<nullptr>)
NAPI_NOEXCEPT {
return nullptr;
}

bool _construction_failed = true;
};
Expand Down