From c4473ea1dfa70c17804f928072947d27433cc63b Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Tue, 31 Dec 2019 16:57:18 -0800 Subject: [PATCH] remove static cast in constructor --- napi-inl.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/napi-inl.h b/napi-inl.h index c75ce6c03..f51c4a790 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -3137,12 +3137,11 @@ inline ObjectWrap::ObjectWrap(const Napi::CallbackInfo& callbackInfo) { napi_value wrapper = callbackInfo.This(); napi_status status; napi_ref ref; - T* instance = static_cast(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* instanceRef = instance; + Reference* instanceRef = this; *instanceRef = Reference(env, ref); } @@ -3722,7 +3721,7 @@ inline napi_value ObjectWrap::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; }