summaryrefslogtreecommitdiff
path: root/tests/registry/npm/@denotest/node-addon-implicit-node-gyp/1.0.0/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/registry/npm/@denotest/node-addon-implicit-node-gyp/1.0.0/src')
-rw-r--r--tests/registry/npm/@denotest/node-addon-implicit-node-gyp/1.0.0/src/binding.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/registry/npm/@denotest/node-addon-implicit-node-gyp/1.0.0/src/binding.cc b/tests/registry/npm/@denotest/node-addon-implicit-node-gyp/1.0.0/src/binding.cc
new file mode 100644
index 000000000..188b7c7dc
--- /dev/null
+++ b/tests/registry/npm/@denotest/node-addon-implicit-node-gyp/1.0.0/src/binding.cc
@@ -0,0 +1,29 @@
+// hello.cc using Node-API
+#include <node_api.h>
+
+namespace demo {
+
+napi_value Method(napi_env env, napi_callback_info args) {
+ napi_value greeting;
+ napi_status status;
+
+ status = napi_create_string_utf8(env, "world", NAPI_AUTO_LENGTH, &greeting);
+ if (status != napi_ok) return nullptr;
+ return greeting;
+}
+
+napi_value init(napi_env env, napi_value exports) {
+ napi_status status;
+ napi_value fn;
+
+ status = napi_create_function(env, nullptr, 0, Method, nullptr, &fn);
+ if (status != napi_ok) return nullptr;
+
+ status = napi_set_named_property(env, exports, "hello", fn);
+ if (status != napi_ok) return nullptr;
+ return exports;
+}
+
+NAPI_MODULE(NODE_GYP_MODULE_NAME, init)
+
+} // namespace demo \ No newline at end of file