MCPcopy Index your code
hub / github.com/nodejs/node-addon-api / AttachData

Function AttachData

napi-inl.h:58–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56 typename FreeType,
57 node_addon_api_basic_finalize finalizer = default_basic_finalizer<FreeType>>
58inline 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.

Callers 4

CreateFunctionFunction · 0.85
AccessorMethod · 0.85
AttachPropDataMethod · 0.85
DefineClassMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected