Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
2c1fd695
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
2c1fd695
编写于
5月 04, 2023
作者:
O
openharmony_ci
提交者:
Gitee
5月 04, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8562 fix codecheck of pr8445
Merge pull request !8562 from huangzhenghua/master20230425
上级
ca7c65e8
9e86d127
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
18 deletion
+23
-18
arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp
arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp
+23
-18
未找到文件。
arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp
浏览文件 @
2c1fd695
...
...
@@ -26,6 +26,7 @@
static
napi_ref
test_reference
=
NULL
;
const
int
TAG_NUMBER
=
666
;
const
int
NUMBER_FIVE
=
5
;
static
void
add_returned_status
(
napi_env
env
,
const
char
*
key
,
...
...
@@ -625,11 +626,11 @@ static napi_value createAndGetStringLatin1(napi_env env, napi_callback_info info
"Wrong type of argment. Expects a string."
);
char
buffer
[
128
];
size_t
buffer
_s
ize
=
128
;
size_t
buffer
S
ize
=
128
;
size_t
copied
=
0
;
NAPI_CALL
(
env
,
napi_get_value_string_latin1
(
env
,
args
[
0
],
buffer
,
buffer
_s
ize
,
&
copied
));
napi_get_value_string_latin1
(
env
,
args
[
0
],
buffer
,
buffer
S
ize
,
&
copied
));
NAPI_ASSERT
(
env
,
copied
==
3
,
"napi_get_value_string_latin1 fail"
);
napi_value
output
;
...
...
@@ -653,11 +654,11 @@ static napi_value createAndGetStringUtf8(napi_env env, napi_callback_info info)
"Wrong type of argment. Expects a string."
);
char
buffer
[
128
];
size_t
buffer
_s
ize
=
128
;
size_t
buffer
S
ize
=
128
;
size_t
copied
=
0
;
NAPI_CALL
(
env
,
napi_get_value_string_utf8
(
env
,
args
[
0
],
buffer
,
buffer
_s
ize
,
&
copied
));
napi_get_value_string_utf8
(
env
,
args
[
0
],
buffer
,
buffer
S
ize
,
&
copied
));
NAPI_ASSERT
(
env
,
copied
==
2
,
"napi_get_value_string_utf8 fail"
);
napi_value
output
;
...
...
@@ -666,7 +667,8 @@ static napi_value createAndGetStringUtf8(napi_env env, napi_callback_info info)
return
output
;
}
static
napi_value
CreateAndGetStringUtf16
(
napi_env
env
,
napi_callback_info
info
)
{
static
napi_value
CreateAndGetStringUtf16
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
args
[
1
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
NULL
,
NULL
));
...
...
@@ -679,10 +681,10 @@ static napi_value CreateAndGetStringUtf16(napi_env env, napi_callback_info info)
NAPI_ASSERT
(
env
,
valuetype
==
napi_string
,
"Expect a string."
);
char16_t
buffer
[
128
];
// 128: char16_t type of element size
size_t
buffer
_s
ize
=
128
;
// 128: char16_t type of element size
size_t
buffer
S
ize
=
128
;
// 128: char16_t type of element size
size_t
copied
=
0
;
NAPI_CALL
(
env
,
napi_get_value_string_utf16
(
env
,
args
[
0
],
buffer
,
buffer
_s
ize
,
&
copied
));
NAPI_CALL
(
env
,
napi_get_value_string_utf16
(
env
,
args
[
0
],
buffer
,
buffer
S
ize
,
&
copied
));
napi_value
result
;
NAPI_CALL
(
env
,
napi_create_string_utf16
(
env
,
buffer
,
copied
,
&
result
));
...
...
@@ -690,7 +692,8 @@ static napi_value CreateAndGetStringUtf16(napi_env env, napi_callback_info info)
return
result
;
}
static
napi_value
StringUtf16OfCase
(
napi_env
env
,
napi_callback_info
info
)
{
static
napi_value
StringUtf16OfCase
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
args
[
1
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
NULL
,
NULL
));
...
...
@@ -703,11 +706,11 @@ static napi_value StringUtf16OfCase(napi_env env, napi_callback_info info) {
NAPI_ASSERT
(
env
,
valuetype
==
napi_string
,
"Expects a string."
);
char16_t
buffer
[
5
];
// 5: char16_t type of element size
size_t
buffer
_s
ize
=
5
;
// 5: char16_t type of element size
size_t
buffer
S
ize
=
5
;
// 5: char16_t type of element size
size_t
copied
=
0
;
NAPI_CALL
(
env
,
napi_get_value_string_utf16
(
env
,
args
[
0
],
buffer
,
buffer
_s
ize
,
&
copied
));
napi_get_value_string_utf16
(
env
,
args
[
0
],
buffer
,
buffer
S
ize
,
&
copied
));
napi_value
result
;
NAPI_CALL
(
env
,
napi_create_string_utf16
(
env
,
buffer
,
copied
,
&
result
));
...
...
@@ -715,7 +718,7 @@ static napi_value StringUtf16OfCase(napi_env env, napi_callback_info info) {
return
result
;
}
static
const
napi_type_tag
typeTags
[
5
]
=
{
static
const
napi_type_tag
typeTags
[
NUMBER_FIVE
]
=
{
{
0xdaf987b3cc62481a
,
0xb745b0497f299531
},
{
0xbb7936c374084d9b
,
0xa9548d0762eeedb9
},
{
0xa5ed9ce2e4c00c38
,
0xa9548d0762eeedb1
},
...
...
@@ -723,21 +726,23 @@ static const napi_type_tag typeTags[5] = {
{
0xa5ed9ce2e4c00c38
,
0xdaf987b3cc62481a
},
};
static
napi_value
TypeTaggedInstance
(
napi_env
env
,
napi_callback_info
info
)
{
static
napi_value
TypeTaggedInstance
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
uint32_t
typeIndex
=
0
;
napi_value
instance
=
nullptr
;
napi_value
instance
=
nullptr
;
napi_value
whichType
=
nullptr
;
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
&
whichType
,
NULL
,
NULL
));
NAPI_CALL
(
env
,
napi_get_value_uint32
(
env
,
whichType
,
&
typeIndex
));
NAPI_ASSERT
(
env
,
typeIndex
<=
5
,
"typeIndex out of range"
);
NAPI_ASSERT
(
env
,
typeIndex
<=
NUMBER_FIVE
,
"typeIndex out of range"
);
NAPI_CALL
(
env
,
napi_create_object
(
env
,
&
instance
));
NAPI_CALL
(
env
,
napi_type_tag_object
(
env
,
instance
,
&
typeTags
[
typeIndex
]));
return
instance
;
}
static
napi_value
CheckTypeTag
(
napi_env
env
,
napi_callback_info
info
)
{
static
napi_value
CheckTypeTag
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
2
;
bool
result
;
napi_value
argv
[
2
];
...
...
@@ -748,7 +753,7 @@ static napi_value CheckTypeTag(napi_env env, napi_callback_info info) {
NAPI_CALL
(
env
,
napi_get_value_uint32
(
env
,
argv
[
0
],
&
typeIndex
));
NAPI_ASSERT
(
env
,
typeIndex
<=
5
,
"typeIndex out of range"
);
NAPI_ASSERT
(
env
,
typeIndex
<=
NUMBER_FIVE
,
"typeIndex out of range"
);
NAPI_CALL
(
env
,
napi_check_object_type_tag
(
env
,
argv
[
1
],
&
typeTags
[
typeIndex
],
&
result
));
NAPI_CALL
(
env
,
napi_get_boolean
(
env
,
result
,
&
jsResult
));
...
...
@@ -1731,11 +1736,11 @@ static napi_value TestLatin1(napi_env env, napi_callback_info info)
"Wrong type of argment. Expects a string."
);
char
buffer
[
128
];
size_t
buffer
_s
ize
=
128
;
size_t
buffer
S
ize
=
128
;
size_t
copied
;
NAPI_CALL
(
env
,
napi_get_value_string_latin1
(
env
,
args
[
0
],
buffer
,
buffer
_s
ize
,
&
copied
));
napi_get_value_string_latin1
(
env
,
args
[
0
],
buffer
,
buffer
S
ize
,
&
copied
));
napi_value
output
;
NAPI_CALL
(
env
,
napi_create_string_latin1
(
env
,
buffer
,
copied
,
&
output
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录