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 654b3b9c257bbbd4e10098f58da8f7071344adda..c1781d8299b454a85dd16b196509b9d305493cd5 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 2e995d41efb31f07f13c69934656af66eaf60f5c..04c1ba01a2b309a44ea033ef78c4e9cb40af196d 100644 --- a/interfaces/kits/js/src/common/ani_helper/type_converter.cpp +++ b/interfaces/kits/js/src/common/ani_helper/type_converter.cpp @@ -59,13 +59,8 @@ std::tuple> TypeConverter::ToOptionalInt32(ani_env return { true, std::nullopt }; } - ani_double doubleValue; - if (ANI_OK == env->Object_CallMethodByName_Double(value, "doubleValue", 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) }; } @@ -84,13 +79,8 @@ std::tuple> TypeConverter::ToOptionalInt64(ani_env return { true, std::nullopt }; } - ani_double doubleValue; - if (ANI_OK == env->Object_CallMethodByName_Double(value, "doubleValue", 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) }; } @@ -157,27 +147,13 @@ 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, "doubleValue", 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); 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 ab03c25250a60487492a3242253fa010fd22d6fb..e2f7b9464691f51d71adf67ee1be4dc9fb888a76 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 82fe98317fe46f05c291e898739b351470dcc96b..44b8faf6e3ac8aece21d13579e52bbd4f2a37655 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);