mirror of
https://github.com/openharmony/js_util_module.git
synced 2026-07-19 18:23:35 -04:00
Adapted to the napi_get_typedarray_info interface
issue:https://gitee.com/openharmony/arkui_napi/issues/I5OH39 Describe: The napi_get_typedarray_info module in Util is used for adaptation Signed-off-by: yqhan <hanyuqing2@huawei.com>
This commit is contained in:
+6
-6
@@ -46,7 +46,7 @@ namespace OHOS::Util {
|
||||
void *resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
NAPI_CALL(env, napi_get_typedarray_info(env, src, &type, &length, &resultData, &resultBuffer, &byteOffset));
|
||||
inputEncode_ = static_cast<const unsigned char*>(resultData) + byteOffset;
|
||||
inputEncode_ = static_cast<const unsigned char*>(resultData);
|
||||
unsigned char *rets = EncodeAchieve(inputEncode_, length);
|
||||
if (rets == nullptr) {
|
||||
napi_throw_error(env, "-1", "encode input is null");
|
||||
@@ -75,7 +75,7 @@ namespace OHOS::Util {
|
||||
void *resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
NAPI_CALL(env, napi_get_typedarray_info(env, src, &type, &length, &resultData, &resultBuffer, &byteOffset));
|
||||
inputEncode_ = static_cast<const unsigned char*>(resultData) + byteOffset;
|
||||
inputEncode_ = static_cast<const unsigned char*>(resultData);
|
||||
unsigned char *ret = EncodeAchieve(inputEncode_, length);
|
||||
if (ret == nullptr) {
|
||||
FreeMemory(ret);
|
||||
@@ -168,7 +168,7 @@ namespace OHOS::Util {
|
||||
pret = DecodeAchieve(env, inputString, prolen);
|
||||
}
|
||||
} else if (type == napi_typedarray_type::napi_uint8_array) {
|
||||
inputDecode_ = static_cast<const char*>(resultData) + byteOffset;
|
||||
inputDecode_ = static_cast<const char*>(resultData);
|
||||
pret = DecodeAchieve(env, inputDecode_, length);
|
||||
}
|
||||
void *data = nullptr;
|
||||
@@ -290,7 +290,7 @@ namespace OHOS::Util {
|
||||
napi_value resultBuffer = nullptr;
|
||||
NAPI_CALL(env, napi_get_typedarray_info(env, src, &type, &length, &resultData, &resultBuffer, &byteOffset));
|
||||
unsigned char *inputEncode = nullptr;
|
||||
inputEncode = static_cast<unsigned char*>(resultData) + byteOffset;
|
||||
inputEncode = static_cast<unsigned char*>(resultData);
|
||||
CreateEncodePromise(env, inputEncode, length);
|
||||
return stdEncodeInfo_->promise;
|
||||
}
|
||||
@@ -303,7 +303,7 @@ namespace OHOS::Util {
|
||||
napi_value resultBuffer = nullptr;
|
||||
NAPI_CALL(env, napi_get_typedarray_info(env, src, &type, &length, &resultData, &resultBuffer, &byteOffset));
|
||||
unsigned char *inputEncode = nullptr;
|
||||
inputEncode = static_cast<unsigned char*>(resultData) + byteOffset;
|
||||
inputEncode = static_cast<unsigned char*>(resultData);
|
||||
CreateEncodeToStringPromise(env, inputEncode, length);
|
||||
return stdEncodeInfo_->promise;
|
||||
}
|
||||
@@ -453,7 +453,7 @@ namespace OHOS::Util {
|
||||
napi_get_value_string_utf8(env, src, inputString, prolen + 1, &prolen);
|
||||
CreateDecodePromise(env, inputString, prolen);
|
||||
} else if (type == napi_typedarray_type::napi_uint8_array) {
|
||||
inputDecode = static_cast<char*>(resultData) + byteOffset;
|
||||
inputDecode = static_cast<char*>(resultData);
|
||||
CreateDecodePromise(env, inputDecode, length);
|
||||
}
|
||||
return stdDecodeInfo_->promise;
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace OHOS::Util {
|
||||
napi_value resultBuffer = nullptr;
|
||||
NAPI_CALL(env, napi_get_typedarray_info(env, dest, &type, &length, &resultData, &resultBuffer, &byteOffset));
|
||||
|
||||
char *writeResult = static_cast<char*>(resultData) + byteOffset;
|
||||
char *writeResult = static_cast<char*>(resultData);
|
||||
|
||||
int32_t nchars = 0;
|
||||
int32_t written = 0;
|
||||
|
||||
Reference in New Issue
Block a user