Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
hello.cpp
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
include
"napi/native_api.h"
5
6
static
napi_value
Add
(napi_env env, napi_callback_info info)
7
{
8
size_t requireArgc = 2;
9
size_t argc = 2;
10
napi_value args[2] = {
nullptr
};
11
12
napi_get_cb_info(env, info, &argc, args ,
nullptr
,
nullptr
);
13
14
napi_valuetype valuetype0;
15
napi_typeof(env, args[0], &valuetype0);
16
17
napi_valuetype valuetype1;
18
napi_typeof(env, args[1], &valuetype1);
19
20
double
value0;
21
napi_get_value_double(env, args[0], &value0);
22
23
double
value1;
24
napi_get_value_double(env, args[1], &value1);
25
26
napi_value sum;
27
napi_create_double(env, value0 + value1, &sum);
28
29
return
sum;
30
31
}
32
33
EXTERN_C_START
34
static
napi_value Init(napi_env env, napi_value exports)
35
{
36
napi_property_descriptor desc[] = {
37
{
"add"
,
nullptr
, Add,
nullptr
,
nullptr
,
nullptr
, napi_default,
nullptr
}
38
};
39
napi_define_properties(env, exports,
sizeof
(desc) /
sizeof
(desc[0]), desc);
40
return
exports;
41
}
42
EXTERN_C_END
43
44
static
napi_module demoModule = {
45
.nm_version =1,
46
.nm_flags = 0,
47
.nm_filename =
nullptr
,
48
.nm_register_func = Init,
49
.nm_modname =
"entry"
,
50
.nm_priv = ((
void
*)0),
51
.reserved = { 0 },
52
};
53
54
extern
"C"
__attribute__
((constructor))
void
RegisterEntryModule
(
void
)
55
{
56
napi_module_register(&demoModule);
57
}
Add
static napi_value Add(napi_env env, napi_callback_info info)
Definition
hello.cpp:6
__attribute__
__attribute__((constructor)) void RegisterEntryModule(void)
Definition
hello.cpp:54
qtbase
src
harmonyos
templates
entry
src
main
cpp
hello.cpp
Generated on
for Qt by
1.18.0