diff --git a/util/js_textdecoder.cpp b/util/js_textdecoder.cpp index b5c412c6f1e05391b7ed23180cb5c2a00e647aeb..d0b2a40511532c9b361695e59942baf9b6f94467 100755 --- a/util/js_textdecoder.cpp +++ b/util/js_textdecoder.cpp @@ -32,20 +32,21 @@ namespace OHOS::Util { uint32_t i32Flag = 0; if (optionVec.size() == 2) { // 2:Meaning of optionVec size 2 if (optionVec[0] >= 0 && optionVec[1] >= 0) { - i32Flag |= optionVec[0] ? FATAL_FLG : 0; - i32Flag |= optionVec[1] ? IGNORE_BOM_FLG : 0; + i32Flag |= optionVec[0] ? static_cast(ConverterFlags::FATAL_FLG) : 0; + i32Flag |= optionVec[1] ? static_cast(ConverterFlags::IGNORE_BOM_FLG) : 0; } else if (optionVec[0] >= 0 && optionVec[1] < 0) { - i32Flag |= optionVec[0] ? FATAL_FLG : 0; + i32Flag |= optionVec[0] ? static_cast(ConverterFlags::FATAL_FLG) : 0; } else if (optionVec[0] < 0 && optionVec[1] >= 0) { - i32Flag |= optionVec[1] ? IGNORE_BOM_FLG : 0; + i32Flag |= optionVec[1] ? static_cast(ConverterFlags::IGNORE_BOM_FLG) : 0; } } label_ = i32Flag; bool fatal = - (i32Flag & FATAL_FLG) == FATAL_FLG; + (i32Flag & static_cast(ConverterFlags::FATAL_FLG)) == + static_cast(ConverterFlags::FATAL_FLG); UErrorCode codeflag = U_ZERO_ERROR; - char* pStr = const_cast(encStr_.c_str()); - UConverter* conv = ucnv_open(pStr, &codeflag); + char *pStr = const_cast(encStr_.c_str()); + UConverter *conv = ucnv_open(pStr, &codeflag); if (U_FAILURE(codeflag)) { HILOG_ERROR("ucnv_open failed !"); return; @@ -62,19 +63,20 @@ namespace OHOS::Util { napi_value TextDecoder::Decode(napi_value src, bool iflag) { uint32_t flags = 0; - flags |= iflag ? 0 : FLUSH_FLG; - UBool flush = ((flags & FLUSH_FLG)) == FLUSH_FLG; + flags |= iflag ? 0 : static_cast(ConverterFlags::FLUSH_FLG); + UBool flush = ((flags & static_cast(ConverterFlags::FLUSH_FLG))) == + static_cast(ConverterFlags::FLUSH_FLG); napi_typedarray_type type; size_t length = 0; - void* data1 = nullptr; + void *data1 = nullptr; size_t byteOffset = 0; napi_value arrayBuffer = nullptr; NAPI_CALL(env_, napi_get_typedarray_info(env_, src, &type, &length, &data1, &arrayBuffer, &byteOffset)); - const char* source = static_cast(data1); + const char *source = static_cast(data1); UErrorCode codeFlag = U_ZERO_ERROR; - size_t limit = GetMinByteSize() * length; - size_t len = limit * sizeof(UChar); - UChar* arr = nullptr; + size_t limit = GetMinByteSize() *length; + size_t len = limit *sizeof(UChar); + UChar *arr = nullptr; if (limit > 0) { arr = new UChar[limit + 1]; if (memset_s(arr, len + sizeof(UChar), 0, len + sizeof(UChar)) != 0) { @@ -86,26 +88,24 @@ namespace OHOS::Util { HILOG_ERROR("limit is error"); return nullptr; } - UChar* target = arr; + UChar *target = arr; size_t tarStartPos = (intptr_t)arr; ucnv_toUnicode(GetConverterPtr(), &target, target + len, &source, source + length, nullptr, flush, &codeFlag); size_t resultLength = 0; bool omitInitialBom = false; DecodeArr decArr(target, tarStartPos, limit); SetBomFlag(arr, codeFlag, decArr, resultLength, omitInitialBom); - UChar* arrDat = arr; + UChar *arrDat = arr; if (omitInitialBom && resultLength > 0) { arrDat = &arr[2]; // 2: Obtains the 2 value of the array. } std::u16string tempStr16(arrDat); std::string tepStr = std::wstring_convert, char16_t> {}.to_bytes(tempStr16); - const char* tempCh = tepStr.c_str(); - char* rstCh = const_cast(tempCh); napi_value resultStr = nullptr; - NAPI_CALL(env_, napi_create_string_utf8(env_, rstCh, strlen(rstCh), &resultStr)); + NAPI_CALL(env_, napi_create_string_utf8(env_, tepStr.c_str(), tepStr.size(), &resultStr)); FreedMemory(arr); if (flush) { - label_ &= BOM_SEEN_FLG; + label_ &= static_cast(ConverterFlags::BOM_SEEN_FLG); Reset(); } return resultStr; @@ -121,9 +121,9 @@ namespace OHOS::Util { napi_value TextDecoder::GetFatal() const { - uint32_t temp = label_ & FATAL_FLG; + uint32_t temp = label_ & static_cast(ConverterFlags::FATAL_FLG); bool comRst = false; - if (temp == FATAL_FLG) { + if (temp == static_cast(ConverterFlags::FATAL_FLG)) { comRst = true; } else { comRst = false; @@ -135,9 +135,9 @@ namespace OHOS::Util { napi_value TextDecoder::GetIgnoreBOM() const { - uint32_t temp = label_ & IGNORE_BOM_FLG; + uint32_t temp = label_ & static_cast(ConverterFlags::IGNORE_BOM_FLG); bool comRst = false; - if (temp == IGNORE_BOM_FLG) { + if (temp == static_cast(ConverterFlags::IGNORE_BOM_FLG)) { comRst = true; } else { comRst = false; @@ -172,7 +172,8 @@ namespace OHOS::Util { } } - void TextDecoder::SetBomFlag(const UChar* arr, const UErrorCode codeFlag, const DecodeArr decArr , size_t &rstLen, bool &bomFlag) + void TextDecoder::SetBomFlag(const UChar *arr, const UErrorCode codeFlag, const DecodeArr decArr, + size_t &rstLen, bool &bomFlag) { if (arr == nullptr ) { return; @@ -182,7 +183,7 @@ namespace OHOS::Util { rstLen = (intptr_t)decArr.target - decArr.tarStartPos; if (rstLen > 0 && IsUnicode() && !IsIgnoreBom() && !IsBomFlag()) { bomFlag = (arr[0] == 0xFEFF) ? true : false; - label_ |= BOM_SEEN_FLG; + label_ |= static_cast(ConverterFlags::BOM_SEEN_FLG); } } } diff --git a/util/js_textdecoder.h b/util/js_textdecoder.h index 7f94fd926b7befcf025ea9f235a26ccd8bdf9061..a0901aee24685c148da49858515bdbab61625367 100755 --- a/util/js_textdecoder.h +++ b/util/js_textdecoder.h @@ -26,19 +26,19 @@ using TransformToolPointer = std::unique_ptr; namespace OHOS::Util { struct DecodeArr { - DecodeArr(UChar* tarPos, size_t tarStaPos, size_t limLen) { + DecodeArr(UChar *tarPos, size_t tarStaPos, size_t limLen) { this->target = tarPos; this->tarStartPos = tarStaPos; this->limitLen = limLen; } - UChar* target = 0; + UChar *target = 0; size_t tarStartPos = 0; size_t limitLen = 0; }; class TextDecoder { public: - enum ConverterFlags { + enum class ConverterFlags { FLUSH_FLG = 0x1, FATAL_FLG = 0x2, IGNORE_BOM_FLG = 0x4, @@ -60,8 +60,8 @@ namespace OHOS::Util { } bool IsBomFlag() const { - uint32_t temp = label_ & BOM_SEEN_FLG; - if (temp == BOM_SEEN_FLG) { + uint32_t temp = label_ & static_cast(ConverterFlags::BOM_SEEN_FLG); + if (temp == static_cast(ConverterFlags::BOM_SEEN_FLG)) { return true; } else { return false; @@ -69,8 +69,8 @@ namespace OHOS::Util { } bool IsUnicode() const { - uint32_t temp = label_ & UNICODE_FLG; - if (temp == UNICODE_FLG) { + uint32_t temp = label_ & static_cast(ConverterFlags::UNICODE_FLG); + if (temp == static_cast(ConverterFlags::UNICODE_FLG)) { return true; } else { return false; @@ -78,20 +78,20 @@ namespace OHOS::Util { } bool IsIgnoreBom() const { - uint32_t temp = label_ & IGNORE_BOM_FLG; - if (temp == IGNORE_BOM_FLG) { + uint32_t temp = label_ & static_cast(ConverterFlags::IGNORE_BOM_FLG); + if (temp == static_cast(ConverterFlags::IGNORE_BOM_FLG)) { return true; } else { return false; } } - static void ConverterClose(UConverter* pointer) + static void ConverterClose(UConverter *pointer) { ucnv_close(pointer); } private: - void SetBomFlag(const UChar* arr, const UErrorCode codeFlag, const DecodeArr decArr, size_t& rstLen, bool& bomFlag); - void FreedMemory(UChar* pData); + void SetBomFlag(const UChar *arr, const UErrorCode codeFlag, const DecodeArr decArr, size_t& rstLen, bool& bomFlag); + void FreedMemory(UChar *pData); napi_env env_; uint32_t label_; std::string encStr_; diff --git a/util/js_textencoder.cpp b/util/js_textencoder.cpp index efe55a791ac6a2bcff71efd1cfa401757dd1dd7b..2acd9bdc594efc97af414d2b97cc8745b879308f 100755 --- a/util/js_textencoder.cpp +++ b/util/js_textencoder.cpp @@ -44,7 +44,7 @@ namespace OHOS::Util { NAPI_CALL(env_, napi_get_value_string_utf8(env_, src, buffer, bufferSize + 1, &bufferSize)); - void* data = nullptr; + void *data = nullptr; napi_value arrayBuffer = nullptr; NAPI_CALL(env_, napi_create_arraybuffer(env_, bufferSize, &data, &arrayBuffer)); if (memcpy_s(data, bufferSize, reinterpret_cast(buffer), bufferSize) != 0) { @@ -65,16 +65,16 @@ namespace OHOS::Util { napi_typedarray_type type; size_t byteOffset = 0; size_t length = 0; - void* resultData = nullptr; + void *resultData = nullptr; napi_value resultBuffer = nullptr; NAPI_CALL(env_, napi_get_typedarray_info(env_, dest, &type, &length, &resultData, &resultBuffer, &byteOffset)); - char* writeResult = static_cast(resultData) + byteOffset; + char *writeResult = static_cast(resultData) + byteOffset; int32_t nchars = 0; int32_t written = 0; - NativeEngine* engine = reinterpret_cast(env_); - NativeValue* nativeValue = reinterpret_cast(src); + NativeEngine *engine = reinterpret_cast(env_); + NativeValue *nativeValue = reinterpret_cast(src); engine->EncodeToUtf8(nativeValue, writeResult, &written, length, &nchars); napi_value result = nullptr; diff --git a/util/native_module_util.cpp b/util/native_module_util.cpp index e6f372e42b68cb07ffbc98475e7e49dfa45d3ca6..caf7ff3dda52d46bac45b60797b45e8929d71f75 100755 --- a/util/native_module_util.cpp +++ b/util/native_module_util.cpp @@ -115,7 +115,7 @@ namespace OHOS::Util { argv = new napi_value[argc]; } napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - char* format = nullptr; + char *format = nullptr; size_t formatsize = 0; napi_get_value_string_utf8(env, argv[0], nullptr, 0, &formatsize); if (formatsize > 0) { @@ -149,7 +149,7 @@ namespace OHOS::Util { if (argc > 0) { argv = new napi_value[argc]; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - char* format = nullptr; + char *format = nullptr; size_t formatsize = 0; napi_get_value_string_utf8(env, argv[0], nullptr, 0, &formatsize); if (formatsize > 0) { @@ -159,7 +159,7 @@ namespace OHOS::Util { std::string printInfo; std::vector value; for (size_t i = 1; i < argc; i++) { - char* valueString = nullptr; + char *valueString = nullptr; size_t valuesize = 0; napi_get_value_string_utf8(env, argv[i], nullptr, 0, &valuesize); if (valuesize > 0) { @@ -223,9 +223,9 @@ namespace OHOS::Util { static napi_value GetSecPara(napi_env env, napi_value valData, std::vector ¶Vec) { napi_value messageKeyFatal = nullptr; - const char* messageKeyStrFatal = "fatal"; + const char *messageKeyStrFatal = "fatal"; napi_value messageKeyIgnorebom = nullptr; - const char* messageKeyStrIgnorebom = "ignoreBOM"; + const char *messageKeyStrIgnorebom = "ignoreBOM"; napi_value resultFatal = nullptr; napi_value resultIgnorebom = nullptr; bool bResultFat = false; @@ -248,8 +248,8 @@ namespace OHOS::Util { napi_value thisVar = nullptr; napi_get_cb_info(env, info, &tempArgc, nullptr, &thisVar, nullptr); size_t argc = 0; - void* data = nullptr; - char* type = nullptr; + void *data = nullptr; + char *type = nullptr; size_t typeLen = 0; std::vector paraVec(2, 0); // 2: Specifies the size of the container to be applied for. if (tempArgc == 1) { @@ -284,7 +284,7 @@ namespace OHOS::Util { auto objectInfo = new TextDecoder(env, enconding, paraVec); NAPI_CALL(env, napi_wrap( env, thisVar, objectInfo, - [](napi_env env, void* data, void* hint) { + [](napi_env env, void *data, void *hint) { auto objInfo = (TextDecoder*)data; if (objInfo != nullptr) { delete objInfo; @@ -300,14 +300,14 @@ namespace OHOS::Util { napi_value thisVar = nullptr; napi_get_cb_info(env, info, &tempArgc, nullptr, &thisVar, nullptr); size_t argc = 0; - void* dataPara = nullptr; + void *dataPara = nullptr; napi_typedarray_type type; size_t length = 0; - void* data = nullptr; + void *data = nullptr; napi_value arraybuffer = nullptr; size_t byteOffset = 0; bool iStream = false; - TextDecoder* textDecoder = nullptr; + TextDecoder *textDecoder = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&textDecoder)); napi_value valStr = nullptr; if (tempArgc == 1) { @@ -325,7 +325,7 @@ namespace OHOS::Util { NAPI_CALL(env, napi_get_typedarray_info(env, argv[0], &type, &length, &data, &arraybuffer, &byteOffset)); // second para napi_value messageKeyStream = nullptr; - const char* messageKeyStrStream = "stream"; + const char *messageKeyStrStream = "stream"; napi_value resultStream = nullptr; NAPI_CALL(env, napi_create_string_utf8(env, messageKeyStrStream, strlen(messageKeyStrStream), @@ -341,7 +341,7 @@ namespace OHOS::Util { { napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr)); - TextDecoder* textDecoder = nullptr; + TextDecoder *textDecoder = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&textDecoder)); napi_value retVal = textDecoder->GetEncoding(); return retVal; @@ -351,7 +351,7 @@ namespace OHOS::Util { { napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr)); - TextDecoder* textDecoder = nullptr; + TextDecoder *textDecoder = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&textDecoder)); napi_value retVal = textDecoder->GetFatal(); return retVal; @@ -361,7 +361,7 @@ namespace OHOS::Util { { napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr)); - TextDecoder* textDecoder = nullptr; + TextDecoder *textDecoder = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&textDecoder)); napi_value retVal = textDecoder->GetIgnoreBOM(); return retVal; @@ -371,13 +371,13 @@ namespace OHOS::Util { static napi_value TextEncoderConstructor(napi_env env, napi_callback_info info) { napi_value thisVar = nullptr; - void* data = nullptr; + void *data = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, &data)); auto object = new TextEncoder(env); NAPI_CALL(env, napi_wrap( env, thisVar, object, - [](napi_env env, void* data, void* hint) { + [](napi_env env, void *data, void *hint) { auto obj = (TextEncoder*)data; if (obj != nullptr) { delete obj; @@ -392,7 +392,7 @@ namespace OHOS::Util { napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr)); - TextEncoder* object = nullptr; + TextEncoder *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); return object->GetEncoding(); @@ -413,7 +413,7 @@ namespace OHOS::Util { NAPI_ASSERT(env, valuetype == napi_string, "Wrong argument type. String expected."); - TextEncoder* object = nullptr; + TextEncoder *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); napi_value result = object->Encode(args); @@ -436,7 +436,7 @@ namespace OHOS::Util { napi_typedarray_type valuetype1; size_t length = 0; - void* data = nullptr; + void *data = nullptr; napi_value arraybuffer = nullptr; size_t byteOffset = 0; NAPI_CALL(env, napi_get_typedarray_info(env, args[1], &valuetype1, &length, &data, &arraybuffer, &byteOffset)); @@ -444,7 +444,7 @@ namespace OHOS::Util { NAPI_ASSERT(env, valuetype0 == napi_string, "Wrong argument type. String expected."); NAPI_ASSERT(env, valuetype1 == napi_uint8_array, "Wrong argument type. napi_uint8_array expected."); - TextEncoder* object = nullptr; + TextEncoder *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); napi_value result = object->EncodeInto(args[0], args[1]); @@ -455,7 +455,7 @@ namespace OHOS::Util { static napi_value RationalNumberConstructor(napi_env env, napi_callback_info info) { napi_value thisVar = nullptr; - void* data = nullptr; + void *data = nullptr; size_t argc = 3; napi_value args[2] = { nullptr }; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &thisVar, &data)); @@ -466,7 +466,7 @@ namespace OHOS::Util { auto objectInfo = new RationalNumber(env, num, den); NAPI_CALL(env, napi_wrap( env, thisVar, objectInfo, - [](napi_env env, void* data, void* hint) { + [](napi_env env, void *data, void *hint) { auto objInfo = (RationalNumber*)data; if (objInfo != nullptr) { delete objInfo; @@ -487,7 +487,7 @@ namespace OHOS::Util { napi_valuetype valuetype; NAPI_CALL(env, napi_typeof(env, args, &valuetype)); NAPI_ASSERT(env, valuetype == napi_string, "Wrong argument type. String expected"); - RationalNumber* object = nullptr; + RationalNumber *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); if (RationalNumberClass == nullptr) { napi_throw_error(env, "NullException", "RationalNumberClass must not be null!"); @@ -503,7 +503,7 @@ namespace OHOS::Util { napi_value args = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr)); NAPI_ASSERT(env, argc >= requireArgc, "Wrong nuamber of arguments"); - RationalNumber* object = nullptr; + RationalNumber *object = nullptr; napi_unwrap(env, thisVar, (void**)&object); return object->CompareTo(args); } @@ -516,7 +516,7 @@ namespace OHOS::Util { napi_value args = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr)); NAPI_ASSERT(env, argc >= requireArgc, "Wrong nuamber of arguments"); - RationalNumber* object = nullptr; + RationalNumber *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); return object->Equals(args); } @@ -525,7 +525,7 @@ namespace OHOS::Util { { napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr)); - RationalNumber* object = nullptr; + RationalNumber *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); return object->Value(); } @@ -535,7 +535,7 @@ namespace OHOS::Util { size_t argc = 2; napi_value argv[2] = {0}; napi_value thisVar = nullptr; - void* data = nullptr; + void *data = nullptr; napi_value args = nullptr; napi_get_cb_info(env, info, &argc, argv, &thisVar, &data); NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr)); @@ -545,7 +545,7 @@ namespace OHOS::Util { NAPI_CALL(env, napi_typeof(env, argv[1], &valuetype2)); NAPI_ASSERT(env, valuetype1 == napi_number, "Wrong argument type. String expected"); NAPI_ASSERT(env, valuetype2 == napi_number, "Wrong argument type. String expected"); - RationalNumber* object = nullptr; + RationalNumber *object = nullptr; napi_unwrap(env, thisVar, (void**)&object); napi_value result = nullptr; result = object->GetCommonDivisor(argv[0], argv[1]); @@ -556,7 +556,7 @@ namespace OHOS::Util { { napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr)); - RationalNumber* object = nullptr; + RationalNumber *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); napi_value result = object->GetDenominator(); return result; @@ -566,7 +566,7 @@ namespace OHOS::Util { { napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr)); - RationalNumber* object = nullptr; + RationalNumber *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); napi_value result = object->GetNumerator(); return result; @@ -576,7 +576,7 @@ namespace OHOS::Util { { napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr)); - RationalNumber* object = nullptr; + RationalNumber *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); napi_value result = object->IsFinite(); return result; @@ -586,7 +586,7 @@ namespace OHOS::Util { { napi_value thisVar = nullptr; napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); - RationalNumber* object = nullptr; + RationalNumber *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); napi_value result = object->IsInfinite(); return result; @@ -596,7 +596,7 @@ namespace OHOS::Util { { napi_value thisVar = nullptr; napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); - RationalNumber* object = nullptr; + RationalNumber *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); napi_value result = object->IsNaN(); return result; @@ -605,7 +605,7 @@ namespace OHOS::Util { { napi_value thisVar = nullptr; napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); - RationalNumber* object = nullptr; + RationalNumber *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); napi_value result = object->IsZero(); return result; @@ -615,7 +615,7 @@ namespace OHOS::Util { { napi_value thisVar = nullptr; napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); - RationalNumber* object = nullptr; + RationalNumber *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); napi_value result = object->ToString(); return result; @@ -623,7 +623,7 @@ namespace OHOS::Util { static napi_value RationalNumberInit(napi_env env, napi_value exports) { - const char* RationalNumberClassName = "RationalNumber"; + const char *RationalNumberClassName = "RationalNumber"; static napi_property_descriptor RationalNumberDesc[] = { DECLARE_NAPI_FUNCTION("creatRationalFromString", CreatRationalFromString), DECLARE_NAPI_FUNCTION("compareTo", CompareTo), @@ -651,7 +651,7 @@ namespace OHOS::Util { static napi_value TextcoderInit(napi_env env, napi_value exports) { - const char* textEncoderClassName = "TextEncoder"; + const char *textEncoderClassName = "TextEncoder"; napi_value textEncoderClass = nullptr; static napi_property_descriptor textEncoderDesc[] = { DECLARE_NAPI_GETTER("encoding", GetEncoding), @@ -663,7 +663,7 @@ namespace OHOS::Util { sizeof(textEncoderDesc) / sizeof(textEncoderDesc[0]), textEncoderDesc, &textEncoderClass)); - const char* textDecoderClassName = "TextDecoder"; + const char *textDecoderClassName = "TextDecoder"; napi_value textDecoderClass = nullptr; static napi_property_descriptor textdecoderDesc[] = { DECLARE_NAPI_FUNCTION("decode", TextdecoderDecode), @@ -688,12 +688,12 @@ namespace OHOS::Util { static napi_value Base64Constructor(napi_env env, napi_callback_info info) { napi_value thisVar = nullptr; - void* data = nullptr; + void *data = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, &data)); auto objectInfo = new Base64(env); napi_wrap( env, thisVar, objectInfo, - [](napi_env env, void* data, void* hint) { + [](napi_env env, void *data, void *hint) { auto objInfo = (Base64*)data; if (objInfo != nullptr) { delete objInfo; @@ -713,7 +713,7 @@ namespace OHOS::Util { NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments"); napi_typedarray_type valuetype0; size_t length = 0; - void* data = nullptr; + void *data = nullptr; napi_value arraybuffer = nullptr; size_t byteOffset = 0; NAPI_CALL(env, napi_get_typedarray_info(env, args[0], &valuetype0, &length, &data, &arraybuffer, &byteOffset)); @@ -721,7 +721,7 @@ namespace OHOS::Util { NAPI_CALL(env, napi_typeof(env, args[1], &valuetype1)); NAPI_ASSERT(env, valuetype0 == napi_uint8_array, "Wrong argument type. napi_uint8_array expected."); NAPI_ASSERT(env, valuetype1 == napi_number, "Wrong argument type. Nmuber expected."); - Base64* object = nullptr; + Base64 *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); napi_value result = object->Encode(args[0], args[1]); return result; @@ -737,7 +737,7 @@ namespace OHOS::Util { NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments"); napi_typedarray_type valuetype0; size_t length = 0; - void* data = nullptr; + void *data = nullptr; napi_value arraybuffer = nullptr; size_t byteOffset = 0; NAPI_CALL(env, napi_get_typedarray_info(env, args[0], &valuetype0, &length, &data, &arraybuffer, &byteOffset)); @@ -745,7 +745,7 @@ namespace OHOS::Util { NAPI_CALL(env, napi_typeof(env, args[1], &valuetype1)); NAPI_ASSERT(env, valuetype0 == napi_uint8_array, "Wrong argument type. napi_uint8_array expected."); NAPI_ASSERT(env, valuetype1 == napi_number, "Wrong argument type. Nmuber expected."); - Base64* object = nullptr; + Base64 *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); napi_value result = object->EncodeToString(args[0], args[1]); return result; @@ -762,7 +762,7 @@ namespace OHOS::Util { napi_typedarray_type valuetype0; napi_valuetype valuetype1; size_t length = 0; - void* data = nullptr; + void *data = nullptr; napi_value arraybuffer = nullptr; size_t byteOffset = 0; NAPI_CALL(env, napi_typeof(env, args[0], &valuetype1)); @@ -776,7 +776,7 @@ namespace OHOS::Util { napi_valuetype valuetype2; NAPI_CALL(env, napi_typeof(env, args[1], &valuetype2)); NAPI_ASSERT(env, valuetype2 == napi_number, "Wrong argument type. Nmuber expected."); - Base64* object = nullptr; + Base64 *object = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object)); napi_value result = object->Decode(args[0], args[1]); return result; @@ -784,7 +784,7 @@ namespace OHOS::Util { static napi_value Base64Init(napi_env env, napi_value exports) { - const char* base64ClassName = "Base64"; + const char *base64ClassName = "Base64"; napi_value base64Class = nullptr; static napi_property_descriptor base64Desc[] = { DECLARE_NAPI_FUNCTION("encode", EncodeBase64), @@ -835,7 +835,7 @@ namespace OHOS::Util { // util JS register extern "C" - __attribute__((visibility("default"))) void NAPI_util_GetJSCode(const char** buf, int* buflen) + __attribute__((visibility("default"))) void NAPI_util_GetJSCode(const char **buf, int *buflen) { if (buf != nullptr) { *buf = _binary_util_js_js_start;