Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
8e408d64
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
1 年多 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8e408d64
编写于
5月 25, 2023
作者:
C
chengjinsong2
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改NAPI
Signed-off-by:
N
chengjinsong2
<
chengjinsong2@huawei.com
>
上级
77476028
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
20 deletion
+12
-20
interfaces/kits/jskits/src/native_parameters_js.cpp
interfaces/kits/jskits/src/native_parameters_js.cpp
+1
-0
interfaces/kits/jskits/src_enhance/native_parameters_js.cpp
interfaces/kits/jskits/src_enhance/native_parameters_js.cpp
+11
-20
未找到文件。
interfaces/kits/jskits/src/native_parameters_js.cpp
浏览文件 @
8e408d64
...
...
@@ -173,6 +173,7 @@ static napi_value GetSync(napi_env env, napi_callback_info info)
napi_valuetype
valuetype0
=
napi_null
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
0
],
&
valuetype0
));
NAPI_ASSERT
(
env
,
valuetype0
==
napi_string
,
"Wrong argument type. Numbers expected."
);
napi_valuetype
valuetype1
=
napi_null
;
if
(
argc
==
ARGC_NUMBER
)
{
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
1
],
&
valuetype1
));
...
...
interfaces/kits/jskits/src_enhance/native_parameters_js.cpp
浏览文件 @
8e408d64
...
...
@@ -270,16 +270,13 @@ static napi_value GetSync(napi_env env, napi_callback_info info)
PARAM_JS_LOGV
(
"JSApp get status: %d, key: '%s', value: '%s', defValue: '%s'."
,
ret
,
keyBuf
.
data
(),
value
.
data
(),
defValue
.
data
());
napi_value
napiValue
=
nullptr
;
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
value
.
data
(),
strlen
(
value
.
data
()),
&
napiValue
));
if
(
ret
<
0
)
{
if
(
ret
==
SYSPARAM_NOT_FOUND
)
{
return
napiValue
;
}
napi_throw
(
env
,
BusinessErrorCreate
(
env
,
ret
));
return
nullptr
;
}
napi_value
napiValue
=
nullptr
;
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
value
.
data
(),
strlen
(
value
.
data
()),
&
napiValue
));
return
napiValue
;
}
...
...
@@ -294,35 +291,29 @@ static void GetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext)
std
::
vector
<
char
>
value
(
MAX_VALUE_LENGTH
,
0
);
asyncContext
->
status
=
GetParameter
(
asyncContext
->
key
,
(
asyncContext
->
valueLen
==
0
)
?
nullptr
:
asyncContext
->
value
,
value
.
data
(),
MAX_VALUE_LENGTH
);
asyncContext
->
getValue
=
std
::
string
(
value
.
begin
(),
value
.
end
());
if
(
asyncContext
->
status
==
0
)
{
asyncContext
->
getValue
=
""
;
}
else
if
(
asyncContext
->
status
>
0
)
{
asyncContext
->
getValue
=
std
::
string
(
value
.
begin
(),
value
.
end
());
}
},
[](
napi_env
env
,
napi_status
status
,
void
*
data
)
{
StorageAsyncContext
*
asyncContext
=
reinterpret_cast
<
StorageAsyncContext
*>
(
data
);
napi_value
result
[
ARGC_NUMBER
]
=
{
0
};
if
(
asyncContext
->
status
>
0
)
{
if
(
asyncContext
->
status
>
=
0
)
{
napi_get_undefined
(
env
,
&
result
[
0
]);
napi_create_string_utf8
(
env
,
asyncContext
->
getValue
.
c_str
(),
strlen
(
asyncContext
->
getValue
.
c_str
()),
&
result
[
1
]);
}
else
{
if
(
asyncContext
->
status
==
SYSPARAM_NOT_FOUND
)
{
napi_get_undefined
(
env
,
&
result
[
0
]);
napi_create_string_utf8
(
env
,
asyncContext
->
getValue
.
c_str
(),
strlen
(
asyncContext
->
getValue
.
c_str
()),
&
result
[
1
]);
}
else
{
result
[
0
]
=
BusinessErrorCreate
(
env
,
asyncContext
->
status
);
napi_get_undefined
(
env
,
&
result
[
1
]);
}
result
[
0
]
=
BusinessErrorCreate
(
env
,
asyncContext
->
status
);
napi_get_undefined
(
env
,
&
result
[
1
]);
}
if
(
asyncContext
->
deferred
)
{
if
(
asyncContext
->
status
>
0
)
{
napi_resolve_deferred
(
env
,
asyncContext
->
deferred
,
result
[
1
]);
}
else
{
if
(
asyncContext
->
status
==
SYSPARAM_NOT_FOUND
)
{
napi_resolve_deferred
(
env
,
asyncContext
->
deferred
,
result
[
1
]);
}
else
{
napi_reject_deferred
(
env
,
asyncContext
->
deferred
,
result
[
0
]);
}
napi_reject_deferred
(
env
,
asyncContext
->
deferred
,
result
[
0
]);
}
}
else
{
napi_value
callback
=
nullptr
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录