-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmodule.cc
35 lines (32 loc) · 1.16 KB
/
module.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "data.hh"
#include "icon-object.hh"
#include "menu-object.hh"
#include "napi/napi.hh"
#include "notify-icon-object.hh"
#include "reg-icon-stream.hh"
NAPI_MODULE_INIT() {
EnvData* env_data;
if (auto [status, new_env_data] = create_env_data(env); status != napi_ok) {
napi_throw_last_error(env);
return nullptr;
} else {
env_data = new_env_data;
}
napi_value notify_icon_constructor, menu_constructor, icon_constructor;
NAPI_THROW_RETURN_NULL_IF_NOT_OK(
env, NotifyIconObject::define_class(env_data, ¬ify_icon_constructor));
NAPI_THROW_RETURN_NULL_IF_NOT_OK(
env, MenuObject::define_class(env_data, &menu_constructor));
NAPI_THROW_RETURN_NULL_IF_NOT_OK(
env, IconObject::define_class(env_data, &icon_constructor));
NAPI_THROW_RETURN_NULL_IF_NOT_OK(
env, napi_define_properties(
env, exports,
{
icon_stream_property(),
napi_value_property("NotifyIcon", notify_icon_constructor),
napi_value_property("Menu", menu_constructor),
napi_value_property("Icon", icon_constructor),
}));
return exports;
}