mirror of
https://gitee.com/openharmony/napi_generator
synced 2024-11-23 08:20:01 +00:00
修改napi class snippets
Signed-off-by: chen-zhongwei050 <chenzhongwei050@chinasoftinc.com>
This commit is contained in:
parent
866d668fcb
commit
a051ab8659
@ -18,7 +18,7 @@
|
|||||||
" napi_ref wrapper_;",
|
" napi_ref wrapper_;",
|
||||||
"};",
|
"};",
|
||||||
"HelloWorld::HelloWorld(): value_(\"\"), env_(nullptr), wrapper_(nullptr) {}",
|
"HelloWorld::HelloWorld(): value_(\"\"), env_(nullptr), wrapper_(nullptr) {}",
|
||||||
"HelloWorld::~HelloWorld() {}",
|
"HelloWorld::~HelloWorld() { napi_delete_reference(env_, wrapper_); }",
|
||||||
"void HelloWorld::Destructor(napi_env env, void* nativeObject, [[maybe_unused]] void* finalize_hint)",
|
"void HelloWorld::Destructor(napi_env env, void* nativeObject, [[maybe_unused]] void* finalize_hint)",
|
||||||
"{",
|
"{",
|
||||||
" reinterpret_cast<HelloWorld*>(nativeObject)->~HelloWorld();",
|
" reinterpret_cast<HelloWorld*>(nativeObject)->~HelloWorld();",
|
||||||
@ -45,18 +45,18 @@
|
|||||||
"}",
|
"}",
|
||||||
"napi_value HelloWorld::GetValue(napi_env env, napi_callback_info info)",
|
"napi_value HelloWorld::GetValue(napi_env env, napi_callback_info info)",
|
||||||
"{",
|
"{",
|
||||||
" // Todo: you can use \"napigetinfo\" command to get snippets that get js context and arguments.",
|
" // Todo: you can use \"napiobjectin\" command that get object param from js.",
|
||||||
" HelloWorld* obj;",
|
" HelloWorld* obj;",
|
||||||
" // Retrieve obj (the C++ object) previously wrapped in jsThis (the ArkTS object), and perform subsequent operations.",
|
" // Retrieve obj (the C++ object) previously wrapped in jsThis (the ArkTS object), and perform subsequent operations.",
|
||||||
" napi_unwrap(env, jsThis, reinterpret_cast<void**>(&obj));",
|
" napi_unwrap(env, jsThis, reinterpret_cast<void**>(&obj));",
|
||||||
" // Todo: you can use \"napireturn_\" to choose command that return value to js.",
|
" // Todo: you can use \"napistringutf8out\" command that return string utf8 value to js.",
|
||||||
"}",
|
"}",
|
||||||
"napi_value HelloWorld::SetValue(napi_env env, napi_callback_info info)",
|
"napi_value HelloWorld::SetValue(napi_env env, napi_callback_info info)",
|
||||||
"{",
|
"{",
|
||||||
" // Todo: you can use \"napigetinfo\" command to get snippets that get js context and arguments.",
|
" // Todo: you can use \"napiobjectin\" command that get object param from js.",
|
||||||
" HelloWorld* obj;",
|
" HelloWorld* obj;",
|
||||||
" napi_unwrap(env, jsThis, reinterpret_cast<void**>(&obj));",
|
" napi_unwrap(env, jsThis, reinterpret_cast<void**>(&obj));",
|
||||||
" // Todo: you can use \"napigetparam_\" to choose command that get params from js.",
|
" // Todo: you can use \"napistringutf8in\" command that get string utf8 param from js.",
|
||||||
" return nullptr;",
|
" return nullptr;",
|
||||||
"}",
|
"}",
|
||||||
"napi_value HelloWorld::Hello(napi_env env, napi_callback_info info)",
|
"napi_value HelloWorld::Hello(napi_env env, napi_callback_info info)",
|
||||||
|
Loading…
Reference in New Issue
Block a user