| 56 | typename FreeType, |
| 57 | node_addon_api_basic_finalize finalizer = default_basic_finalizer<FreeType>> |
| 58 | inline napi_status AttachData(napi_env env, |
| 59 | napi_value obj, |
| 60 | FreeType* data, |
| 61 | void* hint = nullptr) { |
| 62 | napi_status status; |
| 63 | #if (NAPI_VERSION < 5) |
| 64 | napi_value symbol, external; |
| 65 | status = napi_create_symbol(env, nullptr, &symbol); |
| 66 | if (status == napi_ok) { |
| 67 | status = napi_create_external(env, data, finalizer, hint, &external); |
| 68 | if (status == napi_ok) { |
| 69 | napi_property_descriptor desc = {nullptr, |
| 70 | symbol, |
| 71 | nullptr, |
| 72 | nullptr, |
| 73 | nullptr, |
| 74 | external, |
| 75 | napi_default, |
| 76 | nullptr}; |
| 77 | status = napi_define_properties(env, obj, 1, &desc); |
| 78 | } |
| 79 | } |
| 80 | #else // NAPI_VERSION >= 5 |
| 81 | status = napi_add_finalizer(env, obj, data, finalizer, hint, nullptr); |
| 82 | #endif |
| 83 | return status; |
| 84 | } |
| 85 | |
| 86 | // For use in JS to C++ callback wrappers to catch any Napi::Error exceptions |
| 87 | // and rethrow them as JavaScript exceptions before returning from the callback. |
no outgoing calls
no test coverage detected