From 2f1a4de3df14bf2d53c66b7ae0f55ece4b939c93 Mon Sep 17 00:00:00 2001 From: wanzixuan Date: Tue, 22 Jul 2025 21:00:52 +0800 Subject: [PATCH] Modify overload for taihe Signed-off-by: wanzixuan --- .../idl/ohos.file.storageStatistics.taihe | 40 ++++++++++++++----- .../src/ohos.file.storageStatistics.impl.cpp | 12 +++++- .../idl/ohos.file.volumeManager.taihe | 16 ++++++-- .../src/ohos.file.volumeManager.impl.cpp | 4 ++ 4 files changed, 57 insertions(+), 15 deletions(-) diff --git a/interfaces/kits/taihe/storage_statistics/idl/ohos.file.storageStatistics.taihe b/interfaces/kits/taihe/storage_statistics/idl/ohos.file.storageStatistics.taihe index ff0e0eb0a..96ebfb6f3 100644 --- a/interfaces/kits/taihe/storage_statistics/idl/ohos.file.storageStatistics.taihe +++ b/interfaces/kits/taihe/storage_statistics/idl/ohos.file.storageStatistics.taihe @@ -19,14 +19,22 @@ static { loadLibrary("storage_statistics_taihe.z"); } """) -@gen_async("getFreeSize") -@gen_promise("getFreeSize") function GetFreeSizeSync(): i64; -@gen_async("getTotalSize") -@gen_promise("getTotalSize") +@static_overload("getFreeSize") +@async function GetFreeSizeWithCallback(): i64; + +@static_overload("getFreeSize") +@promise function GetFreeSizeReturnsPromise(): i64; + function GetTotalSizeSync(): i64; +@static_overload("getTotalSize") +@async function GetTotalSizeWithCallback(): i64; + +@static_overload("getTotalSize") +@promise function GetTotalSizeReturnsPromise(): i64; + struct BundleStats { dataSize: i64; cacheSize: i64; @@ -41,14 +49,26 @@ struct StorageStats { function MakeStorageStats(total: i64): StorageStats; -@gen_async("getCurrentBundleStats") -@gen_promise("getCurrentBundleStats") function GetCurrentBundleStatsSync(): BundleStats; -@gen_async("getUserStorageStats") -@gen_promise("getUserStorageStats") +@static_overload("getCurrentBundleStats") +@async function GetCurrentBundleStatsWithCallback(): BundleStats; + +@static_overload("getCurrentBundleStats") +@promise function GetCurrentBundleStatsReturnsPromise(): BundleStats; + function GetUserStorageStatsSync(): StorageStats; -@gen_async("getUserStorageStats") -@gen_promise("getUserStorageStats") function GetUserStorageStatsByidSync(userID: i64): StorageStats; + +@static_overload("getUserStorageStats") +@async function GetUserStorageStatsWithCallback(): StorageStats; + +@static_overload("getUserStorageStats") +@promise function GetUserStorageStatsReturnsPromise(): StorageStats; + +@static_overload("getUserStorageStats") +@async function GetUserStorageStatsWithUserIdCallback(userID: i64): StorageStats; + +@static_overload("getUserStorageStats") +@promise function GetUserStorageStatsWithUserIdReturnsPromise(userID: i64): StorageStats; diff --git a/interfaces/kits/taihe/storage_statistics/src/ohos.file.storageStatistics.impl.cpp b/interfaces/kits/taihe/storage_statistics/src/ohos.file.storageStatistics.impl.cpp index e9755e178..e3358ee0d 100644 --- a/interfaces/kits/taihe/storage_statistics/src/ohos.file.storageStatistics.impl.cpp +++ b/interfaces/kits/taihe/storage_statistics/src/ohos.file.storageStatistics.impl.cpp @@ -118,13 +118,23 @@ ohos::file::storageStatistics::StorageStats GetUserStorageStatsByidSync(int64_t } } // namespace ANI::storageStatistics -// Since these macros are auto-generate, lint will cause false positive. +// Since these macros are auto-generate, lint will cause false pgetCurrentBundleStatsgetCurrentBundleStatsositive. // NOLINTBEGIN TH_EXPORT_CPP_API_GetFreeSizeSync(ANI::StorageStatistics::GetFreeSizeSync); +TH_EXPORT_CPP_API_GetFreeSizeWithCallback(ANI::StorageStatistics::GetFreeSizeSync); +TH_EXPORT_CPP_API_GetFreeSizeReturnsPromise(ANI::StorageStatistics::GetFreeSizeSync); TH_EXPORT_CPP_API_GetTotalSizeSync(ANI::StorageStatistics::GetTotalSizeSync); +TH_EXPORT_CPP_API_GetTotalSizeWithCallback(ANI::StorageStatistics::GetTotalSizeSync); +TH_EXPORT_CPP_API_GetTotalSizeReturnsPromise(ANI::StorageStatistics::GetTotalSizeSync); TH_EXPORT_CPP_API_MakeBundleStats(ANI::StorageStatistics::MakeBundleStats); TH_EXPORT_CPP_API_MakeStorageStats(ANI::StorageStatistics::MakeStorageStats); TH_EXPORT_CPP_API_GetCurrentBundleStatsSync(ANI::StorageStatistics::GetCurrentBundleStatsSync); +TH_EXPORT_CPP_API_GetCurrentBundleStatsWithCallback(ANI::StorageStatistics::GetCurrentBundleStatsSync); +TH_EXPORT_CPP_API_GetCurrentBundleStatsReturnsPromise(ANI::StorageStatistics::GetCurrentBundleStatsSync); TH_EXPORT_CPP_API_GetUserStorageStatsSync(ANI::StorageStatistics::GetUserStorageStatsSync); +TH_EXPORT_CPP_API_GetUserStorageStatsWithCallback(ANI::StorageStatistics::GetUserStorageStatsSync); +TH_EXPORT_CPP_API_GetUserStorageStatsReturnsPromise(ANI::StorageStatistics::GetUserStorageStatsSync); TH_EXPORT_CPP_API_GetUserStorageStatsByidSync(ANI::StorageStatistics::GetUserStorageStatsByidSync); +TH_EXPORT_CPP_API_GetUserStorageStatsWithUserIdCallback(ANI::StorageStatistics::GetUserStorageStatsByidSync); +TH_EXPORT_CPP_API_GetUserStorageStatsWithUserIdReturnsPromise(ANI::StorageStatistics::GetUserStorageStatsByidSync); // NOLINTEND diff --git a/interfaces/kits/taihe/volume_manager/idl/ohos.file.volumeManager.taihe b/interfaces/kits/taihe/volume_manager/idl/ohos.file.volumeManager.taihe index 4e3457d29..7e8eb7266 100644 --- a/interfaces/kits/taihe/volume_manager/idl/ohos.file.volumeManager.taihe +++ b/interfaces/kits/taihe/volume_manager/idl/ohos.file.volumeManager.taihe @@ -26,10 +26,18 @@ struct Volume { function MakeVolume(description: String, uuid: String): Volume; -@gen_async("getVolumeByUuid") -@gen_promise("getVolumeByUuid") function GetVolumeByUuidSync(uuid: String): Volume; -@gen_async("getAllVolumes") -@gen_promise("getAllVolumes") +@static_overload("getVolumeByUuid") +@async function GetVolumeByUuidWithCallback(uuid: String): Volume; + +@static_overload("getVolumeByUuid") +@promise function GetVolumeByUuidReturnsPromise(uuid: String): Volume; + function GetAllVolumesSync(): Array; + +@static_overload("getAllVolumes") +@async function GetAllVolumesWithCallback(): Array; + +@static_overload("getAllVolumes") +@promise function GetAllVolumesReturnsPromise(): Array; diff --git a/interfaces/kits/taihe/volume_manager/src/ohos.file.volumeManager.impl.cpp b/interfaces/kits/taihe/volume_manager/src/ohos.file.volumeManager.impl.cpp index 3250f7714..971e59940 100644 --- a/interfaces/kits/taihe/volume_manager/src/ohos.file.volumeManager.impl.cpp +++ b/interfaces/kits/taihe/volume_manager/src/ohos.file.volumeManager.impl.cpp @@ -74,5 +74,9 @@ taihe::array_view GetAllVolumesSync() // NOLINTBEGIN TH_EXPORT_CPP_API_MakeVolume(ANI::VolumeManager::MakeVolume); TH_EXPORT_CPP_API_GetVolumeByUuidSync(ANI::VolumeManager::GetVolumeByUuidSync); +TH_EXPORT_CPP_API_GetVolumeByUuidWithCallback(ANI::VolumeManager::GetVolumeByUuidSync); +TH_EXPORT_CPP_API_GetVolumeByUuidReturnsPromise(ANI::VolumeManager::GetVolumeByUuidSync); TH_EXPORT_CPP_API_GetAllVolumesSync(ANI::VolumeManager::GetAllVolumesSync); +TH_EXPORT_CPP_API_GetAllVolumesWithCallback(ANI::VolumeManager::GetAllVolumesSync); +TH_EXPORT_CPP_API_GetAllVolumesReturnsPromise(ANI::VolumeManager::GetAllVolumesSync); // NOLINTEND -- Gitee