| 4904 | |
| 4905 | template <typename T> |
| 4906 | inline NAPI_NO_SANITIZE_VPTR ObjectWrap<T>::~ObjectWrap() { |
| 4907 | // If the JS object still exists at this point, remove the finalizer added |
| 4908 | // through `napi_wrap()`. |
| 4909 | if (!IsEmpty() && !_finalized) { |
| 4910 | Object object = Value(); |
| 4911 | // It is not valid to call `napi_remove_wrap()` with an empty `object`. |
| 4912 | // This happens e.g. during garbage collection. |
| 4913 | if (!object.IsEmpty() && _construction_failed) { |
| 4914 | napi_remove_wrap(Env(), object, nullptr); |
| 4915 | } |
| 4916 | } |
| 4917 | } |
| 4918 | |
| 4919 | // with RTTI turned on, modern compilers check to see if virtual function |
| 4920 | // pointers are stripped of RTTI by void casts. this is intrinsic to how Unwrap |