From 90e3848bdc77595d12d25bdf18ef0764e90f90f1 Mon Sep 17 00:00:00 2001 From: heguokai <275503077@qq.com> Date: Sat, 9 Aug 2025 15:47:30 +0800 Subject: [PATCH] modify for array length from double to int Signed-off-by: heguokai <275503077@qq.com> --- frameworks/ets/ani/src/sts_action_button.cpp | 8 ++--- frameworks/ets/ani/src/sts_bundle_option.cpp | 6 ++-- frameworks/ets/ani/src/sts_common.cpp | 32 +++++++++---------- frameworks/ets/ani/src/sts_convert_other.cpp | 26 +++++++-------- frameworks/ets/ani/src/sts_disturb_mode.cpp | 8 ++--- .../ets/ani/src/sts_notification_content.cpp | 8 ++--- frameworks/ets/ani/src/sts_slot.cpp | 8 ++--- 7 files changed, 48 insertions(+), 48 deletions(-) diff --git a/frameworks/ets/ani/src/sts_action_button.cpp b/frameworks/ets/ani/src/sts_action_button.cpp index 7ea002ad5..24012799e 100644 --- a/frameworks/ets/ani/src/sts_action_button.cpp +++ b/frameworks/ets/ani/src/sts_action_button.cpp @@ -233,20 +233,20 @@ ani_status GetNotificationActionButtonArray(ani_env *env, ani_object param, ani_ref arrayObj = nullptr; ani_boolean isUndefined = true; ani_status status; - ani_double length; + ani_int length; StsActionButton actionButton; if ((status = GetPropertyRef(env, param, name, isUndefined, arrayObj)) != ANI_OK || isUndefined == ANI_TRUE) { ANS_LOGE("GetActionButtonArray: GetPropertyRef name = %{public}s, status = %{public}d", name, status); return ANI_INVALID_ARGS; } - if (ANI_OK!= (status = GetPropertyDouble(env, static_cast(arrayObj), "length", isUndefined, length))) { + if (ANI_OK!= (status = GetPropertyInt(env, static_cast(arrayObj), "length", isUndefined, length))) { ANS_LOGE("GetActionButtonArray: GetPropertyDouble name = %{public}s, status = %{public}d", name, status); return status; } - for (int i = 0; i < static_cast(length); i++) { + for (int32_t i = 0; i < length; i++) { ani_ref buttonRef; if (ANI_OK != (status = env->Object_CallMethodByName_Ref(static_cast(arrayObj), - "$_get", "i:C{std.core.Object}", &buttonRef, (ani_int)i))) { + "$_get", "i:C{std.core.Object}", &buttonRef, i))) { ANS_LOGE("GetActionButtonArray: get ref failed, status = %{public}d, index = %{public}d", status, i); return status; } diff --git a/frameworks/ets/ani/src/sts_bundle_option.cpp b/frameworks/ets/ani/src/sts_bundle_option.cpp index 35a45a92b..8bf27fe09 100644 --- a/frameworks/ets/ani/src/sts_bundle_option.cpp +++ b/frameworks/ets/ani/src/sts_bundle_option.cpp @@ -85,14 +85,14 @@ bool UnwrapArrayBundleOption(ani_env *env, return false; } ani_status status; - ani_double length; - status = env->Object_GetPropertyByName_Double(static_cast(arrayObj), "length", &length); + ani_int length; + status = env->Object_GetPropertyByName_Int(static_cast(arrayObj), "length", &length); if (status != ANI_OK) { ANS_LOGE("UnwrapArrayBundleOption: get length failed, status = %{public}d", status); return false; } Notification::NotificationBundleOption option; - for (int32_t i = 0; i < static_cast(length); i++) { + for (int32_t i = 0; i < length; i++) { ani_ref optionRef; status = env->Object_CallMethodByName_Ref(static_cast(arrayObj), "$_get", "i:C{std.core.Object}", &optionRef, i); diff --git a/frameworks/ets/ani/src/sts_common.cpp b/frameworks/ets/ani/src/sts_common.cpp index 23c0d06dc..0da585c0e 100644 --- a/frameworks/ets/ani/src/sts_common.cpp +++ b/frameworks/ets/ani/src/sts_common.cpp @@ -84,16 +84,16 @@ bool GetStringArrayByAniObj(ani_env *env, const ani_object ani_obj, std::vector< ANS_LOGE("GetStringArrayByAniObj fail, has nullptr"); return false; } - ani_double length; - ani_status status = env->Object_GetPropertyByName_Double(ani_obj, "length", &length); + ani_int length; + ani_status status = env->Object_GetPropertyByName_Int(ani_obj, "length", &length); if (status != ANI_OK) { ANS_LOGE("Object_GetPropertyByName_Double faild. status %{public}d", status); return false; } - for (int i = 0; i < int(length); i++) { + for (int32_t i = 0; i < length; i++) { ani_ref stringEntryRef; status = env->Object_CallMethodByName_Ref(ani_obj, - "$_get", "i:C{std.core.Object}", &stringEntryRef, (ani_int)i); + "$_get", "i:C{std.core.Object}", &stringEntryRef, i); if (status != ANI_OK) { ANS_LOGE("status : %{public}d", status); return false; @@ -295,21 +295,21 @@ ani_status GetPropertyStringArray(ani_env *env, ani_object param, const char *na ANS_LOGD("GetPropertyStringArray: %{public}s", name); ani_ref arrayObj = nullptr; ani_status status; - ani_double length; + ani_int length; if ((status = GetPropertyRef(env, param, name, isUndefined, arrayObj)) != ANI_OK || isUndefined == ANI_TRUE) { ANS_LOGE("GetPropertyRef fail, status = %{public}d, isUndefind = %{public}d", status, isUndefined); return ANI_INVALID_ARGS; } - status = env->Object_GetPropertyByName_Double(static_cast(arrayObj), "length", &length); + status = env->Object_GetPropertyByName_Int(static_cast(arrayObj), "length", &length); if (status != ANI_OK) { ANS_LOGE("status : %{public}d", status); return status; } std::string str = ""; - for (int i = 0; i < static_cast(length); i++) { + for (int32_t i = 0; i < length; i++) { ani_ref stringEntryRef; status = env->Object_CallMethodByName_Ref(static_cast(arrayObj), - "$_get", "i:C{std.core.Object}", &stringEntryRef, (ani_int)i); + "$_get", "i:C{std.core.Object}", &stringEntryRef, i); if (status != ANI_OK) { ANS_LOGE("status : %{public}d, index: %{public}d", status, i); return status; @@ -331,21 +331,21 @@ ani_status GetPropertyNumberArray(ani_env *env, ani_object param, const char *na ANS_LOGD("GetPropertyNumberArray enter"); ani_ref arrayObj = nullptr; ani_status status; - ani_double length; + ani_int length; if ((status = GetPropertyRef(env, param, name, isUndefined, arrayObj)) != ANI_OK || isUndefined == ANI_TRUE) { return ANI_INVALID_ARGS; } - status = env->Object_GetPropertyByName_Double(static_cast(arrayObj), "length", &length); + status = env->Object_GetPropertyByName_Int(static_cast(arrayObj), "length", &length); if (status != ANI_OK) { ANS_LOGI("status : %{public}d", status); return status; } - for (int i = 0; i < static_cast(length); i++) { + for (int32_t i = 0; i < length; i++) { ani_ref numEntryRef; status = env->Object_CallMethodByName_Ref(static_cast(arrayObj), - "$_get", "i:C{std.core.Object}", &numEntryRef, (ani_int)i); + "$_get", "i:C{std.core.Object}", &numEntryRef, i); if (status != ANI_OK) { ANS_LOGI("status : %{public}d, index: %{public}d", status, i); return status; @@ -369,21 +369,21 @@ ani_status GetPropertyLongArray(ani_env *env, ani_object param, const char *name ANS_LOGD("GetPropertyLongArray enter"); ani_ref arrayObj = nullptr; ani_status status; - ani_double length; + ani_int length; if ((status = GetPropertyRef(env, param, name, isUndefined, arrayObj)) != ANI_OK || isUndefined == ANI_TRUE) { return ANI_INVALID_ARGS; } - status = env->Object_GetPropertyByName_Double(static_cast(arrayObj), "length", &length); + status = env->Object_GetPropertyByName_Int(static_cast(arrayObj), "length", &length); if (status != ANI_OK) { ANS_LOGI("status : %{public}d", status); return status; } - for (int i = 0; i < static_cast(length); i++) { + for (int32_t i = 0; i < length; i++) { ani_ref numEntryRef; status = env->Object_CallMethodByName_Ref(static_cast(arrayObj), - "$_get", "i:C{std.core.Object}", &numEntryRef, (ani_int)i); + "$_get", "i:C{std.core.Object}", &numEntryRef, i); if (status != ANI_OK) { ANS_LOGI("status : %{public}d, index: %{public}d", status, i); return status; diff --git a/frameworks/ets/ani/src/sts_convert_other.cpp b/frameworks/ets/ani/src/sts_convert_other.cpp index e82916c4e..4d537c83a 100644 --- a/frameworks/ets/ani/src/sts_convert_other.cpp +++ b/frameworks/ets/ani/src/sts_convert_other.cpp @@ -118,17 +118,17 @@ ani_status GetPixelMapArrayByRef(ani_env *env, ani_ref param, std::vectorObject_GetPropertyByName_Double(static_cast(param), "length", &length); + ani_int length; + status = env->Object_GetPropertyByName_Int(static_cast(param), "length", &length); if (status != ANI_OK) { ANS_LOGE("GetPixelMapArrayByRef: status : %{public}d", status); return status; } - for (int i = 0; i < static_cast(length); i++) { + for (int32_t i = 0; i < length; i++) { ani_ref pixelMapRef; status = env->Object_CallMethodByName_Ref(static_cast(param), - "$_get", "i:C{std.core.Object}", &pixelMapRef, (ani_int)i); + "$_get", "i:C{std.core.Object}", &pixelMapRef, i); if (status != ANI_OK) { ANS_LOGE("GetPixelMapArrayByRef:status : %{public}d, index: %{public}d", status, i); pixelMaps.clear(); @@ -180,20 +180,20 @@ ani_status GetResourceArray(ani_env *env, ani_ref arrayObj = nullptr; ani_boolean isUndefined = true; ani_status status; - ani_double length; + ani_int length; if ((status = GetPropertyRef(env, param, name, isUndefined, arrayObj)) != ANI_OK || isUndefined == ANI_TRUE) { ANS_LOGE("GetResourceArray failed, status : %{public}d", status); return ANI_INVALID_ARGS; } - status = env->Object_GetPropertyByName_Double(static_cast(arrayObj), "length", &length); + status = env->Object_GetPropertyByName_Int(static_cast(arrayObj), "length", &length); if (status != ANI_OK) { ANS_LOGE("GetResourceArray : status : %{public}d", status); return status; } - for (int i = 0; i < static_cast(length); i++) { + for (int32_t i = 0; i < length; i++) { ani_ref iconRef; status = env->Object_CallMethodByName_Ref(static_cast(arrayObj), - "$_get", "i:C{std.core.Object}", &iconRef, (ani_int)i); + "$_get", "i:C{std.core.Object}", &iconRef, i); if (status != ANI_OK) { res.clear(); ANS_LOGE("GetResourceArray: status = %{public}d, index = %{public}d", status, i); @@ -211,7 +211,7 @@ ani_status GetResourceArray(ani_env *env, return status; } -ani_status GetKeyString(ani_env *env, ani_object obj, int index, ani_string &str) +ani_status GetKeyString(ani_env *env, ani_object obj, int32_t index, ani_string &str) { ANS_LOGD("GetKeyString call"); if (env == nullptr || obj == nullptr) { @@ -221,7 +221,7 @@ ani_status GetKeyString(ani_env *env, ani_object obj, int index, ani_string &str ani_status status = ANI_ERROR; ani_ref stringEntryRef; status = env->Object_CallMethodByName_Ref(obj, - "$_get", "i:C{std.core.Object}", &stringEntryRef, (ani_int)index); + "$_get", "i:C{std.core.Object}", &stringEntryRef, index); if (status != ANI_OK) { ANS_LOGE("status : %{public}d, index: %{public}d", status, index); return status; @@ -277,15 +277,15 @@ ani_status GetPixelMapByRef( return ANI_ERROR; } ani_status status = ANI_ERROR; - ani_double length; + ani_int length; if (ANI_OK != - (status = env->Object_GetPropertyByName_Double(static_cast(keysStrArrayRef), "length", &length))) { + (status = env->Object_GetPropertyByName_Int(static_cast(keysStrArrayRef), "length", &length))) { ANS_LOGE("GetPixelMapByRef : Object_GetPropertyByName_Double status = %{public}d", status); return status; } ani_string strAni = {}; std::vector keys = {}; - for (int i = 0; i < static_cast(length); i++) { + for (int32_t i = 0; i < length; i++) { if ((status = GetKeyString(env, static_cast(keysStrArrayRef), i, strAni)) != ANI_OK) { ANS_LOGE("GetPixelMapByRef : GetKeyString status = %{public}d", status); keys.clear(); diff --git a/frameworks/ets/ani/src/sts_disturb_mode.cpp b/frameworks/ets/ani/src/sts_disturb_mode.cpp index f57445ea2..0f836672d 100644 --- a/frameworks/ets/ani/src/sts_disturb_mode.cpp +++ b/frameworks/ets/ani/src/sts_disturb_mode.cpp @@ -64,16 +64,16 @@ bool UnwrapArrayDoNotDisturbProfile(ani_env *env, ani_object arrayObj, return false; } ani_status status; - ani_double length; - status = env->Object_GetPropertyByName_Double(arrayObj, "length", &length); + ani_int length; + status = env->Object_GetPropertyByName_Int(arrayObj, "length", &length); if (status != ANI_OK) { ANS_LOGD("UnwrapArrayDoNotDisturbProfile: status = %{public}d", status); return false; } - for (int i = 0; i < static_cast(length); i++) { + for (int32_t i = 0; i < length; i++) { ani_ref optionRef; status = env->Object_CallMethodByName_Ref(arrayObj, "$_get", - "i:C{std.core.Object}", &optionRef, (ani_int)i); + "i:C{std.core.Object}", &optionRef, i); if (status != ANI_OK) { ANS_LOGE("UnwrapArrayDoNotDisturbProfile: status : %{public}d, index: %{public}d", status, i); return false; diff --git a/frameworks/ets/ani/src/sts_notification_content.cpp b/frameworks/ets/ani/src/sts_notification_content.cpp index 1edd1f1a1..fa6ffffbe 100644 --- a/frameworks/ets/ani/src/sts_notification_content.cpp +++ b/frameworks/ets/ani/src/sts_notification_content.cpp @@ -320,20 +320,20 @@ ani_status GetIconButtonArray(ani_env *env, ani_ref arrayObj = nullptr; ani_boolean isUndefined = true; ani_status status = ANI_ERROR; - ani_double length; + ani_int length; if (((status = GetPropertyRef(env, param, name, isUndefined, arrayObj)) != ANI_OK) || isUndefined == ANI_TRUE) { ANS_LOGI("get param failed, may be %{public}s : undefined", name); return ANI_INVALID_ARGS; } - status = env->Object_GetPropertyByName_Double(static_cast(arrayObj), "length", &length); + status = env->Object_GetPropertyByName_Int(static_cast(arrayObj), "length", &length); if (status != ANI_OK) { ANS_LOGI("status : %{public}d", status); return status; } - for (int i = 0; i < static_cast(length); i++) { + for (int32_t i = 0; i < length; i++) { ani_ref buttonRef; status = env->Object_CallMethodByName_Ref(static_cast(arrayObj), - "$_get", "i:C{std.core.Object}", &buttonRef, (ani_int)i); + "$_get", "i:C{std.core.Object}", &buttonRef, i); if (status != ANI_OK) { ANS_LOGI("status : %{public}d, index: %{public}d", status, i); return status; diff --git a/frameworks/ets/ani/src/sts_slot.cpp b/frameworks/ets/ani/src/sts_slot.cpp index 0167a798b..43f29248d 100644 --- a/frameworks/ets/ani/src/sts_slot.cpp +++ b/frameworks/ets/ani/src/sts_slot.cpp @@ -304,16 +304,16 @@ bool UnwrapNotificationSlotArrayByAniObj(ani_env *env, ani_object notificationSl ANS_LOGE("notificationSlotArrayObj is null"); return false; } - ani_double length; - ani_status status = env->Object_GetPropertyByName_Double(notificationSlotArrayObj, "length", &length); + ani_int length; + ani_status status = env->Object_GetPropertyByName_Int(notificationSlotArrayObj, "length", &length); if (status != ANI_OK) { ANS_LOGE("Object_GetPropertyByName_Double faild. status : %{public}d", status); return false; } - for (int i = 0; i < int(length); i++) { + for (int32_t i = 0; i < length; i++) { ani_ref notificationSlotEntryRef; status = env->Object_CallMethodByName_Ref(notificationSlotArrayObj, - "$_get", "i:C{std.core.Object}", ¬ificationSlotEntryRef, (ani_int)i); + "$_get", "i:C{std.core.Object}", ¬ificationSlotEntryRef, i); if (status != ANI_OK) { ANS_LOGE("Object_CallMethodByName_Ref faild. status : %{public}d", status); } -- Gitee