• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <js_native_api.h>
2 #include "../common.h"
3 #include "../entry_point.h"
4 
CreateObject(napi_env env,napi_callback_info info)5 static napi_value CreateObject(napi_env env, napi_callback_info info) {
6   size_t argc = 1;
7   napi_value args[1];
8   NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
9 
10   napi_value obj;
11   NODE_API_CALL(env, napi_create_object(env, &obj));
12 
13   NODE_API_CALL(env, napi_set_named_property(env, obj, "msg", args[0]));
14 
15   return obj;
16 }
17 
18 EXTERN_C_START
Init(napi_env env,napi_value exports)19 napi_value Init(napi_env env, napi_value exports) {
20   NODE_API_CALL(env,
21       napi_create_function(env, "exports", -1, CreateObject, NULL, &exports));
22   return exports;
23 }
24 EXTERN_C_END
25