mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Currently the nm_modname does not match the file name of the resulting module. In fact, the nm_modname is pretty arbitrary. This seeks to introduce some consistency into the nm_modname property by having the name of the module appear in exactly one place: the "target_name" property of the gyp target that builds the module. PR-URL: https://github.com/nodejs/node/pull/15209 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
36 lines
1.0 KiB
C
36 lines
1.0 KiB
C
#include <node_api.h>
|
|
#include "../common.h"
|
|
|
|
napi_value Test(napi_env env, napi_callback_info info) {
|
|
size_t argc = 10;
|
|
napi_value args[10];
|
|
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
|
|
|
|
NAPI_ASSERT(env, argc > 0, "Wrong number of arguments");
|
|
|
|
napi_valuetype valuetype0;
|
|
NAPI_CALL(env, napi_typeof(env, args[0], &valuetype0));
|
|
|
|
NAPI_ASSERT(env, valuetype0 == napi_function,
|
|
"Wrong type of arguments. Expects a function as first argument.");
|
|
|
|
napi_value* argv = args + 1;
|
|
argc = argc - 1;
|
|
|
|
napi_value global;
|
|
NAPI_CALL(env, napi_get_global(env, &global));
|
|
|
|
napi_value result;
|
|
NAPI_CALL(env, napi_call_function(env, global, args[0], argc, argv, &result));
|
|
|
|
return result;
|
|
}
|
|
|
|
void Init(napi_env env, napi_value exports, napi_value module, void* priv) {
|
|
napi_value fn;
|
|
NAPI_CALL_RETURN_VOID(env, napi_create_function(env, NULL, Test, NULL, &fn));
|
|
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, exports, "Test", fn));
|
|
}
|
|
|
|
NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)
|