Skip to content

Commit

Permalink
remove static cast in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Schulhof committed Jan 7, 2020
1 parent 8cf3755 commit b00638c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3137,12 +3137,11 @@ inline ObjectWrap<T>::ObjectWrap(const Napi::CallbackInfo& callbackInfo) {
napi_value wrapper = callbackInfo.This();
napi_status status;
napi_ref ref;
T* instance = static_cast<T*>(this);
status = napi_wrap(env, wrapper, instance, FinalizeCallback, nullptr, &ref);
status = napi_wrap(env, wrapper, this, FinalizeCallback, nullptr, &ref);
NAPI_THROW_IF_FAILED_VOID(env, status);

ObjectWrapCleanup::MarkWrapOK(callbackInfo);
Reference<Object>* instanceRef = instance;
Reference<Object>* instanceRef = this;
*instanceRef = Reference<Object>(env, ref);
}

Expand Down Expand Up @@ -3722,7 +3721,7 @@ inline napi_value ObjectWrap<T>::ConstructorCallbackWrapper(
try {
new T(callbackInfo);
} catch (const Error& e) {
// re-throw the error after removing the failed wrap.
// Re-throw the error after removing the failed wrap.
cleanup.RemoveWrap(callbackInfo);
throw e;
}
Expand Down

0 comments on commit b00638c

Please sign in to comment.