mirror of
https://github.com/openharmony/js_util_module.git
synced 2026-07-19 18:23:35 -04:00
+21
-22
@@ -36,10 +36,9 @@ namespace OHOS::Util {
|
||||
121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 61
|
||||
};
|
||||
}
|
||||
Base64::Base64(napi_env env_) : env(env_) {}
|
||||
|
||||
/* base64 encode */
|
||||
napi_value Base64::EncodeSync(napi_value src)
|
||||
napi_value Base64::EncodeSync(napi_env env, napi_value src)
|
||||
{
|
||||
napi_typedarray_type type;
|
||||
size_t byteOffset = 0;
|
||||
@@ -68,7 +67,7 @@ namespace OHOS::Util {
|
||||
}
|
||||
|
||||
/* base64 encodeToString */
|
||||
napi_value Base64::EncodeToStringSync(napi_value src)
|
||||
napi_value Base64::EncodeToStringSync(napi_env env, napi_value src)
|
||||
{
|
||||
napi_typedarray_type type;
|
||||
size_t byteOffset = 0;
|
||||
@@ -141,7 +140,7 @@ namespace OHOS::Util {
|
||||
}
|
||||
|
||||
/* base64 decode */
|
||||
napi_value Base64::DecodeSync(napi_value src)
|
||||
napi_value Base64::DecodeSync(napi_env env, napi_value src)
|
||||
{
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
napi_typeof(env, src, &valuetype);
|
||||
@@ -168,11 +167,11 @@ namespace OHOS::Util {
|
||||
}
|
||||
if (inputString != nullptr) {
|
||||
napi_get_value_string_utf8(env, src, inputString, prolen + 1, &prolen);
|
||||
pret = DecodeAchieve(inputString, prolen);
|
||||
pret = DecodeAchieve(env, inputString, prolen);
|
||||
}
|
||||
} else if (type == napi_typedarray_type::napi_uint8_array) {
|
||||
inputDecode_ = static_cast<const char*>(resultData) + byteOffset;
|
||||
pret = DecodeAchieve(inputDecode_, length);
|
||||
pret = DecodeAchieve(env, inputDecode_, length);
|
||||
}
|
||||
void *data = nullptr;
|
||||
napi_value arrayBuffer = nullptr;
|
||||
@@ -191,7 +190,7 @@ namespace OHOS::Util {
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned char *Base64::DecodeAchieve(const char *input, size_t inputLen)
|
||||
unsigned char *Base64::DecodeAchieve(napi_env env, const char *input, size_t inputLen)
|
||||
{
|
||||
retLen = (inputLen / TRAGET_FOUR) * TRAGET_THREE;
|
||||
decodeOutLen = retLen;
|
||||
@@ -284,7 +283,7 @@ namespace OHOS::Util {
|
||||
return couts;
|
||||
}
|
||||
|
||||
napi_value Base64::Encode(napi_value src)
|
||||
napi_value Base64::Encode(napi_env env, napi_value src)
|
||||
{
|
||||
napi_typedarray_type type;
|
||||
size_t byteOffset = 0;
|
||||
@@ -294,10 +293,10 @@ namespace OHOS::Util {
|
||||
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;
|
||||
CreateEncodePromise(inputEncode, length);
|
||||
CreateEncodePromise(env, inputEncode, length);
|
||||
return stdEncodeInfo_->promise;
|
||||
}
|
||||
napi_value Base64::EncodeToString(napi_value src)
|
||||
napi_value Base64::EncodeToString(napi_env env, napi_value src)
|
||||
{
|
||||
napi_typedarray_type type;
|
||||
size_t byteOffset = 0;
|
||||
@@ -307,10 +306,10 @@ namespace OHOS::Util {
|
||||
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;
|
||||
CreateEncodeToStringPromise(inputEncode, length);
|
||||
CreateEncodeToStringPromise(env, inputEncode, length);
|
||||
return stdEncodeInfo_->promise;
|
||||
}
|
||||
void Base64::CreateEncodePromise(unsigned char *inputDecode, size_t length)
|
||||
void Base64::CreateEncodePromise(napi_env env, unsigned char *inputDecode, size_t length)
|
||||
{
|
||||
napi_value resourceName = nullptr;
|
||||
stdEncodeInfo_ = new EncodeInfo();
|
||||
@@ -323,7 +322,7 @@ namespace OHOS::Util {
|
||||
reinterpret_cast<void*>(stdEncodeInfo_), &stdEncodeInfo_->worker);
|
||||
napi_queue_async_work(env, stdEncodeInfo_->worker);
|
||||
}
|
||||
void Base64::CreateEncodeToStringPromise(unsigned char *inputDecode, size_t length)
|
||||
void Base64::CreateEncodeToStringPromise(napi_env env, unsigned char *inputDecode, size_t length)
|
||||
{
|
||||
napi_value resourceName = nullptr;
|
||||
stdEncodeInfo_ = new EncodeInfo();
|
||||
@@ -335,7 +334,7 @@ namespace OHOS::Util {
|
||||
reinterpret_cast<void*>(stdEncodeInfo_), &stdEncodeInfo_->worker);
|
||||
napi_queue_async_work(env, stdEncodeInfo_->worker);
|
||||
}
|
||||
unsigned char *EncodeAchieves(EncodeInfo *encodeInfo)
|
||||
unsigned char *EncodeAchieves(napi_env env, EncodeInfo *encodeInfo)
|
||||
{
|
||||
const unsigned char *input = encodeInfo->sinputEncode;
|
||||
size_t inputLen = encodeInfo->slength;
|
||||
@@ -388,7 +387,7 @@ namespace OHOS::Util {
|
||||
void Base64::ReadStdEncode(napi_env env, void *data)
|
||||
{
|
||||
auto stdEncodeInfo = reinterpret_cast<EncodeInfo*>(data);
|
||||
unsigned char *rets = EncodeAchieves(stdEncodeInfo);
|
||||
unsigned char *rets = EncodeAchieves(env, stdEncodeInfo);
|
||||
stdEncodeInfo->sinputEncoding = rets;
|
||||
}
|
||||
void Base64::EndStdEncode(napi_env env, napi_status status, void *buffer)
|
||||
@@ -414,7 +413,7 @@ namespace OHOS::Util {
|
||||
void Base64::ReadStdEncodeToString(napi_env env, void *data)
|
||||
{
|
||||
auto stdEncodeInfo = reinterpret_cast<EncodeInfo*>(data);
|
||||
unsigned char *rets = EncodeAchieves(stdEncodeInfo);
|
||||
unsigned char *rets = EncodeAchieves(env, stdEncodeInfo);
|
||||
stdEncodeInfo->sinputEncoding = rets;
|
||||
}
|
||||
void Base64::EndStdEncodeToString(napi_env env, napi_status status, void *buffer)
|
||||
@@ -428,7 +427,7 @@ namespace OHOS::Util {
|
||||
delete[] stdEncodeInfo->sinputEncoding;
|
||||
delete stdEncodeInfo;
|
||||
}
|
||||
napi_value Base64::Decode(napi_value src)
|
||||
napi_value Base64::Decode(napi_env env, napi_value src)
|
||||
{
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
napi_typeof(env, src, &valuetype);
|
||||
@@ -454,16 +453,16 @@ namespace OHOS::Util {
|
||||
napi_throw_error(env, "-2", "prolen is error !");
|
||||
}
|
||||
napi_get_value_string_utf8(env, src, inputString, prolen + 1, &prolen);
|
||||
CreateDecodePromise(inputString, prolen);
|
||||
CreateDecodePromise(env, inputString, prolen);
|
||||
} else if (type == napi_typedarray_type::napi_uint8_array) {
|
||||
inputDecode = static_cast<char*>(resultData) + byteOffset;
|
||||
CreateDecodePromise(inputDecode, length);
|
||||
CreateDecodePromise(env, inputDecode, length);
|
||||
}
|
||||
delete[] inputString;
|
||||
inputString = nullptr;
|
||||
return stdDecodeInfo_->promise;
|
||||
}
|
||||
void Base64::CreateDecodePromise(char *inputDecode, size_t length)
|
||||
void Base64::CreateDecodePromise(napi_env env, char *inputDecode, size_t length)
|
||||
{
|
||||
napi_value resourceName = nullptr;
|
||||
stdDecodeInfo_ = new DecodeInfo();
|
||||
@@ -510,7 +509,7 @@ namespace OHOS::Util {
|
||||
}
|
||||
return retLen;
|
||||
}
|
||||
unsigned char *DecodeAchieves(DecodeInfo *decodeInfo)
|
||||
unsigned char *DecodeAchieves(napi_env env, DecodeInfo *decodeInfo)
|
||||
{
|
||||
const char *input = decodeInfo->sinputDecode;
|
||||
size_t inputLen = decodeInfo->slength;
|
||||
@@ -564,7 +563,7 @@ namespace OHOS::Util {
|
||||
void Base64::ReadStdDecode(napi_env env, void *data)
|
||||
{
|
||||
auto stdDecodeInfo = reinterpret_cast<DecodeInfo*>(data);
|
||||
unsigned char *rets = DecodeAchieves(stdDecodeInfo);
|
||||
unsigned char *rets = DecodeAchieves(env, stdDecodeInfo);
|
||||
stdDecodeInfo->sinputDecoding = rets;
|
||||
}
|
||||
void Base64::EndStdDecode(napi_env env, napi_status status, void *buffer)
|
||||
|
||||
+17
-14
@@ -61,10 +61,8 @@ namespace OHOS::Util {
|
||||
public:
|
||||
/**
|
||||
* Constructor of Base64.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
*/
|
||||
explicit Base64(napi_env env);
|
||||
explicit Base64() {}
|
||||
|
||||
/**
|
||||
* Destructor of Base64.
|
||||
@@ -74,48 +72,53 @@ namespace OHOS::Util {
|
||||
/**
|
||||
* Output the corresponding text after encoding the input parameters.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Encode the input uint8 array.
|
||||
*/
|
||||
napi_value EncodeSync(napi_value src);
|
||||
napi_value EncodeSync(napi_env env, napi_value src);
|
||||
|
||||
/**
|
||||
* Output the corresponding text after encoding the input parameters.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Encode the input uint8 array.
|
||||
*/
|
||||
napi_value EncodeToStringSync(napi_value src);
|
||||
napi_value EncodeToStringSync(napi_env env, napi_value src);
|
||||
|
||||
/**
|
||||
* Output the corresponding text after encoding the input parameters.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Decode the input uint8 array or string.
|
||||
*/
|
||||
napi_value DecodeSync(napi_value src);
|
||||
napi_value DecodeSync(napi_env env, napi_value src);
|
||||
|
||||
/**
|
||||
* Output the corresponding text after asynchronously encoding the input parameters.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Asynchronously encoded input uint8 array.
|
||||
*/
|
||||
napi_value Encode(napi_value src);
|
||||
napi_value Encode(napi_env env, napi_value src);
|
||||
|
||||
/**
|
||||
* Output the corresponding text after asynchronously encoding the input parameters.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Asynchronously encoded input uint8 array.
|
||||
*/
|
||||
napi_value EncodeToString(napi_value src);
|
||||
napi_value EncodeToString(napi_env env, napi_value src);
|
||||
|
||||
/**
|
||||
* Output the corresponding text after asynchronously encoding the input parameters.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Asynchronously decode the input uint8 array or string.
|
||||
*/
|
||||
napi_value Decode(napi_value src);
|
||||
napi_value Decode(napi_env env, napi_value src);
|
||||
|
||||
private:
|
||||
napi_env env;
|
||||
unsigned char *DecodeAchieve(const char *input, size_t inputLen);
|
||||
unsigned char *DecodeAchieve(napi_env env, const char *input, size_t inputLen);
|
||||
unsigned char *EncodeAchieve(const unsigned char *input, size_t inputLen);
|
||||
size_t Finds(char ch);
|
||||
size_t DecodeOut(size_t equalCount, size_t retLen);
|
||||
@@ -126,9 +129,9 @@ namespace OHOS::Util {
|
||||
const unsigned char *inputEncode_ = nullptr;
|
||||
const char *inputDecode_ = nullptr;
|
||||
unsigned char *retDecode = nullptr;
|
||||
void CreateEncodePromise(unsigned char *inputDecode, size_t length);
|
||||
void CreateEncodeToStringPromise(unsigned char *inputDecode, size_t length);
|
||||
void CreateDecodePromise(char *inputDecode, size_t length);
|
||||
void CreateEncodePromise(napi_env env, unsigned char *inputDecode, size_t length);
|
||||
void CreateEncodeToStringPromise(napi_env env, unsigned char *inputDecode, size_t length);
|
||||
void CreateDecodePromise(napi_env env, char *inputDecode, size_t length);
|
||||
EncodeInfo *stdEncodeInfo_ = nullptr;
|
||||
DecodeInfo *stdDecodeInfo_ = nullptr;
|
||||
static void ReadStdEncode(napi_env env, void *data);
|
||||
|
||||
+11
-11
@@ -26,8 +26,8 @@
|
||||
#include "unicode/unistr.h"
|
||||
#include "utils/log.h"
|
||||
namespace OHOS::Util {
|
||||
TextDecoder::TextDecoder(napi_env env, std::string buff, std::vector<int> optionVec)
|
||||
: env_(env), label_(0), encStr_(buff), tranTool_(nullptr, nullptr)
|
||||
TextDecoder::TextDecoder(std::string buff, std::vector<int> optionVec)
|
||||
: label_(0), encStr_(buff), tranTool_(nullptr, nullptr)
|
||||
{
|
||||
uint32_t i32Flag = 0;
|
||||
if (optionVec.size() == 2) { // 2:Meaning of optionVec size 2
|
||||
@@ -59,7 +59,7 @@ namespace OHOS::Util {
|
||||
}
|
||||
|
||||
|
||||
napi_value TextDecoder::Decode(napi_value src, bool iflag)
|
||||
napi_value TextDecoder::Decode(napi_env env, napi_value src, bool iflag)
|
||||
{
|
||||
uint8_t flags = 0;
|
||||
flags |= (iflag ? 0 : static_cast<uint8_t>(ConverterFlags::FLUSH_FLG));
|
||||
@@ -70,7 +70,7 @@ namespace OHOS::Util {
|
||||
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));
|
||||
NAPI_CALL(env, napi_get_typedarray_info(env, src, &type, &length, &data1, &arrayBuffer, &byteOffset));
|
||||
const char *source = static_cast<char*>(data1);
|
||||
UErrorCode codeFlag = U_ZERO_ERROR;
|
||||
size_t limit = GetMinByteSize() * length;
|
||||
@@ -101,7 +101,7 @@ namespace OHOS::Util {
|
||||
std::u16string tempStr16(arrDat);
|
||||
std::string tepStr = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> {}.to_bytes(tempStr16);
|
||||
napi_value resultStr = nullptr;
|
||||
NAPI_CALL(env_, napi_create_string_utf8(env_, tepStr.c_str(), tepStr.size(), &resultStr));
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, tepStr.c_str(), tepStr.size(), &resultStr));
|
||||
FreedMemory(arr);
|
||||
if (flush) {
|
||||
label_ &= static_cast<uint32_t>(ConverterFlags::BOM_SEEN_FLG);
|
||||
@@ -110,15 +110,15 @@ namespace OHOS::Util {
|
||||
return resultStr;
|
||||
}
|
||||
|
||||
napi_value TextDecoder::GetEncoding() const
|
||||
napi_value TextDecoder::GetEncoding(napi_env env) const
|
||||
{
|
||||
size_t length = strlen(encStr_.c_str());
|
||||
napi_value result = nullptr;
|
||||
NAPI_CALL(env_, napi_create_string_utf8(env_, encStr_.c_str(), length, &result));
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, encStr_.c_str(), length, &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value TextDecoder::GetFatal() const
|
||||
napi_value TextDecoder::GetFatal(napi_env env) const
|
||||
{
|
||||
uint32_t temp = label_ & static_cast<uint32_t>(ConverterFlags::FATAL_FLG);
|
||||
bool comRst = false;
|
||||
@@ -128,11 +128,11 @@ namespace OHOS::Util {
|
||||
comRst = false;
|
||||
}
|
||||
napi_value result = nullptr;
|
||||
NAPI_CALL(env_, napi_get_boolean(env_, comRst, &result));
|
||||
NAPI_CALL(env, napi_get_boolean(env, comRst, &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value TextDecoder::GetIgnoreBOM() const
|
||||
napi_value TextDecoder::GetIgnoreBOM(napi_env env) const
|
||||
{
|
||||
uint32_t temp = label_ & static_cast<uint32_t>(ConverterFlags::IGNORE_BOM_FLG);
|
||||
bool comRst = false;
|
||||
@@ -142,7 +142,7 @@ namespace OHOS::Util {
|
||||
comRst = false;
|
||||
}
|
||||
napi_value result;
|
||||
NAPI_CALL(env_, napi_get_boolean(env_, comRst, &result));
|
||||
NAPI_CALL(env, napi_get_boolean(env, comRst, &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+12
-7
@@ -51,11 +51,10 @@ namespace OHOS::Util {
|
||||
/**
|
||||
* Constructor of textdecoder
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param buff Encoding format.
|
||||
* @param optionVec There are two attributes of code related option parameters: fatal and ignorebom.
|
||||
*/
|
||||
TextDecoder(napi_env env, std::string buff, std::vector<int> optionVec);
|
||||
TextDecoder(std::string buff, std::vector<int> optionVec);
|
||||
|
||||
/**
|
||||
* Destructor of textencoder.
|
||||
@@ -65,25 +64,32 @@ namespace OHOS::Util {
|
||||
/**
|
||||
* Destructor of textencoder.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src An array that matches the format and needs to be decoded.
|
||||
* @param iflag Decoding related option parameters.
|
||||
*/
|
||||
napi_value Decode(napi_value src, bool iflag);
|
||||
napi_value Decode(napi_env env, napi_value src, bool iflag);
|
||||
|
||||
/**
|
||||
* Get encoding format.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
*/
|
||||
napi_value GetEncoding() const;
|
||||
napi_value GetEncoding(napi_env env) const;
|
||||
|
||||
/**
|
||||
* Gets the setting of the exception thrown.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
*/
|
||||
napi_value GetFatal() const;
|
||||
napi_value GetFatal(napi_env env) const;
|
||||
|
||||
/**
|
||||
* Gets whether to ignore the setting of BOM flag.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
*/
|
||||
napi_value GetIgnoreBOM() const;
|
||||
napi_value GetIgnoreBOM(napi_env env) const;
|
||||
|
||||
/**
|
||||
* Gets the size of minimum byte.
|
||||
@@ -154,7 +160,6 @@ namespace OHOS::Util {
|
||||
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_;
|
||||
TransformToolPointer tranTool_;
|
||||
|
||||
+15
-19
@@ -21,73 +21,69 @@
|
||||
#include "securec.h"
|
||||
#include "utils/log.h"
|
||||
namespace OHOS::Util {
|
||||
TextEncoder::TextEncoder(napi_env env) : env_(env), encoding_("utf-8")
|
||||
{
|
||||
}
|
||||
|
||||
napi_value TextEncoder::GetEncoding() const
|
||||
napi_value TextEncoder::GetEncoding(napi_env env) const
|
||||
{
|
||||
napi_value result = nullptr;
|
||||
NAPI_CALL(env_, napi_create_string_utf8(env_, encoding_.c_str(), encoding_.length(), &result));
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, encoding_.c_str(), encoding_.length(), &result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value TextEncoder::Encode(napi_value src) const
|
||||
napi_value TextEncoder::Encode(napi_env env, napi_value src) const
|
||||
{
|
||||
std::string buffer = "";
|
||||
size_t bufferSize = 0;
|
||||
if (napi_get_value_string_utf8(env_, src, nullptr, 0, &bufferSize) != napi_ok) {
|
||||
if (napi_get_value_string_utf8(env, src, nullptr, 0, &bufferSize) != napi_ok) {
|
||||
HILOG_ERROR("can not get src size");
|
||||
return nullptr;
|
||||
}
|
||||
buffer.reserve(bufferSize + 1);
|
||||
buffer.resize(bufferSize);
|
||||
if (napi_get_value_string_utf8(env_, src, buffer.data(), bufferSize + 1, &bufferSize) != napi_ok) {
|
||||
if (napi_get_value_string_utf8(env, src, buffer.data(), bufferSize + 1, &bufferSize) != napi_ok) {
|
||||
HILOG_ERROR("can not get src value");
|
||||
return nullptr;
|
||||
}
|
||||
void *data = nullptr;
|
||||
napi_value arrayBuffer = nullptr;
|
||||
napi_create_arraybuffer(env_, bufferSize, &data, &arrayBuffer);
|
||||
napi_create_arraybuffer(env, bufferSize, &data, &arrayBuffer);
|
||||
if (memcpy_s(data, bufferSize, reinterpret_cast<void*>(buffer.data()), bufferSize) != EOK) {
|
||||
HILOG_ERROR("copy buffer to arraybuffer error");
|
||||
return nullptr;
|
||||
}
|
||||
napi_value result = nullptr;
|
||||
NAPI_CALL(env_, napi_create_typedarray(env_, napi_uint8_array, bufferSize, arrayBuffer, 0, &result));
|
||||
NAPI_CALL(env, napi_create_typedarray(env, napi_uint8_array, bufferSize, arrayBuffer, 0, &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value TextEncoder::EncodeInto(napi_value src, napi_value dest) const
|
||||
napi_value TextEncoder::EncodeInto(napi_env env, napi_value src, napi_value dest) const
|
||||
{
|
||||
napi_typedarray_type type;
|
||||
size_t byteOffset = 0;
|
||||
size_t length = 0;
|
||||
void *resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
NAPI_CALL(env_, napi_get_typedarray_info(env_, dest, &type, &length, &resultData, &resultBuffer, &byteOffset));
|
||||
NAPI_CALL(env, napi_get_typedarray_info(env, dest, &type, &length, &resultData, &resultBuffer, &byteOffset));
|
||||
|
||||
char *writeResult = static_cast<char*>(resultData) + byteOffset;
|
||||
|
||||
int32_t nchars = 0;
|
||||
int32_t written = 0;
|
||||
NativeEngine *engine = reinterpret_cast<NativeEngine*>(env_);
|
||||
NativeEngine *engine = reinterpret_cast<NativeEngine*>(env);
|
||||
NativeValue *nativeValue = reinterpret_cast<NativeValue*>(src);
|
||||
engine->EncodeToUtf8(nativeValue, writeResult, &written, length, &nchars);
|
||||
|
||||
napi_value result = nullptr;
|
||||
NAPI_CALL(env_, napi_create_object(env_, &result));
|
||||
NAPI_CALL(env, napi_create_object(env, &result));
|
||||
|
||||
napi_value read = nullptr;
|
||||
NAPI_CALL(env_, napi_create_int32(env_, nchars, &read));
|
||||
NAPI_CALL(env, napi_create_int32(env, nchars, &read));
|
||||
|
||||
NAPI_CALL(env_, napi_set_named_property(env_, result, "read", read));
|
||||
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_int32(env, written, &resWritten));
|
||||
|
||||
NAPI_CALL(env_, napi_set_named_property(env_, result, "written", resWritten));
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "written", resWritten));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -26,9 +26,8 @@ namespace OHOS::Util {
|
||||
/**
|
||||
* Constructor of textdecoder.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
*/
|
||||
explicit TextEncoder(napi_env env);
|
||||
explicit TextEncoder() : encoding_("utf-8") {}
|
||||
|
||||
/**
|
||||
* Destructor of textencoder.
|
||||
@@ -37,26 +36,29 @@ namespace OHOS::Util {
|
||||
|
||||
/**
|
||||
* Get encoding format.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
*/
|
||||
napi_value GetEncoding() const;
|
||||
napi_value GetEncoding(napi_env env) const;
|
||||
|
||||
/**
|
||||
* Output the corresponding text after encoding the input parameters.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src A string that needs to be encoded.
|
||||
*/
|
||||
napi_value Encode(napi_value src) const;
|
||||
napi_value Encode(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Place the generated UTF-8 encoded text.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src A string that needs to be encoded.
|
||||
* @param dest Uint8array object instance, which is used to put the generated UTF-8 encoded text into it.
|
||||
*/
|
||||
napi_value EncodeInto(napi_value src, napi_value dest) const;
|
||||
napi_value EncodeInto(napi_env env, napi_value src, napi_value dest) const;
|
||||
|
||||
private:
|
||||
napi_env env_;
|
||||
std::string encoding_;
|
||||
};
|
||||
}
|
||||
|
||||
+139
-141
@@ -20,35 +20,33 @@
|
||||
#include "utils/log.h"
|
||||
|
||||
namespace OHOS::Util {
|
||||
Types::Types(napi_env env) : env_(env) {}
|
||||
|
||||
napi_value Types::IsAnyArrayBuffer(napi_value src) const
|
||||
napi_value Types::IsAnyArrayBuffer(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
bool rstFlag = false;
|
||||
napi_value rst = nullptr;
|
||||
napi_status napiRst = napi_is_arraybuffer(env_, src, &rstFlag);
|
||||
napi_status napiRst = napi_is_arraybuffer(env, src, &rstFlag);
|
||||
if (napiRst == napi_ok && rstFlag) {
|
||||
flag = true;
|
||||
}
|
||||
napi_get_boolean(env_, flag, &rst);
|
||||
napi_get_boolean(env, flag, &rst);
|
||||
return rst;
|
||||
}
|
||||
|
||||
napi_value Types::IsArrayBufferView(napi_value src) const
|
||||
napi_value Types::IsArrayBufferView(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
napi_value rst = nullptr;
|
||||
bool flag = false;
|
||||
napi_status rstStatus = napi_typeof(env_, src, &valuetype);
|
||||
napi_status rstStatus = napi_typeof(env, src, &valuetype);
|
||||
if ((valuetype != napi_valuetype::napi_object) || (rstStatus != napi_ok)) {
|
||||
napi_get_boolean(env_, flag, &rst);
|
||||
napi_get_boolean(env, flag, &rst);
|
||||
return rst;
|
||||
}
|
||||
bool rstFlag = false;
|
||||
napi_status napiRst = napi_is_dataview(env_, src, &rstFlag);
|
||||
napi_status napiRst = napi_is_dataview(env, src, &rstFlag);
|
||||
if (napiRst == napi_ok && rstFlag) {
|
||||
napi_get_boolean(env_, rstFlag, &rst);
|
||||
napi_get_boolean(env, rstFlag, &rst);
|
||||
return rst;
|
||||
}
|
||||
napi_typedarray_type type = napi_int8_array;
|
||||
@@ -56,7 +54,7 @@ namespace OHOS::Util {
|
||||
size_t length = 0;
|
||||
void* resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
napi_status rstSta = napi_get_typedarray_info(env_, src, &type, &length,
|
||||
napi_status rstSta = napi_get_typedarray_info(env, src, &type, &length,
|
||||
&resultData, &resultBuffer, &byteOffset);
|
||||
if (rstSta == napi_ok) {
|
||||
switch (type) {
|
||||
@@ -76,46 +74,46 @@ namespace OHOS::Util {
|
||||
break;
|
||||
}
|
||||
}
|
||||
napi_get_boolean(env_, flag, &rst);
|
||||
napi_get_boolean(env, flag, &rst);
|
||||
return rst;
|
||||
}
|
||||
|
||||
napi_value Types::IsArgumentsObject(napi_value src) const
|
||||
napi_value Types::IsArgumentsObject(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype result = napi_undefined;
|
||||
bool flag = false;
|
||||
napi_typeof(env_, src, &result);
|
||||
napi_typeof(env, src, &result);
|
||||
if (result == napi_object) {
|
||||
NAPI_CALL(env_, napi_is_arguments_object(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_arguments_object(env, src, &flag));
|
||||
}
|
||||
napi_value rst = nullptr;
|
||||
napi_get_boolean(env_, flag, &rst);
|
||||
napi_get_boolean(env, flag, &rst);
|
||||
return rst;
|
||||
}
|
||||
|
||||
napi_value Types::IsArrayBuffer(napi_value src) const
|
||||
napi_value Types::IsArrayBuffer(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_arraybuffer(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_arraybuffer(env, src, &flag));
|
||||
napi_value rst = nullptr;
|
||||
napi_get_boolean(env_, flag, &rst);
|
||||
napi_get_boolean(env, flag, &rst);
|
||||
return rst;
|
||||
}
|
||||
|
||||
napi_value Types::IsAsyncFunction(napi_value src) const
|
||||
napi_value Types::IsAsyncFunction(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype result = napi_undefined;
|
||||
bool flag = false;
|
||||
napi_typeof(env_, src, &result);
|
||||
napi_typeof(env, src, &result);
|
||||
if (result == napi_function) {
|
||||
NAPI_CALL(env_, napi_is_async_function(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_async_function(env, src, &flag));
|
||||
}
|
||||
napi_value rst = nullptr;
|
||||
napi_get_boolean(env_, flag, &rst);
|
||||
napi_get_boolean(env, flag, &rst);
|
||||
return rst;
|
||||
}
|
||||
|
||||
napi_value Types::IsBigInt64Array(napi_value src) const
|
||||
napi_value Types::IsBigInt64Array(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_typedarray_type type = napi_int8_array;
|
||||
size_t byteOffset = 0;
|
||||
@@ -123,17 +121,17 @@ namespace OHOS::Util {
|
||||
void* resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
bool flag = false;
|
||||
napi_get_typedarray_info(env_, src, &type, &length, &resultData, &resultBuffer, &byteOffset);
|
||||
napi_get_typedarray_info(env, src, &type, &length, &resultData, &resultBuffer, &byteOffset);
|
||||
if (type == napi_typedarray_type::napi_bigint64_array) {
|
||||
flag = true;
|
||||
}
|
||||
napi_value rst = nullptr;
|
||||
napi_get_boolean(env_, flag, &rst);
|
||||
napi_get_boolean(env, flag, &rst);
|
||||
HILOG_INFO("The type is not supported!");
|
||||
return rst;
|
||||
}
|
||||
|
||||
napi_value Types::IsBigUint64Array(napi_value src) const
|
||||
napi_value Types::IsBigUint64Array(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_typedarray_type type = napi_int8_array;
|
||||
size_t byteOffset = 0;
|
||||
@@ -141,453 +139,453 @@ namespace OHOS::Util {
|
||||
void* resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
bool flag = false;
|
||||
napi_get_typedarray_info(env_, src, &type, &length, &resultData, &resultBuffer, &byteOffset);
|
||||
napi_get_typedarray_info(env, src, &type, &length, &resultData, &resultBuffer, &byteOffset);
|
||||
if (type == napi_typedarray_type::napi_biguint64_array) {
|
||||
flag = true;
|
||||
}
|
||||
napi_value rst = nullptr;
|
||||
napi_get_boolean(env_, flag, &rst);
|
||||
napi_get_boolean(env, flag, &rst);
|
||||
HILOG_INFO("The type is not supported!");
|
||||
return rst;
|
||||
}
|
||||
|
||||
napi_value Types::IsBooleanObject(napi_value src) const
|
||||
napi_value Types::IsBooleanObject(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype result = napi_undefined;
|
||||
napi_typeof(env_, src, &result);
|
||||
napi_typeof(env, src, &result);
|
||||
bool flag = false;
|
||||
if (result == napi_object) {
|
||||
NAPI_CALL(env_, napi_is_boolean_object(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_boolean_object(env, src, &flag));
|
||||
}
|
||||
napi_value rst = nullptr;
|
||||
napi_get_boolean(env_, flag, &rst);
|
||||
napi_get_boolean(env, flag, &rst);
|
||||
return rst;
|
||||
}
|
||||
|
||||
napi_value Types::IsBoxedPrimitive(napi_value src) const
|
||||
napi_value Types::IsBoxedPrimitive(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
bool rstNum = false;
|
||||
bool rstStr = false;
|
||||
bool rstBool = false;
|
||||
bool rstSym = false;
|
||||
NAPI_CALL(env_, napi_get_value_bool(env_, IsNumberObject(src), &rstNum));
|
||||
NAPI_CALL(env_, napi_get_value_bool(env_, IsStringObject(src), &rstStr));
|
||||
NAPI_CALL(env_, napi_get_value_bool(env_, IsBooleanObject(src), &rstBool));
|
||||
NAPI_CALL(env_, napi_get_value_bool(env_, IsSymbolObject(src), &rstSym));
|
||||
NAPI_CALL(env, napi_get_value_bool(env, IsNumberObject(env, src), &rstNum));
|
||||
NAPI_CALL(env, napi_get_value_bool(env, IsStringObject(env, src), &rstStr));
|
||||
NAPI_CALL(env, napi_get_value_bool(env, IsBooleanObject(env, src), &rstBool));
|
||||
NAPI_CALL(env, napi_get_value_bool(env, IsSymbolObject(env, src), &rstSym));
|
||||
if (rstNum || rstStr || rstBool || rstSym) {
|
||||
flag = true;
|
||||
}
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsDataView(napi_value src) const
|
||||
napi_value Types::IsDataView(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_dataview(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_dataview(env, src, &flag));
|
||||
napi_value rst = nullptr;
|
||||
napi_get_boolean(env_, flag, &rst);
|
||||
napi_get_boolean(env, flag, &rst);
|
||||
return rst;
|
||||
}
|
||||
|
||||
napi_value Types::IsDate(napi_value src) const
|
||||
napi_value Types::IsDate(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_date(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_date(env, src, &flag));
|
||||
napi_value rst = nullptr;
|
||||
napi_get_boolean(env_, flag, &rst);
|
||||
napi_get_boolean(env, flag, &rst);
|
||||
return rst;
|
||||
}
|
||||
|
||||
napi_value Types::IsExternal(napi_value src) const
|
||||
napi_value Types::IsExternal(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
bool flag = false;
|
||||
napi_typeof(env_, src, &type);
|
||||
napi_typeof(env, src, &type);
|
||||
if (type == napi_valuetype::napi_external) {
|
||||
flag = true;
|
||||
}
|
||||
napi_value rst = nullptr;
|
||||
napi_get_boolean(env_, flag, &rst);
|
||||
napi_get_boolean(env, flag, &rst);
|
||||
return rst;
|
||||
}
|
||||
|
||||
napi_value Types::IsFloat32Array(napi_value src) const
|
||||
napi_value Types::IsFloat32Array(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
bool flag = false;
|
||||
napi_value result = nullptr;
|
||||
napi_typeof(env_, src, &valuetype);
|
||||
napi_typeof(env, src, &valuetype);
|
||||
if (valuetype == napi_valuetype::napi_object) {
|
||||
napi_typedarray_type type = napi_int8_array;
|
||||
size_t byteOffset = 0;
|
||||
size_t length = 0;
|
||||
void* resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
napi_get_typedarray_info(env_, src, &type, &length,
|
||||
napi_get_typedarray_info(env, src, &type, &length,
|
||||
&resultData, &resultBuffer, &byteOffset);
|
||||
if (type == napi_typedarray_type::napi_float32_array) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsFloat64Array(napi_value src) const
|
||||
napi_value Types::IsFloat64Array(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
bool flag = false;
|
||||
napi_value result = nullptr;
|
||||
napi_typeof(env_, src, &valuetype);
|
||||
napi_typeof(env, src, &valuetype);
|
||||
if (valuetype == napi_valuetype::napi_object) {
|
||||
napi_typedarray_type type = napi_int8_array;
|
||||
size_t byteOffset = 0;
|
||||
size_t length = 0;
|
||||
void* resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
napi_get_typedarray_info(env_, src, &type, &length,
|
||||
napi_get_typedarray_info(env, src, &type, &length,
|
||||
&resultData, &resultBuffer, &byteOffset);
|
||||
if (type == napi_typedarray_type::napi_float64_array) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsGeneratorFunction(napi_value src) const
|
||||
napi_value Types::IsGeneratorFunction(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype result = napi_undefined;
|
||||
napi_typeof(env_, src, &result);
|
||||
napi_typeof(env, src, &result);
|
||||
bool flag = false;
|
||||
if (result == napi_function) {
|
||||
NAPI_CALL(env_, napi_is_generator_function(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_generator_function(env, src, &flag));
|
||||
}
|
||||
napi_value rst = nullptr;
|
||||
napi_get_boolean(env_, flag, &rst);
|
||||
napi_get_boolean(env, flag, &rst);
|
||||
return rst;
|
||||
}
|
||||
|
||||
napi_value Types::IsGeneratorObject(napi_value src) const
|
||||
napi_value Types::IsGeneratorObject(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_generator_object(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_generator_object(env, src, &flag));
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsInt8Array(napi_value src) const
|
||||
napi_value Types::IsInt8Array(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
bool flag = false;
|
||||
napi_value result = nullptr;
|
||||
napi_typeof(env_, src, &valuetype);
|
||||
napi_typeof(env, src, &valuetype);
|
||||
if (valuetype == napi_valuetype::napi_object) {
|
||||
napi_typedarray_type type = napi_int8_array;
|
||||
size_t byteOffset = 0;
|
||||
size_t length = 0;
|
||||
void* resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
napi_status rstSta = napi_get_typedarray_info(env_, src, &type, &length,
|
||||
napi_status rstSta = napi_get_typedarray_info(env, src, &type, &length,
|
||||
&resultData, &resultBuffer, &byteOffset);
|
||||
if ((rstSta == napi_ok) && (type == napi_typedarray_type::napi_int8_array)) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsInt16Array(napi_value src) const
|
||||
napi_value Types::IsInt16Array(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
bool flag = false;
|
||||
napi_value result = nullptr;
|
||||
napi_typeof(env_, src, &valuetype);
|
||||
napi_typeof(env, src, &valuetype);
|
||||
if (valuetype == napi_valuetype::napi_object) {
|
||||
napi_typedarray_type type = napi_int8_array;
|
||||
size_t byteOffset = 0;
|
||||
size_t length = 0;
|
||||
void* resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
napi_get_typedarray_info(env_, src, &type, &length,
|
||||
napi_get_typedarray_info(env, src, &type, &length,
|
||||
&resultData, &resultBuffer, &byteOffset);
|
||||
if (type == napi_typedarray_type::napi_int16_array) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsInt32Array(napi_value src) const
|
||||
napi_value Types::IsInt32Array(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
bool flag = false;
|
||||
napi_value result = nullptr;
|
||||
napi_typeof(env_, src, &valuetype);
|
||||
napi_typeof(env, src, &valuetype);
|
||||
if (valuetype == napi_valuetype::napi_object) {
|
||||
napi_typedarray_type type = napi_int8_array;
|
||||
size_t byteOffset = 0;
|
||||
size_t length = 0;
|
||||
void* resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
napi_get_typedarray_info(env_, src, &type, &length,
|
||||
napi_get_typedarray_info(env, src, &type, &length,
|
||||
&resultData, &resultBuffer, &byteOffset);
|
||||
if (type == napi_typedarray_type::napi_int32_array) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsMap(napi_value src) const
|
||||
napi_value Types::IsMap(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_map(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_map(env, src, &flag));
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsMapIterator(napi_value src) const
|
||||
napi_value Types::IsMapIterator(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_map_iterator(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_map_iterator(env, src, &flag));
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsModuleNamespaceObject(napi_value src) const
|
||||
napi_value Types::IsModuleNamespaceObject(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_module_namespace_object(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_module_namespace_object(env, src, &flag));
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
HILOG_INFO("The type is not supported!");
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsNativeError(napi_value src) const
|
||||
napi_value Types::IsNativeError(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_error(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_error(env, src, &flag));
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsNumberObject(napi_value src) const
|
||||
napi_value Types::IsNumberObject(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
napi_value result = nullptr;
|
||||
napi_typeof(env_, src, &valuetype);
|
||||
napi_typeof(env, src, &valuetype);
|
||||
if (valuetype == napi_valuetype::napi_object) {
|
||||
NAPI_CALL(env_, napi_is_number_object(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_number_object(env, src, &flag));
|
||||
}
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsPromise(napi_value src) const
|
||||
napi_value Types::IsPromise(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_promise(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_promise(env, src, &flag));
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsProxy(napi_value src) const
|
||||
napi_value Types::IsProxy(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_proxy(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_proxy(env, src, &flag));
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsRegExp(napi_value src) const
|
||||
napi_value Types::IsRegExp(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_reg_exp(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_reg_exp(env, src, &flag));
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsSet(napi_value src) const
|
||||
napi_value Types::IsSet(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_set(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_set(env, src, &flag));
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsSetIterator(napi_value src) const
|
||||
napi_value Types::IsSetIterator(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_set_iterator(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_set_iterator(env, src, &flag));
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsSharedArrayBuffer(napi_value src) const
|
||||
napi_value Types::IsSharedArrayBuffer(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
HILOG_INFO("The type is not supported!");
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsStringObject(napi_value src) const
|
||||
napi_value Types::IsStringObject(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
napi_typeof(env_, src, &valuetype);
|
||||
napi_typeof(env, src, &valuetype);
|
||||
if (valuetype == napi_valuetype::napi_object) {
|
||||
NAPI_CALL(env_, napi_is_string_object(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_string_object(env, src, &flag));
|
||||
}
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsSymbolObject(napi_value src) const
|
||||
napi_value Types::IsSymbolObject(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
napi_value result = nullptr;
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
napi_typeof(env_, src, &valuetype);
|
||||
napi_typeof(env, src, &valuetype);
|
||||
if (valuetype == napi_valuetype::napi_object) {
|
||||
NAPI_CALL(env_, napi_is_symbol_object(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_symbol_object(env, src, &flag));
|
||||
}
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsTypedArray(napi_value src) const
|
||||
napi_value Types::IsTypedArray(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_typedarray(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_typedarray(env, src, &flag));
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsUint8Array(napi_value src) const
|
||||
napi_value Types::IsUint8Array(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
bool flag = false;
|
||||
napi_value result = nullptr;
|
||||
napi_typeof(env_, src, &valuetype);
|
||||
napi_typeof(env, src, &valuetype);
|
||||
if (valuetype == napi_valuetype::napi_object) {
|
||||
napi_typedarray_type type = napi_int8_array;
|
||||
size_t byteOffset = 0;
|
||||
size_t length = 0;
|
||||
void* resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
napi_get_typedarray_info(env_, src, &type, &length,
|
||||
napi_get_typedarray_info(env, src, &type, &length,
|
||||
&resultData, &resultBuffer, &byteOffset);
|
||||
if (type == napi_typedarray_type::napi_uint8_array) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsUint8ClampedArray(napi_value src) const
|
||||
napi_value Types::IsUint8ClampedArray(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
bool flag = false;
|
||||
napi_value result = nullptr;
|
||||
napi_typeof(env_, src, &valuetype);
|
||||
napi_typeof(env, src, &valuetype);
|
||||
if (valuetype == napi_valuetype::napi_object) {
|
||||
napi_typedarray_type type = napi_int8_array;
|
||||
size_t byteOffset = 0;
|
||||
size_t length = 0;
|
||||
void* resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
napi_get_typedarray_info(env_, src, &type, &length,
|
||||
napi_get_typedarray_info(env, src, &type, &length,
|
||||
&resultData, &resultBuffer, &byteOffset);
|
||||
if (type == napi_typedarray_type::napi_uint8_clamped_array) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsUint16Array(napi_value src) const
|
||||
napi_value Types::IsUint16Array(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
bool flag = false;
|
||||
napi_value result = nullptr;
|
||||
napi_typeof(env_, src, &valuetype);
|
||||
napi_typeof(env, src, &valuetype);
|
||||
if (valuetype == napi_valuetype::napi_object) {
|
||||
napi_typedarray_type type = napi_int8_array;
|
||||
size_t byteOffset = 0;
|
||||
size_t length = 0;
|
||||
void* resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
napi_get_typedarray_info(env_, src, &type, &length,
|
||||
napi_get_typedarray_info(env, src, &type, &length,
|
||||
&resultData, &resultBuffer, &byteOffset);
|
||||
if (type == napi_typedarray_type::napi_uint16_array) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsUint32Array(napi_value src) const
|
||||
napi_value Types::IsUint32Array(napi_env env, napi_value src) const
|
||||
{
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
bool flag = false;
|
||||
napi_value result = nullptr;
|
||||
napi_typeof(env_, src, &valuetype);
|
||||
napi_typeof(env, src, &valuetype);
|
||||
if (valuetype == napi_valuetype::napi_object) {
|
||||
napi_typedarray_type type = napi_int8_array;
|
||||
size_t byteOffset = 0;
|
||||
size_t length = 0;
|
||||
void* resultData = nullptr;
|
||||
napi_value resultBuffer = nullptr;
|
||||
napi_get_typedarray_info(env_, src, &type, &length,
|
||||
napi_get_typedarray_info(env, src, &type, &length,
|
||||
&resultData, &resultBuffer, &byteOffset);
|
||||
if (type == napi_typedarray_type::napi_uint32_array) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsWeakMap(napi_value src) const
|
||||
napi_value Types::IsWeakMap(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_weak_map(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_weak_map(env, src, &flag));
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value Types::IsWeakSet(napi_value src) const
|
||||
napi_value Types::IsWeakSet(napi_env env, napi_value src) const
|
||||
{
|
||||
bool flag = false;
|
||||
NAPI_CALL(env_, napi_is_weak_set(env_, src, &flag));
|
||||
NAPI_CALL(env, napi_is_weak_set(env, src, &flag));
|
||||
napi_value result = nullptr;
|
||||
napi_get_boolean(env_, flag, &result);
|
||||
napi_get_boolean(env, flag, &result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+79
-44
@@ -30,9 +30,8 @@ namespace OHOS::Util {
|
||||
/**
|
||||
* Constructor of Types.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
*/
|
||||
explicit Types(napi_env env);
|
||||
explicit Types() {}
|
||||
|
||||
/**
|
||||
* Destructor of Types.
|
||||
@@ -42,278 +41,314 @@ namespace OHOS::Util {
|
||||
/**
|
||||
* Check whether the entered value is of arraybuffer type.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsAnyArrayBuffer(napi_value src) const;
|
||||
napi_value IsAnyArrayBuffer(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is a built-in arraybufferview auxiliary type.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsArrayBufferView(napi_value src) const;
|
||||
napi_value IsArrayBufferView(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is an arguments object type.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsArgumentsObject(napi_value src) const;
|
||||
napi_value IsArgumentsObject(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is of arraybuffer type.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsArrayBuffer(napi_value src) const;
|
||||
napi_value IsArrayBuffer(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the input value is an asynchronous function type.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsAsyncFunction(napi_value src) const;
|
||||
napi_value IsAsyncFunction(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is a bigint64array type.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsBigInt64Array(napi_value src) const;
|
||||
napi_value IsBigInt64Array(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is a biguint64array type.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsBigUint64Array(napi_value src) const;
|
||||
napi_value IsBigUint64Array(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is a Boolean object type.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsBooleanObject(napi_value src) const;
|
||||
napi_value IsBooleanObject(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is Boolean or number or string or symbol object type.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsBoxedPrimitive(napi_value src) const;
|
||||
napi_value IsBoxedPrimitive(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is of DataView type.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsDataView(napi_value src) const;
|
||||
napi_value IsDataView(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is of type date.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsDate(napi_value src) const;
|
||||
napi_value IsDate(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is of type native external.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsExternal(napi_value src) const;
|
||||
napi_value IsExternal(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of float32array array.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsFloat32Array(napi_value src) const;
|
||||
napi_value IsFloat32Array(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of float64array array.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsFloat64Array(napi_value src) const;
|
||||
napi_value IsFloat64Array(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the value entered is the type of generator function.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsGeneratorFunction(napi_value src) const;
|
||||
napi_value IsGeneratorFunction(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the value entered is the type of generator object.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsGeneratorObject(napi_value src) const;
|
||||
napi_value IsGeneratorObject(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the value entered is the type of int8 array.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsInt8Array(napi_value src) const;
|
||||
napi_value IsInt8Array(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the value entered is the type of int16 array.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsInt16Array(napi_value src) const;
|
||||
napi_value IsInt16Array(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the value entered is the type of int32 array.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsInt32Array(napi_value src) const;
|
||||
napi_value IsInt32Array(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the value entered is the type of map.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsMap(napi_value src) const;
|
||||
napi_value IsMap(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the iterator type of map.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsMapIterator(napi_value src) const;
|
||||
napi_value IsMapIterator(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the module name space type of object.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsModuleNamespaceObject(napi_value src) const;
|
||||
napi_value IsModuleNamespaceObject(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is of type error.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsNativeError(napi_value src) const;
|
||||
napi_value IsNativeError(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the number type of object.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsNumberObject(napi_value src) const;
|
||||
napi_value IsNumberObject(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of promise.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsPromise(napi_value src) const;
|
||||
napi_value IsPromise(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of proxy.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsProxy(napi_value src) const;
|
||||
napi_value IsProxy(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of regexp.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsRegExp(napi_value src) const;
|
||||
napi_value IsRegExp(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of set.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsSet(napi_value src) const;
|
||||
napi_value IsSet(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the iterator type of set.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsSetIterator(napi_value src) const;
|
||||
napi_value IsSetIterator(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of sharedarraybuffer.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsSharedArrayBuffer(napi_value src) const;
|
||||
napi_value IsSharedArrayBuffer(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the string type of object.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsStringObject(napi_value src) const;
|
||||
napi_value IsStringObject(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the symbol type of object.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsSymbolObject(napi_value src) const;
|
||||
napi_value IsSymbolObject(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of typedarray.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsTypedArray(napi_value src) const;
|
||||
napi_value IsTypedArray(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of uint8array.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsUint8Array(napi_value src) const;
|
||||
napi_value IsUint8Array(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of uint8clampedarray.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsUint8ClampedArray(napi_value src) const;
|
||||
napi_value IsUint8ClampedArray(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of uint16array.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsUint16Array(napi_value src) const;
|
||||
napi_value IsUint16Array(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of uint32array.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsUint32Array(napi_value src) const;
|
||||
napi_value IsUint32Array(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of weakmap.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsWeakMap(napi_value src) const;
|
||||
napi_value IsWeakMap(napi_env env, napi_value src) const;
|
||||
|
||||
/**
|
||||
* Check whether the entered value is the type of weakset.
|
||||
*
|
||||
* @param env NAPI environment parameters.
|
||||
* @param src Object to be tested.
|
||||
*/
|
||||
napi_value IsWeakSet(napi_value src) const;
|
||||
|
||||
private:
|
||||
napi_env env_;
|
||||
napi_value IsWeakSet(napi_env env, napi_value src) const;
|
||||
};
|
||||
}
|
||||
#endif // UTIL_JS_TYPES_H_
|
||||
|
||||
+57
-57
@@ -306,7 +306,7 @@ namespace OHOS::Util {
|
||||
}
|
||||
delete []type;
|
||||
type = nullptr;
|
||||
auto objectInfo = new TextDecoder(env, enconding, paraVec);
|
||||
auto objectInfo = new TextDecoder(enconding, paraVec);
|
||||
NAPI_CALL(env, napi_wrap(
|
||||
env, thisVar, objectInfo,
|
||||
[](napi_env environment, void *data, void *hint) {
|
||||
@@ -341,7 +341,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &argv, nullptr, &dataPara));
|
||||
// first para
|
||||
NAPI_CALL(env, napi_get_typedarray_info(env, argv, &type, &length, &data, &arraybuffer, &byteOffset));
|
||||
valStr = textDecoder->Decode(argv, iStream);
|
||||
valStr = textDecoder->Decode(env, argv, iStream);
|
||||
} else if (tempArgc == 2) { // 2: The number of parameters is 2.
|
||||
argc = 2; // 2: The number of parameters is 2.
|
||||
napi_value argvArr[2] = { 0 };
|
||||
@@ -357,7 +357,7 @@ namespace OHOS::Util {
|
||||
&messageKeyStream));
|
||||
NAPI_CALL(env, napi_get_property(env, argvArr[1], messageKeyStream, &resultStream));
|
||||
NAPI_CALL(env, napi_get_value_bool(env, resultStream, &iStream));
|
||||
valStr = textDecoder->Decode(argvArr[0], iStream);
|
||||
valStr = textDecoder->Decode(env, argvArr[0], iStream);
|
||||
}
|
||||
return valStr;
|
||||
}
|
||||
@@ -368,7 +368,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr));
|
||||
TextDecoder *textDecoder = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&textDecoder));
|
||||
napi_value retVal = textDecoder->GetEncoding();
|
||||
napi_value retVal = textDecoder->GetEncoding(env);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr));
|
||||
TextDecoder *textDecoder = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&textDecoder));
|
||||
napi_value retVal = textDecoder->GetFatal();
|
||||
napi_value retVal = textDecoder->GetFatal(env);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr));
|
||||
TextDecoder *textDecoder = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&textDecoder));
|
||||
napi_value retVal = textDecoder->GetIgnoreBOM();
|
||||
napi_value retVal = textDecoder->GetIgnoreBOM(env);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ namespace OHOS::Util {
|
||||
void *data = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, &data));
|
||||
|
||||
auto object = new TextEncoder(env);
|
||||
auto object = new TextEncoder();
|
||||
NAPI_CALL(env, napi_wrap(
|
||||
env, thisVar, object,
|
||||
[](napi_env environment, void *data, void *hint) {
|
||||
@@ -420,7 +420,7 @@ namespace OHOS::Util {
|
||||
TextEncoder *object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
|
||||
return object->GetEncoding();
|
||||
return object->GetEncoding(env);
|
||||
}
|
||||
|
||||
static napi_value Encode(napi_env env, napi_callback_info info)
|
||||
@@ -441,7 +441,7 @@ namespace OHOS::Util {
|
||||
TextEncoder *object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
|
||||
napi_value result = object->Encode(args);
|
||||
napi_value result = object->Encode(env, args);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -472,7 +472,7 @@ namespace OHOS::Util {
|
||||
TextEncoder *object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
|
||||
napi_value result = object->EncodeInto(args[0], args[1]);
|
||||
napi_value result = object->EncodeInto(env, args[0], args[1]);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -517,7 +517,7 @@ namespace OHOS::Util {
|
||||
napi_value thisVar = nullptr;
|
||||
void *data = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, &data));
|
||||
auto objectInfo = new Base64(env);
|
||||
auto objectInfo = new Base64();
|
||||
napi_wrap(
|
||||
env, thisVar, objectInfo,
|
||||
[](napi_env environment, void *data, void *hint) {
|
||||
@@ -547,7 +547,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, valuetype0 == napi_uint8_array, "Wrong argument type. napi_uint8_array expected.");
|
||||
Base64 *object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->EncodeSync(args[0]);
|
||||
napi_value result = object->EncodeSync(env, args[0]);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -568,7 +568,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, valuetype0 == napi_uint8_array, "Wrong argument type. napi_uint8_array expected.");
|
||||
Base64 *object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->EncodeToStringSync(args[0]);
|
||||
napi_value result = object->EncodeToStringSync(env, args[0]);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -596,7 +596,7 @@ namespace OHOS::Util {
|
||||
}
|
||||
Base64 *object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->DecodeSync(args[0]);
|
||||
napi_value result = object->DecodeSync(env, args[0]);
|
||||
return result;
|
||||
}
|
||||
static napi_value EncodeAsync(napi_env env, napi_callback_info info)
|
||||
@@ -616,7 +616,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, valuetype0 == napi_uint8_array, "Wrong argument type. napi_uint8_array expected.");
|
||||
Base64 *object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->Encode(args[0]);
|
||||
napi_value result = object->Encode(env, args[0]);
|
||||
return result;
|
||||
}
|
||||
static napi_value EncodeToStringAsync(napi_env env, napi_callback_info info)
|
||||
@@ -636,7 +636,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, valuetype0 == napi_uint8_array, "Wrong argument type. napi_uint8_array expected.");
|
||||
Base64 *object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->EncodeToString(args[0]);
|
||||
napi_value result = object->EncodeToString(env, args[0]);
|
||||
return result;
|
||||
}
|
||||
static napi_value DecodeAsync(napi_env env, napi_callback_info info)
|
||||
@@ -663,7 +663,7 @@ namespace OHOS::Util {
|
||||
}
|
||||
Base64 *object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->Decode(args[0]);
|
||||
napi_value result = object->Decode(env, args[0]);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -687,7 +687,7 @@ namespace OHOS::Util {
|
||||
napi_value thisVar = nullptr;
|
||||
void* data = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, &data));
|
||||
auto objectInfo = new Types(env);
|
||||
auto objectInfo = new Types();
|
||||
napi_wrap(
|
||||
env, thisVar, objectInfo,
|
||||
[](napi_env environment, void* data, void* hint) {
|
||||
@@ -708,7 +708,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsAnyArrayBuffer(args);
|
||||
napi_value rst = object->IsAnyArrayBuffer(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -720,7 +720,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsArrayBufferView(args);
|
||||
napi_value rst = object->IsArrayBufferView(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsArgumentsObject(args);
|
||||
napi_value rst = object->IsArgumentsObject(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -744,7 +744,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsArrayBuffer(args);
|
||||
napi_value rst = object->IsArrayBuffer(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -756,7 +756,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsAsyncFunction(args);
|
||||
napi_value rst = object->IsAsyncFunction(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -768,7 +768,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsBigInt64Array(args);
|
||||
napi_value rst = object->IsBigInt64Array(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -780,7 +780,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsBigUint64Array(args);
|
||||
napi_value rst = object->IsBigUint64Array(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -792,7 +792,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsBooleanObject(args);
|
||||
napi_value rst = object->IsBooleanObject(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -804,7 +804,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsBoxedPrimitive(args);
|
||||
napi_value rst = object->IsBoxedPrimitive(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -816,7 +816,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsDataView(args);
|
||||
napi_value rst = object->IsDataView(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -828,7 +828,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsDate(args);
|
||||
napi_value rst = object->IsDate(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -840,7 +840,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsExternal(args);
|
||||
napi_value rst = object->IsExternal(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -852,7 +852,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsFloat32Array(args);
|
||||
napi_value rst = object->IsFloat32Array(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -864,7 +864,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsFloat64Array(args);
|
||||
napi_value rst = object->IsFloat64Array(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -876,7 +876,7 @@ namespace OHOS::Util {
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &args, &thisVar, nullptr));
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value rst = object->IsGeneratorFunction(args);
|
||||
napi_value rst = object->IsGeneratorFunction(env, args);
|
||||
return rst;
|
||||
}
|
||||
|
||||
@@ -890,7 +890,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsGeneratorObject(args);
|
||||
napi_value result = object->IsGeneratorObject(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -904,7 +904,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsInt8Array(args);
|
||||
napi_value result = object->IsInt8Array(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -918,7 +918,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsInt16Array(args);
|
||||
napi_value result = object->IsInt16Array(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -932,7 +932,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsInt32Array(args);
|
||||
napi_value result = object->IsInt32Array(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -946,7 +946,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsMap(args);
|
||||
napi_value result = object->IsMap(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -960,7 +960,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsMapIterator(args);
|
||||
napi_value result = object->IsMapIterator(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -974,7 +974,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsModuleNamespaceObject(args);
|
||||
napi_value result = object->IsModuleNamespaceObject(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -988,7 +988,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsNativeError(args);
|
||||
napi_value result = object->IsNativeError(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1002,7 +1002,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsNumberObject(args);
|
||||
napi_value result = object->IsNumberObject(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1016,7 +1016,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsPromise(args);
|
||||
napi_value result = object->IsPromise(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1030,7 +1030,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsProxy(args);
|
||||
napi_value result = object->IsProxy(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1044,7 +1044,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsRegExp(args);
|
||||
napi_value result = object->IsRegExp(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1058,7 +1058,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsSet(args);
|
||||
napi_value result = object->IsSet(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1072,7 +1072,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsSetIterator(args);
|
||||
napi_value result = object->IsSetIterator(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1086,7 +1086,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsSharedArrayBuffer(args);
|
||||
napi_value result = object->IsSharedArrayBuffer(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1100,7 +1100,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsStringObject(args);
|
||||
napi_value result = object->IsStringObject(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1114,7 +1114,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsSymbolObject(args);
|
||||
napi_value result = object->IsSymbolObject(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1128,7 +1128,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsTypedArray(args);
|
||||
napi_value result = object->IsTypedArray(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1142,7 +1142,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsUint8Array(args);
|
||||
napi_value result = object->IsUint8Array(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1156,7 +1156,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsUint8ClampedArray(args);
|
||||
napi_value result = object->IsUint8ClampedArray(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1170,7 +1170,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsUint16Array(args);
|
||||
napi_value result = object->IsUint16Array(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1184,7 +1184,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsUint32Array(args);
|
||||
napi_value result = object->IsUint32Array(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1198,7 +1198,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsWeakMap(args);
|
||||
napi_value result = object->IsWeakMap(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1212,7 +1212,7 @@ namespace OHOS::Util {
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments");
|
||||
Types* object = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, (void**)&object));
|
||||
napi_value result = object->IsWeakSet(args);
|
||||
napi_value result = object->IsWeakSet(env, args);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user