11cb0ef41Sopenharmony_ci#include <node_api.h>
21cb0ef41Sopenharmony_ci#include "../../js-native-api/common.h"
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_cistatic void finalizer(napi_env env, void *data, void *hint) {
51cb0ef41Sopenharmony_ci  NODE_API_CALL_RETURN_VOID(env,
61cb0ef41Sopenharmony_ci      napi_throw_error(env, NULL, "Error during Finalize"));
71cb0ef41Sopenharmony_ci}
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_cistatic char buffer_data[12];
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cistatic napi_value createExternalBuffer(napi_env env, napi_callback_info info) {
121cb0ef41Sopenharmony_ci  napi_value buffer;
131cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_external_buffer(env, sizeof(buffer_data),
141cb0ef41Sopenharmony_ci      buffer_data, finalizer, NULL, &buffer));
151cb0ef41Sopenharmony_ci  return buffer;
161cb0ef41Sopenharmony_ci}
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_cistatic napi_value Init(napi_env env, napi_value exports) {
191cb0ef41Sopenharmony_ci  napi_property_descriptor descriptors[] = {
201cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("createExternalBuffer", createExternalBuffer),
211cb0ef41Sopenharmony_ci  };
221cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_define_properties(
231cb0ef41Sopenharmony_ci      env, exports, sizeof(descriptors) / sizeof(*descriptors), descriptors));
241cb0ef41Sopenharmony_ci  return exports;
251cb0ef41Sopenharmony_ci}
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ciNAPI_MODULE(NODE_GYP_MODULE_NAME, Init)
28