mirror of
https://gitee.com/openharmony/commonlibrary_ets_utils
synced 2024-11-26 17:12:32 +00:00
NAPI fix warnings
Issues: https://gitee.com/openharmony/arkui_napi/issues/IAWCZP Signed-off-by: wangbowen36 <wangbowen36@huawei.com>
This commit is contained in:
parent
15d451c88b
commit
84169346cb
@ -58,7 +58,7 @@ namespace OHOS::Util {
|
||||
char *writeResult = static_cast<char*>(resultData);
|
||||
|
||||
int32_t nchars = 0;
|
||||
int32_t written = 0;
|
||||
uint32_t written = 0;
|
||||
TextEcodeInfo encodeInfo(env, src, encoding_);
|
||||
EncodeToUtf8(encodeInfo, writeResult, &written, length, &nchars);
|
||||
|
||||
@ -71,7 +71,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "read", read));
|
||||
|
||||
napi_value resWritten = nullptr;
|
||||
NAPI_CALL(env, napi_create_int32(env, written, &resWritten));
|
||||
NAPI_CALL(env, napi_create_uint32(env, written, &resWritten));
|
||||
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "written", resWritten));
|
||||
|
||||
|
@ -101,7 +101,7 @@ void EncodeConversion(napi_env env, napi_value src, napi_value* arrayBuffer, siz
|
||||
}
|
||||
}
|
||||
|
||||
void EncodeToUtf8(TextEcodeInfo encodeInfo, char* writeResult, int32_t* written, size_t length, int32_t* nchars)
|
||||
void EncodeToUtf8(TextEcodeInfo encodeInfo, char* writeResult, uint32_t* written, size_t length, int32_t* nchars)
|
||||
{
|
||||
NativeEngine *engine = reinterpret_cast<NativeEngine*>(encodeInfo.env);
|
||||
engine->EncodeToUtf8(encodeInfo.src, writeResult, written, length, nchars);
|
||||
|
@ -105,7 +105,7 @@ namespace Commonlibrary::Platform {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void EncodeToUtf8(TextEcodeInfo encodeInfo, char* writeResult, int32_t* written, size_t length, int32_t* nchars)
|
||||
void EncodeToUtf8(TextEcodeInfo encodeInfo, char* writeResult, uint32_t* written, size_t length, int32_t* nchars)
|
||||
{
|
||||
if (encodeInfo.encoding == "utf-16be" || encodeInfo.encoding == "utf-16le") {
|
||||
EncodeTo16BE(encodeInfo, writeResult, written, length, nchars);
|
||||
@ -354,7 +354,7 @@ namespace Commonlibrary::Platform {
|
||||
return STATE_OTHER_TWO;
|
||||
}
|
||||
|
||||
void OtherEncodeUtf8(TextEcodeInfo encodeInfo, char* writeResult, int32_t* written, size_t length, int32_t* nchar)
|
||||
void OtherEncodeUtf8(TextEcodeInfo encodeInfo, char* writeResult, uint32_t* written, size_t length, int32_t* nchar)
|
||||
{
|
||||
size_t inputSize = 0;
|
||||
napi_get_value_string_utf16(encodeInfo.env, encodeInfo.src, nullptr, 0, &inputSize);
|
||||
@ -390,11 +390,11 @@ namespace Commonlibrary::Platform {
|
||||
writeResult++;
|
||||
}
|
||||
*nchar = static_cast<int32_t>(outInfo.cntSize);
|
||||
*written = static_cast<int32_t>(writeLength);
|
||||
*written = static_cast<uint32_t>(writeLength);
|
||||
FreedMemory(originalBuffer);
|
||||
}
|
||||
|
||||
void EncodeTo16BE(TextEcodeInfo encodeInfo, char* writeResult, int32_t* written, size_t length, int32_t* nchars)
|
||||
void EncodeTo16BE(TextEcodeInfo encodeInfo, char* writeResult, uint32_t* written, size_t length, int32_t* nchars)
|
||||
{
|
||||
size_t inputSize = 0;
|
||||
napi_get_value_string_utf16(encodeInfo.env, encodeInfo.src, nullptr, 0, &inputSize);
|
||||
@ -432,7 +432,7 @@ namespace Commonlibrary::Platform {
|
||||
return;
|
||||
}
|
||||
*nchars = static_cast<int32_t>(i);
|
||||
*written = static_cast<int32_t>(writeLength);
|
||||
*written = static_cast<uint32_t>(writeLength);
|
||||
FreedMemory(originalBuffer);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ namespace Commonlibrary::Platform {
|
||||
std::string ConvertToString(UChar* uchar, size_t length);
|
||||
void EncodeIntoChinese(napi_env env, napi_value src, std::string encoding, std::string& buffer);
|
||||
std::string UnicodeConversion(std::string encoding, char16_t* originalBuffer, size_t inputSize);
|
||||
void EncodeToUtf8(TextEcodeInfo encodeInfo, char* writeResult, int32_t* written, size_t length, int32_t* nchars);
|
||||
void EncodeToUtf8(TextEcodeInfo encodeInfo, char* writeResult, uint32_t* written, size_t length, int32_t* nchars);
|
||||
void EncodeConversion(napi_env env, napi_value src, napi_value* arrayBuffer, size_t &outLens,
|
||||
std::string encoding);
|
||||
void FreedMemory(char *data);
|
||||
@ -88,8 +88,9 @@ namespace Commonlibrary::Platform {
|
||||
std::u16string Utf16BEToLE(const std::u16string &wstr);
|
||||
void OtherEncode(napi_env env, napi_value src, napi_value* arrayBuffer, size_t &outLens, std::string encoding);
|
||||
std::u16string EncodeUtf16BE(napi_env env, napi_value src);
|
||||
void OtherEncodeUtf8(TextEcodeInfo encodeInfo, char* writeResult, int32_t* written, size_t length, int32_t* nchars);
|
||||
void EncodeTo16BE(TextEcodeInfo encodeInfo, char* writeResult, int32_t* written, size_t length, int32_t* nchars);
|
||||
void OtherEncodeUtf8(TextEcodeInfo encodeInfo, char* writeResult, uint32_t* written, size_t length,
|
||||
int32_t* nchars);
|
||||
void EncodeTo16BE(TextEcodeInfo encodeInfo, char* writeResult, uint32_t* written, size_t length, int32_t* nchars);
|
||||
void FreedMemory(char16_t *&data);
|
||||
char16_t *ApplyMemory(const size_t &inputSize);
|
||||
} // namespace Commonlibrary::Platform
|
||||
|
Loading…
Reference in New Issue
Block a user