From e82a00ce26b61897ea0d9985d818579f9e78065c Mon Sep 17 00:00:00 2001 From: tianp Date: Wed, 21 May 2025 16:40:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=BD=AC=E5=8C=96?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tianp --- .../kits/js/src/common/ani_helper/ani_helper.h | 2 +- .../kits/js/src/common/ani_helper/type_converter.cpp | 12 ++++++------ .../kits/js/src/mod_fs/properties/ani/close_ani.cpp | 2 +- .../js/src/mod_fs/properties/ani/listfile_ani.cpp | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/interfaces/kits/js/src/common/ani_helper/ani_helper.h b/interfaces/kits/js/src/common/ani_helper/ani_helper.h index 654b3b9c2..c1781d829 100644 --- a/interfaces/kits/js/src/common/ani_helper/ani_helper.h +++ b/interfaces/kits/js/src/common/ani_helper/ani_helper.h @@ -112,7 +112,7 @@ public: static const string longValueSig = Builder::BuildSignatureDescriptor({}, BasicTypes::longType); ani_long value; status = env->Object_CallMethodByName_Long( - static_cast(property), "longValue", longValueSig.c_str(), &value); + static_cast(property), "toLong", longValueSig.c_str(), &value); if (status != ANI_OK) { return { false, nullopt }; } diff --git a/interfaces/kits/js/src/common/ani_helper/type_converter.cpp b/interfaces/kits/js/src/common/ani_helper/type_converter.cpp index 2e995d41e..7056e4ade 100644 --- a/interfaces/kits/js/src/common/ani_helper/type_converter.cpp +++ b/interfaces/kits/js/src/common/ani_helper/type_converter.cpp @@ -60,12 +60,12 @@ std::tuple> TypeConverter::ToOptionalInt32(ani_env } ani_double doubleValue; - if (ANI_OK == env->Object_CallMethodByName_Double(value, "doubleValue", nullptr, &doubleValue)) { + if (ANI_OK == env->Object_CallMethodByName_Double(value, "toDouble", nullptr, &doubleValue)) { return { true, std::make_optional(static_cast(doubleValue)) }; } ani_int intValue; - if (ANI_OK == env->Object_CallMethodByName_Int(value, "intValue", nullptr, &intValue)) { + if (ANI_OK == env->Object_CallMethodByName_Int(value, "toInt", nullptr, &intValue)) { return { true, std::make_optional(intValue) }; } @@ -85,12 +85,12 @@ std::tuple> TypeConverter::ToOptionalInt64(ani_env } ani_double doubleValue; - if (ANI_OK == env->Object_CallMethodByName_Double(value, "doubleValue", nullptr, &doubleValue)) { + if (ANI_OK == env->Object_CallMethodByName_Double(value, "toDouble", nullptr, &doubleValue)) { return { true, std::make_optional(static_cast(doubleValue)) }; } ani_long longValue; - if (ANI_OK == env->Object_CallMethodByName_Long(value, "longValue", nullptr, &longValue)) { + if (ANI_OK == env->Object_CallMethodByName_Long(value, "toLong", nullptr, &longValue)) { return { true, std::make_optional(longValue) }; } @@ -163,7 +163,7 @@ static std::tuple ParseFd(ani_env *env, const ani_object &pathOrF env->Object_InstanceOf(pathOrFd, doubleClass, &isFd); if (isFd) { ani_double doubleValue; - if (ANI_OK != env->Object_CallMethodByName_Double(pathOrFd, "doubleValue", nullptr, &doubleValue)) { + if (ANI_OK != env->Object_CallMethodByName_Double(pathOrFd, "toDouble", nullptr, &doubleValue)) { HILOGE("Parse file path failed"); return { false, 0 }; } @@ -177,7 +177,7 @@ static std::tuple ParseFd(ani_env *env, const ani_object &pathOrF env->Object_InstanceOf(pathOrFd, intClass, &isFd); if (isFd) { ani_int fd; - if (ANI_OK != env->Object_CallMethodByName_Int(pathOrFd, "intValue", nullptr, &fd)) { + if (ANI_OK != env->Object_CallMethodByName_Int(pathOrFd, "toInt", nullptr, &fd)) { HILOGE("Parse file path failed"); return { false, 0 }; } diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.cpp index ab03c2525..e2f7b9464 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.cpp @@ -43,7 +43,7 @@ tuple ParseFdOrFile(ani_env *env, ani_object obj) env->Object_InstanceOf(obj, doubleClass, &isDouble); if (isDouble) { ani_int fd; - if (ANI_OK != env->Object_CallMethodByName_Int(obj, "intValue", nullptr, &fd)) { + if (ANI_OK != env->Object_CallMethodByName_Int(obj, "toInt", nullptr, &fd)) { HILOGE("Get fd value failed"); return { false, result, nullptr }; } diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp index 82fe98317..44b8faf6e 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp @@ -65,7 +65,7 @@ tuple ParseIntParam(ani_env *env, ani_object obj, string tag) } ani_int result_ref_res; if (ANI_OK != env->Object_CallMethodByName_Int( - static_cast(result_ref), "intValue", nullptr, &result_ref_res)) { + static_cast(result_ref), "toInt", nullptr, &result_ref_res)) { result = -1; return { false, result }; } @@ -87,7 +87,7 @@ tuple> ParseDoubleParam(ani_env *env, ani_object obj, str ani_double result_ref_res; if (ANI_OK != env->Object_CallMethodByName_Double( - static_cast(result_ref), "doubleValue", nullptr, &result_ref_res)) { + static_cast(result_ref), "toDouble", nullptr, &result_ref_res)) { return { false, nullopt }; } double result = static_cast(result_ref_res); -- Gitee From 17f650ddb3d916cd1d38ebf8bb2b1c6c566a2b7c Mon Sep 17 00:00:00 2001 From: tianp Date: Wed, 21 May 2025 17:30:03 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tianp --- .../src/common/ani_helper/type_converter.cpp | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/interfaces/kits/js/src/common/ani_helper/type_converter.cpp b/interfaces/kits/js/src/common/ani_helper/type_converter.cpp index 7056e4ade..04c1ba01a 100644 --- a/interfaces/kits/js/src/common/ani_helper/type_converter.cpp +++ b/interfaces/kits/js/src/common/ani_helper/type_converter.cpp @@ -59,11 +59,6 @@ std::tuple> TypeConverter::ToOptionalInt32(ani_env return { true, std::nullopt }; } - ani_double doubleValue; - if (ANI_OK == env->Object_CallMethodByName_Double(value, "toDouble", nullptr, &doubleValue)) { - return { true, std::make_optional(static_cast(doubleValue)) }; - } - ani_int intValue; if (ANI_OK == env->Object_CallMethodByName_Int(value, "toInt", nullptr, &intValue)) { return { true, std::make_optional(intValue) }; @@ -84,11 +79,6 @@ std::tuple> TypeConverter::ToOptionalInt64(ani_env return { true, std::nullopt }; } - ani_double doubleValue; - if (ANI_OK == env->Object_CallMethodByName_Double(value, "toDouble", nullptr, &doubleValue)) { - return { true, std::make_optional(static_cast(doubleValue)) }; - } - ani_long longValue; if (ANI_OK == env->Object_CallMethodByName_Long(value, "toLong", nullptr, &longValue)) { return { true, std::make_optional(longValue) }; @@ -157,20 +147,6 @@ static std::tuple ParseFd(ani_env *env, const ani_object &pathOrF { ani_boolean isFd = false; - auto doubleClassDesc = BoxedTypes::Double::classDesc.c_str(); - ani_class doubleClass; - env->FindClass(doubleClassDesc, &doubleClass); - env->Object_InstanceOf(pathOrFd, doubleClass, &isFd); - if (isFd) { - ani_double doubleValue; - if (ANI_OK != env->Object_CallMethodByName_Double(pathOrFd, "toDouble", nullptr, &doubleValue)) { - HILOGE("Parse file path failed"); - return { false, 0 }; - } - int32_t fd = static_cast(doubleValue); - return { true, fd }; - } - auto intClassDesc = BoxedTypes::Int::classDesc.c_str(); ani_class intClass; env->FindClass(intClassDesc, &intClass); -- Gitee