From 9affcaf897a870c77f5ff9c141fb7fd765736bf4 Mon Sep 17 00:00:00 2001 From: wanchengzhen Date: Tue, 15 Feb 2022 16:41:22 +0800 Subject: [PATCH 1/3] codex Signed-off-by: wanchengzhen --- OAT.xml | 3 +- .../AMS/mock_serviceability_manager_service.h | 3 +- frameworks/kits/ability/native/BUILD.gn | 6 - .../kits/ability/native/include/ability.h | 31 - .../ability/native/include/ability_impl.h | 2 +- .../ability/native/include/ability_thread.h | 4 +- .../ability/native/include/datashare_helper.h | 1 + .../distributed_client.h | 9 +- .../native/include/iability_callback.h | 3 - .../kits/ability/native/src/ability.cpp | 80 - .../kits/ability/native/src/ability_impl.cpp | 2 +- .../native/src/ability_runtime/js_ability.cpp | 10 +- .../ability/native/src/ability_thread.cpp | 18 +- .../distributed/continuation_manager.cpp | 4 - .../ability/native/src/datashare_helper.cpp | 76 +- .../distributed_client.cpp | 11 +- .../native/src/js_datashare_ext_ability.cpp | 34 +- .../include/mock_ability_manager_client.h | 6 +- .../include/mock_ability_manager_service.h | 3 +- .../mock_ability_scheduler_for_observer.h | 6 +- .../test/mock/include/mock_bundle_manager.cpp | 26 + .../test/mock/include/mock_bundle_manager.h | 8 + .../mock/include/mock_bundle_manager_form.h | 21 + .../form_extension_context.cpp | 6 +- .../appkit/native/app/include/main_thread.h | 4 +- .../appkit/native/app/src/main_thread.cpp | 12 +- .../mock_ability_manager_client_interface1.h | 13 + .../test/unittest/context_container_test.cpp | 12 +- .../Mock/include/mock_ability_mgr_service.h | 2 +- .../Mock/include/mock_bundle_mgr_service.h | 4 + .../mock/AMS/mock_ability_manager_service.h | 3 +- .../AMS/mock_serviceability_manager_service.h | 3 +- .../include/ability_manager_client.h | 15 +- .../include/ability_manager_interface.h | 11 +- .../include/ability_scheduler_interface.h | 4 +- .../ability_manager/include/start_options.h | 7 +- .../js/@ohos.ability.particleAbility.d.ts | 26 - ...@ohos.application.DataShareExtAbility.d.ts | 92 +- interfaces/kits/js/@ohos.data.dataShare.d.ts | 213 -- interfaces/kits/napi/BUILD.gn | 1 - .../abilityManager/napi_ability_manager.cpp | 9 +- .../aafwk/ability_context/ability_context.js | 8 +- .../aafwk/app/app_manager/js_app_manager.cpp | 90 + interfaces/kits/napi/aafwk/dataShare/BUILD.gn | 69 - .../napi/aafwk/dataShare/data_share_common.h | 360 -- .../aafwk/dataShare/napi_datashare_helper.cpp | 3322 ----------------- .../aafwk/dataShare/napi_datashare_helper.h | 426 --- .../dataShare/native_datashare_module.cpp | 54 - .../napi/aafwk/inner/napi_common/BUILD.gn | 1 - .../napi_common/feature_ability_common.h | 1 - .../inner/napi_common/napi_common_ability.cpp | 328 -- .../inner/napi_common/napi_common_ability.h | 22 +- .../aafwk/mission_manager/mission_manager.cpp | 21 +- .../particleAbility/particle_ability.cpp | 30 - .../include/ability_manager_proxy.h | 8 +- .../include/ability_manager_service.h | 6 +- .../abilitymgr/include/ability_manager_stub.h | 3 +- services/abilitymgr/include/ability_record.h | 4 +- .../include/ability_scheduler_proxy.h | 4 +- services/abilitymgr/include/lifecycle_deal.h | 2 +- services/abilitymgr/include/mission_list.h | 4 +- .../abilitymgr/include/mission_list_manager.h | 16 +- .../abilitymgr/src/ability_manager_client.cpp | 17 - .../abilitymgr/src/ability_manager_proxy.cpp | 28 +- .../src/ability_manager_service.cpp | 105 +- .../abilitymgr/src/ability_manager_stub.cpp | 21 +- services/abilitymgr/src/ability_record.cpp | 13 +- .../src/ability_scheduler_proxy.cpp | 7 +- .../abilitymgr/src/ability_scheduler_stub.cpp | 9 +- services/abilitymgr/src/lifecycle_deal.cpp | 2 +- services/abilitymgr/src/mission_list.cpp | 8 +- .../abilitymgr/src/mission_list_manager.cpp | 23 +- .../abilitymgr/src/pending_want_manager.cpp | 3 +- services/abilitymgr/src/start_options.cpp | 15 - .../libs/aakit/include/ability_scheduler.h | 4 +- .../ability_scheduler_mock.h | 6 +- .../include/bundlemgr/mock_bundle_manager.h | 8 + .../ability_manager_stub_mock.h | 3 +- .../ability_manager_service_test.cpp | 9 +- .../ability_manager_stub_impl_mock.h | 6 +- .../ability_manager_stub_mock.h | 2 +- .../ability_schedule_stub_mock.h | 6 +- .../abilityms_appms_test.cpp | 24 +- .../phone/lifecycle_test/lifecycle_test.cpp | 10 +- .../appmgr/include/app_mgr_service_inner.h | 2 +- services/appmgr/src/ams_mgr_scheduler.cpp | 4 +- services/appmgr/src/app_mgr_service_inner.cpp | 37 +- .../test/mock/include/mock_bundle_manager.h | 21 +- .../test/mock/src/mock_bundle_manager.cpp | 4 + .../ams_app_life_cycle_test.cpp | 100 +- .../ams_service_event_drive_test.cpp | 20 +- services/formmgr/src/form_mgr_service.cpp | 6 +- .../test/mock/include/mock_ability_manager.h | 13 +- .../test/mock/include/mock_bundle_manager.h | 25 +- .../fms_form_host_record_test.cpp | 16 +- .../fms_form_mgr_add_form_test.cpp | 22 +- .../fms_form_mgr_cast_temp_form_test.cpp | 16 +- .../fms_form_mgr_death_callback_test.cpp | 18 +- .../fms_form_mgr_delete_form_test.cpp | 16 +- .../fms_form_mgr_lifecycle_update_test.cpp | 11 +- .../fms_form_mgr_message_event_test.cpp | 16 +- ...s_form_mgr_notify_invisible_forms_test.cpp | 24 +- ...fms_form_mgr_notify_visible_forms_test.cpp | 13 +- .../fms_form_mgr_release_form_test.cpp | 8 +- .../fms_form_mgr_request_form_test.cpp | 14 +- .../fms_form_mgr_update_form_test.cpp | 17 +- .../fms_form_provider_mgr_test.cpp | 18 +- .../fms_form_set_next_refresh_test.cpp | 21 +- .../fms_form_sys_event_receiver_test.cpp | 18 +- .../fms_form_timer_mgr_test.cpp | 3 + .../include/appmgr/mock_ability_mgr_host.h | 6 +- .../mock/include/mock_ability_mgr_service.h | 3 +- .../mock/include/mock_ability_scheduler.h | 4 +- .../include/mock_ability_scheduler_stub.h | 4 +- services/test/mock/include/mock_bundle_mgr.h | 8 + .../abilitySrc/amsStDataAbility/BUILD.gn | 2 +- .../include/verify_act_data_ability.h | 9 +- .../src/verify_act_data_ability.cpp | 439 ++- tools/aa/src/ability_command.cpp | 37 +- tools/test/mock/mock_ability_manager_stub.h | 3 +- zidl/bundle.json | 37 - zidl/test/native/BUILD.gn | 69 - zidl/test/native/include/izidl_test_service.h | 36 - zidl/test/native/include/test_client.h | 34 - zidl/test/native/include/test_service.h | 36 - .../native/include/zidl_test_service_proxy.h | 48 - .../native/include/zidl_test_service_stub.h | 37 - zidl/test/native/src/main_client.cpp | 75 - zidl/test/native/src/main_server.cpp | 31 - zidl/test/native/src/test_client.cpp | 65 - zidl/test/native/src/test_service.cpp | 64 - .../native/src/zidl_test_service_proxy.cpp | 64 - .../native/src/zidl_test_service_stub.cpp | 48 - zidl/test/zidlgen/IZidlTestService.zidl | 19 - zidl/test/zidlgen/zidl | Bin 216360 -> 0 bytes 135 files changed, 1234 insertions(+), 6339 deletions(-) delete mode 100644 interfaces/kits/js/@ohos.data.dataShare.d.ts delete mode 100644 interfaces/kits/napi/aafwk/dataShare/BUILD.gn delete mode 100644 interfaces/kits/napi/aafwk/dataShare/data_share_common.h delete mode 100644 interfaces/kits/napi/aafwk/dataShare/napi_datashare_helper.cpp delete mode 100644 interfaces/kits/napi/aafwk/dataShare/napi_datashare_helper.h delete mode 100644 interfaces/kits/napi/aafwk/dataShare/native_datashare_module.cpp delete mode 100644 zidl/bundle.json delete mode 100644 zidl/test/native/BUILD.gn delete mode 100644 zidl/test/native/include/izidl_test_service.h delete mode 100644 zidl/test/native/include/test_client.h delete mode 100644 zidl/test/native/include/test_service.h delete mode 100644 zidl/test/native/include/zidl_test_service_proxy.h delete mode 100644 zidl/test/native/include/zidl_test_service_stub.h delete mode 100644 zidl/test/native/src/main_client.cpp delete mode 100644 zidl/test/native/src/main_server.cpp delete mode 100644 zidl/test/native/src/test_client.cpp delete mode 100644 zidl/test/native/src/test_service.cpp delete mode 100644 zidl/test/native/src/zidl_test_service_proxy.cpp delete mode 100644 zidl/test/native/src/zidl_test_service_stub.cpp delete mode 100644 zidl/test/zidlgen/IZidlTestService.zidl delete mode 100644 zidl/test/zidlgen/zidl diff --git a/OAT.xml b/OAT.xml index 141c974629a..96b39662a64 100644 --- a/OAT.xml +++ b/OAT.xml @@ -62,8 +62,7 @@ Note:If the text contains special characters, please escape them according to th - - + diff --git a/frameworks/kits/ability/ability_runtime/test/mock/AMS/mock_serviceability_manager_service.h b/frameworks/kits/ability/ability_runtime/test/mock/AMS/mock_serviceability_manager_service.h index 64a58e4af28..fb6a3059f83 100644 --- a/frameworks/kits/ability/ability_runtime/test/mock/AMS/mock_serviceability_manager_service.h +++ b/frameworks/kits/ability/ability_runtime/test/mock/AMS/mock_serviceability_manager_service.h @@ -117,7 +117,7 @@ public: MOCK_METHOD1(GetPendinTerminateAbilityTestgRequestWant, void(int id)); MOCK_METHOD1(GetSystemMemoryAttr, void(AppExecFwk::SystemMemoryAttr &memoryInfo)); MOCK_METHOD3(StartContinuation, int(const Want &want, const sptr &abilityToken, int32_t status)); - MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); + MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, const int32_t result)); MOCK_METHOD1(LockMissionForCleanup, int(int32_t missionId)); MOCK_METHOD1(UnlockMissionForCleanup, int(int32_t missionId)); @@ -134,7 +134,6 @@ public: MOCK_METHOD1(CleanMission, int(int32_t missionId)); MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); - MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions &startOptions)); MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); diff --git a/frameworks/kits/ability/native/BUILD.gn b/frameworks/kits/ability/native/BUILD.gn index 3bfc269332c..6473ae59308 100644 --- a/frameworks/kits/ability/native/BUILD.gn +++ b/frameworks/kits/ability/native/BUILD.gn @@ -76,7 +76,6 @@ config("ability_public_config") { "//third_party/libuv/include", "//foundation/aafwk/standard/frameworks/kits/appkit/native/ability_runtime/context", "//foundation/aafwk/standard/interfaces/innerkits/base/include/ohos/aafwk/base", - "//foundation/aafwk/standard/frameworks/kits/ability/native/include", "//foundation/aafwk/standard/frameworks/kits/ability/native/include/continuation/remote_register_service", "//foundation/aafwk/standard/frameworks/kits/ability/native/include/continuation/distributed", "//foundation/aafwk/standard/frameworks/kits/ability/native/include/distributed_ability_runtime", @@ -125,7 +124,6 @@ ohos_shared_library("abilitykit_native") { "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/common/include", "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_dataability/include", "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_resultset/include", - "//foundation/distributeddatamgr/objectstore/interfaces/innerkits/", "//base/global/i18n_standard/frameworks/intl/include", ] @@ -234,7 +232,6 @@ ohos_shared_library("abilitykit_native") { configs = [ ":ability_config" ] public_configs = [ ":ability_public_config", - "//base/notification/ans_standard/frameworks/wantagent:wantagent_innerkits_public_config", "//foundation/aafwk/standard/frameworks/kits/ability/ability_runtime:ability_context_public_config", ] @@ -242,7 +239,6 @@ ohos_shared_library("abilitykit_native") { ":static_subscriber_ipc", "${INNERKITS_PATH}/base:base", "${INNERKITS_PATH}/want:want", - "//base/notification/ans_standard/frameworks/wantagent:wantagent_innerkits", "//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk:libpermissionsdk_standard", "//foundation/aafwk/standard/common/task_dispatcher:task_dispatcher", "//foundation/aafwk/standard/frameworks/kits/ability/ability_runtime:ability_context_native", @@ -257,7 +253,6 @@ ohos_shared_library("abilitykit_native") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", "//foundation/multimodalinput/input/frameworks/proxy:libmmi-common", - "//foundation/resourceschedule/background_task_mgr/interfaces/innerkits:bgtaskmgr_innerkits", "//third_party/icu/icu4c:shared_icuuc", ] @@ -269,7 +264,6 @@ ohos_shared_library("abilitykit_native") { "access_token:libaccesstoken_sdk", "bytrace_standard:bytrace_core", "ces_standard:cesfwk_innerkits", - "distributeddataobject:distributeddataobject_impl", "form_runtime:fmskit_native", "form_runtime:form_manager", "ipc:ipc_core", diff --git a/frameworks/kits/ability/native/include/ability.h b/frameworks/kits/ability/native/include/ability.h index b43960bd9f4..55b6f88512d 100755 --- a/frameworks/kits/ability/native/include/ability.h +++ b/frameworks/kits/ability/native/include/ability.h @@ -44,7 +44,6 @@ #include "iremote_object.h" #include "pac_map.h" #include "want.h" -#include "want_agent.h" #include "window_option.h" #include "window_scene.h" #include "wm_common.h" @@ -672,14 +671,6 @@ public: */ virtual void Dump(const std::string &extra); - /** - * @brief dump ability info - * - * @param params dump params that indicate different dump targets - * @param info dump ability info - */ - virtual void Dump(const std::vector ¶ms, std::vector &info); - /** * @brief Keeps this Service ability in the background and displays a notification bar. * To use this method, you need to request the ohos.permission.KEEP_BACKGROUND_RUNNING permission from the system. @@ -1015,21 +1006,6 @@ public: */ bool DeleteForm(const int64_t formId); - /** - * @brief Keep this Service ability in the background and displays a notification bar. - * - * @param wantAgent Indicates which ability to start when user click the notification bar. - * @return the method result code, 0 means succeed - */ - virtual int StartBackgroundRunning(const Notification::WantAgent::WantAgent &wantAgent) final; - - /** - * @brief Cancel background running of this ability to free up system memory. - * - * @return the method result code, 0 means succeed - */ - virtual int StopBackgroundRunning() final; - /** * @brief The form callback. */ @@ -1461,13 +1437,6 @@ protected: */ bool IsRestoredInContinuation() const; - /** - * @brief wait for distributed object to complete sync - * - * @param want the want param. - */ - void WaitingDistributedObjectSyncComplete(const Want& want); - /** * @brief Notify continuation * diff --git a/frameworks/kits/ability/native/include/ability_impl.h b/frameworks/kits/ability/native/include/ability_impl.h index c5ee7da1607..cf2afeb8a7b 100755 --- a/frameworks/kits/ability/native/include/ability_impl.h +++ b/frameworks/kits/ability/native/include/ability_impl.h @@ -349,7 +349,7 @@ public: * * @return */ - virtual void NotifyContinuationResult(int32_t result); + virtual void NotifyContinuationResult(const int32_t result); bool IsStageBasedModel() const; diff --git a/frameworks/kits/ability/native/include/ability_thread.h b/frameworks/kits/ability/native/include/ability_thread.h index 6ad054d18b4..2b870321f20 100644 --- a/frameworks/kits/ability/native/include/ability_thread.h +++ b/frameworks/kits/ability/native/include/ability_thread.h @@ -313,7 +313,7 @@ public: * * @param result: Continuation result */ - void NotifyContinuationResult(int32_t result); + void NotifyContinuationResult(const int32_t result); /** * @brief Converts the given uri that refer to the Data ability into a normalized URI. A normalized URI can be used @@ -400,7 +400,7 @@ public: * * @param runnerInfo ability runner info. */ - void DumpAbilityInfo(const std::vector ¶ms, std::vector &info); + void DumpAbilityInfo(std::vector &info); sptr CallRequest(); diff --git a/frameworks/kits/ability/native/include/datashare_helper.h b/frameworks/kits/ability/native/include/datashare_helper.h index 29f15ba6204..39cb1935ace 100644 --- a/frameworks/kits/ability/native/include/datashare_helper.h +++ b/frameworks/kits/ability/native/include/datashare_helper.h @@ -264,6 +264,7 @@ private: std::shared_ptr uri_ = nullptr; sptr dataShareProxy_ = nullptr; bool isSystemCaller_ = false; + std::mutex lock_; static std::mutex oplock_; sptr callerDeathRecipient_ = nullptr; std::map, sptr> registerMap_; diff --git a/frameworks/kits/ability/native/include/distributed_ability_runtime/distributed_client.h b/frameworks/kits/ability/native/include/distributed_ability_runtime/distributed_client.h index f931e17ee99..a8a75b9274d 100644 --- a/frameworks/kits/ability/native/include/distributed_ability_runtime/distributed_client.h +++ b/frameworks/kits/ability/native/include/distributed_ability_runtime/distributed_client.h @@ -31,15 +31,14 @@ class DistributedClient { public: DistributedClient() = default; virtual ~DistributedClient() = default; - int32_t StartRemoteAbility(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode, - uint32_t accessToken); + int32_t StartRemoteAbility(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode); int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId, int32_t missionId, const sptr& callback, const OHOS::AAFwk::WantParams& wantParams); int32_t StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId, int32_t callerUid, - int32_t status, uint32_t accessToken); + int32_t status); int32_t NotifyCompleteContinuation(const std::u16string &devId, int32_t sessionId, bool isSuccess); - int32_t ConnectRemoteAbility(const OHOS::AAFwk::Want& want, const sptr& connect, - int32_t callerUid, int32_t callerPid, uint32_t accessToken); + int32_t ConnectRemoteAbility(const OHOS::AAFwk::Want& want, + const sptr& connect, int32_t callerUid, int32_t callerPid); int32_t DisconnectRemoteAbility(const sptr& connect); int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag); int32_t StopSyncRemoteMissions(const std::string& devId); diff --git a/frameworks/kits/ability/native/include/iability_callback.h b/frameworks/kits/ability/native/include/iability_callback.h index 7a4f8195fb7..a62753795d5 100644 --- a/frameworks/kits/ability/native/include/iability_callback.h +++ b/frameworks/kits/ability/native/include/iability_callback.h @@ -20,9 +20,6 @@ namespace OHOS { namespace AppExecFwk { class IAbilityCallback { public: - IAbilityCallback() = default; - virtual ~IAbilityCallback() = default; - /** * @brief Called back at ability context. */ diff --git a/frameworks/kits/ability/native/src/ability.cpp b/frameworks/kits/ability/native/src/ability.cpp index bb233168059..54ce04dd202 100755 --- a/frameworks/kits/ability/native/src/ability.cpp +++ b/frameworks/kits/ability/native/src/ability.cpp @@ -24,20 +24,17 @@ #include "ability_runtime/js_ability.h" #include "abs_shared_result_set.h" #include "app_log_wrapper.h" -#include "background_task_mgr_helper.h" #include "bytrace.h" #include "connection_manager.h" #include "context_impl.h" #include "continuation_manager.h" #include "continuation_register_manager.h" #include "continuation_register_manager_proxy.h" -#include "continuous_task_param.h" #include "data_ability_operation.h" #include "data_ability_predicates.h" #include "data_ability_result.h" #include "data_uri_utils.h" #include "display_type.h" -#include "distributed_objectstore.h" #include "form_host_client.h" #include "form_mgr.h" #include "form_provider_client.h" @@ -81,7 +78,6 @@ static std::mutex formLock; constexpr int64_t SEC_TO_MILLISEC = 1000; constexpr int64_t MILLISEC_TO_NANOSEC = 1000000; -constexpr int32_t DISTRIBUTED_OBJECT_TIMEOUT = 3000; Ability* Ability::Create(const std::unique_ptr& runtime) { @@ -279,7 +275,6 @@ void Ability::Destroy() APP_LOGI("%{public}s begin.", __func__); // Release the scene. if (scene_ != nullptr) { - scene_->GoDestroy(); scene_ = nullptr; onSceneDestroyed(); } @@ -418,43 +413,8 @@ bool Ability::IsRestoredInContinuation() const return false; } -void Ability::WaitingDistributedObjectSyncComplete(const Want& want) -{ - int sessionId = want.GetIntParam(DMS_SESSION_ID, DEFAULT_DMS_SESSION_ID); - std::string originDeviceId = want.GetStringParam(DMS_ORIGIN_DEVICE_ID); - - APP_LOGI("continuation WaitingDistributedObjectSyncComplete begin"); - auto timeout = [self = shared_from_this(), sessionId, originDeviceId]() { - APP_LOGI("DistributedObject sync timeout"); - self->continuationManager_->NotifyCompleteContinuation( - originDeviceId, sessionId, false, nullptr); - }; - - // std::shared_ptr handler = handler_; - auto callback = [self = shared_from_this(), sessionId, originDeviceId]() { - APP_LOGI("DistributedObject sync complete"); - if (self->handler_ != nullptr) { - self->handler_->RemoveTask("Waiting_Sync_Timeout"); - } - self->continuationManager_->NotifyCompleteContinuation( - originDeviceId, sessionId, true, nullptr); - }; - - std::string &bundleName = abilityInfo_->bundleName; - APP_LOGI("continuation TriggerRestore begin"); - ObjectStore::DistributedObjectStore::GetInstance(bundleName)->TriggerRestore(callback); - APP_LOGI("continuation TriggerRestore end"); - - if (handler_ != nullptr) { - APP_LOGI("continuation set timeout begin"); - handler_->PostTask(timeout, "Waiting_Sync_Timeout", DISTRIBUTED_OBJECT_TIMEOUT); - APP_LOGI("continuation set timeout end"); - } -} - void Ability::NotityContinuationResult(const Want& want, bool success) { - APP_LOGI("NotityContinuationResult begin"); std::weak_ptr ReplicaHandler = continuationHandler_; reverseContinuationSchedulerReplica_ = sptr( new (std::nothrow) ReverseContinuationSchedulerReplica(handler_, ReplicaHandler)); @@ -1262,15 +1222,6 @@ void Ability::Dump(const std::string &extra) } } -/** - * @brief dump ability info - * - * @param params dump params that indicate different dump targets - * @param info dump ability info -*/ -void Ability::Dump(const std::vector ¶ms, std::vector &info) -{} - /** * @brief Keeps this Service ability in the background and displays a notification bar. * To use this method, you need to request the ohos.permission.KEEP_BACKGROUND_RUNNING permission from the system. @@ -1994,30 +1945,6 @@ bool Ability::DeleteForm(const int64_t formId) return DeleteForm(formId, DELETE_FORM); } -/** - * @brief Keep this Service ability in the background and displays a notification bar. - * - * @param wantAgent Indicates which ability to start when user click the notification bar. - * @return the method result code, 0 means succeed - */ -int Ability::StartBackgroundRunning(const Notification::WantAgent::WantAgent &wantAgent) -{ - uint32_t defaultBgMode = 0; - BackgroundTaskMgr::ContinuousTaskParam taskParam = BackgroundTaskMgr::ContinuousTaskParam(false, defaultBgMode, - std::make_shared(wantAgent), abilityInfo_->name, GetToken()); - return BackgroundTaskMgr::BackgroundTaskMgrHelper::RequestStartBackgroundRunning(taskParam); -} - -/** - * @brief Cancel background running of this ability to free up system memory. - * - * @return the method result code, 0 means succeed - */ -int Ability::StopBackgroundRunning() -{ - return BackgroundTaskMgr::BackgroundTaskMgrHelper::RequestStopBackgroundRunning(abilityInfo_->name, GetToken()); -} - /** * @brief Cast temp form with formId. * @@ -3345,13 +3272,6 @@ void Ability::DoOnForeground(const Want& want) if (abilityWindow_ != nullptr) { APP_LOGI("%{public}s begin abilityWindow_->OnPostAbilityForeground, sceneFlag:%{public}d.", __func__, sceneFlag_); - auto window = abilityWindow_->GetWindow(); - if (window != nullptr && want.HasParameter(Want::PARAM_RESV_WINDOW_MODE)) { - auto windowMode = want.GetIntParam(Want::PARAM_RESV_WINDOW_MODE, - AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED); - window->SetWindowMode(static_cast(windowMode)); - APP_LOGI("set window mode = %{public}d.", windowMode); - } abilityWindow_->OnPostAbilityForeground(sceneFlag_); APP_LOGI("%{public}s end abilityWindow_->OnPostAbilityForeground.", __func__); } else { diff --git a/frameworks/kits/ability/native/src/ability_impl.cpp b/frameworks/kits/ability/native/src/ability_impl.cpp index e4aed208c0b..a57bfb9b105 100755 --- a/frameworks/kits/ability/native/src/ability_impl.cpp +++ b/frameworks/kits/ability/native/src/ability_impl.cpp @@ -918,7 +918,7 @@ void AbilityImpl::ContinueAbility(const std::string& deviceId) ability_->ContinueAbilityWithStack(deviceId); } -void AbilityImpl::NotifyContinuationResult(int32_t result) +void AbilityImpl::NotifyContinuationResult(const int32_t result) { if (ability_ == nullptr) { APP_LOGE("AbilityImpl::NotifyContinuationResult ability_ is nullptr"); diff --git a/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp b/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp index 46ad247b289..a5563e07cd4 100755 --- a/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp +++ b/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp @@ -455,18 +455,10 @@ void JsAbility::DoOnForeground(const Want &want) HILOG_ERROR("restore: content storage is nullptr"); } OnSceneRestored(); - WaitingDistributedObjectSyncComplete(want); + NotityContinuationResult(want, true); } else { OnSceneCreated(); } - } else { - auto window = scene_->GetMainWindow(); - if (window != nullptr && want.HasParameter(Want::PARAM_RESV_WINDOW_MODE)) { - auto windowMode = want.GetIntParam(Want::PARAM_RESV_WINDOW_MODE, - AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED); - window->SetWindowMode(static_cast(windowMode)); - HILOG_INFO("set window mode = %{public}d.", windowMode); - } } HILOG_INFO("%{public}s begin scene_->GoForeground, sceneFlag_:%{public}d.", __func__, Ability::sceneFlag_); scene_->GoForeground(Ability::sceneFlag_); diff --git a/frameworks/kits/ability/native/src/ability_thread.cpp b/frameworks/kits/ability/native/src/ability_thread.cpp index 9b980402d57..ef238eaad0a 100644 --- a/frameworks/kits/ability/native/src/ability_thread.cpp +++ b/frameworks/kits/ability/native/src/ability_thread.cpp @@ -1212,7 +1212,7 @@ void AbilityThread::ContinueAbility(const std::string& deviceId) abilityImpl_->ContinueAbility(deviceId); } -void AbilityThread::NotifyContinuationResult(int32_t result) +void AbilityThread::NotifyContinuationResult(const int32_t result) { APP_LOGI("NotifyContinuationResult, result:%{public}d", result); if (abilityImpl_ == nullptr) { @@ -1559,23 +1559,9 @@ std::shared_ptr AbilityThread::BuildAbilityConte return abilityContextImpl; } -void AbilityThread::DumpAbilityInfo(const std::vector ¶ms, std::vector &info) +void AbilityThread::DumpAbilityInfo(std::vector &info) { APP_LOGI("%{public}s begin.", __func__); - if (!params.empty()) { - if (abilityImpl_->IsStageBasedModel()) { - auto window = currentAbility_->GetWindow(); - if (window == nullptr) { - APP_LOGE("DumpAbilityInfo window == nullptr"); - return; - } - window->DumpInfo(params, info); - } else { - currentAbility_->Dump(params, info); - } - - return; - } std::string dumpInfo = " event:"; info.push_back(dumpInfo); diff --git a/frameworks/kits/ability/native/src/continuation/distributed/continuation_manager.cpp b/frameworks/kits/ability/native/src/continuation/distributed/continuation_manager.cpp index 92d95f336f5..cb26a3056fa 100644 --- a/frameworks/kits/ability/native/src/continuation/distributed/continuation_manager.cpp +++ b/frameworks/kits/ability/native/src/continuation/distributed/continuation_manager.cpp @@ -21,7 +21,6 @@ #include "app_log_wrapper.h" #include "continuation_handler.h" #include "distributed_client.h" -#include "distributed_objectstore.h" #include "operation_builder.h" #include "string_ex.h" #include "string_wrapper.h" @@ -163,9 +162,6 @@ int32_t ContinuationManager::OnContinueAndGetContent(WantParams &wantParams) APP_LOGE("OnContinue failed."); return CONTINUE_ON_CONTINUE_FAILED; } - auto abilityInfo = abilityInfo_.lock(); - std::string &bundleName = abilityInfo->bundleName; - ObjectStore::DistributedObjectStore::GetInstance(bundleName)->TriggerSync(); status = GetContentInfo(wantParams); if (!status) { diff --git a/frameworks/kits/ability/native/src/datashare_helper.cpp b/frameworks/kits/ability/native/src/datashare_helper.cpp index 5635726b05f..db011ced34f 100644 --- a/frameworks/kits/ability/native/src/datashare_helper.cpp +++ b/frameworks/kits/ability/native/src/datashare_helper.cpp @@ -30,7 +30,6 @@ namespace OHOS { namespace AppExecFwk { namespace { const std::string SCHEME_DATASHARE = "datashare"; -constexpr int INVALID_VALUE = -1; } // namespace std::mutex DataShareHelper::oplock_; @@ -92,6 +91,7 @@ void DataShareHelper::AddDataShareDeathRecipient(const sptr &toke void DataShareHelper::OnSchedulerDied(const wptr &remote) { APP_LOGI("'%{public}s start':", __func__); + std::lock_guard guard(lock_); auto object = remote.promote(); object = nullptr; dataShareProxy_ = nullptr; @@ -147,19 +147,19 @@ std::shared_ptr DataShareHelper::Creator( std::shared_ptr DataShareHelper::Creator( const std::shared_ptr &context, const AAFwk::Want &want, const std::shared_ptr &uri) { - APP_LOGI("DataShareHelper::Creator with context, want and uri called start."); + APP_LOGI("DataShareHelper::Creator with context uri called start."); if (context == nullptr) { - APP_LOGE("DataShareHelper::Creator failed, context == nullptr"); + APP_LOGE("DataShareHelper::Creator (context, uri) failed, context == nullptr"); return nullptr; } if (uri == nullptr) { - APP_LOGE("DataShareHelper::Creator failed, uri == nullptr"); + APP_LOGE("DataShareHelper::Creator (context, uri) failed, uri == nullptr"); return nullptr; } if (uri->GetScheme() != SCHEME_DATASHARE) { - APP_LOGE("DataShareHelper::Creator failed, the Scheme is not datashare, Scheme: %{public}s", + APP_LOGE("DataShareHelper::Creator (context, uri) failed, the Scheme is not datashare, Scheme: %{public}s", uri->GetScheme().c_str()); return nullptr; } @@ -179,11 +179,11 @@ std::shared_ptr DataShareHelper::Creator( DataShareHelper *ptrDataShareHelper = new (std::nothrow) DataShareHelper(context, want, uri, dataShareProxy); if (ptrDataShareHelper == nullptr) { - APP_LOGE("DataShareHelper::Creator failed, create DataShareHelper failed"); + APP_LOGE("DataShareHelper::Creator (context, uri) failed, create DataShareHelper failed"); return nullptr; } - APP_LOGI("DataShareHelper::Creator with context, want and uri called end."); + APP_LOGI("DataShareHelper::Creator with context uri called end."); return std::shared_ptr(ptrDataShareHelper); } @@ -202,19 +202,19 @@ std::shared_ptr DataShareHelper::Creator( const std::shared_ptr &context, const AAFwk::Want &want, const std::shared_ptr &uri) { - APP_LOGI("DataShareHelper::Creator with runtime context, want and uri called start."); + APP_LOGI("DataShareHelper::Creator with context uri called start."); if (context == nullptr) { - APP_LOGE("DataShareHelper::Creator failed, context == nullptr"); + APP_LOGE("DataShareHelper::Creator (context, uri) failed, context == nullptr"); return nullptr; } if (uri == nullptr) { - APP_LOGE("DataShareHelper::Creator failed, uri == nullptr"); + APP_LOGE("DataShareHelper::Creator (context, uri) failed, uri == nullptr"); return nullptr; } if (uri->GetScheme() != SCHEME_DATASHARE) { - APP_LOGE("DataShareHelper::Creator failed, the Scheme is not datashare, Scheme: %{public}s", + APP_LOGE("DataShareHelper::Creator (context, uri) failed, the Scheme is not datashare, Scheme: %{public}s", uri->GetScheme().c_str()); return nullptr; } @@ -234,11 +234,11 @@ std::shared_ptr DataShareHelper::Creator( DataShareHelper *ptrDataShareHelper = new (std::nothrow) DataShareHelper(context, want, uri, dataShareProxy); if (ptrDataShareHelper == nullptr) { - APP_LOGE("DataShareHelper::Creator failed, create DataShareHelper failed"); + APP_LOGE("DataShareHelper::Creator (context, uri) failed, create DataShareHelper failed"); return nullptr; } - APP_LOGI("DataShareHelper::Creator with runtime context, want and uri called end."); + APP_LOGI("DataShareHelper::Creator with context uri called end."); return std::shared_ptr(ptrDataShareHelper); } @@ -251,6 +251,7 @@ std::shared_ptr DataShareHelper::Creator( bool DataShareHelper::Release() { APP_LOGI("DataShareHelper::Release start."); + std::lock_guard guard(lock_); if (uri_ == nullptr) { APP_LOGE("DataShareHelper::Release failed, uri_ is nullptr"); return false; @@ -278,6 +279,7 @@ bool DataShareHelper::Release() std::vector DataShareHelper::GetFileTypes(Uri &uri, const std::string &mimeTypeFilter) { APP_LOGI("DataShareHelper::GetFileTypes start."); + std::lock_guard guard(lock_); std::vector matchedMIMEs; if (!CheckUriParam(uri)) { APP_LOGE("%{public}s called. CheckUriParam uri failed", __func__); @@ -294,8 +296,6 @@ std::vector DataShareHelper::GetFileTypes(Uri &uri, const std::stri if (isSystemCaller_ && dataShareProxy_) { AddDataShareDeathRecipient(dataShareProxy_->AsObject()); } - } else { - dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); } if (dataShareProxy_ == nullptr) { @@ -333,7 +333,8 @@ std::vector DataShareHelper::GetFileTypes(Uri &uri, const std::stri int DataShareHelper::OpenFile(Uri &uri, const std::string &mode) { APP_LOGI("DataShareHelper::OpenFile start."); - int fd = INVALID_VALUE; + std::lock_guard guard(lock_); + int fd = -1; if (!CheckUriParam(uri)) { APP_LOGE("%{public}s called. CheckUriParam uri failed", __func__); return fd; @@ -349,8 +350,6 @@ int DataShareHelper::OpenFile(Uri &uri, const std::string &mode) if (isSystemCaller_ && dataShareProxy_) { AddDataShareDeathRecipient(dataShareProxy_->AsObject()); } - } else { - dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); } if (dataShareProxy_ == nullptr) { @@ -388,7 +387,8 @@ int DataShareHelper::OpenFile(Uri &uri, const std::string &mode) int DataShareHelper::OpenRawFile(Uri &uri, const std::string &mode) { APP_LOGI("DataShareHelper::OpenRawFile start."); - int fd = INVALID_VALUE; + std::lock_guard guard(lock_); + int fd = -1; if (!CheckUriParam(uri)) { APP_LOGE("%{public}s called. CheckUriParam uri failed", __func__); return fd; @@ -404,8 +404,6 @@ int DataShareHelper::OpenRawFile(Uri &uri, const std::string &mode) if (isSystemCaller_ && dataShareProxy_) { AddDataShareDeathRecipient(dataShareProxy_->AsObject()); } - } else { - dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); } if (dataShareProxy_ == nullptr) { @@ -439,7 +437,8 @@ int DataShareHelper::OpenRawFile(Uri &uri, const std::string &mode) int DataShareHelper::Insert(Uri &uri, const NativeRdb::ValuesBucket &value) { APP_LOGI("DataShareHelper::Insert start."); - int index = INVALID_VALUE; + std::lock_guard guard(lock_); + int index = -1; if (!CheckUriParam(uri)) { APP_LOGE("%{public}s called. CheckUriParam uri failed", __func__); return index; @@ -455,8 +454,6 @@ int DataShareHelper::Insert(Uri &uri, const NativeRdb::ValuesBucket &value) if (isSystemCaller_ && dataShareProxy_) { AddDataShareDeathRecipient(dataShareProxy_->AsObject()); } - } else { - dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); } if (dataShareProxy_ == nullptr) { @@ -492,7 +489,8 @@ int DataShareHelper::Update( Uri &uri, const NativeRdb::ValuesBucket &value, const NativeRdb::DataAbilityPredicates &predicates) { APP_LOGI("DataShareHelper::Update start."); - int index = INVALID_VALUE; + std::lock_guard guard(lock_); + int index = -1; if (!CheckUriParam(uri)) { APP_LOGE("%{public}s called. CheckUriParam uri failed", __func__); return index; @@ -508,8 +506,6 @@ int DataShareHelper::Update( if (isSystemCaller_ && dataShareProxy_) { AddDataShareDeathRecipient(dataShareProxy_->AsObject()); } - } else { - dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); } if (dataShareProxy_ == nullptr) { @@ -543,7 +539,8 @@ int DataShareHelper::Update( int DataShareHelper::Delete(Uri &uri, const NativeRdb::DataAbilityPredicates &predicates) { APP_LOGI("DataShareHelper::Delete start."); - int index = INVALID_VALUE; + std::lock_guard guard(lock_); + int index = -1; if (!CheckUriParam(uri)) { APP_LOGE("%{public}s called. CheckUriParam uri failed", __func__); return index; @@ -559,8 +556,6 @@ int DataShareHelper::Delete(Uri &uri, const NativeRdb::DataAbilityPredicates &pr if (isSystemCaller_ && dataShareProxy_) { AddDataShareDeathRecipient(dataShareProxy_->AsObject()); } - } else { - dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); } if (dataShareProxy_ == nullptr) { @@ -596,6 +591,7 @@ std::shared_ptr DataShareHelper::Query( Uri &uri, std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates) { APP_LOGI("DataShareHelper::Query start."); + std::lock_guard guard(lock_); std::shared_ptr resultset = nullptr; if (!CheckUriParam(uri)) { @@ -613,8 +609,6 @@ std::shared_ptr DataShareHelper::Query( if (isSystemCaller_ && dataShareProxy_) { AddDataShareDeathRecipient(dataShareProxy_->AsObject()); } - } else { - dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); } if (dataShareProxy_ == nullptr) { @@ -648,6 +642,7 @@ std::shared_ptr DataShareHelper::Query( std::string DataShareHelper::GetType(Uri &uri) { APP_LOGI("DataShareHelper::GetType start."); + std::lock_guard guard(lock_); std::string type; if (!CheckUriParam(uri)) { APP_LOGE("%{public}s called. CheckUriParam uri failed", __func__); @@ -664,8 +659,6 @@ std::string DataShareHelper::GetType(Uri &uri) if (isSystemCaller_ && dataShareProxy_) { AddDataShareDeathRecipient(dataShareProxy_->AsObject()); } - } else { - dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); } if (dataShareProxy_ == nullptr) { @@ -699,7 +692,8 @@ std::string DataShareHelper::GetType(Uri &uri) int DataShareHelper::BatchInsert(Uri &uri, const std::vector &values) { APP_LOGI("DataShareHelper::BatchInsert start."); - int ret = INVALID_VALUE; + std::lock_guard guard(lock_); + int ret = -1; if (!CheckUriParam(uri)) { APP_LOGE("%{public}s called. CheckUriParam uri failed", __func__); return ret; @@ -715,8 +709,6 @@ int DataShareHelper::BatchInsert(Uri &uri, const std::vectorAsObject()); } - } else { - dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); } if (dataShareProxy_ == nullptr) { @@ -922,8 +914,6 @@ void DataShareHelper::NotifyChange(const Uri &uri) dataShareConnection_->ConnectDataShareExtAbility(want_, token_); } dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); - } else { - dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); } if (dataShareProxy_ == nullptr) { @@ -957,6 +947,7 @@ void DataShareHelper::NotifyChange(const Uri &uri) Uri DataShareHelper::NormalizeUri(Uri &uri) { APP_LOGI("DataShareHelper::NormalizeUri start."); + std::lock_guard guard(lock_); Uri urivalue(""); if (!CheckUriParam(uri)) { APP_LOGE("%{public}s called. CheckUriParam uri failed", __func__); @@ -973,8 +964,6 @@ Uri DataShareHelper::NormalizeUri(Uri &uri) if (isSystemCaller_ && dataShareProxy_) { AddDataShareDeathRecipient(dataShareProxy_->AsObject()); } - } else { - dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); } if (dataShareProxy_ == nullptr) { @@ -1010,6 +999,7 @@ Uri DataShareHelper::NormalizeUri(Uri &uri) Uri DataShareHelper::DenormalizeUri(Uri &uri) { APP_LOGI("DataShareHelper::DenormalizeUri start."); + std::lock_guard guard(lock_); Uri urivalue(""); if (!CheckUriParam(uri)) { APP_LOGE("%{public}s called. CheckUriParam uri failed", __func__); @@ -1026,8 +1016,6 @@ Uri DataShareHelper::DenormalizeUri(Uri &uri) if (isSystemCaller_ && dataShareProxy_) { AddDataShareDeathRecipient(dataShareProxy_->AsObject()); } - } else { - dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); } if (dataShareProxy_ == nullptr) { @@ -1085,8 +1073,6 @@ std::vector> DataShareHelper::ExecuteBatch( APP_LOGE("DataShareHelper::ExecuteBatch failed dataShareProxy_ == nullptr"); return results; } - } else { - dataShareProxy_ = dataShareConnection_->GetDataShareProxy(); } if (dataShareProxy_ == nullptr) { diff --git a/frameworks/kits/ability/native/src/distributed_ability_runtime/distributed_client.cpp b/frameworks/kits/ability/native/src/distributed_ability_runtime/distributed_client.cpp index 9255c711399..b7ef1ed1473 100644 --- a/frameworks/kits/ability/native/src/distributed_ability_runtime/distributed_client.cpp +++ b/frameworks/kits/ability/native/src/distributed_ability_runtime/distributed_client.cpp @@ -37,7 +37,7 @@ sptr DistributedClient::GetDmsProxy() } int32_t DistributedClient::StartRemoteAbility(const OHOS::AAFwk::Want& want, - int32_t callerUid, int32_t requestCode, uint32_t accessToken) + int32_t callerUid, int32_t requestCode) { HILOG_INFO("called"); sptr remote = GetDmsProxy(); @@ -51,13 +51,12 @@ int32_t DistributedClient::StartRemoteAbility(const OHOS::AAFwk::Want& want, PARCEL_WRITE_HELPER(data, Parcelable, &want); PARCEL_WRITE_HELPER(data, Int32, callerUid); PARCEL_WRITE_HELPER(data, Int32, requestCode); - PARCEL_WRITE_HELPER(data, Uint32, accessToken); MessageParcel reply; PARCEL_TRANSACT_SYNC_RET_INT(remote, START_REMOTE_ABILITY, data, reply); } -int32_t DistributedClient::ConnectRemoteAbility(const OHOS::AAFwk::Want& want, const sptr& connect, - int32_t callerUid, int32_t callerPid, uint32_t accessToken) +int32_t DistributedClient::ConnectRemoteAbility(const OHOS::AAFwk::Want& want, + const sptr& connect, int32_t callerUid, int32_t callerPid) { HILOG_INFO("called"); if (connect == nullptr) { @@ -78,7 +77,6 @@ int32_t DistributedClient::ConnectRemoteAbility(const OHOS::AAFwk::Want& want, c PARCEL_WRITE_HELPER(data, RemoteObject, connect); PARCEL_WRITE_HELPER(data, Int32, callerUid); PARCEL_WRITE_HELPER(data, Int32, callerPid); - PARCEL_WRITE_HELPER(data, Uint32, accessToken); MessageParcel reply; PARCEL_TRANSACT_SYNC_RET_INT(remote, CONNECT_REMOTE_ABILITY, data, reply); } @@ -132,7 +130,7 @@ int32_t DistributedClient::ContinueMission(const std::string& srcDeviceId, const } int32_t DistributedClient::StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId, int32_t callerUid, - int32_t status, uint32_t accessToken) + int32_t status) { HILOG_INFO("called"); sptr remote = GetDmsProxy(); @@ -148,7 +146,6 @@ int32_t DistributedClient::StartContinuation(const OHOS::AAFwk::Want& want, int3 PARCEL_WRITE_HELPER(data, Int32, missionId); PARCEL_WRITE_HELPER(data, Int32, callerUid); PARCEL_WRITE_HELPER(data, Int32, status); - PARCEL_WRITE_HELPER(data, Uint32, accessToken); MessageParcel reply; PARCEL_TRANSACT_SYNC_RET_INT(remote, START_CONTINUATION, data, reply); } diff --git a/frameworks/kits/ability/native/src/js_datashare_ext_ability.cpp b/frameworks/kits/ability/native/src/js_datashare_ext_ability.cpp index 58c8add6c89..dde8bac32b0 100644 --- a/frameworks/kits/ability/native/src/js_datashare_ext_ability.cpp +++ b/frameworks/kits/ability/native/src/js_datashare_ext_ability.cpp @@ -213,7 +213,7 @@ NativeValue* JsDataShareExtAbility::CallObjectMethod(const char* name, NativeVal return nullptr; } HILOG_INFO("JsDataShareExtAbility::CallFunction(%{public}s), success", name); - return handleScope.Escape(nativeEngine.CallFunction(value, method, argv, argc)); + return nativeEngine.CallFunction(value, method, argv, argc); } void JsDataShareExtAbility::GetSrcPath(std::string &srcPath) @@ -338,10 +338,6 @@ int JsDataShareExtAbility::Insert(const Uri &uri, const NativeRdb::ValuesBucket napi_value napiUri = nullptr; napi_create_string_utf8(env, uri.ToString().c_str(), NAPI_AUTO_LENGTH, &napiUri); napi_value napiValue = rdbValueBucketNewInstance_(env, const_cast(value)); - if (napiValue == nullptr) { - HILOG_ERROR("%{public}s failed to make new instance of rdbValueBucket.", __func__); - return ret; - } NativeValue* nativeUri = reinterpret_cast(napiUri); NativeValue* nativeValue = reinterpret_cast(napiValue); @@ -381,18 +377,10 @@ int JsDataShareExtAbility::Update(const Uri &uri, const NativeRdb::ValuesBucket napi_value napiUri = nullptr; napi_create_string_utf8(env, uri.ToString().c_str(), NAPI_AUTO_LENGTH, &napiUri); napi_value napiValue = rdbValueBucketNewInstance_(env, const_cast(value)); - if (napiValue == nullptr) { - HILOG_ERROR("%{public}s failed to make new instance of rdbValueBucket.", __func__); - return ret; - } OHOS::NativeRdb::DataAbilityPredicates* predicatesPtr = new OHOS::NativeRdb::DataAbilityPredicates(); *predicatesPtr = predicates; napi_value napiPredicates = dataAbilityPredicatesNewInstance_(env, predicatesPtr); - if (napiPredicates == nullptr) { - HILOG_ERROR("%{public}s failed to make new instance of dataAbilityPredicates.", __func__); - return ret; - } NativeValue* nativeUri = reinterpret_cast(napiUri); NativeValue* nativeValue = reinterpret_cast(napiValue); @@ -431,10 +419,6 @@ int JsDataShareExtAbility::Delete(const Uri &uri, const NativeRdb::DataAbilityPr OHOS::NativeRdb::DataAbilityPredicates* predicatesPtr = new OHOS::NativeRdb::DataAbilityPredicates(); *predicatesPtr = predicates; napi_value napiPredicates = dataAbilityPredicatesNewInstance_(env, predicatesPtr); - if (napiPredicates == nullptr) { - HILOG_ERROR("%{public}s failed to make new instance of dataAbilityPredicates.", __func__); - return ret; - } NativeValue* nativeUri = reinterpret_cast(napiUri); NativeValue* nativePredicates = reinterpret_cast(napiPredicates); @@ -487,10 +471,6 @@ std::shared_ptr JsDataShareExtAbility::Query(cons OHOS::NativeRdb::DataAbilityPredicates* predicatesPtr = new OHOS::NativeRdb::DataAbilityPredicates(); *predicatesPtr = predicates; napi_value napiPredicates = dataAbilityPredicatesNewInstance_(env, predicatesPtr); - if (napiPredicates == nullptr) { - HILOG_ERROR("%{public}s failed to make new instance of dataAbilityPredicates.", __func__); - return ret; - } NativeValue* nativeUri = reinterpret_cast(napiUri); NativeValue* nativeColumns = reinterpret_cast(napiColumns); @@ -502,11 +482,6 @@ std::shared_ptr JsDataShareExtAbility::Query(cons return ret; } - if (rdbResultSetProxyGetNativeObject_ == nullptr) { - HILOG_ERROR("%{public}s rdbResultSetProxyGetNativeObject_ is null.", __func__); - return ret; - } - auto nativeObject = rdbResultSetProxyGetNativeObject_(env, reinterpret_cast(nativeResult)); if (nativeObject == nullptr) { HILOG_ERROR("JsiPaEngine AbsSharedResultSet from JS to Native failed"); @@ -570,10 +545,6 @@ int JsDataShareExtAbility::BatchInsert(const Uri &uri, const std::vector(value)); - if (result == nullptr) { - HILOG_ERROR("%{public}s failed to make new instance of rdbValueBucket.", __func__); - return ret; - } napi_set_element(env, napiValues, index++, result); } @@ -670,13 +641,10 @@ std::vector> JsDataShareExtAbilit bool JsDataShareExtAbility::CheckCallingPermission(const std::string &permission) { - HILOG_INFO("%{public}s begin, permission:%{public}s", __func__, permission.c_str()); if (!permission.empty() && AccessTokenKit::VerifyAccessToken(IPCSkeleton::GetCallingTokenID(), permission) != AppExecFwk::Constants::PERMISSION_GRANTED) { - HILOG_ERROR("%{public}s permission not granted.", __func__); return false; } - HILOG_INFO("%{public}s end.", __func__); return true; } } // namespace AbilityRuntime diff --git a/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_client.h b/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_client.h index c5d85822a23..3c1fda6d1d2 100755 --- a/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_client.h +++ b/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_client.h @@ -125,9 +125,9 @@ public: { return std::vector>(); }; - virtual void NotifyContinuationResult(int32_t result) {}; + virtual void NotifyContinuationResult(const int32_t result) {}; virtual void ContinueAbility(const std::string& deviceId) {}; - virtual void DumpAbilityInfo(const std::vector ¶ms, std::vector &info) {}; + virtual void DumpAbilityInfo(std::vector &info) {}; virtual sptr CallRequest() { return sptr(nullptr); @@ -135,4 +135,4 @@ public: }; } // namespace AppExecFwk } // namespace OHOS -#endif // FOUNDATION_APPEXECFWK_OHOS_ABILITY_NATIVE_MOCK_ABILITY_MANAGER_CLIENT_H +#endif // FOUNDATION_APPEXECFWK_OHOS_ABILITY_NATIVE_MOCK_ABILITY_MANAGER_CLIENT_H \ No newline at end of file diff --git a/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_service.h b/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_service.h index 5b099201890..f828cef1da6 100644 --- a/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_service.h +++ b/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_service.h @@ -137,7 +137,7 @@ public: MOCK_METHOD1(GetPendinTerminateAbilityTestgRequestWant, void(int id)); MOCK_METHOD1(GetSystemMemoryAttr, void(AppExecFwk::SystemMemoryAttr &memoryInfo)); MOCK_METHOD3(StartContinuation, int(const Want &want, const sptr &abilityToken, int32_t status)); - MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); + MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, const int32_t result)); MOCK_METHOD5(ContinueMission, int(const std::string &srcDeviceId, const std::string &dstDeviceId, int32_t missionId, const sptr &callBack, AAFwk::WantParams &wantParams)); MOCK_METHOD2(ContinueAbility, int(const std::string &deviceId, int32_t missionId)); @@ -154,7 +154,6 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD2(SetMissionLabel, int(const sptr &token, const std::string &label)); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); - MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions &startOptions)); MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector &info)); MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector &info)); diff --git a/frameworks/kits/ability/native/test/mock/include/mock_ability_scheduler_for_observer.h b/frameworks/kits/ability/native/test/mock/include/mock_ability_scheduler_for_observer.h index b5c7d3e35c2..a638facadc4 100755 --- a/frameworks/kits/ability/native/test/mock/include/mock_ability_scheduler_for_observer.h +++ b/frameworks/kits/ability/native/test/mock/include/mock_ability_scheduler_for_observer.h @@ -58,9 +58,9 @@ public: MOCK_METHOD2(ScheduleUnregisterObserver, bool(const Uri &uri, const sptr &dataObserver)); MOCK_METHOD1(ScheduleNotifyChange, bool(const Uri &uri)); MOCK_METHOD1(ExecuteBatch, std::vector>(const std::vector> &operation)); - MOCK_METHOD1(NotifyContinuationResult, void(int32_t result)); + MOCK_METHOD1(NotifyContinuationResult, void(const int32_t result)); MOCK_METHOD1(ContinueAbility, void(const std::string& deviceId)); - MOCK_METHOD2(DumpAbilityInfo, void(const std::vector ¶ms, std::vector &info)); + MOCK_METHOD1(DumpAbilityInfo, void(std::vector &info)); virtual sptr CallRequest() { @@ -71,4 +71,4 @@ public: } // namespace AppExecFwk } // namespace OHOS -#endif /* OHOS_APPEXECFWK_MOCK_ABILITY_SCHEDULER_FOR_OBESERVER_H */ +#endif /* OHOS_APPEXECFWK_MOCK_ABILITY_SCHEDULER_FOR_OBESERVER_H */ \ No newline at end of file diff --git a/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager.cpp b/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager.cpp index cc5a68fc251..0716fe7de16 100644 --- a/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager.cpp +++ b/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager.cpp @@ -153,6 +153,11 @@ bool BundleMgrProxy::IsSafeMode() { return true; } +bool BundleMgrProxy::CleanBundleCacheFiles( + const std::string &bundleName, const sptr &cleanCacheCallback) +{ + return true; +} bool BundleMgrProxy::CleanBundleDataFiles(const std::string &bundleName, const int userId) { return true; @@ -178,10 +183,18 @@ bool BundleMgrProxy::IsApplicationEnabled(const std::string &bundleName) { return true; } +bool BundleMgrProxy::SetApplicationEnabled(const std::string &bundleName, bool isEnable) +{ + return true; +} bool BundleMgrProxy::IsAbilityEnabled(const AbilityInfo &abilityInfo) { return true; } +bool BundleMgrProxy::SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled) +{ + return true; +} std::string BundleMgrProxy::GetAbilityIcon(const std::string &bundleName, const std::string &className) { return ""; @@ -386,6 +399,11 @@ bool BundleMgrService::IsSafeMode() { return true; } +bool BundleMgrService::CleanBundleCacheFiles( + const std::string &bundleName, const sptr &cleanCacheCallback) +{ + return true; +} bool BundleMgrService::CleanBundleDataFiles(const std::string &bundleName, const int userId) { return true; @@ -411,10 +429,18 @@ bool BundleMgrService::IsApplicationEnabled(const std::string &bundleName) { return true; } +bool BundleMgrService::SetApplicationEnabled(const std::string &bundleName, bool isEnable) +{ + return true; +} bool BundleMgrService::IsAbilityEnabled(const AbilityInfo &abilityInfo) { return true; } +bool BundleMgrService::SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled) +{ + return true; +} std::string BundleMgrService::GetAbilityIcon(const std::string &bundleName, const std::string &className) { return ""; diff --git a/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager.h b/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager.h index aa70e0a2391..03c958a02c9 100644 --- a/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager.h +++ b/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager.h @@ -79,6 +79,8 @@ public: virtual bool HasSystemCapability(const std::string &capName) override; virtual bool GetSystemAvailableCapabilities(std::vector &systemCaps) override; virtual bool IsSafeMode() override; + virtual bool CleanBundleCacheFiles( + const std::string &bundleName, const sptr &cleanCacheCallback) override; virtual bool CleanBundleDataFiles(const std::string &bundleName, const int userId) override; virtual bool RegisterBundleStatusCallback(const sptr &bundleStatusCallback) override; virtual bool ClearBundleStatusCallback(const sptr &bundleStatusCallback) override; @@ -86,7 +88,9 @@ public: virtual bool DumpInfos( const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result) override; virtual bool IsApplicationEnabled(const std::string &bundleName) override; + virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) override; virtual bool IsAbilityEnabled(const AbilityInfo &abilityInfo) override; + virtual bool SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled) override; virtual std::string GetAbilityIcon(const std::string &bundleName, const std::string &className) override; virtual bool CanRequestPermission( const std::string &bundleName, const std::string &permissionName, const int userId) override; @@ -162,6 +166,8 @@ public: virtual bool HasSystemCapability(const std::string &capName) override; virtual bool GetSystemAvailableCapabilities(std::vector &systemCaps) override; virtual bool IsSafeMode() override; + virtual bool CleanBundleCacheFiles( + const std::string &bundleName, const sptr &cleanCacheCallback) override; virtual bool CleanBundleDataFiles(const std::string &bundleName, const int userId) override; virtual bool RegisterBundleStatusCallback(const sptr &bundleStatusCallback) override; virtual bool ClearBundleStatusCallback(const sptr &bundleStatusCallback) override; @@ -169,7 +175,9 @@ public: virtual bool DumpInfos( const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result) override; virtual bool IsApplicationEnabled(const std::string &bundleName) override; + virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) override; virtual bool IsAbilityEnabled(const AbilityInfo &abilityInfo) override; + virtual bool SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled) override; virtual std::string GetAbilityIcon(const std::string &bundleName, const std::string &className) override; virtual bool CanRequestPermission( const std::string &bundleName, const std::string &permissionName, const int userId) override; diff --git a/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager_form.h b/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager_form.h index 3ef1c1037f5..28704c66b9e 100644 --- a/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager_form.h +++ b/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager_form.h @@ -146,6 +146,12 @@ public: { return true; } + // clears cache data of a specified application. + virtual bool CleanBundleCacheFiles( + const std::string &bundleName, const sptr &cleanCacheCallback) override + { + return true; + } virtual bool CleanBundleDataFiles(const std::string &bundleName, const int userId) override { return true; @@ -209,6 +215,10 @@ public: { return true; } + virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) override + { + return true; + } virtual bool GetBundleInfo( const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId) override; @@ -239,6 +249,7 @@ public: bool(const std::string &bundleName, const std::string &permission, const int userId)); MOCK_METHOD2(GetNameForUid, bool(const int uid, std::string &name)); MOCK_METHOD2(GetBundlesForUid, bool(const int uid, std::vector &)); + MOCK_METHOD2(SetAbilityEnabled, bool(const AbilityInfo &, bool)); MOCK_METHOD1(IsAbilityEnabled, bool(const AbilityInfo &)); MOCK_METHOD2(GetAbilityIcon, std::string(const std::string &bundleName, const std::string &className)); MOCK_METHOD1(RegisterAllPermissionsChanged, bool(const sptr &callback)); @@ -333,6 +344,12 @@ public: { return true; }; + // clears cache data of a specified application. + virtual bool CleanBundleCacheFiles( + const std::string &bundleName, const sptr &cleanCacheCallback) override + { + return true; + }; virtual bool RegisterBundleStatusCallback(const sptr &bundleStatusCallback) override { @@ -372,6 +389,10 @@ public: return true; }; + virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) override + { + return true; + }; /** * @brief Obtains information about the shortcuts of the application. diff --git a/frameworks/kits/appkit/native/ability_runtime/form_extension_context.cpp b/frameworks/kits/appkit/native/ability_runtime/form_extension_context.cpp index 7e8e1ae7a34..c6f080e518b 100644 --- a/frameworks/kits/appkit/native/ability_runtime/form_extension_context.cpp +++ b/frameworks/kits/appkit/native/ability_runtime/form_extension_context.cpp @@ -55,7 +55,7 @@ ErrCode FormExtensionContext::StartAbility(const AAFwk::Want &want) const ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, token_, -1); HILOG_DEBUG("%{public}s. End calling StartAbility. ret=%{public}d", __func__, err); if (err != ERR_OK) { - HILOG_ERROR("FormExtensionContext::StartAbility is failed %{public}d", err); + HILOG_ERROR("ServiceContext::StartAbility is failed %{public}d", err); } return err; } @@ -66,7 +66,7 @@ ErrCode FormExtensionContext::StartAbility(const AAFwk::Want &want, const AAFwk: ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, startOptions, token_, -1); HILOG_DEBUG("%{public}s. End calling StartAbility. ret=%{public}d", __func__, err); if (err != ERR_OK) { - HILOG_ERROR("FormExtensionContext::StartAbility is failed %{public}d", err); + HILOG_ERROR("ServiceContext::StartAbility is failed %{public}d", err); } return err; } @@ -75,7 +75,7 @@ AppExecFwk::AbilityType FormExtensionContext::GetAbilityInfoType() const { std::shared_ptr info = GetAbilityInfo(); if (info == nullptr) { - HILOG_ERROR("FormExtensionContext::GetAbilityInfoType info == nullptr"); + HILOG_ERROR("ServiceContext::GetAbilityInfoType info == nullptr"); return AppExecFwk::AbilityType::UNKNOWN; } diff --git a/frameworks/kits/appkit/native/app/include/main_thread.h b/frameworks/kits/appkit/native/app/include/main_thread.h index 28e6e32b652..4520c6a637f 100644 --- a/frameworks/kits/appkit/native/app/include/main_thread.h +++ b/frameworks/kits/appkit/native/app/include/main_thread.h @@ -392,10 +392,8 @@ private: * * @brief Task in event handler timeout detected. * - * @param runner the runner belong to the mainthread. - * */ - void TaskTimeoutDetected(const std::shared_ptr& runner); + void TaskTimeoutDetected(); /** * diff --git a/frameworks/kits/appkit/native/app/src/main_thread.cpp b/frameworks/kits/appkit/native/app/src/main_thread.cpp index 9e9c7569465..868b04c2eb8 100644 --- a/frameworks/kits/appkit/native/app/src/main_thread.cpp +++ b/frameworks/kits/appkit/native/app/src/main_thread.cpp @@ -1294,7 +1294,7 @@ void MainThread::HandleConfigurationUpdated(const Configuration &config) APP_LOGI("MainThread::HandleConfigurationUpdated called end."); } -void MainThread::TaskTimeoutDetected(const std::shared_ptr &runner) +void MainThread::TaskTimeoutDetected() { BYTRACE_NAME(BYTRACE_TAG_APP, __PRETTY_FUNCTION__); APP_LOGI("MainThread::TaskTimeoutDetected called start."); @@ -1303,14 +1303,14 @@ void MainThread::TaskTimeoutDetected(const std::shared_ptr &runner) APP_LOGI("MainThread::TaskTimeoutDetected delivery timeout"); }; auto distributeTimeoutCallback = []() { - APP_LOGI("MainThread::TaskTimeoutDetected distribute timeout"); + APP_LOGI("MainThread::TaskTimeoutDetected delivery timeout"); }; - if (runner !=nullptr && mainHandler_ != nullptr) { - runner->SetDeliveryTimeout(DELIVERY_TIME); + if (mainHandler_ != nullptr) { + mainHandler_->SetDeliveryTimeout(DELIVERY_TIME); mainHandler_->SetDeliveryTimeoutCallback(deliveryTimeoutCallback); - runner->SetDistributeTimeout(DISTRIBUTE_TIME); + mainHandler_->SetDistributeTimeout(DISTRIBUTE_TIME); mainHandler_->SetDistributeTimeoutCallback(distributeTimeoutCallback); } APP_LOGI("MainThread::TaskTimeoutDetected called end."); @@ -1341,7 +1341,7 @@ void MainThread::Init(const std::shared_ptr &runner, const std::sha if (!watchDogHandler_->PostTask(taskWatchDog)) { APP_LOGE("MainThread::Init WatchDog postTask task failed"); } - TaskTimeoutDetected(runner); + TaskTimeoutDetected(); /* watchDogHandler_->Init(mainHandler_, watchDogHandler_); APP_LOGI("MainThread:Init before CreateRunner."); diff --git a/frameworks/kits/appkit/native/test/mock/include/mock_ability_manager_client_interface1.h b/frameworks/kits/appkit/native/test/mock/include/mock_ability_manager_client_interface1.h index a82f685e6a3..d1a6b166fa0 100644 --- a/frameworks/kits/appkit/native/test/mock/include/mock_ability_manager_client_interface1.h +++ b/frameworks/kits/appkit/native/test/mock/include/mock_ability_manager_client_interface1.h @@ -196,6 +196,11 @@ public: { return true; }; + virtual bool CleanBundleCacheFiles( + const std::string &bundleName, const sptr &cleanCacheCallback) + { + return true; + }; virtual bool CleanBundleDataFiles(const std::string &bundleName, const int userId = 0) { return true; @@ -221,10 +226,18 @@ public: { return true; }; + virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) + { + return true; + }; virtual bool IsAbilityEnabled(const AbilityInfo &abilityInfo) { return true; }; + virtual bool SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled) + { + return true; + }; virtual std::string GetAbilityIcon(const std::string &bundleName, const std::string &className) { return std::string(""); diff --git a/frameworks/kits/appkit/native/test/unittest/context_container_test.cpp b/frameworks/kits/appkit/native/test/unittest/context_container_test.cpp index a4b2e5a9028..c9a1cda312b 100644 --- a/frameworks/kits/appkit/native/test/unittest/context_container_test.cpp +++ b/frameworks/kits/appkit/native/test/unittest/context_container_test.cpp @@ -52,18 +52,18 @@ void ContextContainerTest::TearDownTestCase(void) void ContextContainerTest::SetUp(void) { + OHOS::sptr bundleObject = new (std::nothrow) BundleMgrService(); + + OHOS::DelayedSingleton::GetInstance()->RegisterSystemAbility( + OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID, bundleObject); OHOS::DelayedSingleton::GetInstance()->RegisterSystemAbility( - OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID, new BundleMgrService()); + OHOS::ABILITY_MGR_SERVICE_ID, bundleObject); context_ = std::make_shared(); contextDeal_ = std::make_shared(); } void ContextContainerTest::TearDown(void) -{ - OHOS::DelayedSingleton::DestroyInstance(); - context_ = nullptr; - contextDeal_ = nullptr; -} +{} /** * @tc.number: AppExecFwk_ContextContainer_GetBundleName_0100 diff --git a/frameworks/kits/appkit/test/Mock/include/mock_ability_mgr_service.h b/frameworks/kits/appkit/test/Mock/include/mock_ability_mgr_service.h index c776ffb53d1..f53ce738e03 100644 --- a/frameworks/kits/appkit/test/Mock/include/mock_ability_mgr_service.h +++ b/frameworks/kits/appkit/test/Mock/include/mock_ability_mgr_service.h @@ -73,7 +73,6 @@ public: MOCK_METHOD1(CleanMission, int(int32_t missionId)); MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); - MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions &startOptions)); MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector &info)); MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector &info)); @@ -109,6 +108,7 @@ private: bool DumpStateCalled_ = false; Semaphore sem_; }; + } // namespace AAFwk } // namespace OHOS #endif // FOUNDATION_APPEXECFWK_KITS_APPKIT_TEST_MOCK_ABILITY_MGR_SERVICE_H \ No newline at end of file diff --git a/frameworks/kits/appkit/test/Mock/include/mock_bundle_mgr_service.h b/frameworks/kits/appkit/test/Mock/include/mock_bundle_mgr_service.h index 3154fb4edce..f7a06c00d72 100644 --- a/frameworks/kits/appkit/test/Mock/include/mock_bundle_mgr_service.h +++ b/frameworks/kits/appkit/test/Mock/include/mock_bundle_mgr_service.h @@ -87,6 +87,8 @@ public: MOCK_METHOD1(HasSystemCapability, bool(const std::string &capName)); MOCK_METHOD1(GetSystemAvailableCapabilities, bool(std::vector &systemCaps)); MOCK_METHOD0(IsSafeMode, bool()); + MOCK_METHOD2(CleanBundleCacheFiles, + bool(const std::string &bundleName, const sptr &cleanCacheCallback)); MOCK_METHOD2(CleanBundleDataFiles, bool(const std::string &bundleName, const int userId)); MOCK_METHOD1(RegisterBundleStatusCallback, bool(const sptr &bundleStatusCallback)); MOCK_METHOD1(ClearBundleStatusCallback, bool(const sptr &bundleStatusCallback)); @@ -98,6 +100,7 @@ public: } MOCK_METHOD0(GetBundleInstaller, sptr()); MOCK_METHOD1(GetBundleInstaller, bool(const std::string &)); + MOCK_METHOD2(SetApplicationEnabled, bool(const std::string &, bool)); MOCK_METHOD1(IsApplicationEnabled, bool(const std::string &)); virtual bool CanRequestPermission( @@ -112,6 +115,7 @@ public: } MOCK_METHOD2(GetNameForUid, bool(const int uid, std::string &name)); MOCK_METHOD2(GetBundlesForUid, bool(const int uid, std::vector &)); + MOCK_METHOD2(SetAbilityEnabled, bool(const AbilityInfo &, bool)); MOCK_METHOD1(IsAbilityEnabled, bool(const AbilityInfo &)); MOCK_METHOD2(GetAbilityIcon, std::string(const std::string &bundleName, const std::string &className)); MOCK_METHOD1(RegisterAllPermissionsChanged, bool(const sptr &callback)); diff --git a/frameworks/kits/test/mock/AMS/mock_ability_manager_service.h b/frameworks/kits/test/mock/AMS/mock_ability_manager_service.h index d44cbd503d6..08e6ee1ace6 100644 --- a/frameworks/kits/test/mock/AMS/mock_ability_manager_service.h +++ b/frameworks/kits/test/mock/AMS/mock_ability_manager_service.h @@ -114,7 +114,7 @@ public: MOCK_METHOD1(SetMissionStackSetting, int(const StackSetting &stackSetting)); MOCK_METHOD1(GetPendinTerminateAbilityTestgRequestWant, void(int id)); MOCK_METHOD3(StartContinuation, int(const Want &want, const sptr &abilityToken, int32_t status)); - MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); + MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, const int32_t result)); MOCK_METHOD5(ContinueMission, int(const std::string &srcDeviceId, const std::string &dstDeviceId, int32_t missionId, const sptr &callBack, AAFwk::WantParams &wantParams)); MOCK_METHOD2(ContinueAbility, int(const std::string &deviceId, int32_t missionId)); @@ -130,7 +130,6 @@ public: MOCK_METHOD1(CleanMission, int(int32_t missionId)); MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); - MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions &startOptions)); MOCK_METHOD2(SetMissionLabel, int(const sptr &token, const std::string &label)); MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); diff --git a/frameworks/kits/test/mock/AMS/mock_serviceability_manager_service.h b/frameworks/kits/test/mock/AMS/mock_serviceability_manager_service.h index 32f421dde29..cca6d5b4c93 100644 --- a/frameworks/kits/test/mock/AMS/mock_serviceability_manager_service.h +++ b/frameworks/kits/test/mock/AMS/mock_serviceability_manager_service.h @@ -113,7 +113,7 @@ public: MOCK_METHOD1(GetPendinTerminateAbilityTestgRequestWant, void(int id)); MOCK_METHOD1(GetSystemMemoryAttr, void(AppExecFwk::SystemMemoryAttr &memoryInfo)); MOCK_METHOD3(StartContinuation, int(const Want &want, const sptr &abilityToken, int32_t status)); - MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); + MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, const int32_t result)); MOCK_METHOD5(ContinueMission, int(const std::string &srcDeviceId, const std::string &dstDeviceId, int32_t missionId, const sptr &callBack, AAFwk::WantParams &wantParams)); MOCK_METHOD2(ContinueAbility, int(const std::string &deviceId, int32_t missionId)); @@ -129,7 +129,6 @@ public: MOCK_METHOD1(CleanMission, int(int32_t missionId)); MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); - MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions &startOptions)); MOCK_METHOD2(SetMissionLabel, int(const sptr &token, const std::string &label)); MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); diff --git a/interfaces/innerkits/ability_manager/include/ability_manager_client.h b/interfaces/innerkits/ability_manager/include/ability_manager_client.h index a1276abb217..2fb59725614 100644 --- a/interfaces/innerkits/ability_manager/include/ability_manager_client.h +++ b/interfaces/innerkits/ability_manager/include/ability_manager_client.h @@ -609,13 +609,11 @@ public: /** * @brief Move a mission to front. * @param missionId Id of target mission. - * @param startOptions Special startOptions for target mission. * * @return Returns ERR_OK on success, others on failure. */ ErrCode MoveMissionToFront(int32_t missionId); - ErrCode MoveMissionToFront(int32_t missionId, const StartOptions &startOptions); - + /** * Start Ability, connect session with common ability. * @@ -751,16 +749,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ ErrCode DoAbilityBackground(const sptr &token, uint32_t flag); - - /** - * Set ability controller. - * - * @param abilityController, The ability controller. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest); - + private: static std::mutex mutex_; static std::shared_ptr instance_; diff --git a/interfaces/innerkits/ability_manager/include/ability_manager_interface.h b/interfaces/innerkits/ability_manager/include/ability_manager_interface.h index f38d68f96f9..b741244ada4 100644 --- a/interfaces/innerkits/ability_manager/include/ability_manager_interface.h +++ b/interfaces/innerkits/ability_manager/include/ability_manager_interface.h @@ -544,7 +544,7 @@ public: virtual void NotifyCompleteContinuation(const std::string &deviceId, int32_t sessionId, bool isSuccess) = 0; - virtual int NotifyContinuationResult(int32_t missionId, int32_t result) = 0; + virtual int NotifyContinuationResult(int32_t missionId, const int32_t result) = 0; virtual int LockMissionForCleanup(int32_t missionId) = 0; @@ -566,9 +566,7 @@ public: virtual int CleanAllMissions() = 0; virtual int MoveMissionToFront(int32_t missionId) = 0; - - virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) = 0; - + /** * Start Ability, connect session with common ability. * @@ -671,7 +669,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ virtual int DelegatorDoAbilityBackground(const sptr &token) = 0; - + /** * Calls this interface to move the ability to the foreground. * @@ -863,9 +861,6 @@ public: // ipc id for ability background (55) DO_ABILITY_BACKGROUND, - // ipc id for move mission to front by options (56) - MOVE_MISSION_TO_FRONT_BY_OPTIONS, - // ipc id 1001-2000 for DMS // ipc id for starting ability (1001) START_ABILITY = 1001, diff --git a/interfaces/innerkits/ability_manager/include/ability_scheduler_interface.h b/interfaces/innerkits/ability_manager/include/ability_scheduler_interface.h index c56581a4cf5..42db89b9854 100644 --- a/interfaces/innerkits/ability_manager/include/ability_scheduler_interface.h +++ b/interfaces/innerkits/ability_manager/include/ability_scheduler_interface.h @@ -273,9 +273,9 @@ public: virtual std::vector> ExecuteBatch( const std::vector> &operations) = 0; virtual void ContinueAbility(const std::string& deviceId) = 0; - virtual void NotifyContinuationResult(int32_t result) = 0; + virtual void NotifyContinuationResult(const int32_t result) = 0; - virtual void DumpAbilityInfo(const std::vector ¶ms, std::vector &info) = 0; + virtual void DumpAbilityInfo(std::vector& info) = 0; virtual sptr CallRequest() = 0; diff --git a/interfaces/innerkits/ability_manager/include/start_options.h b/interfaces/innerkits/ability_manager/include/start_options.h index ed8bc0f6e70..82fe7cd47f7 100644 --- a/interfaces/innerkits/ability_manager/include/start_options.h +++ b/interfaces/innerkits/ability_manager/include/start_options.h @@ -22,16 +22,11 @@ #include "parcel.h" namespace OHOS { namespace AAFwk { -class StartOptions final : public Parcelable, public std::enable_shared_from_this { +class StartOptions : public Parcelable { public: static const std::string STRING_DISPLAY_ID; const int32_t DEFAULT_DISPLAY_ID {0}; - StartOptions() = default; - ~StartOptions() = default; - StartOptions(const StartOptions &other); - StartOptions &operator=(const StartOptions &other); - bool ReadFromParcel(Parcel &parcel); virtual bool Marshalling(Parcel &parcel) const override; static StartOptions *Unmarshalling(Parcel &parcel); diff --git a/interfaces/kits/js/@ohos.ability.particleAbility.d.ts b/interfaces/kits/js/@ohos.ability.particleAbility.d.ts index a6db3d53a1c..44e794c32b5 100644 --- a/interfaces/kits/js/@ohos.ability.particleAbility.d.ts +++ b/interfaces/kits/js/@ohos.ability.particleAbility.d.ts @@ -16,7 +16,6 @@ import { AsyncCallback } from './basic'; import { StartAbilityParameter } from './ability/startAbilityParameter'; import { Want } from './ability/want'; import { ConnectOptions } from './ability/connectOptions'; -import { NotificationRequest } from './notification/notificationRequest'; /** * A Particle Ability represents an ability with service. @@ -61,30 +60,5 @@ declare namespace particleAbility { */ function disconnectAbility(connection: number, callback:AsyncCallback): void; function disconnectAbility(connection: number): Promise; - - /** - * Keep this Service ability in the background and display a notification bar. - * - * @since 7 - * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask - * @permission ohos.permission.KEEP_BACKGROUND_RUNNING - * @param id Identifies the notification bar information. - * @param request Indicates the notificationRequest instance containing information for displaying a notification bar. - * @FAModelOnly - * @deprecated - */ - function startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback): void; - function startBackgroundRunning(id: number, request: NotificationRequest): Promise; - - /** - * Cancel background running of this ability to free up system memory. - * - * @since 7 - * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask - * @FAModelOnly - * @deprecated - */ - function cancelBackgroundRunning(callback: AsyncCallback): void; - function cancelBackgroundRunning(): Promise; } export default particleAbility; \ No newline at end of file diff --git a/interfaces/kits/js/@ohos.application.DataShareExtAbility.d.ts b/interfaces/kits/js/@ohos.application.DataShareExtAbility.d.ts index 47018ace74d..4e9c950410b 100644 --- a/interfaces/kits/js/@ohos.application.DataShareExtAbility.d.ts +++ b/interfaces/kits/js/@ohos.application.DataShareExtAbility.d.ts @@ -22,16 +22,17 @@ import rdb from './@ohos.data.rdb'; /** * class of datashare extension ability. * - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Provider + * @since 8 + * @sysCap AAFwk + * @devices phone, tablet, tv, wearable, car * @systemapi hide for inner use. */ export default class DataShareExtAbility { /** * Indicates datashare extension ability context. * - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Provider + * @since 8 + * @sysCap AAFwk * @systemapi hide for inner use. */ context?: ExtensionContext; @@ -39,8 +40,9 @@ export default class DataShareExtAbility { /** * Called back when a datashare extension ability is started for initialization. * - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Provider + * @devices phone, tablet, tv, wearable, car + * @since 8 + * @sysCap AAFwk * @param want Indicates connection information about the datashare extension ability. * @systemapi hide for inner use. * @return - @@ -50,8 +52,9 @@ export default class DataShareExtAbility { /** * Obtains the MIME type of files. This method should be implemented by a data share. * - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Provider + * @devices phone, tablet, tv, wearable, car + * @since 8 + * @sysCap AAFwk * @param uri Indicates the path of the files to obtain. * @param mimeTypeFilter Indicates the MIME type of the files to obtain. This parameter cannot be set to {@code * null}. @@ -60,13 +63,14 @@ export default class DataShareExtAbility { *

3. "*/jpg": Obtains files whose subtype is JPG of any main type. * @return Returns the MIME type of the matched files; returns null if there is no type that matches the Data */ - getFileTypes?(uri: string, mimeTypeFilter: string): Array; + getFileTypes?(uri: string, mimeTypeFilter:string, callback: AsyncCallback>): void; /** * Opens a file. This method should be implemented by a data share. * - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Provider + * @devices phone, tablet, tv, wearable, car + * @since 8 + * @sysCap AAFwk * @param uri Indicates the path of the file to open. * @param mode Indicates the open mode, which can be "r" for read-only access, "w" for write-only access (erasing * whatever data is currently in the file), "wt" for write access that truncates any existing file, @@ -74,24 +78,26 @@ export default class DataShareExtAbility { * existing data, or "rwt" for read and write access that truncates any existing file. * @return Returns the file descriptor. */ - openFile?(uri: string, mode: string): number; + openFile?(uri: string, mode: string, callback: AsyncCallback): void; /** * Inserts a data record into the database. This method should be implemented by a data share. * - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Provider + * @devices phone, tablet, tv, wearable, car + * @since 8 + * @sysCap AAFwk * @param uri Indicates the position where the data is to insert. * @param valueBucket Indicates the data to insert. * @return Returns the index of the newly inserted data record. */ - insert?(uri: string, valueBucket: rdb.ValuesBucket): number; + insert?(uri: string, values: rdb.ValuesBucket, callback: AsyncCallback): void; /** * Updates one or more data records in the database. This method should be implemented by a data share. * - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Provider + * @devices phone, tablet, tv, wearable, car + * @since 8 + * @sysCap AAFwk * @param uri Indicates the database table storing the data to update. * @param valueBucket Indicates the data to update. This parameter can be null. * @param predicates Indicates filter criteria. If this parameter is null, all data records will be updated by @@ -99,25 +105,28 @@ export default class DataShareExtAbility { * @return Returns the number of data records updated. * @return - */ - update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates): number; + update?(uri: string, values: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, + callback: AsyncCallback): void; /** * Deletes one or more data records. This method should be implemented by a data share. * - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Provider + * @devices phone, tablet, tv, wearable, car + * @since 8 + * @sysCap AAFwk * @param uri Indicates the database table storing the data to delete. * @param predicates Indicates filter criteria. If this parameter is null, all data records will be deleted by * default. * @return Returns the number of data records deleted. */ - delete?(uri: string, predicates: dataAbility.DataAbilityPredicates): number; + delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; /** * Queries one or more data records in the database. This method should be implemented by a data share. * - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Provider + * @devices phone, tablet, tv, wearable, car + * @since 8 + * @sysCap AAFwk * @param uri Indicates the database table storing the data to query. * @param columns Indicates the columns to be queried, in array, for example, {"name","age"}. You should define * the processing logic when this parameter is null. @@ -125,54 +134,59 @@ export default class DataShareExtAbility { * default. * @return Returns the queried data. */ - query?(uri: string, columns: Array, predicates: dataAbility.DataAbilityPredicates): ResultSet; + query?(uri: string, columns: Array, predicates: dataAbility.DataAbilityPredicates, + callback: AsyncCallback): void; /** - * Obtains the MIME type matching the data specified by the URI of the data share. This method should be + * Obtains the MIME type matching the data specified by the uri of the data share. This method should be * implemented by a data share. * *

Data abilities supports general data types, including text, HTML, and JPEG.

* - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Provider + * @devices phone, tablet, tv, wearable, car + * @since 8 + * @sysCap AAFwk * @param uri Indicates the uri of the data. * @return Returns the MIME type that matches the data specified by {@code uri}. */ - getType?(uri: string): string; + getType?(uri: string, callback: AsyncCallback): void; /** * Inserts multiple data records into the database. This method should be implemented by a data share. * - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Provider + * @devices phone, tablet, tv, wearable, car + * @since 8 + * @sysCap AAFwk * @param uri Indicates the position where the data is to insert. * @param valueBuckets Indicates the data to insert. * @return Returns the number of data records inserted. */ - batchInsert?(uri: string, valueBuckets: Array): number; + batchInsert?(uri: string, values: Array, callback: AsyncCallback): void; /** - * Converts the given {@code uri} that refer to the data share into a normalized URI. A normalized URI can be + * Converts the given {@code uri} that refer to the data share into a normalized uri. A normalized uri can be * used across devices, persisted, backed up, and restored. It can refer to the same item in the data share * even if the context has changed. * - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Provider + * @devices phone, tablet, tv, wearable, car + * @since 8 + * @sysCap AAFwk * @param uri Indicates the uri to normalize. - * @return Returns the normalized uri if the data share supports URI normalization; + * @return Returns the normalized uri if the data share supports uri normalization; */ - normalizeUri?(uri: string): string; + normalizeUri?(uri: string, callback: AsyncCallback): void; /** * Converts the given normalized {@code uri} generated by {@link #normalizeUri(uri)} into a denormalized one. * The default implementation of this method returns the original uri passed to it. * - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Provider + * @devices phone, tablet, tv, wearable, car + * @since 8 + * @sysCap AAFwk * @param uri Indicates the uri to denormalize. * @return Returns the denormalized {@code uri} object if the denormalization is successful; returns the original * {@code uri} passed to this method if there is nothing to do; returns {@code null} if the data identified by * the original {@code uri} cannot be found in the current environment. */ - denormalizeUri?(uri: string): string; + denormalizeUri?(uri: string, callback: AsyncCallback): void; } \ No newline at end of file diff --git a/interfaces/kits/js/@ohos.data.dataShare.d.ts b/interfaces/kits/js/@ohos.data.dataShare.d.ts deleted file mode 100644 index 20cf3eb02d7..00000000000 --- a/interfaces/kits/js/@ohos.data.dataShare.d.ts +++ /dev/null @@ -1,213 +0,0 @@ -/* -* Copyright (c) 2021 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import { AsyncCallback, Callback } from './basic'; -import { Want } from './ability/want'; -import Context from './application/Context'; -import { ValuesBucket, ResultSet, DataSharePredicates } from './@ohos.data.rdb'; - -declare namespace dataShare { - /** - * Obtains the dataShareHelper. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param context Indicates the application context. - * @param want Indicates The element parameter of the service ability. - * @param uri Indicates the path of the file to open. - * @return Returns the dataShareHelper. - * @systemapi Hide this for inner system use - */ - function createDataShareHelper(context: Context, want: Want, uri: string): DataShareHelper; - - /** - * DataShareHelper - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @systemapi Hide this for inner system use - */ - interface DataShareHelper { - /** - * Opens a file in a specified remote path. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param uri Indicates the path of the file to open. - * @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access - * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing - * file, "wa" for write-only access to append to any existing data, "rw" for read and write access on - * any existing data, or "rwt" for read and write access that truncates any existing file. - * @param callback Indicates the callback when openfile success - * @systemapi Hide this for inner system use - */ - openFile(uri: string, mode: string, callback: AsyncCallback): void; - openFile(uri: string, mode: string): Promise; - - /** - * Registers an observer to observe data specified by the given uri. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param type dataChange. - * @param uri Indicates the path of the data to operate. - * @param callback Indicates the callback when dataChange. - * @systemapi Hide this for inner system use - */ - on(type: 'dataChange', uri: string, callback: AsyncCallback): void; - - /** - * Deregisters an observer used for monitoring data specified by the given uri. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param type dataChange. - * @param uri Indicates the path of the data to operate. - * @param callback Indicates the registered callback. - * @systemapi Hide this for inner system use - */ - off(type: 'dataChange', uri: string, callback?: AsyncCallback): void; - - /** - * Inserts a single data record into the database. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param uri Indicates the path of the data to operate. - * @param value Indicates the data record to insert. If this parameter is null, a blank row will be inserted. - * @return Returns the index of the inserted data record. - * @systemapi Hide this for inner system use - */ - insert(URI: string, values: ValuesBucket, callback: AsyncCallback): void; - insert(URI: string, values: ValuesBucket): Promise; - - /** - * Deletes one or more data records from the database. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param uri Indicates the path of the data to operate. - * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. - * @return Returns the number of data records deleted. - * @systemapi Hide this for inner system use - */ - delete(URI: string, predicates: DataSharePredicates, callback: AsyncCallback): void; - delete(URI: string, predicates: DataSharePredicates): Promise; - - /** - * Queries data in the database. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param uri Indicates the path of data to query. - * @param columns Indicates the columns to query. If this parameter is null, all columns are queried. - * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. - * @return Returns the query result. - * @systemapi Hide this for inner system use - */ - query(URI: string, columns: Array, predicates: DataSharePredicates, callback: AsyncCallback): void; - query(URI: string, columns: Array, predicates: DataSharePredicates): Promise; - - /** - * Updates data records in the database. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param uri Indicates the path of data to update. - * @param value Indicates the data to update. This parameter can be null. - * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. - * @return Returns the number of data records updated. - * @systemapi Hide this for inner system use - */ - update(URI: string, values: ValuesBucket, predicates: DataSharePredicates, callback: AsyncCallback): void; - update(URI: string, values: ValuesBucket, predicates: DataSharePredicates): Promise; - - /** - * Inserts multiple data records into the database. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param uri Indicates the path of the data to operate. - * @param values Indicates the data records to insert. - * @return Returns the number of data records inserted. - * @systemapi Hide this for inner system use - */ - batchInsert(URI: string, values: Array, callback: AsyncCallback): void; - batchInsert(URI: string, values: Array): Promise; - - /** - * Obtains the MIME type of the date specified by the given URI. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param uri Indicates the path of the data to operate. - * @return Returns the MIME type that matches the data specified by uri. - * @systemapi Hide this for inner system use - */ - getType(URI: string, callback: AsyncCallback): void; - getType(URI: string): Promise; - - /** - * Obtains the MIME types of files supported. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param uri Indicates the path of the files to obtain. - * @param mimeTypeFilter Indicates the MIME types of the files to obtain. This parameter cannot be null. - *

1. "*/*": Obtains all types supported by Data abilities. - *

2. "image/*": Obtains files whose main type is image of any subtype. - *

3. "*/jpg": Obtains files whose subtype is JPG of any main type. - * @return Returns the matched MIME types. If there is no match, {@code null} is returned. - * @systemapi Hide this for inner system use - */ - getFileTypes(uri: string, mimeTypeFilter:string, callback: AsyncCallback>): void; - getFileTypes(uri: string, mimeTypeFilter): Promise>; - - /** - * Converts the given {@code uri} that refers to the Data ability into a normalized {@link ohos.utils.net.Uri}. - * A normalized URI can be used across devices, persisted, backed up, and restored. - *

To transfer a normalized URI from another environment to the current environment, you should call this - * method again to re-normalize the URI for the current environment or call {@link #denormalizeUri(Uri)} - * to convert it to a denormalized URI that can be used only in the current environment. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param uri Indicates the {@link ohos.utils.net.Uri} object to normalize. - * @return Returns the normalized {@code Uri} object if the Data ability supports URI normalization; - * returns {@code null} otherwise. - * @throws DataShareRemoteException Throws this exception if the remote process exits. - * @throws NullPointerException Throws this exception if {@code uri} is null. - * @see #denormalizeUri - * @systemapi Hide this for inner system use - */ - normalizeUri(uri: string, callback: AsyncCallback): void; - normalizeUri(uri: string): Promise; - - /** - * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param uri Indicates the {@link ohos.utils.net.Uri} object to denormalize. - * @return Returns the denormalized {@code Uri} object if the denormalization is successful; returns the - * original {@code Uri} passed to this method if there is nothing to do; returns {@code null} if the data - * identified by the normalized {@code Uri} cannot be found in the current environment. - * @throws DataShareRemoteException Throws this exception if the remote process exits. - * @throws NullPointerException Throws this exception if {@code uri} is null. - * @see #normalizeUri - * @systemapi Hide this for inner system use - */ - denormalizeUri(uri: string, callback: AsyncCallback): void; - denormalizeUri(uri: string): Promise; - - /** - * Notifies the registered observers of a change to the data resource specified by Uri. - * @since 9 - * @sysCap SystemCapability.DistributedDataMgr.DataShare.Consumer - * @param uri Indicates the {@link ohos.utils.net.Uri} object to notifyChange. - * @systemapi Hide this for inner system use - */ - notifyChange(URI: string, callback: AsyncCallback): void; - notifyChange(URI: string): Promise; - } -} - -export default dataShare; diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index 35518604778..aff640ffd0f 100644 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -29,7 +29,6 @@ group("napi_packages") { "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/app/test_runner:testrunner_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/callee:callee_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/caller:caller_napi", - "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/dataShare:datashare", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/dataUriUtils:datauriutils", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/datashare_ext_ability:datashareextability_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/datashare_ext_ability_context:datashareextabilitycontext_napi", diff --git a/interfaces/kits/napi/aafwk/abilityManager/napi_ability_manager.cpp b/interfaces/kits/napi/aafwk/abilityManager/napi_ability_manager.cpp index 6f33960308b..6517c51b2c4 100644 --- a/interfaces/kits/napi/aafwk/abilityManager/napi_ability_manager.cpp +++ b/interfaces/kits/napi/aafwk/abilityManager/napi_ability_manager.cpp @@ -50,9 +50,6 @@ OHOS::sptr GetAppManagerInstance() napi_value ParseBundleName(napi_env env, std::string &bundleName, napi_value args) { - napi_valuetype valuetype = napi_valuetype::napi_null; - NAPI_CALL(env, napi_typeof(env, args, &valuetype)); - NAPI_ASSERT(env, valuetype == napi_string, "Wrong argument type. String expected."); char buf[NapiAbilityMgr::BUFFER_LENGTH_MAX] = {0}; size_t len = 0; napi_get_value_string_utf8(env, args, buf, NapiAbilityMgr::BUFFER_LENGTH_MAX, &len); @@ -1692,6 +1689,9 @@ napi_value NAPI_KillProcessesByBundleName(napi_env env, napi_callback_info info) HILOG_INFO("argc = [%{public}zu]", argc); std::string bundleName = ""; + napi_valuetype valuetype = napi_valuetype::napi_null; + NAPI_CALL(env, napi_typeof(env, argv[0], &valuetype)); + NAPI_ASSERT(env, valuetype == napi_string, "Wrong argument type. String expected."); ParseBundleName(env, bundleName, argv[0]); bool callBackMode = false; @@ -1813,6 +1813,9 @@ napi_value NAPI_ClearUpApplicationData(napi_env env, napi_callback_info info) HILOG_INFO("argc = [%{public}zu]", argc); std::string bundleName = ""; + napi_valuetype valuetype = napi_valuetype::napi_null; + NAPI_CALL(env, napi_typeof(env, argv[0], &valuetype)); + NAPI_ASSERT(env, valuetype == napi_string, "Wrong argument type. String expected."); ParseBundleName(env, bundleName, argv[0]); bool callBackMode = false; diff --git a/interfaces/kits/napi/aafwk/ability_context/ability_context.js b/interfaces/kits/napi/aafwk/ability_context/ability_context.js index 0be12bee92f..c053519cd7c 100755 --- a/interfaces/kits/napi/aafwk/ability_context/ability_context.js +++ b/interfaces/kits/napi/aafwk/ability_context/ability_context.js @@ -52,12 +52,12 @@ class AbilityContext extends Context { } } - startAbilityForResult(want, options, callback) { - return this.__context_impl__.startAbilityForResult(want, options, callback) + startAbilityForResult(want, callback) { + return this.__context_impl__.startAbilityForResult(want, callback) } - startAbilityForResultWithAccount(want, accountId, options, callback) { - return this.__context_impl__.startAbilityForResultWithAccount(want, accountId, options, callback) + startAbilityForResultWithAccount(want, accountId, callback) { + return this.__context_impl__.startAbilityForResultWithAccount(want, accountId, callback) } connectAbility(want, options) { diff --git a/interfaces/kits/napi/aafwk/app/app_manager/js_app_manager.cpp b/interfaces/kits/napi/aafwk/app/app_manager/js_app_manager.cpp index 9e864b0619a..66029a291d6 100644 --- a/interfaces/kits/napi/aafwk/app/app_manager/js_app_manager.cpp +++ b/interfaces/kits/napi/aafwk/app/app_manager/js_app_manager.cpp @@ -89,6 +89,18 @@ public: return (me != nullptr) ? me->OnKillProcessWithAccount(*engine, *info) : nullptr; } + static NativeValue* KillProcessesByBundleName(NativeEngine* engine, NativeCallbackInfo* info) + { + JsAppManager* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnkillProcess(*engine, *info) : nullptr; + } + + static NativeValue* ClearUpApplicationData(NativeEngine* engine, NativeCallbackInfo* info) + { + JsAppManager* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnClearUpApplicationData(*engine, *info) : nullptr; + } + private: sptr appManager_ = nullptr; sptr abilityManager_ = nullptr; @@ -270,6 +282,80 @@ private: return result; } + NativeValue* OnkillProcess(NativeEngine &engine, NativeCallbackInfo &info) + { + HILOG_INFO("%{public}s is called", __FUNCTION__); + if (info.argc == 0) { + HILOG_ERROR("Not enough params"); + return engine.CreateUndefined(); + } + + std::string bundleName; + if (!ConvertFromJsValue(engine, info.argv[0], bundleName)) { + HILOG_ERROR("get bundelName failed!"); + return engine.CreateUndefined(); + } + + HILOG_INFO("kill process [%{public}s]", bundleName.c_str()); + AsyncTask::CompleteCallback complete = [bundleName, abilityManager = abilityManager_](NativeEngine& engine, + AsyncTask& task, int32_t status) { + if (abilityManager == nullptr) { + HILOG_WARN("abilityManager nullptr"); + task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "abilityManager nullptr")); + return; + } + auto errcode = abilityManager->KillProcess(bundleName); + if (errcode == 0) { + task.Resolve(engine, engine.CreateUndefined()); + } else { + task.Reject(engine, CreateJsError(engine, errcode, "kill process failed.")); + } + }; + + NativeValue* lastParam = (info.argc == 1) ? nullptr : info.argv[1]; + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return result; + } + + NativeValue* OnClearUpApplicationData(NativeEngine &engine, NativeCallbackInfo &info) + { + HILOG_INFO("%{public}s is called", __FUNCTION__); + if (info.argc == 0) { + HILOG_ERROR("Not enough params"); + return engine.CreateUndefined(); + } + + std::string bundleName; + if (!ConvertFromJsValue(engine, info.argv[0], bundleName)) { + HILOG_ERROR("get bundelName failed!"); + return engine.CreateUndefined(); + } + + HILOG_INFO("kill process [%{public}s]", bundleName.c_str()); + AsyncTask::CompleteCallback complete = [bundleName, abilityManager = abilityManager_](NativeEngine& engine, + AsyncTask& task, int32_t status) { + if (abilityManager == nullptr) { + HILOG_WARN("abilityManager nullptr"); + task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "abilityManager nullptr")); + return; + } + auto errcode = abilityManager->ClearUpApplicationData(bundleName); + if (errcode == 0) { + task.Resolve(engine, engine.CreateUndefined()); + } else { + task.Reject(engine, CreateJsError(engine, errcode, "clear up application failed.")); + } + }; + + NativeValue* lastParam = (info.argc == 1) ? nullptr : info.argv[1]; + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return result; + } + NativeValue* OnKillProcessWithAccount(NativeEngine &engine, NativeCallbackInfo &info) { HILOG_INFO("%{public}s is called", __FUNCTION__); @@ -359,6 +445,10 @@ NativeValue* JsAppManagerInit(NativeEngine* engine, NativeValue* exportObj) JsAppManager::IsRunningInStabilityTest); BindNativeFunction(*engine, *object, "killProcessWithAccount", JsAppManager::KillProcessWithAccount); + BindNativeFunction(*engine, *object, "killProcessesByBundleName", + JsAppManager::KillProcessesByBundleName); + BindNativeFunction(*engine, *object, "clearUpApplicationData", + JsAppManager::ClearUpApplicationData); HILOG_INFO("JsAppManagerInit end"); return engine->CreateUndefined(); } diff --git a/interfaces/kits/napi/aafwk/dataShare/BUILD.gn b/interfaces/kits/napi/aafwk/dataShare/BUILD.gn deleted file mode 100644 index 2248e600e88..00000000000 --- a/interfaces/kits/napi/aafwk/dataShare/BUILD.gn +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") - -ohos_shared_library("datashare") { - include_dirs = [ - "//foundation/ace/napi/interfaces/kits", - "//third_party/node/src", - "//third_party/libuv/include", - "//foundation/aafwk/standard/frameworks/kits/ability/native/include", - "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/dataShare", - "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common", - "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_rdb/include", - "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/common/include", - "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_dataability/include", - "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_resultset/include", - ] - - sources = [ - "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/common/src/js_utils.cpp", - "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_dataability/src/napi_data_ability_predicates.cpp", - "//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_resultset/src/napi_result_set.cpp", - "napi_datashare_helper.cpp", - "native_datashare_module.cpp", - ] - - deps = [ - "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", - "//foundation/aafwk/standard/frameworks/kits/appkit:appkit_native", - "//foundation/aafwk/standard/interfaces/innerkits/base:base", - "//foundation/aafwk/standard/interfaces/innerkits/dataobs_manager:dataobs_manager", - "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common:napi_common", - "//foundation/ace/napi:ace_napi", - "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", - "//third_party/libuv:uv_static", - "//utils/native/base:utils", - ] - - external_deps = [ - "ability_base:want", - "ability_runtime:ability_manager", - "ability_runtime:app_manager", - "ability_runtime:napi_base_context", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", - "eventhandler:libeventhandler", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "native_appdatamgr:native_appdatafwk", - "native_appdatamgr:native_dataability", - "native_appdatamgr:native_rdb", - ] - - relative_install_dir = "module/data" - - subsystem_name = "aafwk" - part_name = "ability_runtime" -} diff --git a/interfaces/kits/napi/aafwk/dataShare/data_share_common.h b/interfaces/kits/napi/aafwk/dataShare/data_share_common.h deleted file mode 100644 index b462002faa4..00000000000 --- a/interfaces/kits/napi/aafwk/dataShare/data_share_common.h +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_APPEXECFWK_DATASHARE_COMMON_H -#define OHOS_APPEXECFWK_DATASHARE_COMMON_H -#include "ability.h" -#include "abs_shared_result_set.h" -#include "data_ability_predicates.h" -#include "napi/native_api.h" -#include "napi/native_common.h" -#include "napi/native_node_api.h" -#include "napi_common.h" -#include "napi_common_util.h" -#include "values_bucket.h" -#include "want.h" - -using Want = OHOS::AAFwk::Want; -using Ability = OHOS::AppExecFwk::Ability; -using AbilityStartSetting = OHOS::AppExecFwk::AbilityStartSetting; - -namespace OHOS { -namespace AppExecFwk { -struct CallAbilityParam { - Want want; - int requestCode = 0; - bool forResultOption = false; - std::shared_ptr setting = nullptr; -}; - -struct OnAbilityCallback { - int requestCode = 0; - int resultCode = 0; - Want resultData; - CallbackInfo cb; -}; - -struct ContinueAbilityOptionsInfo { - bool reversible = false; - std::string deviceId; -}; - -struct AsyncCallbackInfo { - CallbackInfo cbInfo; - napi_async_work asyncWork = nullptr; - napi_deferred deferred = nullptr; - Ability *ability = nullptr; - CallAbilityParam param; - CallbackInfo aceCallback; - bool native_result; - AbilityType abilityType = AbilityType::UNKNOWN; - int errCode = 0; - ContinueAbilityOptionsInfo optionInfo; -}; - -struct CBBase { - CallbackInfo cbInfo; - napi_async_work asyncWork; - napi_deferred deferred; - Ability *ability = nullptr; - AbilityType abilityType = AbilityType::UNKNOWN; - int errCode = 0; -}; - -struct AppInfo_ { - std::string name; - std::string description; - int32_t descriptionId = 0; - bool systemApp = false; - bool enabled = true; // no data - std::string label; - std::string labelId; - std::string icon; - std::string iconId; - std::string process; - int32_t supportedModes = 0; - std::vector moduleSourceDirs; - std::vector permissions; - std::vector moduleInfos; - std::string entryDir; -}; - -struct AppInfoCB { - CBBase cbBase; - AppInfo_ appInfo; -}; - -struct AppTypeCB { - CBBase cbBase; - std::string name; -}; - -struct AbilityInfo_ { - std::string bundleName; - std::string name; - std::string label; - std::string description; - std::string icon; - int32_t labelId; - int32_t descriptionId; - int32_t iconId; - std::string moduleName; - std::string process; - std::string targetAbility; // no data - int32_t backgroundModes; // no data - bool isVisible = true; - bool formEnabled = false; // no data - int32_t type = 0; - int32_t subType = 0; // no data - int32_t orientation = 0; - int32_t launchMode = 0; - std::vector permissions; - std::vector deviceTypes; - std::vector deviceCapabilities; - std::string readPermission; // no data - std::string writePermission; // no data - AppInfo_ appInfo; - int32_t formEntity; // no data - int32_t minFormHeight; // no data - int32_t defaultFormHeight; // no data - int32_t minFormWidth; // no data - int32_t defaultFormWidth; // no data - std::string uri; -}; -struct AbilityInfoCB { - CBBase cbBase; - AbilityInfo_ abilityInfo; -}; - -struct AbilityNameCB { - CBBase cbBase; - std::string name; -}; - -struct ProcessInfoCB { - CBBase cbBase; - pid_t pid = 0; - std::string processName; -}; - -struct ProcessNameCB { - CBBase cbBase; - std::string processName; -}; - -struct CallingBundleCB { - CBBase cbBase; - std::string callingBundleName; -}; - -struct GetOrCreateLocalDirCB { - CBBase cbBase; - std::string rootDir; -}; - -struct DatabaseDirCB { - CBBase cbBase; - std::string dataBaseDir; -}; - -struct PreferencesDirCB { - CBBase cbBase; - std::string preferencesDir; -}; - -struct ElementNameCB { - CBBase cbBase; - std::string deviceId; - std::string bundleName; - std::string abilityName; - std::string uri; - std::string shortName; -}; - -struct HapModuleInfo_ { - std::string name; - std::string description; - int32_t descriptionId = 0; // no data - std::string icon; - std::string label; - int32_t labelId = 0; // no data - int32_t iconId = 0; // no data - std::string backgroundImg; - int32_t supportedModes = 0; - std::vector reqCapabilities; - std::vector deviceTypes; - std::vector abilityInfos; - std::string moduleName; - std::string mainAbilityName; // no data - bool installationFree; // no data -}; - -struct HapModuleInfoCB { - CBBase cbBase; - HapModuleInfo_ hapModuleInfo; -}; - -struct DataShareHelperCB { - CBBase cbBase; - napi_ref uri = nullptr; - napi_value result = nullptr; -}; - -struct DSHelperInsertCB { - CBBase cbBase; - DataShareHelper *dataShareHelper = nullptr; - std::string uri; - NativeRdb::ValuesBucket valueBucket; - int result = 0; - int execResult; -}; - -class NAPIAbilityConnection; -struct AbilityConnectionCB { - napi_env env; - napi_ref callback[3] = {0}; // onConnect/onDisconnect/onFailed - int resultCode = 0; - ElementName elementName; - sptr connection; -}; -struct ConnectAbilityCB { - CBBase cbBase; - Want want; - sptr abilityConnection; - AbilityConnectionCB abilityConnectionCB; - int64_t id; - bool result; - int errCode = 0; -}; - -struct DSHelperNotifyChangeCB { - CBBase cbBase; - DataShareHelper *dataShareHelper = nullptr; - std::string uri; - int execResult; -}; - -class NAPIDataShareObserver; -struct DSHelperOnOffCB { - CBBase cbBase; - DataShareHelper *dataShareHelper = nullptr; - sptr observer; - std::string uri; - int result = 0; - std::vector NotifyList; - std::vector DestoryList; -}; - -struct ShowOnLockScreenCB { - CBBase cbBase; - bool isShow; -}; - -struct DSHelperGetTypeCB { - CBBase cbBase; - DataShareHelper *dataShareHelper = nullptr; - std::string uri; - std::string result = ""; - int execResult; -}; - -struct DSHelperGetFileTypesCB { - CBBase cbBase; - DataShareHelper *dataShareHelper = nullptr; - std::string uri; - std::string mimeTypeFilter; - std::vector result; - int execResult; -}; - -struct DSHelperNormalizeUriCB { - CBBase cbBase; - DataShareHelper *dataShareHelper = nullptr; - std::string uri; - std::string result = ""; - int execResult; -}; - -struct DSHelperDenormalizeUriCB { - CBBase cbBase; - DataShareHelper *dataShareHelper = nullptr; - std::string uri; - std::string result = ""; - int execResult; -}; - -struct DSHelperDeleteCB { - CBBase cbBase; - DataShareHelper *dataShareHelper = nullptr; - std::string uri; - NativeRdb::DataAbilityPredicates predicates; - int result = 0; - int execResult; -}; - -struct DSHelperQueryCB { - CBBase cbBase; - DataShareHelper *dataShareHelper = nullptr; - std::string uri; - std::vector columns; - NativeRdb::DataAbilityPredicates predicates; - std::shared_ptr result; - int execResult; -}; - -struct DSHelperUpdateCB { - CBBase cbBase; - DataShareHelper *dataShareHelper = nullptr; - std::string uri; - NativeRdb::ValuesBucket valueBucket; - NativeRdb::DataAbilityPredicates predicates; - int result = 0; - int execResult; -}; - -struct DSHelperBatchInsertCB { - CBBase cbBase; - DataShareHelper *dataShareHelper = nullptr; - std::string uri; - std::vector values; - int result = 0; - int execResult; -}; - -struct DSHelperOpenFileCB { - CBBase cbBase; - DataShareHelper *dataShareHelper = nullptr; - std::string uri; - std::string mode; - int result = 0; - int execResult; -}; - -struct DSHelperReleaseCB { - CBBase cbBase; - DataShareHelper *dataShareHelper = nullptr; - bool result = false; -}; - -struct DSHelperExecuteBatchCB { - CBBase cbBase; - std::string uri; - std::vector> operations; - DataShareHelper *dataShareHelper = nullptr; - std::vector> result; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif /* OHOS_APPEXECFWK_DATASHARE_COMMON_H */ diff --git a/interfaces/kits/napi/aafwk/dataShare/napi_datashare_helper.cpp b/interfaces/kits/napi/aafwk/dataShare/napi_datashare_helper.cpp deleted file mode 100644 index 98c264fbbfa..00000000000 --- a/interfaces/kits/napi/aafwk/dataShare/napi_datashare_helper.cpp +++ /dev/null @@ -1,3322 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "napi_datashare_helper.h" - -#include -#include -#include - -#include "datashare_helper.h" -#include "data_ability_observer_interface.h" -#include "uri.h" - -#include "data_ability_result.h" -#include "hilog_wrapper.h" -#include "message_parcel.h" -#include "napi_base_context.h" -#include "napi_data_ability_predicates.h" -#include "napi_rdb_predicates.h" -#include "napi_result_set.h" -#include "securec.h" - -using namespace OHOS::AAFwk; -using namespace OHOS::AppExecFwk; - -namespace OHOS { -namespace AppExecFwk { -namespace { -const std::string DATASHARE_CLASS_NAME = "DataShareHelper"; -constexpr int NO_ERROR = 0; -constexpr int INVALID_PARAMETER = -1; - -std::string NapiValueToStringUtf8(napi_env env, napi_value value) -{ - std::string result = ""; - return UnwrapStringFromJS(env, value, result); -} - -bool NapiValueToArrayStringUtf8(napi_env env, napi_value param, std::vector &result) -{ - return UnwrapArrayStringFromJS(env, param, result); -} -} - -std::list> g_dataShareHelperList; -static napi_ref g_constructorRef = nullptr; - -/** - * @brief acquireDataAbilityHelper processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param dataShareHelperCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value AcquireDataShareHelperWrap(napi_env env, napi_callback_info info, DataShareHelperCB *dataShareHelperCB) -{ - HILOG_INFO("%{public}s,called", __func__); - if (dataShareHelperCB == nullptr) { - HILOG_ERROR("%{public}s,dataShareHelperCB == nullptr", __func__); - return nullptr; - } - - size_t requireArgc = ARGS_THREE; - size_t argc = ARGS_THREE; - napi_value args[ARGS_THREE] = {nullptr}; - NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr)); - if (argc > requireArgc) { - HILOG_ERROR("%{public}s, Wrong argument count %{public}zu.", __func__, argc); - return nullptr; - } - - napi_value result = nullptr; - napi_value cons = nullptr; - if (napi_get_reference_value(env, g_constructorRef, &cons) != napi_ok) { - return nullptr; - } - NAPI_CALL(env, napi_new_instance(env, cons, ARGS_THREE, args, &result)); - - if (!IsTypeForNapiValue(env, result, napi_object)) { - HILOG_ERROR("%{public}s, IsTypeForNapiValue isn`t object", __func__); - return nullptr; - } - - if (IsTypeForNapiValue(env, result, napi_null)) { - HILOG_ERROR("%{public}s, IsTypeForNapiValue is null", __func__); - return nullptr; - } - - if (IsTypeForNapiValue(env, result, napi_undefined)) { - HILOG_ERROR("%{public}s, IsTypeForNapiValue is undefined", __func__); - return nullptr; - } - - delete dataShareHelperCB; - dataShareHelperCB = nullptr; - HILOG_INFO("%{public}s,end", __func__); - return result; -} - -/** - * @brief AcquireDataAbilityHelper. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_AcquireDataShareHelperCommon(napi_env env, napi_callback_info info, AbilityType abilityType) -{ - HILOG_INFO("%{public}s,called", __func__); - DataShareHelperCB *dataShareHelperCB = new (std::nothrow) DataShareHelperCB; - if (dataShareHelperCB == nullptr) { - HILOG_ERROR("%{public}s, dataShareHelperCB == nullptr", __func__); - return WrapVoidToJS(env); - } - - dataShareHelperCB->cbBase.cbInfo.env = env; - dataShareHelperCB->cbBase.errCode = NAPI_ERR_NO_ERROR; - dataShareHelperCB->cbBase.abilityType = abilityType; - napi_value ret = AcquireDataShareHelperWrap(env, info, dataShareHelperCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s, ret == nullptr", __func__); - if (dataShareHelperCB != nullptr) { - delete dataShareHelperCB; - dataShareHelperCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -/** - * @brief DataShareHelper NAPI method : CreateDataShareHelper. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_CreateDataShareHelper(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s, called", __func__); - return NAPI_AcquireDataShareHelperCommon(env, info, AbilityType::EXTENSION); -} - -/** - * @brief DataShareHelper NAPI module registration. - * - * @param env The environment that the Node-API call is invoked under. - * @param exports An empty object via the exports parameter as a convenience. - * - * @return The return value from Init is treated as the exports object for the module. - */ -napi_value DataShareHelperInit(napi_env env, napi_value exports) -{ - HILOG_INFO("%{public}s,called", __func__); - napi_property_descriptor properties[] = { - DECLARE_NAPI_FUNCTION("insert", NAPI_Insert), - DECLARE_NAPI_FUNCTION("notifyChange", NAPI_NotifyChange), - DECLARE_NAPI_FUNCTION("on", NAPI_Register), - DECLARE_NAPI_FUNCTION("off", NAPI_UnRegister), - DECLARE_NAPI_FUNCTION("delete", NAPI_Delete), - DECLARE_NAPI_FUNCTION("query", NAPI_Query), - DECLARE_NAPI_FUNCTION("update", NAPI_Update), - DECLARE_NAPI_FUNCTION("batchInsert", NAPI_BatchInsert), - DECLARE_NAPI_FUNCTION("openFile", NAPI_OpenFile), - DECLARE_NAPI_FUNCTION("getType", NAPI_GetType), - DECLARE_NAPI_FUNCTION("getFileTypes", NAPI_GetFileTypes), - DECLARE_NAPI_FUNCTION("normalizeUri", NAPI_NormalizeUri), - DECLARE_NAPI_FUNCTION("denormalizeUri", NAPI_DenormalizeUri), - DECLARE_NAPI_FUNCTION("release", NAPI_Release), - }; - - napi_value cons = nullptr; - NAPI_CALL(env, - napi_define_class(env, - DATASHARE_CLASS_NAME.c_str(), - NAPI_AUTO_LENGTH, - DataShareHelperConstructor, - nullptr, - sizeof(properties) / sizeof(*properties), - properties, - &cons)); - g_dataShareHelperList.clear(); - NAPI_CALL(env, napi_create_reference(env, cons, 1, &g_constructorRef)); - NAPI_CALL(env, napi_set_named_property(env, exports, DATASHARE_CLASS_NAME.c_str(), cons)); - - napi_property_descriptor export_properties[] = { - DECLARE_NAPI_FUNCTION("createDataShareHelper", NAPI_CreateDataShareHelper), - }; - NAPI_CALL(env, napi_define_properties(env, exports, sizeof(export_properties) / sizeof(export_properties[0]), - export_properties)); - return exports; -} - -napi_value DataShareHelperConstructor(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s, called", __func__); - size_t argc = ARGS_THREE; - napi_value argv[ARGS_THREE] = {nullptr}; - napi_value thisVar = nullptr; - NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr)); - NAPI_ASSERT(env, argc > 0, "Wrong number of arguments"); - AAFwk::Want want; - OHOS::AppExecFwk::UnwrapWant(env, argv[PARAM1], want); - std::string strUri = NapiValueToStringUtf8(env, argv[PARAM2]); - std::shared_ptr dataShareHelper = nullptr; - bool isStageMode = false; - napi_status status = AbilityRuntime::IsStageContext(env, argv[PARAM0], isStageMode); - if (status != napi_ok || !isStageMode) { - auto ability = OHOS::AbilityRuntime::GetCurrentAbility(env); - NAPI_ASSERT(env, ability != nullptr, "DataShareHelperConstructor: failed to get native ability"); - HILOG_INFO("FA Model: ability = %{public}p strUri = %{public}s", ability, strUri.c_str()); - dataShareHelper = DataShareHelper::Creator(ability->GetContext(), want, std::make_shared(strUri)); - } else { - auto context = OHOS::AbilityRuntime::GetStageModeContext(env, argv[PARAM0]); - NAPI_ASSERT(env, context != nullptr, "DataShareHelperConstructor: failed to get native context"); - HILOG_INFO("Stage Model: context = %{public}p strUri = %{public}s", context.get(), strUri.c_str()); - dataShareHelper = DataShareHelper::Creator(context, want, std::make_shared(strUri)); - } - NAPI_ASSERT(env, dataShareHelper != nullptr, "DataShareHelperConstructor: dataShareHelper is nullptr"); - g_dataShareHelperList.emplace_back(dataShareHelper); - napi_wrap(env, thisVar, dataShareHelper.get(), [](napi_env env, void *data, void *hint) { - DataShareHelper *objectInfo = static_cast(data); - auto helper = std::find_if(registerInstances_.begin(), registerInstances_.end(), - [&objectInfo](const DSHelperOnOffCB *helper) { return helper->dataShareHelper == objectInfo; }); - if (helper != registerInstances_.end()) { - HILOG_INFO("DataShareHelper finalize_cb find helper"); - (*helper)->dataShareHelper->Release(); - delete *helper; - registerInstances_.erase(helper); - } - g_dataShareHelperList.remove_if([objectInfo](const std::shared_ptr &dataShareHelper) { - return objectInfo == dataShareHelper.get(); - }); - }, nullptr, nullptr); - HILOG_INFO("%{public}s,called end", __func__); - return thisVar; -} - -/** - * @brief DataShareHelper NAPI method : insert. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_Insert(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s, called", __func__); - DSHelperInsertCB *insertCB = new (std::nothrow) DSHelperInsertCB; - if (insertCB == nullptr) { - HILOG_ERROR("%{public}s, insertCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - insertCB->cbBase.cbInfo.env = env; - insertCB->cbBase.asyncWork = nullptr; - insertCB->cbBase.deferred = nullptr; - insertCB->cbBase.ability = nullptr; - - napi_value ret = InsertWrap(env, info, insertCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s, ret == nullptr.", __func__); - if (insertCB != nullptr) { - delete insertCB; - insertCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,called end", __func__); - return ret; -} - -/** - * @brief Insert processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value InsertWrap(napi_env env, napi_callback_info info, DSHelperInsertCB *insertCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argcAsync = ARGS_THREE; - const size_t argcPromise = ARGS_TWO; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - napi_value thisVar = nullptr; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); - if (valuetype == napi_string) { - insertCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); - HILOG_INFO("%{public}s,uri=%{public}s", __func__, insertCB->uri.c_str()); - } else { - HILOG_ERROR("%{public}s, Wrong argument type.", __func__); - } - - insertCB->valueBucket.Clear(); - AnalysisValuesBucket(insertCB->valueBucket, env, args[PARAM1]); - - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - HILOG_INFO("%{public}s,DataShareHelper objectInfo = %{public}p", __func__, objectInfo); - insertCB->dataShareHelper = objectInfo; - - if (argcAsync > argcPromise) { - ret = InsertAsync(env, args, ARGS_TWO, insertCB); - } else { - ret = InsertPromise(env, insertCB); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -void AnalysisValuesBucket(NativeRdb::ValuesBucket &valuesBucket, const napi_env &env, const napi_value &arg) -{ - napi_value keys = 0; - napi_get_property_names(env, arg, &keys); - uint32_t arrLen = 0; - napi_status status = napi_get_array_length(env, keys, &arrLen); - if (status != napi_ok) { - HILOG_ERROR("ValuesBucket errr"); - return; - } - HILOG_INFO("ValuesBucket num:%{public}d ", arrLen); - for (size_t i = 0; i < arrLen; ++i) { - napi_value key = 0; - status = napi_get_element(env, keys, i, &key); - std::string keyStr = UnwrapStringFromJS(env, key); - napi_value value = 0; - napi_get_property(env, arg, key, &value); - - SetValuesBucketObject(valuesBucket, env, keyStr, value); - } -} - -void SetValuesBucketObject( - NativeRdb::ValuesBucket &valuesBucket, const napi_env &env, std::string keyStr, napi_value value) -{ - napi_valuetype valueType = napi_undefined; - napi_typeof(env, value, &valueType); - if (valueType == napi_string) { - std::string valueString = UnwrapStringFromJS(env, value); - HILOG_INFO("ValueObject type:%{public}d, key:%{public}s, value:%{public}s", - valueType, - keyStr.c_str(), - valueString.c_str()); - valuesBucket.PutString(keyStr, valueString); - } else if (valueType == napi_number) { - double valueNumber = 0; - napi_get_value_double(env, value, &valueNumber); - valuesBucket.PutDouble(keyStr, valueNumber); - HILOG_INFO( - "ValueObject type:%{public}d, key:%{public}s, value:%{public}lf", valueType, keyStr.c_str(), valueNumber); - } else if (valueType == napi_boolean) { - bool valueBool = false; - napi_get_value_bool(env, value, &valueBool); - HILOG_INFO( - "ValueObject type:%{public}d, key:%{public}s, value:%{public}d", valueType, keyStr.c_str(), valueBool); - valuesBucket.PutBool(keyStr, valueBool); - } else if (valueType == napi_null) { - valuesBucket.PutNull(keyStr); - HILOG_INFO("ValueObject type:%{public}d, key:%{public}s, value:null", valueType, keyStr.c_str()); - } else if (valueType == napi_object) { - HILOG_INFO("ValueObject type:%{public}d, key:%{public}s, value:Uint8Array", valueType, keyStr.c_str()); - valuesBucket.PutBlob(keyStr, ConvertU8Vector(env, value)); - } else { - HILOG_ERROR("valuesBucket error"); - } -} -napi_value InsertAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperInsertCB *insertCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || insertCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &insertCB->cbBase.cbInfo.callback)); - } - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - InsertExecuteCB, - InsertAsyncCompleteCB, - (void *)insertCB, - &insertCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, insertCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - HILOG_INFO("%{public}s, asyncCallback end", __func__); - return result; -} - -napi_value InsertPromise(napi_env env, DSHelperInsertCB *insertCB) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (insertCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - napi_deferred deferred; - napi_value promise = 0; - NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); - insertCB->cbBase.deferred = deferred; - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - InsertExecuteCB, - InsertPromiseCompleteCB, - (void *)insertCB, - &insertCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, insertCB->cbBase.asyncWork)); - HILOG_INFO("%{public}s, promise end", __func__); - return promise; -} - -void InsertExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_Insert, worker pool thread execute."); - DSHelperInsertCB *insertCB = static_cast(data); - if (insertCB->dataShareHelper != nullptr) { - insertCB->execResult = INVALID_PARAMETER; - if (!insertCB->uri.empty()) { - OHOS::Uri uri(insertCB->uri); - insertCB->result = insertCB->dataShareHelper->Insert(uri, insertCB->valueBucket); - insertCB->execResult = NO_ERROR; - } - } else { - HILOG_ERROR("NAPI_Insert, dataShareHelper == nullptr."); - } - HILOG_INFO("NAPI_Insert, worker pool thread execute end."); -} - -void InsertAsyncCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_Insert, main event thread complete."); - DSHelperInsertCB *insertCB = static_cast(data); - napi_value callback = nullptr; - napi_value undefined = nullptr; - napi_value result[ARGS_TWO] = {nullptr}; - napi_value callResult = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); - NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, insertCB->cbBase.cbInfo.callback, &callback)); - - result[PARAM0] = GetCallbackErrorValue(env, insertCB->execResult); - napi_create_int32(env, insertCB->result, &result[PARAM1]); - NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); - - if (insertCB->cbBase.cbInfo.callback != nullptr) { - NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, insertCB->cbBase.cbInfo.callback)); - } - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, insertCB->cbBase.asyncWork)); - delete insertCB; - insertCB = nullptr; - HILOG_INFO("NAPI_Insert, main event thread complete end."); -} - -void InsertPromiseCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_Insert, main event thread complete."); - DSHelperInsertCB *insertCB = static_cast(data); - napi_value result = nullptr; - napi_create_int32(env, insertCB->result, &result); - NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, insertCB->cbBase.deferred, result)); - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, insertCB->cbBase.asyncWork)); - delete insertCB; - insertCB = nullptr; - HILOG_INFO("NAPI_Insert, main event thread complete end."); -} - -/** - * @brief Parse the ValuesBucket parameters. - * - * @param param Indicates the want parameters saved the parse result. - * @param env The environment that the Node-API call is invoked under. - * @param args Indicates the arguments passed into the callback. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value UnwrapValuesBucket(std::string &value, napi_env env, napi_value args) -{ - HILOG_INFO("%{public}s,called", __func__); - napi_valuetype valueType = napi_undefined; - napi_typeof(env, args, &valueType); - if (valueType != napi_object) { - HILOG_ERROR("%{public}s, valueType != napi_object.", __func__); - return nullptr; - } - - std::string strValue = ""; - if (UnwrapStringByPropertyName(env, args, "value", strValue)) { - HILOG_INFO("%{public}s,strValue=%{public}s", __func__, strValue.c_str()); - value = strValue; - } else { - HILOG_ERROR("%{public}s, value == nullptr.", __func__); - return nullptr; - } - - napi_value result; - NAPI_CALL(env, napi_create_int32(env, 1, &result)); - HILOG_INFO("%{public}s,end", __func__); - return result; -} - -/** - * @brief DataShareHelper NAPI method : notifyChange. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_NotifyChange(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - DSHelperNotifyChangeCB *notifyChangeCB = new (std::nothrow) DSHelperNotifyChangeCB; - if (notifyChangeCB == nullptr) { - HILOG_ERROR("%{public}s, notifyChangeCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - notifyChangeCB->cbBase.cbInfo.env = env; - notifyChangeCB->cbBase.asyncWork = nullptr; - notifyChangeCB->cbBase.deferred = nullptr; - notifyChangeCB->cbBase.ability = nullptr; - - napi_value ret = NotifyChangeWrap(env, info, notifyChangeCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s, ret == nullptr.", __func__); - if (notifyChangeCB != nullptr) { - delete notifyChangeCB; - notifyChangeCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -/** - * @brief NotifyChange processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param notifyChangeCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value NotifyChangeWrap(napi_env env, napi_callback_info info, DSHelperNotifyChangeCB *notifyChangeCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argcAsync = ARGS_TWO; - const size_t argcPromise = ARGS_ONE; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - napi_value thisVar = nullptr; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); - if (valuetype == napi_string) { - notifyChangeCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); - HILOG_INFO("%{public}s,uri=%{public}s", __func__, notifyChangeCB->uri.c_str()); - } else { - HILOG_ERROR("%{public}s, Wrong argument type.", __func__); - } - - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - HILOG_INFO("DataShareHelper objectInfo = %{public}p", objectInfo); - notifyChangeCB->dataShareHelper = objectInfo; - - if (argcAsync > argcPromise) { - ret = NotifyChangeAsync(env, args, argcAsync, argcPromise, notifyChangeCB); - } else { - ret = NotifyChangePromise(env, notifyChangeCB); - } - return ret; -} - -napi_value NotifyChangeAsync( - napi_env env, napi_value *args, size_t argcAsync, const size_t argcPromise, DSHelperNotifyChangeCB *notifyChangeCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || notifyChangeCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argcPromise], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[argcPromise], 1, ¬ifyChangeCB->cbBase.cbInfo.callback)); - } - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - NotifyChangeExecuteCB, - NotifyChangeAsyncCompleteCB, - (void *)notifyChangeCB, - ¬ifyChangeCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, notifyChangeCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - return result; -} - -napi_value NotifyChangePromise(napi_env env, DSHelperNotifyChangeCB *notifyChangeCB) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (notifyChangeCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - napi_deferred deferred; - napi_value promise = 0; - NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); - notifyChangeCB->cbBase.deferred = deferred; - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - NotifyChangeExecuteCB, - NotifyChangePromiseCompleteCB, - (void *)notifyChangeCB, - ¬ifyChangeCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, notifyChangeCB->cbBase.asyncWork)); - return promise; -} - -void NotifyChangeExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_NotifyChange, worker pool thread execute."); - DSHelperNotifyChangeCB *notifyChangeCB = static_cast(data); - if (notifyChangeCB->dataShareHelper != nullptr) { - notifyChangeCB->execResult = INVALID_PARAMETER; - if (!notifyChangeCB->uri.empty()) { - OHOS::Uri uri(notifyChangeCB->uri); - notifyChangeCB->dataShareHelper->NotifyChange(uri); - notifyChangeCB->execResult = NO_ERROR; - } else { - HILOG_ERROR("%{public}s, notifyChangeCB uri is empty.", __func__); - } - } -} - -void NotifyChangeAsyncCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_NotifyChange, main event thread complete."); - DSHelperNotifyChangeCB *notifyChangeCB = static_cast(data); - napi_value callback = nullptr; - napi_value undefined = nullptr; - napi_value result[ARGS_TWO] = {nullptr}; - napi_value callResult = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); - NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, notifyChangeCB->cbBase.cbInfo.callback, &callback)); - - if (!IsTypeForNapiValue(env, callback, napi_function)) { - delete notifyChangeCB; - notifyChangeCB = nullptr; - HILOG_INFO("NAPI_NotifyChange, callback is invalid."); - return; - } - - result[PARAM0] = GetCallbackErrorValue(env, notifyChangeCB->execResult); - result[PARAM1] = WrapVoidToJS(env); - NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); - - if (notifyChangeCB->cbBase.cbInfo.callback != nullptr) { - NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, notifyChangeCB->cbBase.cbInfo.callback)); - } - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, notifyChangeCB->cbBase.asyncWork)); - delete notifyChangeCB; - notifyChangeCB = nullptr; -} - -void NotifyChangePromiseCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_NotifyChange, main event thread complete."); - DSHelperNotifyChangeCB *notifyChangeCB = static_cast(data); - napi_value result = nullptr; - napi_create_int32(env, 0, &result); - NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, notifyChangeCB->cbBase.deferred, result)); - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, notifyChangeCB->cbBase.asyncWork)); - delete notifyChangeCB; - notifyChangeCB = nullptr; -} - -/** - * @brief DataShareHelper NAPI method : on. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_Register(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - DSHelperOnOffCB *onCB = new (std::nothrow) DSHelperOnOffCB; - if (onCB == nullptr) { - HILOG_ERROR("%{public}s, onCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - onCB->cbBase.cbInfo.env = env; - onCB->cbBase.asyncWork = nullptr; - onCB->cbBase.deferred = nullptr; - onCB->cbBase.ability = nullptr; - - napi_value ret = RegisterWrap(env, info, onCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s, ret == nullptr.", __func__); - if (onCB != nullptr) { - delete onCB; - onCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,called end", __func__); - return ret; -} - -/** - * @brief On processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value RegisterWrap(napi_env env, napi_callback_info info, DSHelperOnOffCB *onCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argcAsync = ARGS_THREE; - const size_t argcPromise = ARGS_TWO; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - napi_value thisVar = nullptr; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - onCB->result = NO_ERROR; - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); - if (valuetype == napi_string) { - std::string type = NapiValueToStringUtf8(env, args[PARAM0]); - if (type == "dataChange") { - HILOG_INFO("%{public}s, Wrong type=%{public}s", __func__, type.c_str()); - } else { - HILOG_ERROR("%{public}s, Wrong argument type is %{public}s.", __func__, type.c_str()); - onCB->result = INVALID_PARAMETER; - } - } else { - HILOG_ERROR("%{public}s, Wrong argument type.", __func__); - onCB->result = INVALID_PARAMETER; - } - - NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetype)); - if (valuetype == napi_string) { - onCB->uri = NapiValueToStringUtf8(env, args[PARAM1]); - HILOG_INFO("%{public}s,uri=%{public}s", __func__, onCB->uri.c_str()); - } else { - HILOG_ERROR("%{public}s, Wrong argument type.", __func__); - onCB->result = INVALID_PARAMETER; - } - - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - HILOG_INFO("DataShareHelper objectInfo = %{public}p", objectInfo); - onCB->dataShareHelper = objectInfo; - - ret = RegisterAsync(env, args, argcAsync, argcPromise, onCB); - return ret; -} - -napi_value RegisterAsync( - napi_env env, napi_value *args, size_t argcAsync, const size_t argcPromise, DSHelperOnOffCB *onCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || onCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argcPromise], &valuetype)); - if (valuetype == napi_function) { - HILOG_INFO("valuetype is napi_function"); - NAPI_CALL(env, napi_create_reference(env, args[argcPromise], 1, &onCB->cbBase.cbInfo.callback)); - } else { - HILOG_INFO("not valuetype isn't napi_function"); - onCB->result = INVALID_PARAMETER; - } - - sptr observer(new (std::nothrow) NAPIDataShareObserver()); - observer->SetEnv(env); - observer->SetCallbackRef(onCB->cbBase.cbInfo.callback); - onCB->observer = observer; - - if (onCB->result == NO_ERROR) { - registerInstances_.emplace_back(onCB); - } - - NAPI_CALL(env, - napi_create_async_work( - env, - nullptr, - resourceName, - RegisterExecuteCB, - RegisterCompleteCB, - (void *)onCB, - &onCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, onCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - return result; -} - -void RegisterExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_Register, worker pool thread execute."); - DSHelperOnOffCB *onCB = static_cast(data); - if (onCB->dataShareHelper != nullptr) { - if (onCB->result != INVALID_PARAMETER && !onCB->uri.empty() && onCB->cbBase.cbInfo.callback != nullptr) { - OHOS::Uri uri(onCB->uri); - onCB->dataShareHelper->RegisterObserver(uri, onCB->observer); - } else { - HILOG_ERROR("%{public}s, dataShareHelper uri is empty or callback is nullptr.", __func__); - } - } -} - -void RegisterCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_Register, main event thread complete."); - DSHelperOnOffCB *onCB = static_cast(data); - if (onCB == nullptr) { - HILOG_ERROR("%{public}s, input params onCB is nullptr.", __func__); - return; - } - if (onCB->result == NO_ERROR) { - return; - } - HILOG_INFO("NAPI_Register, input params onCB is invalid params, will be release"); - onCB->observer->ReleaseJSCallback(); - delete onCB; - onCB = nullptr; - HILOG_INFO("NAPI_Register, main event thread complete over an release invalid onCB."); -} - -/** - * @brief DataShareHelper NAPI method : Off. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_UnRegister(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - DSHelperOnOffCB *offCB = new (std::nothrow) DSHelperOnOffCB; - if (offCB == nullptr) { - HILOG_ERROR("%{public}s, offCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - offCB->cbBase.cbInfo.env = env; - offCB->cbBase.asyncWork = nullptr; - offCB->cbBase.deferred = nullptr; - offCB->cbBase.ability = nullptr; - - napi_value ret = UnRegisterWrap(env, info, offCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s, ret == nullptr.", __func__); - if (offCB != nullptr) { - delete offCB; - offCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,called end", __func__); - return ret; -} - -/** - * @brief Off processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value UnRegisterWrap(napi_env env, napi_callback_info info, DSHelperOnOffCB *offCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argc = ARGS_THREE; - const size_t argcPromise = ARGS_TWO; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - napi_value thisVar = nullptr; - NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &thisVar, nullptr)); - NAPI_ASSERT(env, argc <= argCountWithAsync && argc <= ARGS_MAX_COUNT, "UnRegisterWrap: Wrong argument count"); - offCB->result = INVALID_PARAMETER; - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); - if (valuetype == napi_string) { - std::string type = NapiValueToStringUtf8(env, args[PARAM0]); - if (type == "dataChange") { - offCB->result = NO_ERROR; - } - } - offCB->uri = ""; - if (argc > ARGS_TWO) { - NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetype)); - if (valuetype == napi_string) { - offCB->uri = NapiValueToStringUtf8(env, args[PARAM1]); - } else { - offCB->result = INVALID_PARAMETER; - } - NAPI_CALL(env, napi_typeof(env, args[PARAM2], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[PARAM2], 1, &offCB->cbBase.cbInfo.callback)); - } else { - offCB->result = INVALID_PARAMETER; - } - } else { - NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetype)); - if (valuetype == napi_string) { - offCB->uri = NapiValueToStringUtf8(env, args[PARAM1]); - } else if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[PARAM1], 1, &offCB->cbBase.cbInfo.callback)); - } else { - offCB->result = INVALID_PARAMETER; - } - } - HILOG_INFO("%{public}s,uri=%{public}s", __func__, offCB->uri.c_str()); - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - offCB->dataShareHelper = objectInfo; - ret = UnRegisterAsync(env, args, argc, argcPromise, offCB); - return ret; -} - -napi_value UnRegisterAsync( - napi_env env, napi_value *args, size_t argc, const size_t argcPromise, DSHelperOnOffCB *offCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || offCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - if (offCB->result == NO_ERROR) { - FindRegisterObs(env, offCB); - } - - NAPI_CALL(env, - napi_create_async_work( - env, - nullptr, - resourceName, - UnRegisterExecuteCB, - UnRegisterCompleteCB, - (void *)offCB, - &offCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, offCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - return result; -} - -static void FindRegisterObsByCallBack(napi_env env, DSHelperOnOffCB *data) -{ - HILOG_INFO("NAPI_UnRegister, UnRegisterExecuteCB callback is not null."); - if (data == nullptr || data->dataShareHelper == nullptr) { - HILOG_ERROR("NAPI_UnRegister, param is null."); - return; - } - napi_value callbackA = 0; - napi_get_reference_value(data->cbBase.cbInfo.env, data->cbBase.cbInfo.callback, &callbackA); - std::string strUri = data->uri; - do { - auto helper = std::find_if( - registerInstances_.begin(), - registerInstances_.end(), - [callbackA, strUri](const DSHelperOnOffCB *helper) { - bool result = false; - if (helper == nullptr || helper->cbBase.cbInfo.callback == nullptr) { - HILOG_ERROR("%{public}s is nullptr", ((helper == nullptr) ? "helper" : "cbBase.cbInfo.callback")); - return result; - } - if (helper->uri != strUri) { - HILOG_ERROR("uri inconsistent, h=[%{public}s] u=[%{public}s]", helper->uri.c_str(), strUri.c_str()); - return result; - } - napi_value callbackB = 0; - napi_get_reference_value(helper->cbBase.cbInfo.env, helper->cbBase.cbInfo.callback, &callbackB); - auto ret = napi_strict_equals(helper->cbBase.cbInfo.env, callbackA, callbackB, &result); - HILOG_INFO("NAPI_UnRegister cb equals status=%{public}d result=%{public}d.", ret, result); - return result; - }); - if (helper != registerInstances_.end()) { - data->NotifyList.emplace_back(*helper); - registerInstances_.erase(helper); - HILOG_INFO("NAPI_UnRegister Instances erase size = %{public}zu", registerInstances_.size()); - } else { - HILOG_INFO("NAPI_UnRegister not match any callback. %{public}zu", registerInstances_.size()); - break; - } - } while (true); - HILOG_INFO("NAPI_UnRegister, UnRegisterExecuteCB FindRegisterObsByCallBack Called End."); -} - -void FindRegisterObs(napi_env env, DSHelperOnOffCB *data) -{ - HILOG_INFO("NAPI_UnRegister, FindRegisterObs main event thread execute."); - if (data == nullptr || data->dataShareHelper == nullptr) { - HILOG_ERROR("NAPI_UnRegister, param is null."); - return; - } - if (data->cbBase.cbInfo.callback != nullptr) { - HILOG_INFO("NAPI_UnRegister, UnRegisterExecuteCB callback is not null."); - FindRegisterObsByCallBack(env, data); - } else { - if (data->uri.empty()) { - HILOG_ERROR("NAPI_UnRegister, error: uri is empty."); - return; - } - - HILOG_INFO("NAPI_UnRegister, uri=%{public}s.", data->uri.c_str()); - std::string strUri = data->uri; - do { - auto helper = std::find_if(registerInstances_.begin(), registerInstances_.end(), - [strUri](const DSHelperOnOffCB *helper) { return helper->uri == strUri; }); - if (helper != registerInstances_.end()) { - OHOS::Uri uri((*helper)->uri); - data->NotifyList.emplace_back(*helper); - registerInstances_.erase(helper); - HILOG_INFO("NAPI_UnRegister Instances erase size = %{public}zu", registerInstances_.size()); - } else { - HILOG_INFO("NAPI_UnRegister not match any uri."); - break; - } - } while (true); - } - HILOG_INFO("NAPI_UnRegister, FindRegisterObs main event thread execute.end %{public}zu", data->NotifyList.size()); -} - -void UnRegisterExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_UnRegister, UnRegisterExecuteCB main event thread execute."); - DSHelperOnOffCB *offCB = static_cast(data); - if (offCB == nullptr || offCB->dataShareHelper == nullptr) { - HILOG_ERROR("NAPI_UnRegister, param is null."); - if (offCB != nullptr) { - delete offCB; - offCB = nullptr; - } - return; - } - HILOG_INFO("NAPI_UnRegister, offCB->DestoryList size is %{public}zu", offCB->NotifyList.size()); - for (auto &iter : offCB->NotifyList) { - if (iter != nullptr && iter->observer != nullptr) { - OHOS::Uri uri(iter->uri); - iter->dataShareHelper->UnregisterObserver(uri, iter->observer); - offCB->DestoryList.emplace_back(iter); - } - } - offCB->NotifyList.clear(); - HILOG_INFO("NAPI_UnRegister, UnRegisterExecuteCB main event thread execute. end"); -} - -void UnRegisterCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_UnRegister, main event thread complete."); - // cannot run it in executeCB, because need to use napi_strict_equals compare callbacks. - DSHelperOnOffCB *offCB = static_cast(data); - if (offCB == nullptr || offCB->dataShareHelper == nullptr) { - HILOG_ERROR("NAPI_UnRegister, param is null."); - if (offCB != nullptr) { - delete offCB; - offCB = nullptr; - } - return; - } - HILOG_INFO("NAPI_UnRegister, offCB->DestoryList size is %{public}zu", offCB->DestoryList.size()); - for (auto &iter : offCB->DestoryList) { - HILOG_INFO("NAPI_UnRegister ReleaseJSCallback. 1 ---"); - if (iter->observer != nullptr) { - if (iter->observer->GetWorkPre() == 1 && iter->observer->GetWorkRun() == 0) { - iter->observer->SetAssociatedObject(iter); - iter->observer->ChangeWorkInt(); - HILOG_INFO("NAPI_UnRegister ReleaseJSCallback. 3 ---"); - } else { - iter->observer->ReleaseJSCallback(); - delete iter; - iter = nullptr; - HILOG_INFO("NAPI_UnRegister ReleaseJSCallback. 4 ---"); - } - } - } - - offCB->DestoryList.clear(); - if (offCB != nullptr) { - delete offCB; - offCB = nullptr; - } - - HILOG_INFO("NAPI_UnRegister, main event thread complete. end"); -} - -void NAPIDataShareObserver::ReleaseJSCallback() -{ - if (ref_ == nullptr) { - HILOG_ERROR("NAPIDataShareObserver::ReleaseJSCallback, ref_ is null."); - return; - } - napi_delete_reference(env_, ref_); - HILOG_INFO("NAPIDataShareObserver::%{public}s, called. end", __func__); -} - -void NAPIDataShareObserver::SetAssociatedObject(DSHelperOnOffCB* object) -{ - onCB_ = object; - HILOG_INFO("NAPIDataShareObserver::%{public}s, called. end", __func__); -} - -void NAPIDataShareObserver::ChangeWorkPre() -{ - HILOG_INFO("NAPIDataShareObserver::%{public}s, called.", __func__); - std::lock_guard lock_l(mutex_); - workPre_ = 1; - HILOG_INFO("NAPIDataShareObserver::%{public}s, called. end %{public}d", __func__, workPre_); -} -void NAPIDataShareObserver::ChangeWorkRun() -{ - workRun_ = 1; - HILOG_INFO("NAPIDataShareObserver::%{public}s, called. end %{public}d", __func__, workRun_); -} -void NAPIDataShareObserver::ChangeWorkInt() -{ - intrust_ = 1; - HILOG_INFO("NAPIDataShareObserver::%{public}s, called. end %{public}d", __func__, intrust_); -} - -void NAPIDataShareObserver::ChangeWorkPreDone() -{ - HILOG_INFO("NAPIDataShareObserver::%{public}s, called.", __func__); - std::lock_guard lock_l(mutex_); - workPre_ = 0; - HILOG_INFO("NAPIDataShareObserver::%{public}s, called. end %{public}d", __func__, workPre_); -} - -void NAPIDataShareObserver::ChangeWorkRunDone() -{ - workRun_ = 0; - intrust_ = 0; - HILOG_INFO("NAPIDataShareObserver::%{public}s, called end %{public}d %{public}d", __func__, workRun_, intrust_); -} - -int NAPIDataShareObserver::GetWorkPre() -{ - HILOG_INFO("NAPIDataShareObserver::%{public}s, called.", __func__); - std::lock_guard lock_l(mutex_); - HILOG_INFO("NAPIDataShareObserver::%{public}s, called. end %{public}d", __func__, workPre_); - return workPre_; -} - -int NAPIDataShareObserver::GetWorkInt() -{ - HILOG_INFO("NAPIDataShareObserver::%{public}s, called. end %{public}d", __func__, intrust_); - return intrust_; -} - -int NAPIDataShareObserver::GetWorkRun() -{ - HILOG_INFO("NAPIDataShareObserver::%{public}s, called. %{public}d", __func__, workRun_); - return workRun_; -} - -const DSHelperOnOffCB* NAPIDataShareObserver::GetAssociatedObject(void) -{ - HILOG_INFO("NAPIDataShareObserver::%{public}s, called.", __func__); - return onCB_; -} - -void NAPIDataShareObserver::SetEnv(const napi_env &env) -{ - env_ = env; - HILOG_INFO("NAPIDataShareObserver::%{public}s, called. end", __func__); -} - -void NAPIDataShareObserver::SetCallbackRef(const napi_ref &ref) -{ - ref_ = ref; - HILOG_INFO("NAPIDataShareObserver::%{public}s, called. end", __func__); -} - -static void OnChangeJSThreadWorker(uv_work_t *work, int status) -{ - HILOG_INFO("OnChange, uv_queue_work"); - if (work == nullptr) { - HILOG_ERROR("OnChange, uv_queue_work input work is nullptr"); - return; - } - DSHelperOnOffCB *onCB = (DSHelperOnOffCB *)work->data; - NAPIDataShareObserver* obs = onCB->observer; - onCB->observer = nullptr; - if (obs != nullptr) { - obs->ChangeWorkRun(); - } - napi_value result[ARGS_TWO] = {0}; - result[PARAM0] = GetCallbackErrorValue(onCB->cbBase.cbInfo.env, NO_ERROR); - napi_value callback = 0; - napi_value undefined = 0; - napi_get_undefined(onCB->cbBase.cbInfo.env, &undefined); - napi_value callResult = 0; - napi_get_reference_value(onCB->cbBase.cbInfo.env, onCB->cbBase.cbInfo.callback, &callback); - napi_call_function(onCB->cbBase.cbInfo.env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult); - if (obs != nullptr) { - if (obs->GetWorkInt() == 1) { - obs->ReleaseJSCallback(); - const DSHelperOnOffCB* assicuated = obs->GetAssociatedObject(); - if (assicuated != nullptr) { - HILOG_INFO("OnChange, uv_queue_work ReleaseJSCallback Called"); - obs->SetAssociatedObject(nullptr); - delete assicuated; - assicuated = nullptr; - } - } else { - obs->ChangeWorkRunDone(); - obs->ChangeWorkPreDone(); - } - } - if (onCB != nullptr) { - delete onCB; - onCB = nullptr; - } - if (work != nullptr) { - delete work; - work = nullptr; - } - HILOG_INFO("OnChange, uv_queue_work. end"); -} - -void NAPIDataShareObserver::OnChange() -{ - if (ref_ == nullptr) { - HILOG_ERROR("%{public}s, OnChange ref is nullptr.", __func__); - return; - } - ChangeWorkPre(); - uv_loop_s *loop = nullptr; - napi_get_uv_event_loop(env_, &loop); - if (loop == nullptr) { - HILOG_ERROR("%{public}s, loop == nullptr.", __func__); - ChangeWorkPreDone(); - return; - } - uv_work_t *work = new uv_work_t; - if (work == nullptr) { - HILOG_ERROR("%{public}s, work==nullptr.", __func__); - ChangeWorkPreDone(); - return; - } - DSHelperOnOffCB *onCB = new (std::nothrow) DSHelperOnOffCB; - if (onCB == nullptr) { - HILOG_ERROR("%{public}s, onCB == nullptr.", __func__); - if (work != nullptr) { - delete work; - work = nullptr; - } - ChangeWorkPreDone(); - return; - } - onCB->cbBase.cbInfo.env = env_; - onCB->cbBase.cbInfo.callback = ref_; - onCB->observer = this; - work->data = (void *)onCB; - int rev = uv_queue_work( - loop, - work, - [](uv_work_t *work) {}, - OnChangeJSThreadWorker); - if (rev != 0) { - if (onCB != nullptr) { - delete onCB; - onCB = nullptr; - } - if (work != nullptr) { - delete work; - work = nullptr; - } - } - HILOG_INFO("%{public}s, called. end", __func__); -} - -napi_value NAPI_GetType(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - DSHelperGetTypeCB *gettypeCB = new (std::nothrow) DSHelperGetTypeCB; - if (gettypeCB == nullptr) { - HILOG_ERROR("%{public}s, gettypeCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - gettypeCB->cbBase.cbInfo.env = env; - gettypeCB->cbBase.asyncWork = nullptr; - gettypeCB->cbBase.deferred = nullptr; - gettypeCB->cbBase.ability = nullptr; - - napi_value ret = GetTypeWrap(env, info, gettypeCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s,ret == nullptr", __func__); - if (gettypeCB != nullptr) { - delete gettypeCB; - gettypeCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -napi_value GetTypeWrap(napi_env env, napi_callback_info info, DSHelperGetTypeCB *gettypeCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argcAsync = ARGS_TWO; - const size_t argcPromise = ARGS_ONE; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - napi_value thisVar = nullptr; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); - if (valuetype == napi_string) { - gettypeCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); - HILOG_INFO("%{public}s,uri=%{public}s", __func__, gettypeCB->uri.c_str()); - } else { - HILOG_ERROR("%{public}s, Wrong argument type.", __func__); - } - - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - HILOG_INFO("%{public}s,DataShareHelper objectInfo = %{public}p", __func__, objectInfo); - gettypeCB->dataShareHelper = objectInfo; - - if (argcAsync > argcPromise) { - ret = GetTypeAsync(env, args, ARGS_ONE, gettypeCB); - } else { - ret = GetTypePromise(env, gettypeCB); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -napi_value GetTypeAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperGetTypeCB *gettypeCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || gettypeCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &gettypeCB->cbBase.cbInfo.callback)); - } - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - GetTypeExecuteCB, - GetTypeAsyncCompleteCB, - (void *)gettypeCB, - &gettypeCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, gettypeCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - HILOG_INFO("%{public}s, asyncCallback end", __func__); - return result; -} - -napi_value GetTypePromise(napi_env env, DSHelperGetTypeCB *gettypeCB) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (gettypeCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - napi_deferred deferred; - napi_value promise = 0; - NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); - gettypeCB->cbBase.deferred = deferred; - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - GetTypeExecuteCB, - GetTypePromiseCompleteCB, - (void *)gettypeCB, - &gettypeCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, gettypeCB->cbBase.asyncWork)); - HILOG_INFO("%{public}s, promise end.", __func__); - return promise; -} - -void GetTypeExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_GetType, worker pool thread execute."); - DSHelperGetTypeCB *gettypeCB = static_cast(data); - if (gettypeCB->dataShareHelper != nullptr) { - gettypeCB->execResult = INVALID_PARAMETER; - if (!gettypeCB->uri.empty()) { - OHOS::Uri uri(gettypeCB->uri); - gettypeCB->result = gettypeCB->dataShareHelper->GetType(uri); - gettypeCB->execResult = NO_ERROR; - } else { - HILOG_ERROR("NAPI_GetType, dataShareHelper uri is empty."); - } - } else { - HILOG_ERROR("NAPI_GetType, dataShareHelper == nullptr."); - } - HILOG_INFO("NAPI_GetType, worker pool thread execute end."); -} - -void GetTypeAsyncCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_GetType, main event thread complete."); - DSHelperGetTypeCB *gettypeCB = static_cast(data); - napi_value callback = nullptr; - napi_value undefined = nullptr; - napi_value result[ARGS_TWO] = {nullptr}; - napi_value callResult = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); - NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, gettypeCB->cbBase.cbInfo.callback, &callback)); - - result[PARAM0] = GetCallbackErrorValue(env, gettypeCB->execResult); - napi_create_string_utf8(env, gettypeCB->result.c_str(), NAPI_AUTO_LENGTH, &result[PARAM1]); - - NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); - - if (gettypeCB->cbBase.cbInfo.callback != nullptr) { - NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, gettypeCB->cbBase.cbInfo.callback)); - } - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, gettypeCB->cbBase.asyncWork)); - delete gettypeCB; - gettypeCB = nullptr; - HILOG_INFO("NAPI_GetType, main event thread complete end."); -} - -void GetTypePromiseCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_GetType, main event thread complete."); - DSHelperGetTypeCB *gettypeCB = static_cast(data); - napi_value result = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, gettypeCB->result.c_str(), NAPI_AUTO_LENGTH, &result)); - NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, gettypeCB->cbBase.deferred, result)); - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, gettypeCB->cbBase.asyncWork)); - delete gettypeCB; - gettypeCB = nullptr; - HILOG_INFO("NAPI_GetType, main event thread complete end."); -} - -napi_value NAPI_GetFileTypes(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - DSHelperGetFileTypesCB *getfiletypesCB = new (std::nothrow) DSHelperGetFileTypesCB; - if (getfiletypesCB == nullptr) { - HILOG_ERROR("%{public}s, getfiletypesCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - getfiletypesCB->cbBase.cbInfo.env = env; - getfiletypesCB->cbBase.asyncWork = nullptr; - getfiletypesCB->cbBase.deferred = nullptr; - getfiletypesCB->cbBase.ability = nullptr; - - napi_value ret = GetFileTypesWrap(env, info, getfiletypesCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s,ret == nullptr", __func__); - if (getfiletypesCB != nullptr) { - delete getfiletypesCB; - getfiletypesCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -napi_value GetFileTypesWrap(napi_env env, napi_callback_info info, DSHelperGetFileTypesCB *getfiletypesCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argcAsync = ARGS_THREE; - const size_t argcPromise = ARGS_TWO; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - napi_value thisVar = nullptr; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); - if (valuetype == napi_string) { - getfiletypesCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); - HILOG_INFO("%{public}s,uri=%{public}s", __func__, getfiletypesCB->uri.c_str()); - } - - NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetype)); - if (valuetype == napi_string) { - getfiletypesCB->mimeTypeFilter = NapiValueToStringUtf8(env, args[PARAM1]); - HILOG_INFO("%{public}s,mimeTypeFilter=%{public}s", __func__, getfiletypesCB->mimeTypeFilter.c_str()); - } - - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - HILOG_INFO("%{public}s,DataShareHelper objectInfo = %{public}p", __func__, objectInfo); - getfiletypesCB->dataShareHelper = objectInfo; - - if (argcAsync > argcPromise) { - ret = GetFileTypesAsync(env, args, ARGS_TWO, getfiletypesCB); - } else { - ret = GetFileTypesPromise(env, getfiletypesCB); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} -napi_value GetFileTypesAsync( - napi_env env, napi_value *args, const size_t argCallback, DSHelperGetFileTypesCB *getfiletypesCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || getfiletypesCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &getfiletypesCB->cbBase.cbInfo.callback)); - } - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - GetFileTypesExecuteCB, - GetFileTypesAsyncCompleteCB, - (void *)getfiletypesCB, - &getfiletypesCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, getfiletypesCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - HILOG_INFO("%{public}s, asyncCallback end.", __func__); - return result; -} - -napi_value GetFileTypesPromise(napi_env env, DSHelperGetFileTypesCB *getfiletypesCB) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (getfiletypesCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - napi_deferred deferred; - napi_value promise = 0; - NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); - getfiletypesCB->cbBase.deferred = deferred; - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - GetFileTypesExecuteCB, - GetFileTypesPromiseCompleteCB, - (void *)getfiletypesCB, - &getfiletypesCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, getfiletypesCB->cbBase.asyncWork)); - HILOG_INFO("%{public}s, promise end.", __func__); - return promise; -} - -void GetFileTypesExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_GetFileTypes, worker pool thread execute."); - DSHelperGetFileTypesCB *getfiletypesCB = static_cast(data); - if (getfiletypesCB->dataShareHelper != nullptr) { - getfiletypesCB->execResult = INVALID_PARAMETER; - if (!getfiletypesCB->uri.empty()) { - OHOS::Uri uri(getfiletypesCB->uri); - HILOG_INFO("NAPI_GetFileTypes, uri:%{public}s", uri.ToString().c_str()); - HILOG_INFO("NAPI_GetFileTypes, mimeTypeFilter:%{public}s", getfiletypesCB->mimeTypeFilter.c_str()); - getfiletypesCB->result = getfiletypesCB->dataShareHelper->GetFileTypes( - uri, - getfiletypesCB->mimeTypeFilter); - getfiletypesCB->execResult = NO_ERROR; - } else { - HILOG_INFO("NAPI_GetFileTypes, dataShareHelper uri is empty."); - } - } else { - HILOG_INFO("NAPI_GetFileTypes, dataShareHelper == nullptr."); - } - HILOG_INFO("NAPI_GetFileTypes, worker pool thread execute end."); -} - -void GetFileTypesAsyncCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_GetFileTypes, main event thread complete."); - DSHelperGetFileTypesCB *getfiletypesCB = static_cast(data); - napi_value callback = nullptr; - napi_value undefined = nullptr; - napi_value result[ARGS_TWO] = {nullptr}; - napi_value callResult = nullptr; - - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); - NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, getfiletypesCB->cbBase.cbInfo.callback, &callback)); - - result[PARAM0] = GetCallbackErrorValue(env, getfiletypesCB->execResult); - result[PARAM1] = WrapGetFileTypesCB(env, *getfiletypesCB); - - NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); - - if (getfiletypesCB->cbBase.cbInfo.callback != nullptr) { - NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, getfiletypesCB->cbBase.cbInfo.callback)); - } - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, getfiletypesCB->cbBase.asyncWork)); - delete getfiletypesCB; - getfiletypesCB = nullptr; - HILOG_INFO("NAPI_GetFileTypes, main event thread complete end."); -} - -napi_value WrapGetFileTypesCB(napi_env env, const DSHelperGetFileTypesCB &getfiletypesCB) -{ - HILOG_INFO("WrapGetFileTypesCB, called."); - HILOG_INFO("NAPI_GetFileTypes, result.size:%{public}zu", getfiletypesCB.result.size()); - for (size_t i = 0; i < getfiletypesCB.result.size(); i++) { - HILOG_INFO("NAPI_GetFileTypes, result[%{public}zu]:%{public}s", i, getfiletypesCB.result.at(i).c_str()); - } - napi_value proValue = nullptr; - - napi_value jsArrayresult = nullptr; - NAPI_CALL(env, napi_create_array(env, &jsArrayresult)); - for (size_t i = 0; i < getfiletypesCB.result.size(); i++) { - proValue = nullptr; - NAPI_CALL(env, napi_create_string_utf8(env, getfiletypesCB.result.at(i).c_str(), NAPI_AUTO_LENGTH, &proValue)); - NAPI_CALL(env, napi_set_element(env, jsArrayresult, i, proValue)); - } - HILOG_INFO("WrapGetFileTypesCB, end."); - return jsArrayresult; -} - -void GetFileTypesPromiseCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_GetFileTypes, main event thread complete."); - DSHelperGetFileTypesCB *getfiletypesCB = static_cast(data); - napi_value result = nullptr; - - result = WrapGetFileTypesCB(env, *getfiletypesCB); - NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, getfiletypesCB->cbBase.deferred, result)); - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, getfiletypesCB->cbBase.asyncWork)); - delete getfiletypesCB; - getfiletypesCB = nullptr; - HILOG_INFO("NAPI_GetFileTypes, main event thread complete end."); -} - -napi_value NAPI_NormalizeUri(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - DSHelperNormalizeUriCB *normalizeuriCB = new (std::nothrow) DSHelperNormalizeUriCB; - if (normalizeuriCB == nullptr) { - HILOG_ERROR("%{public}s, normalizeuriCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - normalizeuriCB->cbBase.cbInfo.env = env; - normalizeuriCB->cbBase.asyncWork = nullptr; - normalizeuriCB->cbBase.deferred = nullptr; - normalizeuriCB->cbBase.ability = nullptr; - - napi_value ret = NormalizeUriWrap(env, info, normalizeuriCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s,ret == nullptr", __func__); - if (normalizeuriCB != nullptr) { - delete normalizeuriCB; - normalizeuriCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -napi_value NormalizeUriWrap(napi_env env, napi_callback_info info, DSHelperNormalizeUriCB *normalizeuriCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argcAsync = ARGS_TWO; - const size_t argcPromise = ARGS_ONE; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - napi_value thisVar = nullptr; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); - if (valuetype == napi_string) { - normalizeuriCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); - HILOG_INFO("%{public}s,uri=%{public}s", __func__, normalizeuriCB->uri.c_str()); - } - - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - HILOG_INFO("%{public}s,DataShareHelper objectInfo = %{public}p", __func__, objectInfo); - normalizeuriCB->dataShareHelper = objectInfo; - - if (argcAsync > argcPromise) { - ret = NormalizeUriAsync(env, args, ARGS_ONE, normalizeuriCB); - } else { - ret = NormalizeUriPromise(env, normalizeuriCB); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} -napi_value NormalizeUriAsync( - napi_env env, napi_value *args, const size_t argCallback, DSHelperNormalizeUriCB *normalizeuriCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || normalizeuriCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &normalizeuriCB->cbBase.cbInfo.callback)); - } - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - NormalizeUriExecuteCB, - NormalizeUriAsyncCompleteCB, - (void *)normalizeuriCB, - &normalizeuriCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, normalizeuriCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - HILOG_INFO("%{public}s, asyncCallback end.", __func__); - return result; -} - -napi_value NormalizeUriPromise(napi_env env, DSHelperNormalizeUriCB *normalizeuriCB) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (normalizeuriCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - napi_deferred deferred; - napi_value promise = 0; - NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); - normalizeuriCB->cbBase.deferred = deferred; - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - NormalizeUriExecuteCB, - NormalizeUriPromiseCompleteCB, - (void *)normalizeuriCB, - &normalizeuriCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, normalizeuriCB->cbBase.asyncWork)); - HILOG_INFO("%{public}s, promise end.", __func__); - return promise; -} - -void NormalizeUriExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_NormalizeUri, worker pool thread execute."); - DSHelperNormalizeUriCB *normalizeuriCB = static_cast(data); - Uri uriValue(normalizeuriCB->uri); - if (normalizeuriCB->dataShareHelper != nullptr) { - normalizeuriCB->execResult = INVALID_PARAMETER; - if (!normalizeuriCB->uri.empty()) { - OHOS::Uri uri(normalizeuriCB->uri); - uriValue = normalizeuriCB->dataShareHelper->NormalizeUri(uri); - normalizeuriCB->result = uriValue.ToString(); - normalizeuriCB->execResult = NO_ERROR; - } - } else { - HILOG_INFO("NAPI_NormalizeUri, dataShareHelper == nullptr"); - } - HILOG_INFO("NAPI_NormalizeUri, worker pool thread execute end."); -} - -void NormalizeUriAsyncCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_NormalizeUri, main event thread complete."); - DSHelperNormalizeUriCB *normalizeuriCB = static_cast(data); - napi_value callback = nullptr; - napi_value undefined = nullptr; - napi_value result[ARGS_TWO] = {nullptr}; - napi_value callResult = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); - NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, normalizeuriCB->cbBase.cbInfo.callback, &callback)); - - result[PARAM0] = GetCallbackErrorValue(env, normalizeuriCB->execResult); - NAPI_CALL_RETURN_VOID( - env, napi_create_string_utf8(env, normalizeuriCB->result.c_str(), NAPI_AUTO_LENGTH, &result[PARAM1])); - - NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); - - if (normalizeuriCB->cbBase.cbInfo.callback != nullptr) { - NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, normalizeuriCB->cbBase.cbInfo.callback)); - } - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, normalizeuriCB->cbBase.asyncWork)); - delete normalizeuriCB; - normalizeuriCB = nullptr; - HILOG_INFO("NAPI_NormalizeUri, main event thread complete end."); -} - -void NormalizeUriPromiseCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_NormalizeUri, main event thread complete."); - DSHelperNormalizeUriCB *normalizeuriCB = static_cast(data); - napi_value result = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, normalizeuriCB->result.c_str(), NAPI_AUTO_LENGTH, &result)); - NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, normalizeuriCB->cbBase.deferred, result)); - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, normalizeuriCB->cbBase.asyncWork)); - delete normalizeuriCB; - normalizeuriCB = nullptr; - HILOG_INFO("NAPI_NormalizeUri, main event thread complete end."); -} - -napi_value NAPI_DenormalizeUri(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - DSHelperDenormalizeUriCB *denormalizeuriCB = new (std::nothrow) DSHelperDenormalizeUriCB; - if (denormalizeuriCB == nullptr) { - HILOG_ERROR("%{public}s, denormalizeuriCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - denormalizeuriCB->cbBase.cbInfo.env = env; - denormalizeuriCB->cbBase.asyncWork = nullptr; - denormalizeuriCB->cbBase.deferred = nullptr; - denormalizeuriCB->cbBase.ability = nullptr; - - napi_value ret = DenormalizeUriWrap(env, info, denormalizeuriCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s,ret == nullptr", __func__); - if (denormalizeuriCB != nullptr) { - delete denormalizeuriCB; - denormalizeuriCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -napi_value DenormalizeUriWrap(napi_env env, napi_callback_info info, DSHelperDenormalizeUriCB *denormalizeuriCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argcAsync = ARGS_TWO; - const size_t argcPromise = ARGS_ONE; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - napi_value thisVar = nullptr; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); - if (valuetype == napi_string) { - denormalizeuriCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); - HILOG_INFO("%{public}s,uri=%{public}s", __func__, denormalizeuriCB->uri.c_str()); - } - - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - HILOG_INFO("%{public}s,DataShareHelper objectInfo = %{public}p", __func__, objectInfo); - denormalizeuriCB->dataShareHelper = objectInfo; - - if (argcAsync > argcPromise) { - ret = DenormalizeUriAsync(env, args, ARGS_ONE, denormalizeuriCB); - } else { - ret = DenormalizeUriPromise(env, denormalizeuriCB); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} -napi_value DenormalizeUriAsync( - napi_env env, napi_value *args, const size_t argCallback, DSHelperDenormalizeUriCB *denormalizeuriCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || denormalizeuriCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &denormalizeuriCB->cbBase.cbInfo.callback)); - } - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - DenormalizeUriExecuteCB, - DenormalizeUriAsyncCompleteCB, - (void *)denormalizeuriCB, - &denormalizeuriCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, denormalizeuriCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - HILOG_INFO("%{public}s, asyncCallback end.", __func__); - return result; -} - -napi_value DenormalizeUriPromise(napi_env env, DSHelperDenormalizeUriCB *denormalizeuriCB) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (denormalizeuriCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - napi_deferred deferred; - napi_value promise = 0; - NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); - denormalizeuriCB->cbBase.deferred = deferred; - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - DenormalizeUriExecuteCB, - DenormalizeUriPromiseCompleteCB, - (void *)denormalizeuriCB, - &denormalizeuriCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, denormalizeuriCB->cbBase.asyncWork)); - HILOG_INFO("%{public}s, promise end.", __func__); - return promise; -} - -void DenormalizeUriExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_DenormalizeUri, worker pool thread execute."); - DSHelperDenormalizeUriCB *denormalizeuriCB = static_cast(data); - Uri uriValue(denormalizeuriCB->uri); - if (denormalizeuriCB->dataShareHelper != nullptr) { - denormalizeuriCB->execResult = INVALID_PARAMETER; - if (!denormalizeuriCB->uri.empty()) { - OHOS::Uri uri(denormalizeuriCB->uri); - uriValue = denormalizeuriCB->dataShareHelper->DenormalizeUri(uri); - denormalizeuriCB->result = uriValue.ToString(); - denormalizeuriCB->execResult = NO_ERROR; - } else { - HILOG_ERROR("NAPI_DenormalizeUri, dataShareHelper uri is empty"); - } - } else { - HILOG_ERROR("NAPI_DenormalizeUri, dataShareHelper == nullptr"); - } - HILOG_INFO("NAPI_DenormalizeUri, worker pool thread execute end."); -} - -void DenormalizeUriAsyncCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_DenormalizeUri, main event thread complete."); - DSHelperDenormalizeUriCB *denormalizeuriCB = static_cast(data); - napi_value callback = nullptr; - napi_value undefined = nullptr; - napi_value result[ARGS_TWO] = {nullptr}; - napi_value callResult = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); - NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, denormalizeuriCB->cbBase.cbInfo.callback, &callback)); - - result[PARAM0] = GetCallbackErrorValue(env, denormalizeuriCB->execResult); - NAPI_CALL_RETURN_VOID( - env, napi_create_string_utf8(env, denormalizeuriCB->result.c_str(), NAPI_AUTO_LENGTH, &result[PARAM1])); - - NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); - - if (denormalizeuriCB->cbBase.cbInfo.callback != nullptr) { - NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, denormalizeuriCB->cbBase.cbInfo.callback)); - } - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, denormalizeuriCB->cbBase.asyncWork)); - delete denormalizeuriCB; - denormalizeuriCB = nullptr; - HILOG_INFO("NAPI_DenormalizeUri, main event thread complete end."); -} - -void DenormalizeUriPromiseCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_DenormalizeUri, main event thread complete."); - DSHelperDenormalizeUriCB *denormalizeuriCB = static_cast(data); - napi_value result = nullptr; - NAPI_CALL_RETURN_VOID( - env, napi_create_string_utf8(env, denormalizeuriCB->result.c_str(), NAPI_AUTO_LENGTH, &result)); - NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, denormalizeuriCB->cbBase.deferred, result)); - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, denormalizeuriCB->cbBase.asyncWork)); - delete denormalizeuriCB; - denormalizeuriCB = nullptr; - HILOG_INFO("NAPI_DenormalizeUri, main event thread complete end."); -} - -void UnwrapDataAbilityPredicates(NativeRdb::DataAbilityPredicates &predicates, napi_env env, napi_value value) -{ - auto tempPredicates = DataAbilityJsKit::DataAbilityPredicatesProxy::GetNativePredicates(env, value); - if (tempPredicates == nullptr) { - HILOG_ERROR("%{public}s, GetNativePredicates retval Marshalling failed.", __func__); - return; - } - predicates = *tempPredicates; -} - -/** - * @brief DataShareHelper NAPI method : insert. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_Delete(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - DSHelperDeleteCB *deleteCB = new (std::nothrow) DSHelperDeleteCB; - if (deleteCB == nullptr) { - HILOG_ERROR("%{public}s, deleteCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - deleteCB->cbBase.cbInfo.env = env; - deleteCB->cbBase.asyncWork = nullptr; - deleteCB->cbBase.deferred = nullptr; - deleteCB->cbBase.ability = nullptr; - - napi_value ret = DeleteWrap(env, info, deleteCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s,ret == nullptr", __func__); - if (deleteCB != nullptr) { - delete deleteCB; - deleteCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -/** - * @brief Insert processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value DeleteWrap(napi_env env, napi_callback_info info, DSHelperDeleteCB *deleteCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argcAsync = ARGS_THREE; - const size_t argcPromise = ARGS_TWO; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - napi_value thisVar = nullptr; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); - if (valuetype == napi_string) { - deleteCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); - HILOG_INFO("%{public}s,uri=%{public}s", __func__, deleteCB->uri.c_str()); - } - - UnwrapDataAbilityPredicates(deleteCB->predicates, env, args[PARAM1]); - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - HILOG_INFO("%{public}s,DataShareHelper objectInfo = %{public}p", __func__, objectInfo); - deleteCB->dataShareHelper = objectInfo; - - if (argcAsync > argcPromise) { - ret = DeleteAsync(env, args, ARGS_TWO, deleteCB); - } else { - ret = DeletePromise(env, deleteCB); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -napi_value DeleteAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperDeleteCB *deleteCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || deleteCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &deleteCB->cbBase.cbInfo.callback)); - } - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - DeleteExecuteCB, - DeleteAsyncCompleteCB, - (void *)deleteCB, - &deleteCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, deleteCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - HILOG_INFO("%{public}s, asyncCallback end.", __func__); - return result; -} - -napi_value DeletePromise(napi_env env, DSHelperDeleteCB *deleteCB) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (deleteCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - napi_deferred deferred; - napi_value promise = 0; - NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); - deleteCB->cbBase.deferred = deferred; - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - DeleteExecuteCB, - DeletePromiseCompleteCB, - (void *)deleteCB, - &deleteCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, deleteCB->cbBase.asyncWork)); - HILOG_INFO("%{public}s, promise end.", __func__); - return promise; -} - -void DeleteExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_Delete, worker pool thread execute."); - DSHelperDeleteCB *deleteCB = static_cast(data); - if (deleteCB->dataShareHelper != nullptr) { - deleteCB->execResult = INVALID_PARAMETER; - if (!deleteCB->uri.empty()) { - OHOS::Uri uri(deleteCB->uri); - deleteCB->result = deleteCB->dataShareHelper->Delete(uri, deleteCB->predicates); - deleteCB->execResult = NO_ERROR; - } else { - HILOG_ERROR("NAPI_Delete, dataShareHelper uri is empty"); - } - } else { - HILOG_ERROR("NAPI_Delete, dataShareHelper == nullptr"); - } - HILOG_INFO("NAPI_Delete, worker pool thread execute end."); -} - -void DeleteAsyncCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_Delete, main event thread complete."); - DSHelperDeleteCB *DeleteCB = static_cast(data); - napi_value callback = nullptr; - napi_value undefined = nullptr; - napi_value result[ARGS_TWO] = {nullptr}; - napi_value callResult = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); - NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, DeleteCB->cbBase.cbInfo.callback, &callback)); - - result[PARAM0] = GetCallbackErrorValue(env, DeleteCB->execResult); - napi_create_int32(env, DeleteCB->result, &result[PARAM1]); - NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); - - if (DeleteCB->cbBase.cbInfo.callback != nullptr) { - NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, DeleteCB->cbBase.cbInfo.callback)); - } - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, DeleteCB->cbBase.asyncWork)); - delete DeleteCB; - DeleteCB = nullptr; - HILOG_INFO("NAPI_Delete, main event thread complete end."); -} - -void DeletePromiseCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_Delete, main event thread complete."); - DSHelperDeleteCB *DeleteCB = static_cast(data); - napi_value result = nullptr; - napi_create_int32(env, DeleteCB->result, &result); - NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, DeleteCB->cbBase.deferred, result)); - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, DeleteCB->cbBase.asyncWork)); - delete DeleteCB; - DeleteCB = nullptr; - HILOG_INFO("NAPI_Delete, main event thread complete end."); -} - -/** - * @brief DataShareHelper NAPI method : insert. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_Update(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - DSHelperUpdateCB *updateCB = new (std::nothrow) DSHelperUpdateCB; - if (updateCB == nullptr) { - HILOG_ERROR("%{public}s, updateCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - updateCB->cbBase.cbInfo.env = env; - updateCB->cbBase.asyncWork = nullptr; - updateCB->cbBase.deferred = nullptr; - updateCB->cbBase.ability = nullptr; - - napi_value ret = UpdateWrap(env, info, updateCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s,ret == nullptr", __func__); - if (updateCB != nullptr) { - delete updateCB; - updateCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -/** - * @brief Insert processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value UpdateWrap(napi_env env, napi_callback_info info, DSHelperUpdateCB *updateCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argcAsync = ARGS_FOUR; - const size_t argcPromise = ARGS_THREE; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - napi_value thisVar = nullptr; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); - if (valuetype == napi_string) { - updateCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); - HILOG_INFO("%{public}s,uri=%{public}s", __func__, updateCB->uri.c_str()); - } - - updateCB->valueBucket.Clear(); - AnalysisValuesBucket(updateCB->valueBucket, env, args[PARAM1]); - UnwrapDataAbilityPredicates(updateCB->predicates, env, args[PARAM2]); - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - HILOG_INFO("%{public}s,DataShareHelper objectInfo = %{public}p", __func__, objectInfo); - updateCB->dataShareHelper = objectInfo; - - if (argcAsync > argcPromise) { - ret = UpdateAsync(env, args, ARGS_THREE, updateCB); - } else { - ret = UpdatePromise(env, updateCB); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -napi_value UpdateAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperUpdateCB *updateCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || updateCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &updateCB->cbBase.cbInfo.callback)); - } - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - UpdateExecuteCB, - UpdateAsyncCompleteCB, - (void *)updateCB, - &updateCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, updateCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - HILOG_INFO("%{public}s, asyncCallback end.", __func__); - return result; -} - -napi_value UpdatePromise(napi_env env, DSHelperUpdateCB *updateCB) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (updateCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - napi_deferred deferred; - napi_value promise = 0; - NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); - updateCB->cbBase.deferred = deferred; - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - UpdateExecuteCB, - UpdatePromiseCompleteCB, - (void *)updateCB, - &updateCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, updateCB->cbBase.asyncWork)); - HILOG_INFO("%{public}s, promise end.", __func__); - return promise; -} - -void UpdateExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_Update, worker pool thread execute."); - DSHelperUpdateCB *updateCB = static_cast(data); - if (updateCB->dataShareHelper != nullptr) { - updateCB->execResult = INVALID_PARAMETER; - if (!updateCB->uri.empty()) { - OHOS::Uri uri(updateCB->uri); - updateCB->result = updateCB->dataShareHelper->Update(uri, updateCB->valueBucket, updateCB->predicates); - updateCB->execResult = NO_ERROR; - } else { - HILOG_ERROR("NAPI_Update, dataShareHelper uri is empty"); - } - } else { - HILOG_ERROR("NAPI_Update, dataShareHelper == nullptr"); - } - HILOG_INFO("NAPI_Update, worker pool thread execute end."); -} - -void UpdateAsyncCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_Update, main event thread complete."); - DSHelperUpdateCB *updateCB = static_cast(data); - napi_value callback = nullptr; - napi_value undefined = nullptr; - napi_value result[ARGS_TWO] = {nullptr}; - napi_value callResult = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); - NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, updateCB->cbBase.cbInfo.callback, &callback)); - - result[PARAM0] = GetCallbackErrorValue(env, updateCB->execResult); - napi_create_int32(env, updateCB->result, &result[PARAM1]); - NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); - - if (updateCB->cbBase.cbInfo.callback != nullptr) { - NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, updateCB->cbBase.cbInfo.callback)); - } - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, updateCB->cbBase.asyncWork)); - delete updateCB; - updateCB = nullptr; - HILOG_INFO("NAPI_Update, main event thread complete end."); -} - -void UpdatePromiseCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_Update, main event thread complete."); - DSHelperUpdateCB *updateCB = static_cast(data); - napi_value result = nullptr; - napi_create_int32(env, updateCB->result, &result); - NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, updateCB->cbBase.deferred, result)); - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, updateCB->cbBase.asyncWork)); - delete updateCB; - updateCB = nullptr; - HILOG_INFO("NAPI_Update, main event thread complete end."); -} - -/** - * @brief DataShareHelper NAPI method : insert. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_OpenFile(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - DSHelperOpenFileCB *openFileCB = new (std::nothrow) DSHelperOpenFileCB; - if (openFileCB == nullptr) { - HILOG_ERROR("%{public}s, openFileCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - openFileCB->cbBase.cbInfo.env = env; - openFileCB->cbBase.asyncWork = nullptr; - openFileCB->cbBase.deferred = nullptr; - openFileCB->cbBase.ability = nullptr; - - napi_value ret = OpenFileWrap(env, info, openFileCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s,ret == nullptr", __func__); - if (openFileCB != nullptr) { - delete openFileCB; - openFileCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -/** - * @brief Insert processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value OpenFileWrap(napi_env env, napi_callback_info info, DSHelperOpenFileCB *openFileCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argcAsync = ARGS_THREE; - const size_t argcPromise = ARGS_TWO; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - napi_value thisVar = nullptr; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); - if (valuetype == napi_string) { - openFileCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); - HILOG_INFO("%{public}s,uri=%{public}s", __func__, openFileCB->uri.c_str()); - } - - NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetype)); - if (valuetype == napi_string) { - openFileCB->mode = NapiValueToStringUtf8(env, args[PARAM1]); - HILOG_INFO("%{public}s,mode=%{public}s", __func__, openFileCB->mode.c_str()); - } - - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - HILOG_INFO("%{public}s,DataShareHelper objectInfo = %{public}p", __func__, objectInfo); - openFileCB->dataShareHelper = objectInfo; - - if (argcAsync > argcPromise) { - ret = OpenFileAsync(env, args, ARGS_TWO, openFileCB); - } else { - ret = OpenFilePromise(env, openFileCB); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -napi_value OpenFileAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperOpenFileCB *openFileCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || openFileCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &openFileCB->cbBase.cbInfo.callback)); - } - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - OpenFileExecuteCB, - OpenFileAsyncCompleteCB, - (void *)openFileCB, - &openFileCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, openFileCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - HILOG_INFO("%{public}s, asyncCallback end.", __func__); - return result; -} - -napi_value OpenFilePromise(napi_env env, DSHelperOpenFileCB *openFileCB) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (openFileCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - napi_deferred deferred; - napi_value promise = 0; - NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); - openFileCB->cbBase.deferred = deferred; - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - OpenFileExecuteCB, - OpenFilePromiseCompleteCB, - (void *)openFileCB, - &openFileCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, openFileCB->cbBase.asyncWork)); - HILOG_INFO("%{public}s, promise end.", __func__); - return promise; -} - -void OpenFileExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_OpenFile, worker pool thread execute."); - DSHelperOpenFileCB *OpenFileCB = static_cast(data); - if (OpenFileCB->dataShareHelper != nullptr) { - OpenFileCB->execResult = INVALID_PARAMETER; - if (!OpenFileCB->uri.empty()) { - OHOS::Uri uri(OpenFileCB->uri); - OpenFileCB->result = OpenFileCB->dataShareHelper->OpenFile(uri, OpenFileCB->mode); - OpenFileCB->execResult = NO_ERROR; - } else { - HILOG_ERROR("NAPI_OpenFile, dataShareHelper uri is empty"); - } - } else { - HILOG_ERROR("NAPI_OpenFile, dataShareHelper == nullptr"); - } - HILOG_INFO("NAPI_OpenFile, worker pool thread execute end."); -} - -void OpenFileAsyncCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_OpenFile, main event thread complete."); - DSHelperOpenFileCB *OpenFileCB = static_cast(data); - napi_value callback = nullptr; - napi_value undefined = nullptr; - napi_value result[ARGS_TWO] = {nullptr}; - napi_value callResult = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); - NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, OpenFileCB->cbBase.cbInfo.callback, &callback)); - - result[PARAM0] = GetCallbackErrorValue(env, OpenFileCB->execResult); - napi_create_int32(env, OpenFileCB->result, &result[PARAM1]); - NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); - - if (OpenFileCB->cbBase.cbInfo.callback != nullptr) { - NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, OpenFileCB->cbBase.cbInfo.callback)); - } - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, OpenFileCB->cbBase.asyncWork)); - delete OpenFileCB; - OpenFileCB = nullptr; - HILOG_INFO("NAPI_OpenFile, main event thread complete end."); -} - -void OpenFilePromiseCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_OpenFileCB, main event thread complete."); - DSHelperOpenFileCB *OpenFileCB = static_cast(data); - napi_value result = nullptr; - napi_create_int32(env, OpenFileCB->result, &result); - NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, OpenFileCB->cbBase.deferred, result)); - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, OpenFileCB->cbBase.asyncWork)); - delete OpenFileCB; - OpenFileCB = nullptr; - HILOG_INFO("NAPI_OpenFileCB, main event thread complete end."); -} - -/** - * @brief DataShareHelper NAPI method : insert. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_BatchInsert(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - DSHelperBatchInsertCB *BatchInsertCB = new (std::nothrow) DSHelperBatchInsertCB; - if (BatchInsertCB == nullptr) { - HILOG_ERROR("%{public}s, BatchInsertCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - BatchInsertCB->cbBase.cbInfo.env = env; - BatchInsertCB->cbBase.asyncWork = nullptr; - BatchInsertCB->cbBase.deferred = nullptr; - BatchInsertCB->cbBase.ability = nullptr; - - napi_value ret = BatchInsertWrap(env, info, BatchInsertCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s,ret == nullptr", __func__); - if (BatchInsertCB != nullptr) { - delete BatchInsertCB; - BatchInsertCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -std::vector NapiValueObject(napi_env env, napi_value param) -{ - HILOG_INFO("%{public}s,called", __func__); - std::vector result; - UnwrapArrayObjectFromJS(env, param, result); - return result; -} - -bool UnwrapArrayObjectFromJS(napi_env env, napi_value param, std::vector &value) -{ - HILOG_INFO("%{public}s,called", __func__); - uint32_t arraySize = 0; - napi_value jsValue = nullptr; - std::string strValue = ""; - - if (!IsArrayForNapiValue(env, param, arraySize)) { - HILOG_INFO("%{public}s, IsArrayForNapiValue is false", __func__); - return false; - } - - value.clear(); - for (uint32_t i = 0; i < arraySize; i++) { - jsValue = nullptr; - if (napi_get_element(env, param, i, &jsValue) != napi_ok) { - HILOG_INFO("%{public}s, napi_get_element is false", __func__); - return false; - } - - NativeRdb::ValuesBucket valueBucket; - valueBucket.Clear(); - AnalysisValuesBucket(valueBucket, env, jsValue); - - value.push_back(valueBucket); - } - HILOG_INFO("%{public}s,end", __func__); - return true; -} - -/** - * @brief Insert processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value BatchInsertWrap(napi_env env, napi_callback_info info, DSHelperBatchInsertCB *batchInsertCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argcAsync = ARGS_THREE; - const size_t argcPromise = ARGS_TWO; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - napi_value thisVar = nullptr; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); - if (valuetype == napi_string) { - batchInsertCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); - HILOG_INFO("%{public}s,uri=%{public}s", __func__, batchInsertCB->uri.c_str()); - } - - batchInsertCB->values = NapiValueObject(env, args[PARAM1]); - - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - HILOG_INFO("%{public}s,DataShareHelper objectInfo = %{public}p", __func__, objectInfo); - batchInsertCB->dataShareHelper = objectInfo; - - if (argcAsync > argcPromise) { - ret = BatchInsertAsync(env, args, ARGS_TWO, batchInsertCB); - } else { - ret = BatchInsertPromise(env, batchInsertCB); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -napi_value BatchInsertAsync( - napi_env env, napi_value *args, const size_t argCallback, DSHelperBatchInsertCB *batchInsertCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || batchInsertCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &batchInsertCB->cbBase.cbInfo.callback)); - } - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - BatchInsertExecuteCB, - BatchInsertAsyncCompleteCB, - (void *)batchInsertCB, - &batchInsertCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, batchInsertCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - HILOG_INFO("%{public}s, asyncCallback end.", __func__); - return result; -} - -napi_value BatchInsertPromise(napi_env env, DSHelperBatchInsertCB *batchInsertCB) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (batchInsertCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - napi_deferred deferred; - napi_value promise = 0; - NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); - batchInsertCB->cbBase.deferred = deferred; - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - BatchInsertExecuteCB, - BatchInsertPromiseCompleteCB, - (void *)batchInsertCB, - &batchInsertCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, batchInsertCB->cbBase.asyncWork)); - HILOG_INFO("%{public}s, promise end.", __func__); - return promise; -} - -void BatchInsertExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_BatchInsert, worker pool thread execute."); - DSHelperBatchInsertCB *batchInsertCB = static_cast(data); - if (batchInsertCB->dataShareHelper != nullptr) { - batchInsertCB->execResult = INVALID_PARAMETER; - if (!batchInsertCB->uri.empty()) { - OHOS::Uri uri(batchInsertCB->uri); - batchInsertCB->result = batchInsertCB->dataShareHelper->BatchInsert(uri, batchInsertCB->values); - batchInsertCB->execResult = NO_ERROR; - } else { - HILOG_ERROR("NAPI_BatchInsert, dataShareHelper uri is empyt"); - } - } else { - HILOG_ERROR("NAPI_BatchInsert, dataShareHelper == nullptr"); - } - HILOG_INFO("NAPI_BatchInsert, worker pool thread execute end."); -} - -void BatchInsertAsyncCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_BatchInsert, main event thread complete."); - DSHelperBatchInsertCB *BatchInsertCB = static_cast(data); - napi_value callback = nullptr; - napi_value undefined = nullptr; - napi_value result[ARGS_TWO] = {nullptr}; - napi_value callResult = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); - NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, BatchInsertCB->cbBase.cbInfo.callback, &callback)); - - result[PARAM0] = GetCallbackErrorValue(env, BatchInsertCB->execResult); - napi_create_int32(env, BatchInsertCB->result, &result[PARAM1]); - NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); - - if (BatchInsertCB->cbBase.cbInfo.callback != nullptr) { - NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, BatchInsertCB->cbBase.cbInfo.callback)); - } - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, BatchInsertCB->cbBase.asyncWork)); - delete BatchInsertCB; - BatchInsertCB = nullptr; - HILOG_INFO("NAPI_BatchInsert, main event thread complete end."); -} - -void BatchInsertPromiseCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_BatchInsertCB, main event thread complete."); - DSHelperBatchInsertCB *BatchInsertCB = static_cast(data); - napi_value result = nullptr; - napi_create_int32(env, BatchInsertCB->result, &result); - NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, BatchInsertCB->cbBase.deferred, result)); - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, BatchInsertCB->cbBase.asyncWork)); - delete BatchInsertCB; - BatchInsertCB = nullptr; - HILOG_INFO("NAPI_BatchInsertCB, main event thread complete end."); -} - -/** - * @brief DataShareHelper NAPI method : insert. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_Query(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - DSHelperQueryCB *QueryCB = new (std::nothrow) DSHelperQueryCB; - if (QueryCB == nullptr) { - HILOG_ERROR("%{public}s, QueryCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - QueryCB->cbBase.cbInfo.env = env; - QueryCB->cbBase.asyncWork = nullptr; - QueryCB->cbBase.deferred = nullptr; - QueryCB->cbBase.ability = nullptr; - - napi_value ret = QueryWrap(env, info, QueryCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s,ret == nullptr", __func__); - if (QueryCB != nullptr) { - delete QueryCB; - QueryCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -/** - * @brief Insert processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value QueryWrap(napi_env env, napi_callback_info info, DSHelperQueryCB *queryCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argcAsync = ARGS_FOUR; - const size_t argcPromise = ARGS_THREE; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - napi_value thisVar = nullptr; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); - if (valuetype == napi_string) { - queryCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); - HILOG_INFO("%{public}s,uri=%{public}s", __func__, queryCB->uri.c_str()); - } - - std::vector result; - bool arrayStringbool = false; - arrayStringbool = NapiValueToArrayStringUtf8(env, args[PARAM1], result); - if (!arrayStringbool) { - HILOG_ERROR("%{public}s, The return value of arraystringbool is false", __func__); - } - queryCB->columns = result; - for (size_t i = 0; i < queryCB->columns.size(); i++) { - HILOG_INFO("%{public}s,columns=%{public}s", __func__, queryCB->columns.at(i).c_str()); - } - - UnwrapDataAbilityPredicates(queryCB->predicates, env, args[PARAM2]); - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - HILOG_INFO("%{public}s,DataShareHelper objectInfo = %{public}p", __func__, objectInfo); - queryCB->dataShareHelper = objectInfo; - - if (argcAsync > argcPromise) { - ret = QueryAsync(env, args, ARGS_THREE, queryCB); - } else { - ret = QueryPromise(env, queryCB); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -napi_value QueryAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperQueryCB *queryCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || queryCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &queryCB->cbBase.cbInfo.callback)); - } - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - QueryExecuteCB, - QueryAsyncCompleteCB, - (void *)queryCB, - &queryCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, queryCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - HILOG_INFO("%{public}s, asyncCallback end.", __func__); - return result; -} - -napi_value QueryPromise(napi_env env, DSHelperQueryCB *queryCB) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (queryCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - napi_deferred deferred; - napi_value promise = 0; - NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); - queryCB->cbBase.deferred = deferred; - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - QueryExecuteCB, - QueryPromiseCompleteCB, - (void *)queryCB, - &queryCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, queryCB->cbBase.asyncWork)); - HILOG_INFO("%{public}s, promise end.", __func__); - return promise; -} - -void QueryPromiseCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_DSHelperQueryCB, main event thread complete."); - DSHelperQueryCB *QueryCB = static_cast(data); - napi_value result = nullptr; - result = WrapResultSet(env, QueryCB->result); - NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, QueryCB->cbBase.deferred, result)); - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, QueryCB->cbBase.asyncWork)); - delete QueryCB; - QueryCB = nullptr; - HILOG_INFO("NAPI_DSHelperQueryCB, main event thread complete end."); -} - -void QueryExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_Query, worker pool thread execute."); - DSHelperQueryCB *queryCB = static_cast(data); - if (queryCB->dataShareHelper != nullptr) { - queryCB->execResult = INVALID_PARAMETER; - if (!queryCB->uri.empty()) { - OHOS::Uri uri(queryCB->uri); - auto resultset = queryCB->dataShareHelper->Query(uri, queryCB->columns, queryCB->predicates); - if (resultset != nullptr) { - queryCB->result = resultset; - queryCB->execResult = NO_ERROR; - } else { - HILOG_INFO("NAPI_Query, resultset == nullptr."); - } - } else { - HILOG_ERROR("NAPI_Query, dataShareHelper uri is empty"); - } - } else { - HILOG_ERROR("NAPI_Query, dataShareHelper == nullptr"); - } - HILOG_INFO("NAPI_Query, worker pool thread execute end."); -} - -void QueryAsyncCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_Query, main event thread complete."); - DSHelperQueryCB *queryCB = static_cast(data); - napi_value callback = nullptr; - napi_value undefined = nullptr; - napi_value result[ARGS_TWO] = {nullptr}; - napi_value callResult = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); - NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, queryCB->cbBase.cbInfo.callback, &callback)); - - result[PARAM0] = GetCallbackErrorValue(env, queryCB->execResult); - result[PARAM1] = WrapResultSet(env, queryCB->result); - - NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); - - if (queryCB->cbBase.cbInfo.callback != nullptr) { - NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, queryCB->cbBase.cbInfo.callback)); - } - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, queryCB->cbBase.asyncWork)); - delete queryCB; - queryCB = nullptr; - HILOG_INFO("NAPI_Query, main event thread complete end."); -} - -napi_value WrapResultSet(napi_env env, const std::shared_ptr &resultSet) -{ - HILOG_INFO("%{public}s,called", __func__); - if (resultSet == nullptr) { - HILOG_ERROR("%{public}s, input parameter resultSet is nullptr", __func__); - return WrapVoidToJS(env); - } - - return RdbJsKit::ResultSetProxy::NewInstance(env, resultSet); -} - -napi_value NAPI_Release(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - DSHelperReleaseCB *releaseCB = new (std::nothrow) DSHelperReleaseCB; - if (releaseCB == nullptr) { - HILOG_ERROR("%{public}s, releaseCB == nullptr.", __func__); - return WrapVoidToJS(env); - } - releaseCB->cbBase.cbInfo.env = env; - releaseCB->cbBase.asyncWork = nullptr; - releaseCB->cbBase.deferred = nullptr; - - napi_value ret = ReleaseWrap(env, info, releaseCB); - if (ret == nullptr) { - HILOG_ERROR("%{public}s,ret == nullptr", __func__); - if (releaseCB != nullptr) { - delete releaseCB; - releaseCB = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -napi_value ReleaseWrap(napi_env env, napi_callback_info info, DSHelperReleaseCB *releaseCB) -{ - HILOG_INFO("%{public}s,called", __func__); - size_t argcAsync = ARGS_ONE; - const size_t argcPromise = ARGS_ZERO; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = nullptr; - napi_value thisVar = nullptr; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - DataShareHelper *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); - HILOG_INFO("DataShareHelper ReleaseWrap objectInfo = %{public}p", objectInfo); - releaseCB->dataShareHelper = objectInfo; - - if (argcAsync > argcPromise) { - ret = ReleaseAsync(env, args, PARAM0, releaseCB); - } else { - ret = ReleasePromise(env, releaseCB); - } - HILOG_INFO("%{public}s,end", __func__); - return ret; -} - -napi_value ReleaseAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperReleaseCB *releaseCB) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || releaseCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &releaseCB->cbBase.cbInfo.callback)); - } - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - ReleaseExecuteCB, - ReleaseAsyncCompleteCB, - (void *)releaseCB, - &releaseCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, releaseCB->cbBase.asyncWork)); - napi_value result = 0; - NAPI_CALL(env, napi_get_null(env, &result)); - HILOG_INFO("%{public}s, asyncCallback end.", __func__); - return result; -} - -napi_value ReleasePromise(napi_env env, DSHelperReleaseCB *releaseCB) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (releaseCB == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - napi_deferred deferred; - napi_value promise = 0; - NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); - releaseCB->cbBase.deferred = deferred; - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - ReleaseExecuteCB, - ReleasePromiseCompleteCB, - (void *)releaseCB, - &releaseCB->cbBase.asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, releaseCB->cbBase.asyncWork)); - HILOG_INFO("%{public}s, promise end.", __func__); - return promise; -} - -void ReleaseExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_Release, worker pool thread execute."); - DSHelperReleaseCB *releaseCB = static_cast(data); - if (releaseCB->dataShareHelper != nullptr) { - releaseCB->result = releaseCB->dataShareHelper->Release(); - } else { - HILOG_ERROR("NAPI_Release, dataShareHelper == nullptr"); - } - HILOG_INFO("NAPI_Release, worker pool thread execute end."); -} - -void ReleaseAsyncCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_Release, main event thread complete."); - DSHelperReleaseCB *releaseCB = static_cast(data); - napi_value callback = nullptr; - napi_value undefined = nullptr; - napi_value result[ARGS_TWO] = {nullptr}; - napi_value callResult = nullptr; - NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); - NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, releaseCB->cbBase.cbInfo.callback, &callback)); - - result[PARAM0] = GetCallbackErrorValue(env, NO_ERROR); - napi_get_boolean(env, releaseCB->result, &result[PARAM1]); - NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); - - if (releaseCB->cbBase.cbInfo.callback != nullptr) { - NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, releaseCB->cbBase.cbInfo.callback)); - } - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, releaseCB->cbBase.asyncWork)); - delete releaseCB; - releaseCB = nullptr; - HILOG_INFO("NAPI_Release, main event thread complete end."); -} - -void ReleasePromiseCompleteCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("NAPI_Release, main event thread complete."); - DSHelperReleaseCB *releaseCB = static_cast(data); - napi_value result = nullptr; - napi_get_boolean(env, releaseCB->result, &result); - NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, releaseCB->cbBase.deferred, result)); - NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, releaseCB->cbBase.asyncWork)); - delete releaseCB; - releaseCB = nullptr; - HILOG_INFO("NAPI_Release, main event thread complete end."); -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/kits/napi/aafwk/dataShare/napi_datashare_helper.h b/interfaces/kits/napi/aafwk/dataShare/napi_datashare_helper.h deleted file mode 100644 index 4cbaeafaf18..00000000000 --- a/interfaces/kits/napi/aafwk/dataShare/napi_datashare_helper.h +++ /dev/null @@ -1,426 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_APPEXECFWK_NAPI_DATASHARE_HELPER_H -#define OHOS_APPEXECFWK_NAPI_DATASHARE_HELPER_H -#include "data_ability_observer_stub.h" -#include "data_share_common.h" - -namespace OHOS { -namespace AppExecFwk { -class NAPIDataShareObserver : public AAFwk::DataAbilityObserverStub { -public: - void OnChange() override; - void SetEnv(const napi_env &env); - void SetCallbackRef(const napi_ref &ref); - void ReleaseJSCallback(); - - void SetAssociatedObject(DSHelperOnOffCB* object); - const DSHelperOnOffCB* GetAssociatedObject(void); - - void ChangeWorkPre(); - void ChangeWorkRun(); - void ChangeWorkInt(); - void ChangeWorkPreDone(); - void ChangeWorkRunDone(); - int GetWorkPre(); - int GetWorkRun(); - int GetWorkInt(); - -private: - napi_env env_ = nullptr; - napi_ref ref_ = nullptr; - DSHelperOnOffCB* onCB_ = nullptr; - int workPre_ = 0; - int workRun_ = 0; - int intrust_ = 0; - std::mutex mutex_; -}; - -/** - * @brief DataShareHelper NAPI module registration. - * - * @param env The environment that the Node-API call is invoked under. - * @param exports An empty object via the exports parameter as a convenience. - * - * @return The return value from Init is treated as the exports object for the module. - */ -napi_value DataShareHelperInit(napi_env env, napi_value exports); -napi_value DataShareHelperConstructor(napi_env env, napi_callback_info info); - -/** - * @brief DataShareHelper NAPI method : insert. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_Insert(napi_env env, napi_callback_info info); - -/** - * @brief Insert processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value InsertWrap(napi_env env, napi_callback_info info, DSHelperInsertCB *insertCB); - -/** - * @brief Insert Async. - * - * @param env The environment that the Node-API call is invoked under. - * @param args Indicates the arguments passed into the callback. - * @param argcPromise Asynchronous data processing. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value InsertAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperInsertCB *insertCB); - -/** - * @brief Insert Promise. - * - * @param env The environment that the Node-API call is invoked under. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value InsertPromise(napi_env env, DSHelperInsertCB *insertCB); - -/** - * @brief Insert asynchronous processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param data Point to asynchronous processing of data. - */ -void InsertExecuteCB(napi_env env, void *data); - -/** - * @brief The callback at the end of the asynchronous callback. - * - * @param env The environment that the Node-API call is invoked under. - * @param data Point to asynchronous processing of data. - */ -void InsertAsyncCompleteCB(napi_env env, napi_status status, void *data); - -/** - * @brief The callback at the end of the Promise callback. - * - * @param env The environment that the Node-API call is invoked under. - * @param data Point to asynchronous processing of data. - */ -void InsertPromiseCompleteCB(napi_env env, napi_status status, void *data); - -/** - * @brief DataShareHelper NAPI method : notifyChange. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_NotifyChange(napi_env env, napi_callback_info info); - -/** - * @brief NotifyChange processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param notifyChangeCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value NotifyChangeWrap(napi_env env, napi_callback_info info, DSHelperNotifyChangeCB *notifyChangeCB); - -/** - * @brief NotifyChange Async. - * - * @param env The environment that the Node-API call is invoked under. - * @param args Indicates the arguments passed into the callback. - * @param argcPromise Asynchronous data processing. - * @param notifyChangeCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value NotifyChangeAsync( - napi_env env, napi_value *args, size_t argcAsync, const size_t argcPromise, DSHelperNotifyChangeCB *notifyChangeCB); - -/** - * @brief NotifyChange Promise. - * - * @param env The environment that the Node-API call is invoked under. - * @param notifyChangeCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value NotifyChangePromise(napi_env env, DSHelperNotifyChangeCB *notifyChangeCB); - -/** - * @brief NotifyChange asynchronous processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param data Point to asynchronous processing of data. - */ -void NotifyChangeExecuteCB(napi_env env, void *data); - -/** - * @brief The callback at the end of the asynchronous callback. - * - * @param env The environment that the Node-API call is invoked under. - * @param data Point to asynchronous processing of data. - */ -void NotifyChangeAsyncCompleteCB(napi_env env, napi_status status, void *data); - -/** - * @brief The callback at the end of the Promise callback. - * - * @param env The environment that the Node-API call is invoked under. - * @param data Point to asynchronous processing of data. - */ -void NotifyChangePromiseCompleteCB(napi_env env, napi_status status, void *data); - -/** - * @brief DataShareHelper NAPI method : on. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_Register(napi_env env, napi_callback_info info); - -/** - * @brief On processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value RegisterWrap(napi_env env, napi_callback_info info, DSHelperOnOffCB *insertCB); - -/** - * @brief On Async. - * - * @param env The environment that the Node-API call is invoked under. - * @param args Indicates the arguments passed into the callback. - * @param argcPromise Asynchronous data processing. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value RegisterAsync( - napi_env env, napi_value *args, size_t argcAsync, const size_t argcPromise, DSHelperOnOffCB *insertCB); - -/** - * @brief On asynchronous processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param data Point to asynchronous processing of data. - */ -void RegisterExecuteCB(napi_env env, void *data); -void RegisterCompleteCB(napi_env env, napi_status status, void *data); - -/** - * @brief DataShareHelper NAPI method : off. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_UnRegister(napi_env env, napi_callback_info info); - -/** - * @brief Off processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value UnRegisterWrap(napi_env env, napi_callback_info info, DSHelperOnOffCB *insertCB); - -/** - * @brief Off Async. - * - * @param env The environment that the Node-API call is invoked under. - * @param args Indicates the arguments passed into the callback. - * @param argcPromise Asynchronous data processing. - * @param insertCB Process data asynchronously. - * - * @return Return JS data successfully, otherwise return nullptr. - */ -napi_value UnRegisterAsync( - napi_env env, napi_value *args, size_t argcAsync, const size_t argcPromise, DSHelperOnOffCB *insertCB); - -/** - * @brief Off asynchronous processing function. - * - * @param env The environment that the Node-API call is invoked under. - * @param data Point to asynchronous processing of data. - */ -void UnRegisterExecuteCB(napi_env env, void *data); -void UnRegisterCompleteCB(napi_env env, napi_status status, void *data); -void FindRegisterObs(napi_env env, DSHelperOnOffCB *data); -/** - * @brief Parse the ValuesBucket parameters. - * - * @param param Indicates the want parameters saved the parse result. - * @param env The environment that the Node-API call is invoked under. - * @param args Indicates the arguments passed into the callback. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value UnwrapValuesBucket(std::string &value, napi_env env, napi_value args); - -static std::vector registerInstances_; -napi_value NAPI_Release(napi_env env, napi_callback_info info); - -napi_value ReleaseWrap(napi_env env, napi_callback_info info, DSHelperReleaseCB *releaseCB); - -napi_value ReleaseAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperReleaseCB *releaseCB); - -napi_value ReleasePromise(napi_env env, DSHelperReleaseCB *releaseCB); - -void ReleaseExecuteCB(napi_env env, void *data); - -void ReleaseAsyncCompleteCB(napi_env env, napi_status status, void *data); - -void ReleasePromiseCompleteCB(napi_env env, napi_status status, void *data); - -napi_value NAPI_GetType(napi_env env, napi_callback_info info); -napi_value NAPI_GetType(napi_env env, napi_callback_info info); -napi_value GetTypeWrap(napi_env env, napi_callback_info info, DSHelperGetTypeCB *gettypeCB); -napi_value GetTypeAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperGetTypeCB *gettypeCB); -napi_value GetTypePromise(napi_env env, DSHelperGetTypeCB *gettypeCB); -void GetTypeExecuteCB(napi_env env, void *data); -void GetTypeAsyncCompleteCB(napi_env env, napi_status status, void *data); -void GetTypePromiseCompleteCB(napi_env env, napi_status status, void *data); - -napi_value NAPI_GetFileTypes(napi_env env, napi_callback_info info); -napi_value NAPI_GetFileTypes(napi_env env, napi_callback_info info); -napi_value GetFileTypesWrap(napi_env env, napi_callback_info info, DSHelperGetFileTypesCB *getfiletypesCB); -napi_value GetFileTypesAsync( - napi_env env, napi_value *args, const size_t argCallback, DSHelperGetFileTypesCB *getfiletypesCB); -napi_value GetFileTypesPromise(napi_env env, DSHelperGetFileTypesCB *getfiletypesCB); -void GetFileTypesExecuteCB(napi_env env, void *data); -void GetFileTypesAsyncCompleteCB(napi_env env, napi_status status, void *data); -void GetFileTypesPromiseCompleteCB(napi_env env, napi_status status, void *data); -napi_value WrapGetFileTypesCB(napi_env env, const DSHelperGetFileTypesCB &getfiletypesCB); - -napi_value NAPI_NormalizeUri(napi_env env, napi_callback_info info); -napi_value NAPI_NormalizeUri(napi_env env, napi_callback_info info); -napi_value NormalizeUriWrap(napi_env env, napi_callback_info info, DSHelperNormalizeUriCB *normalizeuriCB); -napi_value NormalizeUriAsync( - napi_env env, napi_value *args, const size_t argCallback, DSHelperNormalizeUriCB *normalizeuriCB); -napi_value NormalizeUriPromise(napi_env env, DSHelperNormalizeUriCB *normalizeuriCB); -void NormalizeUriExecuteCB(napi_env env, void *data); -void NormalizeUriAsyncCompleteCB(napi_env env, napi_status status, void *data); -void NormalizeUriPromiseCompleteCB(napi_env env, napi_status status, void *data); - -napi_value NAPI_DenormalizeUri(napi_env env, napi_callback_info info); -napi_value NAPI_DenormalizeUri(napi_env env, napi_callback_info info); -napi_value DenormalizeUriWrap(napi_env env, napi_callback_info info, DSHelperDenormalizeUriCB *denormalizeuriCB); -napi_value DenormalizeUriAsync( - napi_env env, napi_value *args, const size_t argCallback, DSHelperDenormalizeUriCB *denormalizeuriCB); -napi_value DenormalizeUriPromise(napi_env env, DSHelperDenormalizeUriCB *denormalizeuriCB); -void DenormalizeUriExecuteCB(napi_env env, void *data); -void DenormalizeUriAsyncCompleteCB(napi_env env, napi_status status, void *data); -void DenormalizeUriPromiseCompleteCB(napi_env env, napi_status status, void *data); - -napi_value NAPI_Delete(napi_env env, napi_callback_info info); - -napi_value DeleteWrap(napi_env env, napi_callback_info info, DSHelperDeleteCB *deleteCB); -napi_value DeleteAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperDeleteCB *deleteCB); - -napi_value DeletePromise(napi_env env, DSHelperDeleteCB *deleteCB); - -void DeleteExecuteCB(napi_env env, void *data); - -void DeleteAsyncCompleteCB(napi_env env, napi_status status, void *data); - -void DeletePromiseCompleteCB(napi_env env, napi_status status, void *data); - -napi_value NAPI_Update(napi_env env, napi_callback_info info); - -napi_value UpdateWrap(napi_env env, napi_callback_info info, DSHelperUpdateCB *updateCB); -napi_value UpdateAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperUpdateCB *updateCB); - -napi_value UpdatePromise(napi_env env, DSHelperUpdateCB *updateCB); - -void UpdateExecuteCB(napi_env env, void *data); - -void UpdateAsyncCompleteCB(napi_env env, napi_status status, void *data); - -void UpdatePromiseCompleteCB(napi_env env, napi_status status, void *data); - -napi_value NAPI_OpenFile(napi_env env, napi_callback_info info); - -napi_value OpenFileWrap(napi_env env, napi_callback_info info, DSHelperOpenFileCB *openFileCB); -napi_value OpenFileAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperOpenFileCB *openFileCB); - -napi_value OpenFilePromise(napi_env env, DSHelperOpenFileCB *openFileCB); - -void OpenFileExecuteCB(napi_env env, void *data); - -void OpenFileAsyncCompleteCB(napi_env env, napi_status status, void *data); - -void OpenFilePromiseCompleteCB(napi_env env, napi_status status, void *data); - -napi_value NAPI_BatchInsert(napi_env env, napi_callback_info info); - -napi_value BatchInsertWrap(napi_env env, napi_callback_info info, DSHelperBatchInsertCB *batchInsertCB); -napi_value BatchInsertAsync( - napi_env env, napi_value *args, const size_t argCallback, DSHelperBatchInsertCB *batchInsertCB); - -napi_value BatchInsertPromise(napi_env env, DSHelperBatchInsertCB *batchInsertCB); - -void BatchInsertExecuteCB(napi_env env, void *data); - -void BatchInsertAsyncCompleteCB(napi_env env, napi_status status, void *data); - -void BatchInsertPromiseCompleteCB(napi_env env, napi_status status, void *data); - -std::vector NapiValueObject(napi_env env, napi_value param); - -bool UnwrapArrayObjectFromJS(napi_env env, napi_value param, std::vector &value); - -napi_value NAPI_Query(napi_env env, napi_callback_info info); - -napi_value QueryWrap(napi_env env, napi_callback_info info, DSHelperQueryCB *queryCB); - -napi_value QueryAsync(napi_env env, napi_value *args, const size_t argCallback, DSHelperQueryCB *queryCB); - -napi_value QueryPromise(napi_env env, DSHelperQueryCB *queryCB); - -void QueryExecuteCB(napi_env env, void *data); - -void QueryAsyncCompleteCB(napi_env env, napi_status status, void *data); - -void QueryPromiseCompleteCB(napi_env env, napi_status status, void *data); - -napi_value WrapResultSet(napi_env env, const std::shared_ptr &resultSet); - -void AnalysisValuesBucket(NativeRdb::ValuesBucket &value, const napi_env &env, const napi_value &arg); -void SetValuesBucketObject( - NativeRdb::ValuesBucket &valuesBucket, const napi_env &env, std::string keyStr, napi_value value); - -void UnwrapDataAbilityPredicates(NativeRdb::DataAbilityPredicates &predicates, napi_env env, napi_value value); -} // namespace AppExecFwk -} // namespace OHOS -#endif /* OHOS_APPEXECFWK_NAPI_DATASHARE_HELPER_H */ diff --git a/interfaces/kits/napi/aafwk/dataShare/native_datashare_module.cpp b/interfaces/kits/napi/aafwk/dataShare/native_datashare_module.cpp deleted file mode 100644 index 078fee397f3..00000000000 --- a/interfaces/kits/napi/aafwk/dataShare/native_datashare_module.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "napi_datashare_helper.h" -#include "napi/native_api.h" -#include "napi/native_node_api.h" - -namespace OHOS { -namespace AppExecFwk { -EXTERN_C_START -/* - * The module initialization. - */ -static napi_value Init(napi_env env, napi_value exports) -{ - DataShareHelperInit(env, exports); - return exports; -} -EXTERN_C_END - -/* - * The module definition. - */ -static napi_module _module = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "data.dataShare", - .nm_priv = ((void *)0), - .reserved = {0} -}; - -/* - * The module registration. - */ -extern "C" __attribute__((constructor)) void RegisterModule(void) -{ - napi_module_register(&_module); -} -} // namespace AppExecFwk -} // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/napi/aafwk/inner/napi_common/BUILD.gn b/interfaces/kits/napi/aafwk/inner/napi_common/BUILD.gn index e3904f5ff16..aff79d10f1b 100644 --- a/interfaces/kits/napi/aafwk/inner/napi_common/BUILD.gn +++ b/interfaces/kits/napi/aafwk/inner/napi_common/BUILD.gn @@ -30,7 +30,6 @@ ohos_shared_library("napi_common") { ] deps = [ - "//base/notification/ans_standard/frameworks/wantagent:wantagent_innerkits", "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", "//foundation/aafwk/standard/frameworks/kits/appkit:appkit_native", "//foundation/aafwk/standard/interfaces/innerkits/base:base", diff --git a/interfaces/kits/napi/aafwk/inner/napi_common/feature_ability_common.h b/interfaces/kits/napi/aafwk/inner/napi_common/feature_ability_common.h index 6738cc3a15c..5441466206d 100644 --- a/interfaces/kits/napi/aafwk/inner/napi_common/feature_ability_common.h +++ b/interfaces/kits/napi/aafwk/inner/napi_common/feature_ability_common.h @@ -58,7 +58,6 @@ struct AsyncCallbackInfo { napi_async_work asyncWork = nullptr; napi_deferred deferred = nullptr; Ability *ability = nullptr; - Notification::WantAgent::WantAgent *wantAgent = nullptr; CallAbilityParam param; CallbackInfo aceCallback; bool native_result; diff --git a/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.cpp b/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.cpp index a5b9eda80d3..71d51480c38 100644 --- a/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.cpp +++ b/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.cpp @@ -3501,333 +3501,5 @@ napi_value AcquireDataAbilityHelperWrap(napi_env env, napi_callback_info info, D HILOG_INFO("%{public}s,end", __func__); return result; } - -napi_value UnwrapParamForWantAgent(napi_env &env, napi_value &args, Notification::WantAgent::WantAgent *&wantAgent) -{ - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args, &valuetype)); - NAPI_ASSERT(env, valuetype == napi_object, "Wrong argument type. Object expected."); - napi_value wantAgentParam = nullptr; - napi_value result = nullptr; - - bool hasProperty = false; - NAPI_CALL(env, napi_has_named_property(env, args, "wantAgent", &hasProperty)); - if (hasProperty) { - napi_get_named_property(env, args, "wantAgent", &wantAgentParam); - NAPI_CALL(env, napi_typeof(env, wantAgentParam, &valuetype)); - NAPI_ASSERT(env, valuetype == napi_object, "Wrong argument type. Object expected."); - napi_unwrap(env, wantAgentParam, (void **)&wantAgent); - } - - napi_get_null(env, &result); - return result; -} - -void StartBackgroundRunningExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("%{public}s called.", __func__); - AsyncCallbackInfo *asyncCallbackInfo = (AsyncCallbackInfo *)data; - if (asyncCallbackInfo == nullptr) { - HILOG_ERROR("%{public}s asyncCallbackInfo == nullptr", __func__); - return; - } - if (asyncCallbackInfo->errCode == NAPI_ERR_PARAM_INVALID) { - HILOG_ERROR("parse input param failed"); - return; - } - if (asyncCallbackInfo->ability == nullptr) { - asyncCallbackInfo->errCode = NAPI_ERR_ACE_ABILITY; - HILOG_ERROR("%{public}s ability == nullptr", __func__); - return; - } - const std::shared_ptr info = asyncCallbackInfo->ability->GetAbilityInfo(); - if (info == nullptr) { - HILOG_ERROR("abilityinfo is null"); - asyncCallbackInfo->errCode = NAPI_ERR_ACE_ABILITY; - return; - } - - asyncCallbackInfo->errCode = asyncCallbackInfo->ability->StartBackgroundRunning(*asyncCallbackInfo->wantAgent); - - HILOG_INFO("%{public}s end.", __func__); -} - -void BackgroundRunningCallbackCompletedCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("%{public}s called.", __func__); - AsyncCallbackInfo *asyncCallbackInfo = static_cast(data); - napi_value callback = 0; - napi_value undefined = 0; - napi_value result[ARGS_TWO] = {0}; - napi_value callResult = 0; - napi_get_undefined(env, &undefined); - if (asyncCallbackInfo->errCode == NAPI_ERR_NO_ERROR) { - result[0] = WrapUndefinedToJS(env); - napi_create_int32(env, 0, &result[1]); - } else { - result[1] = WrapUndefinedToJS(env); - result[0] = GetCallbackErrorValue(env, asyncCallbackInfo->errCode); - } - - napi_get_reference_value(env, asyncCallbackInfo->cbInfo.callback, &callback); - napi_call_function(env, undefined, callback, ARGS_TWO, result, &callResult); - - if (asyncCallbackInfo->cbInfo.callback != nullptr) { - napi_delete_reference(env, asyncCallbackInfo->cbInfo.callback); - } - napi_delete_async_work(env, asyncCallbackInfo->asyncWork); - delete asyncCallbackInfo; - asyncCallbackInfo = nullptr; - HILOG_INFO("%{public}s end.", __func__); -} - -void BackgroundRunningPromiseCompletedCB(napi_env env, napi_status status, void *data) -{ - HILOG_INFO("%{public}s called.", __func__); - AsyncCallbackInfo *asyncCallbackInfo = static_cast(data); - napi_value result = 0; - if (asyncCallbackInfo->errCode == NAPI_ERR_NO_ERROR) { - napi_create_int32(env, 0, &result); - napi_resolve_deferred(env, asyncCallbackInfo->deferred, result); - } else { - result = GetCallbackErrorValue(env, asyncCallbackInfo->errCode); - napi_reject_deferred(env, asyncCallbackInfo->deferred, result); - } - - napi_delete_async_work(env, asyncCallbackInfo->asyncWork); - HILOG_INFO("%{public}s, end.", __func__); - delete asyncCallbackInfo; -} - -napi_value StartBackgroundRunningAsync( - napi_env env, napi_value *args, const size_t argCallback, AsyncCallbackInfo *asyncCallbackInfo) -{ - HILOG_INFO("%{public}s asyncCallback.", __func__); - if (args == nullptr || asyncCallbackInfo == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - - napi_valuetype valuetype = napi_undefined; - NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); - if (valuetype == napi_function) { - NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &asyncCallbackInfo->cbInfo.callback)); - } - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - StartBackgroundRunningExecuteCB, - BackgroundRunningCallbackCompletedCB, - (void *)asyncCallbackInfo, - &asyncCallbackInfo->asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, asyncCallbackInfo->asyncWork)); - - HILOG_INFO("%{public}s asyncCallback end.", __func__); - return WrapVoidToJS(env); -} - -napi_value StartBackgroundRunningPromise(napi_env env, AsyncCallbackInfo *asyncCallbackInfo) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (asyncCallbackInfo == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName; - NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); - napi_deferred deferred; - napi_value promise = 0; - NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); - asyncCallbackInfo->deferred = deferred; - - NAPI_CALL(env, - napi_create_async_work(env, - nullptr, - resourceName, - StartBackgroundRunningExecuteCB, - BackgroundRunningPromiseCompletedCB, - (void *)asyncCallbackInfo, - &asyncCallbackInfo->asyncWork)); - NAPI_CALL(env, napi_queue_async_work(env, asyncCallbackInfo->asyncWork)); - HILOG_INFO("%{public}s, end.", __func__); - return promise; -} - -napi_value StartBackgroundRunningWrap(napi_env &env, napi_callback_info &info, AsyncCallbackInfo *asyncCallbackInfo) -{ - HILOG_INFO("%{public}s called.", __func__); - size_t paramNums = 3; - const size_t minParamNums = 2; - const size_t maxParamNums = 3; - napi_value args[maxParamNums] = {nullptr}; - napi_value ret = 0; - - NAPI_CALL(env, napi_get_cb_info(env, info, ¶mNums, args, NULL, NULL)); - - if (paramNums < minParamNums || paramNums > maxParamNums) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - if (UnwrapParamForWantAgent(env, args[1], asyncCallbackInfo->wantAgent) == nullptr) { - asyncCallbackInfo->errCode = NAPI_ERR_PARAM_INVALID; - } - - if (paramNums == maxParamNums) { - ret = StartBackgroundRunningAsync(env, args, maxParamNums - 1, asyncCallbackInfo); - } else { - ret = StartBackgroundRunningPromise(env, asyncCallbackInfo); - } - - HILOG_INFO("%{public}s end.", __func__); - return ret; -} - -napi_value NAPI_StartBackgroundRunningCommon(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s called.", __func__); - AsyncCallbackInfo *asyncCallbackInfo = CreateAsyncCallbackInfo(env); - if (asyncCallbackInfo == nullptr) { - HILOG_ERROR("%{public}s asyncCallbackInfo == nullpter", __func__); - return WrapVoidToJS(env); - } - - asyncCallbackInfo->errCode = NAPI_ERR_NO_ERROR; - napi_value ret = StartBackgroundRunningWrap(env, info, asyncCallbackInfo); - if (ret == nullptr) { - HILOG_ERROR("%{public}s ret == nullpter", __func__); - if (asyncCallbackInfo != nullptr) { - delete asyncCallbackInfo; - asyncCallbackInfo = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s end.", __func__); - return ret; -} - -void CancelBackgroundRunningExecuteCB(napi_env env, void *data) -{ - HILOG_INFO("NAPI_PACancelBackgroundRunning, worker pool thread execute."); - AsyncCallbackInfo *asyncCallbackInfo = static_cast(data); - if (asyncCallbackInfo->ability != nullptr) { - asyncCallbackInfo->ability->StopBackgroundRunning(); - } else { - HILOG_ERROR("NAPI_PACancelBackgroundRunning, ability == nullptr"); - } - HILOG_INFO("NAPI_PACancelBackgroundRunning, worker pool thread execute end."); -} - -napi_value CancelBackgroundRunningAsync( - napi_env env, napi_value *args, const size_t argCallback, AsyncCallbackInfo *asyncCallbackInfo) -{ - HILOG_INFO("%{public}s, asyncCallback.", __func__); - if (args == nullptr || asyncCallbackInfo == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName); - - napi_valuetype valuetype = napi_undefined; - napi_typeof(env, args[argCallback], &valuetype); - if (valuetype == napi_function) { - napi_create_reference(env, args[argCallback], 1, &asyncCallbackInfo->cbInfo.callback); - } - - napi_create_async_work( - env, - nullptr, - resourceName, - CancelBackgroundRunningExecuteCB, - BackgroundRunningCallbackCompletedCB, - (void *)asyncCallbackInfo, - &asyncCallbackInfo->asyncWork); - napi_queue_async_work(env, asyncCallbackInfo->asyncWork); - napi_value result = 0; - napi_get_null(env, &result); - HILOG_INFO("%{public}s, asyncCallback end", __func__); - return result; -} - -napi_value CancelBackgroundRunningPromise(napi_env env, AsyncCallbackInfo *asyncCallbackInfo) -{ - HILOG_INFO("%{public}s, promise.", __func__); - if (asyncCallbackInfo == nullptr) { - HILOG_ERROR("%{public}s, param == nullptr.", __func__); - return nullptr; - } - napi_value resourceName = 0; - napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName); - napi_deferred deferred; - napi_value promise = 0; - napi_create_promise(env, &deferred, &promise); - - asyncCallbackInfo->deferred = deferred; - - napi_create_async_work( - env, - nullptr, - resourceName, - CancelBackgroundRunningExecuteCB, - BackgroundRunningPromiseCompletedCB, - (void *)asyncCallbackInfo, - &asyncCallbackInfo->asyncWork); - napi_queue_async_work(env, asyncCallbackInfo->asyncWork); - HILOG_INFO("%{public}s, promise end", __func__); - return promise; -} - -napi_value CancelBackgroundRunningWrap(napi_env &env, napi_callback_info &info, AsyncCallbackInfo *asyncCallbackInfo) -{ - HILOG_INFO("%{public}s called.", __func__); - size_t argcAsync = 1; - const size_t argcPromise = 0; - const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; - napi_value args[ARGS_MAX_COUNT] = {nullptr}; - napi_value ret = 0; - - NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, NULL, NULL)); - if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); - return nullptr; - } - - if (argcAsync > argcPromise) { - ret = CancelBackgroundRunningAsync(env, args, 0, asyncCallbackInfo); - } else { - ret = CancelBackgroundRunningPromise(env, asyncCallbackInfo); - } - - HILOG_INFO("%{public}s end.", __func__); - return ret; -} - -napi_value NAPI_CancelBackgroundRunningCommon(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s called.", __func__); - AsyncCallbackInfo *asyncCallbackInfo = CreateAsyncCallbackInfo(env); - if (asyncCallbackInfo == nullptr) { - HILOG_ERROR("%{public}s asyncCallbackInfo == nullpter", __func__); - return WrapVoidToJS(env); - } - - asyncCallbackInfo->errCode = NAPI_ERR_NO_ERROR; - napi_value ret = CancelBackgroundRunningWrap(env, info, asyncCallbackInfo); - if (ret == nullptr) { - HILOG_ERROR("%{public}s ret == nullpter", __func__); - if (asyncCallbackInfo != nullptr) { - delete asyncCallbackInfo; - asyncCallbackInfo = nullptr; - } - ret = WrapVoidToJS(env); - } - HILOG_INFO("%{public}s end.", __func__); - return ret; -} } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.h b/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.h index c15bb499a33..293bf202414 100644 --- a/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.h +++ b/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.h @@ -26,7 +26,7 @@ const std::int32_t STR_MAX_SIZE = 128; napi_value *GetGlobalClassContext(void); -napi_status SaveGlobalDataAbilityHelper(napi_env env, napi_value constructor); +napi_status SaveGlobalDataAbilityHelper(napi_env env, napi_value constructor); napi_value GetGlobalDataAbilityHelper(napi_env env); bool& GetDataAbilityHelperStatus(); @@ -227,26 +227,6 @@ napi_value NAPI_AcquireDataAbilityHelperCommon(napi_env env, napi_callback_info napi_value ConvertAbilityInfo(napi_env env, const AbilityInfo &abilityInfo); -/** - * @brief start background running. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_StartBackgroundRunningCommon(napi_env env, napi_callback_info info); - -/** - * @brief cancel background running. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_CancelBackgroundRunningCommon(napi_env env, napi_callback_info info); - bool CheckAbilityType(const CBBase *cbBase); struct ConnecttionKey { diff --git a/interfaces/kits/napi/aafwk/mission_manager/mission_manager.cpp b/interfaces/kits/napi/aafwk/mission_manager/mission_manager.cpp index d7e9f78a1d5..da1fb0fdefd 100644 --- a/interfaces/kits/napi/aafwk/mission_manager/mission_manager.cpp +++ b/interfaces/kits/napi/aafwk/mission_manager/mission_manager.cpp @@ -23,15 +23,12 @@ #include "js_mission_listener.h" #include "js_runtime_utils.h" #include "mission_snapshot.h" -#include "napi_common_start_options.h" #include "pixel_map_napi.h" -#include "start_options.h" #include namespace OHOS { namespace AbilityRuntime { -constexpr size_t ARGC_ONE = 1; using namespace OHOS::AppExecFwk; using AbilityManagerClient = AAFwk::AbilityManagerClient; namespace { @@ -455,23 +452,14 @@ private: HILOG_ERROR("Parse missionId failed"); errCode = ERR_NOT_OK; } - decltype(info.argc) unwrapArgc = 1; - - AAFwk::StartOptions startOptions; - if (info.argc > ARGC_ONE && info.argv[1]->TypeOf() == NATIVE_OBJECT) { - HILOG_INFO("OnMoveMissionToFront start options is used."); - AppExecFwk::UnwrapStartOptions(reinterpret_cast(&engine), - reinterpret_cast(info.argv[1]), startOptions); - unwrapArgc++; - } + AsyncTask::CompleteCallback complete = - [missionId, errCode, startOptions, unwrapArgc](NativeEngine &engine, AsyncTask &task, int32_t status) { + [missionId, errCode](NativeEngine &engine, AsyncTask &task, int32_t status) { if (errCode != 0) { task.Reject(engine, CreateJsError(engine, errCode, "Invalidate params.")); return; } - auto ret = (unwrapArgc == 1) ? AbilityManagerClient::GetInstance()->MoveMissionToFront(missionId) : - AbilityManagerClient::GetInstance()->MoveMissionToFront(missionId, startOptions); + auto ret = AbilityManagerClient::GetInstance()->MoveMissionToFront(missionId); if (ret == 0) { task.Resolve(engine, engine.CreateUndefined()); } else { @@ -479,7 +467,7 @@ private: } }; - NativeValue* lastParam = (info.argc <= unwrapArgc) ? nullptr : info.argv[unwrapArgc]; + NativeValue* lastParam = (info.argc <= 1) ? nullptr : info.argv[1]; NativeValue* result = nullptr; AsyncTask::Schedule( engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); @@ -517,6 +505,7 @@ NativeValue* JsMissionManagerInit(NativeEngine* engine, NativeValue* exportObj) BindNativeFunction(*engine, *object, "clearMission", JsMissionManager::ClearMission); BindNativeFunction(*engine, *object, "clearAllMissions", JsMissionManager::ClearAllMissions); BindNativeFunction(*engine, *object, "moveMissionToFront", JsMissionManager::MoveMissionToFront); + BindNativeFunction(*engine, *object, "moveMissionToFront", JsMissionManager::MoveMissionToFront); return engine->CreateUndefined(); } } // namespace AbilityRuntime diff --git a/interfaces/kits/napi/aafwk/particleAbility/particle_ability.cpp b/interfaces/kits/napi/aafwk/particleAbility/particle_ability.cpp index aa4f8065c8d..c5dd1ae82d3 100644 --- a/interfaces/kits/napi/aafwk/particleAbility/particle_ability.cpp +++ b/interfaces/kits/napi/aafwk/particleAbility/particle_ability.cpp @@ -182,34 +182,6 @@ napi_value NAPI_PAAcquireDataAbilityHelper(napi_env env, napi_callback_info info return NAPI_AcquireDataAbilityHelperCommon(env, info, AbilityType::UNKNOWN); } -/** - * @brief ParticleAbility NAPI method : startBackgroundRunning. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_PAStartBackgroundRunning(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - return NAPI_StartBackgroundRunningCommon(env, info); -} - -/** - * @brief ParticleAbility NAPI method : cancelBackgroundRunning. - * - * @param env The environment that the Node-API call is invoked under. - * @param info The callback info passed into the callback function. - * - * @return The return value from NAPI C++ to JS for the module. - */ -napi_value NAPI_PACancelBackgroundRunning(napi_env env, napi_callback_info info) -{ - HILOG_INFO("%{public}s,called", __func__); - return NAPI_CancelBackgroundRunningCommon(env, info); -} - /** * @brief ParticleAbility NAPI module registration. * @@ -233,8 +205,6 @@ napi_value ParticleAbilityInit(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("connectAbility", NAPI_PAConnectAbility), DECLARE_NAPI_FUNCTION("disconnectAbility", NAPI_PADisConnectAbility), DECLARE_NAPI_FUNCTION("acquireDataAbilityHelper", NAPI_PAAcquireDataAbilityHelper), - DECLARE_NAPI_FUNCTION("startBackgroundRunning", NAPI_PAStartBackgroundRunning), - DECLARE_NAPI_FUNCTION("cancelBackgroundRunning", NAPI_PACancelBackgroundRunning), }; napi_define_properties(env, exports, sizeof(properties) / sizeof(properties[0]), properties); diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index 79f078b1c1e..18ad4c0f89a 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -519,7 +519,7 @@ public: virtual void NotifyCompleteContinuation(const std::string &deviceId, int32_t sessionId, bool isSuccess) override; - virtual int NotifyContinuationResult(int32_t missionId, int32_t result) override; + virtual int NotifyContinuationResult(int32_t missionId, const int32_t result) override; virtual int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override; @@ -544,9 +544,7 @@ public: virtual int CleanAllMissions() override; virtual int MoveMissionToFront(int32_t missionId) override; - - virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override; - + /** * Start Ability, connect session with common ability. * @@ -657,7 +655,7 @@ public: * @param pid The not response process ID. */ virtual bool SendANRProcessID(int pid) override; - + private: template int GetParcelableInfos(MessageParcel &reply, std::vector &parcelableInfos); diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index 212db26fad7..925610fa4e9 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -215,7 +215,7 @@ public: * @param result, continuation result. * @return Returns ERR_OK on success, others on failure. */ - virtual int NotifyContinuationResult(int32_t missionId, int32_t result) override; + virtual int NotifyContinuationResult(int32_t missionId, const int32_t result) override; /** * RegisterMissionListener, register remote device mission listener. @@ -659,8 +659,6 @@ public: virtual int MoveMissionToFront(int32_t missionId) override; - virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override; - virtual int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override; virtual int StopSyncRemoteMissions(const std::string& devId) override; @@ -1109,8 +1107,6 @@ private: int DelegatorMoveMissionToFront(int32_t missionId); - void StartupResidentProcess(); - using DumpFuncType = void (AbilityManagerService::*)(const std::string &args, std::vector &info); std::map dumpFuncMap_; diff --git a/services/abilitymgr/include/ability_manager_stub.h b/services/abilitymgr/include/ability_manager_stub.h index 448a262cf09..08bacb824ca 100644 --- a/services/abilitymgr/include/ability_manager_stub.h +++ b/services/abilitymgr/include/ability_manager_stub.h @@ -142,7 +142,7 @@ private: int CleanMissionInner(MessageParcel &data, MessageParcel &reply); int CleanAllMissionsInner(MessageParcel &data, MessageParcel &reply); int MoveMissionToFrontInner(MessageParcel &data, MessageParcel &reply); - + // for new version ability (call ability) int StartAbilityByCallInner(MessageParcel &data, MessageParcel &reply); int ReleaseInner(MessageParcel &data, MessageParcel &reply); @@ -170,7 +170,6 @@ private: int DoAbilityBackgroundInner(MessageParcel &data, MessageParcel &reply); int IsRunningInStabilityTestInner(MessageParcel &data, MessageParcel &reply); - int MoveMissionToFrontByOptionsInner(MessageParcel &data, MessageParcel &reply); using RequestFuncType = int (AbilityManagerStub::*)(MessageParcel &data, MessageParcel &reply); std::map requestFuncMap_; diff --git a/services/abilitymgr/include/ability_record.h b/services/abilitymgr/include/ability_record.h index 78633a38fd5..1753d77f382 100644 --- a/services/abilitymgr/include/ability_record.h +++ b/services/abilitymgr/include/ability_record.h @@ -670,7 +670,7 @@ public: * dump ability state info. * */ - void DumpAbilityState(std::vector &info, bool isClient, const std::vector ¶ms); + void DumpAbilityState(std::vector &info, bool isClient); void SetStartTime(); @@ -755,7 +755,7 @@ public: void SetLaunchReason(const LaunchReason &reason); void SetLastExitReason(const LastExitReason &reason); void ContinueAbility(const std::string& deviceId); - void NotifyContinuationResult(int32_t result); + void NotifyContinuationResult(const int32_t result); std::shared_ptr GetOwnedMissionList() const; void SetUseNewMission(); diff --git a/services/abilitymgr/include/ability_scheduler_proxy.h b/services/abilitymgr/include/ability_scheduler_proxy.h index 26e93b3e80d..7b505783d67 100644 --- a/services/abilitymgr/include/ability_scheduler_proxy.h +++ b/services/abilitymgr/include/ability_scheduler_proxy.h @@ -297,7 +297,7 @@ public: * @param The continuation result. * @return */ - void NotifyContinuationResult(int32_t result) override; + void NotifyContinuationResult(const int32_t result) override; /** * Dump Ability Runner info. @@ -305,7 +305,7 @@ public: * @param * @return Ability Runner info. */ - void DumpAbilityInfo(const std::vector ¶ms, std::vector &info) override; + void DumpAbilityInfo(std::vector &info) override; sptr CallRequest() override; private: diff --git a/services/abilitymgr/include/lifecycle_deal.h b/services/abilitymgr/include/lifecycle_deal.h index 2d894433ff1..dfca7756eda 100644 --- a/services/abilitymgr/include/lifecycle_deal.h +++ b/services/abilitymgr/include/lifecycle_deal.h @@ -58,7 +58,7 @@ public: void ForegroundNew(const Want &want, LifeCycleStateInfo &stateInfo); void BackgroundNew(const Want &want, LifeCycleStateInfo &stateInfo); void ContinueAbility(const std::string& deviceId); - void NotifyContinuationResult(int32_t result); + void NotifyContinuationResult(const int32_t result); private: sptr GetScheduler(); diff --git a/services/abilitymgr/include/mission_list.h b/services/abilitymgr/include/mission_list.h index 30b4140bdcc..ca093f4dca8 100644 --- a/services/abilitymgr/include/mission_list.h +++ b/services/abilitymgr/include/mission_list.h @@ -174,9 +174,7 @@ public: * @param info dump result. */ void DumpList(std::vector &info, bool isClient); - - void DumpStateByRecordId( - std::vector &info, bool isClient, int32_t abilityRecordId, const std::vector ¶ms); + void DumpStateByRecordId(std::vector &info, bool isClient, int32_t abilityRecordId); std::shared_ptr GetMissionBySpecifiedFlag(const std::string &flag) const; private: diff --git a/services/abilitymgr/include/mission_list_manager.h b/services/abilitymgr/include/mission_list_manager.h index 191b986b813..650085f7f87 100644 --- a/services/abilitymgr/include/mission_list_manager.h +++ b/services/abilitymgr/include/mission_list_manager.h @@ -27,7 +27,6 @@ #include "mission_info.h" #include "mission_snapshot.h" #include "snapshot.h" -#include "start_options.h" #include "want.h" namespace OHOS { @@ -68,10 +67,9 @@ public: int GetMissionInfo(int32_t missionId, MissionInfo &missionInfo); - int MoveMissionToFront(int32_t missionId, std::shared_ptr startOptions = nullptr); + int MoveMissionToFront(int32_t missionId); - int MoveMissionToFront(int32_t missionId, bool isCallerFromLauncher, - std::shared_ptr startOptions = nullptr); + int MoveMissionToFront(int32_t missionId, bool isCallerFromLauncher); /** * OnAbilityRequestDone, app manager service call this interface after ability request done. @@ -264,14 +262,7 @@ public: */ void DumpMissionList(std::vector &info, bool isClient, const std::string &args = ""); - /** - * @brief dump mission list by id with params - * - * @param info dump result. - * @param params dump params. - */ - void DumpMissionListByRecordId( - std::vector& info, bool isClient, int32_t abilityRecordId, const std::vector& params); + void DumpMissionListByRecordId(std::vector &info, bool isClient, int32_t abilityRecordId); /** * @brief dump mission by id @@ -303,6 +294,7 @@ public: * @param element, target ability name. */ int ReleaseLocked(const sptr &connect, const AppExecFwk::ElementName &element); + /** * @brief register snapshotHandler * @param handler the snapshotHandler diff --git a/services/abilitymgr/src/ability_manager_client.cpp b/services/abilitymgr/src/ability_manager_client.cpp index bf217771d14..ec19bb5290a 100644 --- a/services/abilitymgr/src/ability_manager_client.cpp +++ b/services/abilitymgr/src/ability_manager_client.cpp @@ -772,14 +772,6 @@ ErrCode AbilityManagerClient::MoveMissionToFront(int32_t missionId) return abms->MoveMissionToFront(missionId); } -ErrCode AbilityManagerClient::MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) -{ - CHECK_REMOTE_OBJECT_AND_RETURN(remoteObject_, ABILITY_SERVICE_NOT_CONNECTED); - - sptr abms = iface_cast(remoteObject_); - return abms->MoveMissionToFront(missionId, startOptions); -} - ErrCode AbilityManagerClient::StartAbilityByCall( const Want &want, const sptr &connect, const sptr &callToken) { @@ -932,14 +924,5 @@ ErrCode AbilityManagerClient::DoAbilityBackground(const sptr &tok sptr abms = iface_cast(remoteObject_); return abms->DoAbilityBackground(token, flag); } - -ErrCode AbilityManagerClient::SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) -{ - CHECK_REMOTE_OBJECT_AND_RETURN(remoteObject_, ABILITY_SERVICE_NOT_CONNECTED); - - sptr abms = iface_cast(remoteObject_); - return abms->SetAbilityController(abilityController, imAStabilityTest); -} } // namespace AAFwk } // namespace AAFwk diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index 14980e30031..86db7a562d3 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -1721,7 +1721,7 @@ void AbilityManagerProxy::NotifyCompleteContinuation(const std::string &deviceId } } -int AbilityManagerProxy::NotifyContinuationResult(int32_t missionId, int32_t result) +int AbilityManagerProxy::NotifyContinuationResult(int32_t missionId, const int32_t result) { MessageParcel data; MessageParcel reply; @@ -1996,32 +1996,6 @@ int AbilityManagerProxy::MoveMissionToFront(int32_t missionId) return reply.ReadInt32(); } -int AbilityManagerProxy::MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) -{ - int error; - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return INNER_ERR; - } - if (!data.WriteInt32(missionId)) { - HILOG_ERROR("move mission to front , WriteInt32 fail."); - return ERR_INVALID_VALUE; - } - if (!data.WriteParcelable(&startOptions)) { - HILOG_ERROR("startOptions write failed."); - return INNER_ERR; - } - error = Remote()->SendRequest(IAbilityManager::MOVE_MISSION_TO_FRONT_BY_OPTIONS, data, reply, option); - if (error != NO_ERROR) { - HILOG_ERROR("move mission to front, SendRequest error: %d", error); - return error; - } - return reply.ReadInt32(); -} - int AbilityManagerProxy::StartUser(int userId) { int error; diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 55b4fdf9727..f3f806dacc3 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -288,6 +288,10 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr &connect) @@ -1011,15 +1023,13 @@ int AbilityManagerService::StartContinuation(const Want &want, const sptrMoveMissionToFront(missionId); } -int AbilityManagerService::MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) -{ - HILOG_INFO("request MoveMissionToFront, missionId:%{public}d", missionId); - CHECK_POINTER_AND_RETURN(currentMissionListManager_, ERR_NO_INIT); - CHECK_POINTER_AND_RETURN(iBundleManager_, ERR_NO_INIT); - - if (!CheckCallerIsSystemAppByIpc()) { - HILOG_ERROR("caller is not system app"); - return CALLER_ISNOT_SYSTEMAPP; - } - - auto options = std::make_shared(startOptions); - return currentMissionListManager_->MoveMissionToFront(missionId, options); -} - std::shared_ptr AbilityManagerService::GetServiceRecordByElementName(const std::string &element) { return connectManager_->GetServiceRecordByElementName(element); @@ -1506,6 +1501,10 @@ sptr AbilityManagerService::AcquireDataAbility( abilityRequest.appInfo.bundleName.c_str(), abilityRequest.abilityInfo.name.c_str()); + if (CheckStaticCfgPermission(abilityRequest.abilityInfo) != ERR_OK) { + return nullptr; + } + CHECK_POINTER_AND_RETURN(dataAbilityManager_, nullptr); return dataAbilityManager_->Acquire(abilityRequest, tryBind, callerToken, isSystem); } @@ -1700,10 +1699,9 @@ void AbilityManagerService::DumpSysAbilityInner( if (argList.empty()) { return; } - if (argList.size() >= MIN_DUMP_ARGUMENT_NUM) { + if (argList.size() == MIN_DUMP_ARGUMENT_NUM) { HILOG_INFO("argList = %{public}s", argList[1].c_str()); - std::vector params(argList.begin() + MIN_DUMP_ARGUMENT_NUM, argList.end()); - targetManager->DumpMissionListByRecordId(info, isClient, std::stoi(argList[1]), params); + targetManager->DumpMissionListByRecordId(info, isClient, std::stoi(argList[1])); } else { info.emplace_back("error: invalid argument, please see 'ability dumpsys -h'."); } @@ -3216,7 +3214,8 @@ void AbilityManagerService::StartSystemApplication() StartingSystemUiAbility(); - StartupResidentProcess(); + // Location may change + DelayedSingleton::GetInstance()->StartupResidentProcess(); } void AbilityManagerService::StartingSystemUiAbility() @@ -4260,25 +4259,24 @@ int AbilityManagerService::CheckStaticCfgPermission(AppExecFwk::AbilityInfo &abi abilityInfo.extensionAbilityType == AppExecFwk::ExtensionAbilityType::DATASHARE) || (abilityInfo.type == AppExecFwk::AbilityType::DATA)) { // just need check the read permission and write permission of extension ability or data ability - if (!abilityInfo.readPermission.empty()) { - int checkReadPermission = AccessTokenKit::VerifyAccessToken(tokenId, abilityInfo.readPermission); - if (checkReadPermission == ERR_OK) { - return AppExecFwk::Constants::PERMISSION_GRANTED; - } - HILOG_WARN("verify access token fail, read permission: %{public}s", abilityInfo.readPermission.c_str()); + if (!abilityInfo.readPermission.empty() && + AccessTokenKit::VerifyAccessToken(tokenId, abilityInfo.readPermission) + != AppExecFwk::Constants::PERMISSION_GRANTED) { + HILOG_ERROR("verify access token failed, read permission: %{public}s", + abilityInfo.readPermission.c_str()); + return AppExecFwk::Constants::PERMISSION_NOT_GRANTED; } - if (!abilityInfo.writePermission.empty()) { - int checkWritePermission = AccessTokenKit::VerifyAccessToken(tokenId, abilityInfo.writePermission); - if (checkWritePermission == ERR_OK) { - return AppExecFwk::Constants::PERMISSION_GRANTED; - } - HILOG_WARN("verify access token fail, write permission: %{public}s", abilityInfo.writePermission.c_str()); + if (!abilityInfo.writePermission.empty() && + AccessTokenKit::VerifyAccessToken(tokenId, abilityInfo.writePermission) + != AppExecFwk::Constants::PERMISSION_GRANTED) { + HILOG_ERROR("verify access token failed, write permission: %{public}s", + abilityInfo.writePermission.c_str()); + return AppExecFwk::Constants::PERMISSION_NOT_GRANTED; } - if (!abilityInfo.readPermission.empty() || !abilityInfo.writePermission.empty()) { // 'readPermission' and 'writePermission' take precedence over 'permission' // when 'readPermission' or 'writePermission' is not empty, no need check 'permission' - return AppExecFwk::Constants::PERMISSION_NOT_GRANTED; + return ERR_OK; } } @@ -4290,31 +4288,12 @@ int AbilityManagerService::CheckStaticCfgPermission(AppExecFwk::AbilityInfo &abi for (auto permission : abilityInfo.permissions) { if (AccessTokenKit::VerifyAccessToken(tokenId, permission) != AppExecFwk::Constants::PERMISSION_GRANTED) { - HILOG_ERROR("verify access token fail, permission: %{public}s", permission.c_str()); + HILOG_ERROR("verify access token failed, permission: %{public}s", permission.c_str()); return AppExecFwk::Constants::PERMISSION_NOT_GRANTED; } } return ERR_OK; } - -void AbilityManagerService::StartupResidentProcess() -{ - // Location may change - std::vector bundleInfos; - (void)iBundleManager_->QueryKeepAliveBundleInfos(bundleInfos); - for (auto bundleInfo : bundleInfos) { - for (auto hapModuleInfo : bundleInfo.hapModuleInfos) { - if (!hapModuleInfo.mainElementName.empty()) { - AppExecFwk::AbilityInfo abilityInfo; - Want want; - want.SetElementName(hapModuleInfo.bundleName, hapModuleInfo.mainElementName); - (void)StartAbility(want, USER_ID_NO_HEAD, DEFAULT_INVAL_VALUE); // user 0 - } - } - } - - DelayedSingleton::GetInstance()->StartupResidentProcess(); -} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index 6d679b09bd3..d9088839c36 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -125,7 +125,6 @@ void AbilityManagerStub::SecondStepInit() requestFuncMap_[CLEAN_MISSION] = &AbilityManagerStub::CleanMissionInner; requestFuncMap_[CLEAN_ALL_MISSIONS] = &AbilityManagerStub::CleanAllMissionsInner; requestFuncMap_[MOVE_MISSION_TO_FRONT] = &AbilityManagerStub::MoveMissionToFrontInner; - requestFuncMap_[MOVE_MISSION_TO_FRONT_BY_OPTIONS] = &AbilityManagerStub::MoveMissionToFrontByOptionsInner; requestFuncMap_[START_CALL_ABILITY] = &AbilityManagerStub::StartAbilityByCallInner; requestFuncMap_[RELEASE_CALL_ABILITY] = &AbilityManagerStub::ReleaseInner; requestFuncMap_[SET_MISSION_LABEL] = &AbilityManagerStub::SetMissionLabelInner; @@ -1149,25 +1148,9 @@ int AbilityManagerStub::MoveMissionToFrontInner(MessageParcel &data, MessageParc return NO_ERROR; } -int AbilityManagerStub::MoveMissionToFrontByOptionsInner(MessageParcel &data, MessageParcel &reply) -{ - int32_t missionId = data.ReadInt32(); - StartOptions *startOptions = data.ReadParcelable(); - if (startOptions == nullptr) { - HILOG_ERROR("startOptions is nullptr"); - return ERR_INVALID_VALUE; - } - int result = MoveMissionToFront(missionId, *startOptions); - if (!reply.WriteInt32(result)) { - HILOG_ERROR("MoveMissionToFront failed."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - int AbilityManagerStub::StartAbilityByCallInner(MessageParcel &data, MessageParcel &reply) { - + HILOG_DEBUG("AbilityManagerStub::StartAbilityByCallInner begin."); Want *want = data.ReadParcelable(); if (want == nullptr) { @@ -1183,7 +1166,7 @@ int AbilityManagerStub::StartAbilityByCallInner(MessageParcel &data, MessageParc reply.WriteInt32(result); delete want; - + HILOG_DEBUG("AbilityManagerStub::StartAbilityByCallInner end."); return NO_ERROR; diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index 1c398aea0b9..90c73efb5bd 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -922,8 +922,7 @@ void AbilityRecord::Dump(std::vector &info) } } -void AbilityRecord::DumpAbilityState( - std::vector &info, bool isClient, const std::vector ¶ms) +void AbilityRecord::DumpAbilityState(std::vector &info, bool isClient) { HILOG_INFO("%{public}s begin.", __func__); std::string dumpInfo = " AbilityRecord ID #" + std::to_string(recordId_); @@ -955,10 +954,7 @@ void AbilityRecord::DumpAbilityState( // add dump client info if (isClient && scheduler_ && isReady_) { - scheduler_->DumpAbilityInfo(params, info); - if (!params.empty()) { - return; - } + scheduler_->DumpAbilityInfo(info); AppExecFwk::Configuration config; if (DelayedSingleton::GetInstance()->GetConfiguration(config) == ERR_OK) { info.emplace_back(" configuration: " + config.GetName()); @@ -996,8 +992,7 @@ void AbilityRecord::DumpService(std::vector &info, bool isClient) c } // add dump client info if (isClient && scheduler_ && isReady_) { - std::vector params; - scheduler_->DumpAbilityInfo(params, info); + scheduler_->DumpAbilityInfo(info); AppExecFwk::Configuration config; if (DelayedSingleton::GetInstance()->GetConfiguration(config) == ERR_OK) { info.emplace_back(" configuration: " + config.GetName()); @@ -1297,7 +1292,7 @@ void AbilityRecord::SetLastExitReason(const LastExitReason &reason) lifeCycleStateInfo_.launchParam.lastExitReason = reason; } -void AbilityRecord::NotifyContinuationResult(int32_t result) +void AbilityRecord::NotifyContinuationResult(const int32_t result) { HILOG_INFO("NotifyContinuationResult."); CHECK_POINTER(lifecycleDeal_); diff --git a/services/abilitymgr/src/ability_scheduler_proxy.cpp b/services/abilitymgr/src/ability_scheduler_proxy.cpp index bdf34a06b6f..c95d108a3ee 100755 --- a/services/abilitymgr/src/ability_scheduler_proxy.cpp +++ b/services/abilitymgr/src/ability_scheduler_proxy.cpp @@ -981,7 +981,7 @@ void AbilitySchedulerProxy::NotifyContinuationResult(int32_t result) } } -void AbilitySchedulerProxy::DumpAbilityInfo(const std::vector ¶ms, std::vector &info) +void AbilitySchedulerProxy::DumpAbilityInfo(std::vector &info) { MessageParcel data; MessageParcel reply; @@ -991,11 +991,6 @@ void AbilitySchedulerProxy::DumpAbilityInfo(const std::vector ¶ return; } - if (!data.WriteStringVector(params)) { - HILOG_ERROR("DumpAbilityRunner fail to write params"); - return; - } - int32_t err = Remote()->SendRequest(IAbilityScheduler::DUMP_ABILITY_RUNNER_INNER, data, reply, option); if (err != NO_ERROR) { HILOG_ERROR("DumpAbilityRunner fail to SendRequest. err: %d", err); diff --git a/services/abilitymgr/src/ability_scheduler_stub.cpp b/services/abilitymgr/src/ability_scheduler_stub.cpp index 89e19940414..e72008a219a 100644 --- a/services/abilitymgr/src/ability_scheduler_stub.cpp +++ b/services/abilitymgr/src/ability_scheduler_stub.cpp @@ -580,13 +580,10 @@ int AbilitySchedulerStub::NotifyContinuationResultInner(MessageParcel &data, Mes int AbilitySchedulerStub::DumpAbilityInfoInner(MessageParcel &data, MessageParcel &reply) { + std::vector infos; - std::vector params; - if (!data.ReadStringVector(¶ms)) { - HILOG_INFO("DumpAbilityInfoInner read params error"); - return NO_ERROR; - } - DumpAbilityInfo(params, infos); + + DumpAbilityInfo(infos); for (const auto & infostep:infos) { HILOG_INFO("DumpAbilityInfoInner infos = %{public}s", infostep.c_str()); diff --git a/services/abilitymgr/src/lifecycle_deal.cpp b/services/abilitymgr/src/lifecycle_deal.cpp index 2ab80063fdc..3e5160e9f9a 100755 --- a/services/abilitymgr/src/lifecycle_deal.cpp +++ b/services/abilitymgr/src/lifecycle_deal.cpp @@ -160,7 +160,7 @@ void LifecycleDeal::ContinueAbility(const std::string& deviceId) abilityScheduler_->ContinueAbility(deviceId); } -void LifecycleDeal::NotifyContinuationResult(int32_t result) +void LifecycleDeal::NotifyContinuationResult(const int32_t result) { HILOG_INFO("NotifyContinuationResult."); auto abilityScheduler = GetScheduler(); diff --git a/services/abilitymgr/src/mission_list.cpp b/services/abilitymgr/src/mission_list.cpp index 24e621a6808..439df45cef9 100644 --- a/services/abilitymgr/src/mission_list.cpp +++ b/services/abilitymgr/src/mission_list.cpp @@ -264,8 +264,7 @@ void MissionList::Dump(std::vector& info) } } -void MissionList::DumpStateByRecordId( - std::vector &info, bool isClient, int32_t abilityRecordId, const std::vector ¶ms) +void MissionList::DumpStateByRecordId(std::vector &info, bool isClient, int32_t abilityRecordId) { for (const auto& mission : missions_) { if (mission) { @@ -273,7 +272,7 @@ void MissionList::DumpStateByRecordId( if (abilityRecord) { if (abilityRecord->GetRecordId() == abilityRecordId) { HILOG_INFO("record begain to call DumpAbilityState %{public}s", __func__); - abilityRecord->DumpAbilityState(info, isClient, params); + abilityRecord->DumpAbilityState(info, isClient); return; } } @@ -295,8 +294,7 @@ void MissionList::DumpList(std::vector &info, bool isClient) auto abilityRecord = mission->GetAbilityRecord(); if (abilityRecord) { HILOG_INFO("record begain to call DumpAbilityState %{public}s", __func__); - std::vector params; - abilityRecord->DumpAbilityState(info, isClient, params); + abilityRecord->DumpAbilityState(info, isClient); } } } diff --git a/services/abilitymgr/src/mission_list_manager.cpp b/services/abilitymgr/src/mission_list_manager.cpp index 198261ccc02..4447b96782c 100644 --- a/services/abilitymgr/src/mission_list_manager.cpp +++ b/services/abilitymgr/src/mission_list_manager.cpp @@ -145,14 +145,13 @@ int MissionListManager::GetMissionInfo(int32_t missionId, MissionInfo &missionIn return DelayedSingleton::GetInstance()->GetMissionInfoById(missionId, missionInfo); } -int MissionListManager::MoveMissionToFront(int32_t missionId, std::shared_ptr startOptions) +int MissionListManager::MoveMissionToFront(int32_t missionId) { std::lock_guard guard(managerLock_); - return MoveMissionToFront(missionId, true, startOptions); + return MoveMissionToFront(missionId, true); } -int MissionListManager::MoveMissionToFront(int32_t missionId, bool isCallerFromLauncher, - std::shared_ptr startOptions) +int MissionListManager::MoveMissionToFront(int32_t missionId, bool isCallerFromLauncher) { HILOG_INFO("move mission to front:%{public}d.", missionId); std::lock_guard guard(managerLock_); @@ -178,11 +177,7 @@ int MissionListManager::MoveMissionToFront(int32_t missionId, bool isCallerFromL HILOG_ERROR("get target ability record failed, missionId: %{public}d", missionId); return MOVE_MISSION_FAILED; } - if (startOptions != nullptr) { - Want want(targetAbilityRecord->GetWant()); - want.SetParam(Want::PARAM_RESV_WINDOW_MODE, startOptions->GetWindowMode()); - targetAbilityRecord->SetWant(want); - } + // schedule target ability to foreground. targetAbilityRecord->ProcessForegroundAbility(); HILOG_DEBUG("SetMovingState, missionId: %{public}d", missionId); @@ -1579,7 +1574,7 @@ void MissionListManager::Dump(std::vector &info) } void MissionListManager::DumpMissionListByRecordId( - std::vector &info, bool isClient, int32_t abilityRecordId, const std::vector ¶ms) + std::vector &info, bool isClient, int32_t abilityRecordId) { std::lock_guard guard(managerLock_); std::string dumpInfo = "User ID #" + std::to_string(userId_); @@ -1587,23 +1582,23 @@ void MissionListManager::DumpMissionListByRecordId( for (const auto& missionList : currentMissionLists_) { if (missionList && missionList != launcherList_) { HILOG_INFO("missionList begain to call DumpMissionListByRecordId %{public}s", __func__); - missionList->DumpStateByRecordId(info, isClient, abilityRecordId, params); + missionList->DumpStateByRecordId(info, isClient, abilityRecordId); } } if (defaultStandardList_) { HILOG_INFO("defaultStandardList begain to call DumpMissionListByRecordId %{public}s", __func__); - defaultStandardList_->DumpStateByRecordId(info, isClient, abilityRecordId, params); + defaultStandardList_->DumpStateByRecordId(info, isClient, abilityRecordId); } if (defaultSingleList_) { HILOG_INFO("defaultSingleList begain to call DumpMissionListByRecordId %{public}s", __func__); - defaultSingleList_->DumpStateByRecordId(info, isClient, abilityRecordId, params); + defaultSingleList_->DumpStateByRecordId(info, isClient, abilityRecordId); } if (launcherList_) { HILOG_INFO("launcherList begain to call DumpMissionListByRecordId %{public}s", __func__); - launcherList_->DumpStateByRecordId(info, isClient, abilityRecordId, params); + launcherList_->DumpStateByRecordId(info, isClient, abilityRecordId); } } void MissionListManager::DumpMissionList(std::vector &info, bool isClient, const std::string &args) diff --git a/services/abilitymgr/src/pending_want_manager.cpp b/services/abilitymgr/src/pending_want_manager.cpp index 22f19601b8c..f7461d333c9 100644 --- a/services/abilitymgr/src/pending_want_manager.cpp +++ b/services/abilitymgr/src/pending_want_manager.cpp @@ -235,8 +235,7 @@ int32_t PendingWantManager::DeviceIdDetermine( return result; } DistributedClient dmsClient; - uint32_t accessToken = IPCSkeleton::GetCallingTokenID(); - result = dmsClient.StartRemoteAbility(want, callerUid, requestCode, accessToken); + result = dmsClient.StartRemoteAbility(want, callerUid, requestCode); if (result != ERR_OK) { HILOG_ERROR("%{public}s: StartRemoteAbility Error! result = %{public}d", __func__, result); } diff --git a/services/abilitymgr/src/start_options.cpp b/services/abilitymgr/src/start_options.cpp index 0ec49ac7681..20eb4bfd33a 100644 --- a/services/abilitymgr/src/start_options.cpp +++ b/services/abilitymgr/src/start_options.cpp @@ -20,21 +20,6 @@ namespace AAFwk { const std::string StartOptions::STRING_DISPLAY_ID = "ohos.aafwk.displayId"; -StartOptions::StartOptions(const StartOptions &other) -{ - windowMode_ = other.windowMode_; - displayId_ = other.displayId_; -} - -StartOptions &StartOptions::operator=(const StartOptions &other) -{ - if (this != &other) { - windowMode_ = other.windowMode_; - displayId_ = other.displayId_; - } - return *this; -} - bool StartOptions::ReadFromParcel(Parcel &parcel) { SetWindowMode(parcel.ReadInt32()); diff --git a/services/abilitymgr/test/mock/libs/aakit/include/ability_scheduler.h b/services/abilitymgr/test/mock/libs/aakit/include/ability_scheduler.h index bc9551997f3..03bb8e5c183 100755 --- a/services/abilitymgr/test/mock/libs/aakit/include/ability_scheduler.h +++ b/services/abilitymgr/test/mock/libs/aakit/include/ability_scheduler.h @@ -97,11 +97,11 @@ public: { return std::vector>(); }; - virtual void NotifyContinuationResult(int32_t result) override + virtual void NotifyContinuationResult(const int32_t result) override {}; virtual void ContinueAbility(const std::string& deviceId) override {}; - virtual void DumpAbilityInfo(const std::vector ¶ms, std::vector &info) override + virtual void DumpAbilityInfo(std::vector &info) override {}; virtual sptr CallRequest() override { diff --git a/services/abilitymgr/test/mock/libs/ability_scheduler_mock/ability_scheduler_mock.h b/services/abilitymgr/test/mock/libs/ability_scheduler_mock/ability_scheduler_mock.h index ec5ea8943c5..34bcf6228f5 100755 --- a/services/abilitymgr/test/mock/libs/ability_scheduler_mock/ability_scheduler_mock.h +++ b/services/abilitymgr/test/mock/libs/ability_scheduler_mock/ability_scheduler_mock.h @@ -41,9 +41,9 @@ public: MOCK_METHOD3(ScheduleCommandAbility, void(const Want &, bool, int)); MOCK_METHOD1(NotifyTopActiveAbilityChanged, void(bool flag)); MOCK_METHOD2(NotifyMultiWinModeChanged, void(int32_t winModeKey, bool flag)); - MOCK_METHOD1(NotifyContinuationResult, void(int32_t result)); + MOCK_METHOD1(NotifyContinuationResult, void(const int32_t result)); MOCK_METHOD1(ContinueAbility, void(const std::string& deviceId)); - MOCK_METHOD2(DumpAbilityInfo, void(const std::vector ¶ms, std::vector &info)); + MOCK_METHOD1(DumpAbilityInfo, void(std::vector &info)); int InvokeSendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { @@ -150,4 +150,4 @@ public: int code_ = 0; }; } // namespace AAFwk -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/test/mock/libs/appexecfwk_core/include/bundlemgr/mock_bundle_manager.h b/services/abilitymgr/test/mock/libs/appexecfwk_core/include/bundlemgr/mock_bundle_manager.h index 9f26de66177..79b09256f74 100644 --- a/services/abilitymgr/test/mock/libs/appexecfwk_core/include/bundlemgr/mock_bundle_manager.h +++ b/services/abilitymgr/test/mock/libs/appexecfwk_core/include/bundlemgr/mock_bundle_manager.h @@ -180,6 +180,8 @@ public: MOCK_METHOD1(HasSystemCapability, bool(const std::string &capName)); MOCK_METHOD1(GetSystemAvailableCapabilities, bool(std::vector &systemCaps)); MOCK_METHOD0(IsSafeMode, bool()); + MOCK_METHOD2(CleanBundleCacheFiles, + bool(const std::string &bundleName, const sptr &cleanCacheCallback)); MOCK_METHOD2(CleanBundleDataFiles, bool(const std::string &bundleName, const int userId)); MOCK_METHOD3(RequestPermissionFromUser, bool(const std::string &bundleName, const std::string &permission, const int userId)); @@ -189,6 +191,7 @@ public: MOCK_METHOD4( DumpInfos, bool(const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result)); MOCK_METHOD1(IsApplicationEnabled, bool(const std::string &bundleName)); + MOCK_METHOD2(SetApplicationEnabled, bool(const std::string &bundleName, bool isEnable)); MOCK_METHOD0(GetBundleInstaller, sptr()); MOCK_METHOD0(GetBundleUserMgr, sptr()); MOCK_METHOD2(GetAppIdByBundleName, std::string(const std::string &bundleName, const int userId)); @@ -197,6 +200,7 @@ public: MOCK_METHOD2(QueryAbilityInfos, bool(const Want &want, std::vector &abilityInfos)); MOCK_METHOD2(QueryAbilityInfosForClone, bool(const Want &want, std::vector &abilityInfos)); MOCK_METHOD1(IsAbilityEnabled, bool(const AbilityInfo &abilityInfo)); + MOCK_METHOD2(SetAbilityEnabled, bool(const AbilityInfo &abilityInfo, bool isEnabled)); MOCK_METHOD2(GetAbilityIcon, std::string(const std::string &bundleName, const std::string &className)); MOCK_METHOD3( CanRequestPermission, bool(const std::string &bundleName, const std::string &permissionName, const int userId)); @@ -260,11 +264,14 @@ public: MOCK_METHOD1(HasSystemCapability, bool(const std::string &capName)); MOCK_METHOD1(GetSystemAvailableCapabilities, bool(std::vector &systemCaps)); MOCK_METHOD0(IsSafeMode, bool()); + MOCK_METHOD2(CleanBundleCacheFiles, + bool(const std::string &bundleName, const sptr &cleanCacheCallback)); MOCK_METHOD2(CleanBundleDataFiles, bool(const std::string &bundleName, const int userId)); MOCK_METHOD3(RequestPermissionFromUser, bool(const std::string &bundleName, const std::string &permission, const int userId)); MOCK_METHOD1(RegisterBundleStatusCallback, bool(const sptr &bundleStatusCallback)); MOCK_METHOD1(ClearBundleStatusCallback, bool(const sptr &)); + MOCK_METHOD2(SetApplicationEnabled, bool(const std::string &bundleName, bool isEnable)); MOCK_METHOD0(GetBundleInstaller, sptr()); MOCK_METHOD0(GetBundleUserMgr, sptr()); MOCK_METHOD2(GetAppIdByBundleName, std::string(const std::string &bundleName, const int userId)); @@ -273,6 +280,7 @@ public: MOCK_METHOD2(QueryAbilityInfos, bool(const Want &want, std::vector &abilityInfos)); MOCK_METHOD2(QueryAbilityInfosForClone, bool(const Want &want, std::vector &abilityInfos)); MOCK_METHOD1(IsAbilityEnabled, bool(const AbilityInfo &abilityInfo)); + MOCK_METHOD2(SetAbilityEnabled, bool(const AbilityInfo &abilityInfo, bool isEnabled)); MOCK_METHOD2(GetAbilityIcon, std::string(const std::string &bundleName, const std::string &className)); MOCK_METHOD3( CanRequestPermission, bool(const std::string &bundleName, const std::string &permissionName, const int userId)); diff --git a/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/ability_manager_stub_mock.h b/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/ability_manager_stub_mock.h index d06f56e6423..bf6c9c53302 100644 --- a/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/ability_manager_stub_mock.h +++ b/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/ability_manager_stub_mock.h @@ -393,7 +393,7 @@ public: MOCK_METHOD2(GetPendingRequestWant, int(const sptr &target, std::shared_ptr &want)); MOCK_METHOD1(GetSystemMemoryAttr, void(AppExecFwk::SystemMemoryAttr &memoryInfo)); MOCK_METHOD3(StartContinuation, int(const Want &want, const sptr &abilityToken, int32_t status)); - MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); + MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, const int32_t result)); MOCK_METHOD5(ContinueMission, int(const std::string &srcDeviceId, const std::string &dstDeviceId, int32_t missionId, const sptr &callBack, AAFwk::WantParams &wantParams)); MOCK_METHOD2(ContinueAbility, int(const std::string &deviceId, int32_t missionId)); @@ -409,7 +409,6 @@ public: MOCK_METHOD1(CleanMission, int(int32_t missionId)); MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); - MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions &startOptions)); MOCK_METHOD2(SetMissionLabel, int(const sptr &token, const std::string &label)); MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector &info)); diff --git a/services/abilitymgr/test/unittest/phone/ability_manager_service_test/ability_manager_service_test.cpp b/services/abilitymgr/test/unittest/phone/ability_manager_service_test/ability_manager_service_test.cpp index 827759c8945..9afa0aa2423 100644 --- a/services/abilitymgr/test/unittest/phone/ability_manager_service_test/ability_manager_service_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_manager_service_test/ability_manager_service_test.cpp @@ -98,8 +98,8 @@ public: public: AbilityRequest abilityRequest_; + std::shared_ptr abilityMs_ {nullptr}; std::shared_ptr abilityRecord_ {nullptr}; - std::shared_ptr abilityMs_ = DelayedSingleton::GetInstance(); }; int AbilityManagerServiceTest::StartAbility(const Want &want) @@ -161,7 +161,9 @@ void AbilityManagerServiceTest::OnStartAms() void AbilityManagerServiceTest::OnStopAms() { - abilityMs_->OnStop(); + abilityMs_->eventLoop_.reset(); + abilityMs_->handler_.reset(); + abilityMs_->state_ = ServiceRunningState::STATE_NOT_START; } void AbilityManagerServiceTest::SetUpTestCase() @@ -177,6 +179,7 @@ void AbilityManagerServiceTest::TearDownTestCase() void AbilityManagerServiceTest::SetUp() { + abilityMs_ = OHOS::DelayedSingleton::GetInstance(); OnStartAms(); WaitUntilTaskFinished(); if (abilityRecord_ == nullptr) { @@ -185,11 +188,13 @@ void AbilityManagerServiceTest::SetUp() abilityRequest_.abilityInfo.type = AbilityType::DATA; abilityRecord_ = AbilityRecord::CreateAbilityRecord(abilityRequest_); } + } void AbilityManagerServiceTest::TearDown() { OnStopAms(); + OHOS::DelayedSingleton::DestroyInstance(); } /* diff --git a/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/ability_manager_stub_impl_mock.h b/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/ability_manager_stub_impl_mock.h index ea21028ca66..344172f5499 100644 --- a/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/ability_manager_stub_impl_mock.h +++ b/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/ability_manager_stub_impl_mock.h @@ -49,7 +49,7 @@ public: MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); MOCK_METHOD2(SetMissionLabel, int(const sptr &token, const std::string &label)); MOCK_METHOD3(StartContinuation, int(const Want &want, const sptr &abilityToken, int32_t status)); - MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); + MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, const int32_t result)); MOCK_METHOD5(ContinueMission, int(const std::string &srcDeviceId, const std::string &dstDeviceId, int32_t missionId, const sptr &callBack, AAFwk::WantParams &wantParams)); MOCK_METHOD2(ContinueAbility, int(const std::string &deviceId, int32_t missionId)); @@ -357,10 +357,6 @@ public: { return 0; } - virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override - { - return 0; - } virtual int GetMissionInfos(const std::string& deviceId, int32_t numMax, std::vector &missionInfos) override { diff --git a/services/abilitymgr/test/unittest/phone/ability_manager_test/ability_manager_stub_mock.h b/services/abilitymgr/test/unittest/phone/ability_manager_test/ability_manager_stub_mock.h index 2b6a3166749..c7af16c3182 100644 --- a/services/abilitymgr/test/unittest/phone/ability_manager_test/ability_manager_stub_mock.h +++ b/services/abilitymgr/test/unittest/phone/ability_manager_test/ability_manager_stub_mock.h @@ -124,7 +124,7 @@ public: return 0; } MOCK_METHOD3(StartContinuation, int(const Want &want, const sptr &abilityToken, int32_t status)); - MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); + MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, const int32_t result)); MOCK_METHOD5(ContinueMission, int(const std::string &srcDeviceId, const std::string &dstDeviceId, int32_t missionId, const sptr &callBack, AAFwk::WantParams &wantParams)); MOCK_METHOD2(ContinueAbility, int(const std::string &deviceId, int32_t missionId)); diff --git a/services/abilitymgr/test/unittest/phone/ability_scheduler_stub_test/ability_schedule_stub_mock.h b/services/abilitymgr/test/unittest/phone/ability_scheduler_stub_test/ability_schedule_stub_mock.h index ce061009455..a1a4ef18a98 100755 --- a/services/abilitymgr/test/unittest/phone/ability_scheduler_stub_test/ability_schedule_stub_mock.h +++ b/services/abilitymgr/test/unittest/phone/ability_scheduler_stub_test/ability_schedule_stub_mock.h @@ -129,11 +129,11 @@ public: { return std::vector>(); } - virtual void NotifyContinuationResult(int32_t result) override + virtual void NotifyContinuationResult(const int32_t result) override {} virtual void ContinueAbility(const std::string& deviceId) override {} - virtual void DumpAbilityInfo(const std::vector ¶ms, std::vector &info) override + virtual void DumpAbilityInfo(std::vector &info) override {} virtual sptr CallRequest() override { @@ -143,4 +143,4 @@ public: } // namespace AAFwk } // namespace OHOS -#endif +#endif \ No newline at end of file diff --git a/services/abilitymgr/test/unittest/phone/abilityms_appms_test/abilityms_appms_test.cpp b/services/abilitymgr/test/unittest/phone/abilityms_appms_test/abilityms_appms_test.cpp index a529e853178..2ea8b76aa7a 100644 --- a/services/abilitymgr/test/unittest/phone/abilityms_appms_test/abilityms_appms_test.cpp +++ b/services/abilitymgr/test/unittest/phone/abilityms_appms_test/abilityms_appms_test.cpp @@ -86,7 +86,8 @@ public: public: std::shared_ptr abilityRecord_ {nullptr}; - std::shared_ptr abilityMs_ = DelayedSingleton::GetInstance(); + std::shared_ptr callback_ {nullptr}; + std::shared_ptr abilityMs_ {nullptr}; }; void AbilityMsAppmsTest::OnStartabilityAms() @@ -134,20 +135,18 @@ void AbilityMsAppmsTest::OnStartabilityAms() } void AbilityMsAppmsTest::SetUpTestCase(void) -{ - DelayedSingleton::GetInstance()->RegisterSystemAbility( - OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID, new BundleMgrService()); - DelayedSingleton::GetInstance()->Init(std::make_shared()); -} - +{} void AbilityMsAppmsTest::TearDownTestCase(void) -{ - OHOS::DelayedSingleton::DestroyInstance(); - DelayedSingleton::DestroyInstance(); -} +{} void AbilityMsAppmsTest::SetUp(void) { + DelayedSingleton::GetInstance()->RegisterSystemAbility( + OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID, new BundleMgrService()); + DelayedSingleton::GetInstance(); + callback_ = std::make_shared(); + DelayedSingleton::GetInstance()->Init(callback_); + abilityMs_ = DelayedSingleton::GetInstance(); OnStartabilityAms(); StartAbility(); GTEST_LOG_(INFO) << "SetUp"; @@ -155,7 +154,8 @@ void AbilityMsAppmsTest::SetUp(void) void AbilityMsAppmsTest::TearDown(void) { - abilityMs_->OnStop(); + OHOS::DelayedSingleton::DestroyInstance(); + DelayedSingleton::DestroyInstance(); GTEST_LOG_(INFO) << "TearDown"; } diff --git a/services/abilitymgr/test/unittest/phone/lifecycle_test/lifecycle_test.cpp b/services/abilitymgr/test/unittest/phone/lifecycle_test/lifecycle_test.cpp index 26defef799b..4870fe569ab 100644 --- a/services/abilitymgr/test/unittest/phone/lifecycle_test/lifecycle_test.cpp +++ b/services/abilitymgr/test/unittest/phone/lifecycle_test/lifecycle_test.cpp @@ -80,7 +80,7 @@ public: public: int startLancherFlag_ = false; - std::shared_ptr abilityMs_ = OHOS::DelayedSingleton::GetInstance(); + std::shared_ptr abilityMs_ {nullptr}; std::shared_ptr launcherAbilityRecord_ {nullptr}; // launcher ability OHOS::sptr launcherToken_ {nullptr}; // token of launcher ability std::shared_ptr nextAbilityRecord_ {nullptr}; // ability being launched @@ -143,6 +143,7 @@ void LifecycleTest::TearDownTestCase(void) void LifecycleTest::SetUp(void) { + abilityMs_ = OHOS::DelayedSingleton::GetInstance(); OnStartabilityAms(); WaitUntilTaskFinished(); StartLauncherAbility(); @@ -151,7 +152,11 @@ void LifecycleTest::SetUp(void) void LifecycleTest::TearDown(void) { - abilityMs_->OnStop(); + abilityMs_->eventLoop_->Stop(); + abilityMs_->eventLoop_.reset(); + abilityMs_->handler_.reset(); + abilityMs_->state_ = ServiceRunningState::STATE_NOT_START; + OHOS::DelayedSingleton::DestroyInstance(); launcherAbilityRecord_.reset(); launcherToken_ = nullptr; nextAbilityRecord_.reset(); @@ -159,6 +164,7 @@ void LifecycleTest::TearDown(void) launcherScheduler_ = nullptr; nextScheduler_ = nullptr; command_.reset(); + abilityMs_ = nullptr; startLancherFlag_ = false; } diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 6d38e4a0c07..a80d7d69f66 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -208,7 +208,7 @@ public: * * @return ERR_OK, return back success, others fail. */ - virtual int32_t KillApplication(const std::string &bundleName); + virtual int32_t KillApplication(const std::string &bundleName, int32_t callerUid); /** * KillApplicationByUid, call KillApplicationByUid() through proxy object, kill the application. diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index 90019d2fbe1..5c08b91c718 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -193,7 +193,9 @@ int32_t AmsMgrScheduler::KillApplication(const std::string &bundleName) if (!IsReady()) { return ERR_INVALID_OPERATION; } - return amsMgrServiceInner_->KillApplication(bundleName); + + int32_t callerUid = IPCSkeleton::GetCallingUid(); + return amsMgrServiceInner_->KillApplication(bundleName, callerUid); } int32_t AmsMgrScheduler::KillApplicationByUid(const std::string &bundleName, const int uid) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 659ac291268..88ce4b1e1cd 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -341,18 +341,29 @@ void AppMgrServiceInner::ApplicationTerminated(const int32_t recordId) APP_LOGI("application is terminated"); } -int32_t AppMgrServiceInner::KillApplication(const std::string &bundleName) +int32_t AppMgrServiceInner::KillApplication(const std::string &bundleName, int32_t callerUid) { if (!appRunningManager_) { APP_LOGE("appRunningManager_ is nullptr"); return ERR_NO_INIT; } + auto userId = GetUserIdByUid(callerUid); + APP_LOGI("userId:%{public}d", userId); + + auto bundleMgr_ = remoteClientManager_->GetBundleManager(); + if (bundleMgr_ == nullptr) { + APP_LOGE("GetBundleManager fail"); + return ERR_NO_INIT; + } + int uid = bundleMgr_->GetUidByBundleName(bundleName, userId); + APP_LOGI("uid value is %{public}d", uid); + int result = ERR_OK; int64_t startTime = SystemTimeMillis(); std::list pids; - if (!appRunningManager_->ProcessExitByBundleName(bundleName, pids)) { + if (!appRunningManager_->ProcessExitByBundleNameAndUid(bundleName, uid, pids)) { APP_LOGI("The process corresponding to the package name did not start"); return result; } @@ -451,7 +462,9 @@ int32_t AppMgrServiceInner::KillApplicationByUserId(const std::string &bundleNam void AppMgrServiceInner::ClearUpApplicationData(const std::string &bundleName, int32_t callerUid, pid_t callerPid) { BYTRACE_NAME(BYTRACE_TAG_APP, __PRETTY_FUNCTION__); - ClearUpApplicationDataByUserId(bundleName, callerUid, callerPid, Constants::DEFAULT_USERID); + auto userId = GetUserIdByUid(callerUid); + APP_LOGI("userId:%{public}d", userId); + ClearUpApplicationDataByUserId(bundleName, callerUid, callerPid, userId); } void AppMgrServiceInner::ClearUpApplicationDataByUserId( @@ -1721,23 +1734,9 @@ void AppMgrServiceInner::StartResidentProcess(const std::vector &inf } for (auto &bundle : infos) { - auto processName = bundle.applicationInfo.process.empty() ? - bundle.applicationInfo.bundleName : bundle.applicationInfo.process; + auto processName = + bundle.applicationInfo.process.empty() ? bundle.applicationInfo.bundleName : bundle.applicationInfo.process; APP_LOGI("processName = [%{public}s]", processName.c_str()); - - bool allElementNameEmpty = true; - for (auto hapModuleInfo : bundle.hapModuleInfos) { - if (!hapModuleInfo.mainElementName.empty()) { - // already start main element and process, no need start process again - allElementNameEmpty = false; - break; - } - } - if (!allElementNameEmpty) { - APP_LOGW("processName [%{public}s] Already exists ", processName.c_str()); - continue; - } - // Inspection records auto appRecord = appRunningManager_->CheckAppRunningRecordIsExist( bundle.applicationInfo.name, processName, bundle.applicationInfo.uid, bundle); diff --git a/services/appmgr/test/mock/include/mock_bundle_manager.h b/services/appmgr/test/mock/include/mock_bundle_manager.h index 0ffda0cf9d4..ba570e769af 100755 --- a/services/appmgr/test/mock/include/mock_bundle_manager.h +++ b/services/appmgr/test/mock/include/mock_bundle_manager.h @@ -44,6 +44,7 @@ public: bool(const std::string &bundleName, const std::string &permission, const int userId)); MOCK_METHOD2(GetNameForUid, bool(const int uid, std::string &name)); MOCK_METHOD2(GetBundlesForUid, bool(const int uid, std::vector &)); + MOCK_METHOD2(SetAbilityEnabled, bool(const AbilityInfo &, bool)); MOCK_METHOD1(IsAbilityEnabled, bool(const AbilityInfo &)); MOCK_METHOD2(GetAbilityIcon, std::string(const std::string &bundleName, const std::string &className)); MOCK_METHOD1(RegisterAllPermissionsChanged, bool(const sptr &callback)); @@ -174,6 +175,12 @@ public: { return true; }; + // clears cache data of a specified application. + virtual bool CleanBundleCacheFiles( + const std::string &bundleName, const sptr &cleanCacheCallback) override + { + return true; + }; virtual bool CleanBundleDataFiles(const std::string &bundleName, const int userId = 0) override { return true; @@ -246,6 +253,7 @@ public: bool(const std::string &bundleName, const std::string &permission, const int userId)); MOCK_METHOD2(GetNameForUid, bool(const int uid, std::string &name)); MOCK_METHOD2(GetBundlesForUid, bool(const int uid, std::vector &)); + MOCK_METHOD2(SetAbilityEnabled, bool(const AbilityInfo &, bool)); MOCK_METHOD1(IsAbilityEnabled, bool(const AbilityInfo &)); MOCK_METHOD2(GetAbilityIcon, std::string(const std::string &bundleName, const std::string &className)); MOCK_METHOD1(RegisterAllPermissionsChanged, bool(const sptr &callback)); @@ -340,6 +348,12 @@ public: { return true; }; + // clears cache data of a specified application. + virtual bool CleanBundleCacheFiles( + const std::string &bundleName, const sptr &cleanCacheCallback) override + { + return true; + }; virtual bool RegisterBundleStatusCallback(const sptr &bundleStatusCallback) override { @@ -375,6 +389,10 @@ public: { return true; }; + virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) override + { + return true; + }; virtual bool GetAllFormsInfo(std::vector &formInfos) override { return true; @@ -403,8 +421,7 @@ public: return true; } virtual bool NotifyAbilityLifeStatus( - const std::string &bundleName, const std::string &abilityName, - const int64_t launchTime, const int uid = 0) override + const std::string &bundleName, const std::string &abilityName, const int64_t launchTime, const int uid = 0) override { return true; } diff --git a/services/appmgr/test/mock/src/mock_bundle_manager.cpp b/services/appmgr/test/mock/src/mock_bundle_manager.cpp index ca3ec28c311..562ad2b5c03 100644 --- a/services/appmgr/test/mock/src/mock_bundle_manager.cpp +++ b/services/appmgr/test/mock/src/mock_bundle_manager.cpp @@ -52,6 +52,7 @@ bool BundleMgrProxy::GetApplicationInfo( std::string BundleMgrProxy::GetAppType(const std::string &bundleName) { + GTEST_LOG_(INFO) << " BundleMgrProxy::GetAppTyp"; return "system"; } @@ -104,17 +105,20 @@ bool BundleMgrService::GetApplicationInfo( std::string BundleMgrService::GetAppType(const std::string &bundleName) { + GTEST_LOG_(INFO) << " BundleMgrService::GetAppType"; return "system"; } bool BundleMgrService::GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) { + GTEST_LOG_(INFO) << " BundleMgrService::GetHapModuleInfo"; hapModuleInfo.name = "Captain"; return true; } bool BundleMgrProxy::GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) { + GTEST_LOG_(INFO) << " BundleMgrService::GetHapModuleInfo"; hapModuleInfo.name = "Captain"; return true; } diff --git a/services/appmgr/test/unittest/ams_app_life_cycle_test/ams_app_life_cycle_test.cpp b/services/appmgr/test/unittest/ams_app_life_cycle_test/ams_app_life_cycle_test.cpp index 1a1d2e20a58..2b4ebe05821 100644 --- a/services/appmgr/test/unittest/ams_app_life_cycle_test/ams_app_life_cycle_test.cpp +++ b/services/appmgr/test/unittest/ams_app_life_cycle_test/ams_app_life_cycle_test.cpp @@ -86,7 +86,6 @@ protected: std::shared_ptr serviceInner_; sptr mock_token_ = nullptr; sptr mockBundleMgr = nullptr; - std::shared_ptr runner_ = nullptr; std::shared_ptr handler_ = nullptr; sptr mockAppStateCallbackStub_ = nullptr; }; @@ -104,17 +103,13 @@ void AmsAppLifeCycleTest::SetUp() mockBundleMgr = new (std::nothrow) BundleMgrService(); serviceInner_->SetBundleManager(mockBundleMgr); - runner_ = EventRunner::Create("AmsAppLifeCycleTest"); - handler_ = std::make_shared(runner_, serviceInner_); + auto runner = EventRunner::Create("AmsAppLifeCycleTest"); + handler_ = std::make_shared(runner, serviceInner_); serviceInner_->SetEventHandler(handler_); } void AmsAppLifeCycleTest::TearDown() -{ - serviceInner_ = nullptr; - handler_ = nullptr; - runner_.reset(); -} +{} std::shared_ptr AmsAppLifeCycleTest::StartProcessAndLoadAbility(const sptr &token, const sptr &preToken, const std::shared_ptr &abilityInfo, @@ -1481,6 +1476,68 @@ HWTEST_F(AmsAppLifeCycleTest, KillApplication_001, TestSize.Level1) EXPECT_EQ(ERR_OK, result); } +/* + * Feature: AMS + * Function: AppLifeCycle + * SubFunction: Schedule + * FunctionPoints: Kill application + * CaseDescription: Verify if AppMgrService Kill by appname successfully. + */ +HWTEST_F(AmsAppLifeCycleTest, KillApplication_002, TestSize.Level1) +{ + const pid_t NEW_PID = 123; + auto abilityInfo = GetAbilityInfoByIndex("0"); + auto appInfo = GetApplication(); + sptr token = GetMockToken(); + + std::shared_ptr mockClientPtr = std::make_shared(); + EXPECT_CALL(*mockClientPtr, StartProcess(_, _)).Times(1).WillOnce(DoAll(SetArgReferee<1>(NEW_PID), Return(ERR_OK))); + + serviceInner_->SetAppSpawnClient(mockClientPtr); + + serviceInner_->LoadAbility(token, nullptr, abilityInfo, appInfo); + BundleInfo bundleInfo; + bundleInfo.appId = "com.ohos.test.helloworld_code123"; + auto appRecord = serviceInner_->appRunningManager_->CheckAppRunningRecordIsExist( + appInfo->name, appInfo->name, appInfo->uid, bundleInfo); + EXPECT_EQ(appRecord->GetPriorityObject()->GetPid(), NEW_PID); + + pid_t pid = fork(); + if (pid > 0) { + appRecord->GetPriorityObject()->SetPid(pid); + } + + sptr mockAppScheduler = new MockAppScheduler(); + sptr client = iface_cast(mockAppScheduler.GetRefPtr()); + appRecord->SetApplicationClient(client); + EXPECT_CALL(*mockAppScheduler, ScheduleProcessSecurityExit()).Times(1); + + int ret = serviceInner_->KillApplication(abilityInfo->applicationName); + EXPECT_EQ(ERR_OK, ret); +} + +/* + * Feature: AMS + * Function: AppLifeCycle + * SubFunction: Schedule + * FunctionPoints: Kill application + * CaseDescription: Verify if AppMgrService Kill by pid successfully. + */ +HWTEST_F(AmsAppLifeCycleTest, KillProcessByPid001, TestSize.Level1) +{ + pid_t pid = fork(); + + if (pid > 0) { + int32_t ret = serviceInner_->KillProcessByPid(pid); + EXPECT_EQ(ERR_OK, ret); + } + + if (pid == 0) { + int32_t ret = serviceInner_->KillProcessByPid(pid); + EXPECT_EQ(-1, ret); + } +} + /* * Feature: AMS * Function: AppLifeCycle @@ -1837,6 +1894,33 @@ HWTEST_F(AmsAppLifeCycleTest, ClearUpApplicationData_001, TestSize.Level1) serviceInner_->ClearUpApplicationData(appRecord->GetBundleName(), appRecord->GetUid(), NEW_PID); } +/* + * Feature: AMS + * Function: AppLifeCycle + * SubFunction: ClearUpApplicationData + * FunctionPoints: UnsuspendApplication + * CaseDescription: test application state is APP_STATE_BACKGROUND(apprecord is nullptr) + */ +HWTEST_F(AmsAppLifeCycleTest, ClearUpApplicationData_002, TestSize.Level1) +{ + auto abilityInfo = GetAbilityInfoByIndex("110"); + auto appInfo = GetApplication(); + sptr token = GetMockToken(); + + int32_t pid = fork(); + + if (pid > 0) { + auto appRecord = StartProcessAndLoadAbility(token, nullptr, abilityInfo, appInfo, pid); + + EXPECT_CALL(*mockBundleMgr, CleanBundleDataFiles(_, _)).Times(1).WillOnce(Return(101)); + appRecord->SetUid(101); + sptr mockAppScheduler = new MockAppScheduler(); + sptr client = iface_cast(mockAppScheduler.GetRefPtr()); + appRecord->SetApplicationClient(client); + serviceInner_->ClearUpApplicationData(appRecord->GetBundleName(), appRecord->GetUid(), pid); + } +} + /* * Feature: AMS * Function: AppLifeCycle::IsBackgroundRunningRestricted diff --git a/services/appmgr/test/unittest/ams_service_event_drive_test/ams_service_event_drive_test.cpp b/services/appmgr/test/unittest/ams_service_event_drive_test/ams_service_event_drive_test.cpp index f17bbdbe689..093b1e7ccb9 100644 --- a/services/appmgr/test/unittest/ams_service_event_drive_test/ams_service_event_drive_test.cpp +++ b/services/appmgr/test/unittest/ams_service_event_drive_test/ams_service_event_drive_test.cpp @@ -47,7 +47,7 @@ public: std::shared_ptr GetAmsEventHandler(); protected: - std::shared_ptr appMgrService_ = std::make_shared(); + std::shared_ptr appMgrService_; }; void AmsServiceEventDriveTest::SetUpTestCase() @@ -58,13 +58,11 @@ void AmsServiceEventDriveTest::TearDownTestCase() void AmsServiceEventDriveTest::SetUp() { - appMgrService_->OnStart(); + appMgrService_ = std::make_shared(); } void AmsServiceEventDriveTest::TearDown() -{ - appMgrService_->OnStop(); -} +{} /* * Feature: AppMgrService @@ -286,7 +284,6 @@ HWTEST_F(AmsServiceEventDriveTest, EventDrive_009, TestSize.Level1) { APP_LOGI("ams_service_event_drive_test_009 start"); - appMgrService_->OnStop(); std::shared_ptr innerService = std::make_shared(); appMgrService_->SetInnerService(innerService); @@ -310,7 +307,6 @@ HWTEST_F(AmsServiceEventDriveTest, EventDrive_010, TestSize.Level1) { APP_LOGI("ams_service_event_drive_test_010 start"); - appMgrService_->OnStop(); std::shared_ptr innerService = std::make_shared(); appMgrService_->SetInnerService(innerService); @@ -334,7 +330,6 @@ HWTEST_F(AmsServiceEventDriveTest, EventDrive_011, TestSize.Level1) { APP_LOGI("ams_service_event_drive_test_011 start"); - appMgrService_->OnStop(); std::shared_ptr innerService = std::make_shared(); appMgrService_->SetInnerService(innerService); @@ -358,7 +353,6 @@ HWTEST_F(AmsServiceEventDriveTest, EventDrive_012, TestSize.Level1) { APP_LOGI("ams_service_event_drive_test_012 start"); - appMgrService_->OnStop(); std::shared_ptr innerService = std::make_shared(); appMgrService_->SetInnerService(innerService); @@ -382,7 +376,6 @@ HWTEST_F(AmsServiceEventDriveTest, EventDrive_013, TestSize.Level1) { APP_LOGI("ams_service_event_drive_test_013 start"); - appMgrService_->OnStop(); std::shared_ptr innerService = std::make_shared(); appMgrService_->SetInnerService(innerService); @@ -406,7 +399,6 @@ HWTEST_F(AmsServiceEventDriveTest, EventDrive_014, TestSize.Level1) { APP_LOGI("ams_service_event_drive_test_014 start"); - appMgrService_->OnStop(); std::shared_ptr innerService = std::make_shared(); appMgrService_->SetInnerService(innerService); @@ -430,7 +422,6 @@ HWTEST_F(AmsServiceEventDriveTest, EventDrive_015, TestSize.Level1) { APP_LOGI("ams_service_event_drive_test_015 start"); - appMgrService_->OnStop(); std::shared_ptr innerService = std::make_shared(); appMgrService_->SetInnerService(innerService); @@ -452,7 +443,6 @@ HWTEST_F(AmsServiceEventDriveTest, EventDrive_016, TestSize.Level1) { APP_LOGI("ams_service_event_drive_test_016 start"); - appMgrService_->OnStop(); std::shared_ptr innerService = std::make_shared(); appMgrService_->SetInnerService(innerService); @@ -866,7 +856,6 @@ HWTEST_F(AmsServiceEventDriveTest, EventDrive_035, TestSize.Level1) { APP_LOGI("ams_service_event_drive_test_035 start"); - appMgrService_->OnStop(); std::shared_ptr innerService = std::make_shared(); appMgrService_->SetInnerService(innerService); @@ -939,7 +928,6 @@ HWTEST_F(AmsServiceEventDriveTest, EventDrive_038, TestSize.Level1) { APP_LOGI("ams_service_event_drive_test_038 start"); - appMgrService_->OnStop(); std::shared_ptr innerService = std::make_shared(); appMgrService_->SetInnerService(innerService); @@ -982,6 +970,7 @@ HWTEST_F(AmsServiceEventDriveTest, EventDrive_039, TestSize.Level1) * EnvConditions: Mobile that can run ohos test framework * CaseDescription: Verify if QueryServiceState act normal after AppMgrService stopped */ +/* HWTEST_F(AmsServiceEventDriveTest, EventDrive_040, TestSize.Level1) { APP_LOGI("AppMgrService::EventDrive_040 start 1"); @@ -1001,6 +990,7 @@ HWTEST_F(AmsServiceEventDriveTest, EventDrive_040, TestSize.Level1) APP_LOGI("AppMgrService::EventDrive_040 end"); } +*/ /* * Feature: AppMgrService diff --git a/services/formmgr/src/form_mgr_service.cpp b/services/formmgr/src/form_mgr_service.cpp index e61d0f15ae9..7eff4a62a66 100644 --- a/services/formmgr/src/form_mgr_service.cpp +++ b/services/formmgr/src/form_mgr_service.cpp @@ -61,10 +61,8 @@ FormMgrService::FormMgrService() FormMgrService::~FormMgrService() { - if (formSysEventReceiver_ != nullptr) { - EventFwk::CommonEventManager::UnSubscribeCommonEvent(formSysEventReceiver_); - formSysEventReceiver_ = nullptr; - } + EventFwk::CommonEventManager::UnSubscribeCommonEvent(formSysEventReceiver_); + formSysEventReceiver_ = nullptr; } bool FormMgrService::IsReady() const diff --git a/services/formmgr/test/mock/include/mock_ability_manager.h b/services/formmgr/test/mock/include/mock_ability_manager.h index 80b69f608f2..1471e067860 100644 --- a/services/formmgr/test/mock/include/mock_ability_manager.h +++ b/services/formmgr/test/mock/include/mock_ability_manager.h @@ -268,7 +268,7 @@ public: { return 0; } - int NotifyContinuationResult(int32_t missionId, int32_t result) override + int NotifyContinuationResult(int32_t missionId, const int32_t result) override { return 0; } @@ -329,10 +329,7 @@ public: { return 0; } - virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override - { - return 0; - } + virtual int SetMissionLabel(const sptr &token, const std::string &lable) override { @@ -712,7 +709,7 @@ public: { return 0; } - int NotifyContinuationResult(int32_t missionId, int32_t result) override + int NotifyContinuationResult(int32_t missionId, const int32_t result) override { return 0; } @@ -801,10 +798,6 @@ public: { return 0; } - virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override - { - return 0; - } virtual int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override { return 0; diff --git a/services/formmgr/test/mock/include/mock_bundle_manager.h b/services/formmgr/test/mock/include/mock_bundle_manager.h index b833123f9a4..91459d4fde8 100755 --- a/services/formmgr/test/mock/include/mock_bundle_manager.h +++ b/services/formmgr/test/mock/include/mock_bundle_manager.h @@ -40,6 +40,7 @@ public: bool(const std::string &bundleName, const std::string &permission, const int userId)); MOCK_METHOD2(GetNameForUid, bool(const int uid, std::string &name)); MOCK_METHOD2(GetBundlesForUid, bool(const int uid, std::vector &)); + MOCK_METHOD2(SetAbilityEnabled, bool(const AbilityInfo &, bool)); MOCK_METHOD1(IsAbilityEnabled, bool(const AbilityInfo &)); MOCK_METHOD1(RegisterAllPermissionsChanged, bool(const sptr &callback)); MOCK_METHOD2(RegisterPermissionsChanged, @@ -157,6 +158,12 @@ public: { return true; } + // clears cache data of a specified application. + virtual bool CleanBundleCacheFiles( + const std::string &bundleName, const sptr &cleanCacheCallback) override + { + return true; + } virtual bool CleanBundleDataFiles(const std::string &bundleName, const int userId = 0) override { return true; @@ -233,6 +240,10 @@ public: { return true; } + virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) override + { + return true; + } virtual bool GetBundleInfo( const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId) override; @@ -259,6 +270,7 @@ public: bool(const std::string &bundleName, const std::string &permission, const int userId)); MOCK_METHOD2(GetNameForUid, bool(const int uid, std::string &name)); MOCK_METHOD2(GetBundlesForUid, bool(const int uid, std::vector &)); + MOCK_METHOD2(SetAbilityEnabled, bool(const AbilityInfo &, bool)); MOCK_METHOD1(IsAbilityEnabled, bool(const AbilityInfo &)); MOCK_METHOD1(RegisterAllPermissionsChanged, bool(const sptr &callback)); MOCK_METHOD2(RegisterPermissionsChanged, @@ -351,6 +363,12 @@ public: { return true; }; + // clears cache data of a specified application. + virtual bool CleanBundleCacheFiles( + const std::string &bundleName, const sptr &cleanCacheCallback) override + { + return true; + }; virtual bool RegisterBundleStatusCallback(const sptr &bundleStatusCallback) override { @@ -390,6 +408,10 @@ public: return true; }; + virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) override + { + return true; + }; virtual bool GetBundleGidsByUid(const std::string &bundleName, const int &uid, std::vector &gids) override { return true; @@ -462,8 +484,7 @@ public: return true; } virtual bool NotifyAbilityLifeStatus( - const std::string &bundleName, const std::string &abilityName, - const int64_t launchTime, const int uid = 0) override + const std::string &bundleName, const std::string &abilityName, const int64_t launchTime, const int uid = 0) override { return true; } diff --git a/services/formmgr/test/unittest/fms_form_host_record_test/fms_form_host_record_test.cpp b/services/formmgr/test/unittest/fms_form_host_record_test/fms_form_host_record_test.cpp index 2388329a8ad..2b29e51a9f8 100644 --- a/services/formmgr/test/unittest/fms_form_host_record_test/fms_form_host_record_test.cpp +++ b/services/formmgr/test/unittest/fms_form_host_record_test/fms_form_host_record_test.cpp @@ -67,13 +67,13 @@ public: protected: sptr token_; std::shared_ptr formyMgrServ_ = DelayedSingleton::GetInstance(); + + sptr mockBundleMgr_; + sptr mockAbilityMgrServ_; }; void FmsFormHostRecordTest::SetUpTestCase() -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); - FormAmsHelper::GetInstance().SetAbilityManager(new MockAbilityMgrService()); -} +{} void FmsFormHostRecordTest::TearDownTestCase() {} @@ -81,6 +81,14 @@ void FmsFormHostRecordTest::TearDownTestCase() void FmsFormHostRecordTest::SetUp() { formyMgrServ_->OnStart(); + + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + EXPECT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); + + mockAbilityMgrServ_ = new (std::nothrow) MockAbilityMgrService(); + FormAmsHelper::GetInstance().SetAbilityManager(mockAbilityMgrServ_); + token_ = new (std::nothrow) MockFormHostClient(); // Permission install diff --git a/services/formmgr/test/unittest/fms_form_mgr_add_form_test/fms_form_mgr_add_form_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_add_form_test/fms_form_mgr_add_form_test.cpp index f651a81d5c3..e6cad4e0edc 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_add_form_test/fms_form_mgr_add_form_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_add_form_test/fms_form_mgr_add_form_test.cpp @@ -71,20 +71,30 @@ public: protected: sptr token_; std::shared_ptr formyMgrServ_ = DelayedSingleton::GetInstance(); + + sptr mockBundleMgr_; + sptr mockAbilityMgrServ_; }; void FmsFormMgrAddFormTest::SetUpTestCase() -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); - FormAmsHelper::GetInstance().SetAbilityManager(new MockAbilityMgrService()); -} +{} void FmsFormMgrAddFormTest::TearDownTestCase() {} void FmsFormMgrAddFormTest::SetUp() { + // APP_LOGI("fms_form_mgr_client_test_001 setup"); formyMgrServ_->OnStart(); + + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + EXPECT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); + + mockAbilityMgrServ_ = new (std::nothrow) MockAbilityMgrService(); + FormAmsHelper::GetInstance().SetAbilityManager(mockAbilityMgrServ_); + + // APP_LOGI("fms_form_mgr_client_test_001 FormMgrService started"); token_ = new (std::nothrow) MockFormHostClient(); // Permission install @@ -106,9 +116,7 @@ void FmsFormMgrAddFormTest::SetUp() } void FmsFormMgrAddFormTest::TearDown() -{ - formyMgrServ_->OnStop(); -} +{} /* * Feature: FormMgrService diff --git a/services/formmgr/test/unittest/fms_form_mgr_cast_temp_form_test/fms_form_mgr_cast_temp_form_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_cast_temp_form_test/fms_form_mgr_cast_temp_form_test.cpp index cd116a163b8..9dd4306f69d 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_cast_temp_form_test/fms_form_mgr_cast_temp_form_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_cast_temp_form_test/fms_form_mgr_cast_temp_form_test.cpp @@ -70,13 +70,13 @@ public: protected: sptr token_; std::shared_ptr formyMgrServ_ = DelayedSingleton::GetInstance(); + + sptr mockBundleMgr_; + sptr mockAbilityMgrServ_; }; void FmsFormMgrCastTempFormTest::SetUpTestCase() -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); - FormAmsHelper::GetInstance().SetAbilityManager(new MockAbilityMgrService()); -} +{} void FmsFormMgrCastTempFormTest::TearDownTestCase() {} @@ -84,6 +84,14 @@ void FmsFormMgrCastTempFormTest::TearDownTestCase() void FmsFormMgrCastTempFormTest::SetUp() { formyMgrServ_->OnStart(); + + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + ASSERT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); + + mockAbilityMgrServ_ = new (std::nothrow) MockAbilityMgrService(); + FormAmsHelper::GetInstance().SetAbilityManager(mockAbilityMgrServ_); + token_ = new (std::nothrow) MockFormHostClient(); // Permission install diff --git a/services/formmgr/test/unittest/fms_form_mgr_death_callback_test/fms_form_mgr_death_callback_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_death_callback_test/fms_form_mgr_death_callback_test.cpp index a28dee10fdd..f9b45712fd4 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_death_callback_test/fms_form_mgr_death_callback_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_death_callback_test/fms_form_mgr_death_callback_test.cpp @@ -72,20 +72,30 @@ public: protected: sptr token_; std::shared_ptr formyMgrServ_ = DelayedSingleton::GetInstance(); + + sptr mockBundleMgr_; + sptr mockAbilityMgrServ_; }; void FmsFormMgrDeathCallbackTest::SetUpTestCase() -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); - FormAmsHelper::GetInstance().SetAbilityManager(new MockAbilityMgrService()); -} +{} void FmsFormMgrDeathCallbackTest::TearDownTestCase() {} void FmsFormMgrDeathCallbackTest::SetUp() { + // APP_LOGI("fms_form_mgr_client_test_001 setup"); formyMgrServ_->OnStart(); + + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + EXPECT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); + + mockAbilityMgrServ_ = new (std::nothrow) MockAbilityMgrService(); + FormAmsHelper::GetInstance().SetAbilityManager(mockAbilityMgrServ_); + + // APP_LOGI("fms_form_mgr_client_test_001 FormMgrService started"); token_ = new (std::nothrow) MockFormHostClient(); // Permission install diff --git a/services/formmgr/test/unittest/fms_form_mgr_delete_form_test/fms_form_mgr_delete_form_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_delete_form_test/fms_form_mgr_delete_form_test.cpp index 0f35979671f..d0ec63205f1 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_delete_form_test/fms_form_mgr_delete_form_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_delete_form_test/fms_form_mgr_delete_form_test.cpp @@ -67,13 +67,13 @@ public: protected: sptr token_; std::shared_ptr formyMgrServ_ = DelayedSingleton::GetInstance(); + + sptr mockBundleMgr_; + sptr mockAbilityMgrServ_; }; void FmsFormMgrDeleteFormTest::SetUpTestCase() -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); - FormAmsHelper::GetInstance().SetAbilityManager(new MockAbilityMgrService()); -} +{} void FmsFormMgrDeleteFormTest::TearDownTestCase() {} @@ -81,6 +81,14 @@ void FmsFormMgrDeleteFormTest::TearDownTestCase() void FmsFormMgrDeleteFormTest::SetUp() { formyMgrServ_->OnStart(); + + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + EXPECT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); + + mockAbilityMgrServ_ = new (std::nothrow) MockAbilityMgrService(); + FormAmsHelper::GetInstance().SetAbilityManager(mockAbilityMgrServ_); + token_ = new (std::nothrow) MockFormHostClient(); // Permission install diff --git a/services/formmgr/test/unittest/fms_form_mgr_lifecycle_update_test/fms_form_mgr_lifecycle_update_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_lifecycle_update_test/fms_form_mgr_lifecycle_update_test.cpp index 1718061927e..045433d88f0 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_lifecycle_update_test/fms_form_mgr_lifecycle_update_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_lifecycle_update_test/fms_form_mgr_lifecycle_update_test.cpp @@ -56,22 +56,27 @@ public: void InitFormItemInfo(int64_t formId, FormItemInfo &formItemInfo) const; protected: + sptr mockBundleMgr_; std::shared_ptr formyMgrServ_ = DelayedSingleton::GetInstance(); sptr token_; }; void FmsFormMgrLifecycleUpdateTest::SetUpTestCase() -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); -} +{} void FmsFormMgrLifecycleUpdateTest::TearDownTestCase() {} void FmsFormMgrLifecycleUpdateTest::SetUp() { + // APP_LOGI("fms_form_mgr_enable_update_test_001 setup"); formyMgrServ_->OnStart(); + // mock BundleMgr + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + ASSERT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); + // token token_ = new (std::nothrow) MockFormHostClient(); diff --git a/services/formmgr/test/unittest/fms_form_mgr_message_event_test/fms_form_mgr_message_event_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_message_event_test/fms_form_mgr_message_event_test.cpp index cc7870b1dcf..efa7bc17664 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_message_event_test/fms_form_mgr_message_event_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_message_event_test/fms_form_mgr_message_event_test.cpp @@ -69,13 +69,13 @@ public: protected: sptr token_; std::shared_ptr formyMgrServ_ = DelayedSingleton::GetInstance(); + + sptr mockBundleMgr_; + sptr mockAbilityMgrServ_; }; void FmsFormMgrMessageEventTest::SetUpTestCase() -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); - FormAmsHelper::GetInstance().SetAbilityManager(new MockAbilityMgrService()); -} +{} void FmsFormMgrMessageEventTest::TearDownTestCase() {} @@ -83,6 +83,14 @@ void FmsFormMgrMessageEventTest::TearDownTestCase() void FmsFormMgrMessageEventTest::SetUp() { formyMgrServ_->OnStart(); + + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + EXPECT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); + + mockAbilityMgrServ_ = new (std::nothrow) MockAbilityMgrService(); + FormAmsHelper::GetInstance().SetAbilityManager(mockAbilityMgrServ_); + token_ = new (std::nothrow) MockFormHostClient(); // Permission install diff --git a/services/formmgr/test/unittest/fms_form_mgr_notify_invisible_forms_test/fms_form_mgr_notify_invisible_forms_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_notify_invisible_forms_test/fms_form_mgr_notify_invisible_forms_test.cpp index bb38d6a70fd..4f5adb32364 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_notify_invisible_forms_test/fms_form_mgr_notify_invisible_forms_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_notify_invisible_forms_test/fms_form_mgr_notify_invisible_forms_test.cpp @@ -45,27 +45,36 @@ const std::string DEF_LABEL1 = "PermissionFormRequireGrant"; class FmsFormMgrNotifyInvisibleFormsTest : public testing::Test { public: + FmsFormMgrNotifyInvisibleFormsTest() : formMgrService_(nullptr) + {} + ~FmsFormMgrNotifyInvisibleFormsTest() + {} static void SetUpTestCase(void); static void TearDownTestCase(void); void SetUp(); void TearDown(); protected: sptr token_; - std::shared_ptr formMgrService_; + sptr mockBundleMgr_; + std::shared_ptr formMgrService_ = DelayedSingleton::GetInstance(); }; void FmsFormMgrNotifyInvisibleFormsTest::SetUpTestCase(void) -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); -} +{} void FmsFormMgrNotifyInvisibleFormsTest::TearDownTestCase(void) {} void FmsFormMgrNotifyInvisibleFormsTest::SetUp(void) { - formMgrService_ = DelayedSingleton::GetInstance(); + formMgrService_ = std::make_shared(); + formMgrService_->OnStart(); + // mock BundleMgr + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + ASSERT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); + // token token_ = new (std::nothrow) OHOS::AppExecFwk::MockFormHostClient(); @@ -91,10 +100,7 @@ void FmsFormMgrNotifyInvisibleFormsTest::SetUp(void) } void FmsFormMgrNotifyInvisibleFormsTest::TearDown(void) -{ - formMgrService_->OnStop(); - token_ = nullptr; -} +{} /** * @tc.number: FmsFormMgrNotifyInvisibleFormsTest_NotifyInvisibleForms_002 diff --git a/services/formmgr/test/unittest/fms_form_mgr_notify_visible_forms_test/fms_form_mgr_notify_visible_forms_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_notify_visible_forms_test/fms_form_mgr_notify_visible_forms_test.cpp index a5d4d7f233e..843686dbc7c 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_notify_visible_forms_test/fms_form_mgr_notify_visible_forms_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_notify_visible_forms_test/fms_form_mgr_notify_visible_forms_test.cpp @@ -56,20 +56,23 @@ public: void TearDown(); protected: sptr token_; - std::shared_ptr formMgrService_; + sptr mockBundleMgr_; + std::shared_ptr formMgrService_ = DelayedSingleton::GetInstance(); }; void FmsFormMgrNotifyVisibleFormsTest::SetUpTestCase(void) -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); -} +{} void FmsFormMgrNotifyVisibleFormsTest::TearDownTestCase(void) {} void FmsFormMgrNotifyVisibleFormsTest::SetUp(void) { - formMgrService_ = DelayedSingleton::GetInstance(); + formMgrService_ = std::make_shared(); formMgrService_->OnStart(); + + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + ASSERT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); token_ = new (std::nothrow) MockFormHostClient(); // Permission install diff --git a/services/formmgr/test/unittest/fms_form_mgr_release_form_test/fms_form_mgr_release_form_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_release_form_test/fms_form_mgr_release_form_test.cpp index d8122862fcb..ca8bdd6c2a4 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_release_form_test/fms_form_mgr_release_form_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_release_form_test/fms_form_mgr_release_form_test.cpp @@ -62,12 +62,11 @@ public: protected: sptr token_; std::shared_ptr formyMgrServ_ = DelayedSingleton::GetInstance(); + sptr mockBundleMgr_; }; void FmsFormMgrReleaseFormTest::SetUpTestCase() -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); -} +{} void FmsFormMgrReleaseFormTest::TearDownTestCase() {} @@ -75,6 +74,9 @@ void FmsFormMgrReleaseFormTest::TearDownTestCase() void FmsFormMgrReleaseFormTest::SetUp() { formyMgrServ_->OnStart(); + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + ASSERT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); token_ = new (std::nothrow) MockFormHostClient(); // Permission install diff --git a/services/formmgr/test/unittest/fms_form_mgr_request_form_test/fms_form_mgr_request_form_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_request_form_test/fms_form_mgr_request_form_test.cpp index 08af6003557..feaecd16054 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_request_form_test/fms_form_mgr_request_form_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_request_form_test/fms_form_mgr_request_form_test.cpp @@ -57,15 +57,14 @@ public: void TearDown(); protected: + sptr mockAbilityMgrServ_; + sptr mockBundleMgr_; sptr token_; std::shared_ptr formyMgrServ_ = DelayedSingleton::GetInstance(); }; void FmsFormMgrRequestFormTest::SetUpTestCase() -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); - FormAmsHelper::GetInstance().SetAbilityManager(new MockAbilityMgrService()); -} +{} void FmsFormMgrRequestFormTest::TearDownTestCase() {} @@ -73,8 +72,15 @@ void FmsFormMgrRequestFormTest::TearDownTestCase() void FmsFormMgrRequestFormTest::SetUp() { formyMgrServ_->OnStart(); + token_ = new (std::nothrow) MockFormHostClient(); + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + ASSERT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); + + mockAbilityMgrServ_ = new (std::nothrow) MockAbilityMgrService(); + FormAmsHelper::GetInstance().SetAbilityManager(mockAbilityMgrServ_); // Permission install std::vector permList; Permission::PermissionDef permDef; diff --git a/services/formmgr/test/unittest/fms_form_mgr_update_form_test/fms_form_mgr_update_form_test.cpp b/services/formmgr/test/unittest/fms_form_mgr_update_form_test/fms_form_mgr_update_form_test.cpp index 311ee272f6f..559958c4f72 100644 --- a/services/formmgr/test/unittest/fms_form_mgr_update_form_test/fms_form_mgr_update_form_test.cpp +++ b/services/formmgr/test/unittest/fms_form_mgr_update_form_test/fms_form_mgr_update_form_test.cpp @@ -63,13 +63,13 @@ public: protected: sptr token_; std::shared_ptr formyMgrServ_ = DelayedSingleton::GetInstance(); + + sptr mockBundleMgr_; + sptr mockAbilityMgrServ_; }; void FmsFormMgrUpdateFormTest::SetUpTestCase() -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); - FormAmsHelper::GetInstance().SetAbilityManager(new MockAbilityMgrService()); -} +{} void FmsFormMgrUpdateFormTest::TearDownTestCase() {} @@ -77,7 +77,16 @@ void FmsFormMgrUpdateFormTest::TearDownTestCase() void FmsFormMgrUpdateFormTest::SetUp() { APP_LOGI("fms_form_mgr_client_updateForm_test_001 setup"); + formyMgrServ_->OnStart(); + + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + ASSERT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); + + mockAbilityMgrServ_ = new (std::nothrow) MockAbilityMgrService(); + FormAmsHelper::GetInstance().SetAbilityManager(mockAbilityMgrServ_); + token_ = new (std::nothrow) MockFormHostClient(); // Permission install diff --git a/services/formmgr/test/unittest/fms_form_provider_mgr_test/fms_form_provider_mgr_test.cpp b/services/formmgr/test/unittest/fms_form_provider_mgr_test/fms_form_provider_mgr_test.cpp index a7ccb2ab73e..cec93e35f57 100644 --- a/services/formmgr/test/unittest/fms_form_provider_mgr_test/fms_form_provider_mgr_test.cpp +++ b/services/formmgr/test/unittest/fms_form_provider_mgr_test/fms_form_provider_mgr_test.cpp @@ -68,20 +68,30 @@ public: protected: sptr token_; std::shared_ptr formyMgrServ_ = DelayedSingleton::GetInstance(); + + sptr mockBundleMgr_; + sptr mockAbilityMgrServ_; }; void FmsFormProviderMgrTest::SetUpTestCase() -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); - FormAmsHelper::GetInstance().SetAbilityManager(new MockAbilityMgrService()); -} +{} void FmsFormProviderMgrTest::TearDownTestCase() {} void FmsFormProviderMgrTest::SetUp() { + // APP_LOGI("fms_form_mgr_client_test_001 setup"); formyMgrServ_->OnStart(); + + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + EXPECT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); + + mockAbilityMgrServ_ = new (std::nothrow) MockAbilityMgrService(); + FormAmsHelper::GetInstance().SetAbilityManager(mockAbilityMgrServ_); + + // APP_LOGI("fms_form_mgr_client_test_001 FormMgrService started"); token_ = new (std::nothrow) MockFormHostClient(); // Permission install diff --git a/services/formmgr/test/unittest/fms_form_set_next_refresh_test/fms_form_set_next_refresh_test.cpp b/services/formmgr/test/unittest/fms_form_set_next_refresh_test/fms_form_set_next_refresh_test.cpp index 7d18793db1e..c363f16e3a2 100644 --- a/services/formmgr/test/unittest/fms_form_set_next_refresh_test/fms_form_set_next_refresh_test.cpp +++ b/services/formmgr/test/unittest/fms_form_set_next_refresh_test/fms_form_set_next_refresh_test.cpp @@ -49,32 +49,35 @@ public: {} ~FmsFormSetNextRefreshTest() {} + std::shared_ptr formSetNextRefresh_ = DelayedSingleton::GetInstance(); static void SetUpTestCase(void); static void TearDownTestCase(void); void SetUp(); void TearDown(); protected: - std::shared_ptr formSetNextRefresh_; + sptr mockBundleMgr_; }; - void FmsFormSetNextRefreshTest::SetUpTestCase(void) -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); -} +{} void FmsFormSetNextRefreshTest::TearDownTestCase(void) {} void FmsFormSetNextRefreshTest::SetUp(void) { - formSetNextRefresh_ = DelayedSingleton::GetInstance(); + formSetNextRefresh_ = std::make_shared(); + formSetNextRefresh_->OnStart(); + + // mock BundleMgr + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + ASSERT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); } void FmsFormSetNextRefreshTest::TearDown(void) -{ - formSetNextRefresh_->OnStop(); -} +{} + /** * @tc.number: FmsFormSetNextRefreshTest_SetNextRefreshTime_001 diff --git a/services/formmgr/test/unittest/fms_form_sys_event_receiver_test/fms_form_sys_event_receiver_test.cpp b/services/formmgr/test/unittest/fms_form_sys_event_receiver_test/fms_form_sys_event_receiver_test.cpp index 15ec5785933..ada590a92a1 100644 --- a/services/formmgr/test/unittest/fms_form_sys_event_receiver_test/fms_form_sys_event_receiver_test.cpp +++ b/services/formmgr/test/unittest/fms_form_sys_event_receiver_test/fms_form_sys_event_receiver_test.cpp @@ -82,20 +82,30 @@ public: protected: sptr token_; std::shared_ptr formyMgrServ_ = DelayedSingleton::GetInstance(); + + sptr mockBundleMgr_; + sptr mockAbilityMgrServ_; }; void FmsFormSysEventReceiverTest::SetUpTestCase() -{ - FormBmsHelper::GetInstance().SetBundleManager(new BundleMgrService()); - FormAmsHelper::GetInstance().SetAbilityManager(new MockAbilityMgrService()); -} +{} void FmsFormSysEventReceiverTest::TearDownTestCase() {} void FmsFormSysEventReceiverTest::SetUp() { + // APP_LOGI("fms_form_mgr_client_test_001 setup"); formyMgrServ_->OnStart(); + + mockBundleMgr_ = new (std::nothrow) BundleMgrService(); + EXPECT_TRUE(mockBundleMgr_ != nullptr); + FormBmsHelper::GetInstance().SetBundleManager(mockBundleMgr_); + + mockAbilityMgrServ_ = new (std::nothrow) MockAbilityMgrService(); + FormAmsHelper::GetInstance().SetAbilityManager(mockAbilityMgrServ_); + + // APP_LOGI("fms_form_mgr_client_test_001 FormMgrService started"); token_ = new (std::nothrow) MockFormHostClient(); // Permission install diff --git a/services/formmgr/test/unittest/fms_form_timer_mgr_test/fms_form_timer_mgr_test.cpp b/services/formmgr/test/unittest/fms_form_timer_mgr_test/fms_form_timer_mgr_test.cpp index 0e1a0d43edc..e41de5bc00a 100644 --- a/services/formmgr/test/unittest/fms_form_timer_mgr_test/fms_form_timer_mgr_test.cpp +++ b/services/formmgr/test/unittest/fms_form_timer_mgr_test/fms_form_timer_mgr_test.cpp @@ -539,6 +539,9 @@ HWTEST_F(FmsFormTimerMgrTest, Fms_FormTimerMgr_0027, Function | MediumTest | Lev GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0027 start"; bool isAddOk4 = FormTimerMgr::GetInstance().AddFormTimer(PARAM_FORM_ID_VALUE_6, 10, 30, 0); EXPECT_EQ(isAddOk4, true); + + std::this_thread::sleep_for(std::chrono::milliseconds(Constants::MIN_PERIOD)); + GTEST_LOG_(INFO) << "Fms_FormTimerMgr_0027 end"; } } diff --git a/services/test/mock/include/appmgr/mock_ability_mgr_host.h b/services/test/mock/include/appmgr/mock_ability_mgr_host.h index 171319d34d7..3707f0dd010 100644 --- a/services/test/mock/include/appmgr/mock_ability_mgr_host.h +++ b/services/test/mock/include/appmgr/mock_ability_mgr_host.h @@ -313,7 +313,7 @@ public: { return 0; } - int NotifyContinuationResult(int32_t missionId, int32_t result) override + int NotifyContinuationResult(int32_t missionId, const int32_t result) override { return 0; } @@ -375,10 +375,6 @@ public: { return 0; } - virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override - { - return 0; - } virtual int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override { return 0; diff --git a/services/test/mock/include/mock_ability_mgr_service.h b/services/test/mock/include/mock_ability_mgr_service.h index 385f2b969d4..83fe2e1c4b3 100644 --- a/services/test/mock/include/mock_ability_mgr_service.h +++ b/services/test/mock/include/mock_ability_mgr_service.h @@ -96,7 +96,7 @@ public: MOCK_METHOD1(SetShowOnLockScreen, int(bool isAllow)); MOCK_METHOD1(GetSystemMemoryAttr, void(AppExecFwk::SystemMemoryAttr &memoryInfo)); MOCK_METHOD3(StartContinuation, int(const Want &want, const sptr &abilityToken, int32_t status)); - MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); + MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, const int32_t result)); MOCK_METHOD5(ContinueMission, int(const std::string &srcDeviceId, const std::string &dstDeviceId, int32_t missionId, const sptr &callBack, AAFwk::WantParams &wantParams)); MOCK_METHOD2(ContinueAbility, int(const std::string &deviceId, int32_t missionId)); @@ -112,7 +112,6 @@ public: MOCK_METHOD1(CleanMission, int(int32_t missionId)); MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); - MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions &startOptions)); MOCK_METHOD2(SetMissionLabel, int(const sptr &token, const std::string &label)); MOCK_METHOD1(ClearUpApplicationData, int(const std::string &)); diff --git a/services/test/mock/include/mock_ability_scheduler.h b/services/test/mock/include/mock_ability_scheduler.h index a5ab5274fef..b4afe3f78cc 100755 --- a/services/test/mock/include/mock_ability_scheduler.h +++ b/services/test/mock/include/mock_ability_scheduler.h @@ -42,9 +42,9 @@ public: ScheduleUnregisterObserver, bool(const Uri &uri, const sptr &dataObserver)); MOCK_METHOD1(ScheduleNotifyChange, bool(const Uri &uri)); MOCK_METHOD1(ExecuteBatch, std::vector>(const std::vector> &operations)); - MOCK_METHOD1(NotifyContinuationResult, void(int32_t result)); + MOCK_METHOD1(NotifyContinuationResult, void(const int32_t result)); MOCK_METHOD1(ContinueAbility, void(const std::string& deviceId)); - MOCK_METHOD2(DumpAbilityInfo, void(const std::vector ¶ms, std::vector &info)); + MOCK_METHOD1(DumpAbilityInfo, void(std::vector &info)); std::vector GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) { std::vector types; diff --git a/services/test/mock/include/mock_ability_scheduler_stub.h b/services/test/mock/include/mock_ability_scheduler_stub.h index 5e36df317ad..1913d5afb08 100755 --- a/services/test/mock/include/mock_ability_scheduler_stub.h +++ b/services/test/mock/include/mock_ability_scheduler_stub.h @@ -51,9 +51,9 @@ public: MOCK_METHOD1(ScheduleNotifyChange, bool(const Uri &uri)); MOCK_METHOD1(ExecuteBatch, std::vector>( const std::vector> &operations)); - MOCK_METHOD1(NotifyContinuationResult, void(int32_t result)); + MOCK_METHOD1(NotifyContinuationResult, void(const int32_t result)); MOCK_METHOD1(ContinueAbility, void(const std::string& deviceId)); - MOCK_METHOD2(DumpAbilityInfo, void(const std::vector ¶ms, std::vector &info)); + MOCK_METHOD1(DumpAbilityInfo, void(std::vector &info)); virtual sptr CallRequest() { diff --git a/services/test/mock/include/mock_bundle_mgr.h b/services/test/mock/include/mock_bundle_mgr.h index ebba5c6557f..fed3a447146 100644 --- a/services/test/mock/include/mock_bundle_mgr.h +++ b/services/test/mock/include/mock_bundle_mgr.h @@ -229,6 +229,8 @@ public: MOCK_METHOD1(HasSystemCapability, bool(const std::string &capName)); MOCK_METHOD1(GetSystemAvailableCapabilities, bool(std::vector &systemCaps)); MOCK_METHOD0(IsSafeMode, bool()); + MOCK_METHOD2(CleanBundleCacheFiles, + bool(const std::string &bundleName, const sptr &cleanCacheCallback)); MOCK_METHOD2(CleanBundleDataFiles, bool(const std::string &bundleName, const int userId)); MOCK_METHOD1(RegisterBundleStatusCallback, bool(const sptr &bundleStatusCallback)); MOCK_METHOD1(ClearBundleStatusCallback, bool(const sptr &bundleStatusCallback)); @@ -236,10 +238,12 @@ public: MOCK_METHOD4( DumpInfos, bool(const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result)); MOCK_METHOD1(IsApplicationEnabled, bool(const std::string &bundleName)); + MOCK_METHOD2(SetApplicationEnabled, bool(const std::string &bundleName, bool isEnable)); MOCK_METHOD0(GetBundleInstaller, sptr()); MOCK_METHOD0(GetBundleUserMgr, sptr()); MOCK_METHOD2(GetNameForUid, bool(const int uid, std::string &name)); MOCK_METHOD2(GetBundlesForUid, bool(const int uid, std::vector &)); + MOCK_METHOD2(SetAbilityEnabled, bool(const AbilityInfo &, bool)); MOCK_METHOD1(IsAbilityEnabled, bool(const AbilityInfo &)); MOCK_METHOD2(GetAbilityIcon, std::string(const std::string &bundleName, const std::string &className)); MOCK_METHOD1(RegisterAllPermissionsChanged, bool(const sptr &callback)); @@ -290,6 +294,8 @@ public: MOCK_METHOD1(HasSystemCapability, bool(const std::string &capName)); MOCK_METHOD1(GetSystemAvailableCapabilities, bool(std::vector &systemCaps)); MOCK_METHOD0(IsSafeMode, bool()); + MOCK_METHOD2(CleanBundleCacheFiles, + bool(const std::string &bundleName, const sptr &cleanCacheCallback)); MOCK_METHOD2(CleanBundleDataFiles, bool(const std::string &bundleName, const int userId)); MOCK_METHOD1(RegisterBundleStatusCallback, bool(const sptr &bundleStatusCallback)); MOCK_METHOD1(ClearBundleStatusCallback, bool(const sptr &bundleStatusCallback)); @@ -297,6 +303,7 @@ public: MOCK_METHOD4( DumpInfos, bool(const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result)); MOCK_METHOD1(IsApplicationEnabled, bool(const std::string &bundleName)); + MOCK_METHOD2(SetApplicationEnabled, bool(const std::string &bundleName, bool isEnable)); MOCK_METHOD0(GetBundleInstaller, sptr()); MOCK_METHOD0(GetBundleUserMgr, sptr()); MOCK_METHOD3( @@ -305,6 +312,7 @@ public: bool(const std::string &bundleName, const std::string &permission, const int userId)); MOCK_METHOD2(GetNameForUid, bool(const int uid, std::string &name)); MOCK_METHOD2(GetBundlesForUid, bool(const int uid, std::vector &)); + MOCK_METHOD2(SetAbilityEnabled, bool(const AbilityInfo &, bool)); MOCK_METHOD1(IsAbilityEnabled, bool(const AbilityInfo &)); MOCK_METHOD2(GetAbilityIcon, std::string(const std::string &bundleName, const std::string &className)); MOCK_METHOD1(RegisterAllPermissionsChanged, bool(const sptr &callback)); diff --git a/test/resource/amssystemtestability/abilitySrc/amsStDataAbility/BUILD.gn b/test/resource/amssystemtestability/abilitySrc/amsStDataAbility/BUILD.gn index 1e0fab8598d..4631a17f0de 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsStDataAbility/BUILD.gn +++ b/test/resource/amssystemtestability/abilitySrc/amsStDataAbility/BUILD.gn @@ -13,7 +13,7 @@ import("//build/ohos.gni") import("//foundation/aafwk/standard/aafwk.gni") -SUBDEMOSYSTEM_DIR = "//foundation/appexecfwk/standard/test/resource/amssystemtestability/abilitySrc/amsStDataAbility" +SUBDEMOSYSTEM_DIR = "${system_test_app_path}/amsStDataAbility" EVENT_DIR = "//base/notification/ces_standard/cesfwk" config("verify_act_ability_config") { diff --git a/test/resource/amssystemtestability/abilitySrc/amsStDataAbility/include/verify_act_data_ability.h b/test/resource/amssystemtestability/abilitySrc/amsStDataAbility/include/verify_act_data_ability.h index b8967ce1f7b..9f87dcda97c 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsStDataAbility/include/verify_act_data_ability.h +++ b/test/resource/amssystemtestability/abilitySrc/amsStDataAbility/include/verify_act_data_ability.h @@ -41,13 +41,10 @@ public: virtual int BatchInsert(const Uri &uri, const std::vector &values) override; std::vector> sharedList_; -}; -class InsertTestOpenCallback : public NativeRdb::RdbOpenCallback { -public: - int OnCreate(NativeRdb::RdbStore &rdbStore) override; - int OnUpgrade(NativeRdb::RdbStore &rdbStore, int oldVersion, int newVersion) override; - static const std::string CREATE_TABLE_TEST; + virtual std::vector GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) override; + virtual Uri NormalizeUri(const Uri &uri) override; + virtual Uri DenormalizeUri(const Uri &uri) override; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/test/resource/amssystemtestability/abilitySrc/amsStDataAbility/src/verify_act_data_ability.cpp b/test/resource/amssystemtestability/abilitySrc/amsStDataAbility/src/verify_act_data_ability.cpp index b5bcbb9676e..f5887fce9d1 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsStDataAbility/src/verify_act_data_ability.cpp +++ b/test/resource/amssystemtestability/abilitySrc/amsStDataAbility/src/verify_act_data_ability.cpp @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSERETURN_ERROR2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -14,11 +14,13 @@ */ #include "abs_shared_result_set.h" +#include "ability_loader.h" +#include "app_log_wrapper.h" +#include "data_ability_helper.h" #include "data_ability_predicates.h" +#include "rdb_helper.h" +#include "rdb_open_callback.h" #include "values_bucket.h" - -#include "app_log_wrapper.h" -#include "ability_loader.h" #include "verify_act_data_ability.h" namespace OHOS { @@ -28,8 +30,25 @@ static std::shared_ptr testStore; static const std::string RDB_TEST_PATH = "/data/test/"; static const std::string DATABASE_FILE_NAME = "insert_test.db"; static const std::string DATABASE_NAME = RDB_TEST_PATH + "insert_test.db"; -static const int defaultReturn = 1; -} +static int defaultReturn = 1; +static const double ageI = 24; +static const double salaryI = 2024.20; +static const int returnError = 0; +static const int returnError1 = -1; +static const int returnError2 = -2; +static const int returnError3 = -3; +static const int value1 = 0; +static const int value2 = 1; +static const int value3 = 2; +static const int value4 = 3; +} // namespace + +class InsertTestOpenCallback : public NativeRdb::RdbOpenCallback { +public: + int OnCreate(NativeRdb::RdbStore &rdbStore) override; + int OnUpgrade(NativeRdb::RdbStore &rdbStore, int oldVersion, int newVersion) override; + static const std::string CREATE_TABLE_TEST; +}; const std::string InsertTestOpenCallback::CREATE_TABLE_TEST = std::string("CREATE TABLE IF NOT EXISTS test ") + std::string("(id INTEGER PRIMARY KEY AUTOINCREMENT, " @@ -38,12 +57,14 @@ const std::string InsertTestOpenCallback::CREATE_TABLE_TEST = int InsertTestOpenCallback::OnCreate(NativeRdb::RdbStore &store) { + APP_LOGI("VerifyActDataAbility OnCreate"); return store.ExecuteSql(CREATE_TABLE_TEST); } int InsertTestOpenCallback::OnUpgrade(NativeRdb::RdbStore &store, int oldVersion, int newVersion) { - return 0; + APP_LOGI("VerifyActDataAbility OnUpgrade"); + return returnError; } void VerifyActDataAbility::OnStart(const Want &want) @@ -56,48 +77,149 @@ void VerifyActDataAbility::OnStart(const Want &want) int VerifyActDataAbility::Insert(const Uri &uri, const NativeRdb::ValuesBucket &value) { APP_LOGI("VerifyActDataAbility <<<>>>"); + std::shared_ptr dataUri = std::make_shared("dataability:///com.ix.VerifyActDataAbility"); + auto notify = DataAbilityHelper::Creator(GetContext(), dataUri); + if (notify == nullptr) { + APP_LOGE("VerifyActDataAbility <<<>>>"); + return returnError; + } + notify->NotifyChange(*dataUri); + + APP_LOGI("VerifyActDataAbility Insert uri.ToString = %{public}s", uri.ToString().c_str()); + APP_LOGI("VerifyActDataAbility Insert dataUri.ToString = %{public}s", dataUri->ToString().c_str()); + APP_LOGI("VerifyActDataAbility uri.Equals = %{public}d", uri.Equals(*dataUri)); + if (uri.Equals(*dataUri) != 1) { + return returnError1; + } + + defaultReturn = 1; + std::map valuesMap; + value.GetAll(valuesMap); + int valuesMapSize = valuesMap.size(); + APP_LOGI("VerifyActDataAbility value = %{public}d", valuesMapSize); + if (!valuesMapSize) + return returnError2; + for (auto item = valuesMap.begin(); item != valuesMap.end(); item++) { + auto valueFirst = item->first; + auto valueSecond = item->second; + int iEOK = 0; + APP_LOGI("VerifyActDataAbility valueSecond.GetType[%{public}d]]", valueSecond.GetType()); + if (valueFirst.compare("name") == 0) { + std::string val; + iEOK = valueSecond.GetString(val); + APP_LOGI("VerifyActDataAbility it iEOK[%{public}d]]", iEOK); + APP_LOGI("VerifyActDataAbility it[%{public}s],[%{public}s]", valueFirst.c_str(), val.c_str()); + if (val.compare("ActsDataAbilityHelperTest")) { + return returnError2; + break; + } + } else if (valueFirst.compare("age") == 0) { + double age; + iEOK = valueSecond.GetDouble(age); + APP_LOGI("VerifyActDataAbility it iEOK[%{public}d]", iEOK); + APP_LOGI("VerifyActDataAbility it[%{public}s],[%{public}f]", valueFirst.c_str(), age); + if (age != ageI) { + return returnError2; + break; + } + } else if (valueFirst.compare("salary") == 0) { + double salary; + iEOK = valueSecond.GetDouble(salary); + APP_LOGI("VerifyActDataAbility it iEOK[%{public}d]]", iEOK); + APP_LOGI("VerifyActDataAbility it[%{public}s],[%{public}f]", valueFirst.c_str(), salary); + if (salary != salaryI) { + return returnError2; + break; + } + } else { + APP_LOGI("VerifyActDataAbility it default[%{public}s]", valueFirst.c_str()); + break; + } + } + + int errCode = 0; + std::string dbDir = GetDatabaseDir(); + NativeRdb::RdbStoreConfig config(dbDir + "/" + DATABASE_FILE_NAME); + InsertTestOpenCallback helper; + testStore = NativeRdb::RdbHelper::GetRdbStore(config, 1, helper, errCode); + APP_LOGI("VerifyActDataAbility Insert Patch %{public}s", (dbDir + "/" + DATABASE_FILE_NAME).c_str()); + + if (testStore == nullptr) { + APP_LOGI("VerifyActDataAbility <<<>>> testStore is nullptr, data will be empty"); + return returnError3; + } + + int64_t id; + int insertError; + if ((insertError = testStore->Insert(id, "test", value)) != 0) { + APP_LOGE("VerifyActDataAbility <<<>>> store->Insert Error %{public}d", insertError); + return insertError; + } + return defaultReturn; } std::shared_ptr VerifyActDataAbility::Query( const Uri &uri, const std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates) { + APP_LOGI("VerifyActDataAbility <<<>>>"); + std::shared_ptr dataUri = std::make_shared("dataability:///com.ix.VerifyActDataAbility"); + + APP_LOGI("VerifyActDataAbility Query uri.ToString = %{public}s", uri.ToString().c_str()); + APP_LOGI("VerifyActDataAbility Query dataUri.ToString = %{public}s", dataUri->ToString().c_str()); + APP_LOGI("VerifyActDataAbility uri.Equals = %{public}d", uri.Equals(*dataUri)); + if (uri.Equals(*dataUri) != 1) { + return nullptr; + } + int indexI = 0; + for (const auto &item : columns) { + switch (indexI++) { + case value1: + if (item.compare("value1") != 0) + return nullptr; + break; + case value2: + if (item.compare("value2") != 0) + return nullptr; + break; + case value3: + if (item.compare("value3") != 0) + return nullptr; + break; + case value4: + if (item.compare("value4") != 0) + return nullptr; + break; + default: + APP_LOGI("VerifyActDataAbility indexI = [%{public}d]]", indexI); + } + } + + APP_LOGI("VerifyActDataAbility Query predicates"); + APP_LOGI("VerifyActDataAbility Query predicates.Is = %{public}d", predicates.IsRawSelection()); + APP_LOGI("VerifyActDataAbility Query predicates.Get = %{public}d", predicates.GetJudgeSource()); + int errCode = 0; std::string dbDir = GetDatabaseDir(); NativeRdb::RdbStoreConfig config(dbDir + "/" + DATABASE_FILE_NAME); InsertTestOpenCallback helper; testStore = NativeRdb::RdbHelper::GetRdbStore(config, 1, helper, errCode); - APP_LOGI("VerifyActDataAbility <<<>>> Patch %{public}s", (dbDir + "/" + DATABASE_FILE_NAME).c_str()); - - int64_t id; - NativeRdb::ValuesBucket values; - int idValue = 1; - int age = 18; - double salary = 100.5; - - values.PutInt("id", idValue); - values.PutString("name", std::string("zhangsan")); - values.PutInt("age", age); - values.PutDouble("salary", salary); - values.PutBlob("blobType", std::vector {1, 2, 3}); + APP_LOGI("VerifyActDataAbility Query Patch %{public}s", (dbDir + "/" + DATABASE_FILE_NAME).c_str()); if (testStore == nullptr) { APP_LOGI("VerifyActDataAbility <<<>>> testStore is nullptr, data will be empty"); return nullptr; } - if (testStore->Replace(id, "test", values) != 0) { - APP_LOGE("VerifyActDataAbility <<<>>> store->Replace Error"); - return nullptr; - } - std::unique_ptr rresultSet = - testStore->QuerySql("SELECT * FROM test WHERE name = ?", std::vector {"zhangsan"}); + testStore->QuerySql("SELECT * FROM test WHERE name = ?" , + std::vector {"ActsDataAbilityHelperTest"}); if (rresultSet == nullptr) { APP_LOGE("VerifyActDataAbility <<<>>> rresultSet is nullptr"); return nullptr; } + APP_LOGE("VerifyActDataAbility <<<>>> ret(rresultSet.release()"); std::shared_ptr ret(rresultSet.release()); sharedList_.push_back(ret); return ret; @@ -107,30 +229,291 @@ int VerifyActDataAbility::Update( const Uri &uri, const NativeRdb::ValuesBucket &value, const NativeRdb::DataAbilityPredicates &predicates) { APP_LOGI("VerifyActDataAbility <<<>>>"); + std::shared_ptr dataUri = std::make_shared("dataability:///com.ix.VerifyActDataAbility"); + auto notify = DataAbilityHelper::Creator(GetContext(), dataUri); + if (notify == nullptr) { + APP_LOGE("VerifyActDataAbility <<<>>>"); + return returnError; + } + notify->NotifyChange(*dataUri); + + APP_LOGI("VerifyActDataAbility Update uri.ToString = %{public}s", uri.ToString().c_str()); + APP_LOGI("VerifyActDataAbility Update dataUri.ToString = %{public}s", dataUri->ToString().c_str()); + APP_LOGI("VerifyActDataAbility uri.Equals = %{public}d", uri.Equals(*dataUri)); + if (uri.Equals(*dataUri) != 1) { + return returnError1; + } + + defaultReturn = 1; + std::map valuesMap; + value.GetAll(valuesMap); + int valuesMapSize = valuesMap.size(); + APP_LOGI("VerifyActDataAbility value = %{public}d", valuesMapSize); + if (!valuesMapSize) + return returnError2; + for (auto item = valuesMap.begin(); item != valuesMap.end(); item++) { + auto valueFirst = item->first; + auto valueSecond = item->second; + APP_LOGI("VerifyActDataAbility valueSecond.GetType[%{public}d]]", valueSecond.GetType()); + if (valueFirst.compare("name") == 0) { + std::string val; + valueSecond.GetString(val); + APP_LOGI("VerifyActDataAbility it[%{public}s],[%{public}s]", valueFirst.c_str(), val.c_str()); + if (val.compare("ActsDataAbilityHelperTest")) { + return returnError2; + break; + } + } else if (valueFirst.compare("age") == 0) { + double age; + valueSecond.GetDouble(age); + APP_LOGI("VerifyActDataAbility it[%{public}s],[%{public}f]", valueFirst.c_str(), age); + if (age != ageI) { + return returnError2; + break; + } + } else if (valueFirst.compare("salary") == 0) { + double salary; + valueSecond.GetDouble(salary); + APP_LOGI("VerifyActDataAbility it[%{public}s],[%{public}f]", valueFirst.c_str(), salary); + if (salary != salaryI) { + return returnError2; + break; + } + } else { + APP_LOGI("VerifyActDataAbility it default[%{public}s]", valueFirst.c_str()); + break; + } + } + APP_LOGI("VerifyActDataAbility Update predicates = %{public}d", predicates.IsRawSelection()); + APP_LOGI("VerifyActDataAbility Update predicates.Get = %{public}d", predicates.GetJudgeSource()); + + int errCode = 0; + std::string dbDir = GetDatabaseDir(); + NativeRdb::RdbStoreConfig config(dbDir + "/" + DATABASE_FILE_NAME); + InsertTestOpenCallback helper; + testStore = NativeRdb::RdbHelper::GetRdbStore(config, 1, helper, errCode); + APP_LOGI("VerifyActDataAbility Update Patch %{public}s", (dbDir + "/" + DATABASE_FILE_NAME).c_str()); + + if (testStore == nullptr) { + APP_LOGI("VerifyActDataAbility <<<>>> testStore is nullptr, data will be empty"); + return returnError3; + } + + int changedRows; + int updatError; + if ((updatError = testStore->Update(changedRows, "test", value)) != 0) { + APP_LOGE("VerifyActDataAbility <<<>>> store->Replace changedRows %{public}d Error %{public}d", + changedRows, + updatError); + return updatError; + } return defaultReturn; } int VerifyActDataAbility::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates) { APP_LOGI("VerifyActDataAbility <<<>>>"); + std::shared_ptr dataUri = std::make_shared("dataability:///com.ix.VerifyActDataAbility"); + auto notify = DataAbilityHelper::Creator(GetContext(), dataUri); + if (notify == nullptr) { + APP_LOGE("VerifyActDataAbility <<<>>>"); + return returnError; + } + notify->NotifyChange(*dataUri); + + defaultReturn = 1; + APP_LOGI("VerifyActDataAbility Delete uri.ToString = %{public}s", uri.ToString().c_str()); + APP_LOGI("VerifyActDataAbility Delete dataUri.ToString = %{public}s", dataUri->ToString().c_str()); + APP_LOGI("VerifyActDataAbility uri.Equals is = %{public}d", uri.Equals(*dataUri)); + if (uri.Equals(*dataUri) != 1) { + return returnError; + } + APP_LOGI("VerifyActDataAbility Delete predicates.Is = %{public}d", predicates.IsRawSelection()); + APP_LOGI("VerifyActDataAbility Delete predicates.Get = %{public}d", predicates.GetJudgeSource()); + + int errCode = 0; + std::string dbDir = GetDatabaseDir(); + NativeRdb::RdbStoreConfig config(dbDir + "/" + DATABASE_FILE_NAME); + InsertTestOpenCallback helper; + testStore = NativeRdb::RdbHelper::GetRdbStore(config, 1, helper, errCode); + APP_LOGI("VerifyActDataAbility Delete Patch %{public}s", (dbDir + "/" + DATABASE_FILE_NAME).c_str()); + + if (testStore == nullptr) { + APP_LOGI("VerifyActDataAbility <<<>>> testStore is nullptr, data will be empty"); + return returnError3; + } + + int changedRows; + int deleteError; + if ((deleteError = testStore->Delete(changedRows, "test")) != 0) { + APP_LOGE("VerifyActDataAbility <<<>>> store->Delete changedRows %{public}d Error %{public}d", + changedRows, + deleteError); + return deleteError; + } return defaultReturn; } std::string VerifyActDataAbility::GetType(const Uri &uri) { APP_LOGI("VerifyActDataAbility <<<>>>"); + APP_LOGI("VerifyActDataAbility GetType uri = %{public}s", uri.ToString().c_str()); + std::shared_ptr dataUri = std::make_shared("dataability:///com.ix.VerifyActDataAbility3"); + APP_LOGI("VerifyActDataAbility GetType dataUri.ToString = %{public}s", dataUri->ToString().c_str()); + APP_LOGI("VerifyActDataAbility uri.Equals = %{public}d", uri.Equals(*dataUri)); + if (uri.Equals(*dataUri) == 1) { + return nullptr; + } std::string retval(uri.ToString()); return retval; } int VerifyActDataAbility::OpenFile(const Uri &uri, const std::string &mode) { APP_LOGI("VerifyActDataAbility <<<>>>"); - return 0; + std::shared_ptr dataUri = std::make_shared("dataability:///com.ix.VerifyActDataAbility"); + defaultReturn = 1; + APP_LOGI("VerifyActDataAbility Delete uri.ToString = %{public}s", uri.ToString().c_str()); + APP_LOGI("VerifyActDataAbility Delete dataUri.ToString = %{public}s", dataUri->ToString().c_str()); + APP_LOGI("VerifyActDataAbility uri.Equals = %{public}d", uri.Equals(*dataUri)); + if (uri.Equals(*dataUri) != 1) { + return returnError1; + } + APP_LOGI("VerifyActDataAbility OpenFile mode = %{public}s", mode.c_str()); + if (!(mode.compare("r") == 0 || mode.compare("w") == 0 || mode.compare("wt") == 0 || mode.compare("wa") == 0 || + mode.compare("rw") == 0 || mode.compare("rwt") == 0)) { + if (mode.compare("A1@k#4%$,.<>)(oioiu*((*&(&*giIGT^%&^Ug;sdfk;losd*7873iug8%&^$&%]ERFUy&^%&&R7") == 0) { + defaultReturn = returnError2; + } else + defaultReturn = returnError3; + } + APP_LOGI("VerifyActDataAbility OpenFile defaultReturn = %{public}d", defaultReturn); + return defaultReturn; } int VerifyActDataAbility::BatchInsert(const Uri &uri, const std::vector &values) { APP_LOGI("VerifyActDataAbility <<<>>>"); - return Ability::BatchInsert(uri, values); + std::shared_ptr dataUri = std::make_shared("dataability:///com.ix.VerifyActDataAbility"); + defaultReturn = 1; + APP_LOGI("VerifyActDataAbility BatchInsert uri.ToString = %{public}s", uri.ToString().c_str()); + APP_LOGI("VerifyActDataAbility BatchInsert dataUri.ToString = %{public}s", dataUri->ToString().c_str()); + APP_LOGI("VerifyActDataAbility uri.Equals = %{public}d", uri.Equals(*dataUri)); + if (uri.Equals(*dataUri) != 1) { + return returnError1; + } + + defaultReturn = 1; + std::map valuesMap; + for (auto it = values.begin(); it != values.end(); it++) { + it->GetAll(valuesMap); + int valuesMapSize = values.size(); + APP_LOGI("VerifyActDataAbility value = %{public}d", valuesMapSize); + if (!valuesMapSize) + return returnError2; + for (auto item = valuesMap.begin(); item != valuesMap.end(); item++) { + auto valueFirst = item->first; + auto valueSecond = item->second; + APP_LOGI("VerifyActDataAbility valueSecond.GetType[%{public}d]]", valueSecond.GetType()); + if (valueFirst.compare("name") == 0) { + std::string val; + valueSecond.GetString(val); + APP_LOGI("VerifyActDataAbility it[%{public}s],[%{public}s]", valueFirst.c_str(), val.c_str()); + if (val.compare("ActsDataAbilityHelperTest")) { + return returnError2; + break; + } + } else if (valueFirst.compare("age") == 0) { + double age; + valueSecond.GetDouble(age); + APP_LOGI("VerifyActDataAbility it[%{public}s],[%{public}f]", valueFirst.c_str(), age); + if (age != ageI) { + return returnError2; + break; + } + } else if (valueFirst.compare("salary") == 0) { + double salary; + valueSecond.GetDouble(salary); + APP_LOGI("VerifyActDataAbility it[%{public}s],[%{public}f]", valueFirst.c_str(), salary); + if (salary != salaryI) { + return returnError2; + break; + } + } else { + APP_LOGI("VerifyActDataAbility it default[%{public}s]", valueFirst.c_str()); + break; + } + } + } + + int retAbilityBatchInsert = Ability::BatchInsert(uri, values); + APP_LOGI("VerifyActDataAbility BatchInsert retAbility = %{public}d", retAbilityBatchInsert); + return retAbilityBatchInsert; +} +std::vector VerifyActDataAbility::GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) +{ + APP_LOGI("VerifyActDataAbility <<<>>>"); + std::shared_ptr dataUri = std::make_shared("dataability:///com.ix.VerifyActDataAbility"); + defaultReturn = 1; + APP_LOGI("VerifyActDataAbility Delete uri.ToString = %{public}s", uri.ToString().c_str()); + APP_LOGI("VerifyActDataAbility Delete dataUri.ToString = %{public}s", dataUri->ToString().c_str()); + APP_LOGI("VerifyActDataAbility uri.Equals = %{public}d", uri.Equals(*dataUri)); + std::vector vectorFileTypes; + if (uri.Equals(*dataUri) != 1) { + APP_LOGE("VerifyActDataAbility uri.Equals(*dataUri) != 1"); + vectorFileTypes.push_back("Uri error"); + return vectorFileTypes; + } + + if (mimeTypeFilter.compare("*/*") == 0) { + vectorFileTypes.push_back("hap"); + vectorFileTypes.push_back("jpg"); + vectorFileTypes.push_back("image/png"); + } else if (mimeTypeFilter.compare("image/*") == 0) { + vectorFileTypes.push_back("image/png"); + } else if (mimeTypeFilter.compare("*/jpg") == 0) { + vectorFileTypes.push_back("jpg"); + } else if (mimeTypeFilter.compare("returnUndefined") == 0) { + return {}; + } + + return vectorFileTypes; } +Uri VerifyActDataAbility::NormalizeUri(const Uri &uri) +{ + APP_LOGI("VerifyActDataAbility <<<>>>"); + APP_LOGI("VerifyActDataAbility NormalizeUri uri = %{public}s", uri.ToString().c_str()); + std::shared_ptr dataUri = std::make_shared("dataability:///com.ix.VerifyActDataAbility"); + std::shared_ptr dataUri3 = std::make_shared("dataability:///com.ix.VerifyActDataAbility3"); + Uri dataUriNull(""); + Uri dataUriError("errorUri"); + APP_LOGI("VerifyActDataAbility NormalizeUri dataUri.ToString = %{public}s", dataUri->ToString().c_str()); + APP_LOGI("VerifyActDataAbility uri.Equals = %{public}d", uri.Equals(*dataUri)); + if (uri.Equals(*dataUri) != 1) { + if (uri.Equals(*dataUri3) == 1) { + return dataUriNull; + } + return dataUriError; + } + return uri; +} + +Uri VerifyActDataAbility::DenormalizeUri(const Uri &uri) +{ + APP_LOGI("VerifyActDataAbility <<<>>>"); + APP_LOGI("VerifyActDataAbility DenormalizeUri uri = %{public}s", uri.ToString().c_str()); + std::shared_ptr dataUri = std::make_shared("dataability:///com.ix.VerifyActDataAbility"); + std::shared_ptr dataUri3 = std::make_shared("dataability:///com.ix.VerifyActDataAbility3"); + Uri dataUriNull(""); + Uri dataUriError("errorUri"); + APP_LOGI("VerifyActDataAbility DenormalizeUri dataUri.ToString = %{public}s", dataUri->ToString().c_str()); + APP_LOGI("VerifyActDataAbility uri.Equals = %{public}d", uri.Equals(*dataUri)); + + if (uri.Equals(*dataUri) != 1) { + if (uri.Equals(*dataUri3) == 1) { + return dataUriNull; + } + return dataUriError; + } + return uri; +} REGISTER_AA(VerifyActDataAbility); } // namespace AppExecFwk } // namespace OHOS diff --git a/tools/aa/src/ability_command.cpp b/tools/aa/src/ability_command.cpp index c95050bd1d0..b08e0b38bef 100644 --- a/tools/aa/src/ability_command.cpp +++ b/tools/aa/src/ability_command.cpp @@ -629,13 +629,9 @@ ErrCode AbilityManagerShellCommand::RunAsDumpsysCommand() if (isfirstCommand == false) { isfirstCommand = true; } else { - // 'aa dumpsys -i 10 -element -lastpage' - // 'aa dumpsys -i 10 -render -lastpage' - if (strcmp(optarg, "astpage")) { - result = OHOS::ERR_INVALID_VALUE; - resultReceiver_.append(HELP_MSG_DUMPSYS); - return result; - } + result = OHOS::ERR_INVALID_VALUE; + resultReceiver_.append(HELP_MSG_DUMPSYS); + return result; } // 'aa dumpsys -l' // 'aa dumpsys --mission-list' @@ -652,12 +648,9 @@ ErrCode AbilityManagerShellCommand::RunAsDumpsysCommand() return result; } } else { - // 'aa dumpsys -i 10 -inspector' - if (strcmp(optarg, "nspector")) { - result = OHOS::ERR_INVALID_VALUE; - resultReceiver_.append(HELP_MSG_DUMPSYS); - return result; - } + result = OHOS::ERR_INVALID_VALUE; + resultReceiver_.append(HELP_MSG_DUMPSYS); + return result; } // 'aa dumpsys -i' // 'aa dumpsys --ability' @@ -667,12 +660,9 @@ ErrCode AbilityManagerShellCommand::RunAsDumpsysCommand() if (isfirstCommand == false) { isfirstCommand = true; } else { - // 'aa dumpsys -i 10 -element' - if (strcmp(optarg, "lement")) { - result = OHOS::ERR_INVALID_VALUE; - resultReceiver_.append(HELP_MSG_DUMPSYS); - return result; - } + result = OHOS::ERR_INVALID_VALUE; + resultReceiver_.append(HELP_MSG_DUMPSYS); + return result; } // 'aa dumpsys -e' // 'aa dumpsys --extension' @@ -694,12 +684,9 @@ ErrCode AbilityManagerShellCommand::RunAsDumpsysCommand() if (isfirstCommand == false) { isfirstCommand = true; } else { - // 'aa dumpsys -i 10 -render' - if (strcmp(optarg, "ender")) { - result = OHOS::ERR_INVALID_VALUE; - resultReceiver_.append(HELP_MSG_DUMPSYS); - return result; - } + result = OHOS::ERR_INVALID_VALUE; + resultReceiver_.append(HELP_MSG_DUMPSYS); + return result; } // 'aa dumpsys -r' // 'aa dumpsys --process' diff --git a/tools/test/mock/mock_ability_manager_stub.h b/tools/test/mock/mock_ability_manager_stub.h index 990e06c9547..15e4358bf46 100644 --- a/tools/test/mock/mock_ability_manager_stub.h +++ b/tools/test/mock/mock_ability_manager_stub.h @@ -119,7 +119,7 @@ public: MOCK_METHOD1(SetShowOnLockScreen, int(bool isAllow)); MOCK_METHOD1(GetSystemMemoryAttr, void(AppExecFwk::SystemMemoryAttr &memoryInfo)); MOCK_METHOD3(StartContinuation, int(const Want &want, const sptr &abilityToken, int32_t status)); - MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); + MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, const int32_t result)); MOCK_METHOD5(ContinueMission, int(const std::string &srcDeviceId, const std::string &dstDeviceId, int32_t missionId, const sptr &callBack, AAFwk::WantParams &wantParams)); MOCK_METHOD2(ContinueAbility, int(const std::string &deviceId, int32_t missionId)); @@ -135,7 +135,6 @@ public: MOCK_METHOD1(CleanMission, int(int32_t missionId)); MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); - MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions &startOptions)); MOCK_METHOD2(SetMissionLabel, int(const sptr &token, const std::string &label)); MOCK_METHOD1(ClearUpApplicationData, int(const std::string &)); diff --git a/zidl/bundle.json b/zidl/bundle.json deleted file mode 100644 index 5127a051270..00000000000 --- a/zidl/bundle.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "@ohos/zidl", - "description": "提供自动生成Extension 服务端及客户端接口文件的能力", - "version": "3.1", - "license": "Apache License 2.0", - "publishAs": "code-segment", - "segment": { - "destPath": "foundation/aafwk/standard/zidl" - }, - "dirs": {}, - "scripts": {}, - "component": { - "name": "zidl", - "subsystem": "aafwk", - "syscap": [], - "features": [], - "adapted_system_type": [ - "standard" - ], - "rom": "", - "ram": "", - "deps": { - "components": [ - "hiviewdfx_hilog_native", - "ipc", - "samgr_standard", - "utils_base" - ], - "third_party": [] - }, - "build": { - "sub_component": [], - "inner_kits": [], - "test": [] - } - } -} \ No newline at end of file diff --git a/zidl/test/native/BUILD.gn b/zidl/test/native/BUILD.gn deleted file mode 100644 index 8dc9839a534..00000000000 --- a/zidl/test/native/BUILD.gn +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") - -IPC_SUBSYSTEM_DIR = "//foundation/communication/ipc" -ZIDL_TEST_DIR = "//foundation/aafwk/standard/zidl/test/native" - -config("ipc_test_config") { - include_dirs = [ - "//utils/native/base/include", - "$ZIDL_TEST_DIR/include", - "$IPC_SUBSYSTEM_DIR/utils/include", - "$IPC_SUBSYSTEM_DIR/ipc/native/src/mock/include", - "//utils/system/safwk/native/include", - ] -} - -ohos_executable("zidl_server_test") { - sources = [ - "./src/main_server.cpp", - "./src/test_service.cpp", - "./src/zidl_test_service_stub.cpp", - ] - - configs = [ ":ipc_test_config" ] - - deps = [ "//utils/native/base:utils" ] - - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "samgr_standard:samgr_proxy", - ] - - subsystem_name = "aafwk" - part_name = "zidl" -} - -ohos_executable("zidl_client_test") { - sources = [ - "./src/main_client.cpp", - "./src/test_client.cpp", - "./src/zidl_test_service_proxy.cpp", - ] - - configs = [ ":ipc_test_config" ] - - deps = [ "//utils/native/base:utils" ] - - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "samgr_standard:samgr_proxy", - ] - - subsystem_name = "aafwk" - part_name = "zidl" -} diff --git a/zidl/test/native/include/izidl_test_service.h b/zidl/test/native/include/izidl_test_service.h deleted file mode 100644 index 3f6308363a8..00000000000 --- a/zidl/test/native/include/izidl_test_service.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_IZIDLTESTSERVICE_H -#define OHOS_IZIDLTESTSERVICE_H - -#include -#include - -namespace OHOS { -class IZidlTestService : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IZidlTestService"); - - virtual ErrCode TestIntTransaction( - /* [in] */ int _data, - /* [out] */ int& result) = 0; - - virtual ErrCode TestStringTransaction( - /* [in] */ const std::string& _data) = 0; -}; -} // namespace OHOS -#endif // OHOS_IZIDLTESTSERVICE_H - diff --git a/zidl/test/native/include/test_client.h b/zidl/test/native/include/test_client.h deleted file mode 100644 index 4d54213003b..00000000000 --- a/zidl/test/native/include/test_client.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_IPC_TEST_SERVICE_CLIENT_H -#define OHOS_IPC_TEST_SERVICE_CLIENT_H - -#include "ipc_debug.h" -#include "log_tags.h" -#include "zidl_test_service_proxy.h" - -namespace OHOS { -class TestClient { -public: - int ConnectService(); - void StartIntTransaction(); - void StartStringTransaction(); -private: - static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "TestClient" }; - sptr testService_; -}; -} // namespace OHOS -#endif // OHOS_IPC_TEST_SERVICE_CLIENT_H diff --git a/zidl/test/native/include/test_service.h b/zidl/test/native/include/test_service.h deleted file mode 100644 index 2c29658c761..00000000000 --- a/zidl/test/native/include/test_service.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_IPC_TEST_SERVICE_H -#define OHOS_IPC_TEST_SERVICE_H - -#include "hilog/log.h" -#include "log_tags.h" -#include "zidl_test_service_stub.h" - -namespace OHOS { -class TestService : public ZidlTestServiceStub { -public: - TestService(); - ~TestService(); - static int Instantiate(); - ErrCode TestIntTransaction(int data, int &rep) override; - ErrCode TestStringTransaction(const std::string& data) override; -private: - static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "TestService" }; -}; -} // namespace OHOS -#endif // OHOS_IPC_TEST_SERVICE_H - diff --git a/zidl/test/native/include/zidl_test_service_proxy.h b/zidl/test/native/include/zidl_test_service_proxy.h deleted file mode 100644 index 7e9ea4dcd58..00000000000 --- a/zidl/test/native/include/zidl_test_service_proxy.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDLTESTSERVICEPROXY_H -#define OHOS_ZIDLTESTSERVICEPROXY_H - -#include "izidl_test_service.h" -#include - -namespace OHOS { -class ZidlTestServiceProxy : public IRemoteProxy { -public: - explicit ZidlTestServiceProxy( - /* [in] */ const sptr& remote) - : IRemoteProxy(remote) - {} - - virtual ~ZidlTestServiceProxy() - {} - - ErrCode TestIntTransaction( - /* [in] */ int _data, - /* [out] */ int& result) override; - - ErrCode TestStringTransaction( - /* [in] */ const std::string& _data) override; - -private: - static constexpr int COMMAND_TEST_INT_TRANSACTION = MIN_TRANSACTION_ID + 0; - static constexpr int COMMAND_TEST_STRING_TRANSACTION = MIN_TRANSACTION_ID + 1; - - static inline BrokerDelegator delegator_; -}; -} // namespace OHOS -#endif // OHOS_ZIDLTESTSERVICEPROXY_H - diff --git a/zidl/test/native/include/zidl_test_service_stub.h b/zidl/test/native/include/zidl_test_service_stub.h deleted file mode 100644 index d88b615bb1f..00000000000 --- a/zidl/test/native/include/zidl_test_service_stub.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDLTESTSERVICESTUB_H -#define OHOS_ZIDLTESTSERVICESTUB_H - -#include "izidl_test_service.h" -#include - -namespace OHOS { -class ZidlTestServiceStub : public IRemoteStub { -public: - int OnRemoteRequest( - /* [in] */ uint32_t code, - /* [in] */ MessageParcel& data, - /* [out] */ MessageParcel& reply, - /* [in] */ MessageOption& option) override; - -private: - static constexpr int COMMAND_TEST_INT_TRANSACTION = MIN_TRANSACTION_ID + 0; - static constexpr int COMMAND_TEST_STRING_TRANSACTION = MIN_TRANSACTION_ID + 1; -}; -} // namespace OHOS -#endif // OHOS_ZIDLTESTSERVICESTUB_H - diff --git a/zidl/test/native/src/main_client.cpp b/zidl/test/native/src/main_client.cpp deleted file mode 100644 index 7238b197b76..00000000000 --- a/zidl/test/native/src/main_client.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "ipc_debug.h" -#include "ipc_skeleton.h" -#include "log_tags.h" -#include "test_client.h" - -using namespace OHOS; -using namespace OHOS::HiviewDFX; -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "IPCTestClient" }; - -enum TestCommand { - TEST_CMD_NONE = 0, - TEST_CMD_INT_TRANS = 1, - TEST_CMD_STRING_TRANS = 2 -}; - -namespace { -std::vector GetArgvOptions(int argc, char **argv) -{ - std::vector argvOptions; - for (int i = 1; i < argc; i++) { - argvOptions.emplace_back(std::string(argv[i])); - } - return argvOptions; -} -} - -int main(int argc, char *argv[]) -{ - TestCommand commandId = TestCommand::TEST_CMD_INT_TRANS; - if (argc > 1) { - commandId = TestCommand(atoi(argv[1])); - } else { - ZLOGE(LABEL, "unknown command"); - } - std::vector argvOptions; - argvOptions = GetArgvOptions(argc, argv); - std::unique_ptr testClient = std::make_unique(); - if (testClient->ConnectService()) { - return -1; - } - - ZLOGE(LABEL, "commandId= : %{public}d", commandId); - switch (commandId) { - case TestCommand::TEST_CMD_INT_TRANS: - testClient->StartIntTransaction(); - break; - case TestCommand::TEST_CMD_STRING_TRANS: - testClient->StartStringTransaction(); - break; - default: - ZLOGI(LABEL, "main arg error"); - break; - } - - IPCSkeleton::JoinWorkThread(); - return 0; -} diff --git a/zidl/test/native/src/main_server.cpp b/zidl/test/native/src/main_server.cpp deleted file mode 100644 index 0765721662f..00000000000 --- a/zidl/test/native/src/main_server.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ipc_debug.h" -#include "ipc_skeleton.h" -#include "log_tags.h" -#include "test_service.h" - -using namespace OHOS; -using namespace OHOS::HiviewDFX; - -[[maybe_unused]]static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "IPCTestServer" }; - -int main(int argc __attribute__((unused)), char **argv __attribute__((unused))) -{ - TestService::Instantiate(); - ZLOGI(LABEL, "call StartThreadPool"); - IPCSkeleton::JoinWorkThread(); -} diff --git a/zidl/test/native/src/test_client.cpp b/zidl/test/native/src/test_client.cpp deleted file mode 100644 index b2e7abd8e58..00000000000 --- a/zidl/test/native/src/test_client.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "test_client.h" - -#include "if_system_ability_manager.h" -#include "ipc_debug.h" -#include "ipc_skeleton.h" -#include "iservice_registry.h" -#include "system_ability_definition.h" - -namespace OHOS { -int TestClient::ConnectService() -{ - auto saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (saMgr == nullptr) { - ZLOGE(LABEL, "get registry fail"); - return -1; - } - - sptr object = saMgr->GetSystemAbility(IPC_TEST_SERVICE); - - if (object != nullptr) { - ZLOGE(LABEL, "Got test Service object"); - testService_ = (new (std::nothrow) ZidlTestServiceProxy(object)); - } - - if (testService_ == nullptr) { - ZLOGE(LABEL, "Could not find Test Service!"); - return -1; - } - - return 0; -} - -void TestClient::StartIntTransaction() -{ - if (testService_ != nullptr) { - ZLOGE(LABEL, "StartIntTransaction"); - [[maybe_unused]] int result = 0; - testService_->TestIntTransaction(1234, result); // 1234 : test number - ZLOGE(LABEL, "Rec result from server %{public}d.", result); - } -} - -void TestClient::StartStringTransaction() -{ - if (testService_ != nullptr) { - ZLOGI(LABEL, "StartIntTransaction"); - testService_->TestStringTransaction("ZIDL Test"); - } -} -} // namespace OHOS diff --git a/zidl/test/native/src/test_service.cpp b/zidl/test/native/src/test_service.cpp deleted file mode 100644 index acf2f6346c1..00000000000 --- a/zidl/test/native/src/test_service.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "test_service.h" - -#include - -#include "if_system_ability_manager.h" -#include "ipc_debug.h" -#include "ipc_skeleton.h" -#include "iservice_registry.h" -#include "system_ability_definition.h" - -namespace OHOS { -using namespace OHOS::HiviewDFX; - -int TestService::Instantiate() -{ - ZLOGI(LABEL, "%{public}s call in", __func__); - auto saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (saMgr == nullptr) { - ZLOGE(LABEL, "%{public}s:fail to get Registry", __func__); - return -ENODEV; - } - - sptr newInstance = new TestService(); - int result = saMgr->AddSystemAbility(IPC_TEST_SERVICE, newInstance); - ZLOGI(LABEL, "%{public}s: IPC_TEST_SERVICE result = %{public}d", __func__, result); - return result; -} - -TestService::TestService() -{ -} - -TestService::~TestService() -{ -} - -ErrCode TestService::TestIntTransaction(int data, int &rep) -{ - ZLOGE(LABEL, " TestService:read from client data = %{public}d", data); - rep = data + data; - return ERR_NONE; -} - -ErrCode TestService::TestStringTransaction(const std::string &data) -{ - ZLOGE(LABEL, "TestService:read string from client data = %{public}s", data.c_str()); - return data.size(); -} -} // namespace OHOS diff --git a/zidl/test/native/src/zidl_test_service_proxy.cpp b/zidl/test/native/src/zidl_test_service_proxy.cpp deleted file mode 100644 index 314cadb6a24..00000000000 --- a/zidl/test/native/src/zidl_test_service_proxy.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "zidl_test_service_proxy.h" - -namespace OHOS { -ErrCode ZidlTestServiceProxy::TestIntTransaction( - /* [in] */ int _data, - /* [out] */ int& result) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - - data.WriteInt32(_data); - - int32_t st = Remote()->SendRequest(COMMAND_TEST_INT_TRANSACTION, data, reply, option); - if (st != ERR_NONE) { - return st; - } - - ErrCode ec = reply.ReadInt32(); - if (FAILED(ec)) { - return ec; - } - - result = reply.ReadInt32(); - return ERR_OK; -} - -ErrCode ZidlTestServiceProxy::TestStringTransaction( - /* [in] */ const std::string& _data) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - - data.WriteString16(Str8ToStr16(_data)); - - int32_t st = Remote()->SendRequest(COMMAND_TEST_STRING_TRANSACTION, data, reply, option); - if (st != ERR_NONE) { - return st; - } - - ErrCode ec = reply.ReadInt32(); - if (FAILED(ec)) { - return ec; - } - - return ERR_OK; -} -} // namespace OHOS diff --git a/zidl/test/native/src/zidl_test_service_stub.cpp b/zidl/test/native/src/zidl_test_service_stub.cpp deleted file mode 100644 index adf63cd1dec..00000000000 --- a/zidl/test/native/src/zidl_test_service_stub.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "zidl_test_service_stub.h" - -namespace OHOS { -int ZidlTestServiceStub::OnRemoteRequest( - /* [in] */ uint32_t code, - /* [in] */ MessageParcel& data, - /* [out] */ MessageParcel& reply, - /* [in] */ MessageOption& option) -{ - switch (code) { - case COMMAND_TEST_INT_TRANSACTION: { - int _data = data.ReadInt32(); - int result; - ErrCode ec = TestIntTransaction(_data, result); - reply.WriteInt32(ec); - if (SUCCEEDED(ec)) { - reply.WriteInt32(result); - } - return ERR_NONE; - } - case COMMAND_TEST_STRING_TRANSACTION: { - std::string _data = Str16ToStr8(data.ReadString16()); - ErrCode ec = TestStringTransaction(_data); - reply.WriteInt32(ec); - return ERR_NONE; - } - default: - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - - return ERR_TRANSACTION_FAILED; -} -} // namespace OHOS diff --git a/zidl/test/zidlgen/IZidlTestService.zidl b/zidl/test/zidlgen/IZidlTestService.zidl deleted file mode 100644 index 8d2fa0b91c5..00000000000 --- a/zidl/test/zidlgen/IZidlTestService.zidl +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -interface OHOS.IZidlTestService { - int TestIntTransaction([in] int data); - void TestStringTransaction([in] String data); -} \ No newline at end of file diff --git a/zidl/test/zidlgen/zidl b/zidl/test/zidlgen/zidl deleted file mode 100644 index c3bde7295221617c5bdc4e7a695702a580ac0c22..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 216360 zcmeFa34ByV);?Sb0Ru*D6&;k!cnOOELP$b@u!s#wkU)S)0wRl@Ch3rdPSSRFASh~N zP*G7MqB4pamr+zkqoSfB#u*oMP&2N`fD?Db=)@fz)bFXPQ{DGg_f0@?-uM6g-U}zE z`>AtJovJ!@YPm~akY6}4J}!=_qYE3y_&4JMi8(1Dbz&DK!kjFJ9ge@rtT*chGy&wK zRGnAG%LK&}Nsepd=WU>LohOr=;>tqK`FVCn&l)MIICDrzj&=nZl&;FBcuTW9PjT~k zyo~KbW%=8uTX|zosb6vZyoNj}-w@KcJdHKUY?(TbR|n6p)G6glORc~t6q!lAM)qVw)Zk%-O{lB9f?%dhNooX71v*n`{1=^1KwojXaP;;OBO`n(H9 zWDoU~5Ak`cYwL#8<%}3IB0D`;lb$8?@n+^FIBnWYp@G*LWf4y27*BVe(LME{As@8d z_+}_`#hBqCae~dC(|{inBdr3M5d*)_2EWM$e-wC13_Yt*@L2dwz+>6-DI6gde#X(U z@d3SK<1qZ19h5@a@&H_3X95zp}x52|JHu z&3k0D96=@gz~K6iWc3fqabY~+g9l37@tnkOCHxN=68C>0@g~B*BK<|5Nd4Og|LfsW zzVtFFkMJUnRTxiszD?Ikd?ewmLnPkZQ|d7Ye{rnDi*`u)T}oc`uOnH*GATcp@HrR+ zxPHgu63>>Wu`d%P-oDCePgkSr34bYH;?8u5 zPa%8-DvH~0WJr7^;rEwGy!l0m-;8-1KW?ie`MnZ|i{j23miK}wep?`6I^It0K zCy(U+e7e+AR4wKE5q=B#dGqZO-$eMSbEJIx9TGo+@FP)C!hX%3Lh=XWI9YG#&f+jo z4ldvRvD9-S;rWKdn>I;1FD861)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?70{gdz}Z@0>~_`T&eeo3YyA7dl&)C+e&ZE*9mu=OxeAB3x8v~rMKp5%eCff zrste))!#~g8h)(Pc>L$D{eyJ(#fcKO{#x^`1>b}Zrnl<<{i|dPEjP=WcvS+c9aefC znoCXpe4$Klxl2o}n9{ZCZ~0O#Ure93@L!gelz-aC zNuTccvS7<)+1%8$(p&OXhf3eQJS!cNh#!R_=3%AJovq3(lJ4AY8FWv73~AYSR(eam zSXe53_Azt(taO%ZWy=l7)bfk&mg$OSNH;1{C;wRKEuWFy(p&QE;F&W08dbg(zk7N+ z!c)uNGF?HLbgg)n+r9h}1klfl-93FlxB7Q4|D%+& RRvC1y@^N=W+OHdE`#(nTh9Lj| -- Gitee From d34bb96d4a969ebc8f75b64d713fa3661a31d2df Mon Sep 17 00:00:00 2001 From: wanchengzhen Date: Tue, 15 Feb 2022 16:50:47 +0800 Subject: [PATCH 2/3] codex Signed-off-by: wanchengzhen --- .../mock/include/mock_app_mgr_service_inner.h | 2 +- .../ams_app_life_cycle_test.cpp | 6 +- .../ams_mgr_scheduler_test.cpp | 2 +- .../ams_app_life_cycle_module_test.cpp | 15 +- .../ams_app_mgr_service_module_test.cpp | 4 +- .../ams_ipc_ams_mgr_module_test.cpp | 2 +- zidl/BUILD.gn | 76 ++ zidl/CMakeLists.txt | 43 + zidl/ast/CMakeLists.txt | 41 + zidl/ast/ast_array_type.cpp | 37 + zidl/ast/ast_array_type.h | 50 + zidl/ast/ast_boolean_type.cpp | 37 + zidl/ast/ast_boolean_type.h | 36 + zidl/ast/ast_byte_type.cpp | 37 + zidl/ast/ast_byte_type.h | 36 + zidl/ast/ast_char_type.cpp | 37 + zidl/ast/ast_char_type.h | 36 + zidl/ast/ast_double_type.cpp | 37 + zidl/ast/ast_double_type.h | 36 + zidl/ast/ast_float_type.cpp | 37 + zidl/ast/ast_float_type.h | 36 + zidl/ast/ast_integer_type.cpp | 37 + zidl/ast/ast_integer_type.h | 36 + zidl/ast/ast_interface_type.cpp | 95 ++ zidl/ast/ast_interface_type.h | 95 ++ zidl/ast/ast_list_type.cpp | 37 + zidl/ast/ast_list_type.h | 51 + zidl/ast/ast_long_type.cpp | 37 + zidl/ast/ast_long_type.h | 36 + zidl/ast/ast_map_type.cpp | 37 + zidl/ast/ast_map_type.h | 63 + zidl/ast/ast_method.cpp | 84 ++ zidl/ast/ast_method.h | 92 ++ zidl/ast/ast_module.cpp | 261 ++++ zidl/ast/ast_module.h | 159 +++ zidl/ast/ast_namespace.cpp | 117 ++ zidl/ast/ast_namespace.h | 93 ++ zidl/ast/ast_node.cpp | 36 + zidl/ast/ast_node.h | 38 + zidl/ast/ast_parameter.cpp | 46 + zidl/ast/ast_parameter.h | 86 ++ zidl/ast/ast_sequenceable_type.cpp | 64 + zidl/ast/ast_sequenceable_type.h | 42 + zidl/ast/ast_short_type.cpp | 37 + zidl/ast/ast_short_type.h | 36 + zidl/ast/ast_string_type.cpp | 37 + zidl/ast/ast_string_type.h | 36 + zidl/ast/ast_type.cpp | 129 ++ zidl/ast/ast_type.h | 83 ++ zidl/ast/ast_void_type.cpp | 37 + zidl/ast/ast_void_type.h | 36 + zidl/bundle.json | 37 + zidl/codegen/CMakeLists.txt | 24 + zidl/codegen/code_emitter.cpp | 48 + zidl/codegen/code_emitter.h | 60 + zidl/codegen/code_generator.cpp | 95 ++ zidl/codegen/code_generator.h | 52 + zidl/codegen/cpp_code_emitter.cpp | 1175 ++++++++++++++++ zidl/codegen/cpp_code_emitter.h | 237 ++++ zidl/codegen/java_code_emitter.cpp | 1178 +++++++++++++++++ zidl/codegen/java_code_emitter.h | 241 ++++ zidl/codegen/js_code_emitter.cpp | 1167 ++++++++++++++++ zidl/codegen/js_code_emitter.h | 236 ++++ zidl/main.cpp | 106 ++ zidl/metadata/CMakeLists.txt | 24 + zidl/metadata/metadata.h | 124 ++ zidl/metadata/metadata_builder.cpp | 502 +++++++ zidl/metadata/metadata_builder.h | 107 ++ zidl/metadata/metadata_dumper.cpp | 299 +++++ zidl/metadata/metadata_dumper.h | 78 ++ zidl/metadata/metadata_reader.cpp | 80 ++ zidl/metadata/metadata_reader.h | 38 + zidl/metadata/metadata_serializer.cpp | 242 ++++ zidl/metadata/metadata_serializer.h | 112 ++ zidl/parser/CMakeLists.txt | 22 + zidl/parser/lexer.cpp | 383 ++++++ zidl/parser/lexer.h | 127 ++ zidl/parser/parser.cpp | 688 ++++++++++ zidl/parser/parser.h | 108 ++ zidl/parser/token.h | 65 + zidl/test/native/BUILD.gn | 69 + zidl/test/native/include/izidl_test_service.h | 36 + zidl/test/native/include/test_client.h | 34 + zidl/test/native/include/test_service.h | 36 + .../native/include/zidl_test_service_proxy.h | 48 + .../native/include/zidl_test_service_stub.h | 37 + zidl/test/native/src/main_client.cpp | 75 ++ zidl/test/native/src/main_server.cpp | 31 + zidl/test/native/src/test_client.cpp | 65 + zidl/test/native/src/test_service.cpp | 64 + .../native/src/zidl_test_service_proxy.cpp | 64 + .../native/src/zidl_test_service_stub.cpp | 48 + zidl/test/zidlgen/IZidlTestService.zidl | 19 + zidl/test/zidlgen/zidl | Bin 0 -> 216360 bytes zidl/util/CMakeLists.txt | 27 + zidl/util/autoptr.h | 309 +++++ zidl/util/file.cpp | 190 +++ zidl/util/file.h | 103 ++ zidl/util/light_refcount_base.cpp | 37 + zidl/util/light_refcount_base.h | 50 + zidl/util/logger.cpp | 82 ++ zidl/util/logger.h | 70 + zidl/util/options.cpp | 108 ++ zidl/util/options.h | 128 ++ zidl/util/string.cpp | 720 ++++++++++ zidl/util/string.h | 192 +++ zidl/util/string_builder.cpp | 171 +++ zidl/util/string_builder.h | 55 + zidl/util/string_pool.cpp | 101 ++ zidl/util/string_pool.h | 64 + 110 files changed, 13393 insertions(+), 11 deletions(-) create mode 100644 zidl/BUILD.gn create mode 100644 zidl/CMakeLists.txt create mode 100644 zidl/ast/CMakeLists.txt create mode 100644 zidl/ast/ast_array_type.cpp create mode 100644 zidl/ast/ast_array_type.h create mode 100644 zidl/ast/ast_boolean_type.cpp create mode 100644 zidl/ast/ast_boolean_type.h create mode 100644 zidl/ast/ast_byte_type.cpp create mode 100644 zidl/ast/ast_byte_type.h create mode 100644 zidl/ast/ast_char_type.cpp create mode 100644 zidl/ast/ast_char_type.h create mode 100644 zidl/ast/ast_double_type.cpp create mode 100644 zidl/ast/ast_double_type.h create mode 100644 zidl/ast/ast_float_type.cpp create mode 100644 zidl/ast/ast_float_type.h create mode 100644 zidl/ast/ast_integer_type.cpp create mode 100644 zidl/ast/ast_integer_type.h create mode 100644 zidl/ast/ast_interface_type.cpp create mode 100644 zidl/ast/ast_interface_type.h create mode 100644 zidl/ast/ast_list_type.cpp create mode 100644 zidl/ast/ast_list_type.h create mode 100644 zidl/ast/ast_long_type.cpp create mode 100644 zidl/ast/ast_long_type.h create mode 100644 zidl/ast/ast_map_type.cpp create mode 100644 zidl/ast/ast_map_type.h create mode 100644 zidl/ast/ast_method.cpp create mode 100644 zidl/ast/ast_method.h create mode 100644 zidl/ast/ast_module.cpp create mode 100644 zidl/ast/ast_module.h create mode 100644 zidl/ast/ast_namespace.cpp create mode 100644 zidl/ast/ast_namespace.h create mode 100644 zidl/ast/ast_node.cpp create mode 100644 zidl/ast/ast_node.h create mode 100644 zidl/ast/ast_parameter.cpp create mode 100644 zidl/ast/ast_parameter.h create mode 100644 zidl/ast/ast_sequenceable_type.cpp create mode 100644 zidl/ast/ast_sequenceable_type.h create mode 100644 zidl/ast/ast_short_type.cpp create mode 100644 zidl/ast/ast_short_type.h create mode 100644 zidl/ast/ast_string_type.cpp create mode 100644 zidl/ast/ast_string_type.h create mode 100644 zidl/ast/ast_type.cpp create mode 100644 zidl/ast/ast_type.h create mode 100644 zidl/ast/ast_void_type.cpp create mode 100644 zidl/ast/ast_void_type.h create mode 100644 zidl/bundle.json create mode 100644 zidl/codegen/CMakeLists.txt create mode 100644 zidl/codegen/code_emitter.cpp create mode 100644 zidl/codegen/code_emitter.h create mode 100644 zidl/codegen/code_generator.cpp create mode 100644 zidl/codegen/code_generator.h create mode 100644 zidl/codegen/cpp_code_emitter.cpp create mode 100644 zidl/codegen/cpp_code_emitter.h create mode 100644 zidl/codegen/java_code_emitter.cpp create mode 100644 zidl/codegen/java_code_emitter.h create mode 100644 zidl/codegen/js_code_emitter.cpp create mode 100644 zidl/codegen/js_code_emitter.h create mode 100644 zidl/main.cpp create mode 100644 zidl/metadata/CMakeLists.txt create mode 100644 zidl/metadata/metadata.h create mode 100644 zidl/metadata/metadata_builder.cpp create mode 100644 zidl/metadata/metadata_builder.h create mode 100644 zidl/metadata/metadata_dumper.cpp create mode 100644 zidl/metadata/metadata_dumper.h create mode 100644 zidl/metadata/metadata_reader.cpp create mode 100644 zidl/metadata/metadata_reader.h create mode 100644 zidl/metadata/metadata_serializer.cpp create mode 100644 zidl/metadata/metadata_serializer.h create mode 100644 zidl/parser/CMakeLists.txt create mode 100644 zidl/parser/lexer.cpp create mode 100644 zidl/parser/lexer.h create mode 100644 zidl/parser/parser.cpp create mode 100644 zidl/parser/parser.h create mode 100644 zidl/parser/token.h create mode 100644 zidl/test/native/BUILD.gn create mode 100644 zidl/test/native/include/izidl_test_service.h create mode 100644 zidl/test/native/include/test_client.h create mode 100644 zidl/test/native/include/test_service.h create mode 100644 zidl/test/native/include/zidl_test_service_proxy.h create mode 100644 zidl/test/native/include/zidl_test_service_stub.h create mode 100644 zidl/test/native/src/main_client.cpp create mode 100644 zidl/test/native/src/main_server.cpp create mode 100644 zidl/test/native/src/test_client.cpp create mode 100644 zidl/test/native/src/test_service.cpp create mode 100644 zidl/test/native/src/zidl_test_service_proxy.cpp create mode 100644 zidl/test/native/src/zidl_test_service_stub.cpp create mode 100644 zidl/test/zidlgen/IZidlTestService.zidl create mode 100644 zidl/test/zidlgen/zidl create mode 100644 zidl/util/CMakeLists.txt create mode 100644 zidl/util/autoptr.h create mode 100644 zidl/util/file.cpp create mode 100644 zidl/util/file.h create mode 100644 zidl/util/light_refcount_base.cpp create mode 100644 zidl/util/light_refcount_base.h create mode 100644 zidl/util/logger.cpp create mode 100644 zidl/util/logger.h create mode 100644 zidl/util/options.cpp create mode 100644 zidl/util/options.h create mode 100644 zidl/util/string.cpp create mode 100644 zidl/util/string.h create mode 100644 zidl/util/string_builder.cpp create mode 100644 zidl/util/string_builder.h create mode 100644 zidl/util/string_pool.cpp create mode 100644 zidl/util/string_pool.h diff --git a/services/appmgr/test/mock/include/mock_app_mgr_service_inner.h b/services/appmgr/test/mock/include/mock_app_mgr_service_inner.h index 5b0ceb1b50b..0d4a28ebf18 100644 --- a/services/appmgr/test/mock/include/mock_app_mgr_service_inner.h +++ b/services/appmgr/test/mock/include/mock_app_mgr_service_inner.h @@ -39,7 +39,7 @@ public: MOCK_METHOD1(ApplicationTerminated, void(const int32_t recordId)); MOCK_METHOD2(UpdateAbilityState, void(const sptr &token, const AbilityState state)); MOCK_METHOD1(TerminateAbility, void(const sptr &token)); - MOCK_METHOD1(KillApplication, int32_t(const std::string &bundleName)); + MOCK_METHOD2(KillApplication, int32_t(const std::string &bundleName, int32_t callerUid)); MOCK_METHOD2(KillApplicationByUid, int(const std::string &, const int uid)); MOCK_METHOD1(AbilityTerminated, void(const sptr &token)); MOCK_METHOD3(ClearUpApplicationData, void(const std::string &, const int32_t, const pid_t)); diff --git a/services/appmgr/test/unittest/ams_app_life_cycle_test/ams_app_life_cycle_test.cpp b/services/appmgr/test/unittest/ams_app_life_cycle_test/ams_app_life_cycle_test.cpp index 2b4ebe05821..b0196d811e7 100644 --- a/services/appmgr/test/unittest/ams_app_life_cycle_test/ams_app_life_cycle_test.cpp +++ b/services/appmgr/test/unittest/ams_app_life_cycle_test/ams_app_life_cycle_test.cpp @@ -1472,7 +1472,8 @@ HWTEST_F(AmsAppLifeCycleTest, Stop_003, TestSize.Level1) */ HWTEST_F(AmsAppLifeCycleTest, KillApplication_001, TestSize.Level1) { - int result = serviceInner_->KillApplication("hwei.ss.bb"); + auto uid = 1000; + int result = serviceInner_->KillApplication("hwei.ss.bb", uid); EXPECT_EQ(ERR_OK, result); } @@ -1512,7 +1513,8 @@ HWTEST_F(AmsAppLifeCycleTest, KillApplication_002, TestSize.Level1) appRecord->SetApplicationClient(client); EXPECT_CALL(*mockAppScheduler, ScheduleProcessSecurityExit()).Times(1); - int ret = serviceInner_->KillApplication(abilityInfo->applicationName); + auto uid = 1000; + int ret = serviceInner_->KillApplication(abilityInfo->applicationName, uid); EXPECT_EQ(ERR_OK, ret); } diff --git a/services/appmgr/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp b/services/appmgr/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp index 6734c2ef131..526ec395e38 100644 --- a/services/appmgr/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp +++ b/services/appmgr/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp @@ -311,7 +311,7 @@ HWTEST_F(AmsMgrSchedulerTest, AmsMgrScheduler_008, TestSize.Level1) auto mockAppMgrServiceInner = GetMockAppMgrServiceInner(); auto amsEventHandler = GetAmsEventHandler(); - EXPECT_CALL(*mockAppMgrServiceInner, KillApplication(_)).Times(1).WillOnce(Return(ERR_OK)); + EXPECT_CALL(*mockAppMgrServiceInner, KillApplication(_, _)).Times(1).WillOnce(Return(ERR_OK)); // check params AppMgrServiceInner std::unique_ptr amsMgrScheduler2 = std::make_unique(nullptr, amsEventHandler); diff --git a/services/test/moduletest/common/ams/app_life_cycle_test/ams_app_life_cycle_module_test.cpp b/services/test/moduletest/common/ams/app_life_cycle_test/ams_app_life_cycle_module_test.cpp index 41ae0c5b356..1b777e64704 100755 --- a/services/test/moduletest/common/ams/app_life_cycle_test/ams_app_life_cycle_module_test.cpp +++ b/services/test/moduletest/common/ams/app_life_cycle_test/ams_app_life_cycle_module_test.cpp @@ -682,7 +682,8 @@ HWTEST_F(AmsAppLifeCycleModuleTest, StateChange_006, TestSize.Level2) CheckState(appRunningRecord, token, AbilityState::ABILITY_STATE_BACKGROUND, ApplicationState::APP_STATE_BACKGROUND); EXPECT_CALL(*mockAppScheduler, ScheduleProcessSecurityExit()).Times(1); - int32_t ret = serviceInner_->KillApplication(appInfo->bundleName); + auto uid = 1000; + int32_t ret = serviceInner_->KillApplication(appInfo->bundleName, uid); EXPECT_EQ(ret, 0); serviceInner_->OnRemoteDied(mockAppScheduler); // A faked death recipient. auto record = serviceInner_->GetAppRunningRecordByAppRecordId(recordId); @@ -1710,7 +1711,9 @@ HWTEST_F(AmsAppLifeCycleModuleTest, KillApplication_001, TestSize.Level1) EXPECT_EQ(2, static_cast(appMap.size())); EXPECT_CALL(*mockAppScheduler, ScheduleProcessSecurityExit()).Times(1); EXPECT_CALL(*mockAppScheduler1, ScheduleProcessSecurityExit()).Times(1); - int32_t ret = serviceInner_->KillApplication("com.ohos.test.helloworld0"); + + auto uid = 1000; + int32_t ret = serviceInner_->KillApplication("com.ohos.test.helloworld0", uid); EXPECT_EQ(ret, 0); serviceInner_->OnRemoteDied(mockAppScheduler); // A faked death recipient. auto appMap1 = serviceInner_->appRunningManager_->GetAppRunningRecordMap(); @@ -1764,7 +1767,9 @@ HWTEST_F(AmsAppLifeCycleModuleTest, KillApplication_002, TestSize.Level1) auto appMap = serviceInner_->appRunningManager_->GetAppRunningRecordMap(); EXPECT_EQ(2, static_cast(appMap.size())); EXPECT_CALL(*mockAppScheduler, ScheduleProcessSecurityExit()).Times(1); - int32_t ret = serviceInner_->KillApplication("com.ohos.test.helloworld103"); + + auto uid = 1000; + int32_t ret = serviceInner_->KillApplication("com.ohos.test.helloworld103", uid); EXPECT_EQ(ret, 0); serviceInner_->OnRemoteDied(mockAppScheduler); // A faked death recipient. auto appMap1 = serviceInner_->appRunningManager_->GetAppRunningRecordMap(); @@ -1815,7 +1820,9 @@ HWTEST_F(AmsAppLifeCycleModuleTest, KillApplication_003, TestSize.Level1) auto appMap = serviceInner_->appRunningManager_->GetAppRunningRecordMap(); EXPECT_EQ(1, static_cast(appMap.size())); EXPECT_CALL(*mockAppScheduler, ScheduleProcessSecurityExit()).Times(1); - int32_t ret = serviceInner_->KillApplication("com.ohos.test.helloworld101"); + + auto uid = 1000; + int32_t ret = serviceInner_->KillApplication("com.ohos.test.helloworld101", uid); EXPECT_EQ(ret, 0); serviceInner_->OnRemoteDied(mockAppScheduler); // A faked death recipient. auto appMap1 = serviceInner_->appRunningManager_->GetAppRunningRecordMap(); diff --git a/services/test/moduletest/common/ams/app_mgr_service_test/ams_app_mgr_service_module_test.cpp b/services/test/moduletest/common/ams/app_mgr_service_test/ams_app_mgr_service_module_test.cpp index 7cf2697ee73..a288a15525d 100644 --- a/services/test/moduletest/common/ams/app_mgr_service_test/ams_app_mgr_service_module_test.cpp +++ b/services/test/moduletest/common/ams/app_mgr_service_test/ams_app_mgr_service_module_test.cpp @@ -418,7 +418,7 @@ HWTEST_F(AppMgrServiceModuleTest, KillApplication_001, TestSize.Level1) bool testResult = false; Semaphore sem(0); - auto mockHandler = [&testResult, testBundleName, &sem](const std::string &bundleName) { + auto mockHandler = [&testResult, testBundleName, &sem](const std::string &bundleName, int32_t callerUid) { testResult = (bundleName == testBundleName); sem.Post(); return 0; @@ -427,7 +427,7 @@ HWTEST_F(AppMgrServiceModuleTest, KillApplication_001, TestSize.Level1) for (int i = 0; i < COUNT; ++i) { testResult = false; - EXPECT_CALL(*mockAppMgrServiceInner_, KillApplication(_)).Times(1).WillOnce(Invoke(mockHandler)); + EXPECT_CALL(*mockAppMgrServiceInner_, KillApplication(_, _)).Times(1).WillOnce(Invoke(mockHandler)); int ret = appMgrService_->GetAmsMgr()->KillApplication(testBundleName); diff --git a/services/test/moduletest/common/ams/ipc_ams_mgr_test/ams_ipc_ams_mgr_module_test.cpp b/services/test/moduletest/common/ams/ipc_ams_mgr_test/ams_ipc_ams_mgr_module_test.cpp index b85df8ce86f..c3650a192cf 100644 --- a/services/test/moduletest/common/ams/ipc_ams_mgr_test/ams_ipc_ams_mgr_module_test.cpp +++ b/services/test/moduletest/common/ams/ipc_ams_mgr_test/ams_ipc_ams_mgr_module_test.cpp @@ -368,7 +368,7 @@ HWTEST_F(AmsIpcAmsmgrModuleTest, ExcuteAmsmgrIPCInterface_006, TestSize.Level3) mockMockAppMgr->Wait(); for (int i = 0; i < COUNT; i++) { - EXPECT_CALL(*mockAppMgrServiceInner, KillApplication(_)) + EXPECT_CALL(*mockAppMgrServiceInner, KillApplication(_, _)) .WillOnce(InvokeWithoutArgs(mockAppMgrServiceInner.get(), &MockAppMgrServiceInner::Post4Int)); amsMgrScheduler_->KillApplication(bundleName); mockAppMgrServiceInner->Wait(); diff --git a/zidl/BUILD.gn b/zidl/BUILD.gn new file mode 100644 index 00000000000..3ff94170fda --- /dev/null +++ b/zidl/BUILD.gn @@ -0,0 +1,76 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. + +import("//build/ohos.gni") + +config("zidl_config") { + include_dirs = [ + "./", + "//utils/native/base/include/", + ] +} + +common_sources = [ + "ast/ast_array_type.cpp", + "ast/ast_boolean_type.cpp", + "ast/ast_byte_type.cpp", + "ast/ast_char_type.cpp", + "ast/ast_double_type.cpp", + "ast/ast_float_type.cpp", + "ast/ast_integer_type.cpp", + "ast/ast_interface_type.cpp", + "ast/ast_list_type.cpp", + "ast/ast_long_type.cpp", + "ast/ast_map_type.cpp", + "ast/ast_method.cpp", + "ast/ast_module.cpp", + "ast/ast_namespace.cpp", + "ast/ast_node.cpp", + "ast/ast_parameter.cpp", + "ast/ast_sequenceable_type.cpp", + "ast/ast_short_type.cpp", + "ast/ast_string_type.cpp", + "ast/ast_type.cpp", + "ast/ast_void_type.cpp", +] + +common_sources += [ + "codegen/code_emitter.cpp", + "codegen/code_generator.cpp", + "codegen/cpp_code_emitter.cpp", + "codegen/java_code_emitter.cpp", + "codegen/js_code_emitter.cpp", +] + +common_sources += [ + "metadata/metadata_builder.cpp", + "metadata/metadata_dumper.cpp", + "metadata/metadata_reader.cpp", + "metadata/metadata_serializer.cpp", +] + +common_sources += [ + "parser/lexer.cpp", + "parser/parser.cpp", +] + +common_sources += [ + "util/file.cpp", + "util/light_refcount_base.cpp", + "util/logger.cpp", + "util/options.cpp", + "util/string.cpp", + "util/string_builder.cpp", + "util/string_pool.cpp", +] + +ohos_executable("zidl") { + sources = [ "main.cpp" ] + sources += common_sources + + configs = [ ":zidl_config" ] + + deps = [ "//utils/native/base:utilsecurec" ] + + part_name = "zidl" + subsystem_name = "aafwk" +} diff --git a/zidl/CMakeLists.txt b/zidl/CMakeLists.txt new file mode 100644 index 00000000000..491e5326b8d --- /dev/null +++ b/zidl/CMakeLists.txt @@ -0,0 +1,43 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 2.8) + +project(zidl CXX) + +set(ZIDL_DIR ${CMAKE_SOURCE_DIR}) + +include_directories( + ${ZIDL_DIR}) + +add_subdirectory(ast) +add_subdirectory(codegen) +add_subdirectory(metadata) +add_subdirectory(parser) +add_subdirectory(util) + +set(SOURCES + main.cpp) + +set(LINK_LIBS + -Wl,--whole-archive + ast + codegen + metadata + parser + util + -Wl,--no-whole-archive) + +add_executable(zidl ${SOURCES}) +target_link_libraries(zidl + ${LINK_LIBS}) \ No newline at end of file diff --git a/zidl/ast/CMakeLists.txt b/zidl/ast/CMakeLists.txt new file mode 100644 index 00000000000..bfcd05c1053 --- /dev/null +++ b/zidl/ast/CMakeLists.txt @@ -0,0 +1,41 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_directories( + ${ZIDL_DIR}) + +set(SOURCES + ast_array_type.cpp + ast_boolean_type.cpp + ast_byte_type.cpp + ast_char_type.cpp + ast_double_type.cpp + ast_float_type.cpp + ast_integer_type.cpp + ast_interface_type.cpp + ast_list_type.cpp + ast_long_type.cpp + ast_map_type.cpp + ast_method.cpp + ast_module.cpp + ast_namespace.cpp + ast_node.cpp + ast_parameter.cpp + ast_sequenceable_type.cpp + ast_short_type.cpp + ast_string_type.cpp + ast_type.cpp + ast_void_type.cpp) + +add_library(ast STATIC + ${SOURCES}) \ No newline at end of file diff --git a/zidl/ast/ast_array_type.cpp b/zidl/ast/ast_array_type.cpp new file mode 100644 index 00000000000..01c08bfcbda --- /dev/null +++ b/zidl/ast/ast_array_type.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_array_type.h" + +namespace OHOS { +namespace Zidl { + +String ASTArrayType::GetSignature() +{ + return String::Format("[%s", elementType_->GetSignature().string()); +} + +bool ASTArrayType::IsArrayType() +{ + return true; +} + +String ASTArrayType::ToString() +{ + return String::Format("%s[]", elementType_->ToString().string()); +} + +} +} diff --git a/zidl/ast/ast_array_type.h b/zidl/ast/ast_array_type.h new file mode 100644 index 00000000000..8dc4541a830 --- /dev/null +++ b/zidl/ast/ast_array_type.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTARRAYTYPE_H +#define OHOS_ZIDL_ASTARRAYTYPE_H + +#include "ast/ast_type.h" + +namespace OHOS { +namespace Zidl { + +class ASTArrayType : public ASTType { +public: + inline void SetElementType( + /* [in] */ ASTType* elementType) + { + elementType_ = elementType; + } + + inline AutoPtr GetElementType() + { + return elementType_; + } + + String GetSignature() override; + + bool IsArrayType() override; + + String ToString() override; + +private: + AutoPtr elementType_; +}; + +} +} + +#endif // OHOS_ZIDL_ASTARRAYTYPE_H \ No newline at end of file diff --git a/zidl/ast/ast_boolean_type.cpp b/zidl/ast/ast_boolean_type.cpp new file mode 100644 index 00000000000..011e51dc480 --- /dev/null +++ b/zidl/ast/ast_boolean_type.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_boolean_type.h" + +namespace OHOS { +namespace Zidl { + +String ASTBooleanType::GetSignature() +{ + return "Z"; +} + +bool ASTBooleanType::IsBooleanType() +{ + return true; +} + +String ASTBooleanType::ToString() +{ + return "boolean"; +} + +} +} diff --git a/zidl/ast/ast_boolean_type.h b/zidl/ast/ast_boolean_type.h new file mode 100644 index 00000000000..bc411737587 --- /dev/null +++ b/zidl/ast/ast_boolean_type.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTBOOLEANTYPE_H +#define OHOS_ZIDL_ASTBOOLEANTYPE_H + +#include "ast/ast_type.h" + +namespace OHOS { +namespace Zidl { + +class ASTBooleanType : public ASTType { +public: + String GetSignature() override; + + bool IsBooleanType() override; + + String ToString() override; +}; + +} +} + +#endif // OHOS_ZIDL_ASTBOOLEANTYPE_H diff --git a/zidl/ast/ast_byte_type.cpp b/zidl/ast/ast_byte_type.cpp new file mode 100644 index 00000000000..be3e84298b3 --- /dev/null +++ b/zidl/ast/ast_byte_type.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_byte_type.h" + +namespace OHOS { +namespace Zidl { + +String ASTByteType::GetSignature() +{ + return "B"; +} + +bool ASTByteType::IsByteType() +{ + return true; +} + +String ASTByteType::ToString() +{ + return "byte"; +} + +} +} diff --git a/zidl/ast/ast_byte_type.h b/zidl/ast/ast_byte_type.h new file mode 100644 index 00000000000..561fe580f89 --- /dev/null +++ b/zidl/ast/ast_byte_type.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTBYTETYPE_H +#define OHOS_ZIDL_ASTBYTETYPE_H + +#include "ast/ast_type.h" + +namespace OHOS { +namespace Zidl { + +class ASTByteType : public ASTType { +public: + String GetSignature() override; + + bool IsByteType() override; + + String ToString() override; +}; + +} +} + +#endif // OHOS_ZIDL_ASTBYTETYPE_H diff --git a/zidl/ast/ast_char_type.cpp b/zidl/ast/ast_char_type.cpp new file mode 100644 index 00000000000..6a8682dc989 --- /dev/null +++ b/zidl/ast/ast_char_type.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_char_type.h" + +namespace OHOS { +namespace Zidl { + +String ASTCharType::GetSignature() +{ + return "C"; +} + +bool ASTCharType::IsCharType() +{ + return true; +} + +String ASTCharType::ToString() +{ + return "char"; +} + +} +} diff --git a/zidl/ast/ast_char_type.h b/zidl/ast/ast_char_type.h new file mode 100644 index 00000000000..a2d2487a6f2 --- /dev/null +++ b/zidl/ast/ast_char_type.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTCHARTYPE_H +#define OHOS_ZIDL_ASTCHARTYPE_H + +#include "ast/ast_type.h" + +namespace OHOS { +namespace Zidl { + +class ASTCharType : public ASTType { +public: + String GetSignature() override; + + bool IsCharType() override; + + String ToString() override; +}; + +} +} + +#endif // OHOS_ZIDL_ASTCHARTYPE_H diff --git a/zidl/ast/ast_double_type.cpp b/zidl/ast/ast_double_type.cpp new file mode 100644 index 00000000000..7e6b773553c --- /dev/null +++ b/zidl/ast/ast_double_type.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_double_type.h" + +namespace OHOS { +namespace Zidl { + +String ASTDoubleType::GetSignature() +{ + return "D"; +} + +bool ASTDoubleType::IsDoubleType() +{ + return true; +} + +String ASTDoubleType::ToString() +{ + return "double"; +} + +} +} diff --git a/zidl/ast/ast_double_type.h b/zidl/ast/ast_double_type.h new file mode 100644 index 00000000000..625111bbf86 --- /dev/null +++ b/zidl/ast/ast_double_type.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTDOUBLETYPE_H +#define OHOS_ZIDL_ASTDOUBLETYPE_H + +#include "ast/ast_type.h" + +namespace OHOS { +namespace Zidl { + +class ASTDoubleType : public ASTType { +public: + String GetSignature() override; + + bool IsDoubleType() override; + + String ToString() override; +}; + +} +} + +#endif // OHOS_ZIDL_ASTDOUBLETYPE_H \ No newline at end of file diff --git a/zidl/ast/ast_float_type.cpp b/zidl/ast/ast_float_type.cpp new file mode 100644 index 00000000000..df699bba83b --- /dev/null +++ b/zidl/ast/ast_float_type.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_float_type.h" + +namespace OHOS { +namespace Zidl { + +String ASTFloatType::GetSignature() +{ + return "F"; +} + +bool ASTFloatType::IsFloatType() +{ + return true; +} + +String ASTFloatType::ToString() +{ + return "float"; +} + +} +} diff --git a/zidl/ast/ast_float_type.h b/zidl/ast/ast_float_type.h new file mode 100644 index 00000000000..44ef0103c5b --- /dev/null +++ b/zidl/ast/ast_float_type.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTFLOATTYPE_H +#define OHOS_ZIDL_ASTFLOATTYPE_H + +#include "ast/ast_type.h" + +namespace OHOS { +namespace Zidl { + +class ASTFloatType : public ASTType { +public: + String GetSignature() override; + + bool IsFloatType() override; + + String ToString() override; +}; + +} +} + +#endif // OHOS_ZIDL_ASTFLOATTYPE_H diff --git a/zidl/ast/ast_integer_type.cpp b/zidl/ast/ast_integer_type.cpp new file mode 100644 index 00000000000..16918c9a6e2 --- /dev/null +++ b/zidl/ast/ast_integer_type.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_integer_type.h" + +namespace OHOS { +namespace Zidl { + +String ASTIntegerType::GetSignature() +{ + return "I"; +} + +bool ASTIntegerType::IsIntegerType() +{ + return true; +} + +String ASTIntegerType::ToString() +{ + return "int"; +} + +} +} diff --git a/zidl/ast/ast_integer_type.h b/zidl/ast/ast_integer_type.h new file mode 100644 index 00000000000..cc30c15b4d3 --- /dev/null +++ b/zidl/ast/ast_integer_type.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTINTEGERTYPE_H +#define OHOS_ZIDL_ASTINTEGERTYPE_H + +#include "ast/ast_type.h" + +namespace OHOS { +namespace Zidl { + +class ASTIntegerType : public ASTType { +public: + String GetSignature() override; + + bool IsIntegerType() override; + + String ToString() override; +}; + +} +} + +#endif // OHOS_ZIDL_ASTINTEGERTYPE_H diff --git a/zidl/ast/ast_interface_type.cpp b/zidl/ast/ast_interface_type.cpp new file mode 100644 index 00000000000..b92003f6816 --- /dev/null +++ b/zidl/ast/ast_interface_type.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_interface_type.h" +#include "util/string_builder.h" + +namespace OHOS { +namespace Zidl { + +void ASTInterfaceType::SetNamespace( + /* [in] */ ASTNamespace* nspace) +{ + ASTType::SetNamespace(nspace); + if (namespace_ != nullptr) { + namespace_->AddInterface(this); + } +} + +void ASTInterfaceType::AddMethod( + /* [in] */ ASTMethod* method) +{ + if (method == nullptr) { + return; + } + methods_.push_back(method); +} + +AutoPtr ASTInterfaceType::GetMethod( + /* [in] */ size_t index) +{ + if (index >= methods_.size()) { + return nullptr; + } + + return methods_[index]; +} + +String ASTInterfaceType::GetSignature() +{ + String fullName = namespace_ != nullptr ? + namespace_->ToString() + name_ : name_; + return "L" + fullName.Replace('.', '/') + ";"; +} + +bool ASTInterfaceType::IsInterfaceType() +{ + return true; +} + +String ASTInterfaceType::ToString() +{ + return name_; +} + +String ASTInterfaceType::Dump( + /* [in] */ const String& prefix) +{ + StringBuilder sb; + + sb.Append(prefix).Append("interface "); + if (namespace_ != nullptr) { + sb.Append(namespace_->ToString()); + } + sb.Append(name_); + if (isExternal_) { + sb.Append(";\n"); + } else { + sb.Append(" {\n"); + for (auto method : methods_) { + String info = method->Dump(prefix + " "); + sb.Append(info); + if (method != methods_[methods_.size() - 1]) { + sb.Append('\n'); + } + } + sb.Append(prefix).Append("}\n"); + } + + return sb.ToString(); +} + +} +} diff --git a/zidl/ast/ast_interface_type.h b/zidl/ast/ast_interface_type.h new file mode 100644 index 00000000000..ff858591e0a --- /dev/null +++ b/zidl/ast/ast_interface_type.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTINTERFACETYPE_H +#define OHOS_ZIDL_ASTINTERFACETYPE_H + +#include +#include "ast/ast_method.h" +#include "ast/ast_type.h" +#include "util/autoptr.h" + +namespace OHOS { +namespace Zidl { + +class ASTInterfaceType : public ASTType { +public: + void SetNamespace( + /* [in] */ ASTNamespace* nspace) override; + + inline void SetLicense( + /* [in] */ const String& license) + { + license_ = license; + } + + inline String GetLicense() const + { + return license_; + } + + inline void SetOneway( + /* [in] */ bool oneway) + { + oneway_ = oneway; + } + + inline bool IsOneway() + { + return oneway_; + } + + void AddMethod( + /* [in] */ ASTMethod* method); + + AutoPtr GetMethod( + /* [in] */ size_t index); + + inline size_t GetMethodNumber() + { + return methods_.size(); + } + + void SetExternal( + /* [in] */ bool external) + { + isExternal_ = external; + } + + bool IsExternal() const + { + return isExternal_; + } + + String GetSignature() override; + + bool IsInterfaceType() override; + + String ToString() override; + + String Dump( + /* [in] */ const String& prefix) override; + +private: + String license_; + bool oneway_ = false; + std::vector> methods_; + bool isExternal_ = false; +}; + +} +} + +#endif // OHOS_ZIDL_ASTINTERFACETYPE_H diff --git a/zidl/ast/ast_list_type.cpp b/zidl/ast/ast_list_type.cpp new file mode 100644 index 00000000000..5c31c6f4cf0 --- /dev/null +++ b/zidl/ast/ast_list_type.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_list_type.h" + +namespace OHOS { +namespace Zidl { + +String ASTListType::GetSignature() +{ + return String::Format("LList[%s];", elementType_->GetSignature().string()); +} + +bool ASTListType::IsListType() +{ + return true; +} + +String ASTListType::ToString() +{ + return String::Format("List<%s>", elementType_->ToString().string()); +} + +} +} diff --git a/zidl/ast/ast_list_type.h b/zidl/ast/ast_list_type.h new file mode 100644 index 00000000000..d6c80a6833a --- /dev/null +++ b/zidl/ast/ast_list_type.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTLISTTYPE_H +#define OHOS_ZIDL_ASTLISTTYPE_H + +#include "ast/ast_type.h" +#include "util/autoptr.h" + +namespace OHOS { +namespace Zidl { + +class ASTListType : public ASTType { +public: + inline void SetElementType( + /* [in] */ ASTType* elementType) + { + elementType_ = elementType; + } + + inline AutoPtr GetElementType() + { + return elementType_; + } + + String GetSignature() override; + + bool IsListType() override; + + String ToString() override; + +private: + AutoPtr elementType_; +}; + +} +} + +#endif // OHOS_ZIDL_ASTLISTTYPE_H diff --git a/zidl/ast/ast_long_type.cpp b/zidl/ast/ast_long_type.cpp new file mode 100644 index 00000000000..29c7bdd01ff --- /dev/null +++ b/zidl/ast/ast_long_type.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_long_type.h" + +namespace OHOS { +namespace Zidl { + +String ASTLongType::GetSignature() +{ + return "J"; +} + +bool ASTLongType::IsLongType() +{ + return true; +} + +String ASTLongType::ToString() +{ + return "long"; +} + +} +} diff --git a/zidl/ast/ast_long_type.h b/zidl/ast/ast_long_type.h new file mode 100644 index 00000000000..eec1873fc33 --- /dev/null +++ b/zidl/ast/ast_long_type.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTLONGTYPE_H +#define OHOS_ZIDL_ASTLONGTYPE_H + +#include "ast/ast_type.h" + +namespace OHOS { +namespace Zidl { + +class ASTLongType : public ASTType { +public: + String GetSignature() override; + + bool IsLongType() override; + + String ToString() override; +}; + +} +} + +#endif // OHOS_ZIDL_ASTLONGTYPE_H diff --git a/zidl/ast/ast_map_type.cpp b/zidl/ast/ast_map_type.cpp new file mode 100644 index 00000000000..2f41e6b4a29 --- /dev/null +++ b/zidl/ast/ast_map_type.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_map_type.h" + +namespace OHOS { +namespace Zidl { + +String ASTMapType::GetSignature() +{ + return String::Format("LMap[%s%s];", keyType_->GetSignature().string(), valueType_->GetSignature().string()); +} + +bool ASTMapType::IsMapType() +{ + return true; +} + +String ASTMapType::ToString() +{ + return String::Format("Map<%s, %s>", keyType_->ToString().string(), valueType_->ToString().string()); +} + +} +} diff --git a/zidl/ast/ast_map_type.h b/zidl/ast/ast_map_type.h new file mode 100644 index 00000000000..3fcddce5404 --- /dev/null +++ b/zidl/ast/ast_map_type.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTMAPTYPE_H +#define OHOS_ZIDL_ASTMAPTYPE_H + +#include "ast/ast_type.h" +#include "util/autoptr.h" + +namespace OHOS { +namespace Zidl { + +class ASTMapType : public ASTType { +public: + inline void SetKeyType( + /* [in] */ ASTType* keyType) + { + keyType_ = keyType; + } + + inline AutoPtr GetKeyType() + { + return keyType_; + } + + inline void SetValueType( + /* [in] */ ASTType* valueType) + { + valueType_ = valueType; + } + + inline AutoPtr GetValueType() + { + return valueType_; + } + + String GetSignature() override; + + bool IsMapType() override; + + String ToString() override; + +private: + AutoPtr keyType_; + AutoPtr valueType_; +}; + +} +} + +#endif // OHOS_ZIDL_ASTMAPTYPE_H \ No newline at end of file diff --git a/zidl/ast/ast_method.cpp b/zidl/ast/ast_method.cpp new file mode 100644 index 00000000000..a9aff6b6d83 --- /dev/null +++ b/zidl/ast/ast_method.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_method.h" +#include "util/string_builder.h" + +namespace OHOS { +namespace Zidl { + +String ASTMethod::GetSignature() +{ + if (signature_.IsEmpty()) { + BuildSignature(); + } + return signature_; +} + +void ASTMethod::BuildSignature() +{ + StringBuilder sb; + + sb.AppendFormat("(%s)", returnType_->GetSignature().string()); + for (size_t i = 0; i < parameters_.size(); i++) { + sb.Append(parameters_[i]->GetType()->GetSignature()); + } + signature_ = sb.ToString(); +} + +void ASTMethod::AddParameter( + /* [in] */ ASTParameter* parameter) +{ + if (parameter == nullptr) { + return; + } + parameters_.push_back(parameter); +} + +AutoPtr ASTMethod::GetParameter( + /* [in] */ size_t index) +{ + if (index >= parameters_.size()) { + return nullptr; + } + + return parameters_[index]; +} + +String ASTMethod::Dump( + /* [in] */ const String& prefix) +{ + StringBuilder sb; + + sb.Append(prefix); + sb.Append(returnType_->ToString()).Append(' '); + sb.Append(name_).Append('('); + if (parameters_.size() != 0) { + sb.Append('\n'); + for (auto parameter : parameters_) { + String info = parameter->Dump(prefix + " "); + sb.Append(info); + if (parameter != parameters_[parameters_.size() - 1]) { + sb.Append(",\n"); + } + } + } + sb.Append(");\n"); + + return sb.ToString(); +} + +} +} diff --git a/zidl/ast/ast_method.h b/zidl/ast/ast_method.h new file mode 100644 index 00000000000..638b4a45840 --- /dev/null +++ b/zidl/ast/ast_method.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTMETHOD_H +#define OHOS_ZIDL_ASTMETHOD_H + +#include +#include "ast/ast_node.h" +#include "ast/ast_parameter.h" +#include "util/autoptr.h" +#include "util/string.h" + +namespace OHOS { +namespace Zidl { + +class ASTMethod : public ASTNode { +public: + inline void SetName( + /* [in] */ const String& name) + { + name_ = name; + } + + inline String GetName() + { + return name_; + } + + String GetSignature(); + + inline void SetOneway( + /* [in] */ bool oneway) + { + oneway_ = oneway; + } + + inline bool IsOneway() + { + return oneway_; + } + + inline void SetReturnType( + /* [in] */ ASTType* type) + { + returnType_ = type; + } + + inline AutoPtr GetReturnType() + { + return returnType_; + } + + void AddParameter( + /* [in] */ ASTParameter* parameter); + + AutoPtr GetParameter( + /* [in] */ size_t index); + + inline size_t GetParameterNumber() + { + return parameters_.size(); + } + + String Dump( + /* [in] */ const String& prefix) override; + +private: + void BuildSignature(); + + String name_; + String signature_; + bool oneway_ = false; + AutoPtr returnType_; + std::vector> parameters_; +}; + +} +} + +#endif // OHOS_ZIDL_ASTMETHOD_H diff --git a/zidl/ast/ast_module.cpp b/zidl/ast/ast_module.cpp new file mode 100644 index 00000000000..39d949fad68 --- /dev/null +++ b/zidl/ast/ast_module.cpp @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_module.h" +#include "util/string_builder.h" + +namespace OHOS { +namespace Zidl { + +ASTModule::ASTModule() +{ + booleanType_ = new ASTBooleanType(); + byteType_ = new ASTByteType(); + shortType_ = new ASTShortType(); + integerType_ = new ASTIntegerType(); + longType_ = new ASTLongType(); + floatType_ = new ASTFloatType(); + doubleType_ = new ASTDoubleType(); + charType_ = new ASTCharType(); + stringType_ = new ASTStringType(); + voidType_ = new ASTVoidType(); + + types_["boolean"] = booleanType_.Get(); + types_["byte"] = byteType_.Get(); + types_["short"] = shortType_.Get(); + types_["int"] = integerType_.Get(); + types_["long"] = longType_.Get(); + types_["float"] = floatType_.Get(); + types_["double"] = doubleType_.Get(); + types_["char"] = charType_.Get(); + types_["String"] = stringType_.Get(); + types_["void"] = voidType_.Get(); +} + +void ASTModule::SetZidlFile( + /* [in] */ const String& zidlFile) +{ + zidlFilePath_ = zidlFile; +#ifdef __MINGW32__ + int index = zidlFilePath_.LastIndexOf('\\'); +#else + int index = zidlFilePath_.LastIndexOf('/'); +#endif + int end = zidlFilePath_.LastIndexOf(".zidl") == -1 ? + zidlFilePath_.LastIndexOf(".idl") : zidlFilePath_.LastIndexOf(".zidl"); + name_ = zidlFilePath_.Substring((index == -1) ? 0 : (index + 1), end); +} + +AutoPtr ASTModule::ParseNamespace( + /* [in] */ const String& nspaceStr) +{ + AutoPtr currNspace; + int begin = 0; + int index = 0; + while ((index = nspaceStr.IndexOf('.', begin)) != -1) { + String ns = nspaceStr.Substring(begin, index); + AutoPtr nspace; + if (currNspace == nullptr) { + nspace = FindNamespace(ns); + } else { + nspace = currNspace->FindNamespace(ns); + } + if (nspace == nullptr) { + nspace = new ASTNamespace(ns); + if (currNspace == nullptr) { + AddNamespace(nspace); + } else { + currNspace->AddNamespace(nspace); + } + } + currNspace = nspace; + begin = index + 1; + } + return currNspace; +} + +void ASTModule::AddNamespace( + /* [in] */ ASTNamespace* nspace) +{ + if (nspace == nullptr) { + return; + } + namespaces_.push_back(nspace); +} + +AutoPtr ASTModule::FindNamespace( + /* [in] */ const String& nspaceStr) +{ + for (auto nspace : namespaces_) { + if (nspace->ToShortString().Equals(nspaceStr)) { + return nspace; + } + } + return nullptr; +} + +AutoPtr ASTModule::GetNamespace( + /* [in] */ size_t index) +{ + if (index >= namespaces_.size()) { + return nullptr; + } + + return namespaces_[index]; +} + +void ASTModule::AddInterface( + /* [in] */ ASTInterfaceType* interface) +{ + if (interface == nullptr) { + return; + } + + interfaces_.push_back(interface); + types_[interface->ToString()] = (ASTType*)interface; +} + +AutoPtr ASTModule::GetInterface( + /* [in] */ size_t index) +{ + if (index >= interfaces_.size()) { + return nullptr; + } + + return interfaces_[index]; +} + +int ASTModule::IndexOf( + /* [in] */ ASTInterfaceType* interface) +{ + for (size_t i = 0; i < interfaces_.size(); i++) { + if (interfaces_[i] == interface) { + return i; + } + } + return -1; +} + +void ASTModule::AddSequenceable( + /* [in] */ ASTSequenceableType* sequenceable) +{ + if (sequenceable == nullptr) { + return; + } + + sequenceables_.push_back(sequenceable); + types_[sequenceable->ToString()] = (ASTType*)sequenceable; +} + +AutoPtr ASTModule::GetSequenceable( + /* [in] */ size_t index) +{ + if (index >= sequenceables_.size()) { + return nullptr; + } + + return sequenceables_[index]; +} + +int ASTModule::IndexOf( + /* [in] */ ASTSequenceableType* sequenceable) +{ + for (size_t i = 0; i < sequenceables_.size(); i++) { + if (sequenceables_[i] == sequenceable) { + return i; + } + } + return -1; +} + +void ASTModule::AddType( + /* [in] */ ASTType* type) +{ + if (type == nullptr) { + return; + } + + types_[type->ToString()] = type; +} + +AutoPtr ASTModule::FindType( + /* [in] */ const String& typeName) +{ + if (typeName.IsEmpty()) { + return nullptr; + } + + auto it = types_.find(typeName); + return it != types_.end() ? it->second : nullptr; +} + +int ASTModule::IndexOf( + /* [in] */ ASTType* type) +{ + int i = 0; + for (auto it = types_.begin(); it != types_.end(); ++it, ++i) { + if (it->second == type) { + return i; + } + } + return -1; +} + +bool ASTModule::IsValid() +{ + if (name_.IsEmpty()) { + return false; + } + + return interfaces_.size() > 0; +} + +String ASTModule::Dump( + /* [in] */ const String& prefix) +{ + StringBuilder sb; + + sb.Append(prefix); + sb.Append("Module["); + sb.Append("name: ").Append(name_).Append(" "); + sb.Append("file: ").Append(zidlFilePath_); + sb.Append("]\n"); + + for (auto sequenceable : sequenceables_) { + String info = sequenceable->Dump(" "); + sb.Append(info); + } + sb.Append('\n'); + + for (auto interface : interfaces_) { + if (interface->IsExternal()) { + String info = interface->Dump(" "); + sb.Append(info); + } + } + sb.Append('\n'); + + for (auto interface : interfaces_) { + if (!interface->IsExternal()) { + String info = interface->Dump(" "); + sb.Append(info); + } + } + + return sb.ToString(); +} + +} +} diff --git a/zidl/ast/ast_module.h b/zidl/ast/ast_module.h new file mode 100644 index 00000000000..6256e15b3e0 --- /dev/null +++ b/zidl/ast/ast_module.h @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTMODULE_H +#define OHOS_ZIDL_ASTMODULE_H + +#include +#include +#include "ast/ast_boolean_type.h" +#include "ast/ast_byte_type.h" +#include "ast/ast_char_type.h" +#include "ast/ast_double_type.h" +#include "ast/ast_float_type.h" +#include "ast/ast_integer_type.h" +#include "ast/ast_interface_type.h" +#include "ast/ast_long_type.h" +#include "ast/ast_namespace.h" +#include "ast/ast_node.h" +#include "ast/ast_sequenceable_type.h" +#include "ast/ast_short_type.h" +#include "ast/ast_string_type.h" +#include "ast/ast_void_type.h" +#include "util/autoptr.h" + +namespace OHOS { +namespace Zidl { + +class ASTModule : public ASTNode { +public: + ASTModule(); + + void SetZidlFile( + /* [in] */ const String& zidlFile); + + inline String GetName() + { + return name_; + } + + inline void SetLicense( + /* [in] */ const String& license) + { + license_ = license; + } + + inline String GetLicense() + { + return license_; + } + + AutoPtr ParseNamespace( + /* [in] */ const String& nspaceStr); + + void AddNamespace( + /* [in] */ ASTNamespace* nspace); + + AutoPtr FindNamespace( + /* [in] */ const String& nspaceStr); + + AutoPtr GetNamespace( + /* [in] */ size_t index); + + inline size_t GetNamespaceNumber() + { + return namespaces_.size(); + } + + void AddInterface( + /* [in] */ ASTInterfaceType* interface); + + AutoPtr GetInterface( + /* [in] */ size_t index); + + inline size_t GetInterfaceNumber() + { + return interfaces_.size(); + } + + int IndexOf( + /* [in] */ ASTInterfaceType* interface); + + void AddSequenceable( + /* [in] */ ASTSequenceableType* sequenceable); + + AutoPtr GetSequenceable( + /* [in] */ size_t index); + + inline size_t GetSequenceableNumber() + { + return sequenceables_.size(); + } + + int IndexOf( + /* [in] */ ASTSequenceableType* sequenceable); + + void AddType( + /* [in] */ ASTType* type); + + AutoPtr FindType( + /* [in] */ const String& typeName); + + using TypeStringMap = std::unordered_map, StringHashFunc, StringEqualFunc>; + + inline const TypeStringMap& GetTypes() + { + return types_; + } + + inline size_t GetTypeNumber() + { + return types_.size(); + } + + int IndexOf( + /* [in] */ ASTType* type); + + bool IsValid(); + + String Dump( + /* [in] */ const String& prefix) override; + +private: + String name_; + String license_; + std::vector> namespaces_; + std::vector> interfaces_; + std::vector> sequenceables_; + TypeStringMap types_; + + AutoPtr booleanType_; + AutoPtr byteType_; + AutoPtr shortType_; + AutoPtr integerType_; + AutoPtr longType_; + AutoPtr floatType_; + AutoPtr doubleType_; + AutoPtr charType_; + AutoPtr stringType_; + AutoPtr voidType_; + + String zidlFilePath_; +}; + +} +} + +#endif // OHOS_ZIDL_ASTMODULE_H diff --git a/zidl/ast/ast_namespace.cpp b/zidl/ast/ast_namespace.cpp new file mode 100644 index 00000000000..66b502a41fb --- /dev/null +++ b/zidl/ast/ast_namespace.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_namespace.h" +#include "ast/ast_interface_type.h" +#include "ast/ast_sequenceable_type.h" + +namespace OHOS { +namespace Zidl { + +ASTNamespace:: ASTNamespace( + /* [in] */ const String& nspaceStr) + : name_(nspaceStr), + outerNamespace_(nullptr) +{} + +void ASTNamespace::AddNamespace( + /* [in] */ ASTNamespace* innerNspace) +{ + if (innerNspace == nullptr) { + return; + } + + innerNamespaces_.push_back(innerNspace); + innerNspace->outerNamespace_ = this; +} + +AutoPtr ASTNamespace::FindNamespace( + /* [in] */ const String& nspaceStr) +{ + if (nspaceStr.IsEmpty()) { + return nullptr; + } + + for (auto nspace : innerNamespaces_) { + if (nspace->name_.Equals(nspaceStr)) { + return nspace; + } + } + return nullptr; +} + +AutoPtr ASTNamespace::GetNamespace( + /* [in] */ size_t index) +{ + if (index >= innerNamespaces_.size()) { + return nullptr; + } + + return innerNamespaces_[index]; +} + +void ASTNamespace::AddInterface( + /* [in] */ ASTInterfaceType* interface) +{ + if (interface == nullptr) { + return; + } + + interfaces_.push_back(interface); +} + +AutoPtr ASTNamespace::GetInterface( + /* [in] */ size_t index) +{ + if (index >= interfaces_.size()) { + return nullptr; + } + + return interfaces_[index]; +} + +void ASTNamespace::AddSequenceable( + /* [in] */ ASTSequenceableType* sequenceable) +{ + if (sequenceable == nullptr) { + return; + } + + sequenceables_.push_back(sequenceable); +} + +AutoPtr ASTNamespace::GetSequenceable( + /* [in] */ size_t index) +{ + if (index >= sequenceables_.size()) { + return nullptr; + } + + return sequenceables_[index]; +} + +String ASTNamespace::ToString() +{ + String nspaceStr; + ASTNamespace* nspace = this; + while (nspace != nullptr) { + nspaceStr = nspace->name_ + "." + nspaceStr; + nspace = nspace->outerNamespace_; + } + return nspaceStr; +} + +} +} diff --git a/zidl/ast/ast_namespace.h b/zidl/ast/ast_namespace.h new file mode 100644 index 00000000000..d78d171de19 --- /dev/null +++ b/zidl/ast/ast_namespace.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTNAMESPACE_H +#define OHOS_ZIDL_ASTNAMESPACE_H + +#include +#include "ast/ast_node.h" +#include "util/autoptr.h" + +namespace OHOS { +namespace Zidl { + +class ASTInterfaceType; +class ASTSequenceableType; + +class ASTNamespace : public ASTNode { +public: + ASTNamespace( + /* [in] */ const String& nspaceStr); + + inline String GetName() + { + return name_; + } + + void AddNamespace( + /* [in] */ ASTNamespace* innerNspace); + + AutoPtr FindNamespace( + /* [in] */ const String& nspaceStr); + + AutoPtr GetNamespace( + /* [in] */ size_t index); + + inline size_t GetNamespaceNumber() + { + return innerNamespaces_.size(); + } + + void AddInterface( + /* [in] */ ASTInterfaceType* interface); + + AutoPtr GetInterface( + /* [in] */ size_t index); + + inline size_t GetInterfaceNumber() + { + return interfaces_.size(); + } + + void AddSequenceable( + /* [in] */ ASTSequenceableType* sequenceable); + + AutoPtr GetSequenceable( + /* [in] */ size_t index); + + inline size_t GetSequenceableNumber() + { + return sequenceables_.size(); + } + + inline String ToShortString() + { + return name_; + } + + String ToString() override; + +private: + String name_; + ASTNamespace* outerNamespace_; + std::vector> innerNamespaces_; + std::vector> interfaces_; + std::vector> sequenceables_; +}; + +} +} + +#endif // OHOS_ZIDL_ASTNAMESPACE_H diff --git a/zidl/ast/ast_node.cpp b/zidl/ast/ast_node.cpp new file mode 100644 index 00000000000..f16e2d6ef0b --- /dev/null +++ b/zidl/ast/ast_node.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_node.h" + +namespace OHOS { +namespace Zidl { + +ASTNode::~ASTNode() +{} + +String ASTNode::ToString() +{ + return "ASTNode"; +} + +String ASTNode::Dump( + /* [in] */ const String& prefix) +{ + return prefix + "ASTNode"; +} + +} +} diff --git a/zidl/ast/ast_node.h b/zidl/ast/ast_node.h new file mode 100644 index 00000000000..abe435e6523 --- /dev/null +++ b/zidl/ast/ast_node.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTNODE_H +#define OHOS_ZIDL_ASTNODE_H + +#include "util/light_refcount_base.h" +#include "util/string.h" + +namespace OHOS { +namespace Zidl { + +class ASTNode : public LightRefCountBase { +public: + virtual ~ASTNode(); + + virtual String ToString(); + + virtual String Dump( + /* [in] */ const String& prefix); +}; + +} +} + +#endif // OHOS_ZIDL_ASTNODE_H diff --git a/zidl/ast/ast_parameter.cpp b/zidl/ast/ast_parameter.cpp new file mode 100644 index 00000000000..c62da3aeee4 --- /dev/null +++ b/zidl/ast/ast_parameter.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_parameter.h" +#include "util/string_builder.h" + +namespace OHOS { +namespace Zidl { + +String ASTParameter::Dump( + /* [in] */ const String& prefix) +{ + StringBuilder sb; + + sb.Append(prefix); + sb.Append('['); + if (isInParameter_) { + sb.Append("in"); + } + if (isOutParameter_) { + if (isInParameter_) { + sb.Append(", "); + } + sb.Append("out"); + } + sb.Append("] "); + sb.Append(type_->ToString()).Append(' '); + sb.Append(name_); + + return sb.ToString(); +} + +} +} diff --git a/zidl/ast/ast_parameter.h b/zidl/ast/ast_parameter.h new file mode 100644 index 00000000000..84418edd8c1 --- /dev/null +++ b/zidl/ast/ast_parameter.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTPARAMETER_H +#define OHOS_ZIDL_ASTPARAMETER_H + +#include "ast/ast_node.h" +#include "ast/ast_type.h" +#include "util/autoptr.h" +#include "util/string.h" + +namespace OHOS { +namespace Zidl { + +class ASTParameter : public ASTNode { +public: + inline void SetName( + /* [in] */ const String& name) + { + name_ = name; + } + + inline String GetName() + { + return name_; + } + + inline void SetType( + /* [in] */ ASTType* type) + { + type_ = type; + } + + inline AutoPtr GetType() + { + return type_; + } + + inline void SetInParameter( + /* [in] */ bool inParameter) + { + isInParameter_ = inParameter; + } + + inline bool IsInParameter() + { + return isInParameter_; + } + + inline void SetOutParameter( + /* [in] */ bool outParameter) + { + isOutParameter_ = outParameter; + } + + inline bool IsOutParameter() + { + return isOutParameter_; + } + + String Dump( + /* [in] */ const String& prefix) override; + +private: + String name_; + AutoPtr type_; + bool isInParameter_ = false; + bool isOutParameter_ = false; +}; + +} +} + +#endif // OHOS_ZIDL_ASTPARAMETER_H diff --git a/zidl/ast/ast_sequenceable_type.cpp b/zidl/ast/ast_sequenceable_type.cpp new file mode 100644 index 00000000000..680606733e8 --- /dev/null +++ b/zidl/ast/ast_sequenceable_type.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_sequenceable_type.h" +#include "util/string_builder.h" + +namespace OHOS { +namespace Zidl { + +void ASTSequenceableType::SetNamespace( + /* [in] */ ASTNamespace* nspace) +{ + ASTType::SetNamespace(nspace); + if (namespace_ != nullptr) { + namespace_->AddSequenceable(this); + } +} + +String ASTSequenceableType::GetSignature() +{ + String fullName = namespace_ != nullptr ? + namespace_->ToString() + name_ : name_; + return "L" + fullName.Replace('.', '/') + ";"; +} + +bool ASTSequenceableType::IsSequenceableType() +{ + return true; +} + +String ASTSequenceableType::ToString() +{ + return name_; +} + +String ASTSequenceableType::Dump( + /* [in] */ const String& prefix) +{ + StringBuilder sb; + + sb.Append(prefix).Append("sequenceable "); + if (namespace_ != nullptr) { + sb.Append(namespace_->ToString()); + } + sb.Append(name_); + sb.Append(";\n"); + + return sb.ToString(); +} + +} +} diff --git a/zidl/ast/ast_sequenceable_type.h b/zidl/ast/ast_sequenceable_type.h new file mode 100644 index 00000000000..d22b50d625d --- /dev/null +++ b/zidl/ast/ast_sequenceable_type.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTSEQUENCEABLETYPE_H +#define OHOS_ZIDL_ASTSEQUENCEABLETYPE_H + +#include "ast/ast_type.h" + +namespace OHOS { +namespace Zidl { + +class ASTSequenceableType : public ASTType { +public: + void SetNamespace( + /* [in] */ ASTNamespace* nspace) override; + + String GetSignature() override; + + bool IsSequenceableType() override; + + String ToString() override; + + String Dump( + /* [in] */ const String& prefix) override; +}; + +} +} + +#endif // OHOS_ZIDL_ASTSEQUENCEABLETYPE_H diff --git a/zidl/ast/ast_short_type.cpp b/zidl/ast/ast_short_type.cpp new file mode 100644 index 00000000000..2891aed192c --- /dev/null +++ b/zidl/ast/ast_short_type.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_short_type.h" + +namespace OHOS { +namespace Zidl { + +String ASTShortType::GetSignature() +{ + return "S"; +} + +bool ASTShortType::IsShortType() +{ + return true; +} + +String ASTShortType::ToString() +{ + return "short"; +} + +} +} diff --git a/zidl/ast/ast_short_type.h b/zidl/ast/ast_short_type.h new file mode 100644 index 00000000000..da8766f207a --- /dev/null +++ b/zidl/ast/ast_short_type.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTSHORTTYPE_H +#define OHOS_ZIDL_ASTSHORTTYPE_H + +#include "ast/ast_type.h" + +namespace OHOS { +namespace Zidl { + +class ASTShortType : public ASTType { +public: + String GetSignature() override; + + bool IsShortType() override; + + String ToString() override; +}; + +} +} + +#endif // OHOS_ZIDL_ASTSHORTTYPE_H diff --git a/zidl/ast/ast_string_type.cpp b/zidl/ast/ast_string_type.cpp new file mode 100644 index 00000000000..3144aee55ea --- /dev/null +++ b/zidl/ast/ast_string_type.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_string_type.h" + +namespace OHOS { +namespace Zidl { + +String ASTStringType::GetSignature() +{ + return "T"; +} + +bool ASTStringType::IsStringType() +{ + return true; +} + +String ASTStringType::ToString() +{ + return "String"; +} + +} +} diff --git a/zidl/ast/ast_string_type.h b/zidl/ast/ast_string_type.h new file mode 100644 index 00000000000..e7eab0a4431 --- /dev/null +++ b/zidl/ast/ast_string_type.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTSTRINGTYPE_H +#define OHOS_ZIDL_ASTSTRINGTYPE_H + +#include "ast/ast_type.h" + +namespace OHOS { +namespace Zidl { + +class ASTStringType : public ASTType { +public: + String GetSignature() override; + + bool IsStringType() override; + + String ToString() override; +}; + +} +} + +#endif // OHOS_ZIDL_ASTSTRINGTYPE_H diff --git a/zidl/ast/ast_type.cpp b/zidl/ast/ast_type.cpp new file mode 100644 index 00000000000..1c31469907a --- /dev/null +++ b/zidl/ast/ast_type.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_type.h" + +namespace OHOS { +namespace Zidl { + +void ASTType::SetName( + /* [in] */ const String& name) +{ + name_ = name; +} + +String ASTType::GetName() +{ + return name_; +} + +void ASTType::SetNamespace( + /* [in] */ ASTNamespace* nspace) +{ + namespace_ = nspace; +} + +AutoPtr ASTType::GetNamespace() +{ + return namespace_; +} + +bool ASTType::IsBooleanType() +{ + return false; +} + +bool ASTType::IsByteType() +{ + return false; +} + +bool ASTType::IsShortType() +{ + return false; +} + +bool ASTType::IsIntegerType() +{ + return false; +} + +bool ASTType::IsLongType() +{ + return false; +} + +bool ASTType::IsFloatType() +{ + return false; +} + +bool ASTType::IsDoubleType() +{ + return false; +} + +bool ASTType::IsCharType() +{ + return false; +} + +bool ASTType::IsStringType() +{ + return false; +} + +bool ASTType::IsListType() +{ + return false; +} + +bool ASTType::IsMapType() +{ + return false; +} + +bool ASTType::IsInterfaceType() +{ + return false; +} + +bool ASTType::IsSequenceableType() +{ + return false; +} + +bool ASTType::IsVoidType() +{ + return false; +} + +bool ASTType::IsArrayType() +{ + return false; +} + +String ASTType::ToShortString() +{ + return name_; +} + +String ASTType::ToString() +{ + return namespace_ == nullptr ? name_ : namespace_->ToString() + name_; +} + +} +} \ No newline at end of file diff --git a/zidl/ast/ast_type.h b/zidl/ast/ast_type.h new file mode 100644 index 00000000000..1ecacde4d70 --- /dev/null +++ b/zidl/ast/ast_type.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTTYPE_H +#define OHOS_ZIDL_ASTTYPE_H + +#include "ast/ast_namespace.h" +#include "ast/ast_node.h" +#include "util/autoptr.h" +#include "util/string.h" + +namespace OHOS { +namespace Zidl { + +class ASTType : public ASTNode { +public: + virtual void SetName( + /* [in] */ const String& name); + + virtual String GetName(); + + virtual void SetNamespace( + /* [in] */ ASTNamespace* nspace); + + virtual AutoPtr GetNamespace(); + + virtual String GetSignature() = 0; + + virtual bool IsBooleanType(); + + virtual bool IsByteType(); + + virtual bool IsShortType(); + + virtual bool IsIntegerType(); + + virtual bool IsLongType(); + + virtual bool IsFloatType(); + + virtual bool IsDoubleType(); + + virtual bool IsCharType(); + + virtual bool IsStringType(); + + virtual bool IsListType(); + + virtual bool IsMapType(); + + virtual bool IsInterfaceType(); + + virtual bool IsSequenceableType(); + + virtual bool IsVoidType(); + + virtual bool IsArrayType(); + + virtual String ToShortString(); + + String ToString() override; + +protected: + String name_; + AutoPtr namespace_; +}; + +} +} + +#endif // OHOS_ZIDL_ASTTYPE_H diff --git a/zidl/ast/ast_void_type.cpp b/zidl/ast/ast_void_type.cpp new file mode 100644 index 00000000000..2cce08c685e --- /dev/null +++ b/zidl/ast/ast_void_type.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast/ast_void_type.h" + +namespace OHOS { +namespace Zidl { + +String ASTVoidType::GetSignature() +{ + return "V"; +} + +bool ASTVoidType::IsVoidType() +{ + return true; +} + +String ASTVoidType::ToString() +{ + return "void"; +} + +} +} diff --git a/zidl/ast/ast_void_type.h b/zidl/ast/ast_void_type.h new file mode 100644 index 00000000000..9a66b6f8403 --- /dev/null +++ b/zidl/ast/ast_void_type.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_ASTVOIDTYPE_H +#define OHOS_ZIDL_ASTVOIDTYPE_H + +#include "ast/ast_type.h" + +namespace OHOS { +namespace Zidl { + +class ASTVoidType : public ASTType { +public: + String GetSignature() override; + + bool IsVoidType() override; + + String ToString() override; +}; + +} +} + +#endif // OHOS_ZIDL_ASTBOOLEANTYPE_H \ No newline at end of file diff --git a/zidl/bundle.json b/zidl/bundle.json new file mode 100644 index 00000000000..5127a051270 --- /dev/null +++ b/zidl/bundle.json @@ -0,0 +1,37 @@ +{ + "name": "@ohos/zidl", + "description": "提供自动生成Extension 服务端及客户端接口文件的能力", + "version": "3.1", + "license": "Apache License 2.0", + "publishAs": "code-segment", + "segment": { + "destPath": "foundation/aafwk/standard/zidl" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "zidl", + "subsystem": "aafwk", + "syscap": [], + "features": [], + "adapted_system_type": [ + "standard" + ], + "rom": "", + "ram": "", + "deps": { + "components": [ + "hiviewdfx_hilog_native", + "ipc", + "samgr_standard", + "utils_base" + ], + "third_party": [] + }, + "build": { + "sub_component": [], + "inner_kits": [], + "test": [] + } + } +} \ No newline at end of file diff --git a/zidl/codegen/CMakeLists.txt b/zidl/codegen/CMakeLists.txt new file mode 100644 index 00000000000..bd4a8f37e98 --- /dev/null +++ b/zidl/codegen/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_directories( + ${ZIDL_DIR}) + +set(SOURCES + code_emitter.cpp + code_generator.cpp + cpp_code_emitter.cpp + java_code_emitter.cpp) + +add_library(codegen STATIC + ${SOURCES}) \ No newline at end of file diff --git a/zidl/codegen/code_emitter.cpp b/zidl/codegen/code_emitter.cpp new file mode 100644 index 00000000000..5dfda232720 --- /dev/null +++ b/zidl/codegen/code_emitter.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "codegen/code_emitter.h" + +namespace OHOS { +namespace Zidl { + +const char* CodeEmitter::TAB = " "; + +CodeEmitter::CodeEmitter( + /* [in] */ MetaComponent* mc) + : metaComponent_(mc) +{ + metaInterface_ = nullptr; + for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { + metaInterface_ = metaComponent_->interfaces_[i]; + if (!metaInterface_->external_) { + break; + } + } + + if (metaInterface_ != nullptr) { + interfaceName_ = metaInterface_->name_; + interfaceFullName_ = metaInterface_->namespace_ + interfaceName_; + proxyName_ = interfaceName_.StartsWith("I") ? + interfaceName_.Substring(1) + "Proxy" : interfaceName_ + "Proxy"; + proxyFullName_ = metaInterface_->namespace_ + proxyName_; + stubName_ = interfaceName_.StartsWith("I") ? + interfaceName_.Substring(1) + "Stub" : interfaceName_ + "Stub"; + stubFullName_ = metaInterface_->namespace_ + stubName_; + } +} + +} +} diff --git a/zidl/codegen/code_emitter.h b/zidl/codegen/code_emitter.h new file mode 100644 index 00000000000..4fd84ffd8b7 --- /dev/null +++ b/zidl/codegen/code_emitter.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_CODEEMITTER_H +#define OHOS_ZIDL_CODEEMITTER_H + +#include "metadata/metadata.h" +#include "util/light_refcount_base.h" +#include "util/string.h" + +namespace OHOS { +namespace Zidl { + +class CodeEmitter : public LightRefCountBase { +public: + CodeEmitter( + /* [in] */ MetaComponent* mc); + + inline void SetDirectory( + /* [in] */ const String& directory) + { + directory_ = directory; + } + + virtual void EmitInterface() = 0; + + virtual void EmitInterfaceProxy() = 0; + + virtual void EmitInterfaceStub() = 0; + +protected: + static const char* TAB; + + MetaComponent* metaComponent_; + MetaInterface* metaInterface_; + String directory_; + String interfaceName_; + String interfaceFullName_; + String proxyName_; + String proxyFullName_; + String stubName_; + String stubFullName_; +}; + +} +} + +#endif // OHOS_ZIDL_CODEEMITTER_H diff --git a/zidl/codegen/code_generator.cpp b/zidl/codegen/code_generator.cpp new file mode 100644 index 00000000000..9e0c190cf29 --- /dev/null +++ b/zidl/codegen/code_generator.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "codegen/code_generator.h" +#include +#include +#include +#include "codegen/cpp_code_emitter.h" +#include "codegen/java_code_emitter.h" +#include "codegen/js_code_emitter.h" +#include "util/logger.h" + +namespace OHOS { +namespace Zidl { + +const char* CodeGenerator::TAG = "CodeGenerator"; + +CodeGenerator::CodeGenerator( + /* [in] */ MetaComponent* mc, + /* [in] */ const String& language, + /* [in] */ const String& dir) + : targetLanguage_(language), + targetDirectory_(dir), + metaComponent_(mc) +{ + if (language.Equals("cpp")) { + emitter_ = new CppCodeEmitter(metaComponent_); + } else if (language.Equals("java")) { + emitter_ = new JavaCodeEmitter(metaComponent_); + } else if (language.Equals("js")) { + emitter_ = new JsCodeEmitter(metaComponent_); + } +} + +bool CodeGenerator::ResolveDirectory() +{ +#ifdef __MINGW32__ + if(targetDirectory_.IndexOf(":\\") == -1) { + char* cmd = getcwd(nullptr, 0); + targetDirectory_ = String::Format("%s\\%s", cmd, targetDirectory_.string()); + free(cmd); + } +#else + if (!targetDirectory_.StartsWith("/")) { + char* cwd = getcwd(nullptr, 0); + targetDirectory_ = String::Format("%s/%s", cwd, targetDirectory_.string()); + free(cwd); + } +#endif + + if (!access(targetDirectory_.string(), R_OK | W_OK)) { + return true; + } + +#ifdef __MINGW32__ + if (mkdir(targetDirectory_.string()) != 0) { +#else + if (mkdir(targetDirectory_.string(), S_IRWXU | S_IRWXG | S_IRWXO) != 0) { +#endif + Logger::E(TAG, "Create \"%s\" directory failed.", targetDirectory_.string()); + return false; + } + + return true; +} + +bool CodeGenerator::Generate() +{ + if (!ResolveDirectory()) { + return false; + } + + emitter_->SetDirectory(targetDirectory_); + + emitter_->EmitInterface(); + emitter_->EmitInterfaceProxy(); + emitter_->EmitInterfaceStub(); + + return true; +} + +} +} diff --git a/zidl/codegen/code_generator.h b/zidl/codegen/code_generator.h new file mode 100644 index 00000000000..43eca9157fe --- /dev/null +++ b/zidl/codegen/code_generator.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_CODEGENERATOR_H +#define OHOS_ZIDL_CODEGENERATOR_H + +#include "codegen/code_emitter.h" +#include "metadata/metadata.h" +#include "util/autoptr.h" +#include "util/string.h" + +namespace OHOS { +namespace Zidl { + +class CodeGenerator { +public: + CodeGenerator( + /* [in] */ MetaComponent* mc, + /* [in] */ const String& language, + /* [in] */ const String& dir); + + ~CodeGenerator() = default; + + bool Generate(); + +private: + bool ResolveDirectory(); + + + static const char* TAG; + String targetLanguage_; + String targetDirectory_; + MetaComponent* metaComponent_; + AutoPtr emitter_; +}; + +} +} + +#endif // OHOS_ZIDL_CODEGENERATOR_H diff --git a/zidl/codegen/cpp_code_emitter.cpp b/zidl/codegen/cpp_code_emitter.cpp new file mode 100644 index 00000000000..8e23b8989ce --- /dev/null +++ b/zidl/codegen/cpp_code_emitter.cpp @@ -0,0 +1,1175 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "codegen/cpp_code_emitter.h" + +#include +#include + +#include "securec.h" +#include "util/file.h" + +namespace OHOS { +namespace Zidl { + +void CppCodeEmitter::EmitInterface() +{ + EmitInterfaceHeaderFile(); +} + +void CppCodeEmitter::EmitInterfaceHeaderFile() +{ + String filePath = String::Format("%s/%s.h", directory_.string(), FileName(interfaceName_).string()); + File file(filePath, File::WRITE); + + StringBuilder sb; + + EmitLicense(sb); + sb.Append("\n"); + EmitHeadMacro(sb, interfaceFullName_); + sb.Append("\n"); + EmitInterfaceInclusions(sb); + sb.Append("\n"); + if (EmitInterfaceUsings(sb)) { + sb.Append("\n"); + } + EmitInterfaceDefinition(sb); + EmitTailMacro(sb, interfaceFullName_); + + String data = sb.ToString(); + file.WriteData(data.string(), data.GetLength()); + file.Flush(); + file.Close(); +} + +void CppCodeEmitter::EmitInterfaceInclusions( + /* [in] */ StringBuilder& sb) +{ + EmitInterfaceStdlibInclusions(sb); + EmitInterfaceDBinderInclusions(sb); + // EmitInterfaceParametersInclusions(sb); no idea what does this do + EmitInterfaceSelfDefinedTypeInclusions(sb); +} + +void CppCodeEmitter::EmitInterfaceStdlibInclusions( + /* [in] */ StringBuilder& sb) +{ + bool includeString = false; + bool includeList = false; + bool includeMap = false; + bool includeNum = false; + for (int i = 0; i < metaComponent_->typeNumber_; i++) { + MetaType* mt = metaComponent_->types_[i]; + switch(mt->kind_) { + case TypeKind::Byte: { + if (!includeNum) { + sb.Append("#include \n"); + includeNum = true; + } + break; + } + case TypeKind::String: { + if (!includeString) { + sb.Append("#include \n"); + includeString = true; + } + break; + } + case TypeKind::Array: + case TypeKind::List: { + if (!includeList) { + sb.Append("#include \n"); + includeList = true; + } + break; + } + case TypeKind::Map: { + if (!includeMap) { + sb.Append("#include \n"); + includeMap = true; + } + break; + } + default: + break; + } + } +} + +void CppCodeEmitter::EmitInterfaceDBinderInclusions( + /* [in] */ StringBuilder& sb) +{ + sb.Append("#include \n"); +} + +void CppCodeEmitter::EmitInterfaceParametersInclusions( + /* [in] */ StringBuilder& sb) +{ + sb.Append("#include \"parameters.h\"\n"); +} + +String CppCodeEmitter::GetFilePath(const String& fpnp) +{ + int pos = fpnp.IndexOf(".."); + if (pos == -1) { + return String(); + } + String res = fpnp.Substring(0, pos + 1); + return res; +} + +String CppCodeEmitter::GetNamespace(const String& fpnp) +{ + int pos = fpnp.IndexOf(".."); + if (pos == -1) { + return fpnp; + } + String res = fpnp.Substring(pos + 2); + return res; +} + +void CppCodeEmitter::EmitInterfaceSelfDefinedTypeInclusions( + /* [in] */ StringBuilder& sb) +{ + for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { + MetaSequenceable* mp = metaComponent_->sequenceables_[i]; + String filePath = GetFilePath(String(mp->namespace_)); + String fileName = FileName(filePath + mp->name_); + sb.Append("#include ").AppendFormat("\"%s.h\"\n", fileName.string()); + } + + for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { + MetaInterface* mi = metaComponent_->interfaces_[i]; + if (mi->external_) { + String filePath = GetFilePath(String(mi->namespace_)); + String fileName = FileName(filePath + mi->name_); + sb.Append("#include ").AppendFormat("\"%s.h\"\n", fileName.string()); + } + } +} + +bool CppCodeEmitter::EmitInterfaceUsings( + /* [in] */ StringBuilder& sb) +{ + bool ret = false; + for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { + MetaSequenceable* mp = metaComponent_->sequenceables_[i]; + String np = GetNamespace(String(mp->namespace_)); + if (np.IsEmpty()) { + continue; + } + String fullName = CppFullName(np + mp->name_); + sb.Append("using ").AppendFormat("%s;\n", fullName.string()); + ret = true; + } + + for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { + MetaInterface* mi = metaComponent_->interfaces_[i]; + if (mi->external_) { + String np = GetNamespace(String(mi->namespace_)); + if (np.IsEmpty()) { + continue; + } + String fullName = CppFullName(np + mi->name_); + sb.Append("using ").AppendFormat("%s;\n", fullName.string()); + ret = true; + } + } + return ret; +} + +void CppCodeEmitter::EmitInterfaceDefinition( + /* [in] */ StringBuilder& sb) +{ + EmitBeginNamespace(sb); + sb.AppendFormat("class %s : public IRemoteBroker {\n", metaInterface_->name_); + sb.Append("public:\n"); + EmitInterfaceBody(sb, TAB); + sb.Append("};\n"); + EmitEndNamespace(sb); +} + +void CppCodeEmitter::EmitInterfaceBody( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + String nameWithoutPath = GetNamespace(interfaceFullName_); + sb.Append(TAB).AppendFormat("DECLARE_INTERFACE_DESCRIPTOR(u\"%s\");\n", nameWithoutPath.string()); + sb.Append("\n"); + EmitInterfaceMethods(sb, TAB); +} + +void CppCodeEmitter::EmitInterfaceMethods( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + if (metaInterface_->methodNumber_ > 0) { + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + EmitInterfaceMethod(mm, sb, prefix); + if (i != metaInterface_->methodNumber_ - 1) { + sb.Append("\n"); + } + } + } +} + +void CppCodeEmitter::EmitInterfaceMethod( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; + if (mm->parameterNumber_ == 0 && returnType->kind_ == TypeKind::Void) { + sb.Append(prefix).AppendFormat("virtual ErrCode %s() = 0;\n", mm->name_); + } else { + sb.Append(prefix).AppendFormat("virtual ErrCode %s(\n", mm->name_); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + EmitInterfaceMethodParameter(mp, sb, prefix + TAB); + if (i != mm->parameterNumber_ - 1 || returnType->kind_ != TypeKind::Void) { + sb.Append(",\n"); + } + } + if (returnType->kind_ != TypeKind::Void) { + EmitInterfaceMethodReturn(returnType, sb, prefix + TAB); + } + sb.Append(") = 0;\n"); + } +} + +void CppCodeEmitter::EmitInterfaceMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + if ((mp->attributes_ & ATTR_MASK) == (ATTR_IN | ATTR_OUT)) { + sb.Append(prefix).Append("/* [in, out] */ "); + } else if (mp->attributes_ & ATTR_IN) { + sb.Append(prefix).Append("/* [in] */ "); + } else { + sb.Append(prefix).Append("/* [out] */ "); + } + + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + const std::string name = UnderlineAdded(mp->name_); + sb.AppendFormat("%s %s", EmitType(mt, mp->attributes_, false).string(), name.c_str()); +} + +void CppCodeEmitter::EmitInterfaceMethodReturn( + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("/* [out] */ %s result", EmitType(mt, ATTR_OUT, false).string()); +} + +void CppCodeEmitter::EmitInterfaceProxy() +{ + EmitInterfaceProxyHeaderFile(); + EmitInterfaceProxyCppFile(); +} + +void CppCodeEmitter::EmitInterfaceProxyHeaderFile() +{ + String filePath = String::Format("%s/%s.h", directory_.string(), FileName(proxyName_).string()); + File file(filePath, File::WRITE); + + StringBuilder sb; + + EmitLicense(sb); + sb.Append("\n"); + EmitHeadMacro(sb, proxyFullName_); + sb.Append("\n"); + sb.AppendFormat("#include \"%s.h\"\n", FileName(interfaceName_).string()); + sb.Append("#include \n"); + sb.Append("\n"); + EmitInterfaceProxyInHeaderFile(sb); + EmitTailMacro(sb, proxyFullName_); + + String data = sb.ToString(); + file.WriteData(data.string(), data.GetLength()); + file.Flush(); + file.Close(); +} + +void CppCodeEmitter::EmitInterfaceProxyInHeaderFile( + /* [in] */ StringBuilder& sb) +{ + EmitBeginNamespace(sb); + sb.AppendFormat("class %s : public IRemoteProxy<%s> {\n", + proxyName_.string(), interfaceName_.string()); + sb.Append("public:\n"); + EmitInterfaceProxyConstructor(sb, TAB); + sb.Append("\n"); + EmitInterfaceProxyMethodDecls(sb, TAB); + sb.Append("\n"); + sb.Append("private:\n"); + EmitInterfaceProxyConstants(sb, TAB); + sb.Append("};\n"); + EmitEndNamespace(sb); +} + +void CppCodeEmitter::EmitInterfaceProxyConstructor( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("explicit %s(\n", proxyName_.string()); + sb.Append(prefix + TAB).Append("/* [in] */ const sptr& remote)\n"); + sb.Append(prefix + TAB).AppendFormat(": IRemoteProxy<%s>(remote)\n", interfaceName_.string()); + sb.Append(prefix).Append("{}\n"); + sb.Append("\n"); + sb.Append(prefix).AppendFormat("virtual ~%s()\n", proxyName_.string()); + sb.Append(prefix).Append("{}\n"); +} + +void CppCodeEmitter::EmitInterfaceProxyMethodDecls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + if (metaInterface_->methodNumber_ > 0) { + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + EmitInterfaceProxyMethodDecl(mm, sb, prefix); + if (i != metaInterface_->methodNumber_ - 1) { + sb.Append("\n"); + } + } + } +} + +void CppCodeEmitter::EmitInterfaceProxyMethodDecl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; + if (mm->parameterNumber_ == 0 && returnType->kind_ == TypeKind::Void) { + sb.Append(prefix).AppendFormat("ErrCode %s() override;\n", mm->name_); + } else { + sb.Append(prefix).AppendFormat("ErrCode %s(\n", mm->name_); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + EmitInterfaceMethodParameter(mp, sb, prefix + TAB); + if (i != mm->parameterNumber_ - 1 || returnType->kind_ != TypeKind::Void) { + sb.Append(",\n"); + } + } + if (returnType->kind_ != TypeKind::Void) { + EmitInterfaceMethodReturn(returnType, sb, prefix + TAB); + } + sb.Append(") override;\n"); + } +} + +void CppCodeEmitter::EmitInterfaceProxyConstants( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + EmitInterfaceMethodCommands(sb, prefix); + sb.Append("\n"); + sb.Append(prefix).AppendFormat("static inline BrokerDelegator<%s> delegator_;\n", proxyName_.string()); +} + +void CppCodeEmitter::EmitInterfaceProxyCppFile() +{ + String filePath = String::Format("%s/%s.cpp", directory_.string(), FileName(proxyName_).string()); + File file(filePath, File::WRITE); + + StringBuilder sb; + + EmitLicense(sb); + sb.Append("\n"); + sb.AppendFormat("#include \"%s.h\"\n", FileName(proxyName_).string()); + sb.Append("\n"); + EmitBeginNamespace(sb); + EmitInterfaceProxyMethodImpls(sb, ""); + EmitEndNamespace(sb); + + String data = sb.ToString(); + file.WriteData(data.string(), data.GetLength()); + file.Flush(); + file.Close(); +} + +void CppCodeEmitter::EmitInterfaceProxyMethodImpls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + if (metaInterface_->methodNumber_ > 0) { + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + EmitInterfaceProxyMethodImpl(mm, sb, prefix); + if (i != metaInterface_->methodNumber_ - 1) { + sb.Append("\n"); + } + } + } +} + +void CppCodeEmitter::EmitInterfaceProxyMethodImpl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; + if (mm->parameterNumber_ == 0 && returnType->kind_ == TypeKind::Void) { + sb.Append(prefix).AppendFormat("ErrCode %s::%s()\n", proxyName_.string(), mm->name_); + } else { + sb.Append(prefix).AppendFormat("ErrCode %s::%s(\n", proxyName_.string(), mm->name_); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + EmitInterfaceMethodParameter(mp, sb, prefix + TAB); + if (i != mm->parameterNumber_ - 1 || returnType->kind_ != TypeKind::Void) { + sb.Append(",\n"); + } + } + if (returnType->kind_ != TypeKind::Void) { + EmitInterfaceMethodReturn(returnType, sb, prefix + TAB); + } + sb.Append(")\n"); + } + EmitInterfaceProxyMethodBody(mm, sb, prefix); +} + +void CppCodeEmitter::EmitInterfaceProxyMethodBody( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).Append("{\n"); + sb.Append(prefix + TAB).Append("MessageParcel data;\n"); + sb.Append(prefix + TAB).Append("MessageParcel reply;\n"); + sb.Append(prefix + TAB).AppendFormat("MessageOption option(%s);\n", + (mm->properties_ & METHOD_PROPERTY_ONEWAY) != 0 + ? "MessageOption::TF_ASYNC" : "MessageOption::TF_SYNC"); + sb.Append("\n"); + + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + if ((mp->attributes_ & ATTR_IN) != 0) { + EmitWriteMethodParameter(mp, "data.", sb, prefix + TAB); + } + } + sb.Append("\n"); + sb.Append(prefix + TAB).AppendFormat("int32_t st = Remote()->SendRequest(COMMAND_%s, data, reply, option);\n", + ConstantName(mm->name_).string()); + sb.Append(prefix + TAB).Append("if (st != ERR_NONE) {\n"); + sb.Append(prefix + TAB).Append(" return st;\n"); + sb.Append(prefix + TAB).Append("}\n"); + if ((mm->properties_ & METHOD_PROPERTY_ONEWAY) == 0) { + sb.Append("\n"); + sb.Append(prefix + TAB).Append("ErrCode ec = reply.ReadInt32();\n"); + sb.Append(prefix + TAB).Append("if (FAILED(ec)) {\n"); + sb.Append(prefix + TAB).Append(" return ec;\n"); + sb.Append(prefix + TAB).Append("}\n"); + sb.Append("\n"); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + if ((mp->attributes_ & ATTR_OUT) != 0) { + EmitReadMethodParameter(mp, "reply.", sb, prefix + TAB); + } + } + MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; + if (returnType->kind_ != TypeKind::Void) { + EmitReadVariable("reply.", "result", returnType, sb, prefix + TAB, false); + } + } + sb.Append(prefix + TAB).Append("return ERR_OK;\n"); + sb.Append(prefix).Append("}\n"); +} + +void CppCodeEmitter::EmitWriteMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ const String& parcelName, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + const std::string name = UnderlineAdded(mp->name_); + EmitWriteVariable(parcelName, name, mt, sb, prefix); +} + +void CppCodeEmitter::EmitReadMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ const String& parcelName, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + const std::string name = UnderlineAdded(mp->name_); + EmitReadVariable(parcelName, name, mt, sb, prefix, false); +} + +void CppCodeEmitter::EmitInterfaceStub() +{ + EmitInterfaceStubHeaderFile(); + EmitInterfaceStubCppFile(); +} + +void CppCodeEmitter::EmitInterfaceStubHeaderFile() +{ + String filePath = String::Format("%s/%s.h", directory_.string(), FileName(stubName_).string()); + File file(filePath, File::WRITE); + + StringBuilder sb; + + EmitLicense(sb); + sb.Append("\n"); + EmitHeadMacro(sb, stubFullName_); + sb.Append("\n"); + sb.AppendFormat("#include \"%s.h\"\n", FileName(interfaceName_).string()); + sb.Append("#include \n"); + sb.Append("\n"); + EmitInterfaceStubInHeaderFile(sb); + EmitTailMacro(sb, stubFullName_); + + String data = sb.ToString(); + file.WriteData(data.string(), data.GetLength()); + file.Flush(); + file.Close(); +} + +void CppCodeEmitter::EmitInterfaceStubInHeaderFile( + /* [in] */ StringBuilder& sb) +{ + EmitBeginNamespace(sb); + sb.AppendFormat("class %s : public IRemoteStub<%s> {\n", stubName_.string(), interfaceName_.string()); + sb.Append("public:\n"); + EmitInterfaceStubMethodDecls(sb, TAB); + sb.Append("\n"); + sb.Append("private:\n"); + EmitInterfaceStubConstants(sb, TAB); + sb.Append("};\n"); + EmitEndNamespace(sb); +} + +void CppCodeEmitter::EmitInterfaceStubMethodDecls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).Append("int OnRemoteRequest(\n"); + sb.Append(prefix + TAB).Append("/* [in] */ uint32_t code,\n"); + sb.Append(prefix + TAB).Append("/* [in] */ MessageParcel& data,\n"); + sb.Append(prefix + TAB).Append("/* [out] */ MessageParcel& reply,\n"); + sb.Append(prefix + TAB).Append("/* [in] */ MessageOption& option) override;\n"); +} + +void CppCodeEmitter::EmitInterfaceStubConstants( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + EmitInterfaceMethodCommands(sb, prefix); +} + +void CppCodeEmitter::EmitInterfaceStubCppFile() +{ + String filePath = String::Format("%s/%s.cpp", directory_.string(), FileName(stubName_).string()); + File file(filePath, File::WRITE); + + StringBuilder sb; + + EmitLicense(sb); + sb.Append("\n"); + sb.AppendFormat("#include \"%s.h\"\n", FileName(stubName_).string()); + sb.Append("\n"); + EmitBeginNamespace(sb); + EmitInterfaceStubMethodImpls(sb, ""); + EmitEndNamespace(sb); + + String data = sb.ToString(); + file.WriteData(data.string(), data.GetLength()); + file.Flush(); + file.Close(); +} + +void CppCodeEmitter::EmitInterfaceStubMethodImpls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("int %s::OnRemoteRequest(\n", stubName_.string()); + sb.Append(prefix + TAB).Append("/* [in] */ uint32_t code,\n"); + sb.Append(prefix + TAB).Append("/* [in] */ MessageParcel& data,\n"); + sb.Append(prefix + TAB).Append("/* [out] */ MessageParcel& reply,\n"); + sb.Append(prefix + TAB).Append("/* [in] */ MessageOption& option)\n"); + sb.Append(prefix).Append("{\n"); + sb.Append(prefix + TAB).Append("switch (code) {\n"); + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + EmitInterfaceStubMethodImpl(mm, sb, prefix + TAB + TAB); + } + sb.Append(prefix + TAB).Append(TAB).Append("default:\n"); + sb.Append(prefix + TAB).Append(TAB).Append(TAB).Append( + "return IPCObjectStub::OnRemoteRequest(code, data, reply, option);\n"); + sb.Append(prefix + TAB).Append("}\n\n"); + sb.Append(prefix + TAB).Append("return ERR_TRANSACTION_FAILED;\n"); + sb.Append(prefix).Append("}\n"); +} + +void CppCodeEmitter::EmitInterfaceStubMethodImpl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("case COMMAND_%s: {\n", ConstantName(mm->name_).string()); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + if ((mp->attributes_ & ATTR_IN) != 0) { + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + const std::string name = UnderlineAdded(mp->name_); + EmitReadVariable("data.", name, mt, sb, prefix + TAB); + } else if ((mp->attributes_ & ATTR_OUT) != 0) { + EmitLocalVariable(mp, sb, prefix + TAB); + } + } + MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; + if (returnType->kind_ != TypeKind::Void) { + if ((returnType->kind_ == TypeKind::Sequenceable) || (returnType->kind_ == TypeKind::Interface)) { + sb.Append(prefix + TAB).AppendFormat("%s result = nullptr;\n", EmitType(returnType, ATTR_IN, true).string()); + } else { + sb.Append(prefix + TAB).AppendFormat("%s result;\n", EmitType(returnType, ATTR_IN, true).string()); + } + } + if (mm->parameterNumber_ == 0 && returnType->kind_ == TypeKind::Void) { + sb.Append(prefix + TAB).AppendFormat("ErrCode ec = %s();\n", mm->name_); + } else { + sb.Append(prefix + TAB).AppendFormat("ErrCode ec = %s(", mm->name_); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + const std::string name = UnderlineAdded(mp->name_); + sb.Append(name.c_str()); + if (i != mm->parameterNumber_ - 1 || returnType->kind_ != TypeKind::Void) { + sb.Append(", "); + } + } + if (returnType->kind_ != TypeKind::Void) { + EmitReturnParameter("result", returnType, sb); + } + sb.AppendFormat(");\n", mm->name_); + } + sb.Append(prefix + TAB).Append("reply.WriteInt32(ec);\n"); + bool hasOutParameter = false; + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + if ((mp->attributes_ & ATTR_OUT) != 0) { + hasOutParameter = true; + } + } + if (hasOutParameter || returnType->kind_ != TypeKind::Void) { + sb.Append(prefix + TAB).Append("if (SUCCEEDED(ec)) {\n"); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + if ((mp->attributes_ & ATTR_OUT) != 0) { + EmitWriteMethodParameter(mp, "reply.", sb, prefix + TAB + TAB); + } + } + if (returnType->kind_ != TypeKind::Void) { + EmitWriteVariable("reply.", "result", returnType, sb, prefix + TAB + TAB); + } + sb.Append(prefix + TAB).Append("}\n"); + } + sb.Append(prefix + TAB).Append("return ERR_NONE;\n"); + sb.Append(prefix).Append("}\n"); +} + +void CppCodeEmitter::EmitInterfaceMethodCommands( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + sb.Append(prefix).AppendFormat("static constexpr int COMMAND_%s = MIN_TRANSACTION_ID + %d;\n", ConstantName(mm->name_).string(), i); + } +} + +void CppCodeEmitter::EmitLicense( + /* [in] */ StringBuilder& sb) +{ + sb.Append(metaInterface_->license_).Append("\n"); +} + +void CppCodeEmitter::EmitHeadMacro( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& fullName) +{ + String macroName = MacroName(fullName); + sb.Append("#ifndef ").Append(macroName).Append("\n"); + sb.Append("#define ").Append(macroName).Append("\n"); +} + +void CppCodeEmitter::EmitTailMacro( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& fullName) +{ + String macroName = MacroName(fullName); + sb.Append("#endif // ").Append(macroName).Append("\n\n"); +} + +void CppCodeEmitter::EmitBeginNamespace( + /* [in] */ StringBuilder& sb) +{ + String nspace = GetNamespace(metaInterface_->namespace_); + int index = nspace.IndexOf('.'); + while (index != -1) { + sb.AppendFormat("namespace %s {\n", nspace.Substring(0, index).string()); + nspace = nspace.Substring(index + 1); + index = nspace.IndexOf('.'); + } +} + +void CppCodeEmitter::EmitEndNamespace( + /* [in] */ StringBuilder& sb) +{ + String nspace = GetNamespace(metaInterface_->namespace_); + nspace = nspace.Substring(0, nspace.GetLength() - 1); + while (!nspace.IsEmpty()) { + int index = nspace.LastIndexOf('.'); + sb.AppendFormat("} // namespace %s\n", index != -1 + ? nspace.Substring(index + 1, nspace.GetLength()).string() + : nspace.string()); + nspace = nspace.Substring(0, index); + } +} + +void CppCodeEmitter::EmitWriteVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + switch (mt->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("%sWriteInt32(%s ? 1 : 0);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Char: + case TypeKind::Byte: + case TypeKind::Short: + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("%sWriteInt32(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("%sWriteInt64(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("%sWriteFloat(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("%sWriteDouble(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("%sWriteString16(Str8ToStr16(%s));\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Sequenceable: + sb.Append(prefix).AppendFormat("%sWriteParcelable(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Interface: + sb.Append(prefix).AppendFormat("%sWriteRemoteObject(%s->AsObject());\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Array: + case TypeKind::List: { + sb.Append(prefix).AppendFormat("%sWriteInt32(%s.size());\n", parcelName.string(), name.c_str()); + sb.Append(prefix).AppendFormat("for (auto it = %s.begin(); it != %s.end(); ++it) {\n", + name.c_str(), name.c_str()); + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + EmitWriteVariable(parcelName, "(*it)", innerType, sb, prefix + TAB); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Map: { + sb.Append(prefix).AppendFormat("%sWriteInt32(%s.size());\n", parcelName.string(), name.c_str()); + sb.Append(prefix).AppendFormat("for (auto it = %s.begin(); it != %s.end(); ++it) {\n", + name.c_str(), name.c_str()); + MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; + EmitWriteVariable(parcelName, "(it->first)", keyType, sb, prefix + TAB); + EmitWriteVariable(parcelName, "(it->second)", valueType, sb, prefix + TAB); + sb.Append(prefix).Append("}\n"); + break; + } + default: + break; + } +} + +void CppCodeEmitter::EmitReadVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix, + /* [in] */ bool emitType) +{ + switch (mt->kind_) { + case TypeKind::Boolean: + if (emitType) { + sb.Append(prefix).AppendFormat("%s %s = %sReadInt32() == 1 ? true : false;\n", + EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string()); + } else { + sb.Append(prefix).AppendFormat("%s = %sReadInt32() == 1 ? true : false;\n", + name.c_str(), parcelName.string()); + } + break; + case TypeKind::Char: + case TypeKind::Byte: + case TypeKind::Short: + if (emitType) { + sb.Append(prefix).AppendFormat("%s %s = (%s)%sReadInt32();\n", EmitType(mt, ATTR_IN, true).string(), + name.c_str(), EmitType(mt, ATTR_IN, true).string(), parcelName.string()); + } else { + sb.Append(prefix).AppendFormat("%s = (%s)%sReadInt32();\n", name.c_str(), + EmitType(mt, ATTR_IN, true).string(), parcelName.string()); + } + break; + case TypeKind::Integer: + if (emitType) { + sb.Append(prefix).AppendFormat("%s %s = %sReadInt32();\n", + EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string()); + } else { + sb.Append(prefix).AppendFormat("%s = %sReadInt32();\n", name.c_str(), parcelName.string()); + } + break; + case TypeKind::Long: + if (emitType) { + sb.Append(prefix).AppendFormat("%s %s = %sReadInt64();\n", + EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string()); + } else { + sb.Append(prefix).AppendFormat("%s = %sReadInt64();\n", name.c_str(), parcelName.string()); + } + break; + case TypeKind::Float: + if (emitType) { + sb.Append(prefix).AppendFormat("%s %s = %sReadFloat();\n", + EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string()); + } else { + sb.Append(prefix).AppendFormat("%s = %sReadFloat();\n", name.c_str(), parcelName.string()); + } + break; + case TypeKind::Double: + if (emitType) { + sb.Append(prefix).AppendFormat("%s %s = %sReadDouble();\n", + EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string()); + } else { + sb.Append(prefix).AppendFormat("%s = %sReadDouble();\n", name.c_str(), parcelName.string()); + } + break; + case TypeKind::String: + if (emitType) { + sb.Append(prefix).AppendFormat("%s %s = Str16ToStr8(%sReadString16());\n", + EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string()); + } else { + sb.Append(prefix).AppendFormat("%s = Str16ToStr8(%sReadString16());\n", + name.c_str(), parcelName.string()); + } + break; + case TypeKind::Sequenceable: { + MetaSequenceable* mp = metaComponent_->sequenceables_[mt->index_]; + if (emitType) { + sb.Append(prefix).AppendFormat("%s %s = %sReadParcelable<%s>();\n", + EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string(), mp->name_); + } else { + sb.Append(prefix).AppendFormat("%s = %sReadParcelable<%s>();\n", + name.c_str(), parcelName.string(), mp->name_); + } + break; + } + case TypeKind::Interface: { + MetaInterface* mi = metaComponent_->interfaces_[mt->index_]; + if (emitType) { + sb.Append(prefix).AppendFormat("%s %s = iface_cast<%s>(%sReadRemoteObject());\n", + EmitType(mt, ATTR_IN, true).string(), name.c_str(), mi->name_, parcelName.string()); + } else { + sb.Append(prefix).AppendFormat("%s = iface_cast<%s>(%sReadRemoteObject());\n", + name.c_str(), mi->name_, parcelName.string()); + } + break; + } + case TypeKind::Array: + case TypeKind::List: { + if (emitType) { + sb.Append(prefix).AppendFormat("%s %s;\n", EmitType(mt, ATTR_IN, true).string(), name.c_str()); + } + sb.Append(prefix).AppendFormat("int %sSize = %sReadInt32();\n", name.c_str(), parcelName.string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + EmitReadVariable(parcelName, "value", innerType, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s.push_back(value);\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Map: { + if (emitType) { + sb.Append(prefix).AppendFormat("%s %s;\n", EmitType(mt, ATTR_IN, true).string(), name.c_str()); + } + sb.Append(prefix).AppendFormat("int %sSize = %sReadInt32();\n", name.c_str(), parcelName.string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); + MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; + EmitReadVariable(parcelName, "key", keyType, sb, prefix + TAB); + EmitReadVariable(parcelName, "value", valueType, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s[key] = value;\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + } + default: + break; + } +} + +void CppCodeEmitter::EmitLocalVariable( + /* [in] */ MetaParameter* mp, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + const std::string name = UnderlineAdded(mp->name_); + if ((mt->kind_ == TypeKind::Sequenceable) || (mt->kind_ == TypeKind::Interface)) { + sb.Append(prefix).AppendFormat("%s %s = nullptr;\n", EmitType(mt, ATTR_IN, true).string(), name.c_str()); + } else { + sb.Append(prefix).AppendFormat("%s %s;\n", EmitType(mt, ATTR_IN, true).string(), name.c_str()); + } +} + +void CppCodeEmitter::EmitReturnParameter( + /* [in] */ const String& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb) +{ + switch (mt->kind_) { + case TypeKind::Char: + case TypeKind::Boolean: + case TypeKind::Byte: + case TypeKind::Short: + case TypeKind::Integer: + case TypeKind::Long: + case TypeKind::Float: + case TypeKind::Double: + case TypeKind::String: + case TypeKind::Sequenceable: + case TypeKind::Interface: + case TypeKind::List: + case TypeKind::Map: + case TypeKind::Array: + sb.Append(name); + break; + default: + break; + } +} + +String CppCodeEmitter::EmitType( + /* [in] */ MetaType* mt, + /* [in] */ unsigned int attributes, + /* [in] */ bool isInnerType) +{ + switch(mt->kind_) { + case TypeKind::Char: + if (attributes & ATTR_IN) { + return "zchar"; + } else { + return "zchar&"; + } + case TypeKind::Boolean: + if (attributes & ATTR_IN) { + return "bool"; + } else { + return "bool&"; + } + case TypeKind::Byte: + if (attributes & ATTR_IN) { + return "int8_t"; + } else { + return "int8_t&"; + } + case TypeKind::Short: + if (attributes & ATTR_IN) { + return "short"; + } else { + return "short&"; + } + case TypeKind::Integer: + if (attributes & ATTR_IN) { + return "int"; + } else { + return "int&"; + } + case TypeKind::Long: + if (attributes & ATTR_IN) { + return "long"; + } else { + return "long&"; + } + case TypeKind::Float: + if (attributes & ATTR_IN) { + return "float"; + } else { + return "float&"; + } + case TypeKind::Double: + if (attributes & ATTR_IN) { + return "double"; + } else { + return "double&"; + } + case TypeKind::String: + if (attributes & ATTR_IN) { + if (!isInnerType) { + return "const std::string&"; + } else { + return "std::string"; + } + } else { + return "std::string&"; + } + case TypeKind::Void: + return "void"; + case TypeKind::Sequenceable: { + MetaSequenceable* mp = metaComponent_->sequenceables_[mt->index_]; + if ((attributes & ATTR_MASK) == (ATTR_IN | ATTR_OUT)) { + return String::Format("%s*", mp->name_); + } else if (attributes & ATTR_IN) { + return String::Format("%s*", mp->name_); + } else { + return String::Format("%s*", mp->name_); + } + } + case TypeKind::Interface: { + MetaInterface* mi = metaComponent_->interfaces_[mt->index_]; + if (attributes & ATTR_IN) { + if (!isInnerType) { + return String::Format("sptr<%s>", mi->name_); + } else { + return String::Format("sptr<%s>", mi->name_); + } + } else { + return String::Format("sptr<%s>&", mi->name_); + } + } + case TypeKind::Array: + case TypeKind::List: { + MetaType* elementType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + if (attributes & ATTR_OUT) { + return String::Format("std::vector<%s>&", + EmitType(elementType, ATTR_IN, true).string()); + } else { + if (!isInnerType) { + return String::Format("const std::vector<%s>&", + EmitType(elementType, ATTR_IN, true).string()); + } else { + return String::Format("std::vector<%s>", + EmitType(elementType, ATTR_IN, true).string()); + } + } + } + case TypeKind::Map: { + MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; + if (attributes & ATTR_OUT) { + return String::Format("std::unordered_map<%s, %s>&", + EmitType(keyType, ATTR_IN, true).string(), EmitType(valueType, ATTR_IN, true).string()); + } else { + if (!isInnerType) { + return String::Format("const std::unordered_map<%s, %s>&", + EmitType(keyType, ATTR_IN, true).string(), EmitType(valueType, ATTR_IN, true).string()); + } else { + return String::Format("std::unordered_map<%s, %s>", + EmitType(keyType, ATTR_IN, true).string(), EmitType(valueType, ATTR_IN, true).string()); + } + } + break; + } + default: + return "unknown type"; + } +} + +String CppCodeEmitter::CppFullName( + /* [in] */ const String& name) +{ + if (name.IsEmpty()) { + return name; + } + + return name.Replace(".", "::"); +} + +String CppCodeEmitter::FileName( + /* [in] */ const String& name) +{ + if (name.IsEmpty()) { + return name; + } + + StringBuilder sb; + + for (int i = 0; i < name.GetLength(); i++) { + char c = name[i]; + if (isupper(c) != 0) { + // 2->Index of the last char array. + if (i > 1 && name[i - 1] != '.' && name[i - 2] != '.') { + sb.Append('_'); + } + sb.Append(tolower(c)); + } else { + sb.Append(c); + } + } + + return sb.ToString().Replace('.', '/'); +} + +String CppCodeEmitter::MacroName( + /* [in] */ const String& name) +{ + if (name.IsEmpty()) { + return name; + } + + String macro = name.Replace('.', '_').ToUpperCase() + "_H"; + return macro; +} + +String CppCodeEmitter::ConstantName( + /* [in] */ const String& name) +{ + if (name.IsEmpty()) { + return name; + } + + StringBuilder sb; + + for (int i = 0; i < name.GetLength(); i++) { + char c = name[i]; + if (isupper(c) != 0) { + if (i > 1) { + sb.Append('_'); + } + sb.Append(c); + } else { + sb.Append(toupper(c)); + } + } + + return sb.ToString(); +} + +const std::string CppCodeEmitter::UnderlineAdded(const String& originName) +{ + std::string underline("_"); + return underline + std::string(originName.string()); +} + +} +} diff --git a/zidl/codegen/cpp_code_emitter.h b/zidl/codegen/cpp_code_emitter.h new file mode 100644 index 00000000000..f130be83af3 --- /dev/null +++ b/zidl/codegen/cpp_code_emitter.h @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_CPPCODEEMITTER_H +#define OHOS_ZIDL_CPPCODEEMITTER_H + +#include + +#include "codegen/code_emitter.h" +#include "util/string_builder.h" + +namespace OHOS { +namespace Zidl { + +class CppCodeEmitter : public CodeEmitter { +public: + CppCodeEmitter( + /* [in] */ MetaComponent* mc) + : CodeEmitter(mc) + {} + + void EmitInterface() override; + + void EmitInterfaceProxy() override; + + void EmitInterfaceStub() override; + +private: + void EmitInterfaceHeaderFile(); + + void EmitInterfaceInclusions( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceStdlibInclusions( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceDBinderInclusions( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceParametersInclusions( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceSelfDefinedTypeInclusions( + /* [in] */ StringBuilder& sb); + + bool EmitInterfaceUsings( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceSelfDefinedTypeUsings( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceDefinition( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceBody( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceMethods( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceMethod( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceMethodReturn( + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyHeaderFile(); + + void EmitInterfaceProxyInHeaderFile( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceProxyConstructor( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyMethodDecls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyMethodDecl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyConstants( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyCppFile(); + + void EmitInterfaceProxyMethodImpls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyMethodImpl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyMethodBody( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitWriteMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ const String& parcelName, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReadMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ const String& parcelName, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceStubHeaderFile(); + + void EmitInterfaceStubInHeaderFile( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceStubMethodDecls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceStubConstants( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceStubCppFile(); + + void EmitInterfaceStubMethodImpls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceStubMethodImpl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceMethodCommands( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitLicense( + /* [in] */ StringBuilder& sb); + + void EmitHeadMacro( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& fullName); + + void EmitTailMacro( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& fullName); + + void EmitBeginNamespace( + /* [in] */ StringBuilder& sb); + + void EmitEndNamespace( + /* [in] */ StringBuilder& sb); + + void EmitWriteVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReadVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix, + /* [in] */ bool emitType = true); + + void EmitLocalVariable( + /* [in] */ MetaParameter* mp, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReturnParameter( + /* [in] */ const String& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb); + + String EmitType( + /* [in] */ MetaType* mt, + /* [in] */ unsigned int attributes, + /* [in] */ bool isInnerType); + + String FileName( + /* [in] */ const String& name); + + String GetFilePath(const String& fpnp); + + String GetNamespace(const String& fpnp); + + String MacroName( + /* [in] */ const String& name); + + String CppFullName( + /* [in] */ const String& name); + + String ConstantName( + /* [in] */ const String& name); + + const std::string UnderlineAdded(const String& name); +}; + +} +} + +#endif // OHOS_ZIDL_CPPCODEEMITTER_H diff --git a/zidl/codegen/java_code_emitter.cpp b/zidl/codegen/java_code_emitter.cpp new file mode 100644 index 00000000000..e12fa8b2bd7 --- /dev/null +++ b/zidl/codegen/java_code_emitter.cpp @@ -0,0 +1,1178 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "codegen/java_code_emitter.h" + +#include + +#include "securec.h" +#include "util/file.h" + +namespace OHOS { +namespace Zidl { + +void JavaCodeEmitter::EmitInterface() +{ + String filePath = String::Format("%s/%s.java", directory_.string(), FileName(interfaceName_).string()); + File file(filePath, File::WRITE); + + StringBuilder sb; + + EmitLicense(sb); + sb.Append("\n"); + EmitPackage(sb); + sb.Append("\n"); + EmitInterfaceImports(sb); + sb.Append("\n"); + EmitInterfaceDefinition(sb); + sb.Append("\n"); + + String data = sb.ToString(); + file.WriteData(data.string(), data.GetLength()); + file.Flush(); + file.Close(); +} + +void JavaCodeEmitter::EmitInterfaceImports( + /* [in] */ StringBuilder& sb) +{ + EmitInterfaceCorelibImports(sb); + EmitInterfaceSelfDefinedTypeImports(sb); + EmitInterfaceDBinderImports(sb); +} + +void JavaCodeEmitter::EmitInterfaceCorelibImports( + /* [in] */ StringBuilder& sb) +{ + bool includeList = false; + bool includeMap = false; + for (int i = 0; i < metaComponent_->typeNumber_; i++) { + MetaType* mt = metaComponent_->types_[i]; + switch (mt->kind_) { + case TypeKind::List: { + if (!includeList) { + sb.Append("import java.util.List;\n"); + includeList = true; + } + break; + } + case TypeKind::Map: { + if (!includeMap) { + sb.Append("import java.util.Map;\n"); + includeMap = true; + } + break; + } + default: + break; + } + } +} + +void JavaCodeEmitter::EmitInterfaceDBinderImports( + /* [in] */ StringBuilder& sb) +{ + sb.Append("import ohos.rpc.IRemoteBroker;\n"); + sb.Append("import ohos.rpc.RemoteException;\n"); +} + +void JavaCodeEmitter::EmitInterfaceSelfDefinedTypeImports( + /* [in] */ StringBuilder& sb) +{ + for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { + MetaSequenceable* mp = metaComponent_->sequenceables_[i]; + sb.AppendFormat("import %s%s;\n", mp->namespace_, mp->name_); + } + + for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { + MetaInterface* mi = metaComponent_->interfaces_[i]; + if (mi->external_) { + sb.AppendFormat("import %s%s;\n", mi->namespace_, mi->name_); + } + } +} + +void JavaCodeEmitter::EmitInterfaceDefinition( + /* [in] */ StringBuilder& sb) +{ + sb.AppendFormat("public interface %s extends IRemoteBroker {\n", metaInterface_->name_); + EmitInterfaceMethods(sb, TAB); + sb.Append("};\n"); +} + +void JavaCodeEmitter::EmitInterfaceMethods( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + if (metaInterface_->methodNumber_ > 0) { + sb.Append("\n"); + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + EmitInterfaceMethod(mm, sb, prefix); + if (i != metaInterface_->methodNumber_ - 1) { + sb.Append("\n"); + } + } + } +} + +void JavaCodeEmitter::EmitInterfaceMethod( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; + if (mm->parameterNumber_ == 0) { + sb.Append(prefix).AppendFormat("%s %s() throws RemoteException;\n", EmitType(returnType).string(), MethodName(mm->name_).string()); + } else { + sb.Append(prefix).AppendFormat("%s %s(\n", EmitType(returnType).string(), MethodName(mm->name_).string()); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + EmitInterfaceMethodParameter(mp, sb, prefix + TAB); + if (i != mm->parameterNumber_ - 1) { + sb.Append(",\n"); + } + } + sb.Append(") throws RemoteException;\n"); + } +} + +void JavaCodeEmitter::EmitInterfaceMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + if ((mp->attributes_ & ATTR_MASK) == (ATTR_IN | ATTR_OUT)) { + sb.Append(prefix).Append("/* [inout] */ "); + } else if (mp->attributes_ & ATTR_IN) { + sb.Append(prefix).Append("/* [in] */ "); + } else { + sb.Append(prefix).Append("/* [out] */ "); + } + + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + std::string name = UnderlineAdded(mp->name_); + sb.AppendFormat("%s %s", EmitType(mt).string(), name.c_str()); +} + +void JavaCodeEmitter::EmitInterfaceProxy() +{ + String filePath = String::Format("%s/%s.java", directory_.string(), FileName(proxyName_).string()); + File file(filePath, File::WRITE); + + StringBuilder sb; + + EmitLicense(sb); + sb.Append("\n"); + EmitPackage(sb); + sb.Append("\n"); + EmitInterfaceProxyImports(sb); + sb.Append("\n"); + EmitInterfaceProxyImpl(sb); + sb.Append("\n"); + + String data = sb.ToString(); + file.WriteData(data.string(), data.GetLength()); + file.Flush(); + file.Close(); +} + +void JavaCodeEmitter::EmitInterfaceProxyImports( + /* [in] */ StringBuilder& sb) +{ + EmitInterfaceProxyCorelibImports(sb); + EmitInterfaceProxySelfDefinedTypeImports(sb); + EmitInterfaceProxyDBinderImports(sb); + EmitInterfaceProxyParametersImports(sb); +} + +void JavaCodeEmitter::EmitInterfaceProxyCorelibImports( + /* [in] */ StringBuilder& sb) +{ + bool includeList = false; + bool includeMap = false; + for (int i = 0; i < metaComponent_->typeNumber_; i++) { + MetaType* mt = metaComponent_->types_[i]; + switch(mt->kind_) { + case TypeKind::List: { + if (!includeList) { + sb.Append("import java.util.List;\n"); + sb.Append("import java.util.ArrayList;\n"); + includeList = true; + } + break; + } + case TypeKind::Map: { + if (!includeMap) { + sb.Append("import java.util.Map;\n"); + sb.Append("import java.util.HashMap;\n"); + includeMap = true; + } + break; + } + default: + break; + } + } +} + +void JavaCodeEmitter::EmitInterfaceProxySelfDefinedTypeImports( + /* [in] */ StringBuilder& sb) +{ + for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { + MetaSequenceable* mp = metaComponent_->sequenceables_[i]; + sb.AppendFormat("import %s%s;\n", mp->namespace_, mp->name_); + } + + for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { + MetaInterface* mi = metaComponent_->interfaces_[i]; + if (mi->external_) { + sb.AppendFormat("import %s%s;\n", mi->namespace_, mi->name_); + sb.AppendFormat("import %s%s;\n", mi->namespace_, StubName(String(mi->name_)).string()); + } + } +} + +void JavaCodeEmitter::EmitInterfaceProxyDBinderImports( + /* [in] */ StringBuilder& sb) +{ + sb.Append("import ohos.rpc.IRemoteObject;\n"); + sb.Append("import ohos.rpc.RemoteException;\n"); + sb.Append("import ohos.rpc.MessageParcel;\n"); + sb.Append("import ohos.rpc.MessageOption;\n"); +} + +void JavaCodeEmitter::EmitInterfaceProxyParametersImports( + /* [in] */ StringBuilder& sb) +{ + sb.Append("import ohos.system.version.SystemVersion;\n"); +} + +void JavaCodeEmitter::EmitInterfaceProxyImpl( + /* [in] */ StringBuilder& sb) +{ + sb.AppendFormat("public class %s implements %s {\n", proxyName_.string(), interfaceName_.string()); + EmitInterfaceProxyConstants(sb, TAB); + sb.Append("\n"); + sb.Append(TAB).Append("private final IRemoteObject remote;\n"); + sb.Append(TAB).Append("private static final int ERR_OK = 0;\n"); + sb.Append("\n"); + EmitInterfaceProxyConstructor(sb, TAB); + sb.Append("\n"); + EmitInterfaceProxyMethodImpls(sb, TAB); + sb.Append("};\n"); +} + +void JavaCodeEmitter::EmitInterfaceProxyConstants( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("private static final String DESCRIPTOR = \"%s\";\n\n", interfaceFullName_.string()); + EmitInterfaceMethodCommands(sb, prefix); +} + +void JavaCodeEmitter::EmitInterfaceProxyConstructor( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("public %s(\n", proxyName_.string()); + sb.Append(prefix + TAB).Append("/* [in] */ IRemoteObject remote) {\n"); + sb.Append(prefix + TAB).Append("this.remote = remote;\n"); + sb.Append(prefix).Append("}\n"); + sb.Append("\n"); + sb.Append(prefix).AppendFormat("@Override\n"); + sb.Append(prefix).Append("public IRemoteObject asObject() {\n"); + sb.Append(prefix + TAB).Append("return remote;\n"); + sb.Append(prefix).Append("}\n"); +} + +void JavaCodeEmitter::EmitInterfaceProxyMethodImpls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + if (metaInterface_->methodNumber_ > 0) { + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + EmitInterfaceProxyMethodImpl(mm, sb, prefix); + if (i != metaInterface_->methodNumber_ - 1) { + sb.Append("\n"); + } + } + } +} + +void JavaCodeEmitter::EmitInterfaceProxyMethodImpl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; + sb.Append(prefix).Append("@Override\n"); + if (mm->parameterNumber_ == 0) { + sb.Append(prefix).AppendFormat("public %s %s() throws RemoteException ", EmitType(returnType).string(), MethodName(mm->name_).string()); + } else { + sb.Append(prefix).AppendFormat("public %s %s(\n", EmitType(returnType).string(), MethodName(mm->name_).string()); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + EmitInterfaceMethodParameter(mp, sb, prefix + TAB); + if (i != mm->parameterNumber_ - 1) { + sb.Append(",\n"); + } + } + sb.Append(") throws RemoteException "); + } + EmitInterfaceProxyMethodBody(mm, sb, prefix); +} + +void JavaCodeEmitter::EmitInterfaceProxyMethodBody( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append("{\n"); + sb.Append(prefix + TAB).Append("MessageParcel data = MessageParcel.obtain();\n"); + sb.Append(prefix + TAB).Append("MessageParcel reply = MessageParcel.obtain();\n"); + sb.Append(prefix + TAB).AppendFormat("MessageOption option = new MessageOption(%s);\n", + (mm->properties_ & METHOD_PROPERTY_ONEWAY) != 0 ? "MessageOption.TF_ASYNC" : "MessageOption.TF_SYNC"); + sb.Append("\n"); + int32_t R_API_VERSION = 6; + sb.Append(prefix + TAB).AppendFormat("if (SystemVersion.getApiVersion() >= %d) {\n", R_API_VERSION); + sb.Append(prefix + TAB).Append(" data.updateDataVersion(remote);\n"); + sb.Append(prefix + TAB).Append("}\n"); + sb.Append(prefix).AppendFormat(" data.writeInterfaceToken(DESCRIPTOR);\n"); + + bool needBlankLine = false; + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + if ((mp->attributes_ & ATTR_IN) != 0) { + EmitWriteMethodParameter(mp, "data", sb, prefix + TAB); + needBlankLine = true; + } else if ((mp->attributes_ & ATTR_OUT) != 0) { + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + if (mt->kind_ == TypeKind::Array) { + std::string name = UnderlineAdded(mp->name_); + EmitWriteOutArrayVariable("data", name, mt, sb, prefix + TAB); + } + } + } + if (needBlankLine) { + sb.Append("\n"); + } + sb.Append(prefix + TAB).Append("try {\n"); + sb.Append(prefix + TAB + TAB).AppendFormat("remote.sendRequest(COMMAND_%s, data, reply, option);\n", + ConstantName(mm->name_).string()); + sb.Append(prefix + TAB).Append(" reply.readException();\n"); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + if ((mp->attributes_ & ATTR_OUT) != 0) { + EmitReadMethodParameter(mp, "reply", sb, prefix + TAB + TAB); + } + } + MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; + if (returnType->kind_ != TypeKind::Void) { + EmitReadVariable("reply", "result", returnType, ATTR_IN, sb, prefix + TAB + TAB); + } + if (returnType->kind_ != TypeKind::Void) { + sb.Append(prefix + TAB + TAB).Append("return result;\n"); + } + + sb.Append(prefix + TAB).Append("} finally {\n"); + sb.Append(prefix + TAB + TAB).Append("data.reclaim();\n"); + sb.Append(prefix + TAB + TAB).Append("reply.reclaim();\n"); + sb.Append(prefix + TAB).Append("}\n"); + sb.Append(prefix).Append("}\n"); +} + +void JavaCodeEmitter::EmitWriteMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ const String& parcelName, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + std::string name = UnderlineAdded(mp->name_); + EmitWriteVariable(parcelName, name, mt, sb, prefix); +} + +void JavaCodeEmitter::EmitReadMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ const String& parcelName, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + std::string name = UnderlineAdded(mp->name_); + EmitReadOutVariable(parcelName, name, mt, sb, prefix); +} + +void JavaCodeEmitter::EmitInterfaceStub() +{ + String filePath = String::Format("%s/%s.java", directory_.string(), FileName(stubName_).string()); + File file(filePath, File::WRITE); + + StringBuilder sb; + + EmitLicense(sb); + sb.Append("\n"); + EmitPackage(sb); + sb.Append("\n"); + EmitInterfaceStubImports(sb); + sb.Append("\n"); + EmitInterfaceStubImpl(sb); + sb.Append("\n"); + + String data = sb.ToString(); + file.WriteData(data.string(), data.GetLength()); + file.Flush(); + file.Close(); +} + +void JavaCodeEmitter::EmitInterfaceStubImports( + /* [in] */ StringBuilder& sb) +{ + EmitInterfaceStubCorelibImports(sb); + EmitInterfaceStubSelfDefinedTypeImports(sb); + EmitInterfaceStubDBinderImports(sb); +} + +void JavaCodeEmitter::EmitInterfaceStubCorelibImports( + /* [in] */ StringBuilder& sb) +{ + EmitInterfaceProxyCorelibImports(sb); +} + +void JavaCodeEmitter::EmitInterfaceStubSelfDefinedTypeImports( + /* [in] */ StringBuilder& sb) +{ + for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { + MetaSequenceable* mp = metaComponent_->sequenceables_[i]; + sb.AppendFormat("import %s%s;\n", mp->namespace_, mp->name_); + } + + for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { + MetaInterface* mi = metaComponent_->interfaces_[i]; + if (mi->external_) { + sb.AppendFormat("import %s%s;\n", mi->namespace_, mi->name_); + sb.AppendFormat("import %s%s;\n", mi->namespace_, StubName(String(mi->name_)).string()); + } + } + sb.AppendFormat("import %s;\n", proxyFullName_.string()); +} + +void JavaCodeEmitter::EmitInterfaceStubDBinderImports( + /* [in] */ StringBuilder& sb) +{ + sb.Append("import ohos.rpc.IRemoteBroker;\n"); + sb.Append("import ohos.rpc.IRemoteObject;\n"); + sb.Append("import ohos.rpc.RemoteException;\n"); + sb.Append("import ohos.rpc.RemoteObject;\n"); + sb.Append("import ohos.rpc.MessageParcel;\n"); + sb.Append("import ohos.rpc.MessageOption;\n"); +} + +void JavaCodeEmitter::EmitInterfaceStubImpl( + /* [in] */ StringBuilder& sb) +{ + sb.AppendFormat("public abstract class %s extends RemoteObject implements %s {\n", stubName_.string(), interfaceName_.string()); + EmitInterfaceStubConstants(sb, TAB); + sb.Append("\n"); + sb.Append(TAB).Append("private static final int ERR_OK = 0;\n"); + sb.Append(TAB).Append("private static final int ERR_RUNTIME_EXCEPTION = -1;\n"); + sb.Append("\n"); + EmitInterfaceStubConstructor(sb, TAB); + sb.Append("\n"); + EmitInterfaceStubMethodImpls(sb, TAB); + sb.Append("};\n"); +} + +void JavaCodeEmitter::EmitInterfaceStubConstants( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("private static final String DESCRIPTOR = \"%s\";\n\n", interfaceFullName_.string()); + EmitInterfaceMethodCommands(sb, prefix); +} + +void JavaCodeEmitter::EmitInterfaceStubConstructor( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("public %s(\n", stubName_.string()); + sb.Append(prefix + TAB).Append("/* [in] */ String descriptor) {\n"); + sb.Append(prefix + TAB).Append("super(descriptor);\n"); + sb.Append(prefix).Append("}\n"); + sb.Append("\n"); + sb.Append(prefix).Append("@Override\n"); + sb.Append(prefix).Append("public IRemoteObject asObject() {\n"); + sb.Append(prefix + TAB).Append("return this;\n"); + sb.Append(prefix).Append("}\n"); + sb.Append("\n"); + sb.Append(prefix).AppendFormat("public static %s asInterface(IRemoteObject object) {\n", interfaceName_.string()); + sb.Append(prefix + TAB).Append("if (object == null) {\n"); + sb.Append(prefix + TAB).Append(TAB).Append("return null;\n"); + sb.Append(prefix + TAB).Append("}\n"); + sb.Append("\n"); + sb.Append(prefix + TAB).AppendFormat("%s result = null;\n", interfaceName_.string()); + sb.Append(prefix + TAB).Append("IRemoteBroker broker = object.queryLocalInterface(DESCRIPTOR);\n"); + sb.Append(prefix + TAB).Append("if (broker != null) {\n"); + sb.Append(prefix + TAB).Append(TAB).AppendFormat("if (broker instanceof %s) {\n", interfaceName_.string()); + sb.Append(prefix + TAB).Append(TAB).Append(TAB).AppendFormat("result = (%s)broker;\n", interfaceName_.string()); + sb.Append(prefix + TAB).Append(TAB).Append("}\n"); + sb.Append(prefix + TAB).Append("} else {\n"); + sb.Append(prefix + TAB).Append(TAB).AppendFormat("result = new %s(object);\n", proxyName_.string()); + sb.Append(prefix + TAB).Append("}\n"); + sb.Append("\n"); + sb.Append(prefix + TAB).Append("return result;\n"); + sb.Append(prefix).Append("}\n"); +} + +void JavaCodeEmitter::EmitInterfaceStubMethodImpls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).Append("@Override\n"); + sb.Append(prefix).Append("public boolean onRemoteRequest(\n"); + sb.Append(prefix + TAB).Append("/* [in] */ int code,\n"); + sb.Append(prefix + TAB).Append("/* [in] */ MessageParcel data,\n"); + sb.Append(prefix + TAB).Append("/* [out] */ MessageParcel reply,\n"); + sb.Append(prefix + TAB).Append("/* [in] */ MessageOption option) throws RemoteException {\n"); + sb.Append(prefix + TAB).Append("String token = data.readInterfaceToken();\n"); + sb.Append(prefix + TAB).Append("if (!DESCRIPTOR.equals(token)) {\n"); + sb.Append(prefix + TAB).Append(" return false;\n"); + sb.Append(prefix + TAB).Append("}\n"); + + sb.Append(prefix + TAB).Append("switch (code) {\n"); + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + EmitInterfaceStubMethodImpl(mm, sb, prefix + TAB + TAB); + } + sb.Append(prefix + TAB).Append(TAB).Append("default:\n"); + sb.Append(prefix + TAB).Append(TAB).Append(TAB).Append( + "return super.onRemoteRequest(code, data, reply, option);\n"); + sb.Append(prefix + TAB).Append("}\n"); + sb.Append(prefix).Append("}\n"); +} + +void JavaCodeEmitter::EmitInterfaceStubMethodImpl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("case COMMAND_%s: {\n", ConstantName(mm->name_).string()); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + if ((mp->attributes_ & ATTR_IN) != 0) { + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + EmitReadVariable("data", UnderlineAdded(mp->name_), mt, ATTR_IN, sb, prefix + TAB); + } else if ((mp->attributes_ & ATTR_OUT) != 0) { + EmitLocalVariable(mp, sb, prefix + TAB); + } + } + + MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; + if (returnType->kind_ != TypeKind::Void) { + sb.Append(prefix + TAB).AppendFormat("%s result;\n", EmitType(returnType).string()); + } + + if (mm->parameterNumber_ == 0) { + if (returnType->kind_ == TypeKind::Void) { + sb.Append(prefix + TAB).AppendFormat("%s();\n", mm->name_); + } else { + sb.Append(prefix + TAB).AppendFormat("result = %s();\n", mm->name_); + } + } else { + if (returnType->kind_ == TypeKind::Void) { + sb.Append(prefix + TAB).AppendFormat("%s(", mm->name_); + } else { + sb.Append(prefix + TAB).AppendFormat("result = %s(", mm->name_); + } + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + sb.Append(UnderlineAdded(mp->name_).c_str()); + if (i != mm->parameterNumber_ - 1) { + sb.Append(", "); + } + } + sb.AppendFormat(");\n", mm->name_); + } + + sb.Append(prefix + TAB).Append("reply.writeNoException();\n"); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + if ((mp->attributes_ & ATTR_OUT) != 0) { + EmitWriteMethodParameter(mp, "reply", sb, prefix + TAB); + } + } + if (returnType->kind_ != TypeKind::Void) { + EmitWriteVariable("reply", "result", returnType, sb, prefix + TAB); + } + sb.Append(prefix + TAB).Append("return true;\n"); + sb.Append(prefix).Append("}\n"); +} + +void JavaCodeEmitter::EmitInterfaceMethodCommands( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + sb.Append(prefix).AppendFormat("private static final int COMMAND_%s = IRemoteObject.MIN_TRANSACTION_ID + %d;\n", + ConstantName(mm->name_).string(), i); + } +} + +void JavaCodeEmitter::EmitLicense( + /* [in] */ StringBuilder& sb) +{ + sb.Append(metaInterface_->license_).Append("\n"); +} + +void JavaCodeEmitter::EmitPackage( + /* [in] */ StringBuilder& sb) +{ + String package = metaInterface_->namespace_; + int index = package.LastIndexOf('.'); + sb.AppendFormat("package %s;\n", index != -1 ? package.Substring(0, index).string() : package.string()); +} + +void JavaCodeEmitter::EmitWriteVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + switch (mt->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("%s.writeInt(%s ? 1 : 0);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Char: + case TypeKind::Byte: + case TypeKind::Short: + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("%s.writeInt(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("%s.writeLong(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("%s.writeFloat(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("%s.writeDouble(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("%s.writeString(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Sequenceable: + if (EmitType(mt).Equals("IRemoteObject")) { + sb.Append(prefix).AppendFormat("%s.writeRemoteObject(%s);\n", parcelName.string(), name.c_str()); + break; + } + sb.Append(prefix).AppendFormat("%s.writeSequenceable(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Interface: + sb.Append(prefix).AppendFormat("%s.writeRemoteObject(%s.asObject());\n", parcelName.string(), + name.c_str()); + break; + case TypeKind::List: { + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + sb.Append(prefix).AppendFormat("%s.writeInt(%s.size());\n", parcelName.string(), name.c_str()); + sb.Append(prefix).AppendFormat("for (%s element : %s) {\n", + EmitType(innerType).string(), name.c_str()); + EmitWriteVariable(parcelName, "element", innerType, sb, prefix + TAB); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Map: { + MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; + sb.Append(prefix).AppendFormat("%s.writeInt(%s.size());\n", parcelName.string(), name.c_str()); + sb.Append(prefix).AppendFormat("for (Map.Entry<%s, %s> entry : %s.entrySet()) {\n", + EmitType(keyType).string(), EmitType(valueType).string(), name.c_str()); + EmitWriteVariable(parcelName, "entry.getKey()", keyType, sb, prefix + TAB); + EmitWriteVariable(parcelName, "entry.getValue()", valueType, sb, prefix + TAB); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Array: { + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + sb.Append(prefix).AppendFormat("if (%s == null) {\n", name.c_str()); + sb.Append(prefix).AppendFormat(" %s.writeInt(-1);\n", parcelName.string()); + sb.Append(prefix).Append("} else { \n"); + EmitWriteArrayVariable(parcelName, name, innerType, sb, prefix + TAB); + sb.Append(prefix).Append("}\n"); + break; + } + default: + break; + } +} + +void JavaCodeEmitter::EmitWriteArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + switch (mt->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("%s.writeBooleanArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Char: + sb.Append(prefix).AppendFormat("%s.writeCharArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Byte: + sb.Append(prefix).AppendFormat("%s.writeByteArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Short: + sb.Append(prefix).AppendFormat("%s.writeShortArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("%s.writeIntArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("%s.writeLongArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("%s.writeFloatArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("%s.writeDoubleArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("%s.writeStringArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Sequenceable: + sb.Append(prefix).AppendFormat("%s.writeSequenceableArray(%s);\n", parcelName.string(), name.c_str()); + break; + default: + break; + } +} + +void JavaCodeEmitter::EmitWriteOutArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("if (%s == null) {\n", name.c_str()); + sb.Append(prefix).AppendFormat(" %s.writeInt(-1);\n", parcelName.string()); + sb.Append(prefix).Append("} else {\n"); + sb.Append(prefix).AppendFormat(" %s.writeInt(%s.length);\n", parcelName.string(), name.c_str()); + sb.Append(prefix).Append("}\n"); +} + +void JavaCodeEmitter::EmitReadVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ unsigned int attributes, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + switch (mt->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("%s %s = %s.readInt() == 1 ? true : false;\n", + EmitType(mt).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::Char: + case TypeKind::Byte: + case TypeKind::Short: + sb.Append(prefix).AppendFormat("%s %s = (%s)%s.readInt();\n", + EmitType(mt).string(), name.c_str(), EmitType(mt).string(), parcelName.string()); + break; + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("%s %s = %s.readInt();\n", + EmitType(mt).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("%s %s = %s.readLong();\n", + EmitType(mt).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("%s %s = %s.readFloat();\n", + EmitType(mt).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("%s %s = %s.readDouble();\n", + EmitType(mt).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("%s %s = %s.readString();\n", + EmitType(mt).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::Sequenceable: + if ((attributes & ATTR_OUT) == 0 && EmitType(mt).Equals("IRemoteObject")) { + sb.Append(prefix).AppendFormat("IRemoteObject %s = %s.readRemoteObject();\n", + name.c_str(), parcelName.string()); + break; + } + if ((attributes & ATTR_OUT) == 0) { + sb.Append(prefix).AppendFormat("%s %s = new %s();\n", + EmitType(mt).string(), name.c_str(), EmitType(mt).string()); + } + sb.Append(prefix).AppendFormat("%s.readSequenceable(%s);\n", parcelName.string(), name.c_str()); + + break; + case TypeKind::Interface: + sb.Append(prefix).AppendFormat("%s %s = %s.asInterface(%s.readRemoteObject());\n", EmitType(mt).string(), + name.c_str(), StubName(EmitType(mt)).string(), parcelName.string()); + break; + case TypeKind::List: { + sb.Append(prefix).AppendFormat("%s %s = new Array%s();\n", + EmitType(mt).string(), name.c_str(), EmitType(mt).string()); + sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s.add(value);\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Map: { + sb.Append(prefix).AppendFormat("%s %s = new Hash%s();\n", + EmitType(mt).string(), name.c_str(), EmitType(mt).string()); + sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); + MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; + EmitReadVariable(parcelName, "key", keyType, ATTR_IN, sb, prefix + TAB); + EmitReadVariable(parcelName, "value", valueType, ATTR_IN, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s.put(key, value);\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Array: { + if ((attributes & ATTR_MASK) == ATTR_OUT) { + EmitReadOutArrayVariable(parcelName, name, mt, sb, prefix); + } else { + EmitReadArrayVariable(parcelName, name, mt, attributes, sb, prefix); + } + break; + } + default: + break; + } +} + +void JavaCodeEmitter::EmitReadArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ unsigned int attributes, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + switch (innerType->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("%s[] %s = %s.readBooleanArray();\n", + EmitType(innerType).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::Char: + sb.Append(prefix).AppendFormat("%s[] %s = %s.readCharArray();\n", + EmitType(innerType).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::Byte: + sb.Append(prefix).AppendFormat("%s[] %s = %s.readByteArray();\n", + EmitType(innerType).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::Short: + sb.Append(prefix).AppendFormat("%s[] %s = %s.readShortArray();\n", + EmitType(innerType).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("%s[] %s = %s.readIntArray();\n", + EmitType(innerType).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("%s[] %s = %s.readLongArray();\n", + EmitType(innerType).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("%s[] %s = %s.readFloatArray();\n", + EmitType(innerType).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("%s[] %s = %s.readDoubleArray();\n", + EmitType(innerType).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("%s[] %s = %s.readStringArray();\n", + EmitType(innerType).string(), name.c_str(), parcelName.string()); + break; + case TypeKind::Sequenceable: + sb.Append(prefix).AppendFormat("int size = %s.readInt();\n", parcelName.string()); + sb.Append(prefix).AppendFormat("%s %s = new %s[size];\n", + EmitType(mt).string(), name.c_str(), EmitType(innerType).string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < size; ++i) {\n"); + EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s[i] = value;\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + default: + break; + } +} + +void JavaCodeEmitter::EmitReadOutArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + switch (innerType->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("%s.readBooleanArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Char: + sb.Append(prefix).AppendFormat("%s.readCharArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Byte: + sb.Append(prefix).AppendFormat("%s.readByteArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Short: + sb.Append(prefix).AppendFormat("%s.readShortArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("%s.readIntArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("%s.readLongArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("%s.readFloatArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("%s.readDoubleArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("%s.readStringArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Sequenceable: + sb.Append(prefix).AppendFormat("%s.readSequenceableArray(%s);\n", parcelName.string(), name.c_str()); + break; + default: + break; + } +} + +void JavaCodeEmitter::EmitReadOutVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + switch (mt->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("%s = %s.readInt() == 1 ? true : false;\n", + name.c_str(), parcelName.string()); + break; + case TypeKind::Char: + case TypeKind::Byte: + case TypeKind::Short: + sb.Append(prefix).AppendFormat("%s = (%s)%s.readInt();\n", + name.c_str(), EmitType(mt).string(), parcelName.string()); + break; + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("%s = %s.readInt();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("%s = %s.readLong();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("%s = %s.readFloat();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("%s = %s.readDouble();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("%s = %s.readString();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Sequenceable: + if (EmitType(mt).Equals("IRemoteObject")) { + sb.Append(prefix).AppendFormat("%s = %s.readRemoteObject();\n", name.c_str(), parcelName.string()); + break; + } + sb.Append(prefix).AppendFormat("%s.readSequenceable(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Interface: + sb.Append(prefix).AppendFormat("%s = %s.asInterface(%s.readRemoteObject());\n", name.c_str(), + StubName(EmitType(mt)).string(), parcelName.string()); + break; + case TypeKind::List: { + sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s.add(value);\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Map: { + sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); + MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; + EmitReadVariable(parcelName, "key", keyType, ATTR_IN, sb, prefix + TAB); + EmitReadVariable(parcelName, "value", valueType, ATTR_IN, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s.put(key, value);\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Array: { + EmitReadOutArrayVariable(parcelName, name, mt, sb, prefix); + break; + } + default: + break; + } +} + +void JavaCodeEmitter::EmitLocalVariable( + /* [in] */ MetaParameter* mp, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + std::string name = UnderlineAdded(mp->name_); + if (mt->kind_ == TypeKind::Sequenceable) { + sb.Append(prefix).AppendFormat("%s %s = new %s();\n", EmitType(mt).string(), name.c_str(), + EmitType(mt).string()); + } else if (mt->kind_ == TypeKind::List) { + sb.Append(prefix).AppendFormat("%s %s = new Array%s();\n", EmitType(mt).string(), name.c_str(), + EmitType(mt).string()); + } else if (mt->kind_ == TypeKind::Map) { + sb.Append(prefix).AppendFormat("%s %s = new Hash%s();\n", EmitType(mt).string(), name.c_str(), + EmitType(mt).string()); + } else { + sb.Append(prefix).AppendFormat("%s %s;\n", EmitType(mt).string(), name.c_str()); + } +} + +String JavaCodeEmitter::EmitType( + /* [in] */ MetaType* mt) +{ + switch(mt->kind_) { + case TypeKind::Char: + return "char"; + case TypeKind::Boolean: + return "boolean"; + case TypeKind::Byte: + return "byte"; + case TypeKind::Short: + return "short"; + case TypeKind::Integer: + return "int"; + case TypeKind::Long: + return "long"; + case TypeKind::Float: + return "float"; + case TypeKind::Double: + return "double"; + case TypeKind::String: + return "String"; + case TypeKind::Void: + return "void"; + case TypeKind::Sequenceable: { + MetaSequenceable* mp = metaComponent_->sequenceables_[mt->index_]; + return mp->name_; + } + case TypeKind::Interface: { + MetaInterface* mi = metaComponent_->interfaces_[mt->index_]; + return mi->name_; + } + case TypeKind::List: { + MetaType* elementType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + return String::Format("List<%s>", EmitType(elementType).string()); + } + case TypeKind::Map: { + MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; + return String::Format("Map<%s, %s>", EmitType(keyType).string(), EmitType(valueType).string()); + } + case TypeKind::Array: { + MetaType* elementType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + return String::Format("%s[]", EmitType(elementType).string()); + } + default: + return "unknown type"; + } +} + +String JavaCodeEmitter::FileName( + /* [in] */ const String& name) +{ + if (name.IsEmpty()) { + return name; + } + + return name.Replace('.', '/'); +} + +String JavaCodeEmitter::MethodName( + /* [in] */ const String& name) +{ + if (name.IsEmpty() || islower(name[0])) { + return name; + } + return String::Format("%c%s", tolower(name[0]), name.Substring(1).string()); +} + +String JavaCodeEmitter::ConstantName( + /* [in] */ const String& name) +{ + if (name.IsEmpty()) { + return name; + } + + StringBuilder sb; + + for (int i = 0; i < name.GetLength(); i++) { + char c = name[i]; + if (isupper(c) != 0) { + if (i > 1) { + sb.Append('_'); + } + sb.Append(c); + } else { + sb.Append(toupper(c)); + } + } + + return sb.ToString(); +} + +String JavaCodeEmitter::StubName( + /* [in] */ const String& name) +{ + return name.StartsWith("I") ? (name.Substring(1) + "Stub") : (name + "Stub"); +} + +const std::string JavaCodeEmitter::UnderlineAdded(const String& originName) +{ + std::string underline("_"); + return underline + std::string(originName.string()); +} + +} +} diff --git a/zidl/codegen/java_code_emitter.h b/zidl/codegen/java_code_emitter.h new file mode 100644 index 00000000000..777f74c310c --- /dev/null +++ b/zidl/codegen/java_code_emitter.h @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_JAVACODEEMITTER_H +#define OHOS_ZIDL_JAVACODEEMITTER_H + +#include + +#include "codegen/code_emitter.h" +#include "util/string_builder.h" + +namespace OHOS { +namespace Zidl { + +class JavaCodeEmitter : public CodeEmitter { +public: + JavaCodeEmitter( + /* [in] */ MetaComponent* mc) + : CodeEmitter(mc) + {} + + void EmitInterface() override; + + void EmitInterfaceProxy() override; + + void EmitInterfaceStub() override; + +private: + void EmitInterfaceImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceCorelibImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceDBinderImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceSelfDefinedTypeImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceDefinition( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceMethods( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceMethod( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceProxyCorelibImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceProxySelfDefinedTypeImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceProxyDBinderImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceProxyParametersImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceProxyImpl( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceProxyConstants( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyConstructor( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyMethodImpls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyMethodImpl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyMethodBody( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitWriteMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ const String& parcelName, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReadMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ const String& parcelName, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceStubImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceStubCorelibImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceStubSelfDefinedTypeImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceStubDBinderImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceStubImpl( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceStubConstants( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceStubConstructor( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceStubMethodImpls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceStubMethodImpl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceMethodCommands( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitLicense( + /* [in] */ StringBuilder& sb); + + void EmitPackage( + /* [in] */ StringBuilder& sb); + + void EmitWriteVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReadVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ unsigned int attributes, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReadOutVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReadArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ unsigned int attributes, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitWriteArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitWriteOutArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReadOutArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitLocalVariable( + /* [in] */ MetaParameter* mp, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + String EmitType( + /* [in] */ MetaType* mt); + + String FileName( + /* [in] */ const String& name); + + String MethodName( + /* [in] */ const String& name); + + String ConstantName( + /* [in] */ const String& name); + + String StubName( + /* [in] */ const String& name); + + const std::string UnderlineAdded(const String& name); +}; + +} +} + +#endif // OHOS_ZIDL_JAVACODEEMITTER_H diff --git a/zidl/codegen/js_code_emitter.cpp b/zidl/codegen/js_code_emitter.cpp new file mode 100644 index 00000000000..95c7c048ebf --- /dev/null +++ b/zidl/codegen/js_code_emitter.cpp @@ -0,0 +1,1167 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "codegen/js_code_emitter.h" + +#include +#include + +#include "securec.h" +#include "util/file.h" + +namespace OHOS { +namespace Zidl { + + +void JsCodeEmitter::EmitInterface() +{ +} + +void JsCodeEmitter::EmitInterfaceImports( + /* [in] */ StringBuilder& sb) +{ + sb.Append("import rpc from \"@ohos.rpc\";\n"); +} + +void JsCodeEmitter::EmitInterfaceCorelibImports( + /* [in] */ StringBuilder& sb) +{ + bool includeList = false; + bool includeMap = false; + for (int i = 0; i < metaComponent_->typeNumber_; i++) { + MetaType* mt = metaComponent_->types_[i]; + switch (mt->kind_) { + case TypeKind::List: { + if (!includeList) { + sb.Append("import java.util.List;\n"); + includeList = true; + } + break; + } + case TypeKind::Map: { + if (!includeMap) { + sb.Append("import java.util.Map;\n"); + includeMap = true; + } + break; + } + default: + break; + } + } +} + +void JsCodeEmitter::EmitInterfaceDBinderImports( + /* [in] */ StringBuilder& sb) +{ + sb.Append("import ohos.rpc.IRemoteBroker;\n"); + sb.Append("import ohos.rpc.RemoteException;\n"); +} + +void JsCodeEmitter::EmitInterfaceSelfDefinedTypeImports( + /* [in] */ StringBuilder& sb) +{ + for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { + MetaSequenceable* mp = metaComponent_->sequenceables_[i]; + sb.AppendFormat("import %s%s;\n", mp->namespace_, mp->name_); + } + + for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { + MetaInterface* mi = metaComponent_->interfaces_[i]; + if (mi->external_) { + sb.AppendFormat("import %s%s;\n", mi->namespace_, mi->name_); + } + } +} + +void JsCodeEmitter::EmitInterfaceDefinition( + /* [in] */ StringBuilder& sb) +{ + sb.AppendFormat("public interface %s extends IRemoteBroker {\n", metaInterface_->name_); + EmitInterfaceMethods(sb, TAB); + sb.Append("};\n"); +} + +void JsCodeEmitter::EmitInterfaceMethods( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + if (metaInterface_->methodNumber_ > 0) { + sb.Append("\n"); + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + EmitInterfaceMethod(mm, sb, prefix); + if (i != metaInterface_->methodNumber_ - 1) { + sb.Append("\n"); + } + } + } +} + +void JsCodeEmitter::EmitInterfaceMethod( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; + if (mm->parameterNumber_ == 0) { + sb.Append(prefix).AppendFormat( + "%s %s() throws RemoteException;\n", EmitType(returnType).string(), MethodName(mm->name_).string()); + } else { + sb.Append(prefix).AppendFormat("%s %s(\n", EmitType(returnType).string(), MethodName(mm->name_).string()); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + EmitInterfaceMethodParameter(mp, sb, prefix + TAB); + if (i != mm->parameterNumber_ - 1) { + sb.Append(",\n"); + } + } + sb.Append(") throws RemoteException;\n"); + } +} + +void JsCodeEmitter::EmitInterfaceMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + std::string name = UnderlineAdded(mp->name_); + sb.AppendFormat("%s", name.c_str()); +} + +void JsCodeEmitter::EmitInterfaceProxy() +{ + String filePath = String::Format("%s/%s.js", directory_.string(), FileName(proxyName_).string()); + File file(filePath, File::WRITE); + + StringBuilder sb; + + EmitInterfaceImports(sb); + sb.Append("\n"); + EmitInterfaceStubConstants(sb); + sb.Append("\n"); + EmitJsCallBack(sb); + sb.Append("\n"); + EmitInterfaceProxyImpl(sb); + sb.Append("\n"); + + String data = sb.ToString(); + file.WriteData(data.string(), data.GetLength()); + file.Flush(); + file.Close(); +} + +void JsCodeEmitter::EmitInterfaceProxyImports( + /* [in] */ StringBuilder& sb) +{ + EmitInterfaceProxyCorelibImports(sb); + EmitInterfaceProxySelfDefinedTypeImports(sb); + EmitInterfaceProxyDBinderImports(sb); + EmitInterfaceProxyParametersImports(sb); +} + +void JsCodeEmitter::EmitInterfaceProxyCorelibImports( + /* [in] */ StringBuilder& sb) +{ + bool includeList = false; + bool includeMap = false; + for (int i = 0; i < metaComponent_->typeNumber_; i++) { + MetaType* mt = metaComponent_->types_[i]; + switch(mt->kind_) { + case TypeKind::List: { + if (!includeList) { + sb.Append("import java.util.List;\n"); + sb.Append("import java.util.ArrayList;\n"); + includeList = true; + } + break; + } + case TypeKind::Map: { + if (!includeMap) { + sb.Append("import java.util.Map;\n"); + sb.Append("import java.util.HashMap;\n"); + includeMap = true; + } + break; + } + default: + break; + } + } +} + +void JsCodeEmitter::EmitInterfaceProxySelfDefinedTypeImports( + /* [in] */ StringBuilder& sb) +{ + for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { + MetaSequenceable* mp = metaComponent_->sequenceables_[i]; + sb.AppendFormat("import %s%s;\n", mp->namespace_, mp->name_); + } + + for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { + MetaInterface* mi = metaComponent_->interfaces_[i]; + if (mi->external_) { + sb.AppendFormat("import %s%s;\n", mi->namespace_, mi->name_); + sb.AppendFormat("import %s%s;\n", mi->namespace_, StubName(String(mi->name_)).string()); + } + } +} + +void JsCodeEmitter::EmitInterfaceProxyDBinderImports( + /* [in] */ StringBuilder& sb) +{ + sb.Append("import ohos.rpc.IRemoteObject;\n"); + sb.Append("import ohos.rpc.RemoteException;\n"); + sb.Append("import ohos.rpc.MessageParcel;\n"); + sb.Append("import ohos.rpc.MessageOption;\n"); +} + +void JsCodeEmitter::EmitInterfaceProxyParametersImports( + /* [in] */ StringBuilder& sb) +{ + sb.Append("import ohos.system.version.SystemVersion;\n"); +} + +void JsCodeEmitter::EmitInterfaceProxyImpl( + /* [in] */ StringBuilder& sb) +{ + sb.AppendFormat("export default {\n", proxyName_.string(), interfaceName_.string()); + EmitInterfaceProxyMethodImpls(sb, TAB); + sb.Append("}\n"); +} + +void JsCodeEmitter::EmitInterfaceProxyConstants( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat( + "private static final String DESCRIPTOR = \"%s\";\n\n", interfaceFullName_.string()); + EmitInterfaceMethodCommands(sb); +} + +void JsCodeEmitter::EmitInterfaceProxyConstructor( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("public %s(\n", proxyName_.string()); + sb.Append(prefix + TAB).Append("/* [in] */ IRemoteObject remote) {\n"); + sb.Append(prefix + TAB).Append("this.remote = remote;\n"); + sb.Append(prefix).Append("}\n"); + sb.Append("\n"); + sb.Append(prefix).AppendFormat("@Override\n"); + sb.Append(prefix).Append("public IRemoteObject asObject() {\n"); + sb.Append(prefix + TAB).Append("return remote;\n"); + sb.Append(prefix).Append("}\n"); +} + +void JsCodeEmitter::EmitInterfaceProxyMethodImpls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + if (metaInterface_->methodNumber_ > 0) { + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + EmitInterfaceProxyMethodImpl(mm, sb, prefix); + if (i != metaInterface_->methodNumber_ - 1) { + sb.Append("\n"); + } + } + } +} + +void JsCodeEmitter::EmitInterfaceProxyMethodImpl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + if (mm->parameterNumber_ == 0) { + sb.Append(prefix).AppendFormat("%s() ", MethodName(mm->name_).string()); + } else { + sb.Append(prefix).AppendFormat("%s(", MethodName(mm->name_).string()); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + EmitInterfaceMethodParameter(mp, sb, prefix + TAB); + if (i != mm->parameterNumber_ - 1) { + sb.Append(", "); + } + } + sb.Append(") "); + } + EmitInterfaceProxyMethodBody(mm, sb, prefix); +} + +void JsCodeEmitter::EmitInterfaceProxyMethodBody( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append("{\n"); + sb.Append(prefix + TAB).AppendFormat("let option = new rpc.MessageOption();\n"); + sb.Append(prefix + TAB).Append("let data = new rpc.MessageParcel();\n"); + sb.Append(prefix + TAB).Append("let reply = new rpc.MessageParcel();\n"); + sb.Append("\n"); + + bool needBlankLine = false; + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + if ((mp->attributes_ & ATTR_IN) != 0) { + EmitWriteMethodParameter(mp, "data", sb, prefix + TAB); + needBlankLine = true; + } else if ((mp->attributes_ & ATTR_OUT) != 0) { + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + if (mt->kind_ == TypeKind::Array) { + std::string name = UnderlineAdded(mp->name_); + EmitWriteOutArrayVariable("data", name, mt, sb, prefix + TAB); + } + } + } + if (needBlankLine) { + sb.Append("\n"); + } + + if ((mm->properties_ & METHOD_PROPERTY_ONEWAY) == 0) { + sb.Append(prefix + TAB).AppendFormat("let ret = proxy.sendRequest(COMMAND_%s, data, reply, option)\n", + ConstantName(mm->name_).string()); + sb.Append(prefix + TAB + TAB).AppendFormat(".then(function (result) {\n"); + sb.Append(prefix + TAB + TAB).AppendFormat("if (result.errCode === 0) {\n"); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + if ((mp->attributes_ & ATTR_OUT) != 0) { + EmitReadMethodParameter(mp, "reply", sb, prefix + TAB + TAB); + } + } + MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; + if (returnType->kind_ != TypeKind::Void) { + EmitReadVariable("reply", "result", "msg", returnType, ATTR_IN, sb, prefix + TAB + TAB + TAB); + } else { + sb.Append(prefix + TAB + TAB + TAB).Append("console.log(\"void function call success\");\n"); + } + if (returnType->kind_ != TypeKind::Void) { + sb.Append(prefix + TAB + TAB + TAB).Append("console.log(\"reply msg: \" + msg);\n"); + } + sb.Append(prefix + TAB + TAB).AppendFormat("} else {\n"); + sb.Append(prefix + TAB + TAB + TAB).Append( + "console.log(\"sendRequest failed, errCode: \" + result.errCode);\n"); + sb.Append(prefix + TAB + TAB).AppendFormat("}\n"); + sb.Append(prefix + TAB).AppendFormat("}).catch(function (e) {\n"); + sb.Append(prefix + TAB + TAB).AppendFormat("console.log(\"sendRequest exception:\" + e);\n"); + sb.Append(prefix + TAB).AppendFormat("}).finally (() => {\n"); + sb.Append(prefix + TAB).AppendFormat("console.log(\"sendRequest ends, reclaim parcels\");\n"); + sb.Append(prefix + TAB + TAB).Append("data.reclaim();\n"); + sb.Append(prefix + TAB + TAB).Append("reply.reclaim();\n"); + sb.Append(prefix + TAB).AppendFormat("});\n"); + } else { + sb.Append(prefix + TAB).Append("try {\n"); + sb.Append(prefix + TAB + TAB).AppendFormat( + "let ret = proxy.sendRequest(COMMAND_%s, data, reply, option, %sCallback)\n", + ConstantName(mm->name_).string(), MethodName(mm->name_).string()); + sb.Append(prefix + TAB).Append("} catch(e) {\n"); + sb.Append(prefix + TAB + TAB).AppendFormat("console.log(\"sendRequest exception:\" + e);\n"); + sb.Append(prefix + TAB).AppendFormat("}\n"); + } + sb.Append(prefix).Append("},\n"); +} + +void JsCodeEmitter::EmitWriteMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ const String& parcelName, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + std::string name = UnderlineAdded(mp->name_); + EmitWriteVariable(parcelName, name, mt, sb, prefix); +} + +void JsCodeEmitter::EmitReadMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ const String& parcelName, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + std::string name = UnderlineAdded(mp->name_); + EmitReadOutVariable(parcelName, name, mt, sb, prefix); +} + +void JsCodeEmitter::EmitInterfaceStub() +{ + String filePath = String::Format("%s/%s.js", directory_.string(), FileName(stubName_).string()); + File file(filePath, File::WRITE); + + StringBuilder sb; + EmitInterfaceImports(sb); + sb.Append("\n"); + EmitInterfaceStubConstants(sb); + sb.Append("\n"); + EmitInterfaceStubImpl(sb); + sb.Append("\n"); + + String data = sb.ToString(); + file.WriteData(data.string(), data.GetLength()); + file.Flush(); + file.Close(); +} + +void JsCodeEmitter::EmitInterfaceStubImpl( + /* [in] */ StringBuilder& sb) +{ + sb.AppendFormat("class %s extends rpc.RemoteObject {\n", stubName_.string()); + EmitInterfaceStubConstructor(sb, TAB); + sb.Append("\n"); + EmitInterfaceStubMethodImpls(sb, TAB); + sb.Append("}\n"); +} + +void JsCodeEmitter::EmitInterfaceStubConstants(/* [in] */ StringBuilder& sb) +{ + EmitInterfaceMethodCommands(sb); +} + +void JsCodeEmitter::EmitJsCallBack(/* [in] */ StringBuilder& sb) +{ + if (metaInterface_->methodNumber_ > 0) { + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + if ((mm->properties_ & METHOD_PROPERTY_ONEWAY) == 1) { + sb.AppendFormat("function %sCallback(result) {\n", MethodName(mm->name_).string()); + sb.Append(TAB).AppendFormat("if (result.errCode === 0) {\n"); + + MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; + if (returnType->kind_ != TypeKind::Void) { + EmitReadVariable("reply", "msg", returnType, ATTR_IN, sb, String(TAB) + TAB + TAB); + } else { + sb.Append(String(TAB) + TAB + TAB).Append("console.log(\"void function call success\");\n"); + } + if (returnType->kind_ != TypeKind::Void) { + sb.Append(String(TAB) + TAB + TAB).Append("console.log(\"reply msg: \" + msg);\n"); + } + sb.Append(String(TAB)).AppendFormat("} else {\n"); + sb.Append(String(TAB) + TAB).Append( + "console.log(\"sendRequest failed, errCode: \" + result.errCode);\n"); + sb.Append(String(TAB)).AppendFormat("}\n"); + sb.Append(String(TAB)).AppendFormat("console.log(\"sendRequest ends, reclaim parcels\");\n"); + sb.Append(String(TAB)).Append("data.reclaim();\n"); + sb.Append(String(TAB)).Append("reply.reclaim();\n"); + sb.Append("}\n"); + } + if (i != metaInterface_->methodNumber_ - 1) { + sb.Append("\n"); + } + } + } +} + +void JsCodeEmitter::EmitInterfaceStubConstructor( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("constructor(des) {\n"); + sb.Append(prefix + TAB).Append("super(des);\n"); + sb.Append(prefix).Append("}\n"); +} + +void JsCodeEmitter::EmitInterfaceStubMethodImpls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).Append("onRemoteRequest(code, data, reply, option) {\n"); + sb.Append(prefix + TAB).Append("switch (code) {\n"); + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + EmitInterfaceStubMethodImpl(mm, sb, prefix + TAB + TAB); + } + sb.Append(prefix + TAB).Append(TAB).Append("default:\n"); + sb.Append(prefix + TAB).Append(TAB).Append(TAB).Append( + "return super.onRemoteRequest(code, data, reply, option);\n"); + sb.Append(prefix + TAB).Append("}\n"); + sb.Append(prefix).Append("}\n"); +} + +void JsCodeEmitter::EmitInterfaceStubMethodImpl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("case COMMAND_%s: {\n", ConstantName(mm->name_).string()); + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + if ((mp->attributes_ & ATTR_IN) != 0) { + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + EmitReadVariable("data", UnderlineAdded(mp->name_), mt, ATTR_IN, sb, prefix + TAB); + } else if ((mp->attributes_ & ATTR_OUT) != 0) { + EmitLocalVariable(mp, sb, prefix + TAB); + } + } + + MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; + if (mm->parameterNumber_ == 0) { + if (returnType->kind_ == TypeKind::Void) { + sb.Append(prefix + TAB).AppendFormat("%s();\n", mm->name_); + } else { + sb.Append(prefix + TAB).AppendFormat("let result = %s();\n", mm->name_); + } + } else { + if (returnType->kind_ == TypeKind::Void) { + sb.Append(prefix + TAB).AppendFormat("%s(", mm->name_); + } else { + sb.Append(prefix + TAB).AppendFormat("let result = %s(", mm->name_); + } + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + sb.Append(UnderlineAdded(mp->name_).c_str()); + if (i != mm->parameterNumber_ - 1) { + sb.Append(", "); + } + } + sb.AppendFormat(");\n", mm->name_); + } + + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + if ((mp->attributes_ & ATTR_OUT) != 0) { + EmitWriteMethodParameter(mp, "reply", sb, prefix + TAB); + } + } + if (returnType->kind_ != TypeKind::Void) { + EmitWriteVariable("reply", "result", returnType, sb, prefix + TAB); + } + sb.Append(prefix + TAB).Append("return true;\n"); + sb.Append(prefix).Append("}\n"); +} + +void JsCodeEmitter::EmitInterfaceMethodCommands(/* [in] */ StringBuilder& sb) +{ + for (int i = 0; i < metaInterface_->methodNumber_; i++) { + MetaMethod* mm = metaInterface_->methods_[i]; + sb.AppendFormat("const COMMAND_%s = %d;\n", ConstantName(mm->name_).string(), i); + } +} + +void JsCodeEmitter::EmitLicense( + /* [in] */ StringBuilder& sb) +{ + sb.Append(metaInterface_->license_).Append("\n"); +} + +void JsCodeEmitter::EmitPackage( + /* [in] */ StringBuilder& sb) +{ + String package = metaInterface_->namespace_; + int index = package.LastIndexOf('.'); + sb.AppendFormat("package %s;\n", index != -1 ? package.Substring(0, index).string() : package.string()); +} + +void JsCodeEmitter::EmitWriteVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + switch (mt->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("%s.writeInt(%s ? 1 : 0);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Char: + case TypeKind::Byte: + case TypeKind::Short: + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("%s.writeInt(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("%s.writeLong(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("%s.writeFloat(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("%s.writeDouble(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("%s.writeString(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Sequenceable: + if (EmitType(mt).Equals("IRemoteObject")) { + sb.Append(prefix).AppendFormat("%s.writeRemoteObject(%s);\n", parcelName.string(), name.c_str()); + break; + } + sb.Append(prefix).AppendFormat("%s.writeSequenceable(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Interface: + sb.Append(prefix).AppendFormat("%s.writeRemoteObject(%s.asObject());\n", parcelName.string(), + name.c_str()); + break; + case TypeKind::List: { + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + sb.Append(prefix).AppendFormat("%s.writeInt(%s.size());\n", parcelName.string(), name.c_str()); + sb.Append(prefix).AppendFormat("for (%s element : %s) {\n", + EmitType(innerType).string(), name.c_str()); + EmitWriteVariable(parcelName, "element", innerType, sb, prefix + TAB); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Map: { + MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; + sb.Append(prefix).AppendFormat("%s.writeInt(%s.size());\n", parcelName.string(), name.c_str()); + sb.Append(prefix).AppendFormat("for (Map.Entry<%s, %s> entry : %s.entrySet()) {\n", + EmitType(keyType).string(), EmitType(valueType).string(), name.c_str()); + EmitWriteVariable(parcelName, "entry.getKey()", keyType, sb, prefix + TAB); + EmitWriteVariable(parcelName, "entry.getValue()", valueType, sb, prefix + TAB); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Array: { + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + sb.Append(prefix).AppendFormat("if (%s == null) {\n", name.c_str()); + sb.Append(prefix).AppendFormat(" %s.writeInt(-1);\n", parcelName.string()); + sb.Append(prefix).Append("} else { \n"); + EmitWriteArrayVariable(parcelName, name, innerType, sb, prefix + TAB); + sb.Append(prefix).Append("}\n"); + break; + } + default: + break; + } +} + +void JsCodeEmitter::EmitWriteArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + switch (mt->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("%s.writeBooleanArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Char: + sb.Append(prefix).AppendFormat("%s.writeCharArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Byte: + sb.Append(prefix).AppendFormat("%s.writeByteArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Short: + sb.Append(prefix).AppendFormat("%s.writeShortArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("%s.writeIntArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("%s.writeLongArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("%s.writeFloatArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("%s.writeDoubleArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("%s.writeStringArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Sequenceable: + sb.Append(prefix).AppendFormat("%s.writeSequenceableArray(%s);\n", parcelName.string(), name.c_str()); + break; + default: + break; + } +} + +void JsCodeEmitter::EmitWriteOutArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).AppendFormat("if (%s == null) {\n", name.c_str()); + sb.Append(prefix).AppendFormat(" %s.writeInt(-1);\n", parcelName.string()); + sb.Append(prefix).Append("} else {\n"); + sb.Append(prefix).AppendFormat(" %s.writeInt(%s.length);\n", parcelName.string(), name.c_str()); + sb.Append(prefix).Append("}\n"); +} + +void JsCodeEmitter::EmitReadVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ unsigned int attributes, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + switch (mt->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("let %s = %s.readInt() == 1 ? true : false;\n", name.c_str(), + parcelName.string()); + break; + case TypeKind::Char: + case TypeKind::Byte: + case TypeKind::Short: + sb.Append(prefix).AppendFormat("let %s = %s.readInt();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("let %s = %s.readInt();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("let %s = %s.readLong();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("let %s = %s.readFloat();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("let %s = %s.readDouble();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("let %s = %s.readString();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Sequenceable: + if ((attributes & ATTR_OUT) == 0 && EmitType(mt).Equals("IRemoteObject")) { + sb.Append(prefix).AppendFormat("IRemoteObject %s = %s.readRemoteObject();\n", + name.c_str(), parcelName.string()); + break; + } + if ((attributes & ATTR_OUT) == 0) { + sb.Append(prefix).AppendFormat("%s %s = new %s();\n", + EmitType(mt).string(), name.c_str(), EmitType(mt).string()); + } + sb.Append(prefix).AppendFormat("%s.readSequenceable(%s);\n", parcelName.string(), name.c_str()); + + break; + case TypeKind::Interface: + sb.Append(prefix).AppendFormat("let %s = %s.asInterface(%s.readRemoteObject());\n", name.c_str(), + StubName(EmitType(mt)).string(), parcelName.string()); + break; + case TypeKind::List: { + sb.Append(prefix).AppendFormat("let %s = new Array%s();\n", name.c_str(), EmitType(mt).string()); + sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s.add(value);\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Map: { + sb.Append(prefix).AppendFormat("let %s = new Hash%s();\n", name.c_str(), EmitType(mt).string()); + sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); + MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; + EmitReadVariable(parcelName, "key", keyType, ATTR_IN, sb, prefix + TAB); + EmitReadVariable(parcelName, "value", valueType, ATTR_IN, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s.put(key, value);\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Array: { + if ((attributes & ATTR_MASK) == ATTR_OUT) { + EmitReadOutArrayVariable(parcelName, name, mt, sb, prefix); + } else { + EmitReadArrayVariable(parcelName, name, mt, attributes, sb, prefix); + } + break; + } + default: + break; + } +} + +void JsCodeEmitter::EmitReadVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& returnName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ unsigned int attributes, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + switch (mt->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("let %s = %s.%s.readInt() == 1 ? true : false;\n", name.c_str(), + returnName.c_str(), parcelName.string()); + break; + case TypeKind::Char: + case TypeKind::Byte: + case TypeKind::Short: + sb.Append(prefix).AppendFormat("let %s = %s.%s.readInt();\n", name.c_str(), returnName.c_str(), + parcelName.string()); + break; + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("let %s = %s.%s.readInt();\n", name.c_str(), returnName.c_str(), + parcelName.string()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("let %s = %s.%s.readLong();\n", name.c_str(), returnName.c_str(), + parcelName.string()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("let %s = %s.%s.readFloat();\n", name.c_str(), returnName.c_str(), + parcelName.string()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("let %s = %s.%s.readDouble();\n", name.c_str(), returnName.c_str(), + parcelName.string()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("let %s = %s.%s.readString();\n", name.c_str(), returnName.c_str(), + parcelName.string()); + break; + case TypeKind::Sequenceable: + if ((attributes & ATTR_OUT) == 0 && EmitType(mt).Equals("IRemoteObject")) { + sb.Append(prefix).AppendFormat("IRemoteObject %s = %s.%s.readRemoteObject();\n", + name.c_str(), parcelName.string()); + break; + } + if ((attributes & ATTR_OUT) == 0) { + sb.Append(prefix).AppendFormat("%s %s = new %s();\n", + EmitType(mt).string(), name.c_str(), EmitType(mt).string()); + } + sb.Append(prefix).AppendFormat("%s.readSequenceable(%s);\n", parcelName.string(), name.c_str()); + + break; + case TypeKind::Interface: + sb.Append(prefix).AppendFormat("let %s = %s.%s.asInterface(%s.readRemoteObject());\n", name.c_str(), + StubName(EmitType(mt)).string(), parcelName.string()); + break; + case TypeKind::List: { + sb.Append(prefix).AppendFormat("let %s = new Array%s();\n", name.c_str(), EmitType(mt).string()); + sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s.add(value);\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Map: { + sb.Append(prefix).AppendFormat("let %s = new Hash%s();\n", name.c_str(), EmitType(mt).string()); + sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); + MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; + EmitReadVariable(parcelName, "key", keyType, ATTR_IN, sb, prefix + TAB); + EmitReadVariable(parcelName, "value", valueType, ATTR_IN, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s.put(key, value);\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Array: { + if ((attributes & ATTR_MASK) == ATTR_OUT) { + EmitReadOutArrayVariable(parcelName, name, mt, sb, prefix); + } else { + EmitReadArrayVariable(parcelName, name, mt, attributes, sb, prefix); + } + break; + } + default: + break; + } +} + +void JsCodeEmitter::EmitReadArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ unsigned int attributes, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + switch (innerType->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("let %s = %s.readBooleanArray();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Char: + sb.Append(prefix).AppendFormat("let %s = %s.readCharArray();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Byte: + sb.Append(prefix).AppendFormat("let %s = %s.readByteArray();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Short: + sb.Append(prefix).AppendFormat("let %s = %s.readShortArray();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("let %s = %s.readIntArray();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("let %s = %s.readLongArray();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("let %s = %s.readFloatArray();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("let %s = %s.readDoubleArray();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("let %s = %s.readStringArray();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Sequenceable: + sb.Append(prefix).AppendFormat("int size = %s.readInt();\n", parcelName.string()); + sb.Append(prefix).AppendFormat("%s %s = new %s[size];\n", + EmitType(mt).string(), name.c_str(), EmitType(innerType).string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < size; ++i) {\n"); + EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s[i] = value;\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + default: + break; + } +} + +void JsCodeEmitter::EmitReadOutArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + switch (innerType->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("%s.readBooleanArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Char: + sb.Append(prefix).AppendFormat("%s.readCharArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Byte: + sb.Append(prefix).AppendFormat("%s.readByteArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Short: + sb.Append(prefix).AppendFormat("%s.readShortArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("%s.readIntArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("%s.readLongArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("%s.readFloatArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("%s.readDoubleArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("%s.readStringArray(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Sequenceable: + sb.Append(prefix).AppendFormat("%s.readSequenceableArray(%s);\n", parcelName.string(), name.c_str()); + break; + default: + break; + } +} + +void JsCodeEmitter::EmitReadOutVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + switch (mt->kind_) { + case TypeKind::Boolean: + sb.Append(prefix).AppendFormat("%s = %s.readInt() == 1 ? true : false;\n", + name.c_str(), parcelName.string()); + break; + case TypeKind::Char: + case TypeKind::Byte: + case TypeKind::Short: + sb.Append(prefix).AppendFormat("%s = (%s)%s.readInt();\n", + name.c_str(), EmitType(mt).string(), parcelName.string()); + break; + case TypeKind::Integer: + sb.Append(prefix).AppendFormat("%s = %s.readInt();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Long: + sb.Append(prefix).AppendFormat("%s = %s.readLong();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Float: + sb.Append(prefix).AppendFormat("%s = %s.readFloat();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Double: + sb.Append(prefix).AppendFormat("%s = %s.readDouble();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::String: + sb.Append(prefix).AppendFormat("%s = %s.readString();\n", name.c_str(), parcelName.string()); + break; + case TypeKind::Sequenceable: + if (EmitType(mt).Equals("IRemoteObject")) { + sb.Append(prefix).AppendFormat("%s = %s.readRemoteObject();\n", name.c_str(), parcelName.string()); + break; + } + sb.Append(prefix).AppendFormat("%s.readSequenceable(%s);\n", parcelName.string(), name.c_str()); + break; + case TypeKind::Interface: + sb.Append(prefix).AppendFormat("%s = %s.asInterface(%s.readRemoteObject());\n", name.c_str(), + StubName(EmitType(mt)).string(), parcelName.string()); + break; + case TypeKind::List: { + sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); + MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s.add(value);\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Map: { + sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); + sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); + MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; + EmitReadVariable(parcelName, "key", keyType, ATTR_IN, sb, prefix + TAB); + EmitReadVariable(parcelName, "value", valueType, ATTR_IN, sb, prefix + TAB); + sb.Append(prefix + TAB).AppendFormat("%s.put(key, value);\n", name.c_str()); + sb.Append(prefix).Append("}\n"); + break; + } + case TypeKind::Array: { + EmitReadOutArrayVariable(parcelName, name, mt, sb, prefix); + break; + } + default: + break; + } +} + +void JsCodeEmitter::EmitLocalVariable( + /* [in] */ MetaParameter* mp, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix) +{ + MetaType* mt = metaComponent_->types_[mp->typeIndex_]; + std::string name = UnderlineAdded(mp->name_); + if (mt->kind_ == TypeKind::Sequenceable) { + sb.Append(prefix).AppendFormat("let %s = new %s();\n", name.c_str(), EmitType(mt).string()); + } else if (mt->kind_ == TypeKind::List) { + sb.Append(prefix).AppendFormat("let %s = new Array%s();\n", name.c_str(), EmitType(mt).string()); + } else if (mt->kind_ == TypeKind::Map) { + sb.Append(prefix).AppendFormat("let %s = new Hash%s();\n", name.c_str(), EmitType(mt).string()); + } else { + sb.Append(prefix).AppendFormat("let %s;\n", name.c_str()); + } +} + +String JsCodeEmitter::EmitType( + /* [in] */ MetaType* mt) +{ + switch(mt->kind_) { + case TypeKind::Char: + return "char"; + case TypeKind::Boolean: + return "boolean"; + case TypeKind::Byte: + return "byte"; + case TypeKind::Short: + return "short"; + case TypeKind::Integer: + return "int"; + case TypeKind::Long: + return "long"; + case TypeKind::Float: + return "float"; + case TypeKind::Double: + return "double"; + case TypeKind::String: + return "String"; + case TypeKind::Void: + return "void"; + case TypeKind::Sequenceable: { + MetaSequenceable* mp = metaComponent_->sequenceables_[mt->index_]; + return mp->name_; + } + case TypeKind::Interface: { + MetaInterface* mi = metaComponent_->interfaces_[mt->index_]; + return mi->name_; + } + case TypeKind::List: { + MetaType* elementType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + return String::Format("List<%s>", EmitType(elementType).string()); + } + case TypeKind::Map: { + MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; + return String::Format("Map<%s, %s>", EmitType(keyType).string(), EmitType(valueType).string()); + } + case TypeKind::Array: { + MetaType* elementType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + return String::Format("%s[]", EmitType(elementType).string()); + } + default: + return "unknown type"; + } +} + +String JsCodeEmitter::FileName( + /* [in] */ const String& name) +{ + if (name.IsEmpty()) { + return name; + } + + return name.Replace('.', '/'); +} + +String JsCodeEmitter::MethodName( + /* [in] */ const String& name) +{ + if (name.IsEmpty() || islower(name[0])) { + return name; + } + return String::Format("%c%s", tolower(name[0]), name.Substring(1).string()); +} + +String JsCodeEmitter::ConstantName( + /* [in] */ const String& name) +{ + if (name.IsEmpty()) { + return name; + } + + StringBuilder sb; + + for (int i = 0; i < name.GetLength(); i++) { + char c = name[i]; + if (isupper(c) != 0) { + if (i > 1) { + sb.Append('_'); + } + sb.Append(c); + } else { + sb.Append(toupper(c)); + } + } + + return sb.ToString(); +} + +String JsCodeEmitter::StubName( + /* [in] */ const String& name) +{ + return name.StartsWith("I") ? (name.Substring(1) + "Stub") : (name + "Stub"); +} + +const std::string JsCodeEmitter::UnderlineAdded(const String& originName) +{ + std::string underline("_"); + return underline + std::string(originName.string()); +} + +} +} diff --git a/zidl/codegen/js_code_emitter.h b/zidl/codegen/js_code_emitter.h new file mode 100644 index 00000000000..ad822f91448 --- /dev/null +++ b/zidl/codegen/js_code_emitter.h @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_JSCODEEMITTER_H +#define OHOS_ZIDL_JSCODEEMITTER_H + +#include + +#include "codegen/code_emitter.h" +#include "util/string_builder.h" + +namespace OHOS { +namespace Zidl { + +class JsCodeEmitter : public CodeEmitter { +public: + JsCodeEmitter( + /* [in] */ MetaComponent* mc) + : CodeEmitter(mc) + {} + + void EmitInterface() override; + + void EmitInterfaceProxy() override; + + void EmitInterfaceStub() override; + +private: + void EmitInterfaceImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceCorelibImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceDBinderImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceSelfDefinedTypeImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceDefinition( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceMethods( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceMethod( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceProxyCorelibImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceProxySelfDefinedTypeImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceProxyDBinderImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceProxyParametersImports( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceProxyImpl( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceProxyConstants( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyConstructor( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyMethodImpls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyMethodImpl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceProxyMethodBody( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitWriteMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ const String& parcelName, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReadMethodParameter( + /* [in] */ MetaParameter* mp, + /* [in] */ const String& parcelName, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceStubImpl( + /* [in] */ StringBuilder& sb); + + void EmitInterfaceStubConstants(/* [in] */ StringBuilder& sb); + + void EmitJsCallBack(/* [in] */ StringBuilder& sb); + + void EmitInterfaceStubConstructor( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceStubMethodImpls( + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceStubMethodImpl( + /* [in] */ MetaMethod* mm, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitInterfaceMethodCommands(/* [in] */ StringBuilder& sb); + + void EmitLicense( + /* [in] */ StringBuilder& sb); + + void EmitPackage( + /* [in] */ StringBuilder& sb); + + void EmitWriteVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReadVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ unsigned int attributes, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReadVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& returnName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ unsigned int attributes, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReadOutVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReadArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ unsigned int attributes, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitWriteArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitWriteOutArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitReadOutArrayVariable( + /* [in] */ const String& parcelName, + /* [in] */ const std::string& name, + /* [in] */ MetaType* mt, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + void EmitLocalVariable( + /* [in] */ MetaParameter* mp, + /* [in] */ StringBuilder& sb, + /* [in] */ const String& prefix); + + String EmitType( + /* [in] */ MetaType* mt); + + String FileName( + /* [in] */ const String& name); + + String MethodName( + /* [in] */ const String& name); + + String ConstantName( + /* [in] */ const String& name); + + String StubName( + /* [in] */ const String& name); + + const std::string UnderlineAdded(const String& name); +}; + +} +} + +#endif // OHOS_ZIDL_JSCODEEMITTER_H diff --git a/zidl/main.cpp b/zidl/main.cpp new file mode 100644 index 00000000000..c0e314a6ce9 --- /dev/null +++ b/zidl/main.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "codegen/code_generator.h" +#include "metadata/metadata_builder.h" +#include "metadata/metadata_dumper.h" +#include "metadata/metadata_reader.h" +#include "metadata/metadata_serializer.h" +#include "parser/parser.h" +#include "util/logger.h" +#include "util/options.h" + +using namespace OHOS::Zidl; + +static const char* TAG = "zidl"; + +int main(int argc, char** argv) +{ + Options options(argc, argv); + + if (options.DoShowUsage()) { + options.ShowUsage(); + return 0; + } + + if (options.DoShowVersion()) { + options.ShowVersion(); + return 0; + } + + if (options.HasErrors()) { + options.ShowErrors(); + return 0; + } + + std::shared_ptr metadata; + + if (options.DoCompile()) { + Parser parser(options); + if (!parser.Parse(options.GetSourceFile())) { + Logger::E(TAG, "Parsing .zidl failed."); + return -1; + } + + MetadataBuilder builder(parser.GetModule()); + metadata = builder.Build(); + if (metadata == nullptr) { + Logger::E(TAG, "Generate metadata failed."); + return -1; + } + } + + if (options.DoDumpMetadata()) { + MetadataDumper dumper(metadata.get()); + dumper.Dump(""); + } + + if (options.DoSaveMetadata()) { + File metadataFile(options.GetMetadataFile(), File::WRITE); + if (!metadataFile.IsValid()) { + Logger::E(TAG, "Create metadata file failed."); + return -1; + } + + MetadataSerializer serializer(metadata.get()); + serializer.Serialize(); + uintptr_t data = serializer.GetData(); + int size = serializer.GetDataSize(); + + metadataFile.WriteData(reinterpret_cast(data), size); + metadataFile.Flush(); + metadataFile.Close(); + } + + if (options.DoGenerateCode()) { + if (metadata == nullptr) { + String metadataFile = options.GetMetadataFile(); + metadata = MetadataReader::ReadMetadataFromFile(metadataFile); + if (metadata == nullptr) { + Logger::E(TAG, "Get metadata from \"%s\" failed.", metadataFile.string()); + return -1; + } + } + + CodeGenerator codeGen(metadata.get(), options.GetTargetLanguage(), + options.GetGenerationDirectory()); + if (!codeGen.Generate()) { + Logger::E(TAG, "Generate \"%s\" codes failed.", options.GetTargetLanguage().string()); + return -1; + } + } + + return 0; +} diff --git a/zidl/metadata/CMakeLists.txt b/zidl/metadata/CMakeLists.txt new file mode 100644 index 00000000000..448c9d75914 --- /dev/null +++ b/zidl/metadata/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_directories( + ${ZIDL_DIR}) + +set(SOURCES + metadata_builder.cpp + metadata_dumper.cpp + metadata_reader.cpp + metadata_serializer.cpp) + +add_library(metadata STATIC + ${SOURCES}) \ No newline at end of file diff --git a/zidl/metadata/metadata.h b/zidl/metadata/metadata.h new file mode 100644 index 00000000000..0b405f06e4c --- /dev/null +++ b/zidl/metadata/metadata.h @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_METADATA_H +#define OHOS_ZIDL_METADATA_H + +namespace OHOS { +namespace Zidl { + +static constexpr int METADATA_MAGIC_NUMBER = 0x1DF02ED1; + +enum class TypeKind { + Unknown = 0, + Char = 1, + Boolean = 2, + Byte = 3, + Short = 4, + Integer = 5, + Long = 6, + Float = 7, + Double = 8, + String = 9, + Void = 10, + Sequenceable = 11, + Interface = 12, + List = 13, + Map = 14, + Array = 15, +}; + +struct MetaNamespace; +struct MetaSequenceable; +struct MetaInterface; +struct MetaMethod; +struct MetaParameter; +struct MetaType; + +struct MetaComponent { + int magic_; + int size_; + char* name_; + int namespaceNumber_; + int sequenceableNumber_; + int interfaceNumber_; + int typeNumber_; + MetaNamespace** namespaces_; + MetaSequenceable** sequenceables_; + MetaInterface** interfaces_; + MetaType** types_; + int stringPoolSize_; + char* stringPool_; +}; + +struct MetaNamespace { + char* name_; + int sequenceableNumber_; + int interfaceNumber_; + int namespaceNumber_; + int* sequenceableIndexes_; + int* interfaceIndexes_; + MetaNamespace** namespaces_; +}; + +struct MetaSequenceable { + char* name_; + char* namespace_; +}; + +static constexpr unsigned int INTERFACE_PROPERTY_ONEWAY = 0x1; + +struct MetaInterface { + char* license_; + char* name_; + char* namespace_; + unsigned int properties_; + int methodNumber_; + MetaMethod** methods_; + bool external_; +}; + +static constexpr unsigned int METHOD_PROPERTY_ONEWAY = 0x1; + +struct MetaMethod { + char* name_; + char* signature_; + unsigned int properties_; + int returnTypeIndex_; + int parameterNumber_; + MetaParameter** parameters_; +}; + +static constexpr unsigned int ATTR_IN = 0x1; +static constexpr unsigned int ATTR_OUT = 0x2; +static constexpr unsigned int ATTR_MASK = 0x3; + +struct MetaParameter { + char* name_; + unsigned int attributes_; + int typeIndex_; +}; + +struct MetaType { + TypeKind kind_; + int index_; + int nestedTypeNumber_; + int* nestedTypeIndexes_; +}; + +} +} + +#endif // OHOS_ZIDL_METADATA_H diff --git a/zidl/metadata/metadata_builder.cpp b/zidl/metadata/metadata_builder.cpp new file mode 100644 index 00000000000..6ba08529d4f --- /dev/null +++ b/zidl/metadata/metadata_builder.cpp @@ -0,0 +1,502 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "metadata/metadata_builder.h" +#include +#include "securec.h" +#include "ast/ast_array_type.h" +#include "ast/ast_list_type.h" +#include "ast/ast_map_type.h" +#include "util/logger.h" + +#define ALIGN8(v) (((v) + 7) & ~7) + +namespace OHOS { +namespace Zidl { + +const char* MetadataBuilder::TAG = "MetadataBuilder"; + +std::shared_ptr MetadataBuilder::Build() +{ + if (!module_->IsValid()) { + Logger::E(TAG, "The module is not validate."); + return nullptr; + } + + size_ = CalculateMetadataSize(); + void* metadata = calloc(size_, 1); + if (metadata == nullptr) { + Logger::E(TAG, "Out of memory."); + return nullptr; + } + + metaComponent_.reset( + new(metadata) MetaComponent, + [](MetaComponent* p){ free(p); }); + + WriteMetadata(reinterpret_cast(metadata)); + + return metaComponent_; +} + +size_t MetadataBuilder::CalculateMetadataSize() +{ + baseAddr_ = 0; + CalculateMetaComponent(module_); + return baseAddr_; +} + +void MetadataBuilder::CalculateMetaComponent( + /* [in] */ ASTModule* module) +{ + int namespaceNumber = module->GetNamespaceNumber(); + int sequenceableNumber = module->GetSequenceableNumber(); + int interfaceNumber = module->GetInterfaceNumber(); + int typeNumber = module->GetTypeNumber(); + + // begin address + baseAddr_ = ALIGN8(baseAddr_); + stringPool_.Add(module_->GetName()); + // namespaces_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaComponent)); + // sequenceables_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaNamespace*) * namespaceNumber); + // interfaces_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaSequenceable*) * sequenceableNumber); + // types_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaInterface*) * interfaceNumber); + // stringPool_'s address + baseAddr_ = baseAddr_ + sizeof(MetaType*) * typeNumber; + + for (int i = 0; i < namespaceNumber; i++) { + CalculateMetaNamespace(module->GetNamespace(i)); + } + + for (int i = 0; i < sequenceableNumber; i++) { + CalculateMetaSequenceable(module->GetSequenceable(i)); + } + + for (int i = 0; i < interfaceNumber; i++) { + CalculateMetaInterface(module->GetInterface(i)); + } + + const ASTModule::TypeStringMap& types = module_->GetTypes(); + for (const auto& pair : types) { + CalculateMetaType(pair.second); + } + + // end address + CalculateStringPool(); +} + +void MetadataBuilder::CalculateMetaNamespace( + /* [in] */ ASTNamespace* nspace) +{ + int sequenceableNumber = nspace->GetSequenceableNumber(); + int interfaceNumber = nspace->GetInterfaceNumber(); + int namespaceNumber = nspace->GetNamespaceNumber(); + + // begin address + baseAddr_ = ALIGN8(baseAddr_); + stringPool_.Add(nspace->GetName()); + // sequenceables_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaNamespace)); + // interfaces_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(int) * sequenceableNumber); + // namespaces_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(int) * interfaceNumber); + // end address + baseAddr_ = baseAddr_ + sizeof(MetaNamespace*) * namespaceNumber; + + for (int i = 0; i < namespaceNumber; i++) { + CalculateMetaNamespace(nspace->GetNamespace(i)); + } +} + +void MetadataBuilder::CalculateMetaSequenceable( + /* [in] */ ASTSequenceableType* sequenceable) +{ + // begin address + baseAddr_ = ALIGN8(baseAddr_); + stringPool_.Add(sequenceable->GetName()); + stringPool_.Add(sequenceable->GetNamespace()->ToString()); + // end address + baseAddr_ = baseAddr_ + sizeof(MetaSequenceable); +} + +void MetadataBuilder::CalculateMetaInterface( + /* [in] */ ASTInterfaceType* interface) +{ + int methodNumber = interface->GetMethodNumber(); + + // begin address + baseAddr_ = ALIGN8(baseAddr_); + stringPool_.Add(interface->GetLicense()); + stringPool_.Add(interface->GetName()); + stringPool_.Add(interface->GetNamespace()->ToString()); + // methods_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaInterface)); + // end address + baseAddr_ = baseAddr_ + sizeof(MetaMethod*) * methodNumber; + + for (int i = 0; i < methodNumber; i++) { + CalculateMetaMethod(interface->GetMethod(i)); + } +} + +void MetadataBuilder::CalculateMetaMethod( + /* [in] */ ASTMethod* method) +{ + int parameterNumber = method->GetParameterNumber(); + + // begin address + baseAddr_ = ALIGN8(baseAddr_); + stringPool_.Add(method->GetName()); + stringPool_.Add(method->GetSignature()); + // parameters_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaMethod)); + // end address + baseAddr_ = baseAddr_ + sizeof(MetaParameter*) * parameterNumber; + + for (int i = 0; i < parameterNumber; i++) { + CalculateMetaParameter(method->GetParameter(i)); + } +} + +void MetadataBuilder::CalculateMetaParameter( + /* [in] */ ASTParameter* parameter) +{ + // begin address + baseAddr_ = ALIGN8(baseAddr_); + stringPool_.Add(parameter->GetName()); + // end address + baseAddr_ = baseAddr_ + sizeof(MetaParameter); +} + +void MetadataBuilder::CalculateMetaType( + /* [in] */ ASTType* type) +{ + // begin address + baseAddr_ = ALIGN8(baseAddr_); + // nestedTypeIndexes_'s address + baseAddr_ = baseAddr_ + sizeof(MetaType); + if (type->IsListType()) { + baseAddr_ = ALIGN8(baseAddr_); + // end address + baseAddr_ = baseAddr_ + sizeof(int*); + } else if (type->IsMapType()) { + // end address + baseAddr_ = baseAddr_ + sizeof(int*) * 2; + } +} + +void MetadataBuilder::CalculateStringPool() +{ + // begin address + baseAddr_ = ALIGN8(baseAddr_); + // end address + baseAddr_ = baseAddr_ + stringPool_.GetSize(); +} + +void MetadataBuilder::WriteMetadata( + /* [in] */ uintptr_t base) +{ + baseAddr_ = base; + WriteMetaComponent(module_); +} + +void MetadataBuilder::WriteMetaComponent( + /* [in] */ ASTModule* module) +{ + int namespaceNumber = module->GetNamespaceNumber(); + int sequenceableNumber = module->GetSequenceableNumber(); + int interfaceNumber = module->GetInterfaceNumber(); + int typeNumber = module->GetTypeNumber(); + + // begin address + baseAddr_ = ALIGN8(baseAddr_); + MetaComponent* mc = reinterpret_cast(baseAddr_); + mc->magic_ = METADATA_MAGIC_NUMBER; + mc->size_ = size_; + mc->namespaceNumber_ = namespaceNumber; + mc->sequenceableNumber_ = sequenceableNumber; + mc->interfaceNumber_ = interfaceNumber; + mc->typeNumber_ = typeNumber; + mc->stringPoolSize_ = stringPool_.GetSize(); + // namespaces_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaComponent)); + mc->namespaces_ = reinterpret_cast(baseAddr_); + // sequenceables_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaNamespace*) * namespaceNumber); + mc->sequenceables_ = reinterpret_cast(baseAddr_); + // interfaces_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaSequenceable*) * sequenceableNumber); + mc->interfaces_ = reinterpret_cast(baseAddr_); + // types_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaInterface*) * interfaceNumber); + mc->types_ = reinterpret_cast(baseAddr_); + // stringPool_'s address + baseAddr_ = baseAddr_ + sizeof(MetaType*) * typeNumber; + mc->stringPool_ = reinterpret_cast(baseAddr_); + // end address + baseAddr_ = baseAddr_ + stringPool_.GetSize(); + (void)memcpy_s(mc->stringPool_, stringPool_.GetSize(), stringPool_.GetData(), stringPool_.GetSize()); + + mc->name_ = WriteString(module->GetName()); + + for (int i = 0; i < namespaceNumber; i++) { + mc->namespaces_[i] = WriteMetaNamespace(module->GetNamespace(i)); + } + + for (int i = 0; i < sequenceableNumber; i++) { + mc->sequenceables_[i] = WriteMetaSequenceable(module->GetSequenceable(i)); + } + + for (int i = 0; i < interfaceNumber; i++) { + mc->interfaces_[i] = WriteMetaInterface(module->GetInterface(i)); + } + + const ASTModule::TypeStringMap& types = module->GetTypes(); + int i = 0; + for (const auto& pair : types) { + mc->types_[i++] = WriteMetaType(pair.second); + } +} + +MetaNamespace* MetadataBuilder::WriteMetaNamespace( + /* [in] */ ASTNamespace* nspace) +{ + int sequenceableNumber = nspace->GetSequenceableNumber(); + int interfaceNumber = nspace->GetInterfaceNumber(); + int namespaceNumber = nspace->GetNamespaceNumber(); + + // begin address + baseAddr_ = ALIGN8(baseAddr_); + MetaNamespace* mn = reinterpret_cast(baseAddr_); + mn->name_ = WriteString(nspace->GetName()); + mn->sequenceableNumber_ = sequenceableNumber; + mn->interfaceNumber_ = interfaceNumber; + mn->namespaceNumber_ = namespaceNumber; + // sequenceables_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaNamespace)); + mn->sequenceableIndexes_ = reinterpret_cast(baseAddr_); + // interfaces_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(int) * sequenceableNumber); + mn->interfaceIndexes_ = reinterpret_cast(baseAddr_); + // namespaces_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(int) * interfaceNumber); + mn->namespaces_ = reinterpret_cast(baseAddr_); + // end address + baseAddr_ = baseAddr_ + sizeof(MetaNamespace*) * namespaceNumber; + + for (int i = 0; i < sequenceableNumber; i++) { + AutoPtr sequenceable = nspace->GetSequenceable(i); + mn->sequenceableIndexes_[i] = module_->IndexOf(sequenceable); + } + + for (int i = 0; i < interfaceNumber; i++) { + AutoPtr interface = nspace->GetInterface(i); + mn->interfaceIndexes_[i] = module_->IndexOf(interface); + } + + for (int i = 0; i < namespaceNumber; i++) { + AutoPtr inner = nspace->GetNamespace(i); + mn->namespaces_[i] = WriteMetaNamespace(inner); + } + + return mn; +} + +MetaSequenceable* MetadataBuilder::WriteMetaSequenceable( + /* [in] */ ASTSequenceableType* parcelabe) +{ + // begin address + baseAddr_ = ALIGN8(baseAddr_); + MetaSequenceable* mp = reinterpret_cast(baseAddr_); + mp->name_ = WriteString(parcelabe->GetName()); + mp->namespace_ = WriteString(parcelabe->GetNamespace()->ToString()); + // end address + baseAddr_ = baseAddr_ + sizeof(MetaSequenceable); + + return mp; +} + +MetaInterface* MetadataBuilder::WriteMetaInterface( + /* [in] */ ASTInterfaceType* interface) +{ + int methodNumber = interface->GetMethodNumber(); + + // begin address + baseAddr_ = ALIGN8(baseAddr_); + MetaInterface* mi = reinterpret_cast(baseAddr_); + mi->license_ = WriteString(interface->GetLicense()); + mi->name_ = WriteString(interface->GetName()); + mi->namespace_ = WriteString(interface->GetNamespace()->ToString()); + mi->properties_ = interface->IsOneway() ? INTERFACE_PROPERTY_ONEWAY : 0; + mi->methodNumber_ = methodNumber; + mi->external_ = interface->IsExternal(); + // methods_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaInterface)); + mi->methods_ = reinterpret_cast(baseAddr_); + // end address + baseAddr_ = baseAddr_ + sizeof(MetaMethod*) * methodNumber; + + for (int i = 0; i < methodNumber; i++) { + mi->methods_[i] = WriteMetaMethod(interface->GetMethod(i)); + } + + return mi; +} + +MetaMethod* MetadataBuilder::WriteMetaMethod( + /* [in] */ ASTMethod* method) +{ + int parameterNumber = method->GetParameterNumber(); + + // begin address + baseAddr_ = ALIGN8(baseAddr_); + MetaMethod* mm = reinterpret_cast(baseAddr_); + mm->name_ = WriteString(method->GetName()); + mm->signature_ = WriteString(method->GetSignature()); + mm->properties_ = method->IsOneway() ? METHOD_PROPERTY_ONEWAY : 0; + mm->returnTypeIndex_ = module_->IndexOf(method->GetReturnType()); + mm->parameterNumber_ = parameterNumber; + // parameters_'s address + baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaMethod)); + mm->parameters_ = reinterpret_cast(baseAddr_); + // end address + baseAddr_ = baseAddr_ + sizeof(MetaParameter*) * parameterNumber; + + for (int i = 0; i < parameterNumber; i++) { + mm->parameters_[i] = WriteMetaParameter(method->GetParameter(i)); + } + + return mm; +} + +MetaParameter* MetadataBuilder::WriteMetaParameter( + /* [in] */ ASTParameter* parameter) +{ + // begin address + baseAddr_ = ALIGN8(baseAddr_); + MetaParameter* mp = reinterpret_cast(baseAddr_); + mp->name_ = WriteString(parameter->GetName()); + if (parameter->IsInParameter()) { + mp->attributes_ |= ATTR_IN; + } + if (parameter->IsOutParameter()) { + mp->attributes_ |= ATTR_OUT; + } + mp->typeIndex_ = module_->IndexOf(parameter->GetType()); + // end address + baseAddr_ = baseAddr_ + sizeof(MetaParameter); + + return mp; +} + +MetaType* MetadataBuilder::WriteMetaType( + /* [in] */ ASTType* type) +{ + // begin address + baseAddr_ = ALIGN8(baseAddr_); + MetaType* mt = reinterpret_cast(baseAddr_); + mt->kind_ = Type2Kind(type); + if (type->IsSequenceableType()) { + mt->index_ = module_->IndexOf(static_cast(type)); + } else if (type->IsInterfaceType()) { + mt->index_ = module_->IndexOf(static_cast(type)); + } else { + mt->index_ = module_->IndexOf(type); + } + baseAddr_ = baseAddr_ + sizeof(MetaType); + if (type->IsListType()) { + mt->nestedTypeNumber_ = 1; + // nestedTypeIndexes_'s address + baseAddr_ = ALIGN8(baseAddr_); + mt->nestedTypeIndexes_ = reinterpret_cast(baseAddr_); + AutoPtr elementType = (static_cast(type))->GetElementType(); + mt->nestedTypeIndexes_[0] = module_->IndexOf(elementType); + // end address + baseAddr_ = baseAddr_ + sizeof(int*); + } else if (type->IsMapType()) { + mt->nestedTypeNumber_ = 2; + // nestedTypeIndexes_'s address + baseAddr_ = ALIGN8(baseAddr_); + mt->nestedTypeIndexes_ = reinterpret_cast(baseAddr_); + AutoPtr keyType = (static_cast(type))->GetKeyType(); + AutoPtr valueType = (static_cast(type))->GetValueType(); + mt->nestedTypeIndexes_[0] = module_->IndexOf(keyType); + mt->nestedTypeIndexes_[1] = module_->IndexOf(valueType); + // end address + baseAddr_ = baseAddr_ + sizeof(int*) * 2; + } else if (type->IsArrayType()) { + mt->nestedTypeNumber_ = 1; + // nestedTypeIndexes_'s address + baseAddr_ = ALIGN8(baseAddr_); + mt->nestedTypeIndexes_ = reinterpret_cast(baseAddr_); + AutoPtr elementType = (static_cast(type))->GetElementType(); + mt->nestedTypeIndexes_[0] = module_->IndexOf(elementType); + // end address + baseAddr_ = baseAddr_ + sizeof(int*); + } + + return mt; +} + +char* MetadataBuilder::WriteString( + /* [in] */ const String& string) +{ + return string.IsNull() ? nullptr : metaComponent_->stringPool_ + stringPool_.GetOffset(string); +} + +TypeKind MetadataBuilder::Type2Kind( + /* [in] */ ASTType* type) +{ + if (type->IsCharType()) { + return TypeKind::Char; + } else if (type->IsBooleanType()) { + return TypeKind::Boolean; + } else if (type->IsByteType()) { + return TypeKind::Byte; + } else if (type->IsShortType()) { + return TypeKind::Short; + } else if (type->IsIntegerType()) { + return TypeKind::Integer; + } else if (type->IsLongType()) { + return TypeKind::Long; + } else if (type->IsFloatType()) { + return TypeKind::Float; + } else if (type->IsDoubleType()) { + return TypeKind::Double; + } else if (type->IsStringType()) { + return TypeKind::String; + } else if (type->IsVoidType()) { + return TypeKind::Void; + } else if (type->IsSequenceableType()) { + return TypeKind::Sequenceable; + } else if (type->IsInterfaceType()) { + return TypeKind::Interface; + } else if (type->IsListType()) { + return TypeKind::List; + } else if (type->IsMapType()) { + return TypeKind::Map; + } else if (type->IsArrayType()) { + return TypeKind::Array; + } + return TypeKind::Unknown; +} + +} +} diff --git a/zidl/metadata/metadata_builder.h b/zidl/metadata/metadata_builder.h new file mode 100644 index 00000000000..1d0801fbef6 --- /dev/null +++ b/zidl/metadata/metadata_builder.h @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_METADATABUILDER_H +#define OHOS_ZIDL_METADATABUILDER_H + +#include +#include "ast/ast_module.h" +#include "metadata/metadata.h" +#include "util/autoptr.h" +#include "util/string.h" +#include "util/string_pool.h" + +namespace OHOS { +namespace Zidl { + +class MetadataBuilder { +public: + explicit MetadataBuilder( + /* [in] */ ASTModule* module) + : module_(module) + {} + + ~MetadataBuilder() = default; + + std::shared_ptr Build(); + +private: + size_t CalculateMetadataSize(); + + void CalculateMetaComponent( + /* [in] */ ASTModule* module); + + void CalculateMetaNamespace( + /* [in] */ ASTNamespace* nspace); + + void CalculateMetaSequenceable( + /* [in] */ ASTSequenceableType* sequenceable); + + void CalculateMetaInterface( + /* [in] */ ASTInterfaceType* interface); + + void CalculateMetaMethod( + /* [in] */ ASTMethod* method); + + void CalculateMetaParameter( + /* [in] */ ASTParameter* parameter); + + void CalculateMetaType( + /* [in] */ ASTType* type); + + void CalculateStringPool(); + + void WriteMetadata( + /* [in] */ uintptr_t base); + + void WriteMetaComponent( + /* [in] */ ASTModule* module); + + MetaNamespace* WriteMetaNamespace( + /* [in] */ ASTNamespace* nspace); + + MetaSequenceable* WriteMetaSequenceable( + /* [in] */ ASTSequenceableType* parcelabe); + + MetaInterface* WriteMetaInterface( + /* [in] */ ASTInterfaceType* interface); + + MetaMethod* WriteMetaMethod( + /* [in] */ ASTMethod* method); + + MetaParameter* WriteMetaParameter( + /* [in] */ ASTParameter* parameter); + + MetaType* WriteMetaType( + /* [in] */ ASTType* type); + + char* WriteString( + /* [in] */ const String& string); + + TypeKind Type2Kind( + /* [in] */ ASTType* type); + + static const char* TAG; + AutoPtr module_; + std::shared_ptr metaComponent_; + uintptr_t baseAddr_ = 0; + size_t size_ = 0; + StringPool stringPool_; +}; + +} +} + +#endif // OHOS_ZIDL_METADATABUILDER_H diff --git a/zidl/metadata/metadata_dumper.cpp b/zidl/metadata/metadata_dumper.cpp new file mode 100644 index 00000000000..cba7aec6990 --- /dev/null +++ b/zidl/metadata/metadata_dumper.cpp @@ -0,0 +1,299 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "metadata/metadata_dumper.h" +#include +#include "util/string_builder.h" + +namespace OHOS { +namespace Zidl { + +const char* MetadataDumper::TAB = " "; + +void MetadataDumper::Dump( + /* [in] */ const String& prefix) +{ + if (metaComponent_ == nullptr) { + return; + } + + String dumpStr = DumpMetaComponent(metaComponent_, prefix); + printf("%s\n", dumpStr.string()); +} + +String MetadataDumper::DumpMetaComponent( + /* [in] */ MetaComponent* mc, + /* [in] */ const String& prefix) +{ + StringBuilder sb; + + sb.Append(prefix).Append("MetaComponent\n"); + sb.Append(prefix).Append("{\n"); + sb.Append(prefix + TAB).AppendFormat("\"magic_\" : \"0x%x\",\n", mc->magic_); + sb.Append(prefix + TAB).AppendFormat("\"size_\" : \"%d\",\n", mc->size_); + sb.Append(prefix + TAB).AppendFormat("\"name_\" : \"%s\",\n", mc->name_); + sb.Append(prefix + TAB).AppendFormat("\"namespaceNumber_\" : \"%d\",\n", mc->namespaceNumber_); + sb.Append(prefix + TAB).AppendFormat("\"sequenceableNumber_\" : \"%d\",\n", mc->sequenceableNumber_); + sb.Append(prefix + TAB).AppendFormat("\"interfaceNumber_\" : \"%d\",\n", mc->interfaceNumber_); + sb.Append(prefix + TAB).AppendFormat("\"typeNumber_\" : \"%d\",\n", mc->typeNumber_); + + if (mc->namespaceNumber_ == 0) { + sb.Append(prefix + TAB).Append("\"namespaces_\" : [],\n"); + } else { + sb.Append(prefix + TAB).Append("\"namespaces_\" : [\n"); + for (int i = 0; i < mc->namespaceNumber_; i++) { + DumpMetaNamespace(sb, mc->namespaces_[i], prefix + TAB + TAB); + if (i != mc->namespaceNumber_ - 1) { + sb.Append(",\n"); + } + } + sb.Append("\n" + prefix + TAB).Append("],\n"); + } + + if (mc->sequenceableNumber_ == 0) { + sb.Append(prefix + TAB).Append("\"sequenceables_\" : [],\n"); + } else { + sb.Append(prefix + TAB).Append("\"sequenceables_\" : [\n"); + for (int i = 0; i < mc->sequenceableNumber_; i++) { + DumpMetaSequenceable(sb, mc->sequenceables_[i], prefix + TAB + TAB); + if (i != mc->sequenceableNumber_ - 1) { + sb.Append(",\n"); + } + } + sb.Append("\n" + prefix + TAB).Append("],\n"); + } + + if (mc->interfaceNumber_ == 0) { + sb.Append(prefix + TAB).Append("\"interfaces_\" : [],\n"); + } else { + sb.Append(prefix + TAB).Append("\"interfaces_\" : [\n"); + for (int i = 0; i < mc->interfaceNumber_; i++) { + DumpMetaInterface(sb, mc->interfaces_[i], prefix + TAB + TAB); + if (i != mc->interfaceNumber_ - 1) { + sb.Append(",\n"); + } + } + sb.Append("\n" + prefix + TAB).Append("],\n"); + } + + sb.Append(prefix + TAB).AppendFormat("\"stringPoolSize_\" : \"%d\"\n", mc->stringPoolSize_); + + sb.Append(prefix).Append("}\n"); + + return sb.ToString(); +} + +void MetadataDumper::DumpMetaNamespace( + /* [in] */ StringBuilder& sb, + /* [in] */ MetaNamespace* mn, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).Append("{\n"); + sb.Append(prefix + TAB).AppendFormat("\"name_\" : \"%s\",\n", mn->name_); + sb.Append(prefix + TAB).AppendFormat("\"sequenceableNumber_\" : \"%d\",\n", mn->sequenceableNumber_); + sb.Append(prefix + TAB).AppendFormat("\"interfaceNumber_\" : \"%d\",\n", mn->interfaceNumber_); + sb.Append(prefix + TAB).AppendFormat("\"namespaceNumber_\" : \"%d\",\n", mn->namespaceNumber_); + + if (mn->sequenceableNumber_ == 0) { + sb.Append(prefix + TAB).Append("\"sequenceableIndexes_\" : [],\n"); + } else { + sb.Append(prefix + TAB).Append("\"sequenceableIndexes_\" : [\n"); + for (int i = 0; i < mn->sequenceableNumber_; i++) { + MetaSequenceable* mp = metaComponent_->sequenceables_[mn->sequenceableIndexes_[i]]; + sb.Append(prefix + TAB + TAB).AppendFormat("{ \"name\" : \"%s\" }", mp->name_); + if (i != mn->sequenceableNumber_ - 1) { + sb.Append(",\n"); + } + } + sb.Append("\n" + prefix + TAB).Append("],\n"); + } + + if (mn->interfaceNumber_ == 0) { + sb.Append(prefix + TAB).Append("\"interfaceIndexes_\" : [],\n"); + } else { + sb.Append(prefix + TAB).Append("\"interfaceIndexes_\" : [\n"); + for (int i = 0; i < mn->interfaceNumber_; i++) { + MetaInterface* mi = metaComponent_->interfaces_[mn->interfaceIndexes_[i]]; + sb.Append(prefix + TAB + TAB).AppendFormat("{ \"name\" : \"%s\" }", mi->name_); + if (i != mn->interfaceNumber_ - 1) { + sb.Append(",\n"); + } + } + sb.Append("\n" + prefix + TAB).Append("],\n"); + } + + if (mn->namespaceNumber_ == 0) { + sb.Append(prefix + TAB).Append("\"namespaces_\" : []\n"); + } else { + sb.Append(prefix + TAB).Append("\"namespaces_\" : [\n"); + for (int i = 0; i < mn->namespaceNumber_; i++) { + MetaNamespace* innermn = mn->namespaces_[i]; + DumpMetaNamespace(sb, innermn, prefix + TAB + TAB); + if (i != mn->namespaceNumber_ - 1) { + sb.Append(",\n"); + } + } + sb.Append("\n" + prefix + TAB).Append("]\n"); + } + + sb.Append(prefix).Append("}"); +} + +void MetadataDumper::DumpMetaSequenceable( + /* [in] */ StringBuilder& sb, + /* [in] */ MetaSequenceable* mp, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).Append("{\n"); + sb.Append(prefix + TAB).AppendFormat("\"name_\" : \"%s\",\n", mp->name_); + sb.Append(prefix + TAB).AppendFormat("\"namespace_\" : \"%s\"\n", mp->namespace_); + sb.Append(prefix).Append("}"); +} + +void MetadataDumper::DumpMetaInterface( + /* [in] */ StringBuilder& sb, + /* [in] */ MetaInterface* mi, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).Append("{\n"); + sb.Append(prefix + TAB).AppendFormat("\"name_\" : \"%s\",\n", mi->name_); + sb.Append(prefix + TAB).AppendFormat("\"namespace_\" : \"%s\",\n", mi->namespace_); + sb.Append(prefix + TAB).AppendFormat("\"properties_\" : \"%s\",\n", + (mi->properties_ & INTERFACE_PROPERTY_ONEWAY) != 0 ? "oneway" : ""); + sb.Append(prefix + TAB).AppendFormat("\"methodNumber_\" : \"%d\",\n", mi->methodNumber_); + sb.Append(prefix + TAB).AppendFormat("\"external_\" : \"%d\",\n", mi->external_); + + if (mi->methodNumber_ == 0) { + sb.Append(prefix + TAB).Append("\"methods_\" : []\n"); + } else { + sb.Append(prefix + TAB).Append("\"methods_\" : [\n"); + for (int i = 0; i < mi->methodNumber_; i++) { + DumpMetaMethod(sb, mi->methods_[i], prefix + TAB + TAB); + if (i != mi->methodNumber_ - 1) { + sb.Append(",\n"); + } + } + sb.Append("\n" + prefix + TAB).Append("]\n"); + } + + sb.Append(prefix).Append("}"); +} + +void MetadataDumper::DumpMetaMethod( + /* [in] */ StringBuilder& sb, + /* [in] */ MetaMethod* mm, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).Append("{\n"); + sb.Append(prefix + TAB).AppendFormat("\"name_\" : \"%s\",\n", mm->name_); + sb.Append(prefix + TAB).AppendFormat("\"signature_\" : \"%s\",\n", mm->signature_); + sb.Append(prefix + TAB).AppendFormat("\"properties_\" : \"%s\",\n", + (mm->properties_ & METHOD_PROPERTY_ONEWAY) != 0 ? "oneway" : ""); + MetaType* type = metaComponent_->types_[mm->returnTypeIndex_]; + sb.Append(prefix + TAB).AppendFormat("\"returnType_\" : \"%s\",\n", DumpMetaType(type).string()); + sb.Append(prefix + TAB).AppendFormat("\"parameterNumber_\" : \"%d\",\n", mm->parameterNumber_); + + if (mm->parameterNumber_ == 0) { + sb.Append(prefix + TAB).Append("\"parameters_\" : []\n"); + } else { + sb.Append(prefix + TAB).Append("\"parameters_\" : [\n"); + for (int i = 0; i < mm->parameterNumber_; i++) { + DumpMetaParameter(sb, mm->parameters_[i], prefix + TAB + TAB); + if (i != mm->parameterNumber_ - 1) { + sb.Append(",\n"); + } + } + sb.Append("\n" + prefix + TAB).Append("]\n"); + } + + sb.Append(prefix).Append("}"); +} + +void MetadataDumper::DumpMetaParameter( + /* [in] */ StringBuilder& sb, + /* [in] */ MetaParameter* mp, + /* [in] */ const String& prefix) +{ + sb.Append(prefix).Append("{\n"); + sb.Append(prefix + TAB).AppendFormat("\"name_\" : \"%s\",\n", mp->name_); + sb.Append(prefix + TAB).Append("\"attributes_\" : \""); + bool addComma = false; + if ((mp->attributes_ & ATTR_IN) == ATTR_IN) { + sb.Append("in"); + addComma = true; + } + if ((mp->attributes_ & ATTR_OUT) == ATTR_OUT) { + sb.Append(addComma ? ", out" : "out"); + } + sb.Append("\",\n"); + MetaType* type = metaComponent_->types_[mp->typeIndex_]; + sb.Append(prefix + TAB).AppendFormat("\"type_\" : \"%s\"\n", DumpMetaType(type).string()); + + sb.Append(prefix).Append("}"); +} + +String MetadataDumper::DumpMetaType( + /* [in] */ MetaType* mt) +{ + switch (mt->kind_) { + case TypeKind::Char: + return "char"; + case TypeKind::Boolean: + return "boolean"; + case TypeKind::Byte: + return "byte"; + case TypeKind::Short: + return "short"; + case TypeKind::Integer: + return "int"; + case TypeKind::Long: + return "long"; + case TypeKind::Float: + return "float"; + case TypeKind::Double: + return "double"; + case TypeKind::String: + return "String"; + case TypeKind::Void: + return "void"; + case TypeKind::Sequenceable: { + MetaSequenceable* mp = metaComponent_->sequenceables_[mt->index_]; + return mp->name_; + } + case TypeKind::Interface: { + MetaInterface* mi = metaComponent_->interfaces_[mt->index_]; + return mi->name_; + } + case TypeKind::List: { + MetaType* elementMt = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + return "List<" + DumpMetaType(elementMt) + ">"; + } + case TypeKind::Map: { + MetaType* keyMt = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + MetaType* valueMt = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; + return "Map<" + DumpMetaType(keyMt) + ", " + DumpMetaType(valueMt) + ">"; + } + case TypeKind::Array: { + MetaType* elementMt = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; + return DumpMetaType(elementMt) + "[]"; + } + case TypeKind::Unknown: + default: + return "unknown"; + } +} + +} +} diff --git a/zidl/metadata/metadata_dumper.h b/zidl/metadata/metadata_dumper.h new file mode 100644 index 00000000000..ec30a2b6537 --- /dev/null +++ b/zidl/metadata/metadata_dumper.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_METADATADUMPER_H +#define OHOS_ZIDL_METADATADUMPER_H + +#include "metadata/metadata.h" +#include "util/string.h" +#include "util/string_builder.h" + +namespace OHOS { +namespace Zidl { + +class MetadataDumper { +public: + explicit MetadataDumper( + /* [in] */ MetaComponent* mc) + : metaComponent_(mc) + {} + + ~MetadataDumper() = default; + + void Dump( + /* [in] */ const String& prefix); + +private: + String DumpMetaComponent( + /* [in] */ MetaComponent* mc, + /* [in] */ const String& prefix); + + void DumpMetaNamespace( + /* [in] */ StringBuilder& sb, + /* [in] */ MetaNamespace* mn, + /* [in] */ const String& prefix); + + void DumpMetaSequenceable( + /* [in] */ StringBuilder& sb, + /* [in] */ MetaSequenceable* mp, + /* [in] */ const String& prefix); + + void DumpMetaInterface( + /* [in] */ StringBuilder& sb, + /* [in] */ MetaInterface* mi, + /* [in] */ const String& prefix); + + void DumpMetaMethod( + /* [in] */ StringBuilder& sb, + /* [in] */ MetaMethod* mm, + /* [in] */ const String& prefix); + + void DumpMetaParameter( + /* [in] */ StringBuilder& sb, + /* [in] */ MetaParameter* mp, + /* [in] */ const String& prefix); + + String DumpMetaType( + /* [in] */ MetaType* mt); + + static const char* TAB; + MetaComponent* metaComponent_; +}; + +} +} + +#endif // OHOS_ZIDL_METADATADUMPER_H diff --git a/zidl/metadata/metadata_reader.cpp b/zidl/metadata/metadata_reader.cpp new file mode 100644 index 00000000000..fcd1250bae4 --- /dev/null +++ b/zidl/metadata/metadata_reader.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "metadata/metadata_reader.h" +#include "metadata/metadata_serializer.h" +#include "util/file.h" +#include "util/logger.h" + +namespace OHOS { +namespace Zidl { + +const char* MetadataReader::TAG = "MetadataReader"; + +std::shared_ptr MetadataReader::ReadMetadataFromFile( + /* [in] */ const String& filePath) +{ + File file(filePath, File::READ); + if (!file.IsValid()) { + Logger::E(TAG, "Open \"%s\" file failed.", filePath.string()); + return nullptr; + } + + if (!file.Reset()) { + Logger::E(TAG, "Reset \"%s\" file failed.", filePath.string()); + return nullptr; + } + + MetaComponent header; + + if (!file.ReadData((void*)&header, sizeof(MetaComponent))) { + Logger::E(TAG, "Read \"%s\" file failed.", filePath.string()); + return nullptr; + } + + if (header.magic_ != METADATA_MAGIC_NUMBER || header.size_ < 0) { + Logger::E(TAG, "The metadata in \"%s\" file is bad.", filePath.string()); + return nullptr; + } + + if (!file.Reset()) { + Logger::E(TAG, "Reset \"%s\" file failed.", filePath.string()); + return nullptr; + } + + void* data = malloc(header.size_); + if (data == nullptr) { + Logger::E(TAG, "Malloc metadata failed."); + return nullptr; + } + + if (!file.ReadData(data, header.size_)) { + Logger::E(TAG, "Read \"%s\" file failed.", filePath.string()); + free(data); + return nullptr; + } + + std::shared_ptr metadata( + (MetaComponent*)data, + [](MetaComponent* p){ free(p); }); + + MetadataSerializer serializer((uintptr_t)data); + serializer.Deserialize(); + + return metadata; +} + +} +} diff --git a/zidl/metadata/metadata_reader.h b/zidl/metadata/metadata_reader.h new file mode 100644 index 00000000000..1d7054b67d4 --- /dev/null +++ b/zidl/metadata/metadata_reader.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_METADATAREADER_H +#define OHOS_ZIDL_METADATAREADER_H + +#include +#include "metadata/metadata.h" +#include "util/string.h" + +namespace OHOS { +namespace Zidl { + +class MetadataReader { +public: + static std::shared_ptr ReadMetadataFromFile( + /* [in] */ const String& filePath); + +private: + static const char* TAG; +}; + +} +} + +#endif // OHOS_ZIDL_METADATAREADER_H diff --git a/zidl/metadata/metadata_serializer.cpp b/zidl/metadata/metadata_serializer.cpp new file mode 100644 index 00000000000..8ee9031e5b6 --- /dev/null +++ b/zidl/metadata/metadata_serializer.cpp @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "metadata/metadata_serializer.h" + +namespace OHOS { +namespace Zidl { + +void MetadataSerializer::Serialize() +{ + SerializeMetaComponent(metaComponent_); +} + +void MetadataSerializer::SerializeMetaComponent( + /* [in] */ MetaComponent* mc) +{ + mc->name_ = reinterpret_cast(SerializeAdjust(mc->name_)); + + for (int i = 0; i < mc->namespaceNumber_; i++) { + MetaNamespace* mn = mc->namespaces_[i]; + SerializeMetaNamespace(mn); + mc->namespaces_[i] = reinterpret_cast(SerializeAdjust(mn)); + } + mc->namespaces_ = reinterpret_cast(SerializeAdjust(mc->namespaces_)); + + for (int i = 0; i < mc->sequenceableNumber_; i++) { + MetaSequenceable* mp = mc->sequenceables_[i]; + SerializeMetaSequenceable(mp); + mc->sequenceables_[i] = reinterpret_cast(SerializeAdjust(mp)); + } + mc->sequenceables_ = reinterpret_cast(SerializeAdjust(mc->sequenceables_)); + + for (int i = 0; i < mc->interfaceNumber_; i++) { + MetaInterface* mi = mc->interfaces_[i]; + SerializeMetaInterface(mi); + mc->interfaces_[i] = reinterpret_cast(SerializeAdjust(mi)); + } + mc->interfaces_ = reinterpret_cast(SerializeAdjust(mc->interfaces_)); + + for (int i = 0; i < mc->typeNumber_; i++) { + MetaType* mt = mc->types_[i]; + SerializeMetaType(mt); + mc->types_[i] = reinterpret_cast(SerializeAdjust(mt)); + } + mc->types_ = reinterpret_cast(SerializeAdjust(mc->types_)); + + mc->stringPool_ = reinterpret_cast(SerializeAdjust(mc->stringPool_)); +} + +void MetadataSerializer::SerializeMetaNamespace( + /* [in] */ MetaNamespace* mn) +{ + mn->name_ = reinterpret_cast(SerializeAdjust(mn->name_)); + mn->sequenceableIndexes_ = reinterpret_cast(SerializeAdjust(mn->sequenceableIndexes_)); + mn->interfaceIndexes_ = reinterpret_cast(SerializeAdjust(mn->interfaceIndexes_)); + + for (int i = 0; i < mn->namespaceNumber_; i++) { + MetaNamespace* innermn = mn->namespaces_[i]; + SerializeMetaNamespace(innermn); + mn->namespaces_[i] = reinterpret_cast(SerializeAdjust(innermn)); + } + mn->namespaces_ = reinterpret_cast(SerializeAdjust(mn->namespaces_)); +} + +void MetadataSerializer::SerializeMetaSequenceable( + /* [in] */ MetaSequenceable* mp) +{ + mp->name_ = reinterpret_cast(SerializeAdjust(mp->name_)); + mp->namespace_ = reinterpret_cast(SerializeAdjust(mp->namespace_)); +} + +void MetadataSerializer::SerializeMetaInterface( + /* [in] */ MetaInterface* mi) +{ + mi->license_ = reinterpret_cast(SerializeAdjust(mi->license_)); + mi->name_ = reinterpret_cast(SerializeAdjust(mi->name_)); + mi->namespace_ = reinterpret_cast(SerializeAdjust(mi->namespace_)); + + for (int i = 0; i < mi->methodNumber_; i++) { + MetaMethod* mm = mi->methods_[i]; + SerializeMetaMethod(mm); + mi->methods_[i] = reinterpret_cast(SerializeAdjust(mm)); + } + mi->methods_ = reinterpret_cast(SerializeAdjust(mi->methods_)); +} + +void MetadataSerializer::SerializeMetaMethod( + /* [in] */ MetaMethod* mm) +{ + mm->name_ = reinterpret_cast(SerializeAdjust(mm->name_)); + mm->signature_ = reinterpret_cast(SerializeAdjust(mm->signature_)); + + for (int i = 0; i < mm->parameterNumber_; i++) { + MetaParameter* mp = mm->parameters_[i]; + SerializeMetaParameter(mp); + mm->parameters_[i] = reinterpret_cast(SerializeAdjust(mp)); + } + mm->parameters_ = reinterpret_cast(SerializeAdjust(mm->parameters_)); +} + +void MetadataSerializer::SerializeMetaParameter( + /* [in] */ MetaParameter* mp) +{ + mp->name_ = reinterpret_cast(SerializeAdjust(mp->name_)); +} + +void MetadataSerializer::SerializeMetaType( + /* [in] */ MetaType* mt) +{ + mt->nestedTypeIndexes_ = reinterpret_cast(SerializeAdjust(mt->nestedTypeIndexes_)); +} + +ptrdiff_t MetadataSerializer::SerializeAdjust( + /* [in] */ const void* addr) +{ + return reinterpret_cast(addr) - baseAddr_; +} + +void MetadataSerializer::Deserialize() +{ + DeserializeMetaComponent(metaComponent_); +} + +void MetadataSerializer::DeserializeMetaComponent( + /* [in] */ MetaComponent* mc) +{ + mc->name_ = reinterpret_cast(DeserializeAdjust(mc->name_)); + + mc->namespaces_ = reinterpret_cast(DeserializeAdjust(mc->namespaces_)); + for (int i = 0; i < mc->namespaceNumber_; i++) { + mc->namespaces_[i] = reinterpret_cast(DeserializeAdjust(mc->namespaces_[i])); + MetaNamespace* mn = mc->namespaces_[i]; + DeserializeMetaNamespace(mn); + } + + mc->sequenceables_ = reinterpret_cast(DeserializeAdjust(mc->sequenceables_)); + for (int i = 0; i < mc->sequenceableNumber_; i++) { + mc->sequenceables_[i] = reinterpret_cast(DeserializeAdjust(mc->sequenceables_[i])); + MetaSequenceable* mp = mc->sequenceables_[i]; + DeserializeMetaSequenceable(mp); + } + + mc->interfaces_ = reinterpret_cast(DeserializeAdjust(mc->interfaces_)); + for (int i = 0; i < mc->interfaceNumber_; i++) { + mc->interfaces_[i] = reinterpret_cast(DeserializeAdjust(mc->interfaces_[i])); + MetaInterface* mi = mc->interfaces_[i]; + DeserializeMetaInterface(mi); + } + + mc->types_ = reinterpret_cast(DeserializeAdjust(mc->types_)); + for (int i = 0; i < mc->typeNumber_; i++) { + mc->types_[i] = reinterpret_cast(DeserializeAdjust(mc->types_[i])); + MetaType* mt = mc->types_[i]; + DeserializeMetaType(mt); + } + + mc->stringPool_ = reinterpret_cast(DeserializeAdjust(mc->stringPool_)); +} + +void MetadataSerializer::DeserializeMetaNamespace( + /* [in] */ MetaNamespace* mn) +{ + mn->name_ = reinterpret_cast(DeserializeAdjust(mn->name_)); + mn->sequenceableIndexes_ = reinterpret_cast(DeserializeAdjust(mn->sequenceableIndexes_)); + mn->interfaceIndexes_ = reinterpret_cast(DeserializeAdjust(mn->interfaceIndexes_)); + + mn->namespaces_ = reinterpret_cast(DeserializeAdjust(mn->namespaces_)); + for (int i = 0; i < mn->namespaceNumber_; i++) { + mn->namespaces_[i] = reinterpret_cast(DeserializeAdjust(mn->namespaces_[i])); + MetaNamespace* innermn = mn->namespaces_[i]; + DeserializeMetaNamespace(innermn); + } +} + +void MetadataSerializer::DeserializeMetaSequenceable( + /* [in] */ MetaSequenceable* mp) +{ + mp->name_ = reinterpret_cast(DeserializeAdjust(mp->name_)); + mp->namespace_ = reinterpret_cast(DeserializeAdjust(mp->namespace_)); +} + +void MetadataSerializer::DeserializeMetaInterface( + /* [in] */ MetaInterface* mi) +{ + mi->license_ = reinterpret_cast(DeserializeAdjust(mi->license_)); + mi->name_ = reinterpret_cast(DeserializeAdjust(mi->name_)); + mi->namespace_ = reinterpret_cast(DeserializeAdjust(mi->namespace_)); + + mi->methods_ = reinterpret_cast(DeserializeAdjust(mi->methods_)); + for (int i = 0; i < mi->methodNumber_; i++) { + mi->methods_[i] = reinterpret_cast(DeserializeAdjust(mi->methods_[i])); + MetaMethod* mm = mi->methods_[i]; + DeserializeMetaMethod(mm); + } +} + +void MetadataSerializer::DeserializeMetaMethod( + /* [in] */ MetaMethod* mm) +{ + mm->name_ = reinterpret_cast(DeserializeAdjust(mm->name_)); + mm->signature_ = reinterpret_cast(DeserializeAdjust(mm->signature_)); + + mm->parameters_ = reinterpret_cast(DeserializeAdjust(mm->parameters_)); + for (int i = 0; i < mm->parameterNumber_; i++) { + mm->parameters_[i] = reinterpret_cast(DeserializeAdjust(mm->parameters_[i])); + MetaParameter* mp = mm->parameters_[i]; + DeserializeMetaParameter(mp); + } +} + +void MetadataSerializer::DeserializeMetaParameter( + /* [in] */ MetaParameter* mp) +{ + mp->name_ = reinterpret_cast(DeserializeAdjust(mp->name_)); +} + +void MetadataSerializer::DeserializeMetaType( + /* [in] */ MetaType* mt) +{ + mt->nestedTypeIndexes_ = reinterpret_cast(DeserializeAdjust(mt->nestedTypeIndexes_)); +} + +uintptr_t MetadataSerializer::DeserializeAdjust( + /* [in] */ const void* addr) +{ + return reinterpret_cast(addr) + baseAddr_; +} + +} +} diff --git a/zidl/metadata/metadata_serializer.h b/zidl/metadata/metadata_serializer.h new file mode 100644 index 00000000000..7a5e3a51899 --- /dev/null +++ b/zidl/metadata/metadata_serializer.h @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_METADATASERIALIZER_H +#define OHOS_ZIDL_METADATASERIALIZER_H + +#include +#include +#include "metadata/metadata.h" + +namespace OHOS { +namespace Zidl { + +class MetadataSerializer { +public: + explicit MetadataSerializer( + /* [in] */ MetaComponent* mc) + : metaComponent_(mc), + baseAddr_(reinterpret_cast(mc)) + {} + + explicit MetadataSerializer( + /* [in] */ uintptr_t addr) + : metaComponent_(reinterpret_cast(addr)), + baseAddr_(addr) + {} + + ~MetadataSerializer() = default; + + void Serialize(); + + void Deserialize(); + + inline uintptr_t GetData() const + { + return baseAddr_; + } + + inline int GetDataSize() const + { + return metaComponent_->size_; + } + +private: + void SerializeMetaComponent( + /* [in] */ MetaComponent* mc); + + void SerializeMetaNamespace( + /* [in] */ MetaNamespace* mn); + + void SerializeMetaSequenceable( + /* [in] */ MetaSequenceable* mp); + + void SerializeMetaInterface( + /* [in] */ MetaInterface* mi); + + void SerializeMetaMethod( + /* [in] */ MetaMethod* mm); + + void SerializeMetaParameter( + /* [in] */ MetaParameter* mp); + + void SerializeMetaType( + /* [in] */ MetaType* mt); + + ptrdiff_t SerializeAdjust( + /* [in] */ const void* addr); + + void DeserializeMetaComponent( + /* [in] */ MetaComponent* mc); + + void DeserializeMetaNamespace( + /* [in] */ MetaNamespace* mn); + + void DeserializeMetaSequenceable( + /* [in] */ MetaSequenceable* mp); + + void DeserializeMetaInterface( + /* [in] */ MetaInterface* mi); + + void DeserializeMetaMethod( + /* [in] */ MetaMethod* mm); + + void DeserializeMetaParameter( + /* [in] */ MetaParameter* mp); + + void DeserializeMetaType( + /* [in] */ MetaType* mt); + + uintptr_t DeserializeAdjust( + /* [in] */ const void* addr); + + MetaComponent* metaComponent_; + uintptr_t baseAddr_; +}; + +} +} + +#endif // OHOS_ZIDL_METADATASERIALIZER_H diff --git a/zidl/parser/CMakeLists.txt b/zidl/parser/CMakeLists.txt new file mode 100644 index 00000000000..40b2194801e --- /dev/null +++ b/zidl/parser/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_directories( + ${ZIDL_DIR}) + +set(SOURCES + lexer.cpp + parser.cpp) + +add_library(parser STATIC + ${SOURCES}) \ No newline at end of file diff --git a/zidl/parser/lexer.cpp b/zidl/parser/lexer.cpp new file mode 100644 index 00000000000..c8680d4a6dc --- /dev/null +++ b/zidl/parser/lexer.cpp @@ -0,0 +1,383 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "parser/lexer.h" + +#include +#include "util/string_builder.h" + +namespace OHOS { +namespace Zidl { + +static struct Keywords { + String key_; + Token token_; +} g_keywords[] = { + { String("boolean"), Token::BOOLEAN }, + { String("byte"), Token::BYTE }, + { String("char"), Token::CHAR }, + { String("double"), Token::DOUBLE }, + { String("float"), Token::FLOAT }, + { String("in"), Token::IN }, + { String("inout"), Token::INOUT }, + { String("int"), Token::INTEGER }, + { String("interface"), Token::INTERFACE }, + { String("List"), Token::LIST }, + { String("long"), Token::LONG }, + { String("Map"), Token::MAP }, + { String("oneway"), Token::ONEWAY }, + { String("out"), Token::OUT }, + { String("sequenceable"), Token::SEQUENCEABLE }, + { String("short"), Token::SHORT }, + { String("String"), Token::STRING }, +}; + +Lexer::Lexer() +{ + InitializeKeywords(); +} + +Lexer::~Lexer() +{ + if (currentFile_ != nullptr) { + currentFile_->Close(); + } +} + +void Lexer::InitializeKeywords() +{ + for (size_t i = 0; i < sizeof(g_keywords) / sizeof(struct Keywords); i++) { + keywords_[g_keywords[i].key_] = g_keywords[i].token_; + } +} + +bool Lexer::OpenSourceFile( + /* [in] */ const String& filePath) +{ + currentFile_ = std::make_shared(filePath, File::READ); + if (!currentFile_->IsValid()) { + return false; + } + + return true; +} + +Token Lexer::GetToken( + /* [in] */ bool skipComment) +{ + if (!havePeek_) { + currentToken_ = ReadToken(skipComment); + } + havePeek_ = false; + return currentToken_; +} + +Token Lexer::PeekToken( + /* [in] */ bool skipComment) +{ + if (!havePeek_) { + currentToken_ = ReadToken(skipComment); + havePeek_ = true; + } + return currentToken_; +} + +Token Lexer::ReadToken( + /* [in] */ bool skipComment) +{ + while (!currentFile_->IsEof()) { + char c = currentFile_->GetChar(); + tokenLineNo_ = currentFile_->GetCharLineNumber(); + tokenColumnNo_ = currentFile_->GetCharColumnNumber(); + if (IsSpace(c)) { + continue; + } else if (IsAlphabet(c) || c == '_') { + return ReadIdentifier(c); + } + switch (c) { + case '<': + currentToken_ = Token::ANGLE_BRACKETS_LEFT; + return currentToken_; + case '>': + currentToken_ = Token::ANGLE_BRACKETS_RIGHT; + return currentToken_; + case '{': + currentToken_ = Token::BRACES_LEFT; + return currentToken_; + case '}': + currentToken_ = Token::BRACES_RIGHT; + return currentToken_; + case '[': + currentToken_ = Token::BRACKETS_LEFT; + return currentToken_; + case ']': + currentToken_ = Token::BRACKETS_RIGHT; + return currentToken_; + case ',': + currentToken_ = Token::COMMA; + return currentToken_; + case '/': + if (currentFile_->PeekChar() == '/') { + ReadLineComment(c); + if (!skipComment) { + return currentToken_; + } + continue; + } else if (currentFile_->PeekChar() == '*') { + ReadBlockComment(c); + if (!skipComment) { + return currentToken_; + } + continue; + } + currentToken_ = Token::UNKNOWN; + return currentToken_; + case '(': + currentToken_ = Token::PARENTHESES_LEFT; + return currentToken_; + case ')': + currentToken_ = Token::PARENTHESES_RIGHT; + return currentToken_; + case '.': + currentToken_ = Token::DOT; + return currentToken_; + case ';': + currentToken_ = Token::SEMICOLON; + return currentToken_; + default: + currentToken_ = Token::UNKNOWN; + return currentToken_; + } + } + currentToken_ = Token::END_OF_FILE; + return currentToken_; +} + +Token Lexer::ReadIdentifier( + /* [in] */ char c) +{ + StringBuilder sb; + + sb.Append(c); + while (!currentFile_->IsEof()) { + c = currentFile_->PeekChar(); + if (IsAlphabet(c) || c == '_' || IsDecimalDigital(c) || c == '.') { + c = currentFile_->GetChar(); + sb.Append(c); + continue; + } + if (IsSpace(c)) { + currentFile_->GetChar(); + } + break; + } + String key = sb.ToString(); + auto it = keywords_.find(key); + if (it == keywords_.end()) { + identifier_ = key; + currentToken_ = Token::IDENTIFIER; + } else { + currentToken_ = it->second; + } + return currentToken_; +} + +Token Lexer::ReadLineComment( + /* [in] */ char c) +{ + StringBuilder sb; + + sb.Append(c); + while (!currentFile_->IsEof()) { + c = currentFile_->GetChar(); + if (c == '\n') { + break; + } + sb.Append(c); + } + comment_ = sb.ToString(); + currentToken_ = Token::COMMENT_LINE; + return currentToken_; +} + +Token Lexer::ReadBlockComment( + /* [in] */ char c) +{ + StringBuilder sb; + + sb.Append(c); + while (!currentFile_->IsEof()) { + c = currentFile_->GetChar(); + sb.Append(c); + if (c == '*' && currentFile_->PeekChar() == '/') { + c = currentFile_->GetChar(); + sb.Append(c); + break; + } + } + comment_ = sb.ToString(); + currentToken_ = Token::COMMENT_BLOCK; + return currentToken_; +} + +void Lexer::SkipCurrentLine() +{ + while (!currentFile_->IsEof()) { + char c = currentFile_->GetChar(); + if (c == '\n') { + currentFile_->GetChar(); + return; + } + } +} + +bool Lexer::SkipCurrentLine( + /* [in] */ char untilChar) +{ + while (!currentFile_->IsEof()) { + int c = currentFile_->GetChar(); + if (c == untilChar) { + return true; + } + if (c == '\n') { + currentFile_->GetChar(); + return false; + } + } + return true; +} + +int Lexer::TokenToChar( + /* [in] */ Token token) +{ + switch (token) { + case Token::ANGLE_BRACKETS_LEFT: + return '<'; + case Token::ANGLE_BRACKETS_RIGHT: + return '>'; + case Token::BRACES_LEFT: + return '{'; + case Token::BRACES_RIGHT: + return '}'; + case Token::BRACKETS_LEFT: + return '['; + case Token::BRACKETS_RIGHT: + return ']'; + case Token::COMMA: + return ','; + case Token::DOT: + return '.'; + case Token::PARENTHESES_LEFT: + return '('; + case Token::PARENTHESES_RIGHT: + return ')'; + case Token::SEMICOLON: + return ';'; + case Token::BOOLEAN: + case Token::BYTE: + case Token::CHAR: + case Token::COMMENT_BLOCK: + case Token::COMMENT_LINE: + case Token::DOUBLE: + case Token::END_OF_FILE: + case Token::FLOAT: + case Token::IDENTIFIER: + case Token::IN: + case Token::INOUT: + case Token::INTEGER: + case Token::LIST: + case Token::LONG: + case Token::MAP: + case Token::ONEWAY: + case Token::OUT: + case Token::SEQUENCEABLE: + case Token::SHORT: + case Token::STRING: + default: + return -1; + } +} + +String Lexer::DumpToken() const +{ + switch (currentToken_) { + case Token::ANGLE_BRACKETS_LEFT: + return "<"; + case Token::ANGLE_BRACKETS_RIGHT: + return ">"; + case Token::BOOLEAN: + return "boolean"; + case Token::BRACES_LEFT: + return "{"; + case Token::BRACES_RIGHT: + return "}"; + case Token::BRACKETS_LEFT: + return "["; + case Token::BRACKETS_RIGHT: + return "]"; + case Token::BYTE: + return "byte"; + case Token::CHAR: + return "char"; + case Token::COMMA: + return ","; + case Token::COMMENT_BLOCK: + case Token::COMMENT_LINE: + return comment_; + case Token::DOT: + return "."; + case Token::DOUBLE: + return "double"; + case Token::END_OF_FILE: + return "eof"; + case Token::FLOAT: + return "float"; + case Token::IDENTIFIER: + return identifier_; + case Token::IN: + return "in"; + case Token::INOUT: + return "inout"; + case Token::INTEGER: + return "int"; + case Token::LIST: + return "List"; + case Token::LONG: + return "long"; + case Token::MAP: + return "Map"; + case Token::ONEWAY: + return "oneway"; + case Token::OUT: + return "out"; + case Token::SEQUENCEABLE: + return "sequenceable"; + case Token::PARENTHESES_LEFT: + return "("; + case Token::PARENTHESES_RIGHT: + return ")"; + case Token::SEMICOLON: + return ";"; + case Token::SHORT: + return "short"; + case Token::STRING: + return "String"; + default: + return "unknown token"; + } +} + +} +} diff --git a/zidl/parser/lexer.h b/zidl/parser/lexer.h new file mode 100644 index 00000000000..d43c7050ceb --- /dev/null +++ b/zidl/parser/lexer.h @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_LEXER_H +#define OHOS_ZIDL_LEXER_H + +#include +#include +#include + +#include "parser/token.h" +#include "util/file.h" +#include "util/string.h" + +namespace OHOS { +namespace Zidl { + +class Lexer { +public: + Lexer(); + + ~Lexer(); + + bool OpenSourceFile( + /* [in] */ const String& filePath); + + Token GetToken( + /* [in] */ bool skipComment = true); + + Token PeekToken( + /* [in] */ bool skipComment = true); + + inline String GetIdentifier() const + { + return identifier_; + } + + inline String GetComment() const + { + return comment_; + } + + void SkipCurrentLine(); + + bool SkipCurrentLine( + /* [in] */ char untilChar); + + inline std::shared_ptr GetSourceFile() const + { + return currentFile_; + } + + String DumpToken() const; + + inline int GetTokenLineNumber() const + { + return tokenLineNo_; + } + + inline int GetTokenColumnNumber() const + { + return tokenColumnNo_; + } + + static int TokenToChar( + /* [in] */ Token token); + +private: + void InitializeKeywords(); + + Token ReadToken( + /* [in] */ bool skipComment); + + Token ReadIdentifier( + /* [in] */ char c); + + Token ReadLineComment( + /* [in] */ char c); + + Token ReadBlockComment( + /* [in] */ char c); + + inline static bool IsAlphabet( + /* [in] */ char c) + { + return isalpha(c); + } + + inline static bool IsDecimalDigital( + /* [in] */ char c) + { + return isdigit(c); + } + + inline static bool IsSpace( + /* [in] */ char c) + { + return isspace(c); + } + + static const char* TAG; + std::unordered_map keywords_; + Token currentToken_ = Token::UNKNOWN; + int tokenLineNo_ = 0; + int tokenColumnNo_ = 0; + String identifier_; + String comment_; + bool havePeek_ = false; + std::shared_ptr currentFile_; +}; + +} +} + +#endif // OHOS_ZIDL_LEXER_H diff --git a/zidl/parser/parser.cpp b/zidl/parser/parser.cpp new file mode 100644 index 00000000000..43bc428c659 --- /dev/null +++ b/zidl/parser/parser.cpp @@ -0,0 +1,688 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "parser/parser.h" +#include "ast/ast_array_type.h" +#include "ast/ast_list_type.h" +#include "ast/ast_map_type.h" +#include "ast/ast_parameter.h" +#include "ast/ast_sequenceable_type.h" +#include "util/logger.h" +#include "util/string_builder.h" +#include + +namespace OHOS { +namespace Zidl { + +const char* Parser::TAG = "Parser"; + +Parser::Parser( + /* [in] */ const Options& options) + : options_(options) +{} + +bool Parser::Parse( + /* [in] */ const String& sourceFile) +{ + bool ret = lexer_.OpenSourceFile(sourceFile); + if (!ret) { + Logger::E(TAG, "Fail to open file \"%s\".", sourceFile.string()); + return false; + } + + ret = ParseFile(); + ret = CheckIntegrity() && ret; + + if (!ret) { + ShowError(); + return false; + } + + if (options_.DoDumpAST()) { + String astStr = module_->Dump(""); + printf("%s\n", astStr.string()); + } + + return ret; +} + +bool Parser::ParseFile() +{ + bool ret = true; + + module_ = new ASTModule(); + module_->SetZidlFile(lexer_.GetSourceFile()->GetPath()); + + ParseLicense(); + + Token token; + while ((token = lexer_.PeekToken()) != Token::END_OF_FILE) { + switch (token) { + case Token::BRACKETS_LEFT: + case Token::INTERFACE: + ret = ParseInterface() && ret; + continue; + case Token::SEQUENCEABLE: + ret = ParseSequenceable() && ret; + continue; + case Token::COMMENT_LINE: + lexer_.GetToken(); + continue; + default: + LogError(token, String::Format("%s is not expected.", lexer_.DumpToken().string())); + lexer_.GetToken(); + ret = false; + continue; + } + } + lexer_.GetToken(); + + return ret; +} + +bool Parser::ParseLicense() +{ + Token token = lexer_.PeekToken(false); + if (token != Token::COMMENT_BLOCK) { + return false; + } + + lexer_.GetToken(false); + + module_->SetLicense(lexer_.GetComment()); + + return true; +} + +bool Parser::ParseInterface() +{ + bool ret = true; + bool hasProperties = false; + bool oneway = false; + Token token = lexer_.GetToken(); + if (token == Token::BRACKETS_LEFT) { + token = lexer_.PeekToken(); + if (token != Token::ONEWAY) { + LogError(Token::IDENTIFIER, String::Format("\"%s\" is an illegal interface property.", lexer_.DumpToken().string())); + + if (token != Token::BRACKETS_RIGHT) { + lexer_.SkipCurrentLine(Lexer::TokenToChar(Token::BRACKETS_RIGHT)); + } + ret = false; + } + lexer_.GetToken(); + + oneway = true; + hasProperties = true; + + token = lexer_.PeekToken(); + if (token != Token::BRACKETS_RIGHT) { + LogError(Token::IDENTIFIER, String("\"]\" is expected.")); + while (token != Token::BRACKETS_RIGHT && token != Token::INTERFACE && token != Token::END_OF_FILE) { + lexer_.GetToken(); + token = lexer_.PeekToken(); + } + ret = false; + } else { + lexer_.GetToken(); + } + + token = lexer_.PeekToken(); + if (token != Token::INTERFACE) { + LogError(Token::IDENTIFIER, String("\"interface\" is expected.")); + ret = false; + } else { + lexer_.GetToken(); + } + } + + String interfaceFullName; + + token = lexer_.PeekToken(); + + if (token != Token::IDENTIFIER) { + LogError(token, String::Format("%s is not expected.", lexer_.DumpToken().string())); + lexer_.SkipCurrentLine(); + return false; + } else { + lexer_.GetToken(); + interfaceFullName = lexer_.GetIdentifier(); + token = lexer_.PeekToken(); + } + if (token != Token::SEMICOLON && token != Token::BRACES_LEFT) { + LogError(token, String::Format("%s is not expected.", lexer_.DumpToken().string())); + lexer_.SkipCurrentLine(); + return false; + } + + if (interfaceFullName.IsEmpty()) { + LogError(Token::IDENTIFIER, String("Interface name is expected.")); + return false; + } else if (!IsValidTypeName(interfaceFullName)) { + LogError(Token::IDENTIFIER, String::Format("Interface name \"%s\" is illegal.", interfaceFullName.string())); + return false; + } else if (interfaceFullName.IndexOf(".") == -1) { + LogError(Token::IDENTIFIER, String::Format("Interface name \"%s\" does not have namespace.", + interfaceFullName.string())); + return false; + } + + AutoPtr interface = new ASTInterfaceType(); + parsingInterface_ = interface; + int index = interfaceFullName.LastIndexOf('.'); + if (index != -1) { + interface->SetName(interfaceFullName.Substring(index + 1)); + interface->SetNamespace(module_->ParseNamespace(interfaceFullName.Substring(0, index + 1))); + } else { + interface->SetName(interfaceFullName); + } + + // read ';' + lexer_.GetToken(); + if (token == Token::SEMICOLON) { + if (hasProperties) { + LogError(Token::IDENTIFIER, String("Interface forward declaration should not have properties.")); + return false; + } + interface->SetExternal(true); + module_->AddInterface(interface); + return true; + } else { + if (!interface->GetName().Equals(module_->GetName())) { + LogError(Token::IDENTIFIER, String::Format("Module name \"%s\" is not equal to interface name \"%s\".", + module_->GetName().string(), interface->GetName().string())); + return false; + } + + interface->SetLicense(module_->GetLicense()); + interface->SetOneway(oneway); + + while (token != Token::BRACES_RIGHT && token != Token::END_OF_FILE) { + ret = ParseMethod(interface) && ret; + token = lexer_.PeekToken(); + } + + if (token != Token::BRACES_RIGHT) { + ret = false; + } else { + lexer_.GetToken(); + module_->AddInterface(interface); + } + + return ret; + } +} + +bool Parser::ParseMethod( + /* [in] */ ASTInterfaceType* interface) +{ + bool ret = true; + bool oneway = false; + Token token; + + token = lexer_.PeekToken(); + if (token == Token::BRACKETS_LEFT) { + lexer_.GetToken(); + token = lexer_.PeekToken(); + if (token != Token::ONEWAY) { + LogError(Token::IDENTIFIER, String::Format("\"%s\" is an illegal method property.", + lexer_.DumpToken().string())); + + if (token != Token::BRACKETS_RIGHT) { + lexer_.SkipCurrentLine(Lexer::TokenToChar(Token::BRACKETS_RIGHT)); + } + ret = false; + } + lexer_.GetToken(); + + oneway = true; + + token = lexer_.PeekToken(); + if (token != Token::BRACKETS_RIGHT) { + LogError(Token::IDENTIFIER, String("\"]\" is expected.")); + ret = false; + } else { + lexer_.GetToken(); + } + } + AutoPtr type = ParseType(); + if (type == nullptr) { + token = lexer_.PeekToken(); + if (token != Token::BRACES_RIGHT) { + // jump over colon + lexer_.GetToken(); + while (token != Token::SEMICOLON && token != Token::END_OF_FILE) { + token = lexer_.PeekToken(); + if (token == Token::BRACES_RIGHT) { + break; + } + lexer_.GetToken(); + } + } + return false; + } + + token = lexer_.PeekToken(); + if (token != Token::IDENTIFIER) { + LogError(token, String("Method name is expected.")); + if (token != Token::BRACES_RIGHT) { + // jump over colon + lexer_.GetToken(); + while (token != Token::SEMICOLON && token != Token::END_OF_FILE) { + token = lexer_.PeekToken(); + if (token == Token::BRACES_RIGHT) { + break; + } + lexer_.GetToken(); + } + } + return false; + } + token = lexer_.GetToken(); + + AutoPtr method = new ASTMethod(); + method->SetName(lexer_.GetIdentifier()); + method->SetOneway(oneway); + method->SetReturnType(type); + + token = lexer_.PeekToken(); + if (token != Token::PARENTHESES_LEFT) { + LogError(token, String("\"(\" is expected.")); + if (token != Token::BRACES_RIGHT) { + // jump over colon + lexer_.GetToken(); + while (token != Token::SEMICOLON && token != Token::END_OF_FILE) { + token = lexer_.PeekToken(); + if (token == Token::BRACES_RIGHT) { + break; + } + lexer_.GetToken(); + } + } + return false; + } + token = lexer_.GetToken(); + + token = lexer_.PeekToken(); + while (token != Token::PARENTHESES_RIGHT && token != Token::END_OF_FILE) { + ret = ParseParameter(method) && ret; + token = lexer_.PeekToken(); + if (token == Token::COMMA) { + lexer_.GetToken(); + token = lexer_.PeekToken(); + } + } + lexer_.GetToken(); + if (!ret) { + lexer_.SkipCurrentLine(); + return false; + } + + token = lexer_.PeekToken(); + if (token != Token::SEMICOLON) { + LogError(token, String("\";\" is expected.")); + if (token != Token::BRACES_RIGHT) { + lexer_.SkipCurrentLine(Lexer::TokenToChar(Token::BRACES_RIGHT)); + } + return false; + } + lexer_.GetToken(); + + interface->AddMethod(method); + + return ret; +} + +bool Parser::ParseParameter( + /* [in] */ ASTMethod* method) +{ + Token token = lexer_.PeekToken(); + if (token != Token::BRACKETS_LEFT) { + LogError(token, String("\"[\" is expected.")); + // jump to ',' or ')' + while (token != Token::COMMA && token != Token::PARENTHESES_RIGHT && token != Token::END_OF_FILE) { + lexer_.GetToken(); + token = lexer_.PeekToken(); + } + return false; + } + lexer_.GetToken(); + + AutoPtr parameter = new ASTParameter(); + + token = lexer_.PeekToken(); + while (token != Token::BRACKETS_RIGHT && token != Token::END_OF_FILE) { + switch (token) { + case Token::IN: + lexer_.GetToken(); + parameter->SetInParameter(true); + break; + case Token::OUT: + lexer_.GetToken(); + parameter->SetOutParameter(true); + break; + case Token::INOUT: + lexer_.GetToken(); + parameter->SetInParameter(true); + parameter->SetOutParameter(true); + break; + default: + LogError(token, String("\"in\" or \"out\" or \"inout\" is expected.")); + break; + } + token = lexer_.PeekToken(); + if (token == Token::COMMA) { + lexer_.GetToken(); + token = lexer_.PeekToken(); + continue; + } + if (token != Token::BRACKETS_RIGHT) { + LogError(token, String("\",\" or \"]\" is expected.")); + // jump to ',' or ')' + while (token != Token::COMMA && token != Token::PARENTHESES_RIGHT && token != Token::END_OF_FILE) { + lexer_.GetToken(); + token = lexer_.PeekToken(); + } + return false; + } + } + // read ']' + lexer_.GetToken(); + + AutoPtr type = ParseType(); + if (type == nullptr) { + // jump to ',' or ')' + while (token != Token::COMMA && token != Token::PARENTHESES_RIGHT && token != Token::END_OF_FILE) { + lexer_.GetToken(); + token = lexer_.PeekToken(); + } + return false; + } + + token = lexer_.PeekToken(); + if (token != Token::IDENTIFIER) { + LogError(token, String("Parameter name is expected.")); + // jump to ',' or ')' + while (token != Token::COMMA && token != Token::PARENTHESES_RIGHT && token != Token::END_OF_FILE) { + lexer_.GetToken(); + token = lexer_.PeekToken(); + } + return false; + } + lexer_.GetToken(); + + parameter->SetName(lexer_.GetIdentifier()); + parameter->SetType(type); + method->AddParameter(parameter); + + return true; +} + +AutoPtr Parser::ParseType() +{ + AutoPtr type; + + Token token = lexer_.PeekToken(); + if (IsPrimitiveType(token)) { + lexer_.GetToken(); + type = module_->FindType(lexer_.DumpToken()); + } else if (token == Token::LIST) { + type = ParseList(); + } else if (token == Token::MAP) { + type = ParseMap(); + } else if (token == Token::IDENTIFIER) { + lexer_.GetToken(); + if (parsingInterface_ != nullptr && + parsingInterface_->GetName().Equals(lexer_.GetIdentifier())) { + type = parsingInterface_.Get(); + } else { + type = module_->FindType(lexer_.GetIdentifier()); + } + } else { + LogError(token, String("Type name is expected.")); + return nullptr; + } + + if (type == nullptr) { + LogError(token, String::Format("Type \"%s\" was not declared in the module.", lexer_.DumpToken().string())); + } + + token = lexer_.PeekToken(); + if (token == Token::BRACKETS_LEFT) { + lexer_.GetToken(); + token = lexer_.PeekToken(); + if (token != Token::BRACKETS_RIGHT) { + LogError(token, String("\"]\" is expected.")); + return nullptr; + } + lexer_.GetToken(); + + AutoPtr arrayType = new ASTArrayType(); + arrayType->SetElementType(type); + + type = module_->FindType(arrayType->ToString()); + if (type == nullptr) { + module_->AddType(arrayType); + type = static_cast(arrayType.Get()); + } + } + + return type; +} + +AutoPtr Parser::ParseList() +{ + lexer_.GetToken(); + + Token token = lexer_.PeekToken(); + if (token != Token::ANGLE_BRACKETS_LEFT) { + LogError(token, String("\"<\" is expected.")); + return nullptr; + } + lexer_.GetToken(); + + AutoPtr type = ParseType(); + if (type == nullptr) { + lexer_.SkipCurrentLine('>'); + return nullptr; + } + + token = lexer_.PeekToken(); + if (token != Token::ANGLE_BRACKETS_RIGHT) { + LogError(token, String("\">\" is expected.")); + return nullptr; + } + lexer_.GetToken(); + + AutoPtr list = new ASTListType(); + list->SetElementType(type); + + AutoPtr ret = module_->FindType(list->ToString()); + if (ret == nullptr) { + module_->AddType(list); + ret = list.Get(); + } + + return ret; +} + +AutoPtr Parser::ParseMap() +{ + lexer_.GetToken(); + + Token token = lexer_.PeekToken(); + if (token != Token::ANGLE_BRACKETS_LEFT) { + LogError(token, String("\"<\" is expected.")); + return nullptr; + } + lexer_.GetToken(); + + AutoPtr keyType = ParseType(); + if (keyType == nullptr) { + lexer_.SkipCurrentLine('>'); + return nullptr; + } + + token = lexer_.PeekToken(); + if (token != Token::COMMA) { + LogError(token, String("\",\" is expected.")); + return nullptr; + } + lexer_.GetToken(); + + AutoPtr valueType = ParseType(); + if (valueType == nullptr) { + lexer_.SkipCurrentLine('>'); + return nullptr; + } + + token = lexer_.PeekToken(); + if (token != Token::ANGLE_BRACKETS_RIGHT) { + LogError(token, String("\">\" is expected.")); + return nullptr; + } + lexer_.GetToken(); + + AutoPtr map = new ASTMapType(); + map->SetKeyType(keyType); + map->SetValueType(valueType); + + AutoPtr ret = module_->FindType(map->ToString()); + if (ret == nullptr) { + module_->AddType(map); + ret = map.Get(); + } + + return ret; +} + +bool Parser::ParseSequenceable() +{ + lexer_.GetToken(); + + String classFullName; + + Token token = lexer_.PeekToken(); + if (token != Token::IDENTIFIER) { + LogError(token, String::Format("%s is not expected.", lexer_.DumpToken().string())); + lexer_.SkipCurrentLine(); + return false; + } else { + lexer_.GetToken(); + classFullName = lexer_.GetIdentifier(); + token = lexer_.PeekToken(); + } + + if (token != Token::SEMICOLON) { + LogError(token, String::Format("%s is not expected.", lexer_.DumpToken().string())); + lexer_.SkipCurrentLine(); + return false; + } + + // read ';' + lexer_.GetToken(); + + if (classFullName.IsEmpty()) { + LogError(Token::IDENTIFIER, String("Class name is expected.")); + return false; + } else if (!IsValidTypeName(classFullName)) { + LogError(Token::IDENTIFIER, String::Format("Class name \"%s\" is illegal.", classFullName.string())); + return false; + } + + AutoPtr sequenceable = new ASTSequenceableType(); + int index = classFullName.LastIndexOf('.'); + if (index != -1) { + sequenceable->SetName(classFullName.Substring(index + 1)); + sequenceable->SetNamespace(module_->ParseNamespace(classFullName.Substring(0, index + 1))); + } else { + sequenceable->SetName(classFullName); + } + module_->AddSequenceable(sequenceable); + + return true; +} + +bool Parser::CheckIntegrity() +{ + bool definedInterface = false; + int interfaceNumber = module_->GetInterfaceNumber(); + for (int i = 0; i < interfaceNumber; i++) { + if (!module_->GetInterface(i)->IsExternal()) { + definedInterface = true; + break; + } + } + if (!definedInterface) { + LogError(Token::UNKNOWN, String("An interface is not defined.")); + return false; + } + + return true; +} + +bool Parser::IsValidTypeName( + /* [in] */ const String& typeName) +{ + if (typeName[0] == '.') { + return false; + } + + if (typeName[typeName.GetLength() - 1] == '.') { + return false; + } + + return true; +} + +void Parser::LogError( + /* [in] */ Token token, + /* [in] */ const String& message) +{ + AutoPtr error = new ErrorInfo(); + + String sourceFile = lexer_.GetSourceFile()->GetPath(); +#ifdef __MINGW32__ + error->file_ = sourceFile.Substring(sourceFile.LastIndexOf('\\') + 1); +#else + error->file_ = sourceFile.Substring(sourceFile.LastIndexOf('/') + 1); +#endif + error->lineNo_ = lexer_.GetTokenLineNumber(); + error->columnNo_ = lexer_.GetTokenColumnNumber(); + error->message_ = message; + + if (errors_ == nullptr) { + errors_ = error; + } else { + ErrorInfo* pos = errors_; + while (pos->next_ != nullptr) { + pos = pos->next_; + } + pos->next_ = error; + } +} + +void Parser::ShowError() +{ + ErrorInfo* error = errors_; + while (error != nullptr) { + Logger::E(TAG, "%s[line %d, column %d] %s", error->file_.string(), + error->lineNo_, error->columnNo_, error->message_.string()); + error = error->next_; + } +} + +} +} diff --git a/zidl/parser/parser.h b/zidl/parser/parser.h new file mode 100644 index 00000000000..b0e4f5ec3b1 --- /dev/null +++ b/zidl/parser/parser.h @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_PARSER_H +#define OHOS_ZIDL_PARSER_H + +#include "ast/ast_interface_type.h" +#include "ast/ast_method.h" +#include "ast/ast_module.h" +#include "ast/ast_type.h" +#include "parser/lexer.h" +#include "parser/token.h" +#include "util/autoptr.h" +#include "util/light_refcount_base.h" +#include "util/options.h" +#include "util/string.h" + +namespace OHOS { +namespace Zidl { + +class Parser { +public: + explicit Parser( + /* [in] */ const Options& options); + + ~Parser() = default; + + bool Parse( + /* [in] */ const String& sourceFile); + + inline AutoPtr GetModule() const + { + return module_; + } + +private: + class ErrorInfo : public LightRefCountBase { + public: + String file_; + Token token_; + int lineNo_; + int columnNo_; + String message_; + AutoPtr next_; + }; + + bool ParseFile(); + + bool ParseLicense(); + + bool ParseInterface(); + + bool ParseMethod( + /* [in] */ ASTInterfaceType* interface); + + bool ParseParameter( + /* [in] */ ASTMethod* method); + + AutoPtr ParseType(); + + AutoPtr ParseList(); + + AutoPtr ParseMap(); + + bool ParseSequenceable(); + + bool CheckIntegrity(); + + bool IsValidTypeName( + /* [in] */ const String& typeName); + + inline static bool IsPrimitiveType( + /* [in] */ Token token) + { + return token >= Token::BOOLEAN && token <= Token::STRING; + } + + void LogError( + /* [in] */ Token token, + /* [in] */ const String& message); + + void ShowError(); + + static const char* TAG; + + const Options& options_; + AutoPtr module_; + AutoPtr parsingInterface_; + Lexer lexer_; + AutoPtr errors_; +}; + +} +} + +#endif // OHOS_ZIDL_PARSER_H diff --git a/zidl/parser/token.h b/zidl/parser/token.h new file mode 100644 index 00000000000..a121f147ef6 --- /dev/null +++ b/zidl/parser/token.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_TOKEN_H +#define OHOS_ZIDL_TOKEN_H + +namespace OHOS { +namespace Zidl { + +enum class Token { + UNKNOWN = 0, + // types + BOOLEAN, + CHAR, + BYTE, + SHORT, + INTEGER, + LONG, + FLOAT, + DOUBLE, + STRING, + LIST, + MAP, + // keywords + IN, + INTERFACE, + ONEWAY, + OUT, + INOUT, + SEQUENCEABLE, + // symbols + DOT, // '.' + COMMA, // ',' + SEMICOLON, // ';' + BRACES_LEFT, // '{' + BRACES_RIGHT, // '}' + BRACKETS_LEFT, // '[' + BRACKETS_RIGHT, // ']' + PARENTHESES_LEFT, // '(' + PARENTHESES_RIGHT, // ')' + ANGLE_BRACKETS_LEFT, // '<' + ANGLE_BRACKETS_RIGHT, // '>' + // others + IDENTIFIER, + COMMENT_BLOCK, + COMMENT_LINE, + END_OF_FILE, +}; + +} +} + +#endif // OHOS_ZIDL_TOKEN_H diff --git a/zidl/test/native/BUILD.gn b/zidl/test/native/BUILD.gn new file mode 100644 index 00000000000..8dc9839a534 --- /dev/null +++ b/zidl/test/native/BUILD.gn @@ -0,0 +1,69 @@ +# Copyright (C) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") + +IPC_SUBSYSTEM_DIR = "//foundation/communication/ipc" +ZIDL_TEST_DIR = "//foundation/aafwk/standard/zidl/test/native" + +config("ipc_test_config") { + include_dirs = [ + "//utils/native/base/include", + "$ZIDL_TEST_DIR/include", + "$IPC_SUBSYSTEM_DIR/utils/include", + "$IPC_SUBSYSTEM_DIR/ipc/native/src/mock/include", + "//utils/system/safwk/native/include", + ] +} + +ohos_executable("zidl_server_test") { + sources = [ + "./src/main_server.cpp", + "./src/test_service.cpp", + "./src/zidl_test_service_stub.cpp", + ] + + configs = [ ":ipc_test_config" ] + + deps = [ "//utils/native/base:utils" ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "samgr_standard:samgr_proxy", + ] + + subsystem_name = "aafwk" + part_name = "zidl" +} + +ohos_executable("zidl_client_test") { + sources = [ + "./src/main_client.cpp", + "./src/test_client.cpp", + "./src/zidl_test_service_proxy.cpp", + ] + + configs = [ ":ipc_test_config" ] + + deps = [ "//utils/native/base:utils" ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "samgr_standard:samgr_proxy", + ] + + subsystem_name = "aafwk" + part_name = "zidl" +} diff --git a/zidl/test/native/include/izidl_test_service.h b/zidl/test/native/include/izidl_test_service.h new file mode 100644 index 00000000000..3f6308363a8 --- /dev/null +++ b/zidl/test/native/include/izidl_test_service.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_IZIDLTESTSERVICE_H +#define OHOS_IZIDLTESTSERVICE_H + +#include +#include + +namespace OHOS { +class IZidlTestService : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IZidlTestService"); + + virtual ErrCode TestIntTransaction( + /* [in] */ int _data, + /* [out] */ int& result) = 0; + + virtual ErrCode TestStringTransaction( + /* [in] */ const std::string& _data) = 0; +}; +} // namespace OHOS +#endif // OHOS_IZIDLTESTSERVICE_H + diff --git a/zidl/test/native/include/test_client.h b/zidl/test/native/include/test_client.h new file mode 100644 index 00000000000..4d54213003b --- /dev/null +++ b/zidl/test/native/include/test_client.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_IPC_TEST_SERVICE_CLIENT_H +#define OHOS_IPC_TEST_SERVICE_CLIENT_H + +#include "ipc_debug.h" +#include "log_tags.h" +#include "zidl_test_service_proxy.h" + +namespace OHOS { +class TestClient { +public: + int ConnectService(); + void StartIntTransaction(); + void StartStringTransaction(); +private: + static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "TestClient" }; + sptr testService_; +}; +} // namespace OHOS +#endif // OHOS_IPC_TEST_SERVICE_CLIENT_H diff --git a/zidl/test/native/include/test_service.h b/zidl/test/native/include/test_service.h new file mode 100644 index 00000000000..2c29658c761 --- /dev/null +++ b/zidl/test/native/include/test_service.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_IPC_TEST_SERVICE_H +#define OHOS_IPC_TEST_SERVICE_H + +#include "hilog/log.h" +#include "log_tags.h" +#include "zidl_test_service_stub.h" + +namespace OHOS { +class TestService : public ZidlTestServiceStub { +public: + TestService(); + ~TestService(); + static int Instantiate(); + ErrCode TestIntTransaction(int data, int &rep) override; + ErrCode TestStringTransaction(const std::string& data) override; +private: + static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "TestService" }; +}; +} // namespace OHOS +#endif // OHOS_IPC_TEST_SERVICE_H + diff --git a/zidl/test/native/include/zidl_test_service_proxy.h b/zidl/test/native/include/zidl_test_service_proxy.h new file mode 100644 index 00000000000..7e9ea4dcd58 --- /dev/null +++ b/zidl/test/native/include/zidl_test_service_proxy.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDLTESTSERVICEPROXY_H +#define OHOS_ZIDLTESTSERVICEPROXY_H + +#include "izidl_test_service.h" +#include + +namespace OHOS { +class ZidlTestServiceProxy : public IRemoteProxy { +public: + explicit ZidlTestServiceProxy( + /* [in] */ const sptr& remote) + : IRemoteProxy(remote) + {} + + virtual ~ZidlTestServiceProxy() + {} + + ErrCode TestIntTransaction( + /* [in] */ int _data, + /* [out] */ int& result) override; + + ErrCode TestStringTransaction( + /* [in] */ const std::string& _data) override; + +private: + static constexpr int COMMAND_TEST_INT_TRANSACTION = MIN_TRANSACTION_ID + 0; + static constexpr int COMMAND_TEST_STRING_TRANSACTION = MIN_TRANSACTION_ID + 1; + + static inline BrokerDelegator delegator_; +}; +} // namespace OHOS +#endif // OHOS_ZIDLTESTSERVICEPROXY_H + diff --git a/zidl/test/native/include/zidl_test_service_stub.h b/zidl/test/native/include/zidl_test_service_stub.h new file mode 100644 index 00000000000..d88b615bb1f --- /dev/null +++ b/zidl/test/native/include/zidl_test_service_stub.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDLTESTSERVICESTUB_H +#define OHOS_ZIDLTESTSERVICESTUB_H + +#include "izidl_test_service.h" +#include + +namespace OHOS { +class ZidlTestServiceStub : public IRemoteStub { +public: + int OnRemoteRequest( + /* [in] */ uint32_t code, + /* [in] */ MessageParcel& data, + /* [out] */ MessageParcel& reply, + /* [in] */ MessageOption& option) override; + +private: + static constexpr int COMMAND_TEST_INT_TRANSACTION = MIN_TRANSACTION_ID + 0; + static constexpr int COMMAND_TEST_STRING_TRANSACTION = MIN_TRANSACTION_ID + 1; +}; +} // namespace OHOS +#endif // OHOS_ZIDLTESTSERVICESTUB_H + diff --git a/zidl/test/native/src/main_client.cpp b/zidl/test/native/src/main_client.cpp new file mode 100644 index 00000000000..7238b197b76 --- /dev/null +++ b/zidl/test/native/src/main_client.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "ipc_debug.h" +#include "ipc_skeleton.h" +#include "log_tags.h" +#include "test_client.h" + +using namespace OHOS; +using namespace OHOS::HiviewDFX; +static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "IPCTestClient" }; + +enum TestCommand { + TEST_CMD_NONE = 0, + TEST_CMD_INT_TRANS = 1, + TEST_CMD_STRING_TRANS = 2 +}; + +namespace { +std::vector GetArgvOptions(int argc, char **argv) +{ + std::vector argvOptions; + for (int i = 1; i < argc; i++) { + argvOptions.emplace_back(std::string(argv[i])); + } + return argvOptions; +} +} + +int main(int argc, char *argv[]) +{ + TestCommand commandId = TestCommand::TEST_CMD_INT_TRANS; + if (argc > 1) { + commandId = TestCommand(atoi(argv[1])); + } else { + ZLOGE(LABEL, "unknown command"); + } + std::vector argvOptions; + argvOptions = GetArgvOptions(argc, argv); + std::unique_ptr testClient = std::make_unique(); + if (testClient->ConnectService()) { + return -1; + } + + ZLOGE(LABEL, "commandId= : %{public}d", commandId); + switch (commandId) { + case TestCommand::TEST_CMD_INT_TRANS: + testClient->StartIntTransaction(); + break; + case TestCommand::TEST_CMD_STRING_TRANS: + testClient->StartStringTransaction(); + break; + default: + ZLOGI(LABEL, "main arg error"); + break; + } + + IPCSkeleton::JoinWorkThread(); + return 0; +} diff --git a/zidl/test/native/src/main_server.cpp b/zidl/test/native/src/main_server.cpp new file mode 100644 index 00000000000..0765721662f --- /dev/null +++ b/zidl/test/native/src/main_server.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ipc_debug.h" +#include "ipc_skeleton.h" +#include "log_tags.h" +#include "test_service.h" + +using namespace OHOS; +using namespace OHOS::HiviewDFX; + +[[maybe_unused]]static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "IPCTestServer" }; + +int main(int argc __attribute__((unused)), char **argv __attribute__((unused))) +{ + TestService::Instantiate(); + ZLOGI(LABEL, "call StartThreadPool"); + IPCSkeleton::JoinWorkThread(); +} diff --git a/zidl/test/native/src/test_client.cpp b/zidl/test/native/src/test_client.cpp new file mode 100644 index 00000000000..b2e7abd8e58 --- /dev/null +++ b/zidl/test/native/src/test_client.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "test_client.h" + +#include "if_system_ability_manager.h" +#include "ipc_debug.h" +#include "ipc_skeleton.h" +#include "iservice_registry.h" +#include "system_ability_definition.h" + +namespace OHOS { +int TestClient::ConnectService() +{ + auto saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (saMgr == nullptr) { + ZLOGE(LABEL, "get registry fail"); + return -1; + } + + sptr object = saMgr->GetSystemAbility(IPC_TEST_SERVICE); + + if (object != nullptr) { + ZLOGE(LABEL, "Got test Service object"); + testService_ = (new (std::nothrow) ZidlTestServiceProxy(object)); + } + + if (testService_ == nullptr) { + ZLOGE(LABEL, "Could not find Test Service!"); + return -1; + } + + return 0; +} + +void TestClient::StartIntTransaction() +{ + if (testService_ != nullptr) { + ZLOGE(LABEL, "StartIntTransaction"); + [[maybe_unused]] int result = 0; + testService_->TestIntTransaction(1234, result); // 1234 : test number + ZLOGE(LABEL, "Rec result from server %{public}d.", result); + } +} + +void TestClient::StartStringTransaction() +{ + if (testService_ != nullptr) { + ZLOGI(LABEL, "StartIntTransaction"); + testService_->TestStringTransaction("ZIDL Test"); + } +} +} // namespace OHOS diff --git a/zidl/test/native/src/test_service.cpp b/zidl/test/native/src/test_service.cpp new file mode 100644 index 00000000000..acf2f6346c1 --- /dev/null +++ b/zidl/test/native/src/test_service.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "test_service.h" + +#include + +#include "if_system_ability_manager.h" +#include "ipc_debug.h" +#include "ipc_skeleton.h" +#include "iservice_registry.h" +#include "system_ability_definition.h" + +namespace OHOS { +using namespace OHOS::HiviewDFX; + +int TestService::Instantiate() +{ + ZLOGI(LABEL, "%{public}s call in", __func__); + auto saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (saMgr == nullptr) { + ZLOGE(LABEL, "%{public}s:fail to get Registry", __func__); + return -ENODEV; + } + + sptr newInstance = new TestService(); + int result = saMgr->AddSystemAbility(IPC_TEST_SERVICE, newInstance); + ZLOGI(LABEL, "%{public}s: IPC_TEST_SERVICE result = %{public}d", __func__, result); + return result; +} + +TestService::TestService() +{ +} + +TestService::~TestService() +{ +} + +ErrCode TestService::TestIntTransaction(int data, int &rep) +{ + ZLOGE(LABEL, " TestService:read from client data = %{public}d", data); + rep = data + data; + return ERR_NONE; +} + +ErrCode TestService::TestStringTransaction(const std::string &data) +{ + ZLOGE(LABEL, "TestService:read string from client data = %{public}s", data.c_str()); + return data.size(); +} +} // namespace OHOS diff --git a/zidl/test/native/src/zidl_test_service_proxy.cpp b/zidl/test/native/src/zidl_test_service_proxy.cpp new file mode 100644 index 00000000000..314cadb6a24 --- /dev/null +++ b/zidl/test/native/src/zidl_test_service_proxy.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "zidl_test_service_proxy.h" + +namespace OHOS { +ErrCode ZidlTestServiceProxy::TestIntTransaction( + /* [in] */ int _data, + /* [out] */ int& result) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + data.WriteInt32(_data); + + int32_t st = Remote()->SendRequest(COMMAND_TEST_INT_TRANSACTION, data, reply, option); + if (st != ERR_NONE) { + return st; + } + + ErrCode ec = reply.ReadInt32(); + if (FAILED(ec)) { + return ec; + } + + result = reply.ReadInt32(); + return ERR_OK; +} + +ErrCode ZidlTestServiceProxy::TestStringTransaction( + /* [in] */ const std::string& _data) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + data.WriteString16(Str8ToStr16(_data)); + + int32_t st = Remote()->SendRequest(COMMAND_TEST_STRING_TRANSACTION, data, reply, option); + if (st != ERR_NONE) { + return st; + } + + ErrCode ec = reply.ReadInt32(); + if (FAILED(ec)) { + return ec; + } + + return ERR_OK; +} +} // namespace OHOS diff --git a/zidl/test/native/src/zidl_test_service_stub.cpp b/zidl/test/native/src/zidl_test_service_stub.cpp new file mode 100644 index 00000000000..adf63cd1dec --- /dev/null +++ b/zidl/test/native/src/zidl_test_service_stub.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "zidl_test_service_stub.h" + +namespace OHOS { +int ZidlTestServiceStub::OnRemoteRequest( + /* [in] */ uint32_t code, + /* [in] */ MessageParcel& data, + /* [out] */ MessageParcel& reply, + /* [in] */ MessageOption& option) +{ + switch (code) { + case COMMAND_TEST_INT_TRANSACTION: { + int _data = data.ReadInt32(); + int result; + ErrCode ec = TestIntTransaction(_data, result); + reply.WriteInt32(ec); + if (SUCCEEDED(ec)) { + reply.WriteInt32(result); + } + return ERR_NONE; + } + case COMMAND_TEST_STRING_TRANSACTION: { + std::string _data = Str16ToStr8(data.ReadString16()); + ErrCode ec = TestStringTransaction(_data); + reply.WriteInt32(ec); + return ERR_NONE; + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + + return ERR_TRANSACTION_FAILED; +} +} // namespace OHOS diff --git a/zidl/test/zidlgen/IZidlTestService.zidl b/zidl/test/zidlgen/IZidlTestService.zidl new file mode 100644 index 00000000000..8d2fa0b91c5 --- /dev/null +++ b/zidl/test/zidlgen/IZidlTestService.zidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface OHOS.IZidlTestService { + int TestIntTransaction([in] int data); + void TestStringTransaction([in] String data); +} \ No newline at end of file diff --git a/zidl/test/zidlgen/zidl b/zidl/test/zidlgen/zidl new file mode 100644 index 0000000000000000000000000000000000000000..c3bde7295221617c5bdc4e7a695702a580ac0c22 GIT binary patch literal 216360 zcmeFa34ByV);?Sb0Ru*D6&;k!cnOOELP$b@u!s#wkU)S)0wRl@Ch3rdPSSRFASh~N zP*G7MqB4pamr+zkqoSfB#u*oMP&2N`fD?Db=)@fz)bFXPQ{DGg_f0@?-uM6g-U}zE z`>AtJovJ!@YPm~akY6}4J}!=_qYE3y_&4JMi8(1Dbz&DK!kjFJ9ge@rtT*chGy&wK zRGnAG%LK&}Nsepd=WU>LohOr=;>tqK`FVCn&l)MIICDrzj&=nZl&;FBcuTW9PjT~k zyo~KbW%=8uTX|zosb6vZyoNj}-w@KcJdHKUY?(TbR|n6p)G6glORc~t6q!lAM)qVw)Zk%-O{lB9f?%dhNooX71v*n`{1=^1KwojXaP;;OBO`n(H9 zWDoU~5Ak`cYwL#8<%}3IB0D`;lb$8?@n+^FIBnWYp@G*LWf4y27*BVe(LME{As@8d z_+}_`#hBqCae~dC(|{inBdr3M5d*)_2EWM$e-wC13_Yt*@L2dwz+>6-DI6gde#X(U z@d3SK<1qZ19h5@a@&H_3X95zp}x52|JHu z&3k0D96=@gz~K6iWc3fqabY~+g9l37@tnkOCHxN=68C>0@g~B*BK<|5Nd4Og|LfsW zzVtFFkMJUnRTxiszD?Ikd?ewmLnPkZQ|d7Ye{rnDi*`u)T}oc`uOnH*GATcp@HrR+ zxPHgu63>>Wu`d%P-oDCePgkSr34bYH;?8u5 zPa%8-DvH~0WJr7^;rEwGy!l0m-;8-1KW?ie`MnZ|i{j23miK}wep?`6I^It0K zCy(U+e7e+AR4wKE5q=B#dGqZO-$eMSbEJIx9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i&Z?9e|O-%rT2`z?;erm zqWkZwwiT{ig1RCe3SZ8;$Ql7L|Hn6O!?70{gdz}Z@0>~_`T&eeo3YyA7dl&)C+e&ZE*9mu=OxeAB3x8v~rMKp5%eCff zrste))!#~g8h)(Pc>L$D{eyJ(#fcKO{#x^`1>b}Zrnl<<{i|dPEjP=WcvS+c9aefC znoCXpe4$Klxl2o}n9{ZCZ~0O#Ure93@L!gelz-aC zNuTccvS7<)+1%8$(p&OXhf3eQJS!cNh#!R_=3%AJovq3(lJ4AY8FWv73~AYSR(eam zSXe53_Azt(taO%ZWy=l7)bfk&mg$OSNH;1{C;wRKEuWFy(p&QE;F&W08dbg(zk7N+ z!c)uNGF?HLbgg)n+r9h}1klfl-93FlxB7Q4|D%+& RRvC1y@^N=W+OHdE`#(nTh9Lj| literal 0 HcmV?d00001 diff --git a/zidl/util/CMakeLists.txt b/zidl/util/CMakeLists.txt new file mode 100644 index 00000000000..753b0bb189b --- /dev/null +++ b/zidl/util/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_directories( + ${ZIDL_DIR}) + +set(SOURCES + file.cpp + light_refcount_base.cpp + logger.cpp + options.cpp + string.cpp + string_builder.cpp + string_pool.cpp) + +add_library(util STATIC + ${SOURCES}) \ No newline at end of file diff --git a/zidl/util/autoptr.h b/zidl/util/autoptr.h new file mode 100644 index 00000000000..3574bf9f861 --- /dev/null +++ b/zidl/util/autoptr.h @@ -0,0 +1,309 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_AUTOPTR_H +#define OHOS_ZIDL_AUTOPTR_H + +namespace OHOS { +namespace Zidl { + +template +class AutoPtr { +public: + inline AutoPtr() + : mPtr(nullptr) + {} + + AutoPtr( + /* [in] */ T* other); + + AutoPtr( + /* [in] */ const AutoPtr& other); + + AutoPtr( + /* [in] */ AutoPtr&& other); + + ~AutoPtr(); + + AutoPtr& operator=( + /* [in] */ T* other); + + AutoPtr& operator=( + /* [in] */ const AutoPtr& other); + + AutoPtr& operator=( + /* [in] */ AutoPtr&& other); + + void MoveTo( + /* [out] */ T** other); + + inline operator T*() const; + + inline T** operator&(); + + inline T* operator->() const; + + inline T& operator*() const; + + inline T* Get() const; + + inline bool operator==( + /* [in] */ T* other) const; + + inline bool operator==( + /* [in] */ const AutoPtr& other) const; + + inline bool operator!=( + /* [in] */ T* other) const; + + inline bool operator!=( + /* [in] */ const AutoPtr& other) const; + + inline bool operator>( + /* [in] */ T* other) const; + + inline bool operator>( + /* [in] */ const AutoPtr& other) const; + + inline bool operator<( + /* [in] */ T* other) const; + + inline bool operator<( + /* [in] */ const AutoPtr& other) const; + + inline bool operator<=( + /* [in] */ T* other) const; + + inline bool operator<=( + /* [in] */ const AutoPtr& other) const; + + inline bool operator>=( + /* [in] */ T* other) const; + + inline bool operator>=( + /* [in] */ const AutoPtr& other) const; + +private: + T* mPtr; +}; + +template +AutoPtr::AutoPtr( + /* [in] */ T* other) + : mPtr(other) +{ + if (mPtr != nullptr) { + mPtr->AddRef(); + } +} + +template +AutoPtr::AutoPtr( + /* [in] */ const AutoPtr& other) + : mPtr(other.mPtr) +{ + if (mPtr != nullptr) { + mPtr->AddRef(); + } +} + +template +AutoPtr::AutoPtr( + /* [in] */ AutoPtr&& other) + : mPtr(other.mPtr) +{ + other.mPtr = nullptr; +} + +template +AutoPtr::~AutoPtr() +{ + if (mPtr != nullptr) { + mPtr->Release(); + } +} + +template +AutoPtr& AutoPtr::operator=( + /* [in] */ T* other) +{ + if (mPtr == other) return *this; + + if (other != nullptr) { + other->AddRef(); + } + if (mPtr != nullptr) { + mPtr->Release(); + } + mPtr = other; + return *this; +} + +template +AutoPtr& AutoPtr::operator=( + /* [in] */ const AutoPtr& other) +{ + if (mPtr == other.mPtr) return *this; + + if (other.mPtr != nullptr) { + other.mPtr->AddRef(); + } + if (mPtr != nullptr) { + mPtr->Release(); + } + mPtr = other.mPtr; + return *this; +} + +template +AutoPtr& AutoPtr::operator=( + /* [in] */ AutoPtr&& other) +{ + if (mPtr != nullptr) { + mPtr->Release(); + } + mPtr = other.mPtr; + other.mPtr = nullptr; + return *this; +} + +template +void AutoPtr::MoveTo( + /* [out] */ T** other) +{ + if (other != nullptr) { + *other = mPtr; + mPtr = nullptr; + } +} + +template +AutoPtr::operator T*() const +{ + return mPtr; +} + +template +T** AutoPtr::operator&() +{ + return &mPtr; +} + +template +T* AutoPtr::operator->() const +{ + return mPtr; +} + +template +T& AutoPtr::operator*() const +{ + return *mPtr; +} + +template +T* AutoPtr::Get() const +{ + return mPtr; +} + +template +bool AutoPtr::operator==( + /* [in] */ T* other) const +{ + return mPtr == other; +} + +template +bool AutoPtr::operator==( + /* [in] */ const AutoPtr& other) const +{ + return mPtr == other.mPtr; +} + +template +bool AutoPtr::operator!=( + /* [in] */ T* other) const +{ + return mPtr != other; +} + +template +bool AutoPtr::operator!=( + /* [in] */ const AutoPtr& other) const +{ + return mPtr != other.mPtr; +} + +template +bool AutoPtr::operator>( + /* [in] */ T* other) const +{ + return mPtr > other; +} + +template +bool AutoPtr::operator>( + /* [in] */ const AutoPtr& other) const +{ + return mPtr > other.mPtr; +} + +template +bool AutoPtr::operator<( + /* [in] */ T* other) const +{ + return mPtr < other; +} + +template +bool AutoPtr::operator<( + /* [in] */ const AutoPtr& other) const +{ + return mPtr < other.mPtr; +} + +template +bool AutoPtr::operator<=( + /* [in] */ T* other) const +{ + return mPtr <= other; +} + +template +bool AutoPtr::operator<=( + /* [in] */ const AutoPtr& other) const +{ + return mPtr <= other.mPtr; +} + +template +bool AutoPtr::operator>=( + /* [in] */ T* other) const +{ + return mPtr >= other; +} + +template +bool AutoPtr::operator>=( + /* [in] */ const AutoPtr& other) const +{ + return mPtr >= other.mPtr; +} + +} +} + +#endif // OHOS_ZIDL_AUTOPTR_H diff --git a/zidl/util/file.cpp b/zidl/util/file.cpp new file mode 100644 index 00000000000..1bba24f9127 --- /dev/null +++ b/zidl/util/file.cpp @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "util/file.h" + +#include +#include +#include "securec.h" + +namespace OHOS { +namespace Zidl { + +#ifdef __MINGW32__ +constexpr unsigned int File::READ; +constexpr unsigned int File::WRITE; +constexpr unsigned int File::APPEND; +#endif + +File::File( + /* [in] */ const String& path, + /* [in] */ int mode) + : mode_(mode) +{ + if (path.IsEmpty()) { + return; + } + + if (mode_ & READ) { + fd_ = fopen(path.string(), "r"); + } else if (mode_ & WRITE) { + fd_ = fopen(path.string(), "w+"); + } else if (mode_ & APPEND) { + fd_ = fopen(path.string(), "a+"); + } + + if (fd_ != nullptr) { +#ifndef __MINGW32__ + char* absolutePath = realpath(path.string(), nullptr); + if (absolutePath != nullptr) { + path_ = absolutePath; + + free(absolutePath); + + } else { + path_ = path; + } +#else + char absolutePath[_MAX_PATH]; + _fullpath(absolutePath, path.string(), _MAX_PATH); + path_ = absolutePath; +#endif + } +} + +File::~File() +{ + Close(); +} + +char File::GetChar() +{ + char c = PeekChar(); + + if (position_ + 1 <= size_) { + position_++; + + if (c != '\n') { + columnNo_++; + } else { + columnNo_ = 0; + lineNo_++; + } + } + return c; +} + +char File::PeekChar() +{ + if (position_ + 1 > size_) { + int ret = Read(); + if (ret == -1) { + isEof_ = true; + } + } + + return buffer_[position_]; +} + +bool File::IsEof() const +{ + return isEof_ || buffer_[position_] == static_cast(-1); +} + +int File::Read() +{ + if (isEof_ || isError_) { + return -1; + } + + (void)memset_s(buffer_, BUFFER_SIZE, 0, BUFFER_SIZE); + size_t count = fread(buffer_, 1, BUFFER_SIZE - 1, fd_); + if (count < BUFFER_SIZE - 1) { + isError_ = ferror(fd_) != 0; + buffer_[count] = -1; + } + size_ = count; + position_ = 0; + return count != 0 ? count : -1; +} + +bool File::ReadData( + /* [out] */ void* data, + /* [in] */ size_t size) +{ + if (data == nullptr || size == 0) { + return true; + } + + if (fd_ == nullptr) { + return false; + } + + size_t count = fread(data, size, 1, fd_); + return count == 1; +} + +bool File::WriteData( + /* [in] */ const void* data, + /* [in] */ size_t size) +{ + if (data == nullptr || size == 0) { + return true; + } + + if (fd_ == nullptr || !(mode_ & (WRITE | APPEND))) { + return false; + } + + size_t count = fwrite(data, size, 1, fd_); + return count == 1; +} + +void File::Flush() +{ + if ((mode_ & (WRITE | APPEND)) && fd_ != nullptr) { + fflush(fd_); + } +} + +bool File::Reset() +{ + if (fd_ == nullptr) { + return false; + } + + return fseek(fd_, 0, SEEK_SET) == 0; +} + +bool File::Skip( + /* [in] */ long size) +{ + if (fd_ == nullptr) { + return false; + } + + return fseek(fd_, size, SEEK_CUR) == 0; +} + +void File::Close() +{ + if (fd_ != nullptr) { + fclose(fd_); + fd_ = nullptr; + } +} + +} +} diff --git a/zidl/util/file.h b/zidl/util/file.h new file mode 100644 index 00000000000..1f5f3acc7bf --- /dev/null +++ b/zidl/util/file.h @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_FILE_H +#define OHOS_ZIDL_FILE_H + +#include +#include + +#include "util/string.h" + +namespace OHOS { +namespace Zidl { + +class File { +public: + File( + /* [in] */ const String& path, + /* [in] */ int mode); + + ~File(); + + inline bool IsValid() + { + return fd_ != nullptr; + } + + inline String GetPath() + { + return path_; + } + + char GetChar(); + + char PeekChar(); + + bool IsEof() const; + + inline int GetCharLineNumber() const + { + return lineNo_; + } + + inline int GetCharColumnNumber() const + { + return columnNo_; + } + + bool ReadData( + /* [out] */ void* data, + /* [in] */ size_t size); + + bool WriteData( + /* [in] */ const void* data, + /* [in] */ size_t size); + + void Flush(); + + bool Reset(); + + bool Skip( + /* [in] */ long size); + + void Close(); + + static constexpr unsigned int READ = 0x1; + static constexpr unsigned int WRITE = 0x2; + static constexpr unsigned int APPEND = 0x4; + +private: + int Read(); + + static constexpr int BUFFER_SIZE = 1024; + + char buffer_[BUFFER_SIZE] = {0}; + size_t size_ = 0; + size_t position_ = 0; + size_t columnNo_ = 1; + size_t lineNo_ = 1; + bool isEof_ = false; + bool isError_ = false; + + FILE* fd_ = nullptr; + String path_; + unsigned int mode_ = 0; +}; + +} +} + +#endif // OHOS_ZIDL_STRING_H diff --git a/zidl/util/light_refcount_base.cpp b/zidl/util/light_refcount_base.cpp new file mode 100644 index 00000000000..fb0bedd02ae --- /dev/null +++ b/zidl/util/light_refcount_base.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "util/light_refcount_base.h" + +namespace OHOS { +namespace Zidl { + +int LightRefCountBase::AddRef() +{ + const int beforeCount = refCount_.fetch_add(1, std::memory_order_relaxed); + return beforeCount + 1; +} + +int LightRefCountBase::Release() +{ + const int beforeCount = refCount_.fetch_sub(1, std::memory_order_release); + if (beforeCount - 1 == 0) { + delete this; + } + return beforeCount - 1; +} + +} +} diff --git a/zidl/util/light_refcount_base.h b/zidl/util/light_refcount_base.h new file mode 100644 index 00000000000..55df3d3ece2 --- /dev/null +++ b/zidl/util/light_refcount_base.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_LIGHTREFCOUNTBASE_H +#define OHOS_ZIDL_LIGHTREFCOUNTBASE_H + +#include + +namespace OHOS { +namespace Zidl { + +class LightRefCountBase { +public: + inline LightRefCountBase() + : refCount_(0) + {} + + int AddRef(); + + int Release(); + + inline int GetRefCount() const + { + return refCount_.load(std::memory_order_relaxed); + } + +protected: + inline virtual ~LightRefCountBase() + {} + +private: + std::atomic refCount_; +}; + +} +} + +#endif // OHOS_ZIDL_LIGHTREFCOUNTBASE_H diff --git a/zidl/util/logger.cpp b/zidl/util/logger.cpp new file mode 100644 index 00000000000..acc50e1edb3 --- /dev/null +++ b/zidl/util/logger.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "util/logger.h" + +#include + +namespace OHOS { +namespace Zidl { + +int Logger::level_ = DEBUG; + +void Logger::D( + /* [in] */ const char* tag, + /* [in] */ const char* format, ...) +{ + if (level_ > DEBUG) return; + + va_list args; + va_start(args, format); + Log(tag, format, args); + va_end(args); +} + +void Logger::E( + /* [in] */ const char* tag, + /* [in] */ const char* format, ...) +{ + if (level_ > ERROR) return; + + va_list args; + va_start(args, format); + Err(tag, format, args); + va_end(args); +} + +void Logger::V( + /* [in] */ const char* tag, + /* [in] */ const char* format, ...) +{ + if (level_ > VERBOSE) return; + + va_list args; + va_start(args, format); + Log(tag, format, args); + va_end(args); +} + +void Logger::Log( + /* [in] */ const char* tag, + /* [in] */ const char* format, + /* [in] */ va_list args) +{ + printf("[%s]: ", tag); + vprintf(format, args); + printf("\n"); +} + +void Logger::Err( + /* [in] */ const char* tag, + /* [in] */ const char* format, + /* [in] */ va_list args) +{ + fprintf(stderr, "[%s]: ", tag); + vfprintf(stderr, format, args); + fprintf(stderr, "\n"); +} + +} +} diff --git a/zidl/util/logger.h b/zidl/util/logger.h new file mode 100644 index 00000000000..f31a20ad9a6 --- /dev/null +++ b/zidl/util/logger.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_LOGGER_H +#define OHOS_ZIDL_LOGGER_H + +#include + +namespace OHOS { +namespace Zidl { + +class Logger { +public: + static void D( + /* [in] */ const char* tag, + /* [in] */ const char* format, ...); + + static void E( + /* [in] */ const char* tag, + /* [in] */ const char* format, ...); + + static void V( + /* [in] */ const char* tag, + /* [in] */ const char* format, ...); + + inline static void SetLevel( + /* [in] */ int level) + { + level_ = level; + } + + static constexpr int VERBOSE = 0; + static constexpr int DEBUG = 1; + static constexpr int ERROR = 2; + static constexpr int NOLOG = 3; + +private: + Logger(); + + ~Logger(); + + static void Log( + /* [in] */ const char* tag, + /* [in] */ const char* format, + /* [in] */ va_list args); + + static void Err( + /* [in] */ const char* tag, + /* [in] */ const char* format, + /* [in] */ va_list args); + + static int level_; +}; + +} +} + +#endif // OHOS_ZIDL_LOGGER_H diff --git a/zidl/util/options.cpp b/zidl/util/options.cpp new file mode 100644 index 00000000000..1d210eac978 --- /dev/null +++ b/zidl/util/options.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "options.h" +#include "util/string_builder.h" + +#include +#include + +namespace OHOS { +namespace Zidl { + +void Options::Parse( + /* [in] */ int argc, + /* [in] */ char** argv) +{ + StringBuilder errors; + program_ = argv[0]; + + int i = 1; + while (i < argc) { + String option(argv[i++]); + if (option.Equals("--help")) { + doShowUsage_ = true; + } else if (option.Equals("--version")) { + doShowVersion_ = true; + } else if (option.Equals("-c")) { + doCompile_ = true; + } else if (option.Equals("-dump-ast")) { + doDumpAST_ = true; + } else if (option.Equals("-dump-metadata")) { + doDumpMetadata_ = true; + } else if (option.Equals("-s")) { + doSaveMetadata_ = true; + metadataFile_ = argv[i++]; + } else if (option.Equals("-gen-cpp")) { + doGenerateCode_ = true; + targetLanguage_ = "cpp"; + } else if (option.Equals("-gen-java")) { + doGenerateCode_ = true; + targetLanguage_ = "java"; + } else if (option.Equals("-gen-js")) { + doGenerateCode_ = true; + targetLanguage_ = "js"; + }else if (option.Equals("-d")) { + generationDirectory_ = argv[i++]; + } else if (!option.StartsWith("-")) { + sourceFile_ = option; + } else { + errors.Append(option); + errors.Append(" "); + } + } + + illegalOptions_ = errors.ToString(); +} + +void Options::ShowErrors() +{ + if (!illegalOptions_.IsEmpty()) { + String options = illegalOptions_; + int index; + while ((index = options.IndexOf(' ')) != -1) { + printf("The Option \"%s\" is illegal.\n", options.Substring(0, index).string()); + options = options.Substring(index + 1); + } + } + printf("Use \"--help\" to show usage.\n"); +} + +void Options::ShowVersion() +{ + printf("zidl %d.%d\n" + "Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved.\n\n", + VERSION_MAJOR, VERSION_MINOR); +} + +void Options::ShowUsage() +{ + printf("Compile a .zidl file and generate metadata, or generate C++ and Java codes from metadata.\n" + "Usage: zidl [options] file\n" + "Options:\n" + " --help Display command line options\n" + " --version Display toolchain version information\n" + " -dump-ast Display the AST of the compiled file\n" + " -dump-metadata Display the metadata generated from the compiled file\n" + " -c Compile the .zidl file\n" + " -s Place the metadata into \n" + " -gen-cpp Generate C++ codes\n" + " -gen-java Generate Java codes\n" + " -gen-js Generate Js codes\n" + " -d Place generated codes into \n"); +} + +} +} diff --git a/zidl/util/options.h b/zidl/util/options.h new file mode 100644 index 00000000000..9d7895052ef --- /dev/null +++ b/zidl/util/options.h @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_OPTIONS_H +#define OHOS_ZIDL_OPTIONS_H + +#include "util/string.h" + +namespace OHOS { +namespace Zidl { + +class Options { +public: + inline Options( + /* [in] */ int argc, + /* [in] */ char** argv) + { + Parse(argc, argv); + } + + ~Options() = default; + + inline bool DoShowUsage() const + { + return doShowUsage_; + } + + inline bool DoShowVersion() const + { + return doShowVersion_; + } + + inline bool DoCompile() const + { + return doCompile_; + } + + inline bool DoDumpAST() const + { + return doDumpAST_; + } + + inline bool DoDumpMetadata() const + { + return doDumpMetadata_; + } + + inline bool DoSaveMetadata() const + { + return doSaveMetadata_; + } + + inline bool DoGenerateCode() const + { + return doGenerateCode_; + } + + inline bool HasErrors() const + { + return !illegalOptions_.IsEmpty() || sourceFile_.IsEmpty(); + } + + inline String GetSourceFile() const + { + return sourceFile_; + } + + inline String GetMetadataFile() const + { + return metadataFile_; + } + + inline String GetTargetLanguage() const + { + return targetLanguage_; + } + + inline String GetGenerationDirectory() const + { + return generationDirectory_; + } + + void ShowErrors(); + + void ShowVersion(); + + void ShowUsage(); + +private: + void Parse( + /* [in] */ int argc, + /* [in] */ char** argv); + + static constexpr int VERSION_MAJOR = 0; + static constexpr int VERSION_MINOR = 1; + + String program_; + String sourceFile_; + String metadataFile_; + String targetLanguage_; + String generationDirectory_; + String illegalOptions_; + + bool doShowUsage_ = false; + bool doShowVersion_ = false; + bool doCompile_ = false; + bool doDumpAST_ = false; + bool doDumpMetadata_ = false; + bool doSaveMetadata_ = false; + bool doGenerateCode_ = false; +}; + +} +} + +#endif // OHOS_ZIDL_OPTIONS_H diff --git a/zidl/util/string.cpp b/zidl/util/string.cpp new file mode 100644 index 00000000000..d640223f146 --- /dev/null +++ b/zidl/util/string.cpp @@ -0,0 +1,720 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "util/string.h" +#include "util/string_builder.h" +#include +#include +#include +#include +#include +#include +#include +#include "securec.h" + +#include "util/logger.h" + +namespace OHOS { +namespace Zidl { +constexpr int LINE_MAX_SIZE = 1024; + +using SharedData = struct SharedData { + SharedData( + /* [in] */ int refCount, + /* [in] */ int size) + : refCount_(refCount), size_(size) + {} + + static SharedData* Allocate( + /* [in] */ int size); + + static void AddRef( + /* [in] */ const void* handle); + + static void Release( + /* [in] */ const void* handle); + + inline static char* ToString( + /* [in] */ SharedData* header) + { + return reinterpret_cast(header + 1); + } + + inline static SharedData* GetHeader( + /* [in] */ const void* handle) + { + return reinterpret_cast(const_cast(handle)) - 1; + } + + std::atomic refCount_; + int size_; +}; + +SharedData* SharedData::Allocate( + /* [in] */ int size) +{ + if (size < 0) { + Logger::E(String::TAG, "Size %d is illegal.", size); + return nullptr; + } + if (size > String::MAX_SIZE) { + Logger::E(String::TAG, "The string is too large to alloc."); + return nullptr; + } + + SharedData* handle = reinterpret_cast(malloc(sizeof(SharedData) + size + 1)); + if (handle == nullptr) { + Logger::E(String::TAG, "Fail to malloc %lu bytes memory", size); + return handle; + } + + new (handle)SharedData(1, size); + return handle; +} + +void SharedData::AddRef( + /* [in] */ const void* handle) +{ + if (handle == nullptr) { + return; + } + + SharedData* data = GetHeader(handle); + int before = data->refCount_.fetch_add(1); + if (before + 1 <= 1) { + Logger::E(String::TAG, "The refCount %d of %p is error in AddRef.", before, data); + }; +} + +void SharedData::Release( + /* [in] */ const void* handle) +{ + if (handle == nullptr) { + return; + } + + SharedData* data = GetHeader(handle); + int before = data->refCount_.fetch_sub(1); + if (before - 1 == 0) { + free(data); + } else if (before - 1 < 0) { + Logger::E(String::TAG, "The refCount %d of %p is error in Release.", before - 1, data); + }; +} + + +const char* String::TAG = "String"; + +String::String( + /* [in] */ const char* string) +{ + if (string != nullptr) { + string_ = SharedData::ToString(SharedData::Allocate(strlen(string))); + if (string_ != nullptr) { + (void)strcpy_s(string_, strlen(string) + 1, string); + } + } +} + +String::String( + /* [in] */ const char* string, + /* [in] */ size_t length) +{ + if (string != nullptr) { + string_ = SharedData::ToString(SharedData::Allocate(length)); + if (string_ != nullptr) { + errno_t ret = memcpy_s(string_, length + 1, string, length); + if (ret == EOK) { + string_[length] = '\0'; + } else { + free(string_); + string_ = nullptr; + } + } + } +} + +String::String( + /* [in] */ const String& other) +{ + string_ = other.string_; + SharedData::AddRef(string_); +} + +String::String( + /* [in] */ String&& other) +{ + string_ = other.string_; + other.string_ = nullptr; +} + +String::String( + /* [in] */ int size) +{ + string_ = SharedData::ToString(SharedData::Allocate(size)); + if (string_ != nullptr) { + (void)memset_s(string_, size + 1, 0, size + 1); + } +} + +String::~String() +{ + SharedData::Release(string_); +} + +int String::GetLength() const +{ + if (string_ == nullptr) { + return 0; + } + + return SharedData::GetHeader(string_)->size_; +} + +char String::operator[]( + /* [in] */ int index) const +{ + if (index < 0 || index >= GetLength()) { + return '\0'; + } + return string_[index]; +} + +bool String::Equals( + /* [in] */ const char* string) const +{ + if (string_ == nullptr && string == nullptr) { + return true; + } + + if (string != nullptr && string_ != nullptr) { + if ((size_t)GetLength() != strlen(string)) { + return false; + } + return strcmp(string, string_) == 0; + } + + return false; +} + +bool String::Equals( + /* [in] */ const String& other) const +{ + if (string_ == nullptr && other.string_ == nullptr) { + return true; + } + + if (string_ != nullptr && other.string_ != nullptr) { + if (GetLength() != other.GetLength()) { + return false; + } + return strcmp(string_, other.string_) == 0; + } + return false; +} + +int String::GetHashCode() const +{ + // BKDR Hash Function + unsigned int seed = 31; // 31 131 1313 13131 131313 etc.. + unsigned int hash = 0; + + const char* string = string_; + if (string != nullptr) { + for ( ; *string; ++string) { + hash = hash * seed + (*string); + } + } + return (hash & 0x7FFFFFFF); +} + +int String::IndexOf( + /* [in] */ char c, + /* [in] */ int fromIndex) const +{ + if (IsEmpty() || c == '\0') { + return -1; + } + + if (fromIndex < 0) { + fromIndex = 0; + } else if (fromIndex >= GetLength()) { + return -1; + } + + char* p = string_ + fromIndex; + char* end = string_ + GetLength(); + while (p != end) { + if (*p == c) { + return p - string_; + } + p++; + } + return -1; +} + +int String::IndexOf( + /* [in] */ const char* string, + /* [in] */ int fromIndex) const +{ + if (IsEmpty() || string == nullptr || string[0] == '\0') { + return -1; + } + + if (fromIndex < 0) { + fromIndex = 0; + } else if (fromIndex >= GetLength()) { + return -1; + } + + char* c = strstr(string_ + fromIndex, string); + return c != nullptr ? c - string_ : -1; +} + +int String::IndexOf( + /* [in] */ const String& other, + /* [in] */ int fromIndex) const +{ + if (IsEmpty() || other.IsEmpty()) { + return -1; + } + + if (fromIndex < 0) { + fromIndex = 0; + } else if (fromIndex >= GetLength()) { + return -1; + } + + char* c = strstr(string_ + fromIndex, other.string_); + return c != nullptr ? c - string_ : -1; +} + +int String::LastIndexOf( + /* [in] */ char c, + /* [in] */ int fromIndex) const +{ + if (IsEmpty() || c == '\0') { + return -1; + } + + if (fromIndex < 0) { + return -1; + } else if (fromIndex == 0 || fromIndex >= GetLength()) { + fromIndex = GetLength() - 1; + } + char* p = string_ + fromIndex; + while (p != string_) { + if (*p == c) { + return p - string_; + } + p--; + } + return -1; +} + +int String::LastIndexOf( + /* [in] */ const char* string, + /* [in] */ int fromIndex) const +{ + if (IsEmpty() || string == nullptr || string[0] == '\0') { + return -1; + } + + if (fromIndex < 0) { + return -1; + } else if (fromIndex == 0 || fromIndex >= GetLength()) { + fromIndex = GetLength() - 1; + } + + return LastIndexOfInternal(string, fromIndex); +} + +int String::LastIndexOf( + /* [in] */ const String& other, + /* [in] */ int fromIndex) const +{ + if (IsEmpty() || other.IsEmpty()) { + return -1; + } + + if (fromIndex < 0) { + return -1; + } else if (fromIndex == 0 || fromIndex >= GetLength()) { + fromIndex = GetLength() - 1; + } + + return LastIndexOfInternal(other.string(), fromIndex); +} + +int String::LastIndexOfInternal( + /* [in] */ const char* string, + /* [in] */ int fromIndex) const +{ + int sourceLen = GetLength(); + int stringLen = strlen(string); + int rightIndex = sourceLen - stringLen; + if (fromIndex > rightIndex) { + fromIndex = rightIndex; + } + + int stringLastIndex = stringLen - 1; + char stringLastChar = string[stringLastIndex]; + int min = stringLen - 1; + int i = min + fromIndex; + +startSearchLastChar: + while (true) { + while (i >= min && string_[i] != stringLastChar) { + i--; + } + if (i < min) { + return -1; + } + int j = i - 1; + int start = j - (stringLen - 1); + int k = stringLastIndex - 1; + + while (j > start) { + if (string_[j--] != string[k--]) { + i--; + goto startSearchLastChar; + } + } + return start + 1; + } +} + +bool String::StartsWith( + /* [in] */ const char* string) const +{ + if (string == nullptr || string_ == nullptr) { + return false; + } + + if (string[0] == '\0' && string_[0] == '\0') { + return true; + } + + size_t count = strlen(string); + if (count > (size_t)GetLength()) { + return false; + } + + return memcmp(string_, string, count) == 0; +} + +bool String::StartsWith( + /* [in] */ const String& other) const +{ + if (other.string_ == nullptr || string_ == nullptr) { + return false; + } + + if (other.string_[0] == '\0' && string_[0] == '\0') { + return true; + } + + size_t count = other.GetLength(); + if (count > (size_t)GetLength()) { + return false; + } + + return memcmp(string_, other.string_, count) == 0; +} + +bool String::EndsWith( + /* [in] */ const char* string) const +{ + if (string == nullptr || string_ == nullptr) { + return false; + } + + if (string[0] == '\0') { + return true; + } + + size_t count = strlen(string); + size_t len = GetLength(); + if (count > len) { + return false; + } + + return memcmp(string_ + len - count, string, count) == 0; +} + +bool String::EndsWith( + /* [in] */ const String& other) const +{ + if (other.string_ == nullptr || string_ == nullptr) { + return false; + } + + if (other.string_[0] == '\0') { + return true; + } + + size_t count = other.GetLength(); + size_t len = GetLength(); + if (count > len) { + return false; + } + + return memcmp(string_ + len - count, other.string_, count) == 0; +} + +String String::ToLowerCase() const +{ + if (IsEmpty()) { + return *this; + } + + size_t size = GetLength(); + for (size_t i = 0; i < size; i++) { + if (isupper(string_[i])) { + String newStr(string_); + for (size_t j = i; j < size; j++) { + newStr.string_[j] = tolower(newStr.string_[j]); + } + return newStr; + } + } + return *this; +} + +String String::ToUpperCase() const +{ + if (IsEmpty()) { + return *this; + } + + size_t size = GetLength(); + for (size_t i = 0; i < size; i++) { + if (islower(string_[i])) { + String newStr(string_); + for (size_t j = i; j < size; j++) { + newStr.string_[j] = toupper(newStr.string_[j]); + } + return newStr; + } + } + return *this; +} + +String String::Substring( + /* [in] */ int begin) const +{ + if (begin < 0 || begin >= GetLength()) { + return String(); + } + + return String(string_ + begin); +} + +String String::Substring( + /* [in] */ int begin, + /* [in] */ int end) const +{ + if (begin < 0 || end > GetLength() || begin > end) { + return String(); + } + + return String(string_ + begin, end - begin); +} + +String String::Replace( + /* [in] */ char oldChar, + /* [in] */ char newChar) const +{ + if (oldChar == newChar) { + return *this; + } + + size_t size = GetLength(); + for (size_t i = 0; i < size; i++) { + if (string_[i] == oldChar) { + String newStr(string_); + for (size_t j = i; j < size; j++) { + if (newStr.string_[j] == oldChar) { + newStr.string_[j] = newChar; + } + } + return newStr; + } + } + return *this; +} + +String String::Replace( + /* [in] */ const char* target, + /* [in] */ const char* replacement) const +{ + if (target == nullptr || target[0] == '\0' || replacement == nullptr) { + return *this; + } + + int index = IndexOf(target); + if (index == -1) { + return *this; + } + + StringBuilder sb; + int begin = 0; + int step = strlen(target); + while (index != -1) { + sb.Append(Substring(begin, index)); + sb.Append(replacement); + begin = index + step; + index = IndexOf(target, begin); + } + sb.Append(Substring(begin)); + return sb.ToString(); +} + +String String::Replace( + /* [in] */ const String& target, + /* [in] */ const String& replacement) const +{ + if (target.IsEmpty() || replacement.IsNull()) { + return *this; + } + + int index = IndexOf(target); + if (index== -1) { + return *this; + } + + StringBuilder sb; + int begin = 0; + int step = target.GetLength(); + while (index != -1) { + sb.Append(Substring(begin, index)); + sb.Append(replacement); + begin = index + step; + index = IndexOf(target, begin); + } + sb.Append(Substring(begin)); + return sb.ToString(); +} + +String& String::operator=( + /* [in] */ const char* string) +{ + SharedData::Release(string_); + + if (string == nullptr) { + string_ = nullptr; + return *this; + } + + string_ = SharedData::ToString(SharedData::Allocate(strlen(string))); + if (string_ != nullptr) { + (void)strcpy_s(string_, strlen(string) + 1, string); + } + return *this; +} + +String& String::operator=( + /* [in] */ const String& other) +{ + if (string_ == other.string_) { + return *this; + } + + SharedData::Release(string_); + SharedData::AddRef(other.string_); + string_ = other.string_; + return *this; +} + +String& String::operator=( + /* [in] */ String&& other) +{ + SharedData::Release(string_); + string_ = other.string_; + other.string_ = nullptr; + return *this; +} + +String String::operator+=( + /* [in] */ const char* string) const +{ + if (string == nullptr || string[0] == '\0') { + return *this; + } + + int thisSize = GetLength(); + int newSize = thisSize + strlen(string); + String newString(newSize); + if (newString.string_ != nullptr) { + (void)memcpy_s(newString.string_, newSize + 1, string_, thisSize); + (void)strcpy_s(newString.string_ + thisSize, newSize + 1 - thisSize, string); + } + return newString; +} + +String String::operator+=( + /* [in] */ const String& other) const +{ + if (other.IsEmpty()) { + return *this; + } + + int thisSize = GetLength(); + int newSize = thisSize + other.GetLength(); + String newString(newSize); + if (newString.string_ != nullptr) { + (void)memcpy_s(newString.string_, newSize + 1, string_, thisSize); + (void)strcpy_s(newString.string_ + thisSize, newSize + 1 - thisSize, other.string_); + } + return newString; +} + +String String::Format( + /* [in] */ const char* format, ...) +{ + va_list args, argsCopy; + + va_start(args, format); + va_copy(argsCopy, args); + + char buf[LINE_MAX_SIZE] = {0}; + int len = vsnprintf_s(buf, LINE_MAX_SIZE, LINE_MAX_SIZE - 1, format, args); + String string; + if (len <= 0) { + va_end(args); + va_end(argsCopy); + return string; + } + + string = String(len); + if (string.string_ == nullptr) { + va_end(args); + va_end(argsCopy); + return string; + } + + if (vsnprintf_s(string.string_, len + 1, len, format, argsCopy) < 0) { + va_end(args); + va_end(argsCopy); + return string; + } + + va_end(args); + va_end(argsCopy); + return string; +} + +} +} diff --git a/zidl/util/string.h b/zidl/util/string.h new file mode 100644 index 00000000000..d0f3250315b --- /dev/null +++ b/zidl/util/string.h @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_STRING_H +#define OHOS_ZIDL_STRING_H + +#include + +namespace OHOS { +namespace Zidl { + +class String { +public: + inline String() + {} + + String( + /* [in] */ const char* string); + + String( + /* [in] */ const char* string, + /* [in] */ size_t length); + + String( + /* [in] */ const String& other); + + String( + /* [in] */ String&& other); + + ~String(); + + inline const char* string() const + { + return string_; + } + + inline operator const char*() const + { + return string_; + } + + inline bool IsNull() const + { + return string_ == nullptr; + } + + inline bool IsEmpty() const + { + return string_ == nullptr || string_[0] == '\0'; + } + + int GetLength() const; + + char operator[]( + /* [in] */ int index) const; + + bool Equals( + /* [in] */ const char* string) const; + + bool Equals( + /* [in] */ const String& other) const; + + int GetHashCode() const; + + int IndexOf( + /* [in] */ char c, + /* [in] */ int fromIndex = 0) const; + + int IndexOf( + /* [in] */ const char* string, + /* [in] */ int fromIndex = 0) const; + + int IndexOf( + /* [in] */ const String& other, + /* [in] */ int fromIndex = 0) const; + + int LastIndexOf( + /* [in] */ char c, + /* [in] */ int fromIndex = 0) const; + + int LastIndexOf( + /* [in] */ const char* string, + /* [in] */ int fromIndex = 0) const; + + int LastIndexOf( + /* [in] */ const String& other, + /* [in] */ int fromIndex = 0) const; + + bool StartsWith( + /* [in] */ const char* string) const; + + bool StartsWith( + /* [in] */ const String& other) const; + + bool EndsWith( + /* [in] */ const char* string) const; + + bool EndsWith( + /* [in] */ const String& other) const; + + String ToLowerCase() const; + + String ToUpperCase() const; + + String Substring( + /* [in] */ int begin) const; + + String Substring( + /* [in] */ int begin, + /* [in] */ int end) const; + + String Replace( + /* [in] */ char oldChar, + /* [in] */ char newChar) const; + + String Replace( + /* [in] */ const char* target, + /* [in] */ const char* replacement) const; + + String Replace( + /* [in] */ const String& target, + /* [in] */ const String& replacement) const; + + String& operator=( + /* [in] */ const char* string); + + String& operator=( + /* [in] */ const String& other); + + String& operator=( + /* [in] */ String&& other); + + String operator+=( + /* [in] */ const char* string) const; + + String operator+=( + /* [in] */ const String& other) const; + + static String Format( + /* [in] */ const char* format, ...); + + static const char* TAG; + static constexpr int MAX_SIZE = 262144; // 2^18 + +private: + String( + /* [in] */ int size); + + int LastIndexOfInternal( + /* [in] */ const char* string, + /* [in] */ int fromIndex) const; + + char* string_ = nullptr; +}; + +inline String operator+( + /* [in] */ const String& string1, + /* [in] */ const char* string2) +{ + return string1 += string2; +} + +struct StringHashFunc { + int operator()(const String& key) const + { + return key.GetHashCode(); + } +}; + +struct StringEqualFunc { + bool operator()(const String& lhs, const String& rhs) const + { + return lhs.Equals(rhs); + } +}; + +} +} + +#endif // OHOS_ZIDL_STRING_H diff --git a/zidl/util/string_builder.cpp b/zidl/util/string_builder.cpp new file mode 100644 index 00000000000..e2caea4b583 --- /dev/null +++ b/zidl/util/string_builder.cpp @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "util/string_builder.h" + +#include +#include +#include +#include "securec.h" + +#include "util/logger.h" + +namespace OHOS { +namespace Zidl { + +const char* StringBuilder::TAG = "StringBuilder"; +constexpr int LINE_MAX_SIZE = 1024; + +StringBuilder::~StringBuilder() +{ + if (buffer_ != nullptr) { + free(buffer_); + } +} + +StringBuilder& StringBuilder::Append( + /* [in] */ char c) +{ + if (position_ + 1 >= capacity_) { + if (!Grow(1)) { + return *this; + } + } + + buffer_[position_] = c; + position_ += 1; + return *this; +} + +StringBuilder& StringBuilder::Append( + /* [in] */ const char* string) +{ + if (string == nullptr || string[0] == '\0') { + return *this; + } + + size_t len = strlen(string); + if (position_ + len >= capacity_) { + if (!Grow(len)) { + return *this; + } + } + + (void)memcpy_s(buffer_ + position_, capacity_ - position_, string, len); + position_ += len; + return *this; +} + +StringBuilder& StringBuilder::Append( + /* [in] */ const String& string) +{ + if (string.IsEmpty()) { + return *this; + } + + size_t len = string.GetLength(); + if (position_ + len >= capacity_) { + if (!Grow(len)) { + return *this; + } + } + + (void)memcpy_s(buffer_ + position_, capacity_ - position_, string.string(), len); + position_ += len; + return *this; +} + +StringBuilder& StringBuilder::AppendFormat( + /* [in] */ const char* format, ...) +{ + va_list args, argsCopy; + + va_start(args, format); + va_copy(argsCopy, args); + + char buf[LINE_MAX_SIZE] = {0}; + int len = vsnprintf_s(buf, LINE_MAX_SIZE, LINE_MAX_SIZE - 1, format, args); + if (len <= 0) { + va_end(args); + va_end(argsCopy); + return *this; + } + + if (position_ + len >= capacity_) { + if (!Grow(len)) { + va_end(args); + va_end(argsCopy); + return *this; + } + } + + if (vsnprintf_s(buffer_ + position_, len + 1, len, format, argsCopy) < 0) { + va_end(args); + va_end(argsCopy); + return *this; + } + position_ += len; + va_end(args); + va_end(argsCopy); + + return *this; +} + +bool StringBuilder::Grow( + /* [in] */ size_t size) +{ + if (capacity_ > String::MAX_SIZE) { + Logger::E(TAG, "The StringBuilder is full."); + return false; + } + // 256->the default capacity. + size_t newSize = (capacity_ == 0 ? 256 : capacity_ * 2); + if (newSize < capacity_ + size) { + newSize = capacity_ + size; + } + if (newSize > String::MAX_SIZE) { + newSize = String::MAX_SIZE; + } + if (newSize <= capacity_) { + return false; + } + + char* newBuffer = reinterpret_cast(calloc(newSize, 1)); + if (newBuffer == nullptr) { + Logger::E(TAG, "Fail to malloc %lu bytes memory.", newSize); + return false; + } + + if (buffer_ != nullptr) { + errno_t ret = memcpy_s(newBuffer, newSize, buffer_, capacity_); + if (ret != EOK) { + free(newBuffer); + newBuffer = nullptr; + return false; + } + free(buffer_); + } + buffer_ = newBuffer; + capacity_ = newSize; + return true; +} + +String StringBuilder::ToString() const +{ + return String(buffer_, position_); +} + +} +} diff --git a/zidl/util/string_builder.h b/zidl/util/string_builder.h new file mode 100644 index 00000000000..54f4331d27c --- /dev/null +++ b/zidl/util/string_builder.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_STRINGBUILDER_H +#define OHOS_ZIDL_STRINGBUILDER_H + +#include "util/string.h" + +namespace OHOS { +namespace Zidl { + +class StringBuilder { +public: + ~StringBuilder(); + + StringBuilder& Append( + /* [in] */ char c); + + StringBuilder& Append( + /* [in] */ const char* string); + + StringBuilder& Append( + /* [in] */ const String& string); + + StringBuilder& AppendFormat( + /* [in] */ const char* format, ...); + + String ToString() const; + +private: + bool Grow( + /* [in] */ size_t size); + + static const char* TAG; + char* buffer_ = nullptr; + size_t position_ = 0; + size_t capacity_ = 0; +}; + +} +} + +#endif // OHOS_ZIDL_STRINGBUILDER_H diff --git a/zidl/util/string_pool.cpp b/zidl/util/string_pool.cpp new file mode 100644 index 00000000000..026bcffdeec --- /dev/null +++ b/zidl/util/string_pool.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "util/string_pool.h" +#include +#include "securec.h" +#include "util/logger.h" + +namespace OHOS { +namespace Zidl { + +const char* StringPool::TAG = "StringPool"; + +StringPool::StringPool() +{ + data_ = reinterpret_cast(calloc(1, dataCapacity_)); + if (data_ == nullptr) { + Logger::E(TAG, "Out of memory."); + } +} + +StringPool::~StringPool() +{ + if (data_ != nullptr) { + free(data_); + } +} + +void StringPool::Add( + /* [in] */ const String& string) +{ + if (string.IsEmpty() || stringOffsets_.find(string) != stringOffsets_.end()) { + return; + } + + ptrdiff_t offset = AddInternal(string); + if (offset != -1) { + stringOffsets_[string] = offset; + } +} + +ptrdiff_t StringPool::GetOffset( + /* [in] */ const String& string) +{ + return stringOffsets_[string]; +} + +ptrdiff_t StringPool::AddInternal( + /* [in] */ const String& string) +{ + if (!Grow(string.GetLength() + 1)) { + return -1; + } + + char* addr = data_ + dataOffset_; + (void)strcpy_s(addr, dataCapacity_ - dataOffset_, string.string()); + dataOffset_ += string.GetLength() + 1; + return addr - data_; +} + +bool StringPool::Grow( + /* [in] */ size_t expand) +{ + size_t newSize = dataOffset_ + expand; + if (newSize < dataCapacity_) { + return true; + } + // 3->3x capacity expansion + size_t step = dataCapacity_ * 3; + newSize = step > newSize ? step : step + newSize; + char* newData = reinterpret_cast(calloc(1, newSize)); + if (newData == nullptr) { + Logger::E(TAG, "Out of memory."); + return false; + } + errno_t ret = memcpy_s(newData, newSize, data_, dataOffset_); + if (ret != EOK) { + free(newData); + newData = nullptr; + return false; + } + free(data_); + data_ = newData; + dataCapacity_ = newSize; + return true; +} + +} +} diff --git a/zidl/util/string_pool.h b/zidl/util/string_pool.h new file mode 100644 index 00000000000..7b991512c4c --- /dev/null +++ b/zidl/util/string_pool.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ZIDL_STRINGPOOL_H +#define OHOS_ZIDL_STRINGPOOL_H + +#include +#include "util/string.h" + +namespace OHOS { +namespace Zidl { + +class StringPool { +public: + StringPool(); + + ~StringPool(); + + void Add( + /* [in] */ const String& string); + + ptrdiff_t GetOffset( + /* [in] */ const String& string); + + inline size_t GetSize() + { + return dataOffset_; + } + + inline char* GetData() + { + return data_; + } + +private: + ptrdiff_t AddInternal( + /* [in] */ const String& string); + + bool Grow( + /* [in] */ size_t expand); + + static const char* TAG; + char* data_ = nullptr; + size_t dataCapacity_ = 256; + ptrdiff_t dataOffset_ = 0; + std::unordered_map stringOffsets_; +}; + +} +} + +#endif // OHOS_ZIDL_STRINGPOOL_H -- Gitee From 8d8f31508abdda8d62639ab825fd679d5091db95 Mon Sep 17 00:00:00 2001 From: wanchengzhen Date: Tue, 15 Feb 2022 17:03:42 +0800 Subject: [PATCH 3/3] codex Signed-off-by: wanchengzhen --- zidl/BUILD.gn | 76 -- zidl/CMakeLists.txt | 43 - zidl/ast/CMakeLists.txt | 41 - zidl/ast/ast_array_type.cpp | 37 - zidl/ast/ast_array_type.h | 50 - zidl/ast/ast_boolean_type.cpp | 37 - zidl/ast/ast_boolean_type.h | 36 - zidl/ast/ast_byte_type.cpp | 37 - zidl/ast/ast_byte_type.h | 36 - zidl/ast/ast_char_type.cpp | 37 - zidl/ast/ast_char_type.h | 36 - zidl/ast/ast_double_type.cpp | 37 - zidl/ast/ast_double_type.h | 36 - zidl/ast/ast_float_type.cpp | 37 - zidl/ast/ast_float_type.h | 36 - zidl/ast/ast_integer_type.cpp | 37 - zidl/ast/ast_integer_type.h | 36 - zidl/ast/ast_interface_type.cpp | 95 -- zidl/ast/ast_interface_type.h | 95 -- zidl/ast/ast_list_type.cpp | 37 - zidl/ast/ast_list_type.h | 51 - zidl/ast/ast_long_type.cpp | 37 - zidl/ast/ast_long_type.h | 36 - zidl/ast/ast_map_type.cpp | 37 - zidl/ast/ast_map_type.h | 63 - zidl/ast/ast_method.cpp | 84 -- zidl/ast/ast_method.h | 92 -- zidl/ast/ast_module.cpp | 261 ---- zidl/ast/ast_module.h | 159 --- zidl/ast/ast_namespace.cpp | 117 -- zidl/ast/ast_namespace.h | 93 -- zidl/ast/ast_node.cpp | 36 - zidl/ast/ast_node.h | 38 - zidl/ast/ast_parameter.cpp | 46 - zidl/ast/ast_parameter.h | 86 -- zidl/ast/ast_sequenceable_type.cpp | 64 - zidl/ast/ast_sequenceable_type.h | 42 - zidl/ast/ast_short_type.cpp | 37 - zidl/ast/ast_short_type.h | 36 - zidl/ast/ast_string_type.cpp | 37 - zidl/ast/ast_string_type.h | 36 - zidl/ast/ast_type.cpp | 129 -- zidl/ast/ast_type.h | 83 -- zidl/ast/ast_void_type.cpp | 37 - zidl/ast/ast_void_type.h | 36 - zidl/bundle.json | 37 - zidl/codegen/CMakeLists.txt | 24 - zidl/codegen/code_emitter.cpp | 48 - zidl/codegen/code_emitter.h | 60 - zidl/codegen/code_generator.cpp | 95 -- zidl/codegen/code_generator.h | 52 - zidl/codegen/cpp_code_emitter.cpp | 1175 ---------------- zidl/codegen/cpp_code_emitter.h | 237 ---- zidl/codegen/java_code_emitter.cpp | 1178 ----------------- zidl/codegen/java_code_emitter.h | 241 ---- zidl/codegen/js_code_emitter.cpp | 1167 ---------------- zidl/codegen/js_code_emitter.h | 236 ---- zidl/main.cpp | 106 -- zidl/metadata/CMakeLists.txt | 24 - zidl/metadata/metadata.h | 124 -- zidl/metadata/metadata_builder.cpp | 502 ------- zidl/metadata/metadata_builder.h | 107 -- zidl/metadata/metadata_dumper.cpp | 299 ----- zidl/metadata/metadata_dumper.h | 78 -- zidl/metadata/metadata_reader.cpp | 80 -- zidl/metadata/metadata_reader.h | 38 - zidl/metadata/metadata_serializer.cpp | 242 ---- zidl/metadata/metadata_serializer.h | 112 -- zidl/parser/CMakeLists.txt | 22 - zidl/parser/lexer.cpp | 383 ------ zidl/parser/lexer.h | 127 -- zidl/parser/parser.cpp | 688 ---------- zidl/parser/parser.h | 108 -- zidl/parser/token.h | 65 - zidl/test/native/BUILD.gn | 69 - zidl/test/native/include/izidl_test_service.h | 36 - zidl/test/native/include/test_client.h | 34 - zidl/test/native/include/test_service.h | 36 - .../native/include/zidl_test_service_proxy.h | 48 - .../native/include/zidl_test_service_stub.h | 37 - zidl/test/native/src/main_client.cpp | 75 -- zidl/test/native/src/main_server.cpp | 31 - zidl/test/native/src/test_client.cpp | 65 - zidl/test/native/src/test_service.cpp | 64 - .../native/src/zidl_test_service_proxy.cpp | 64 - .../native/src/zidl_test_service_stub.cpp | 48 - zidl/test/zidlgen/IZidlTestService.zidl | 19 - zidl/test/zidlgen/zidl | Bin 216360 -> 0 bytes zidl/util/CMakeLists.txt | 27 - zidl/util/autoptr.h | 309 ----- zidl/util/file.cpp | 190 --- zidl/util/file.h | 103 -- zidl/util/light_refcount_base.cpp | 37 - zidl/util/light_refcount_base.h | 50 - zidl/util/logger.cpp | 82 -- zidl/util/logger.h | 70 - zidl/util/options.cpp | 108 -- zidl/util/options.h | 128 -- zidl/util/string.cpp | 720 ---------- zidl/util/string.h | 192 --- zidl/util/string_builder.cpp | 171 --- zidl/util/string_builder.h | 55 - zidl/util/string_pool.cpp | 101 -- zidl/util/string_pool.h | 64 - 104 files changed, 13373 deletions(-) delete mode 100644 zidl/BUILD.gn delete mode 100644 zidl/CMakeLists.txt delete mode 100644 zidl/ast/CMakeLists.txt delete mode 100644 zidl/ast/ast_array_type.cpp delete mode 100644 zidl/ast/ast_array_type.h delete mode 100644 zidl/ast/ast_boolean_type.cpp delete mode 100644 zidl/ast/ast_boolean_type.h delete mode 100644 zidl/ast/ast_byte_type.cpp delete mode 100644 zidl/ast/ast_byte_type.h delete mode 100644 zidl/ast/ast_char_type.cpp delete mode 100644 zidl/ast/ast_char_type.h delete mode 100644 zidl/ast/ast_double_type.cpp delete mode 100644 zidl/ast/ast_double_type.h delete mode 100644 zidl/ast/ast_float_type.cpp delete mode 100644 zidl/ast/ast_float_type.h delete mode 100644 zidl/ast/ast_integer_type.cpp delete mode 100644 zidl/ast/ast_integer_type.h delete mode 100644 zidl/ast/ast_interface_type.cpp delete mode 100644 zidl/ast/ast_interface_type.h delete mode 100644 zidl/ast/ast_list_type.cpp delete mode 100644 zidl/ast/ast_list_type.h delete mode 100644 zidl/ast/ast_long_type.cpp delete mode 100644 zidl/ast/ast_long_type.h delete mode 100644 zidl/ast/ast_map_type.cpp delete mode 100644 zidl/ast/ast_map_type.h delete mode 100644 zidl/ast/ast_method.cpp delete mode 100644 zidl/ast/ast_method.h delete mode 100644 zidl/ast/ast_module.cpp delete mode 100644 zidl/ast/ast_module.h delete mode 100644 zidl/ast/ast_namespace.cpp delete mode 100644 zidl/ast/ast_namespace.h delete mode 100644 zidl/ast/ast_node.cpp delete mode 100644 zidl/ast/ast_node.h delete mode 100644 zidl/ast/ast_parameter.cpp delete mode 100644 zidl/ast/ast_parameter.h delete mode 100644 zidl/ast/ast_sequenceable_type.cpp delete mode 100644 zidl/ast/ast_sequenceable_type.h delete mode 100644 zidl/ast/ast_short_type.cpp delete mode 100644 zidl/ast/ast_short_type.h delete mode 100644 zidl/ast/ast_string_type.cpp delete mode 100644 zidl/ast/ast_string_type.h delete mode 100644 zidl/ast/ast_type.cpp delete mode 100644 zidl/ast/ast_type.h delete mode 100644 zidl/ast/ast_void_type.cpp delete mode 100644 zidl/ast/ast_void_type.h delete mode 100644 zidl/bundle.json delete mode 100644 zidl/codegen/CMakeLists.txt delete mode 100644 zidl/codegen/code_emitter.cpp delete mode 100644 zidl/codegen/code_emitter.h delete mode 100644 zidl/codegen/code_generator.cpp delete mode 100644 zidl/codegen/code_generator.h delete mode 100644 zidl/codegen/cpp_code_emitter.cpp delete mode 100644 zidl/codegen/cpp_code_emitter.h delete mode 100644 zidl/codegen/java_code_emitter.cpp delete mode 100644 zidl/codegen/java_code_emitter.h delete mode 100644 zidl/codegen/js_code_emitter.cpp delete mode 100644 zidl/codegen/js_code_emitter.h delete mode 100644 zidl/main.cpp delete mode 100644 zidl/metadata/CMakeLists.txt delete mode 100644 zidl/metadata/metadata.h delete mode 100644 zidl/metadata/metadata_builder.cpp delete mode 100644 zidl/metadata/metadata_builder.h delete mode 100644 zidl/metadata/metadata_dumper.cpp delete mode 100644 zidl/metadata/metadata_dumper.h delete mode 100644 zidl/metadata/metadata_reader.cpp delete mode 100644 zidl/metadata/metadata_reader.h delete mode 100644 zidl/metadata/metadata_serializer.cpp delete mode 100644 zidl/metadata/metadata_serializer.h delete mode 100644 zidl/parser/CMakeLists.txt delete mode 100644 zidl/parser/lexer.cpp delete mode 100644 zidl/parser/lexer.h delete mode 100644 zidl/parser/parser.cpp delete mode 100644 zidl/parser/parser.h delete mode 100644 zidl/parser/token.h delete mode 100644 zidl/test/native/BUILD.gn delete mode 100644 zidl/test/native/include/izidl_test_service.h delete mode 100644 zidl/test/native/include/test_client.h delete mode 100644 zidl/test/native/include/test_service.h delete mode 100644 zidl/test/native/include/zidl_test_service_proxy.h delete mode 100644 zidl/test/native/include/zidl_test_service_stub.h delete mode 100644 zidl/test/native/src/main_client.cpp delete mode 100644 zidl/test/native/src/main_server.cpp delete mode 100644 zidl/test/native/src/test_client.cpp delete mode 100644 zidl/test/native/src/test_service.cpp delete mode 100644 zidl/test/native/src/zidl_test_service_proxy.cpp delete mode 100644 zidl/test/native/src/zidl_test_service_stub.cpp delete mode 100644 zidl/test/zidlgen/IZidlTestService.zidl delete mode 100644 zidl/test/zidlgen/zidl delete mode 100644 zidl/util/CMakeLists.txt delete mode 100644 zidl/util/autoptr.h delete mode 100644 zidl/util/file.cpp delete mode 100644 zidl/util/file.h delete mode 100644 zidl/util/light_refcount_base.cpp delete mode 100644 zidl/util/light_refcount_base.h delete mode 100644 zidl/util/logger.cpp delete mode 100644 zidl/util/logger.h delete mode 100644 zidl/util/options.cpp delete mode 100644 zidl/util/options.h delete mode 100644 zidl/util/string.cpp delete mode 100644 zidl/util/string.h delete mode 100644 zidl/util/string_builder.cpp delete mode 100644 zidl/util/string_builder.h delete mode 100644 zidl/util/string_pool.cpp delete mode 100644 zidl/util/string_pool.h diff --git a/zidl/BUILD.gn b/zidl/BUILD.gn deleted file mode 100644 index 3ff94170fda..00000000000 --- a/zidl/BUILD.gn +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - -import("//build/ohos.gni") - -config("zidl_config") { - include_dirs = [ - "./", - "//utils/native/base/include/", - ] -} - -common_sources = [ - "ast/ast_array_type.cpp", - "ast/ast_boolean_type.cpp", - "ast/ast_byte_type.cpp", - "ast/ast_char_type.cpp", - "ast/ast_double_type.cpp", - "ast/ast_float_type.cpp", - "ast/ast_integer_type.cpp", - "ast/ast_interface_type.cpp", - "ast/ast_list_type.cpp", - "ast/ast_long_type.cpp", - "ast/ast_map_type.cpp", - "ast/ast_method.cpp", - "ast/ast_module.cpp", - "ast/ast_namespace.cpp", - "ast/ast_node.cpp", - "ast/ast_parameter.cpp", - "ast/ast_sequenceable_type.cpp", - "ast/ast_short_type.cpp", - "ast/ast_string_type.cpp", - "ast/ast_type.cpp", - "ast/ast_void_type.cpp", -] - -common_sources += [ - "codegen/code_emitter.cpp", - "codegen/code_generator.cpp", - "codegen/cpp_code_emitter.cpp", - "codegen/java_code_emitter.cpp", - "codegen/js_code_emitter.cpp", -] - -common_sources += [ - "metadata/metadata_builder.cpp", - "metadata/metadata_dumper.cpp", - "metadata/metadata_reader.cpp", - "metadata/metadata_serializer.cpp", -] - -common_sources += [ - "parser/lexer.cpp", - "parser/parser.cpp", -] - -common_sources += [ - "util/file.cpp", - "util/light_refcount_base.cpp", - "util/logger.cpp", - "util/options.cpp", - "util/string.cpp", - "util/string_builder.cpp", - "util/string_pool.cpp", -] - -ohos_executable("zidl") { - sources = [ "main.cpp" ] - sources += common_sources - - configs = [ ":zidl_config" ] - - deps = [ "//utils/native/base:utilsecurec" ] - - part_name = "zidl" - subsystem_name = "aafwk" -} diff --git a/zidl/CMakeLists.txt b/zidl/CMakeLists.txt deleted file mode 100644 index 491e5326b8d..00000000000 --- a/zidl/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cmake_minimum_required(VERSION 2.8) - -project(zidl CXX) - -set(ZIDL_DIR ${CMAKE_SOURCE_DIR}) - -include_directories( - ${ZIDL_DIR}) - -add_subdirectory(ast) -add_subdirectory(codegen) -add_subdirectory(metadata) -add_subdirectory(parser) -add_subdirectory(util) - -set(SOURCES - main.cpp) - -set(LINK_LIBS - -Wl,--whole-archive - ast - codegen - metadata - parser - util - -Wl,--no-whole-archive) - -add_executable(zidl ${SOURCES}) -target_link_libraries(zidl - ${LINK_LIBS}) \ No newline at end of file diff --git a/zidl/ast/CMakeLists.txt b/zidl/ast/CMakeLists.txt deleted file mode 100644 index bfcd05c1053..00000000000 --- a/zidl/ast/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -include_directories( - ${ZIDL_DIR}) - -set(SOURCES - ast_array_type.cpp - ast_boolean_type.cpp - ast_byte_type.cpp - ast_char_type.cpp - ast_double_type.cpp - ast_float_type.cpp - ast_integer_type.cpp - ast_interface_type.cpp - ast_list_type.cpp - ast_long_type.cpp - ast_map_type.cpp - ast_method.cpp - ast_module.cpp - ast_namespace.cpp - ast_node.cpp - ast_parameter.cpp - ast_sequenceable_type.cpp - ast_short_type.cpp - ast_string_type.cpp - ast_type.cpp - ast_void_type.cpp) - -add_library(ast STATIC - ${SOURCES}) \ No newline at end of file diff --git a/zidl/ast/ast_array_type.cpp b/zidl/ast/ast_array_type.cpp deleted file mode 100644 index 01c08bfcbda..00000000000 --- a/zidl/ast/ast_array_type.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_array_type.h" - -namespace OHOS { -namespace Zidl { - -String ASTArrayType::GetSignature() -{ - return String::Format("[%s", elementType_->GetSignature().string()); -} - -bool ASTArrayType::IsArrayType() -{ - return true; -} - -String ASTArrayType::ToString() -{ - return String::Format("%s[]", elementType_->ToString().string()); -} - -} -} diff --git a/zidl/ast/ast_array_type.h b/zidl/ast/ast_array_type.h deleted file mode 100644 index 8dc4541a830..00000000000 --- a/zidl/ast/ast_array_type.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTARRAYTYPE_H -#define OHOS_ZIDL_ASTARRAYTYPE_H - -#include "ast/ast_type.h" - -namespace OHOS { -namespace Zidl { - -class ASTArrayType : public ASTType { -public: - inline void SetElementType( - /* [in] */ ASTType* elementType) - { - elementType_ = elementType; - } - - inline AutoPtr GetElementType() - { - return elementType_; - } - - String GetSignature() override; - - bool IsArrayType() override; - - String ToString() override; - -private: - AutoPtr elementType_; -}; - -} -} - -#endif // OHOS_ZIDL_ASTARRAYTYPE_H \ No newline at end of file diff --git a/zidl/ast/ast_boolean_type.cpp b/zidl/ast/ast_boolean_type.cpp deleted file mode 100644 index 011e51dc480..00000000000 --- a/zidl/ast/ast_boolean_type.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_boolean_type.h" - -namespace OHOS { -namespace Zidl { - -String ASTBooleanType::GetSignature() -{ - return "Z"; -} - -bool ASTBooleanType::IsBooleanType() -{ - return true; -} - -String ASTBooleanType::ToString() -{ - return "boolean"; -} - -} -} diff --git a/zidl/ast/ast_boolean_type.h b/zidl/ast/ast_boolean_type.h deleted file mode 100644 index bc411737587..00000000000 --- a/zidl/ast/ast_boolean_type.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTBOOLEANTYPE_H -#define OHOS_ZIDL_ASTBOOLEANTYPE_H - -#include "ast/ast_type.h" - -namespace OHOS { -namespace Zidl { - -class ASTBooleanType : public ASTType { -public: - String GetSignature() override; - - bool IsBooleanType() override; - - String ToString() override; -}; - -} -} - -#endif // OHOS_ZIDL_ASTBOOLEANTYPE_H diff --git a/zidl/ast/ast_byte_type.cpp b/zidl/ast/ast_byte_type.cpp deleted file mode 100644 index be3e84298b3..00000000000 --- a/zidl/ast/ast_byte_type.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_byte_type.h" - -namespace OHOS { -namespace Zidl { - -String ASTByteType::GetSignature() -{ - return "B"; -} - -bool ASTByteType::IsByteType() -{ - return true; -} - -String ASTByteType::ToString() -{ - return "byte"; -} - -} -} diff --git a/zidl/ast/ast_byte_type.h b/zidl/ast/ast_byte_type.h deleted file mode 100644 index 561fe580f89..00000000000 --- a/zidl/ast/ast_byte_type.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTBYTETYPE_H -#define OHOS_ZIDL_ASTBYTETYPE_H - -#include "ast/ast_type.h" - -namespace OHOS { -namespace Zidl { - -class ASTByteType : public ASTType { -public: - String GetSignature() override; - - bool IsByteType() override; - - String ToString() override; -}; - -} -} - -#endif // OHOS_ZIDL_ASTBYTETYPE_H diff --git a/zidl/ast/ast_char_type.cpp b/zidl/ast/ast_char_type.cpp deleted file mode 100644 index 6a8682dc989..00000000000 --- a/zidl/ast/ast_char_type.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_char_type.h" - -namespace OHOS { -namespace Zidl { - -String ASTCharType::GetSignature() -{ - return "C"; -} - -bool ASTCharType::IsCharType() -{ - return true; -} - -String ASTCharType::ToString() -{ - return "char"; -} - -} -} diff --git a/zidl/ast/ast_char_type.h b/zidl/ast/ast_char_type.h deleted file mode 100644 index a2d2487a6f2..00000000000 --- a/zidl/ast/ast_char_type.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTCHARTYPE_H -#define OHOS_ZIDL_ASTCHARTYPE_H - -#include "ast/ast_type.h" - -namespace OHOS { -namespace Zidl { - -class ASTCharType : public ASTType { -public: - String GetSignature() override; - - bool IsCharType() override; - - String ToString() override; -}; - -} -} - -#endif // OHOS_ZIDL_ASTCHARTYPE_H diff --git a/zidl/ast/ast_double_type.cpp b/zidl/ast/ast_double_type.cpp deleted file mode 100644 index 7e6b773553c..00000000000 --- a/zidl/ast/ast_double_type.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_double_type.h" - -namespace OHOS { -namespace Zidl { - -String ASTDoubleType::GetSignature() -{ - return "D"; -} - -bool ASTDoubleType::IsDoubleType() -{ - return true; -} - -String ASTDoubleType::ToString() -{ - return "double"; -} - -} -} diff --git a/zidl/ast/ast_double_type.h b/zidl/ast/ast_double_type.h deleted file mode 100644 index 625111bbf86..00000000000 --- a/zidl/ast/ast_double_type.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTDOUBLETYPE_H -#define OHOS_ZIDL_ASTDOUBLETYPE_H - -#include "ast/ast_type.h" - -namespace OHOS { -namespace Zidl { - -class ASTDoubleType : public ASTType { -public: - String GetSignature() override; - - bool IsDoubleType() override; - - String ToString() override; -}; - -} -} - -#endif // OHOS_ZIDL_ASTDOUBLETYPE_H \ No newline at end of file diff --git a/zidl/ast/ast_float_type.cpp b/zidl/ast/ast_float_type.cpp deleted file mode 100644 index df699bba83b..00000000000 --- a/zidl/ast/ast_float_type.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_float_type.h" - -namespace OHOS { -namespace Zidl { - -String ASTFloatType::GetSignature() -{ - return "F"; -} - -bool ASTFloatType::IsFloatType() -{ - return true; -} - -String ASTFloatType::ToString() -{ - return "float"; -} - -} -} diff --git a/zidl/ast/ast_float_type.h b/zidl/ast/ast_float_type.h deleted file mode 100644 index 44ef0103c5b..00000000000 --- a/zidl/ast/ast_float_type.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTFLOATTYPE_H -#define OHOS_ZIDL_ASTFLOATTYPE_H - -#include "ast/ast_type.h" - -namespace OHOS { -namespace Zidl { - -class ASTFloatType : public ASTType { -public: - String GetSignature() override; - - bool IsFloatType() override; - - String ToString() override; -}; - -} -} - -#endif // OHOS_ZIDL_ASTFLOATTYPE_H diff --git a/zidl/ast/ast_integer_type.cpp b/zidl/ast/ast_integer_type.cpp deleted file mode 100644 index 16918c9a6e2..00000000000 --- a/zidl/ast/ast_integer_type.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_integer_type.h" - -namespace OHOS { -namespace Zidl { - -String ASTIntegerType::GetSignature() -{ - return "I"; -} - -bool ASTIntegerType::IsIntegerType() -{ - return true; -} - -String ASTIntegerType::ToString() -{ - return "int"; -} - -} -} diff --git a/zidl/ast/ast_integer_type.h b/zidl/ast/ast_integer_type.h deleted file mode 100644 index cc30c15b4d3..00000000000 --- a/zidl/ast/ast_integer_type.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTINTEGERTYPE_H -#define OHOS_ZIDL_ASTINTEGERTYPE_H - -#include "ast/ast_type.h" - -namespace OHOS { -namespace Zidl { - -class ASTIntegerType : public ASTType { -public: - String GetSignature() override; - - bool IsIntegerType() override; - - String ToString() override; -}; - -} -} - -#endif // OHOS_ZIDL_ASTINTEGERTYPE_H diff --git a/zidl/ast/ast_interface_type.cpp b/zidl/ast/ast_interface_type.cpp deleted file mode 100644 index b92003f6816..00000000000 --- a/zidl/ast/ast_interface_type.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_interface_type.h" -#include "util/string_builder.h" - -namespace OHOS { -namespace Zidl { - -void ASTInterfaceType::SetNamespace( - /* [in] */ ASTNamespace* nspace) -{ - ASTType::SetNamespace(nspace); - if (namespace_ != nullptr) { - namespace_->AddInterface(this); - } -} - -void ASTInterfaceType::AddMethod( - /* [in] */ ASTMethod* method) -{ - if (method == nullptr) { - return; - } - methods_.push_back(method); -} - -AutoPtr ASTInterfaceType::GetMethod( - /* [in] */ size_t index) -{ - if (index >= methods_.size()) { - return nullptr; - } - - return methods_[index]; -} - -String ASTInterfaceType::GetSignature() -{ - String fullName = namespace_ != nullptr ? - namespace_->ToString() + name_ : name_; - return "L" + fullName.Replace('.', '/') + ";"; -} - -bool ASTInterfaceType::IsInterfaceType() -{ - return true; -} - -String ASTInterfaceType::ToString() -{ - return name_; -} - -String ASTInterfaceType::Dump( - /* [in] */ const String& prefix) -{ - StringBuilder sb; - - sb.Append(prefix).Append("interface "); - if (namespace_ != nullptr) { - sb.Append(namespace_->ToString()); - } - sb.Append(name_); - if (isExternal_) { - sb.Append(";\n"); - } else { - sb.Append(" {\n"); - for (auto method : methods_) { - String info = method->Dump(prefix + " "); - sb.Append(info); - if (method != methods_[methods_.size() - 1]) { - sb.Append('\n'); - } - } - sb.Append(prefix).Append("}\n"); - } - - return sb.ToString(); -} - -} -} diff --git a/zidl/ast/ast_interface_type.h b/zidl/ast/ast_interface_type.h deleted file mode 100644 index ff858591e0a..00000000000 --- a/zidl/ast/ast_interface_type.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTINTERFACETYPE_H -#define OHOS_ZIDL_ASTINTERFACETYPE_H - -#include -#include "ast/ast_method.h" -#include "ast/ast_type.h" -#include "util/autoptr.h" - -namespace OHOS { -namespace Zidl { - -class ASTInterfaceType : public ASTType { -public: - void SetNamespace( - /* [in] */ ASTNamespace* nspace) override; - - inline void SetLicense( - /* [in] */ const String& license) - { - license_ = license; - } - - inline String GetLicense() const - { - return license_; - } - - inline void SetOneway( - /* [in] */ bool oneway) - { - oneway_ = oneway; - } - - inline bool IsOneway() - { - return oneway_; - } - - void AddMethod( - /* [in] */ ASTMethod* method); - - AutoPtr GetMethod( - /* [in] */ size_t index); - - inline size_t GetMethodNumber() - { - return methods_.size(); - } - - void SetExternal( - /* [in] */ bool external) - { - isExternal_ = external; - } - - bool IsExternal() const - { - return isExternal_; - } - - String GetSignature() override; - - bool IsInterfaceType() override; - - String ToString() override; - - String Dump( - /* [in] */ const String& prefix) override; - -private: - String license_; - bool oneway_ = false; - std::vector> methods_; - bool isExternal_ = false; -}; - -} -} - -#endif // OHOS_ZIDL_ASTINTERFACETYPE_H diff --git a/zidl/ast/ast_list_type.cpp b/zidl/ast/ast_list_type.cpp deleted file mode 100644 index 5c31c6f4cf0..00000000000 --- a/zidl/ast/ast_list_type.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_list_type.h" - -namespace OHOS { -namespace Zidl { - -String ASTListType::GetSignature() -{ - return String::Format("LList[%s];", elementType_->GetSignature().string()); -} - -bool ASTListType::IsListType() -{ - return true; -} - -String ASTListType::ToString() -{ - return String::Format("List<%s>", elementType_->ToString().string()); -} - -} -} diff --git a/zidl/ast/ast_list_type.h b/zidl/ast/ast_list_type.h deleted file mode 100644 index d6c80a6833a..00000000000 --- a/zidl/ast/ast_list_type.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTLISTTYPE_H -#define OHOS_ZIDL_ASTLISTTYPE_H - -#include "ast/ast_type.h" -#include "util/autoptr.h" - -namespace OHOS { -namespace Zidl { - -class ASTListType : public ASTType { -public: - inline void SetElementType( - /* [in] */ ASTType* elementType) - { - elementType_ = elementType; - } - - inline AutoPtr GetElementType() - { - return elementType_; - } - - String GetSignature() override; - - bool IsListType() override; - - String ToString() override; - -private: - AutoPtr elementType_; -}; - -} -} - -#endif // OHOS_ZIDL_ASTLISTTYPE_H diff --git a/zidl/ast/ast_long_type.cpp b/zidl/ast/ast_long_type.cpp deleted file mode 100644 index 29c7bdd01ff..00000000000 --- a/zidl/ast/ast_long_type.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_long_type.h" - -namespace OHOS { -namespace Zidl { - -String ASTLongType::GetSignature() -{ - return "J"; -} - -bool ASTLongType::IsLongType() -{ - return true; -} - -String ASTLongType::ToString() -{ - return "long"; -} - -} -} diff --git a/zidl/ast/ast_long_type.h b/zidl/ast/ast_long_type.h deleted file mode 100644 index eec1873fc33..00000000000 --- a/zidl/ast/ast_long_type.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTLONGTYPE_H -#define OHOS_ZIDL_ASTLONGTYPE_H - -#include "ast/ast_type.h" - -namespace OHOS { -namespace Zidl { - -class ASTLongType : public ASTType { -public: - String GetSignature() override; - - bool IsLongType() override; - - String ToString() override; -}; - -} -} - -#endif // OHOS_ZIDL_ASTLONGTYPE_H diff --git a/zidl/ast/ast_map_type.cpp b/zidl/ast/ast_map_type.cpp deleted file mode 100644 index 2f41e6b4a29..00000000000 --- a/zidl/ast/ast_map_type.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_map_type.h" - -namespace OHOS { -namespace Zidl { - -String ASTMapType::GetSignature() -{ - return String::Format("LMap[%s%s];", keyType_->GetSignature().string(), valueType_->GetSignature().string()); -} - -bool ASTMapType::IsMapType() -{ - return true; -} - -String ASTMapType::ToString() -{ - return String::Format("Map<%s, %s>", keyType_->ToString().string(), valueType_->ToString().string()); -} - -} -} diff --git a/zidl/ast/ast_map_type.h b/zidl/ast/ast_map_type.h deleted file mode 100644 index 3fcddce5404..00000000000 --- a/zidl/ast/ast_map_type.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTMAPTYPE_H -#define OHOS_ZIDL_ASTMAPTYPE_H - -#include "ast/ast_type.h" -#include "util/autoptr.h" - -namespace OHOS { -namespace Zidl { - -class ASTMapType : public ASTType { -public: - inline void SetKeyType( - /* [in] */ ASTType* keyType) - { - keyType_ = keyType; - } - - inline AutoPtr GetKeyType() - { - return keyType_; - } - - inline void SetValueType( - /* [in] */ ASTType* valueType) - { - valueType_ = valueType; - } - - inline AutoPtr GetValueType() - { - return valueType_; - } - - String GetSignature() override; - - bool IsMapType() override; - - String ToString() override; - -private: - AutoPtr keyType_; - AutoPtr valueType_; -}; - -} -} - -#endif // OHOS_ZIDL_ASTMAPTYPE_H \ No newline at end of file diff --git a/zidl/ast/ast_method.cpp b/zidl/ast/ast_method.cpp deleted file mode 100644 index a9aff6b6d83..00000000000 --- a/zidl/ast/ast_method.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_method.h" -#include "util/string_builder.h" - -namespace OHOS { -namespace Zidl { - -String ASTMethod::GetSignature() -{ - if (signature_.IsEmpty()) { - BuildSignature(); - } - return signature_; -} - -void ASTMethod::BuildSignature() -{ - StringBuilder sb; - - sb.AppendFormat("(%s)", returnType_->GetSignature().string()); - for (size_t i = 0; i < parameters_.size(); i++) { - sb.Append(parameters_[i]->GetType()->GetSignature()); - } - signature_ = sb.ToString(); -} - -void ASTMethod::AddParameter( - /* [in] */ ASTParameter* parameter) -{ - if (parameter == nullptr) { - return; - } - parameters_.push_back(parameter); -} - -AutoPtr ASTMethod::GetParameter( - /* [in] */ size_t index) -{ - if (index >= parameters_.size()) { - return nullptr; - } - - return parameters_[index]; -} - -String ASTMethod::Dump( - /* [in] */ const String& prefix) -{ - StringBuilder sb; - - sb.Append(prefix); - sb.Append(returnType_->ToString()).Append(' '); - sb.Append(name_).Append('('); - if (parameters_.size() != 0) { - sb.Append('\n'); - for (auto parameter : parameters_) { - String info = parameter->Dump(prefix + " "); - sb.Append(info); - if (parameter != parameters_[parameters_.size() - 1]) { - sb.Append(",\n"); - } - } - } - sb.Append(");\n"); - - return sb.ToString(); -} - -} -} diff --git a/zidl/ast/ast_method.h b/zidl/ast/ast_method.h deleted file mode 100644 index 638b4a45840..00000000000 --- a/zidl/ast/ast_method.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTMETHOD_H -#define OHOS_ZIDL_ASTMETHOD_H - -#include -#include "ast/ast_node.h" -#include "ast/ast_parameter.h" -#include "util/autoptr.h" -#include "util/string.h" - -namespace OHOS { -namespace Zidl { - -class ASTMethod : public ASTNode { -public: - inline void SetName( - /* [in] */ const String& name) - { - name_ = name; - } - - inline String GetName() - { - return name_; - } - - String GetSignature(); - - inline void SetOneway( - /* [in] */ bool oneway) - { - oneway_ = oneway; - } - - inline bool IsOneway() - { - return oneway_; - } - - inline void SetReturnType( - /* [in] */ ASTType* type) - { - returnType_ = type; - } - - inline AutoPtr GetReturnType() - { - return returnType_; - } - - void AddParameter( - /* [in] */ ASTParameter* parameter); - - AutoPtr GetParameter( - /* [in] */ size_t index); - - inline size_t GetParameterNumber() - { - return parameters_.size(); - } - - String Dump( - /* [in] */ const String& prefix) override; - -private: - void BuildSignature(); - - String name_; - String signature_; - bool oneway_ = false; - AutoPtr returnType_; - std::vector> parameters_; -}; - -} -} - -#endif // OHOS_ZIDL_ASTMETHOD_H diff --git a/zidl/ast/ast_module.cpp b/zidl/ast/ast_module.cpp deleted file mode 100644 index 39d949fad68..00000000000 --- a/zidl/ast/ast_module.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_module.h" -#include "util/string_builder.h" - -namespace OHOS { -namespace Zidl { - -ASTModule::ASTModule() -{ - booleanType_ = new ASTBooleanType(); - byteType_ = new ASTByteType(); - shortType_ = new ASTShortType(); - integerType_ = new ASTIntegerType(); - longType_ = new ASTLongType(); - floatType_ = new ASTFloatType(); - doubleType_ = new ASTDoubleType(); - charType_ = new ASTCharType(); - stringType_ = new ASTStringType(); - voidType_ = new ASTVoidType(); - - types_["boolean"] = booleanType_.Get(); - types_["byte"] = byteType_.Get(); - types_["short"] = shortType_.Get(); - types_["int"] = integerType_.Get(); - types_["long"] = longType_.Get(); - types_["float"] = floatType_.Get(); - types_["double"] = doubleType_.Get(); - types_["char"] = charType_.Get(); - types_["String"] = stringType_.Get(); - types_["void"] = voidType_.Get(); -} - -void ASTModule::SetZidlFile( - /* [in] */ const String& zidlFile) -{ - zidlFilePath_ = zidlFile; -#ifdef __MINGW32__ - int index = zidlFilePath_.LastIndexOf('\\'); -#else - int index = zidlFilePath_.LastIndexOf('/'); -#endif - int end = zidlFilePath_.LastIndexOf(".zidl") == -1 ? - zidlFilePath_.LastIndexOf(".idl") : zidlFilePath_.LastIndexOf(".zidl"); - name_ = zidlFilePath_.Substring((index == -1) ? 0 : (index + 1), end); -} - -AutoPtr ASTModule::ParseNamespace( - /* [in] */ const String& nspaceStr) -{ - AutoPtr currNspace; - int begin = 0; - int index = 0; - while ((index = nspaceStr.IndexOf('.', begin)) != -1) { - String ns = nspaceStr.Substring(begin, index); - AutoPtr nspace; - if (currNspace == nullptr) { - nspace = FindNamespace(ns); - } else { - nspace = currNspace->FindNamespace(ns); - } - if (nspace == nullptr) { - nspace = new ASTNamespace(ns); - if (currNspace == nullptr) { - AddNamespace(nspace); - } else { - currNspace->AddNamespace(nspace); - } - } - currNspace = nspace; - begin = index + 1; - } - return currNspace; -} - -void ASTModule::AddNamespace( - /* [in] */ ASTNamespace* nspace) -{ - if (nspace == nullptr) { - return; - } - namespaces_.push_back(nspace); -} - -AutoPtr ASTModule::FindNamespace( - /* [in] */ const String& nspaceStr) -{ - for (auto nspace : namespaces_) { - if (nspace->ToShortString().Equals(nspaceStr)) { - return nspace; - } - } - return nullptr; -} - -AutoPtr ASTModule::GetNamespace( - /* [in] */ size_t index) -{ - if (index >= namespaces_.size()) { - return nullptr; - } - - return namespaces_[index]; -} - -void ASTModule::AddInterface( - /* [in] */ ASTInterfaceType* interface) -{ - if (interface == nullptr) { - return; - } - - interfaces_.push_back(interface); - types_[interface->ToString()] = (ASTType*)interface; -} - -AutoPtr ASTModule::GetInterface( - /* [in] */ size_t index) -{ - if (index >= interfaces_.size()) { - return nullptr; - } - - return interfaces_[index]; -} - -int ASTModule::IndexOf( - /* [in] */ ASTInterfaceType* interface) -{ - for (size_t i = 0; i < interfaces_.size(); i++) { - if (interfaces_[i] == interface) { - return i; - } - } - return -1; -} - -void ASTModule::AddSequenceable( - /* [in] */ ASTSequenceableType* sequenceable) -{ - if (sequenceable == nullptr) { - return; - } - - sequenceables_.push_back(sequenceable); - types_[sequenceable->ToString()] = (ASTType*)sequenceable; -} - -AutoPtr ASTModule::GetSequenceable( - /* [in] */ size_t index) -{ - if (index >= sequenceables_.size()) { - return nullptr; - } - - return sequenceables_[index]; -} - -int ASTModule::IndexOf( - /* [in] */ ASTSequenceableType* sequenceable) -{ - for (size_t i = 0; i < sequenceables_.size(); i++) { - if (sequenceables_[i] == sequenceable) { - return i; - } - } - return -1; -} - -void ASTModule::AddType( - /* [in] */ ASTType* type) -{ - if (type == nullptr) { - return; - } - - types_[type->ToString()] = type; -} - -AutoPtr ASTModule::FindType( - /* [in] */ const String& typeName) -{ - if (typeName.IsEmpty()) { - return nullptr; - } - - auto it = types_.find(typeName); - return it != types_.end() ? it->second : nullptr; -} - -int ASTModule::IndexOf( - /* [in] */ ASTType* type) -{ - int i = 0; - for (auto it = types_.begin(); it != types_.end(); ++it, ++i) { - if (it->second == type) { - return i; - } - } - return -1; -} - -bool ASTModule::IsValid() -{ - if (name_.IsEmpty()) { - return false; - } - - return interfaces_.size() > 0; -} - -String ASTModule::Dump( - /* [in] */ const String& prefix) -{ - StringBuilder sb; - - sb.Append(prefix); - sb.Append("Module["); - sb.Append("name: ").Append(name_).Append(" "); - sb.Append("file: ").Append(zidlFilePath_); - sb.Append("]\n"); - - for (auto sequenceable : sequenceables_) { - String info = sequenceable->Dump(" "); - sb.Append(info); - } - sb.Append('\n'); - - for (auto interface : interfaces_) { - if (interface->IsExternal()) { - String info = interface->Dump(" "); - sb.Append(info); - } - } - sb.Append('\n'); - - for (auto interface : interfaces_) { - if (!interface->IsExternal()) { - String info = interface->Dump(" "); - sb.Append(info); - } - } - - return sb.ToString(); -} - -} -} diff --git a/zidl/ast/ast_module.h b/zidl/ast/ast_module.h deleted file mode 100644 index 6256e15b3e0..00000000000 --- a/zidl/ast/ast_module.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTMODULE_H -#define OHOS_ZIDL_ASTMODULE_H - -#include -#include -#include "ast/ast_boolean_type.h" -#include "ast/ast_byte_type.h" -#include "ast/ast_char_type.h" -#include "ast/ast_double_type.h" -#include "ast/ast_float_type.h" -#include "ast/ast_integer_type.h" -#include "ast/ast_interface_type.h" -#include "ast/ast_long_type.h" -#include "ast/ast_namespace.h" -#include "ast/ast_node.h" -#include "ast/ast_sequenceable_type.h" -#include "ast/ast_short_type.h" -#include "ast/ast_string_type.h" -#include "ast/ast_void_type.h" -#include "util/autoptr.h" - -namespace OHOS { -namespace Zidl { - -class ASTModule : public ASTNode { -public: - ASTModule(); - - void SetZidlFile( - /* [in] */ const String& zidlFile); - - inline String GetName() - { - return name_; - } - - inline void SetLicense( - /* [in] */ const String& license) - { - license_ = license; - } - - inline String GetLicense() - { - return license_; - } - - AutoPtr ParseNamespace( - /* [in] */ const String& nspaceStr); - - void AddNamespace( - /* [in] */ ASTNamespace* nspace); - - AutoPtr FindNamespace( - /* [in] */ const String& nspaceStr); - - AutoPtr GetNamespace( - /* [in] */ size_t index); - - inline size_t GetNamespaceNumber() - { - return namespaces_.size(); - } - - void AddInterface( - /* [in] */ ASTInterfaceType* interface); - - AutoPtr GetInterface( - /* [in] */ size_t index); - - inline size_t GetInterfaceNumber() - { - return interfaces_.size(); - } - - int IndexOf( - /* [in] */ ASTInterfaceType* interface); - - void AddSequenceable( - /* [in] */ ASTSequenceableType* sequenceable); - - AutoPtr GetSequenceable( - /* [in] */ size_t index); - - inline size_t GetSequenceableNumber() - { - return sequenceables_.size(); - } - - int IndexOf( - /* [in] */ ASTSequenceableType* sequenceable); - - void AddType( - /* [in] */ ASTType* type); - - AutoPtr FindType( - /* [in] */ const String& typeName); - - using TypeStringMap = std::unordered_map, StringHashFunc, StringEqualFunc>; - - inline const TypeStringMap& GetTypes() - { - return types_; - } - - inline size_t GetTypeNumber() - { - return types_.size(); - } - - int IndexOf( - /* [in] */ ASTType* type); - - bool IsValid(); - - String Dump( - /* [in] */ const String& prefix) override; - -private: - String name_; - String license_; - std::vector> namespaces_; - std::vector> interfaces_; - std::vector> sequenceables_; - TypeStringMap types_; - - AutoPtr booleanType_; - AutoPtr byteType_; - AutoPtr shortType_; - AutoPtr integerType_; - AutoPtr longType_; - AutoPtr floatType_; - AutoPtr doubleType_; - AutoPtr charType_; - AutoPtr stringType_; - AutoPtr voidType_; - - String zidlFilePath_; -}; - -} -} - -#endif // OHOS_ZIDL_ASTMODULE_H diff --git a/zidl/ast/ast_namespace.cpp b/zidl/ast/ast_namespace.cpp deleted file mode 100644 index 66b502a41fb..00000000000 --- a/zidl/ast/ast_namespace.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_namespace.h" -#include "ast/ast_interface_type.h" -#include "ast/ast_sequenceable_type.h" - -namespace OHOS { -namespace Zidl { - -ASTNamespace:: ASTNamespace( - /* [in] */ const String& nspaceStr) - : name_(nspaceStr), - outerNamespace_(nullptr) -{} - -void ASTNamespace::AddNamespace( - /* [in] */ ASTNamespace* innerNspace) -{ - if (innerNspace == nullptr) { - return; - } - - innerNamespaces_.push_back(innerNspace); - innerNspace->outerNamespace_ = this; -} - -AutoPtr ASTNamespace::FindNamespace( - /* [in] */ const String& nspaceStr) -{ - if (nspaceStr.IsEmpty()) { - return nullptr; - } - - for (auto nspace : innerNamespaces_) { - if (nspace->name_.Equals(nspaceStr)) { - return nspace; - } - } - return nullptr; -} - -AutoPtr ASTNamespace::GetNamespace( - /* [in] */ size_t index) -{ - if (index >= innerNamespaces_.size()) { - return nullptr; - } - - return innerNamespaces_[index]; -} - -void ASTNamespace::AddInterface( - /* [in] */ ASTInterfaceType* interface) -{ - if (interface == nullptr) { - return; - } - - interfaces_.push_back(interface); -} - -AutoPtr ASTNamespace::GetInterface( - /* [in] */ size_t index) -{ - if (index >= interfaces_.size()) { - return nullptr; - } - - return interfaces_[index]; -} - -void ASTNamespace::AddSequenceable( - /* [in] */ ASTSequenceableType* sequenceable) -{ - if (sequenceable == nullptr) { - return; - } - - sequenceables_.push_back(sequenceable); -} - -AutoPtr ASTNamespace::GetSequenceable( - /* [in] */ size_t index) -{ - if (index >= sequenceables_.size()) { - return nullptr; - } - - return sequenceables_[index]; -} - -String ASTNamespace::ToString() -{ - String nspaceStr; - ASTNamespace* nspace = this; - while (nspace != nullptr) { - nspaceStr = nspace->name_ + "." + nspaceStr; - nspace = nspace->outerNamespace_; - } - return nspaceStr; -} - -} -} diff --git a/zidl/ast/ast_namespace.h b/zidl/ast/ast_namespace.h deleted file mode 100644 index d78d171de19..00000000000 --- a/zidl/ast/ast_namespace.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTNAMESPACE_H -#define OHOS_ZIDL_ASTNAMESPACE_H - -#include -#include "ast/ast_node.h" -#include "util/autoptr.h" - -namespace OHOS { -namespace Zidl { - -class ASTInterfaceType; -class ASTSequenceableType; - -class ASTNamespace : public ASTNode { -public: - ASTNamespace( - /* [in] */ const String& nspaceStr); - - inline String GetName() - { - return name_; - } - - void AddNamespace( - /* [in] */ ASTNamespace* innerNspace); - - AutoPtr FindNamespace( - /* [in] */ const String& nspaceStr); - - AutoPtr GetNamespace( - /* [in] */ size_t index); - - inline size_t GetNamespaceNumber() - { - return innerNamespaces_.size(); - } - - void AddInterface( - /* [in] */ ASTInterfaceType* interface); - - AutoPtr GetInterface( - /* [in] */ size_t index); - - inline size_t GetInterfaceNumber() - { - return interfaces_.size(); - } - - void AddSequenceable( - /* [in] */ ASTSequenceableType* sequenceable); - - AutoPtr GetSequenceable( - /* [in] */ size_t index); - - inline size_t GetSequenceableNumber() - { - return sequenceables_.size(); - } - - inline String ToShortString() - { - return name_; - } - - String ToString() override; - -private: - String name_; - ASTNamespace* outerNamespace_; - std::vector> innerNamespaces_; - std::vector> interfaces_; - std::vector> sequenceables_; -}; - -} -} - -#endif // OHOS_ZIDL_ASTNAMESPACE_H diff --git a/zidl/ast/ast_node.cpp b/zidl/ast/ast_node.cpp deleted file mode 100644 index f16e2d6ef0b..00000000000 --- a/zidl/ast/ast_node.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_node.h" - -namespace OHOS { -namespace Zidl { - -ASTNode::~ASTNode() -{} - -String ASTNode::ToString() -{ - return "ASTNode"; -} - -String ASTNode::Dump( - /* [in] */ const String& prefix) -{ - return prefix + "ASTNode"; -} - -} -} diff --git a/zidl/ast/ast_node.h b/zidl/ast/ast_node.h deleted file mode 100644 index abe435e6523..00000000000 --- a/zidl/ast/ast_node.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTNODE_H -#define OHOS_ZIDL_ASTNODE_H - -#include "util/light_refcount_base.h" -#include "util/string.h" - -namespace OHOS { -namespace Zidl { - -class ASTNode : public LightRefCountBase { -public: - virtual ~ASTNode(); - - virtual String ToString(); - - virtual String Dump( - /* [in] */ const String& prefix); -}; - -} -} - -#endif // OHOS_ZIDL_ASTNODE_H diff --git a/zidl/ast/ast_parameter.cpp b/zidl/ast/ast_parameter.cpp deleted file mode 100644 index c62da3aeee4..00000000000 --- a/zidl/ast/ast_parameter.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_parameter.h" -#include "util/string_builder.h" - -namespace OHOS { -namespace Zidl { - -String ASTParameter::Dump( - /* [in] */ const String& prefix) -{ - StringBuilder sb; - - sb.Append(prefix); - sb.Append('['); - if (isInParameter_) { - sb.Append("in"); - } - if (isOutParameter_) { - if (isInParameter_) { - sb.Append(", "); - } - sb.Append("out"); - } - sb.Append("] "); - sb.Append(type_->ToString()).Append(' '); - sb.Append(name_); - - return sb.ToString(); -} - -} -} diff --git a/zidl/ast/ast_parameter.h b/zidl/ast/ast_parameter.h deleted file mode 100644 index 84418edd8c1..00000000000 --- a/zidl/ast/ast_parameter.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTPARAMETER_H -#define OHOS_ZIDL_ASTPARAMETER_H - -#include "ast/ast_node.h" -#include "ast/ast_type.h" -#include "util/autoptr.h" -#include "util/string.h" - -namespace OHOS { -namespace Zidl { - -class ASTParameter : public ASTNode { -public: - inline void SetName( - /* [in] */ const String& name) - { - name_ = name; - } - - inline String GetName() - { - return name_; - } - - inline void SetType( - /* [in] */ ASTType* type) - { - type_ = type; - } - - inline AutoPtr GetType() - { - return type_; - } - - inline void SetInParameter( - /* [in] */ bool inParameter) - { - isInParameter_ = inParameter; - } - - inline bool IsInParameter() - { - return isInParameter_; - } - - inline void SetOutParameter( - /* [in] */ bool outParameter) - { - isOutParameter_ = outParameter; - } - - inline bool IsOutParameter() - { - return isOutParameter_; - } - - String Dump( - /* [in] */ const String& prefix) override; - -private: - String name_; - AutoPtr type_; - bool isInParameter_ = false; - bool isOutParameter_ = false; -}; - -} -} - -#endif // OHOS_ZIDL_ASTPARAMETER_H diff --git a/zidl/ast/ast_sequenceable_type.cpp b/zidl/ast/ast_sequenceable_type.cpp deleted file mode 100644 index 680606733e8..00000000000 --- a/zidl/ast/ast_sequenceable_type.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_sequenceable_type.h" -#include "util/string_builder.h" - -namespace OHOS { -namespace Zidl { - -void ASTSequenceableType::SetNamespace( - /* [in] */ ASTNamespace* nspace) -{ - ASTType::SetNamespace(nspace); - if (namespace_ != nullptr) { - namespace_->AddSequenceable(this); - } -} - -String ASTSequenceableType::GetSignature() -{ - String fullName = namespace_ != nullptr ? - namespace_->ToString() + name_ : name_; - return "L" + fullName.Replace('.', '/') + ";"; -} - -bool ASTSequenceableType::IsSequenceableType() -{ - return true; -} - -String ASTSequenceableType::ToString() -{ - return name_; -} - -String ASTSequenceableType::Dump( - /* [in] */ const String& prefix) -{ - StringBuilder sb; - - sb.Append(prefix).Append("sequenceable "); - if (namespace_ != nullptr) { - sb.Append(namespace_->ToString()); - } - sb.Append(name_); - sb.Append(";\n"); - - return sb.ToString(); -} - -} -} diff --git a/zidl/ast/ast_sequenceable_type.h b/zidl/ast/ast_sequenceable_type.h deleted file mode 100644 index d22b50d625d..00000000000 --- a/zidl/ast/ast_sequenceable_type.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTSEQUENCEABLETYPE_H -#define OHOS_ZIDL_ASTSEQUENCEABLETYPE_H - -#include "ast/ast_type.h" - -namespace OHOS { -namespace Zidl { - -class ASTSequenceableType : public ASTType { -public: - void SetNamespace( - /* [in] */ ASTNamespace* nspace) override; - - String GetSignature() override; - - bool IsSequenceableType() override; - - String ToString() override; - - String Dump( - /* [in] */ const String& prefix) override; -}; - -} -} - -#endif // OHOS_ZIDL_ASTSEQUENCEABLETYPE_H diff --git a/zidl/ast/ast_short_type.cpp b/zidl/ast/ast_short_type.cpp deleted file mode 100644 index 2891aed192c..00000000000 --- a/zidl/ast/ast_short_type.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_short_type.h" - -namespace OHOS { -namespace Zidl { - -String ASTShortType::GetSignature() -{ - return "S"; -} - -bool ASTShortType::IsShortType() -{ - return true; -} - -String ASTShortType::ToString() -{ - return "short"; -} - -} -} diff --git a/zidl/ast/ast_short_type.h b/zidl/ast/ast_short_type.h deleted file mode 100644 index da8766f207a..00000000000 --- a/zidl/ast/ast_short_type.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTSHORTTYPE_H -#define OHOS_ZIDL_ASTSHORTTYPE_H - -#include "ast/ast_type.h" - -namespace OHOS { -namespace Zidl { - -class ASTShortType : public ASTType { -public: - String GetSignature() override; - - bool IsShortType() override; - - String ToString() override; -}; - -} -} - -#endif // OHOS_ZIDL_ASTSHORTTYPE_H diff --git a/zidl/ast/ast_string_type.cpp b/zidl/ast/ast_string_type.cpp deleted file mode 100644 index 3144aee55ea..00000000000 --- a/zidl/ast/ast_string_type.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_string_type.h" - -namespace OHOS { -namespace Zidl { - -String ASTStringType::GetSignature() -{ - return "T"; -} - -bool ASTStringType::IsStringType() -{ - return true; -} - -String ASTStringType::ToString() -{ - return "String"; -} - -} -} diff --git a/zidl/ast/ast_string_type.h b/zidl/ast/ast_string_type.h deleted file mode 100644 index e7eab0a4431..00000000000 --- a/zidl/ast/ast_string_type.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTSTRINGTYPE_H -#define OHOS_ZIDL_ASTSTRINGTYPE_H - -#include "ast/ast_type.h" - -namespace OHOS { -namespace Zidl { - -class ASTStringType : public ASTType { -public: - String GetSignature() override; - - bool IsStringType() override; - - String ToString() override; -}; - -} -} - -#endif // OHOS_ZIDL_ASTSTRINGTYPE_H diff --git a/zidl/ast/ast_type.cpp b/zidl/ast/ast_type.cpp deleted file mode 100644 index 1c31469907a..00000000000 --- a/zidl/ast/ast_type.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_type.h" - -namespace OHOS { -namespace Zidl { - -void ASTType::SetName( - /* [in] */ const String& name) -{ - name_ = name; -} - -String ASTType::GetName() -{ - return name_; -} - -void ASTType::SetNamespace( - /* [in] */ ASTNamespace* nspace) -{ - namespace_ = nspace; -} - -AutoPtr ASTType::GetNamespace() -{ - return namespace_; -} - -bool ASTType::IsBooleanType() -{ - return false; -} - -bool ASTType::IsByteType() -{ - return false; -} - -bool ASTType::IsShortType() -{ - return false; -} - -bool ASTType::IsIntegerType() -{ - return false; -} - -bool ASTType::IsLongType() -{ - return false; -} - -bool ASTType::IsFloatType() -{ - return false; -} - -bool ASTType::IsDoubleType() -{ - return false; -} - -bool ASTType::IsCharType() -{ - return false; -} - -bool ASTType::IsStringType() -{ - return false; -} - -bool ASTType::IsListType() -{ - return false; -} - -bool ASTType::IsMapType() -{ - return false; -} - -bool ASTType::IsInterfaceType() -{ - return false; -} - -bool ASTType::IsSequenceableType() -{ - return false; -} - -bool ASTType::IsVoidType() -{ - return false; -} - -bool ASTType::IsArrayType() -{ - return false; -} - -String ASTType::ToShortString() -{ - return name_; -} - -String ASTType::ToString() -{ - return namespace_ == nullptr ? name_ : namespace_->ToString() + name_; -} - -} -} \ No newline at end of file diff --git a/zidl/ast/ast_type.h b/zidl/ast/ast_type.h deleted file mode 100644 index 1ecacde4d70..00000000000 --- a/zidl/ast/ast_type.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTTYPE_H -#define OHOS_ZIDL_ASTTYPE_H - -#include "ast/ast_namespace.h" -#include "ast/ast_node.h" -#include "util/autoptr.h" -#include "util/string.h" - -namespace OHOS { -namespace Zidl { - -class ASTType : public ASTNode { -public: - virtual void SetName( - /* [in] */ const String& name); - - virtual String GetName(); - - virtual void SetNamespace( - /* [in] */ ASTNamespace* nspace); - - virtual AutoPtr GetNamespace(); - - virtual String GetSignature() = 0; - - virtual bool IsBooleanType(); - - virtual bool IsByteType(); - - virtual bool IsShortType(); - - virtual bool IsIntegerType(); - - virtual bool IsLongType(); - - virtual bool IsFloatType(); - - virtual bool IsDoubleType(); - - virtual bool IsCharType(); - - virtual bool IsStringType(); - - virtual bool IsListType(); - - virtual bool IsMapType(); - - virtual bool IsInterfaceType(); - - virtual bool IsSequenceableType(); - - virtual bool IsVoidType(); - - virtual bool IsArrayType(); - - virtual String ToShortString(); - - String ToString() override; - -protected: - String name_; - AutoPtr namespace_; -}; - -} -} - -#endif // OHOS_ZIDL_ASTTYPE_H diff --git a/zidl/ast/ast_void_type.cpp b/zidl/ast/ast_void_type.cpp deleted file mode 100644 index 2cce08c685e..00000000000 --- a/zidl/ast/ast_void_type.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ast/ast_void_type.h" - -namespace OHOS { -namespace Zidl { - -String ASTVoidType::GetSignature() -{ - return "V"; -} - -bool ASTVoidType::IsVoidType() -{ - return true; -} - -String ASTVoidType::ToString() -{ - return "void"; -} - -} -} diff --git a/zidl/ast/ast_void_type.h b/zidl/ast/ast_void_type.h deleted file mode 100644 index 9a66b6f8403..00000000000 --- a/zidl/ast/ast_void_type.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_ASTVOIDTYPE_H -#define OHOS_ZIDL_ASTVOIDTYPE_H - -#include "ast/ast_type.h" - -namespace OHOS { -namespace Zidl { - -class ASTVoidType : public ASTType { -public: - String GetSignature() override; - - bool IsVoidType() override; - - String ToString() override; -}; - -} -} - -#endif // OHOS_ZIDL_ASTBOOLEANTYPE_H \ No newline at end of file diff --git a/zidl/bundle.json b/zidl/bundle.json deleted file mode 100644 index 5127a051270..00000000000 --- a/zidl/bundle.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "@ohos/zidl", - "description": "提供自动生成Extension 服务端及客户端接口文件的能力", - "version": "3.1", - "license": "Apache License 2.0", - "publishAs": "code-segment", - "segment": { - "destPath": "foundation/aafwk/standard/zidl" - }, - "dirs": {}, - "scripts": {}, - "component": { - "name": "zidl", - "subsystem": "aafwk", - "syscap": [], - "features": [], - "adapted_system_type": [ - "standard" - ], - "rom": "", - "ram": "", - "deps": { - "components": [ - "hiviewdfx_hilog_native", - "ipc", - "samgr_standard", - "utils_base" - ], - "third_party": [] - }, - "build": { - "sub_component": [], - "inner_kits": [], - "test": [] - } - } -} \ No newline at end of file diff --git a/zidl/codegen/CMakeLists.txt b/zidl/codegen/CMakeLists.txt deleted file mode 100644 index bd4a8f37e98..00000000000 --- a/zidl/codegen/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -include_directories( - ${ZIDL_DIR}) - -set(SOURCES - code_emitter.cpp - code_generator.cpp - cpp_code_emitter.cpp - java_code_emitter.cpp) - -add_library(codegen STATIC - ${SOURCES}) \ No newline at end of file diff --git a/zidl/codegen/code_emitter.cpp b/zidl/codegen/code_emitter.cpp deleted file mode 100644 index 5dfda232720..00000000000 --- a/zidl/codegen/code_emitter.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "codegen/code_emitter.h" - -namespace OHOS { -namespace Zidl { - -const char* CodeEmitter::TAB = " "; - -CodeEmitter::CodeEmitter( - /* [in] */ MetaComponent* mc) - : metaComponent_(mc) -{ - metaInterface_ = nullptr; - for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { - metaInterface_ = metaComponent_->interfaces_[i]; - if (!metaInterface_->external_) { - break; - } - } - - if (metaInterface_ != nullptr) { - interfaceName_ = metaInterface_->name_; - interfaceFullName_ = metaInterface_->namespace_ + interfaceName_; - proxyName_ = interfaceName_.StartsWith("I") ? - interfaceName_.Substring(1) + "Proxy" : interfaceName_ + "Proxy"; - proxyFullName_ = metaInterface_->namespace_ + proxyName_; - stubName_ = interfaceName_.StartsWith("I") ? - interfaceName_.Substring(1) + "Stub" : interfaceName_ + "Stub"; - stubFullName_ = metaInterface_->namespace_ + stubName_; - } -} - -} -} diff --git a/zidl/codegen/code_emitter.h b/zidl/codegen/code_emitter.h deleted file mode 100644 index 4fd84ffd8b7..00000000000 --- a/zidl/codegen/code_emitter.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_CODEEMITTER_H -#define OHOS_ZIDL_CODEEMITTER_H - -#include "metadata/metadata.h" -#include "util/light_refcount_base.h" -#include "util/string.h" - -namespace OHOS { -namespace Zidl { - -class CodeEmitter : public LightRefCountBase { -public: - CodeEmitter( - /* [in] */ MetaComponent* mc); - - inline void SetDirectory( - /* [in] */ const String& directory) - { - directory_ = directory; - } - - virtual void EmitInterface() = 0; - - virtual void EmitInterfaceProxy() = 0; - - virtual void EmitInterfaceStub() = 0; - -protected: - static const char* TAB; - - MetaComponent* metaComponent_; - MetaInterface* metaInterface_; - String directory_; - String interfaceName_; - String interfaceFullName_; - String proxyName_; - String proxyFullName_; - String stubName_; - String stubFullName_; -}; - -} -} - -#endif // OHOS_ZIDL_CODEEMITTER_H diff --git a/zidl/codegen/code_generator.cpp b/zidl/codegen/code_generator.cpp deleted file mode 100644 index 9e0c190cf29..00000000000 --- a/zidl/codegen/code_generator.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "codegen/code_generator.h" -#include -#include -#include -#include "codegen/cpp_code_emitter.h" -#include "codegen/java_code_emitter.h" -#include "codegen/js_code_emitter.h" -#include "util/logger.h" - -namespace OHOS { -namespace Zidl { - -const char* CodeGenerator::TAG = "CodeGenerator"; - -CodeGenerator::CodeGenerator( - /* [in] */ MetaComponent* mc, - /* [in] */ const String& language, - /* [in] */ const String& dir) - : targetLanguage_(language), - targetDirectory_(dir), - metaComponent_(mc) -{ - if (language.Equals("cpp")) { - emitter_ = new CppCodeEmitter(metaComponent_); - } else if (language.Equals("java")) { - emitter_ = new JavaCodeEmitter(metaComponent_); - } else if (language.Equals("js")) { - emitter_ = new JsCodeEmitter(metaComponent_); - } -} - -bool CodeGenerator::ResolveDirectory() -{ -#ifdef __MINGW32__ - if(targetDirectory_.IndexOf(":\\") == -1) { - char* cmd = getcwd(nullptr, 0); - targetDirectory_ = String::Format("%s\\%s", cmd, targetDirectory_.string()); - free(cmd); - } -#else - if (!targetDirectory_.StartsWith("/")) { - char* cwd = getcwd(nullptr, 0); - targetDirectory_ = String::Format("%s/%s", cwd, targetDirectory_.string()); - free(cwd); - } -#endif - - if (!access(targetDirectory_.string(), R_OK | W_OK)) { - return true; - } - -#ifdef __MINGW32__ - if (mkdir(targetDirectory_.string()) != 0) { -#else - if (mkdir(targetDirectory_.string(), S_IRWXU | S_IRWXG | S_IRWXO) != 0) { -#endif - Logger::E(TAG, "Create \"%s\" directory failed.", targetDirectory_.string()); - return false; - } - - return true; -} - -bool CodeGenerator::Generate() -{ - if (!ResolveDirectory()) { - return false; - } - - emitter_->SetDirectory(targetDirectory_); - - emitter_->EmitInterface(); - emitter_->EmitInterfaceProxy(); - emitter_->EmitInterfaceStub(); - - return true; -} - -} -} diff --git a/zidl/codegen/code_generator.h b/zidl/codegen/code_generator.h deleted file mode 100644 index 43eca9157fe..00000000000 --- a/zidl/codegen/code_generator.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_CODEGENERATOR_H -#define OHOS_ZIDL_CODEGENERATOR_H - -#include "codegen/code_emitter.h" -#include "metadata/metadata.h" -#include "util/autoptr.h" -#include "util/string.h" - -namespace OHOS { -namespace Zidl { - -class CodeGenerator { -public: - CodeGenerator( - /* [in] */ MetaComponent* mc, - /* [in] */ const String& language, - /* [in] */ const String& dir); - - ~CodeGenerator() = default; - - bool Generate(); - -private: - bool ResolveDirectory(); - - - static const char* TAG; - String targetLanguage_; - String targetDirectory_; - MetaComponent* metaComponent_; - AutoPtr emitter_; -}; - -} -} - -#endif // OHOS_ZIDL_CODEGENERATOR_H diff --git a/zidl/codegen/cpp_code_emitter.cpp b/zidl/codegen/cpp_code_emitter.cpp deleted file mode 100644 index 8e23b8989ce..00000000000 --- a/zidl/codegen/cpp_code_emitter.cpp +++ /dev/null @@ -1,1175 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "codegen/cpp_code_emitter.h" - -#include -#include - -#include "securec.h" -#include "util/file.h" - -namespace OHOS { -namespace Zidl { - -void CppCodeEmitter::EmitInterface() -{ - EmitInterfaceHeaderFile(); -} - -void CppCodeEmitter::EmitInterfaceHeaderFile() -{ - String filePath = String::Format("%s/%s.h", directory_.string(), FileName(interfaceName_).string()); - File file(filePath, File::WRITE); - - StringBuilder sb; - - EmitLicense(sb); - sb.Append("\n"); - EmitHeadMacro(sb, interfaceFullName_); - sb.Append("\n"); - EmitInterfaceInclusions(sb); - sb.Append("\n"); - if (EmitInterfaceUsings(sb)) { - sb.Append("\n"); - } - EmitInterfaceDefinition(sb); - EmitTailMacro(sb, interfaceFullName_); - - String data = sb.ToString(); - file.WriteData(data.string(), data.GetLength()); - file.Flush(); - file.Close(); -} - -void CppCodeEmitter::EmitInterfaceInclusions( - /* [in] */ StringBuilder& sb) -{ - EmitInterfaceStdlibInclusions(sb); - EmitInterfaceDBinderInclusions(sb); - // EmitInterfaceParametersInclusions(sb); no idea what does this do - EmitInterfaceSelfDefinedTypeInclusions(sb); -} - -void CppCodeEmitter::EmitInterfaceStdlibInclusions( - /* [in] */ StringBuilder& sb) -{ - bool includeString = false; - bool includeList = false; - bool includeMap = false; - bool includeNum = false; - for (int i = 0; i < metaComponent_->typeNumber_; i++) { - MetaType* mt = metaComponent_->types_[i]; - switch(mt->kind_) { - case TypeKind::Byte: { - if (!includeNum) { - sb.Append("#include \n"); - includeNum = true; - } - break; - } - case TypeKind::String: { - if (!includeString) { - sb.Append("#include \n"); - includeString = true; - } - break; - } - case TypeKind::Array: - case TypeKind::List: { - if (!includeList) { - sb.Append("#include \n"); - includeList = true; - } - break; - } - case TypeKind::Map: { - if (!includeMap) { - sb.Append("#include \n"); - includeMap = true; - } - break; - } - default: - break; - } - } -} - -void CppCodeEmitter::EmitInterfaceDBinderInclusions( - /* [in] */ StringBuilder& sb) -{ - sb.Append("#include \n"); -} - -void CppCodeEmitter::EmitInterfaceParametersInclusions( - /* [in] */ StringBuilder& sb) -{ - sb.Append("#include \"parameters.h\"\n"); -} - -String CppCodeEmitter::GetFilePath(const String& fpnp) -{ - int pos = fpnp.IndexOf(".."); - if (pos == -1) { - return String(); - } - String res = fpnp.Substring(0, pos + 1); - return res; -} - -String CppCodeEmitter::GetNamespace(const String& fpnp) -{ - int pos = fpnp.IndexOf(".."); - if (pos == -1) { - return fpnp; - } - String res = fpnp.Substring(pos + 2); - return res; -} - -void CppCodeEmitter::EmitInterfaceSelfDefinedTypeInclusions( - /* [in] */ StringBuilder& sb) -{ - for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { - MetaSequenceable* mp = metaComponent_->sequenceables_[i]; - String filePath = GetFilePath(String(mp->namespace_)); - String fileName = FileName(filePath + mp->name_); - sb.Append("#include ").AppendFormat("\"%s.h\"\n", fileName.string()); - } - - for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { - MetaInterface* mi = metaComponent_->interfaces_[i]; - if (mi->external_) { - String filePath = GetFilePath(String(mi->namespace_)); - String fileName = FileName(filePath + mi->name_); - sb.Append("#include ").AppendFormat("\"%s.h\"\n", fileName.string()); - } - } -} - -bool CppCodeEmitter::EmitInterfaceUsings( - /* [in] */ StringBuilder& sb) -{ - bool ret = false; - for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { - MetaSequenceable* mp = metaComponent_->sequenceables_[i]; - String np = GetNamespace(String(mp->namespace_)); - if (np.IsEmpty()) { - continue; - } - String fullName = CppFullName(np + mp->name_); - sb.Append("using ").AppendFormat("%s;\n", fullName.string()); - ret = true; - } - - for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { - MetaInterface* mi = metaComponent_->interfaces_[i]; - if (mi->external_) { - String np = GetNamespace(String(mi->namespace_)); - if (np.IsEmpty()) { - continue; - } - String fullName = CppFullName(np + mi->name_); - sb.Append("using ").AppendFormat("%s;\n", fullName.string()); - ret = true; - } - } - return ret; -} - -void CppCodeEmitter::EmitInterfaceDefinition( - /* [in] */ StringBuilder& sb) -{ - EmitBeginNamespace(sb); - sb.AppendFormat("class %s : public IRemoteBroker {\n", metaInterface_->name_); - sb.Append("public:\n"); - EmitInterfaceBody(sb, TAB); - sb.Append("};\n"); - EmitEndNamespace(sb); -} - -void CppCodeEmitter::EmitInterfaceBody( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - String nameWithoutPath = GetNamespace(interfaceFullName_); - sb.Append(TAB).AppendFormat("DECLARE_INTERFACE_DESCRIPTOR(u\"%s\");\n", nameWithoutPath.string()); - sb.Append("\n"); - EmitInterfaceMethods(sb, TAB); -} - -void CppCodeEmitter::EmitInterfaceMethods( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - if (metaInterface_->methodNumber_ > 0) { - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - EmitInterfaceMethod(mm, sb, prefix); - if (i != metaInterface_->methodNumber_ - 1) { - sb.Append("\n"); - } - } - } -} - -void CppCodeEmitter::EmitInterfaceMethod( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; - if (mm->parameterNumber_ == 0 && returnType->kind_ == TypeKind::Void) { - sb.Append(prefix).AppendFormat("virtual ErrCode %s() = 0;\n", mm->name_); - } else { - sb.Append(prefix).AppendFormat("virtual ErrCode %s(\n", mm->name_); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - EmitInterfaceMethodParameter(mp, sb, prefix + TAB); - if (i != mm->parameterNumber_ - 1 || returnType->kind_ != TypeKind::Void) { - sb.Append(",\n"); - } - } - if (returnType->kind_ != TypeKind::Void) { - EmitInterfaceMethodReturn(returnType, sb, prefix + TAB); - } - sb.Append(") = 0;\n"); - } -} - -void CppCodeEmitter::EmitInterfaceMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - if ((mp->attributes_ & ATTR_MASK) == (ATTR_IN | ATTR_OUT)) { - sb.Append(prefix).Append("/* [in, out] */ "); - } else if (mp->attributes_ & ATTR_IN) { - sb.Append(prefix).Append("/* [in] */ "); - } else { - sb.Append(prefix).Append("/* [out] */ "); - } - - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - const std::string name = UnderlineAdded(mp->name_); - sb.AppendFormat("%s %s", EmitType(mt, mp->attributes_, false).string(), name.c_str()); -} - -void CppCodeEmitter::EmitInterfaceMethodReturn( - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("/* [out] */ %s result", EmitType(mt, ATTR_OUT, false).string()); -} - -void CppCodeEmitter::EmitInterfaceProxy() -{ - EmitInterfaceProxyHeaderFile(); - EmitInterfaceProxyCppFile(); -} - -void CppCodeEmitter::EmitInterfaceProxyHeaderFile() -{ - String filePath = String::Format("%s/%s.h", directory_.string(), FileName(proxyName_).string()); - File file(filePath, File::WRITE); - - StringBuilder sb; - - EmitLicense(sb); - sb.Append("\n"); - EmitHeadMacro(sb, proxyFullName_); - sb.Append("\n"); - sb.AppendFormat("#include \"%s.h\"\n", FileName(interfaceName_).string()); - sb.Append("#include \n"); - sb.Append("\n"); - EmitInterfaceProxyInHeaderFile(sb); - EmitTailMacro(sb, proxyFullName_); - - String data = sb.ToString(); - file.WriteData(data.string(), data.GetLength()); - file.Flush(); - file.Close(); -} - -void CppCodeEmitter::EmitInterfaceProxyInHeaderFile( - /* [in] */ StringBuilder& sb) -{ - EmitBeginNamespace(sb); - sb.AppendFormat("class %s : public IRemoteProxy<%s> {\n", - proxyName_.string(), interfaceName_.string()); - sb.Append("public:\n"); - EmitInterfaceProxyConstructor(sb, TAB); - sb.Append("\n"); - EmitInterfaceProxyMethodDecls(sb, TAB); - sb.Append("\n"); - sb.Append("private:\n"); - EmitInterfaceProxyConstants(sb, TAB); - sb.Append("};\n"); - EmitEndNamespace(sb); -} - -void CppCodeEmitter::EmitInterfaceProxyConstructor( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("explicit %s(\n", proxyName_.string()); - sb.Append(prefix + TAB).Append("/* [in] */ const sptr& remote)\n"); - sb.Append(prefix + TAB).AppendFormat(": IRemoteProxy<%s>(remote)\n", interfaceName_.string()); - sb.Append(prefix).Append("{}\n"); - sb.Append("\n"); - sb.Append(prefix).AppendFormat("virtual ~%s()\n", proxyName_.string()); - sb.Append(prefix).Append("{}\n"); -} - -void CppCodeEmitter::EmitInterfaceProxyMethodDecls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - if (metaInterface_->methodNumber_ > 0) { - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - EmitInterfaceProxyMethodDecl(mm, sb, prefix); - if (i != metaInterface_->methodNumber_ - 1) { - sb.Append("\n"); - } - } - } -} - -void CppCodeEmitter::EmitInterfaceProxyMethodDecl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; - if (mm->parameterNumber_ == 0 && returnType->kind_ == TypeKind::Void) { - sb.Append(prefix).AppendFormat("ErrCode %s() override;\n", mm->name_); - } else { - sb.Append(prefix).AppendFormat("ErrCode %s(\n", mm->name_); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - EmitInterfaceMethodParameter(mp, sb, prefix + TAB); - if (i != mm->parameterNumber_ - 1 || returnType->kind_ != TypeKind::Void) { - sb.Append(",\n"); - } - } - if (returnType->kind_ != TypeKind::Void) { - EmitInterfaceMethodReturn(returnType, sb, prefix + TAB); - } - sb.Append(") override;\n"); - } -} - -void CppCodeEmitter::EmitInterfaceProxyConstants( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - EmitInterfaceMethodCommands(sb, prefix); - sb.Append("\n"); - sb.Append(prefix).AppendFormat("static inline BrokerDelegator<%s> delegator_;\n", proxyName_.string()); -} - -void CppCodeEmitter::EmitInterfaceProxyCppFile() -{ - String filePath = String::Format("%s/%s.cpp", directory_.string(), FileName(proxyName_).string()); - File file(filePath, File::WRITE); - - StringBuilder sb; - - EmitLicense(sb); - sb.Append("\n"); - sb.AppendFormat("#include \"%s.h\"\n", FileName(proxyName_).string()); - sb.Append("\n"); - EmitBeginNamespace(sb); - EmitInterfaceProxyMethodImpls(sb, ""); - EmitEndNamespace(sb); - - String data = sb.ToString(); - file.WriteData(data.string(), data.GetLength()); - file.Flush(); - file.Close(); -} - -void CppCodeEmitter::EmitInterfaceProxyMethodImpls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - if (metaInterface_->methodNumber_ > 0) { - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - EmitInterfaceProxyMethodImpl(mm, sb, prefix); - if (i != metaInterface_->methodNumber_ - 1) { - sb.Append("\n"); - } - } - } -} - -void CppCodeEmitter::EmitInterfaceProxyMethodImpl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; - if (mm->parameterNumber_ == 0 && returnType->kind_ == TypeKind::Void) { - sb.Append(prefix).AppendFormat("ErrCode %s::%s()\n", proxyName_.string(), mm->name_); - } else { - sb.Append(prefix).AppendFormat("ErrCode %s::%s(\n", proxyName_.string(), mm->name_); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - EmitInterfaceMethodParameter(mp, sb, prefix + TAB); - if (i != mm->parameterNumber_ - 1 || returnType->kind_ != TypeKind::Void) { - sb.Append(",\n"); - } - } - if (returnType->kind_ != TypeKind::Void) { - EmitInterfaceMethodReturn(returnType, sb, prefix + TAB); - } - sb.Append(")\n"); - } - EmitInterfaceProxyMethodBody(mm, sb, prefix); -} - -void CppCodeEmitter::EmitInterfaceProxyMethodBody( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).Append("{\n"); - sb.Append(prefix + TAB).Append("MessageParcel data;\n"); - sb.Append(prefix + TAB).Append("MessageParcel reply;\n"); - sb.Append(prefix + TAB).AppendFormat("MessageOption option(%s);\n", - (mm->properties_ & METHOD_PROPERTY_ONEWAY) != 0 - ? "MessageOption::TF_ASYNC" : "MessageOption::TF_SYNC"); - sb.Append("\n"); - - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - if ((mp->attributes_ & ATTR_IN) != 0) { - EmitWriteMethodParameter(mp, "data.", sb, prefix + TAB); - } - } - sb.Append("\n"); - sb.Append(prefix + TAB).AppendFormat("int32_t st = Remote()->SendRequest(COMMAND_%s, data, reply, option);\n", - ConstantName(mm->name_).string()); - sb.Append(prefix + TAB).Append("if (st != ERR_NONE) {\n"); - sb.Append(prefix + TAB).Append(" return st;\n"); - sb.Append(prefix + TAB).Append("}\n"); - if ((mm->properties_ & METHOD_PROPERTY_ONEWAY) == 0) { - sb.Append("\n"); - sb.Append(prefix + TAB).Append("ErrCode ec = reply.ReadInt32();\n"); - sb.Append(prefix + TAB).Append("if (FAILED(ec)) {\n"); - sb.Append(prefix + TAB).Append(" return ec;\n"); - sb.Append(prefix + TAB).Append("}\n"); - sb.Append("\n"); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - if ((mp->attributes_ & ATTR_OUT) != 0) { - EmitReadMethodParameter(mp, "reply.", sb, prefix + TAB); - } - } - MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; - if (returnType->kind_ != TypeKind::Void) { - EmitReadVariable("reply.", "result", returnType, sb, prefix + TAB, false); - } - } - sb.Append(prefix + TAB).Append("return ERR_OK;\n"); - sb.Append(prefix).Append("}\n"); -} - -void CppCodeEmitter::EmitWriteMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ const String& parcelName, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - const std::string name = UnderlineAdded(mp->name_); - EmitWriteVariable(parcelName, name, mt, sb, prefix); -} - -void CppCodeEmitter::EmitReadMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ const String& parcelName, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - const std::string name = UnderlineAdded(mp->name_); - EmitReadVariable(parcelName, name, mt, sb, prefix, false); -} - -void CppCodeEmitter::EmitInterfaceStub() -{ - EmitInterfaceStubHeaderFile(); - EmitInterfaceStubCppFile(); -} - -void CppCodeEmitter::EmitInterfaceStubHeaderFile() -{ - String filePath = String::Format("%s/%s.h", directory_.string(), FileName(stubName_).string()); - File file(filePath, File::WRITE); - - StringBuilder sb; - - EmitLicense(sb); - sb.Append("\n"); - EmitHeadMacro(sb, stubFullName_); - sb.Append("\n"); - sb.AppendFormat("#include \"%s.h\"\n", FileName(interfaceName_).string()); - sb.Append("#include \n"); - sb.Append("\n"); - EmitInterfaceStubInHeaderFile(sb); - EmitTailMacro(sb, stubFullName_); - - String data = sb.ToString(); - file.WriteData(data.string(), data.GetLength()); - file.Flush(); - file.Close(); -} - -void CppCodeEmitter::EmitInterfaceStubInHeaderFile( - /* [in] */ StringBuilder& sb) -{ - EmitBeginNamespace(sb); - sb.AppendFormat("class %s : public IRemoteStub<%s> {\n", stubName_.string(), interfaceName_.string()); - sb.Append("public:\n"); - EmitInterfaceStubMethodDecls(sb, TAB); - sb.Append("\n"); - sb.Append("private:\n"); - EmitInterfaceStubConstants(sb, TAB); - sb.Append("};\n"); - EmitEndNamespace(sb); -} - -void CppCodeEmitter::EmitInterfaceStubMethodDecls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).Append("int OnRemoteRequest(\n"); - sb.Append(prefix + TAB).Append("/* [in] */ uint32_t code,\n"); - sb.Append(prefix + TAB).Append("/* [in] */ MessageParcel& data,\n"); - sb.Append(prefix + TAB).Append("/* [out] */ MessageParcel& reply,\n"); - sb.Append(prefix + TAB).Append("/* [in] */ MessageOption& option) override;\n"); -} - -void CppCodeEmitter::EmitInterfaceStubConstants( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - EmitInterfaceMethodCommands(sb, prefix); -} - -void CppCodeEmitter::EmitInterfaceStubCppFile() -{ - String filePath = String::Format("%s/%s.cpp", directory_.string(), FileName(stubName_).string()); - File file(filePath, File::WRITE); - - StringBuilder sb; - - EmitLicense(sb); - sb.Append("\n"); - sb.AppendFormat("#include \"%s.h\"\n", FileName(stubName_).string()); - sb.Append("\n"); - EmitBeginNamespace(sb); - EmitInterfaceStubMethodImpls(sb, ""); - EmitEndNamespace(sb); - - String data = sb.ToString(); - file.WriteData(data.string(), data.GetLength()); - file.Flush(); - file.Close(); -} - -void CppCodeEmitter::EmitInterfaceStubMethodImpls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("int %s::OnRemoteRequest(\n", stubName_.string()); - sb.Append(prefix + TAB).Append("/* [in] */ uint32_t code,\n"); - sb.Append(prefix + TAB).Append("/* [in] */ MessageParcel& data,\n"); - sb.Append(prefix + TAB).Append("/* [out] */ MessageParcel& reply,\n"); - sb.Append(prefix + TAB).Append("/* [in] */ MessageOption& option)\n"); - sb.Append(prefix).Append("{\n"); - sb.Append(prefix + TAB).Append("switch (code) {\n"); - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - EmitInterfaceStubMethodImpl(mm, sb, prefix + TAB + TAB); - } - sb.Append(prefix + TAB).Append(TAB).Append("default:\n"); - sb.Append(prefix + TAB).Append(TAB).Append(TAB).Append( - "return IPCObjectStub::OnRemoteRequest(code, data, reply, option);\n"); - sb.Append(prefix + TAB).Append("}\n\n"); - sb.Append(prefix + TAB).Append("return ERR_TRANSACTION_FAILED;\n"); - sb.Append(prefix).Append("}\n"); -} - -void CppCodeEmitter::EmitInterfaceStubMethodImpl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("case COMMAND_%s: {\n", ConstantName(mm->name_).string()); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - if ((mp->attributes_ & ATTR_IN) != 0) { - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - const std::string name = UnderlineAdded(mp->name_); - EmitReadVariable("data.", name, mt, sb, prefix + TAB); - } else if ((mp->attributes_ & ATTR_OUT) != 0) { - EmitLocalVariable(mp, sb, prefix + TAB); - } - } - MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; - if (returnType->kind_ != TypeKind::Void) { - if ((returnType->kind_ == TypeKind::Sequenceable) || (returnType->kind_ == TypeKind::Interface)) { - sb.Append(prefix + TAB).AppendFormat("%s result = nullptr;\n", EmitType(returnType, ATTR_IN, true).string()); - } else { - sb.Append(prefix + TAB).AppendFormat("%s result;\n", EmitType(returnType, ATTR_IN, true).string()); - } - } - if (mm->parameterNumber_ == 0 && returnType->kind_ == TypeKind::Void) { - sb.Append(prefix + TAB).AppendFormat("ErrCode ec = %s();\n", mm->name_); - } else { - sb.Append(prefix + TAB).AppendFormat("ErrCode ec = %s(", mm->name_); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - const std::string name = UnderlineAdded(mp->name_); - sb.Append(name.c_str()); - if (i != mm->parameterNumber_ - 1 || returnType->kind_ != TypeKind::Void) { - sb.Append(", "); - } - } - if (returnType->kind_ != TypeKind::Void) { - EmitReturnParameter("result", returnType, sb); - } - sb.AppendFormat(");\n", mm->name_); - } - sb.Append(prefix + TAB).Append("reply.WriteInt32(ec);\n"); - bool hasOutParameter = false; - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - if ((mp->attributes_ & ATTR_OUT) != 0) { - hasOutParameter = true; - } - } - if (hasOutParameter || returnType->kind_ != TypeKind::Void) { - sb.Append(prefix + TAB).Append("if (SUCCEEDED(ec)) {\n"); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - if ((mp->attributes_ & ATTR_OUT) != 0) { - EmitWriteMethodParameter(mp, "reply.", sb, prefix + TAB + TAB); - } - } - if (returnType->kind_ != TypeKind::Void) { - EmitWriteVariable("reply.", "result", returnType, sb, prefix + TAB + TAB); - } - sb.Append(prefix + TAB).Append("}\n"); - } - sb.Append(prefix + TAB).Append("return ERR_NONE;\n"); - sb.Append(prefix).Append("}\n"); -} - -void CppCodeEmitter::EmitInterfaceMethodCommands( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - sb.Append(prefix).AppendFormat("static constexpr int COMMAND_%s = MIN_TRANSACTION_ID + %d;\n", ConstantName(mm->name_).string(), i); - } -} - -void CppCodeEmitter::EmitLicense( - /* [in] */ StringBuilder& sb) -{ - sb.Append(metaInterface_->license_).Append("\n"); -} - -void CppCodeEmitter::EmitHeadMacro( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& fullName) -{ - String macroName = MacroName(fullName); - sb.Append("#ifndef ").Append(macroName).Append("\n"); - sb.Append("#define ").Append(macroName).Append("\n"); -} - -void CppCodeEmitter::EmitTailMacro( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& fullName) -{ - String macroName = MacroName(fullName); - sb.Append("#endif // ").Append(macroName).Append("\n\n"); -} - -void CppCodeEmitter::EmitBeginNamespace( - /* [in] */ StringBuilder& sb) -{ - String nspace = GetNamespace(metaInterface_->namespace_); - int index = nspace.IndexOf('.'); - while (index != -1) { - sb.AppendFormat("namespace %s {\n", nspace.Substring(0, index).string()); - nspace = nspace.Substring(index + 1); - index = nspace.IndexOf('.'); - } -} - -void CppCodeEmitter::EmitEndNamespace( - /* [in] */ StringBuilder& sb) -{ - String nspace = GetNamespace(metaInterface_->namespace_); - nspace = nspace.Substring(0, nspace.GetLength() - 1); - while (!nspace.IsEmpty()) { - int index = nspace.LastIndexOf('.'); - sb.AppendFormat("} // namespace %s\n", index != -1 - ? nspace.Substring(index + 1, nspace.GetLength()).string() - : nspace.string()); - nspace = nspace.Substring(0, index); - } -} - -void CppCodeEmitter::EmitWriteVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - switch (mt->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("%sWriteInt32(%s ? 1 : 0);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Char: - case TypeKind::Byte: - case TypeKind::Short: - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("%sWriteInt32(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("%sWriteInt64(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("%sWriteFloat(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("%sWriteDouble(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("%sWriteString16(Str8ToStr16(%s));\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Sequenceable: - sb.Append(prefix).AppendFormat("%sWriteParcelable(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Interface: - sb.Append(prefix).AppendFormat("%sWriteRemoteObject(%s->AsObject());\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Array: - case TypeKind::List: { - sb.Append(prefix).AppendFormat("%sWriteInt32(%s.size());\n", parcelName.string(), name.c_str()); - sb.Append(prefix).AppendFormat("for (auto it = %s.begin(); it != %s.end(); ++it) {\n", - name.c_str(), name.c_str()); - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - EmitWriteVariable(parcelName, "(*it)", innerType, sb, prefix + TAB); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Map: { - sb.Append(prefix).AppendFormat("%sWriteInt32(%s.size());\n", parcelName.string(), name.c_str()); - sb.Append(prefix).AppendFormat("for (auto it = %s.begin(); it != %s.end(); ++it) {\n", - name.c_str(), name.c_str()); - MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; - EmitWriteVariable(parcelName, "(it->first)", keyType, sb, prefix + TAB); - EmitWriteVariable(parcelName, "(it->second)", valueType, sb, prefix + TAB); - sb.Append(prefix).Append("}\n"); - break; - } - default: - break; - } -} - -void CppCodeEmitter::EmitReadVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix, - /* [in] */ bool emitType) -{ - switch (mt->kind_) { - case TypeKind::Boolean: - if (emitType) { - sb.Append(prefix).AppendFormat("%s %s = %sReadInt32() == 1 ? true : false;\n", - EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string()); - } else { - sb.Append(prefix).AppendFormat("%s = %sReadInt32() == 1 ? true : false;\n", - name.c_str(), parcelName.string()); - } - break; - case TypeKind::Char: - case TypeKind::Byte: - case TypeKind::Short: - if (emitType) { - sb.Append(prefix).AppendFormat("%s %s = (%s)%sReadInt32();\n", EmitType(mt, ATTR_IN, true).string(), - name.c_str(), EmitType(mt, ATTR_IN, true).string(), parcelName.string()); - } else { - sb.Append(prefix).AppendFormat("%s = (%s)%sReadInt32();\n", name.c_str(), - EmitType(mt, ATTR_IN, true).string(), parcelName.string()); - } - break; - case TypeKind::Integer: - if (emitType) { - sb.Append(prefix).AppendFormat("%s %s = %sReadInt32();\n", - EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string()); - } else { - sb.Append(prefix).AppendFormat("%s = %sReadInt32();\n", name.c_str(), parcelName.string()); - } - break; - case TypeKind::Long: - if (emitType) { - sb.Append(prefix).AppendFormat("%s %s = %sReadInt64();\n", - EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string()); - } else { - sb.Append(prefix).AppendFormat("%s = %sReadInt64();\n", name.c_str(), parcelName.string()); - } - break; - case TypeKind::Float: - if (emitType) { - sb.Append(prefix).AppendFormat("%s %s = %sReadFloat();\n", - EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string()); - } else { - sb.Append(prefix).AppendFormat("%s = %sReadFloat();\n", name.c_str(), parcelName.string()); - } - break; - case TypeKind::Double: - if (emitType) { - sb.Append(prefix).AppendFormat("%s %s = %sReadDouble();\n", - EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string()); - } else { - sb.Append(prefix).AppendFormat("%s = %sReadDouble();\n", name.c_str(), parcelName.string()); - } - break; - case TypeKind::String: - if (emitType) { - sb.Append(prefix).AppendFormat("%s %s = Str16ToStr8(%sReadString16());\n", - EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string()); - } else { - sb.Append(prefix).AppendFormat("%s = Str16ToStr8(%sReadString16());\n", - name.c_str(), parcelName.string()); - } - break; - case TypeKind::Sequenceable: { - MetaSequenceable* mp = metaComponent_->sequenceables_[mt->index_]; - if (emitType) { - sb.Append(prefix).AppendFormat("%s %s = %sReadParcelable<%s>();\n", - EmitType(mt, ATTR_IN, true).string(), name.c_str(), parcelName.string(), mp->name_); - } else { - sb.Append(prefix).AppendFormat("%s = %sReadParcelable<%s>();\n", - name.c_str(), parcelName.string(), mp->name_); - } - break; - } - case TypeKind::Interface: { - MetaInterface* mi = metaComponent_->interfaces_[mt->index_]; - if (emitType) { - sb.Append(prefix).AppendFormat("%s %s = iface_cast<%s>(%sReadRemoteObject());\n", - EmitType(mt, ATTR_IN, true).string(), name.c_str(), mi->name_, parcelName.string()); - } else { - sb.Append(prefix).AppendFormat("%s = iface_cast<%s>(%sReadRemoteObject());\n", - name.c_str(), mi->name_, parcelName.string()); - } - break; - } - case TypeKind::Array: - case TypeKind::List: { - if (emitType) { - sb.Append(prefix).AppendFormat("%s %s;\n", EmitType(mt, ATTR_IN, true).string(), name.c_str()); - } - sb.Append(prefix).AppendFormat("int %sSize = %sReadInt32();\n", name.c_str(), parcelName.string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - EmitReadVariable(parcelName, "value", innerType, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s.push_back(value);\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Map: { - if (emitType) { - sb.Append(prefix).AppendFormat("%s %s;\n", EmitType(mt, ATTR_IN, true).string(), name.c_str()); - } - sb.Append(prefix).AppendFormat("int %sSize = %sReadInt32();\n", name.c_str(), parcelName.string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); - MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; - EmitReadVariable(parcelName, "key", keyType, sb, prefix + TAB); - EmitReadVariable(parcelName, "value", valueType, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s[key] = value;\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - } - default: - break; - } -} - -void CppCodeEmitter::EmitLocalVariable( - /* [in] */ MetaParameter* mp, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - const std::string name = UnderlineAdded(mp->name_); - if ((mt->kind_ == TypeKind::Sequenceable) || (mt->kind_ == TypeKind::Interface)) { - sb.Append(prefix).AppendFormat("%s %s = nullptr;\n", EmitType(mt, ATTR_IN, true).string(), name.c_str()); - } else { - sb.Append(prefix).AppendFormat("%s %s;\n", EmitType(mt, ATTR_IN, true).string(), name.c_str()); - } -} - -void CppCodeEmitter::EmitReturnParameter( - /* [in] */ const String& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb) -{ - switch (mt->kind_) { - case TypeKind::Char: - case TypeKind::Boolean: - case TypeKind::Byte: - case TypeKind::Short: - case TypeKind::Integer: - case TypeKind::Long: - case TypeKind::Float: - case TypeKind::Double: - case TypeKind::String: - case TypeKind::Sequenceable: - case TypeKind::Interface: - case TypeKind::List: - case TypeKind::Map: - case TypeKind::Array: - sb.Append(name); - break; - default: - break; - } -} - -String CppCodeEmitter::EmitType( - /* [in] */ MetaType* mt, - /* [in] */ unsigned int attributes, - /* [in] */ bool isInnerType) -{ - switch(mt->kind_) { - case TypeKind::Char: - if (attributes & ATTR_IN) { - return "zchar"; - } else { - return "zchar&"; - } - case TypeKind::Boolean: - if (attributes & ATTR_IN) { - return "bool"; - } else { - return "bool&"; - } - case TypeKind::Byte: - if (attributes & ATTR_IN) { - return "int8_t"; - } else { - return "int8_t&"; - } - case TypeKind::Short: - if (attributes & ATTR_IN) { - return "short"; - } else { - return "short&"; - } - case TypeKind::Integer: - if (attributes & ATTR_IN) { - return "int"; - } else { - return "int&"; - } - case TypeKind::Long: - if (attributes & ATTR_IN) { - return "long"; - } else { - return "long&"; - } - case TypeKind::Float: - if (attributes & ATTR_IN) { - return "float"; - } else { - return "float&"; - } - case TypeKind::Double: - if (attributes & ATTR_IN) { - return "double"; - } else { - return "double&"; - } - case TypeKind::String: - if (attributes & ATTR_IN) { - if (!isInnerType) { - return "const std::string&"; - } else { - return "std::string"; - } - } else { - return "std::string&"; - } - case TypeKind::Void: - return "void"; - case TypeKind::Sequenceable: { - MetaSequenceable* mp = metaComponent_->sequenceables_[mt->index_]; - if ((attributes & ATTR_MASK) == (ATTR_IN | ATTR_OUT)) { - return String::Format("%s*", mp->name_); - } else if (attributes & ATTR_IN) { - return String::Format("%s*", mp->name_); - } else { - return String::Format("%s*", mp->name_); - } - } - case TypeKind::Interface: { - MetaInterface* mi = metaComponent_->interfaces_[mt->index_]; - if (attributes & ATTR_IN) { - if (!isInnerType) { - return String::Format("sptr<%s>", mi->name_); - } else { - return String::Format("sptr<%s>", mi->name_); - } - } else { - return String::Format("sptr<%s>&", mi->name_); - } - } - case TypeKind::Array: - case TypeKind::List: { - MetaType* elementType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - if (attributes & ATTR_OUT) { - return String::Format("std::vector<%s>&", - EmitType(elementType, ATTR_IN, true).string()); - } else { - if (!isInnerType) { - return String::Format("const std::vector<%s>&", - EmitType(elementType, ATTR_IN, true).string()); - } else { - return String::Format("std::vector<%s>", - EmitType(elementType, ATTR_IN, true).string()); - } - } - } - case TypeKind::Map: { - MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; - if (attributes & ATTR_OUT) { - return String::Format("std::unordered_map<%s, %s>&", - EmitType(keyType, ATTR_IN, true).string(), EmitType(valueType, ATTR_IN, true).string()); - } else { - if (!isInnerType) { - return String::Format("const std::unordered_map<%s, %s>&", - EmitType(keyType, ATTR_IN, true).string(), EmitType(valueType, ATTR_IN, true).string()); - } else { - return String::Format("std::unordered_map<%s, %s>", - EmitType(keyType, ATTR_IN, true).string(), EmitType(valueType, ATTR_IN, true).string()); - } - } - break; - } - default: - return "unknown type"; - } -} - -String CppCodeEmitter::CppFullName( - /* [in] */ const String& name) -{ - if (name.IsEmpty()) { - return name; - } - - return name.Replace(".", "::"); -} - -String CppCodeEmitter::FileName( - /* [in] */ const String& name) -{ - if (name.IsEmpty()) { - return name; - } - - StringBuilder sb; - - for (int i = 0; i < name.GetLength(); i++) { - char c = name[i]; - if (isupper(c) != 0) { - // 2->Index of the last char array. - if (i > 1 && name[i - 1] != '.' && name[i - 2] != '.') { - sb.Append('_'); - } - sb.Append(tolower(c)); - } else { - sb.Append(c); - } - } - - return sb.ToString().Replace('.', '/'); -} - -String CppCodeEmitter::MacroName( - /* [in] */ const String& name) -{ - if (name.IsEmpty()) { - return name; - } - - String macro = name.Replace('.', '_').ToUpperCase() + "_H"; - return macro; -} - -String CppCodeEmitter::ConstantName( - /* [in] */ const String& name) -{ - if (name.IsEmpty()) { - return name; - } - - StringBuilder sb; - - for (int i = 0; i < name.GetLength(); i++) { - char c = name[i]; - if (isupper(c) != 0) { - if (i > 1) { - sb.Append('_'); - } - sb.Append(c); - } else { - sb.Append(toupper(c)); - } - } - - return sb.ToString(); -} - -const std::string CppCodeEmitter::UnderlineAdded(const String& originName) -{ - std::string underline("_"); - return underline + std::string(originName.string()); -} - -} -} diff --git a/zidl/codegen/cpp_code_emitter.h b/zidl/codegen/cpp_code_emitter.h deleted file mode 100644 index f130be83af3..00000000000 --- a/zidl/codegen/cpp_code_emitter.h +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_CPPCODEEMITTER_H -#define OHOS_ZIDL_CPPCODEEMITTER_H - -#include - -#include "codegen/code_emitter.h" -#include "util/string_builder.h" - -namespace OHOS { -namespace Zidl { - -class CppCodeEmitter : public CodeEmitter { -public: - CppCodeEmitter( - /* [in] */ MetaComponent* mc) - : CodeEmitter(mc) - {} - - void EmitInterface() override; - - void EmitInterfaceProxy() override; - - void EmitInterfaceStub() override; - -private: - void EmitInterfaceHeaderFile(); - - void EmitInterfaceInclusions( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceStdlibInclusions( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceDBinderInclusions( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceParametersInclusions( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceSelfDefinedTypeInclusions( - /* [in] */ StringBuilder& sb); - - bool EmitInterfaceUsings( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceSelfDefinedTypeUsings( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceDefinition( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceBody( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceMethods( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceMethod( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceMethodReturn( - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyHeaderFile(); - - void EmitInterfaceProxyInHeaderFile( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceProxyConstructor( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyMethodDecls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyMethodDecl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyConstants( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyCppFile(); - - void EmitInterfaceProxyMethodImpls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyMethodImpl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyMethodBody( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitWriteMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ const String& parcelName, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReadMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ const String& parcelName, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceStubHeaderFile(); - - void EmitInterfaceStubInHeaderFile( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceStubMethodDecls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceStubConstants( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceStubCppFile(); - - void EmitInterfaceStubMethodImpls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceStubMethodImpl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceMethodCommands( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitLicense( - /* [in] */ StringBuilder& sb); - - void EmitHeadMacro( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& fullName); - - void EmitTailMacro( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& fullName); - - void EmitBeginNamespace( - /* [in] */ StringBuilder& sb); - - void EmitEndNamespace( - /* [in] */ StringBuilder& sb); - - void EmitWriteVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReadVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix, - /* [in] */ bool emitType = true); - - void EmitLocalVariable( - /* [in] */ MetaParameter* mp, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReturnParameter( - /* [in] */ const String& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb); - - String EmitType( - /* [in] */ MetaType* mt, - /* [in] */ unsigned int attributes, - /* [in] */ bool isInnerType); - - String FileName( - /* [in] */ const String& name); - - String GetFilePath(const String& fpnp); - - String GetNamespace(const String& fpnp); - - String MacroName( - /* [in] */ const String& name); - - String CppFullName( - /* [in] */ const String& name); - - String ConstantName( - /* [in] */ const String& name); - - const std::string UnderlineAdded(const String& name); -}; - -} -} - -#endif // OHOS_ZIDL_CPPCODEEMITTER_H diff --git a/zidl/codegen/java_code_emitter.cpp b/zidl/codegen/java_code_emitter.cpp deleted file mode 100644 index e12fa8b2bd7..00000000000 --- a/zidl/codegen/java_code_emitter.cpp +++ /dev/null @@ -1,1178 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "codegen/java_code_emitter.h" - -#include - -#include "securec.h" -#include "util/file.h" - -namespace OHOS { -namespace Zidl { - -void JavaCodeEmitter::EmitInterface() -{ - String filePath = String::Format("%s/%s.java", directory_.string(), FileName(interfaceName_).string()); - File file(filePath, File::WRITE); - - StringBuilder sb; - - EmitLicense(sb); - sb.Append("\n"); - EmitPackage(sb); - sb.Append("\n"); - EmitInterfaceImports(sb); - sb.Append("\n"); - EmitInterfaceDefinition(sb); - sb.Append("\n"); - - String data = sb.ToString(); - file.WriteData(data.string(), data.GetLength()); - file.Flush(); - file.Close(); -} - -void JavaCodeEmitter::EmitInterfaceImports( - /* [in] */ StringBuilder& sb) -{ - EmitInterfaceCorelibImports(sb); - EmitInterfaceSelfDefinedTypeImports(sb); - EmitInterfaceDBinderImports(sb); -} - -void JavaCodeEmitter::EmitInterfaceCorelibImports( - /* [in] */ StringBuilder& sb) -{ - bool includeList = false; - bool includeMap = false; - for (int i = 0; i < metaComponent_->typeNumber_; i++) { - MetaType* mt = metaComponent_->types_[i]; - switch (mt->kind_) { - case TypeKind::List: { - if (!includeList) { - sb.Append("import java.util.List;\n"); - includeList = true; - } - break; - } - case TypeKind::Map: { - if (!includeMap) { - sb.Append("import java.util.Map;\n"); - includeMap = true; - } - break; - } - default: - break; - } - } -} - -void JavaCodeEmitter::EmitInterfaceDBinderImports( - /* [in] */ StringBuilder& sb) -{ - sb.Append("import ohos.rpc.IRemoteBroker;\n"); - sb.Append("import ohos.rpc.RemoteException;\n"); -} - -void JavaCodeEmitter::EmitInterfaceSelfDefinedTypeImports( - /* [in] */ StringBuilder& sb) -{ - for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { - MetaSequenceable* mp = metaComponent_->sequenceables_[i]; - sb.AppendFormat("import %s%s;\n", mp->namespace_, mp->name_); - } - - for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { - MetaInterface* mi = metaComponent_->interfaces_[i]; - if (mi->external_) { - sb.AppendFormat("import %s%s;\n", mi->namespace_, mi->name_); - } - } -} - -void JavaCodeEmitter::EmitInterfaceDefinition( - /* [in] */ StringBuilder& sb) -{ - sb.AppendFormat("public interface %s extends IRemoteBroker {\n", metaInterface_->name_); - EmitInterfaceMethods(sb, TAB); - sb.Append("};\n"); -} - -void JavaCodeEmitter::EmitInterfaceMethods( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - if (metaInterface_->methodNumber_ > 0) { - sb.Append("\n"); - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - EmitInterfaceMethod(mm, sb, prefix); - if (i != metaInterface_->methodNumber_ - 1) { - sb.Append("\n"); - } - } - } -} - -void JavaCodeEmitter::EmitInterfaceMethod( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; - if (mm->parameterNumber_ == 0) { - sb.Append(prefix).AppendFormat("%s %s() throws RemoteException;\n", EmitType(returnType).string(), MethodName(mm->name_).string()); - } else { - sb.Append(prefix).AppendFormat("%s %s(\n", EmitType(returnType).string(), MethodName(mm->name_).string()); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - EmitInterfaceMethodParameter(mp, sb, prefix + TAB); - if (i != mm->parameterNumber_ - 1) { - sb.Append(",\n"); - } - } - sb.Append(") throws RemoteException;\n"); - } -} - -void JavaCodeEmitter::EmitInterfaceMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - if ((mp->attributes_ & ATTR_MASK) == (ATTR_IN | ATTR_OUT)) { - sb.Append(prefix).Append("/* [inout] */ "); - } else if (mp->attributes_ & ATTR_IN) { - sb.Append(prefix).Append("/* [in] */ "); - } else { - sb.Append(prefix).Append("/* [out] */ "); - } - - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - std::string name = UnderlineAdded(mp->name_); - sb.AppendFormat("%s %s", EmitType(mt).string(), name.c_str()); -} - -void JavaCodeEmitter::EmitInterfaceProxy() -{ - String filePath = String::Format("%s/%s.java", directory_.string(), FileName(proxyName_).string()); - File file(filePath, File::WRITE); - - StringBuilder sb; - - EmitLicense(sb); - sb.Append("\n"); - EmitPackage(sb); - sb.Append("\n"); - EmitInterfaceProxyImports(sb); - sb.Append("\n"); - EmitInterfaceProxyImpl(sb); - sb.Append("\n"); - - String data = sb.ToString(); - file.WriteData(data.string(), data.GetLength()); - file.Flush(); - file.Close(); -} - -void JavaCodeEmitter::EmitInterfaceProxyImports( - /* [in] */ StringBuilder& sb) -{ - EmitInterfaceProxyCorelibImports(sb); - EmitInterfaceProxySelfDefinedTypeImports(sb); - EmitInterfaceProxyDBinderImports(sb); - EmitInterfaceProxyParametersImports(sb); -} - -void JavaCodeEmitter::EmitInterfaceProxyCorelibImports( - /* [in] */ StringBuilder& sb) -{ - bool includeList = false; - bool includeMap = false; - for (int i = 0; i < metaComponent_->typeNumber_; i++) { - MetaType* mt = metaComponent_->types_[i]; - switch(mt->kind_) { - case TypeKind::List: { - if (!includeList) { - sb.Append("import java.util.List;\n"); - sb.Append("import java.util.ArrayList;\n"); - includeList = true; - } - break; - } - case TypeKind::Map: { - if (!includeMap) { - sb.Append("import java.util.Map;\n"); - sb.Append("import java.util.HashMap;\n"); - includeMap = true; - } - break; - } - default: - break; - } - } -} - -void JavaCodeEmitter::EmitInterfaceProxySelfDefinedTypeImports( - /* [in] */ StringBuilder& sb) -{ - for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { - MetaSequenceable* mp = metaComponent_->sequenceables_[i]; - sb.AppendFormat("import %s%s;\n", mp->namespace_, mp->name_); - } - - for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { - MetaInterface* mi = metaComponent_->interfaces_[i]; - if (mi->external_) { - sb.AppendFormat("import %s%s;\n", mi->namespace_, mi->name_); - sb.AppendFormat("import %s%s;\n", mi->namespace_, StubName(String(mi->name_)).string()); - } - } -} - -void JavaCodeEmitter::EmitInterfaceProxyDBinderImports( - /* [in] */ StringBuilder& sb) -{ - sb.Append("import ohos.rpc.IRemoteObject;\n"); - sb.Append("import ohos.rpc.RemoteException;\n"); - sb.Append("import ohos.rpc.MessageParcel;\n"); - sb.Append("import ohos.rpc.MessageOption;\n"); -} - -void JavaCodeEmitter::EmitInterfaceProxyParametersImports( - /* [in] */ StringBuilder& sb) -{ - sb.Append("import ohos.system.version.SystemVersion;\n"); -} - -void JavaCodeEmitter::EmitInterfaceProxyImpl( - /* [in] */ StringBuilder& sb) -{ - sb.AppendFormat("public class %s implements %s {\n", proxyName_.string(), interfaceName_.string()); - EmitInterfaceProxyConstants(sb, TAB); - sb.Append("\n"); - sb.Append(TAB).Append("private final IRemoteObject remote;\n"); - sb.Append(TAB).Append("private static final int ERR_OK = 0;\n"); - sb.Append("\n"); - EmitInterfaceProxyConstructor(sb, TAB); - sb.Append("\n"); - EmitInterfaceProxyMethodImpls(sb, TAB); - sb.Append("};\n"); -} - -void JavaCodeEmitter::EmitInterfaceProxyConstants( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("private static final String DESCRIPTOR = \"%s\";\n\n", interfaceFullName_.string()); - EmitInterfaceMethodCommands(sb, prefix); -} - -void JavaCodeEmitter::EmitInterfaceProxyConstructor( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("public %s(\n", proxyName_.string()); - sb.Append(prefix + TAB).Append("/* [in] */ IRemoteObject remote) {\n"); - sb.Append(prefix + TAB).Append("this.remote = remote;\n"); - sb.Append(prefix).Append("}\n"); - sb.Append("\n"); - sb.Append(prefix).AppendFormat("@Override\n"); - sb.Append(prefix).Append("public IRemoteObject asObject() {\n"); - sb.Append(prefix + TAB).Append("return remote;\n"); - sb.Append(prefix).Append("}\n"); -} - -void JavaCodeEmitter::EmitInterfaceProxyMethodImpls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - if (metaInterface_->methodNumber_ > 0) { - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - EmitInterfaceProxyMethodImpl(mm, sb, prefix); - if (i != metaInterface_->methodNumber_ - 1) { - sb.Append("\n"); - } - } - } -} - -void JavaCodeEmitter::EmitInterfaceProxyMethodImpl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; - sb.Append(prefix).Append("@Override\n"); - if (mm->parameterNumber_ == 0) { - sb.Append(prefix).AppendFormat("public %s %s() throws RemoteException ", EmitType(returnType).string(), MethodName(mm->name_).string()); - } else { - sb.Append(prefix).AppendFormat("public %s %s(\n", EmitType(returnType).string(), MethodName(mm->name_).string()); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - EmitInterfaceMethodParameter(mp, sb, prefix + TAB); - if (i != mm->parameterNumber_ - 1) { - sb.Append(",\n"); - } - } - sb.Append(") throws RemoteException "); - } - EmitInterfaceProxyMethodBody(mm, sb, prefix); -} - -void JavaCodeEmitter::EmitInterfaceProxyMethodBody( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append("{\n"); - sb.Append(prefix + TAB).Append("MessageParcel data = MessageParcel.obtain();\n"); - sb.Append(prefix + TAB).Append("MessageParcel reply = MessageParcel.obtain();\n"); - sb.Append(prefix + TAB).AppendFormat("MessageOption option = new MessageOption(%s);\n", - (mm->properties_ & METHOD_PROPERTY_ONEWAY) != 0 ? "MessageOption.TF_ASYNC" : "MessageOption.TF_SYNC"); - sb.Append("\n"); - int32_t R_API_VERSION = 6; - sb.Append(prefix + TAB).AppendFormat("if (SystemVersion.getApiVersion() >= %d) {\n", R_API_VERSION); - sb.Append(prefix + TAB).Append(" data.updateDataVersion(remote);\n"); - sb.Append(prefix + TAB).Append("}\n"); - sb.Append(prefix).AppendFormat(" data.writeInterfaceToken(DESCRIPTOR);\n"); - - bool needBlankLine = false; - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - if ((mp->attributes_ & ATTR_IN) != 0) { - EmitWriteMethodParameter(mp, "data", sb, prefix + TAB); - needBlankLine = true; - } else if ((mp->attributes_ & ATTR_OUT) != 0) { - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - if (mt->kind_ == TypeKind::Array) { - std::string name = UnderlineAdded(mp->name_); - EmitWriteOutArrayVariable("data", name, mt, sb, prefix + TAB); - } - } - } - if (needBlankLine) { - sb.Append("\n"); - } - sb.Append(prefix + TAB).Append("try {\n"); - sb.Append(prefix + TAB + TAB).AppendFormat("remote.sendRequest(COMMAND_%s, data, reply, option);\n", - ConstantName(mm->name_).string()); - sb.Append(prefix + TAB).Append(" reply.readException();\n"); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - if ((mp->attributes_ & ATTR_OUT) != 0) { - EmitReadMethodParameter(mp, "reply", sb, prefix + TAB + TAB); - } - } - MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; - if (returnType->kind_ != TypeKind::Void) { - EmitReadVariable("reply", "result", returnType, ATTR_IN, sb, prefix + TAB + TAB); - } - if (returnType->kind_ != TypeKind::Void) { - sb.Append(prefix + TAB + TAB).Append("return result;\n"); - } - - sb.Append(prefix + TAB).Append("} finally {\n"); - sb.Append(prefix + TAB + TAB).Append("data.reclaim();\n"); - sb.Append(prefix + TAB + TAB).Append("reply.reclaim();\n"); - sb.Append(prefix + TAB).Append("}\n"); - sb.Append(prefix).Append("}\n"); -} - -void JavaCodeEmitter::EmitWriteMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ const String& parcelName, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - std::string name = UnderlineAdded(mp->name_); - EmitWriteVariable(parcelName, name, mt, sb, prefix); -} - -void JavaCodeEmitter::EmitReadMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ const String& parcelName, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - std::string name = UnderlineAdded(mp->name_); - EmitReadOutVariable(parcelName, name, mt, sb, prefix); -} - -void JavaCodeEmitter::EmitInterfaceStub() -{ - String filePath = String::Format("%s/%s.java", directory_.string(), FileName(stubName_).string()); - File file(filePath, File::WRITE); - - StringBuilder sb; - - EmitLicense(sb); - sb.Append("\n"); - EmitPackage(sb); - sb.Append("\n"); - EmitInterfaceStubImports(sb); - sb.Append("\n"); - EmitInterfaceStubImpl(sb); - sb.Append("\n"); - - String data = sb.ToString(); - file.WriteData(data.string(), data.GetLength()); - file.Flush(); - file.Close(); -} - -void JavaCodeEmitter::EmitInterfaceStubImports( - /* [in] */ StringBuilder& sb) -{ - EmitInterfaceStubCorelibImports(sb); - EmitInterfaceStubSelfDefinedTypeImports(sb); - EmitInterfaceStubDBinderImports(sb); -} - -void JavaCodeEmitter::EmitInterfaceStubCorelibImports( - /* [in] */ StringBuilder& sb) -{ - EmitInterfaceProxyCorelibImports(sb); -} - -void JavaCodeEmitter::EmitInterfaceStubSelfDefinedTypeImports( - /* [in] */ StringBuilder& sb) -{ - for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { - MetaSequenceable* mp = metaComponent_->sequenceables_[i]; - sb.AppendFormat("import %s%s;\n", mp->namespace_, mp->name_); - } - - for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { - MetaInterface* mi = metaComponent_->interfaces_[i]; - if (mi->external_) { - sb.AppendFormat("import %s%s;\n", mi->namespace_, mi->name_); - sb.AppendFormat("import %s%s;\n", mi->namespace_, StubName(String(mi->name_)).string()); - } - } - sb.AppendFormat("import %s;\n", proxyFullName_.string()); -} - -void JavaCodeEmitter::EmitInterfaceStubDBinderImports( - /* [in] */ StringBuilder& sb) -{ - sb.Append("import ohos.rpc.IRemoteBroker;\n"); - sb.Append("import ohos.rpc.IRemoteObject;\n"); - sb.Append("import ohos.rpc.RemoteException;\n"); - sb.Append("import ohos.rpc.RemoteObject;\n"); - sb.Append("import ohos.rpc.MessageParcel;\n"); - sb.Append("import ohos.rpc.MessageOption;\n"); -} - -void JavaCodeEmitter::EmitInterfaceStubImpl( - /* [in] */ StringBuilder& sb) -{ - sb.AppendFormat("public abstract class %s extends RemoteObject implements %s {\n", stubName_.string(), interfaceName_.string()); - EmitInterfaceStubConstants(sb, TAB); - sb.Append("\n"); - sb.Append(TAB).Append("private static final int ERR_OK = 0;\n"); - sb.Append(TAB).Append("private static final int ERR_RUNTIME_EXCEPTION = -1;\n"); - sb.Append("\n"); - EmitInterfaceStubConstructor(sb, TAB); - sb.Append("\n"); - EmitInterfaceStubMethodImpls(sb, TAB); - sb.Append("};\n"); -} - -void JavaCodeEmitter::EmitInterfaceStubConstants( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("private static final String DESCRIPTOR = \"%s\";\n\n", interfaceFullName_.string()); - EmitInterfaceMethodCommands(sb, prefix); -} - -void JavaCodeEmitter::EmitInterfaceStubConstructor( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("public %s(\n", stubName_.string()); - sb.Append(prefix + TAB).Append("/* [in] */ String descriptor) {\n"); - sb.Append(prefix + TAB).Append("super(descriptor);\n"); - sb.Append(prefix).Append("}\n"); - sb.Append("\n"); - sb.Append(prefix).Append("@Override\n"); - sb.Append(prefix).Append("public IRemoteObject asObject() {\n"); - sb.Append(prefix + TAB).Append("return this;\n"); - sb.Append(prefix).Append("}\n"); - sb.Append("\n"); - sb.Append(prefix).AppendFormat("public static %s asInterface(IRemoteObject object) {\n", interfaceName_.string()); - sb.Append(prefix + TAB).Append("if (object == null) {\n"); - sb.Append(prefix + TAB).Append(TAB).Append("return null;\n"); - sb.Append(prefix + TAB).Append("}\n"); - sb.Append("\n"); - sb.Append(prefix + TAB).AppendFormat("%s result = null;\n", interfaceName_.string()); - sb.Append(prefix + TAB).Append("IRemoteBroker broker = object.queryLocalInterface(DESCRIPTOR);\n"); - sb.Append(prefix + TAB).Append("if (broker != null) {\n"); - sb.Append(prefix + TAB).Append(TAB).AppendFormat("if (broker instanceof %s) {\n", interfaceName_.string()); - sb.Append(prefix + TAB).Append(TAB).Append(TAB).AppendFormat("result = (%s)broker;\n", interfaceName_.string()); - sb.Append(prefix + TAB).Append(TAB).Append("}\n"); - sb.Append(prefix + TAB).Append("} else {\n"); - sb.Append(prefix + TAB).Append(TAB).AppendFormat("result = new %s(object);\n", proxyName_.string()); - sb.Append(prefix + TAB).Append("}\n"); - sb.Append("\n"); - sb.Append(prefix + TAB).Append("return result;\n"); - sb.Append(prefix).Append("}\n"); -} - -void JavaCodeEmitter::EmitInterfaceStubMethodImpls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).Append("@Override\n"); - sb.Append(prefix).Append("public boolean onRemoteRequest(\n"); - sb.Append(prefix + TAB).Append("/* [in] */ int code,\n"); - sb.Append(prefix + TAB).Append("/* [in] */ MessageParcel data,\n"); - sb.Append(prefix + TAB).Append("/* [out] */ MessageParcel reply,\n"); - sb.Append(prefix + TAB).Append("/* [in] */ MessageOption option) throws RemoteException {\n"); - sb.Append(prefix + TAB).Append("String token = data.readInterfaceToken();\n"); - sb.Append(prefix + TAB).Append("if (!DESCRIPTOR.equals(token)) {\n"); - sb.Append(prefix + TAB).Append(" return false;\n"); - sb.Append(prefix + TAB).Append("}\n"); - - sb.Append(prefix + TAB).Append("switch (code) {\n"); - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - EmitInterfaceStubMethodImpl(mm, sb, prefix + TAB + TAB); - } - sb.Append(prefix + TAB).Append(TAB).Append("default:\n"); - sb.Append(prefix + TAB).Append(TAB).Append(TAB).Append( - "return super.onRemoteRequest(code, data, reply, option);\n"); - sb.Append(prefix + TAB).Append("}\n"); - sb.Append(prefix).Append("}\n"); -} - -void JavaCodeEmitter::EmitInterfaceStubMethodImpl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("case COMMAND_%s: {\n", ConstantName(mm->name_).string()); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - if ((mp->attributes_ & ATTR_IN) != 0) { - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - EmitReadVariable("data", UnderlineAdded(mp->name_), mt, ATTR_IN, sb, prefix + TAB); - } else if ((mp->attributes_ & ATTR_OUT) != 0) { - EmitLocalVariable(mp, sb, prefix + TAB); - } - } - - MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; - if (returnType->kind_ != TypeKind::Void) { - sb.Append(prefix + TAB).AppendFormat("%s result;\n", EmitType(returnType).string()); - } - - if (mm->parameterNumber_ == 0) { - if (returnType->kind_ == TypeKind::Void) { - sb.Append(prefix + TAB).AppendFormat("%s();\n", mm->name_); - } else { - sb.Append(prefix + TAB).AppendFormat("result = %s();\n", mm->name_); - } - } else { - if (returnType->kind_ == TypeKind::Void) { - sb.Append(prefix + TAB).AppendFormat("%s(", mm->name_); - } else { - sb.Append(prefix + TAB).AppendFormat("result = %s(", mm->name_); - } - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - sb.Append(UnderlineAdded(mp->name_).c_str()); - if (i != mm->parameterNumber_ - 1) { - sb.Append(", "); - } - } - sb.AppendFormat(");\n", mm->name_); - } - - sb.Append(prefix + TAB).Append("reply.writeNoException();\n"); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - if ((mp->attributes_ & ATTR_OUT) != 0) { - EmitWriteMethodParameter(mp, "reply", sb, prefix + TAB); - } - } - if (returnType->kind_ != TypeKind::Void) { - EmitWriteVariable("reply", "result", returnType, sb, prefix + TAB); - } - sb.Append(prefix + TAB).Append("return true;\n"); - sb.Append(prefix).Append("}\n"); -} - -void JavaCodeEmitter::EmitInterfaceMethodCommands( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - sb.Append(prefix).AppendFormat("private static final int COMMAND_%s = IRemoteObject.MIN_TRANSACTION_ID + %d;\n", - ConstantName(mm->name_).string(), i); - } -} - -void JavaCodeEmitter::EmitLicense( - /* [in] */ StringBuilder& sb) -{ - sb.Append(metaInterface_->license_).Append("\n"); -} - -void JavaCodeEmitter::EmitPackage( - /* [in] */ StringBuilder& sb) -{ - String package = metaInterface_->namespace_; - int index = package.LastIndexOf('.'); - sb.AppendFormat("package %s;\n", index != -1 ? package.Substring(0, index).string() : package.string()); -} - -void JavaCodeEmitter::EmitWriteVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - switch (mt->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("%s.writeInt(%s ? 1 : 0);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Char: - case TypeKind::Byte: - case TypeKind::Short: - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("%s.writeInt(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("%s.writeLong(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("%s.writeFloat(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("%s.writeDouble(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("%s.writeString(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Sequenceable: - if (EmitType(mt).Equals("IRemoteObject")) { - sb.Append(prefix).AppendFormat("%s.writeRemoteObject(%s);\n", parcelName.string(), name.c_str()); - break; - } - sb.Append(prefix).AppendFormat("%s.writeSequenceable(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Interface: - sb.Append(prefix).AppendFormat("%s.writeRemoteObject(%s.asObject());\n", parcelName.string(), - name.c_str()); - break; - case TypeKind::List: { - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - sb.Append(prefix).AppendFormat("%s.writeInt(%s.size());\n", parcelName.string(), name.c_str()); - sb.Append(prefix).AppendFormat("for (%s element : %s) {\n", - EmitType(innerType).string(), name.c_str()); - EmitWriteVariable(parcelName, "element", innerType, sb, prefix + TAB); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Map: { - MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; - sb.Append(prefix).AppendFormat("%s.writeInt(%s.size());\n", parcelName.string(), name.c_str()); - sb.Append(prefix).AppendFormat("for (Map.Entry<%s, %s> entry : %s.entrySet()) {\n", - EmitType(keyType).string(), EmitType(valueType).string(), name.c_str()); - EmitWriteVariable(parcelName, "entry.getKey()", keyType, sb, prefix + TAB); - EmitWriteVariable(parcelName, "entry.getValue()", valueType, sb, prefix + TAB); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Array: { - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - sb.Append(prefix).AppendFormat("if (%s == null) {\n", name.c_str()); - sb.Append(prefix).AppendFormat(" %s.writeInt(-1);\n", parcelName.string()); - sb.Append(prefix).Append("} else { \n"); - EmitWriteArrayVariable(parcelName, name, innerType, sb, prefix + TAB); - sb.Append(prefix).Append("}\n"); - break; - } - default: - break; - } -} - -void JavaCodeEmitter::EmitWriteArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - switch (mt->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("%s.writeBooleanArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Char: - sb.Append(prefix).AppendFormat("%s.writeCharArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Byte: - sb.Append(prefix).AppendFormat("%s.writeByteArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Short: - sb.Append(prefix).AppendFormat("%s.writeShortArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("%s.writeIntArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("%s.writeLongArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("%s.writeFloatArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("%s.writeDoubleArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("%s.writeStringArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Sequenceable: - sb.Append(prefix).AppendFormat("%s.writeSequenceableArray(%s);\n", parcelName.string(), name.c_str()); - break; - default: - break; - } -} - -void JavaCodeEmitter::EmitWriteOutArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("if (%s == null) {\n", name.c_str()); - sb.Append(prefix).AppendFormat(" %s.writeInt(-1);\n", parcelName.string()); - sb.Append(prefix).Append("} else {\n"); - sb.Append(prefix).AppendFormat(" %s.writeInt(%s.length);\n", parcelName.string(), name.c_str()); - sb.Append(prefix).Append("}\n"); -} - -void JavaCodeEmitter::EmitReadVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ unsigned int attributes, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - switch (mt->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("%s %s = %s.readInt() == 1 ? true : false;\n", - EmitType(mt).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::Char: - case TypeKind::Byte: - case TypeKind::Short: - sb.Append(prefix).AppendFormat("%s %s = (%s)%s.readInt();\n", - EmitType(mt).string(), name.c_str(), EmitType(mt).string(), parcelName.string()); - break; - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("%s %s = %s.readInt();\n", - EmitType(mt).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("%s %s = %s.readLong();\n", - EmitType(mt).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("%s %s = %s.readFloat();\n", - EmitType(mt).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("%s %s = %s.readDouble();\n", - EmitType(mt).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("%s %s = %s.readString();\n", - EmitType(mt).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::Sequenceable: - if ((attributes & ATTR_OUT) == 0 && EmitType(mt).Equals("IRemoteObject")) { - sb.Append(prefix).AppendFormat("IRemoteObject %s = %s.readRemoteObject();\n", - name.c_str(), parcelName.string()); - break; - } - if ((attributes & ATTR_OUT) == 0) { - sb.Append(prefix).AppendFormat("%s %s = new %s();\n", - EmitType(mt).string(), name.c_str(), EmitType(mt).string()); - } - sb.Append(prefix).AppendFormat("%s.readSequenceable(%s);\n", parcelName.string(), name.c_str()); - - break; - case TypeKind::Interface: - sb.Append(prefix).AppendFormat("%s %s = %s.asInterface(%s.readRemoteObject());\n", EmitType(mt).string(), - name.c_str(), StubName(EmitType(mt)).string(), parcelName.string()); - break; - case TypeKind::List: { - sb.Append(prefix).AppendFormat("%s %s = new Array%s();\n", - EmitType(mt).string(), name.c_str(), EmitType(mt).string()); - sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s.add(value);\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Map: { - sb.Append(prefix).AppendFormat("%s %s = new Hash%s();\n", - EmitType(mt).string(), name.c_str(), EmitType(mt).string()); - sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); - MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; - EmitReadVariable(parcelName, "key", keyType, ATTR_IN, sb, prefix + TAB); - EmitReadVariable(parcelName, "value", valueType, ATTR_IN, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s.put(key, value);\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Array: { - if ((attributes & ATTR_MASK) == ATTR_OUT) { - EmitReadOutArrayVariable(parcelName, name, mt, sb, prefix); - } else { - EmitReadArrayVariable(parcelName, name, mt, attributes, sb, prefix); - } - break; - } - default: - break; - } -} - -void JavaCodeEmitter::EmitReadArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ unsigned int attributes, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - switch (innerType->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("%s[] %s = %s.readBooleanArray();\n", - EmitType(innerType).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::Char: - sb.Append(prefix).AppendFormat("%s[] %s = %s.readCharArray();\n", - EmitType(innerType).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::Byte: - sb.Append(prefix).AppendFormat("%s[] %s = %s.readByteArray();\n", - EmitType(innerType).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::Short: - sb.Append(prefix).AppendFormat("%s[] %s = %s.readShortArray();\n", - EmitType(innerType).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("%s[] %s = %s.readIntArray();\n", - EmitType(innerType).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("%s[] %s = %s.readLongArray();\n", - EmitType(innerType).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("%s[] %s = %s.readFloatArray();\n", - EmitType(innerType).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("%s[] %s = %s.readDoubleArray();\n", - EmitType(innerType).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("%s[] %s = %s.readStringArray();\n", - EmitType(innerType).string(), name.c_str(), parcelName.string()); - break; - case TypeKind::Sequenceable: - sb.Append(prefix).AppendFormat("int size = %s.readInt();\n", parcelName.string()); - sb.Append(prefix).AppendFormat("%s %s = new %s[size];\n", - EmitType(mt).string(), name.c_str(), EmitType(innerType).string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < size; ++i) {\n"); - EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s[i] = value;\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - default: - break; - } -} - -void JavaCodeEmitter::EmitReadOutArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - switch (innerType->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("%s.readBooleanArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Char: - sb.Append(prefix).AppendFormat("%s.readCharArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Byte: - sb.Append(prefix).AppendFormat("%s.readByteArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Short: - sb.Append(prefix).AppendFormat("%s.readShortArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("%s.readIntArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("%s.readLongArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("%s.readFloatArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("%s.readDoubleArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("%s.readStringArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Sequenceable: - sb.Append(prefix).AppendFormat("%s.readSequenceableArray(%s);\n", parcelName.string(), name.c_str()); - break; - default: - break; - } -} - -void JavaCodeEmitter::EmitReadOutVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - switch (mt->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("%s = %s.readInt() == 1 ? true : false;\n", - name.c_str(), parcelName.string()); - break; - case TypeKind::Char: - case TypeKind::Byte: - case TypeKind::Short: - sb.Append(prefix).AppendFormat("%s = (%s)%s.readInt();\n", - name.c_str(), EmitType(mt).string(), parcelName.string()); - break; - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("%s = %s.readInt();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("%s = %s.readLong();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("%s = %s.readFloat();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("%s = %s.readDouble();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("%s = %s.readString();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Sequenceable: - if (EmitType(mt).Equals("IRemoteObject")) { - sb.Append(prefix).AppendFormat("%s = %s.readRemoteObject();\n", name.c_str(), parcelName.string()); - break; - } - sb.Append(prefix).AppendFormat("%s.readSequenceable(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Interface: - sb.Append(prefix).AppendFormat("%s = %s.asInterface(%s.readRemoteObject());\n", name.c_str(), - StubName(EmitType(mt)).string(), parcelName.string()); - break; - case TypeKind::List: { - sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s.add(value);\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Map: { - sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); - MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; - EmitReadVariable(parcelName, "key", keyType, ATTR_IN, sb, prefix + TAB); - EmitReadVariable(parcelName, "value", valueType, ATTR_IN, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s.put(key, value);\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Array: { - EmitReadOutArrayVariable(parcelName, name, mt, sb, prefix); - break; - } - default: - break; - } -} - -void JavaCodeEmitter::EmitLocalVariable( - /* [in] */ MetaParameter* mp, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - std::string name = UnderlineAdded(mp->name_); - if (mt->kind_ == TypeKind::Sequenceable) { - sb.Append(prefix).AppendFormat("%s %s = new %s();\n", EmitType(mt).string(), name.c_str(), - EmitType(mt).string()); - } else if (mt->kind_ == TypeKind::List) { - sb.Append(prefix).AppendFormat("%s %s = new Array%s();\n", EmitType(mt).string(), name.c_str(), - EmitType(mt).string()); - } else if (mt->kind_ == TypeKind::Map) { - sb.Append(prefix).AppendFormat("%s %s = new Hash%s();\n", EmitType(mt).string(), name.c_str(), - EmitType(mt).string()); - } else { - sb.Append(prefix).AppendFormat("%s %s;\n", EmitType(mt).string(), name.c_str()); - } -} - -String JavaCodeEmitter::EmitType( - /* [in] */ MetaType* mt) -{ - switch(mt->kind_) { - case TypeKind::Char: - return "char"; - case TypeKind::Boolean: - return "boolean"; - case TypeKind::Byte: - return "byte"; - case TypeKind::Short: - return "short"; - case TypeKind::Integer: - return "int"; - case TypeKind::Long: - return "long"; - case TypeKind::Float: - return "float"; - case TypeKind::Double: - return "double"; - case TypeKind::String: - return "String"; - case TypeKind::Void: - return "void"; - case TypeKind::Sequenceable: { - MetaSequenceable* mp = metaComponent_->sequenceables_[mt->index_]; - return mp->name_; - } - case TypeKind::Interface: { - MetaInterface* mi = metaComponent_->interfaces_[mt->index_]; - return mi->name_; - } - case TypeKind::List: { - MetaType* elementType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - return String::Format("List<%s>", EmitType(elementType).string()); - } - case TypeKind::Map: { - MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; - return String::Format("Map<%s, %s>", EmitType(keyType).string(), EmitType(valueType).string()); - } - case TypeKind::Array: { - MetaType* elementType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - return String::Format("%s[]", EmitType(elementType).string()); - } - default: - return "unknown type"; - } -} - -String JavaCodeEmitter::FileName( - /* [in] */ const String& name) -{ - if (name.IsEmpty()) { - return name; - } - - return name.Replace('.', '/'); -} - -String JavaCodeEmitter::MethodName( - /* [in] */ const String& name) -{ - if (name.IsEmpty() || islower(name[0])) { - return name; - } - return String::Format("%c%s", tolower(name[0]), name.Substring(1).string()); -} - -String JavaCodeEmitter::ConstantName( - /* [in] */ const String& name) -{ - if (name.IsEmpty()) { - return name; - } - - StringBuilder sb; - - for (int i = 0; i < name.GetLength(); i++) { - char c = name[i]; - if (isupper(c) != 0) { - if (i > 1) { - sb.Append('_'); - } - sb.Append(c); - } else { - sb.Append(toupper(c)); - } - } - - return sb.ToString(); -} - -String JavaCodeEmitter::StubName( - /* [in] */ const String& name) -{ - return name.StartsWith("I") ? (name.Substring(1) + "Stub") : (name + "Stub"); -} - -const std::string JavaCodeEmitter::UnderlineAdded(const String& originName) -{ - std::string underline("_"); - return underline + std::string(originName.string()); -} - -} -} diff --git a/zidl/codegen/java_code_emitter.h b/zidl/codegen/java_code_emitter.h deleted file mode 100644 index 777f74c310c..00000000000 --- a/zidl/codegen/java_code_emitter.h +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_JAVACODEEMITTER_H -#define OHOS_ZIDL_JAVACODEEMITTER_H - -#include - -#include "codegen/code_emitter.h" -#include "util/string_builder.h" - -namespace OHOS { -namespace Zidl { - -class JavaCodeEmitter : public CodeEmitter { -public: - JavaCodeEmitter( - /* [in] */ MetaComponent* mc) - : CodeEmitter(mc) - {} - - void EmitInterface() override; - - void EmitInterfaceProxy() override; - - void EmitInterfaceStub() override; - -private: - void EmitInterfaceImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceCorelibImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceDBinderImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceSelfDefinedTypeImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceDefinition( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceMethods( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceMethod( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceProxyCorelibImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceProxySelfDefinedTypeImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceProxyDBinderImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceProxyParametersImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceProxyImpl( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceProxyConstants( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyConstructor( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyMethodImpls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyMethodImpl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyMethodBody( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitWriteMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ const String& parcelName, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReadMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ const String& parcelName, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceStubImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceStubCorelibImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceStubSelfDefinedTypeImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceStubDBinderImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceStubImpl( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceStubConstants( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceStubConstructor( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceStubMethodImpls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceStubMethodImpl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceMethodCommands( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitLicense( - /* [in] */ StringBuilder& sb); - - void EmitPackage( - /* [in] */ StringBuilder& sb); - - void EmitWriteVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReadVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ unsigned int attributes, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReadOutVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReadArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ unsigned int attributes, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitWriteArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitWriteOutArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReadOutArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitLocalVariable( - /* [in] */ MetaParameter* mp, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - String EmitType( - /* [in] */ MetaType* mt); - - String FileName( - /* [in] */ const String& name); - - String MethodName( - /* [in] */ const String& name); - - String ConstantName( - /* [in] */ const String& name); - - String StubName( - /* [in] */ const String& name); - - const std::string UnderlineAdded(const String& name); -}; - -} -} - -#endif // OHOS_ZIDL_JAVACODEEMITTER_H diff --git a/zidl/codegen/js_code_emitter.cpp b/zidl/codegen/js_code_emitter.cpp deleted file mode 100644 index 95c7c048ebf..00000000000 --- a/zidl/codegen/js_code_emitter.cpp +++ /dev/null @@ -1,1167 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "codegen/js_code_emitter.h" - -#include -#include - -#include "securec.h" -#include "util/file.h" - -namespace OHOS { -namespace Zidl { - - -void JsCodeEmitter::EmitInterface() -{ -} - -void JsCodeEmitter::EmitInterfaceImports( - /* [in] */ StringBuilder& sb) -{ - sb.Append("import rpc from \"@ohos.rpc\";\n"); -} - -void JsCodeEmitter::EmitInterfaceCorelibImports( - /* [in] */ StringBuilder& sb) -{ - bool includeList = false; - bool includeMap = false; - for (int i = 0; i < metaComponent_->typeNumber_; i++) { - MetaType* mt = metaComponent_->types_[i]; - switch (mt->kind_) { - case TypeKind::List: { - if (!includeList) { - sb.Append("import java.util.List;\n"); - includeList = true; - } - break; - } - case TypeKind::Map: { - if (!includeMap) { - sb.Append("import java.util.Map;\n"); - includeMap = true; - } - break; - } - default: - break; - } - } -} - -void JsCodeEmitter::EmitInterfaceDBinderImports( - /* [in] */ StringBuilder& sb) -{ - sb.Append("import ohos.rpc.IRemoteBroker;\n"); - sb.Append("import ohos.rpc.RemoteException;\n"); -} - -void JsCodeEmitter::EmitInterfaceSelfDefinedTypeImports( - /* [in] */ StringBuilder& sb) -{ - for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { - MetaSequenceable* mp = metaComponent_->sequenceables_[i]; - sb.AppendFormat("import %s%s;\n", mp->namespace_, mp->name_); - } - - for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { - MetaInterface* mi = metaComponent_->interfaces_[i]; - if (mi->external_) { - sb.AppendFormat("import %s%s;\n", mi->namespace_, mi->name_); - } - } -} - -void JsCodeEmitter::EmitInterfaceDefinition( - /* [in] */ StringBuilder& sb) -{ - sb.AppendFormat("public interface %s extends IRemoteBroker {\n", metaInterface_->name_); - EmitInterfaceMethods(sb, TAB); - sb.Append("};\n"); -} - -void JsCodeEmitter::EmitInterfaceMethods( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - if (metaInterface_->methodNumber_ > 0) { - sb.Append("\n"); - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - EmitInterfaceMethod(mm, sb, prefix); - if (i != metaInterface_->methodNumber_ - 1) { - sb.Append("\n"); - } - } - } -} - -void JsCodeEmitter::EmitInterfaceMethod( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; - if (mm->parameterNumber_ == 0) { - sb.Append(prefix).AppendFormat( - "%s %s() throws RemoteException;\n", EmitType(returnType).string(), MethodName(mm->name_).string()); - } else { - sb.Append(prefix).AppendFormat("%s %s(\n", EmitType(returnType).string(), MethodName(mm->name_).string()); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - EmitInterfaceMethodParameter(mp, sb, prefix + TAB); - if (i != mm->parameterNumber_ - 1) { - sb.Append(",\n"); - } - } - sb.Append(") throws RemoteException;\n"); - } -} - -void JsCodeEmitter::EmitInterfaceMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - std::string name = UnderlineAdded(mp->name_); - sb.AppendFormat("%s", name.c_str()); -} - -void JsCodeEmitter::EmitInterfaceProxy() -{ - String filePath = String::Format("%s/%s.js", directory_.string(), FileName(proxyName_).string()); - File file(filePath, File::WRITE); - - StringBuilder sb; - - EmitInterfaceImports(sb); - sb.Append("\n"); - EmitInterfaceStubConstants(sb); - sb.Append("\n"); - EmitJsCallBack(sb); - sb.Append("\n"); - EmitInterfaceProxyImpl(sb); - sb.Append("\n"); - - String data = sb.ToString(); - file.WriteData(data.string(), data.GetLength()); - file.Flush(); - file.Close(); -} - -void JsCodeEmitter::EmitInterfaceProxyImports( - /* [in] */ StringBuilder& sb) -{ - EmitInterfaceProxyCorelibImports(sb); - EmitInterfaceProxySelfDefinedTypeImports(sb); - EmitInterfaceProxyDBinderImports(sb); - EmitInterfaceProxyParametersImports(sb); -} - -void JsCodeEmitter::EmitInterfaceProxyCorelibImports( - /* [in] */ StringBuilder& sb) -{ - bool includeList = false; - bool includeMap = false; - for (int i = 0; i < metaComponent_->typeNumber_; i++) { - MetaType* mt = metaComponent_->types_[i]; - switch(mt->kind_) { - case TypeKind::List: { - if (!includeList) { - sb.Append("import java.util.List;\n"); - sb.Append("import java.util.ArrayList;\n"); - includeList = true; - } - break; - } - case TypeKind::Map: { - if (!includeMap) { - sb.Append("import java.util.Map;\n"); - sb.Append("import java.util.HashMap;\n"); - includeMap = true; - } - break; - } - default: - break; - } - } -} - -void JsCodeEmitter::EmitInterfaceProxySelfDefinedTypeImports( - /* [in] */ StringBuilder& sb) -{ - for (int i = 0; i < metaComponent_->sequenceableNumber_; i++) { - MetaSequenceable* mp = metaComponent_->sequenceables_[i]; - sb.AppendFormat("import %s%s;\n", mp->namespace_, mp->name_); - } - - for (int i = 0; i < metaComponent_->interfaceNumber_; i++) { - MetaInterface* mi = metaComponent_->interfaces_[i]; - if (mi->external_) { - sb.AppendFormat("import %s%s;\n", mi->namespace_, mi->name_); - sb.AppendFormat("import %s%s;\n", mi->namespace_, StubName(String(mi->name_)).string()); - } - } -} - -void JsCodeEmitter::EmitInterfaceProxyDBinderImports( - /* [in] */ StringBuilder& sb) -{ - sb.Append("import ohos.rpc.IRemoteObject;\n"); - sb.Append("import ohos.rpc.RemoteException;\n"); - sb.Append("import ohos.rpc.MessageParcel;\n"); - sb.Append("import ohos.rpc.MessageOption;\n"); -} - -void JsCodeEmitter::EmitInterfaceProxyParametersImports( - /* [in] */ StringBuilder& sb) -{ - sb.Append("import ohos.system.version.SystemVersion;\n"); -} - -void JsCodeEmitter::EmitInterfaceProxyImpl( - /* [in] */ StringBuilder& sb) -{ - sb.AppendFormat("export default {\n", proxyName_.string(), interfaceName_.string()); - EmitInterfaceProxyMethodImpls(sb, TAB); - sb.Append("}\n"); -} - -void JsCodeEmitter::EmitInterfaceProxyConstants( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat( - "private static final String DESCRIPTOR = \"%s\";\n\n", interfaceFullName_.string()); - EmitInterfaceMethodCommands(sb); -} - -void JsCodeEmitter::EmitInterfaceProxyConstructor( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("public %s(\n", proxyName_.string()); - sb.Append(prefix + TAB).Append("/* [in] */ IRemoteObject remote) {\n"); - sb.Append(prefix + TAB).Append("this.remote = remote;\n"); - sb.Append(prefix).Append("}\n"); - sb.Append("\n"); - sb.Append(prefix).AppendFormat("@Override\n"); - sb.Append(prefix).Append("public IRemoteObject asObject() {\n"); - sb.Append(prefix + TAB).Append("return remote;\n"); - sb.Append(prefix).Append("}\n"); -} - -void JsCodeEmitter::EmitInterfaceProxyMethodImpls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - if (metaInterface_->methodNumber_ > 0) { - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - EmitInterfaceProxyMethodImpl(mm, sb, prefix); - if (i != metaInterface_->methodNumber_ - 1) { - sb.Append("\n"); - } - } - } -} - -void JsCodeEmitter::EmitInterfaceProxyMethodImpl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - if (mm->parameterNumber_ == 0) { - sb.Append(prefix).AppendFormat("%s() ", MethodName(mm->name_).string()); - } else { - sb.Append(prefix).AppendFormat("%s(", MethodName(mm->name_).string()); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - EmitInterfaceMethodParameter(mp, sb, prefix + TAB); - if (i != mm->parameterNumber_ - 1) { - sb.Append(", "); - } - } - sb.Append(") "); - } - EmitInterfaceProxyMethodBody(mm, sb, prefix); -} - -void JsCodeEmitter::EmitInterfaceProxyMethodBody( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append("{\n"); - sb.Append(prefix + TAB).AppendFormat("let option = new rpc.MessageOption();\n"); - sb.Append(prefix + TAB).Append("let data = new rpc.MessageParcel();\n"); - sb.Append(prefix + TAB).Append("let reply = new rpc.MessageParcel();\n"); - sb.Append("\n"); - - bool needBlankLine = false; - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - if ((mp->attributes_ & ATTR_IN) != 0) { - EmitWriteMethodParameter(mp, "data", sb, prefix + TAB); - needBlankLine = true; - } else if ((mp->attributes_ & ATTR_OUT) != 0) { - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - if (mt->kind_ == TypeKind::Array) { - std::string name = UnderlineAdded(mp->name_); - EmitWriteOutArrayVariable("data", name, mt, sb, prefix + TAB); - } - } - } - if (needBlankLine) { - sb.Append("\n"); - } - - if ((mm->properties_ & METHOD_PROPERTY_ONEWAY) == 0) { - sb.Append(prefix + TAB).AppendFormat("let ret = proxy.sendRequest(COMMAND_%s, data, reply, option)\n", - ConstantName(mm->name_).string()); - sb.Append(prefix + TAB + TAB).AppendFormat(".then(function (result) {\n"); - sb.Append(prefix + TAB + TAB).AppendFormat("if (result.errCode === 0) {\n"); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - if ((mp->attributes_ & ATTR_OUT) != 0) { - EmitReadMethodParameter(mp, "reply", sb, prefix + TAB + TAB); - } - } - MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; - if (returnType->kind_ != TypeKind::Void) { - EmitReadVariable("reply", "result", "msg", returnType, ATTR_IN, sb, prefix + TAB + TAB + TAB); - } else { - sb.Append(prefix + TAB + TAB + TAB).Append("console.log(\"void function call success\");\n"); - } - if (returnType->kind_ != TypeKind::Void) { - sb.Append(prefix + TAB + TAB + TAB).Append("console.log(\"reply msg: \" + msg);\n"); - } - sb.Append(prefix + TAB + TAB).AppendFormat("} else {\n"); - sb.Append(prefix + TAB + TAB + TAB).Append( - "console.log(\"sendRequest failed, errCode: \" + result.errCode);\n"); - sb.Append(prefix + TAB + TAB).AppendFormat("}\n"); - sb.Append(prefix + TAB).AppendFormat("}).catch(function (e) {\n"); - sb.Append(prefix + TAB + TAB).AppendFormat("console.log(\"sendRequest exception:\" + e);\n"); - sb.Append(prefix + TAB).AppendFormat("}).finally (() => {\n"); - sb.Append(prefix + TAB).AppendFormat("console.log(\"sendRequest ends, reclaim parcels\");\n"); - sb.Append(prefix + TAB + TAB).Append("data.reclaim();\n"); - sb.Append(prefix + TAB + TAB).Append("reply.reclaim();\n"); - sb.Append(prefix + TAB).AppendFormat("});\n"); - } else { - sb.Append(prefix + TAB).Append("try {\n"); - sb.Append(prefix + TAB + TAB).AppendFormat( - "let ret = proxy.sendRequest(COMMAND_%s, data, reply, option, %sCallback)\n", - ConstantName(mm->name_).string(), MethodName(mm->name_).string()); - sb.Append(prefix + TAB).Append("} catch(e) {\n"); - sb.Append(prefix + TAB + TAB).AppendFormat("console.log(\"sendRequest exception:\" + e);\n"); - sb.Append(prefix + TAB).AppendFormat("}\n"); - } - sb.Append(prefix).Append("},\n"); -} - -void JsCodeEmitter::EmitWriteMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ const String& parcelName, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - std::string name = UnderlineAdded(mp->name_); - EmitWriteVariable(parcelName, name, mt, sb, prefix); -} - -void JsCodeEmitter::EmitReadMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ const String& parcelName, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - std::string name = UnderlineAdded(mp->name_); - EmitReadOutVariable(parcelName, name, mt, sb, prefix); -} - -void JsCodeEmitter::EmitInterfaceStub() -{ - String filePath = String::Format("%s/%s.js", directory_.string(), FileName(stubName_).string()); - File file(filePath, File::WRITE); - - StringBuilder sb; - EmitInterfaceImports(sb); - sb.Append("\n"); - EmitInterfaceStubConstants(sb); - sb.Append("\n"); - EmitInterfaceStubImpl(sb); - sb.Append("\n"); - - String data = sb.ToString(); - file.WriteData(data.string(), data.GetLength()); - file.Flush(); - file.Close(); -} - -void JsCodeEmitter::EmitInterfaceStubImpl( - /* [in] */ StringBuilder& sb) -{ - sb.AppendFormat("class %s extends rpc.RemoteObject {\n", stubName_.string()); - EmitInterfaceStubConstructor(sb, TAB); - sb.Append("\n"); - EmitInterfaceStubMethodImpls(sb, TAB); - sb.Append("}\n"); -} - -void JsCodeEmitter::EmitInterfaceStubConstants(/* [in] */ StringBuilder& sb) -{ - EmitInterfaceMethodCommands(sb); -} - -void JsCodeEmitter::EmitJsCallBack(/* [in] */ StringBuilder& sb) -{ - if (metaInterface_->methodNumber_ > 0) { - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - if ((mm->properties_ & METHOD_PROPERTY_ONEWAY) == 1) { - sb.AppendFormat("function %sCallback(result) {\n", MethodName(mm->name_).string()); - sb.Append(TAB).AppendFormat("if (result.errCode === 0) {\n"); - - MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; - if (returnType->kind_ != TypeKind::Void) { - EmitReadVariable("reply", "msg", returnType, ATTR_IN, sb, String(TAB) + TAB + TAB); - } else { - sb.Append(String(TAB) + TAB + TAB).Append("console.log(\"void function call success\");\n"); - } - if (returnType->kind_ != TypeKind::Void) { - sb.Append(String(TAB) + TAB + TAB).Append("console.log(\"reply msg: \" + msg);\n"); - } - sb.Append(String(TAB)).AppendFormat("} else {\n"); - sb.Append(String(TAB) + TAB).Append( - "console.log(\"sendRequest failed, errCode: \" + result.errCode);\n"); - sb.Append(String(TAB)).AppendFormat("}\n"); - sb.Append(String(TAB)).AppendFormat("console.log(\"sendRequest ends, reclaim parcels\");\n"); - sb.Append(String(TAB)).Append("data.reclaim();\n"); - sb.Append(String(TAB)).Append("reply.reclaim();\n"); - sb.Append("}\n"); - } - if (i != metaInterface_->methodNumber_ - 1) { - sb.Append("\n"); - } - } - } -} - -void JsCodeEmitter::EmitInterfaceStubConstructor( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("constructor(des) {\n"); - sb.Append(prefix + TAB).Append("super(des);\n"); - sb.Append(prefix).Append("}\n"); -} - -void JsCodeEmitter::EmitInterfaceStubMethodImpls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).Append("onRemoteRequest(code, data, reply, option) {\n"); - sb.Append(prefix + TAB).Append("switch (code) {\n"); - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - EmitInterfaceStubMethodImpl(mm, sb, prefix + TAB + TAB); - } - sb.Append(prefix + TAB).Append(TAB).Append("default:\n"); - sb.Append(prefix + TAB).Append(TAB).Append(TAB).Append( - "return super.onRemoteRequest(code, data, reply, option);\n"); - sb.Append(prefix + TAB).Append("}\n"); - sb.Append(prefix).Append("}\n"); -} - -void JsCodeEmitter::EmitInterfaceStubMethodImpl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("case COMMAND_%s: {\n", ConstantName(mm->name_).string()); - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - if ((mp->attributes_ & ATTR_IN) != 0) { - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - EmitReadVariable("data", UnderlineAdded(mp->name_), mt, ATTR_IN, sb, prefix + TAB); - } else if ((mp->attributes_ & ATTR_OUT) != 0) { - EmitLocalVariable(mp, sb, prefix + TAB); - } - } - - MetaType* returnType = metaComponent_->types_[mm->returnTypeIndex_]; - if (mm->parameterNumber_ == 0) { - if (returnType->kind_ == TypeKind::Void) { - sb.Append(prefix + TAB).AppendFormat("%s();\n", mm->name_); - } else { - sb.Append(prefix + TAB).AppendFormat("let result = %s();\n", mm->name_); - } - } else { - if (returnType->kind_ == TypeKind::Void) { - sb.Append(prefix + TAB).AppendFormat("%s(", mm->name_); - } else { - sb.Append(prefix + TAB).AppendFormat("let result = %s(", mm->name_); - } - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - sb.Append(UnderlineAdded(mp->name_).c_str()); - if (i != mm->parameterNumber_ - 1) { - sb.Append(", "); - } - } - sb.AppendFormat(");\n", mm->name_); - } - - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - if ((mp->attributes_ & ATTR_OUT) != 0) { - EmitWriteMethodParameter(mp, "reply", sb, prefix + TAB); - } - } - if (returnType->kind_ != TypeKind::Void) { - EmitWriteVariable("reply", "result", returnType, sb, prefix + TAB); - } - sb.Append(prefix + TAB).Append("return true;\n"); - sb.Append(prefix).Append("}\n"); -} - -void JsCodeEmitter::EmitInterfaceMethodCommands(/* [in] */ StringBuilder& sb) -{ - for (int i = 0; i < metaInterface_->methodNumber_; i++) { - MetaMethod* mm = metaInterface_->methods_[i]; - sb.AppendFormat("const COMMAND_%s = %d;\n", ConstantName(mm->name_).string(), i); - } -} - -void JsCodeEmitter::EmitLicense( - /* [in] */ StringBuilder& sb) -{ - sb.Append(metaInterface_->license_).Append("\n"); -} - -void JsCodeEmitter::EmitPackage( - /* [in] */ StringBuilder& sb) -{ - String package = metaInterface_->namespace_; - int index = package.LastIndexOf('.'); - sb.AppendFormat("package %s;\n", index != -1 ? package.Substring(0, index).string() : package.string()); -} - -void JsCodeEmitter::EmitWriteVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - switch (mt->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("%s.writeInt(%s ? 1 : 0);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Char: - case TypeKind::Byte: - case TypeKind::Short: - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("%s.writeInt(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("%s.writeLong(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("%s.writeFloat(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("%s.writeDouble(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("%s.writeString(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Sequenceable: - if (EmitType(mt).Equals("IRemoteObject")) { - sb.Append(prefix).AppendFormat("%s.writeRemoteObject(%s);\n", parcelName.string(), name.c_str()); - break; - } - sb.Append(prefix).AppendFormat("%s.writeSequenceable(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Interface: - sb.Append(prefix).AppendFormat("%s.writeRemoteObject(%s.asObject());\n", parcelName.string(), - name.c_str()); - break; - case TypeKind::List: { - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - sb.Append(prefix).AppendFormat("%s.writeInt(%s.size());\n", parcelName.string(), name.c_str()); - sb.Append(prefix).AppendFormat("for (%s element : %s) {\n", - EmitType(innerType).string(), name.c_str()); - EmitWriteVariable(parcelName, "element", innerType, sb, prefix + TAB); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Map: { - MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; - sb.Append(prefix).AppendFormat("%s.writeInt(%s.size());\n", parcelName.string(), name.c_str()); - sb.Append(prefix).AppendFormat("for (Map.Entry<%s, %s> entry : %s.entrySet()) {\n", - EmitType(keyType).string(), EmitType(valueType).string(), name.c_str()); - EmitWriteVariable(parcelName, "entry.getKey()", keyType, sb, prefix + TAB); - EmitWriteVariable(parcelName, "entry.getValue()", valueType, sb, prefix + TAB); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Array: { - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - sb.Append(prefix).AppendFormat("if (%s == null) {\n", name.c_str()); - sb.Append(prefix).AppendFormat(" %s.writeInt(-1);\n", parcelName.string()); - sb.Append(prefix).Append("} else { \n"); - EmitWriteArrayVariable(parcelName, name, innerType, sb, prefix + TAB); - sb.Append(prefix).Append("}\n"); - break; - } - default: - break; - } -} - -void JsCodeEmitter::EmitWriteArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - switch (mt->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("%s.writeBooleanArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Char: - sb.Append(prefix).AppendFormat("%s.writeCharArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Byte: - sb.Append(prefix).AppendFormat("%s.writeByteArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Short: - sb.Append(prefix).AppendFormat("%s.writeShortArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("%s.writeIntArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("%s.writeLongArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("%s.writeFloatArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("%s.writeDoubleArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("%s.writeStringArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Sequenceable: - sb.Append(prefix).AppendFormat("%s.writeSequenceableArray(%s);\n", parcelName.string(), name.c_str()); - break; - default: - break; - } -} - -void JsCodeEmitter::EmitWriteOutArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).AppendFormat("if (%s == null) {\n", name.c_str()); - sb.Append(prefix).AppendFormat(" %s.writeInt(-1);\n", parcelName.string()); - sb.Append(prefix).Append("} else {\n"); - sb.Append(prefix).AppendFormat(" %s.writeInt(%s.length);\n", parcelName.string(), name.c_str()); - sb.Append(prefix).Append("}\n"); -} - -void JsCodeEmitter::EmitReadVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ unsigned int attributes, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - switch (mt->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("let %s = %s.readInt() == 1 ? true : false;\n", name.c_str(), - parcelName.string()); - break; - case TypeKind::Char: - case TypeKind::Byte: - case TypeKind::Short: - sb.Append(prefix).AppendFormat("let %s = %s.readInt();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("let %s = %s.readInt();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("let %s = %s.readLong();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("let %s = %s.readFloat();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("let %s = %s.readDouble();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("let %s = %s.readString();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Sequenceable: - if ((attributes & ATTR_OUT) == 0 && EmitType(mt).Equals("IRemoteObject")) { - sb.Append(prefix).AppendFormat("IRemoteObject %s = %s.readRemoteObject();\n", - name.c_str(), parcelName.string()); - break; - } - if ((attributes & ATTR_OUT) == 0) { - sb.Append(prefix).AppendFormat("%s %s = new %s();\n", - EmitType(mt).string(), name.c_str(), EmitType(mt).string()); - } - sb.Append(prefix).AppendFormat("%s.readSequenceable(%s);\n", parcelName.string(), name.c_str()); - - break; - case TypeKind::Interface: - sb.Append(prefix).AppendFormat("let %s = %s.asInterface(%s.readRemoteObject());\n", name.c_str(), - StubName(EmitType(mt)).string(), parcelName.string()); - break; - case TypeKind::List: { - sb.Append(prefix).AppendFormat("let %s = new Array%s();\n", name.c_str(), EmitType(mt).string()); - sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s.add(value);\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Map: { - sb.Append(prefix).AppendFormat("let %s = new Hash%s();\n", name.c_str(), EmitType(mt).string()); - sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); - MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; - EmitReadVariable(parcelName, "key", keyType, ATTR_IN, sb, prefix + TAB); - EmitReadVariable(parcelName, "value", valueType, ATTR_IN, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s.put(key, value);\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Array: { - if ((attributes & ATTR_MASK) == ATTR_OUT) { - EmitReadOutArrayVariable(parcelName, name, mt, sb, prefix); - } else { - EmitReadArrayVariable(parcelName, name, mt, attributes, sb, prefix); - } - break; - } - default: - break; - } -} - -void JsCodeEmitter::EmitReadVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& returnName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ unsigned int attributes, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - switch (mt->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("let %s = %s.%s.readInt() == 1 ? true : false;\n", name.c_str(), - returnName.c_str(), parcelName.string()); - break; - case TypeKind::Char: - case TypeKind::Byte: - case TypeKind::Short: - sb.Append(prefix).AppendFormat("let %s = %s.%s.readInt();\n", name.c_str(), returnName.c_str(), - parcelName.string()); - break; - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("let %s = %s.%s.readInt();\n", name.c_str(), returnName.c_str(), - parcelName.string()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("let %s = %s.%s.readLong();\n", name.c_str(), returnName.c_str(), - parcelName.string()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("let %s = %s.%s.readFloat();\n", name.c_str(), returnName.c_str(), - parcelName.string()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("let %s = %s.%s.readDouble();\n", name.c_str(), returnName.c_str(), - parcelName.string()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("let %s = %s.%s.readString();\n", name.c_str(), returnName.c_str(), - parcelName.string()); - break; - case TypeKind::Sequenceable: - if ((attributes & ATTR_OUT) == 0 && EmitType(mt).Equals("IRemoteObject")) { - sb.Append(prefix).AppendFormat("IRemoteObject %s = %s.%s.readRemoteObject();\n", - name.c_str(), parcelName.string()); - break; - } - if ((attributes & ATTR_OUT) == 0) { - sb.Append(prefix).AppendFormat("%s %s = new %s();\n", - EmitType(mt).string(), name.c_str(), EmitType(mt).string()); - } - sb.Append(prefix).AppendFormat("%s.readSequenceable(%s);\n", parcelName.string(), name.c_str()); - - break; - case TypeKind::Interface: - sb.Append(prefix).AppendFormat("let %s = %s.%s.asInterface(%s.readRemoteObject());\n", name.c_str(), - StubName(EmitType(mt)).string(), parcelName.string()); - break; - case TypeKind::List: { - sb.Append(prefix).AppendFormat("let %s = new Array%s();\n", name.c_str(), EmitType(mt).string()); - sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s.add(value);\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Map: { - sb.Append(prefix).AppendFormat("let %s = new Hash%s();\n", name.c_str(), EmitType(mt).string()); - sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); - MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; - EmitReadVariable(parcelName, "key", keyType, ATTR_IN, sb, prefix + TAB); - EmitReadVariable(parcelName, "value", valueType, ATTR_IN, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s.put(key, value);\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Array: { - if ((attributes & ATTR_MASK) == ATTR_OUT) { - EmitReadOutArrayVariable(parcelName, name, mt, sb, prefix); - } else { - EmitReadArrayVariable(parcelName, name, mt, attributes, sb, prefix); - } - break; - } - default: - break; - } -} - -void JsCodeEmitter::EmitReadArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ unsigned int attributes, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - switch (innerType->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("let %s = %s.readBooleanArray();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Char: - sb.Append(prefix).AppendFormat("let %s = %s.readCharArray();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Byte: - sb.Append(prefix).AppendFormat("let %s = %s.readByteArray();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Short: - sb.Append(prefix).AppendFormat("let %s = %s.readShortArray();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("let %s = %s.readIntArray();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("let %s = %s.readLongArray();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("let %s = %s.readFloatArray();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("let %s = %s.readDoubleArray();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("let %s = %s.readStringArray();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Sequenceable: - sb.Append(prefix).AppendFormat("int size = %s.readInt();\n", parcelName.string()); - sb.Append(prefix).AppendFormat("%s %s = new %s[size];\n", - EmitType(mt).string(), name.c_str(), EmitType(innerType).string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < size; ++i) {\n"); - EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s[i] = value;\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - default: - break; - } -} - -void JsCodeEmitter::EmitReadOutArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - switch (innerType->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("%s.readBooleanArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Char: - sb.Append(prefix).AppendFormat("%s.readCharArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Byte: - sb.Append(prefix).AppendFormat("%s.readByteArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Short: - sb.Append(prefix).AppendFormat("%s.readShortArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("%s.readIntArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("%s.readLongArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("%s.readFloatArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("%s.readDoubleArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("%s.readStringArray(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Sequenceable: - sb.Append(prefix).AppendFormat("%s.readSequenceableArray(%s);\n", parcelName.string(), name.c_str()); - break; - default: - break; - } -} - -void JsCodeEmitter::EmitReadOutVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - switch (mt->kind_) { - case TypeKind::Boolean: - sb.Append(prefix).AppendFormat("%s = %s.readInt() == 1 ? true : false;\n", - name.c_str(), parcelName.string()); - break; - case TypeKind::Char: - case TypeKind::Byte: - case TypeKind::Short: - sb.Append(prefix).AppendFormat("%s = (%s)%s.readInt();\n", - name.c_str(), EmitType(mt).string(), parcelName.string()); - break; - case TypeKind::Integer: - sb.Append(prefix).AppendFormat("%s = %s.readInt();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Long: - sb.Append(prefix).AppendFormat("%s = %s.readLong();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Float: - sb.Append(prefix).AppendFormat("%s = %s.readFloat();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Double: - sb.Append(prefix).AppendFormat("%s = %s.readDouble();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::String: - sb.Append(prefix).AppendFormat("%s = %s.readString();\n", name.c_str(), parcelName.string()); - break; - case TypeKind::Sequenceable: - if (EmitType(mt).Equals("IRemoteObject")) { - sb.Append(prefix).AppendFormat("%s = %s.readRemoteObject();\n", name.c_str(), parcelName.string()); - break; - } - sb.Append(prefix).AppendFormat("%s.readSequenceable(%s);\n", parcelName.string(), name.c_str()); - break; - case TypeKind::Interface: - sb.Append(prefix).AppendFormat("%s = %s.asInterface(%s.readRemoteObject());\n", name.c_str(), - StubName(EmitType(mt)).string(), parcelName.string()); - break; - case TypeKind::List: { - sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); - MetaType* innerType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - EmitReadVariable(parcelName, "value", innerType, ATTR_IN, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s.add(value);\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Map: { - sb.Append(prefix).AppendFormat("int %sSize = %s.readInt();\n", name.c_str(), parcelName.string()); - sb.Append(prefix).AppendFormat("for (int i = 0; i < %sSize; ++i) {\n", name.c_str()); - MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; - EmitReadVariable(parcelName, "key", keyType, ATTR_IN, sb, prefix + TAB); - EmitReadVariable(parcelName, "value", valueType, ATTR_IN, sb, prefix + TAB); - sb.Append(prefix + TAB).AppendFormat("%s.put(key, value);\n", name.c_str()); - sb.Append(prefix).Append("}\n"); - break; - } - case TypeKind::Array: { - EmitReadOutArrayVariable(parcelName, name, mt, sb, prefix); - break; - } - default: - break; - } -} - -void JsCodeEmitter::EmitLocalVariable( - /* [in] */ MetaParameter* mp, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix) -{ - MetaType* mt = metaComponent_->types_[mp->typeIndex_]; - std::string name = UnderlineAdded(mp->name_); - if (mt->kind_ == TypeKind::Sequenceable) { - sb.Append(prefix).AppendFormat("let %s = new %s();\n", name.c_str(), EmitType(mt).string()); - } else if (mt->kind_ == TypeKind::List) { - sb.Append(prefix).AppendFormat("let %s = new Array%s();\n", name.c_str(), EmitType(mt).string()); - } else if (mt->kind_ == TypeKind::Map) { - sb.Append(prefix).AppendFormat("let %s = new Hash%s();\n", name.c_str(), EmitType(mt).string()); - } else { - sb.Append(prefix).AppendFormat("let %s;\n", name.c_str()); - } -} - -String JsCodeEmitter::EmitType( - /* [in] */ MetaType* mt) -{ - switch(mt->kind_) { - case TypeKind::Char: - return "char"; - case TypeKind::Boolean: - return "boolean"; - case TypeKind::Byte: - return "byte"; - case TypeKind::Short: - return "short"; - case TypeKind::Integer: - return "int"; - case TypeKind::Long: - return "long"; - case TypeKind::Float: - return "float"; - case TypeKind::Double: - return "double"; - case TypeKind::String: - return "String"; - case TypeKind::Void: - return "void"; - case TypeKind::Sequenceable: { - MetaSequenceable* mp = metaComponent_->sequenceables_[mt->index_]; - return mp->name_; - } - case TypeKind::Interface: { - MetaInterface* mi = metaComponent_->interfaces_[mt->index_]; - return mi->name_; - } - case TypeKind::List: { - MetaType* elementType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - return String::Format("List<%s>", EmitType(elementType).string()); - } - case TypeKind::Map: { - MetaType* keyType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - MetaType* valueType = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; - return String::Format("Map<%s, %s>", EmitType(keyType).string(), EmitType(valueType).string()); - } - case TypeKind::Array: { - MetaType* elementType = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - return String::Format("%s[]", EmitType(elementType).string()); - } - default: - return "unknown type"; - } -} - -String JsCodeEmitter::FileName( - /* [in] */ const String& name) -{ - if (name.IsEmpty()) { - return name; - } - - return name.Replace('.', '/'); -} - -String JsCodeEmitter::MethodName( - /* [in] */ const String& name) -{ - if (name.IsEmpty() || islower(name[0])) { - return name; - } - return String::Format("%c%s", tolower(name[0]), name.Substring(1).string()); -} - -String JsCodeEmitter::ConstantName( - /* [in] */ const String& name) -{ - if (name.IsEmpty()) { - return name; - } - - StringBuilder sb; - - for (int i = 0; i < name.GetLength(); i++) { - char c = name[i]; - if (isupper(c) != 0) { - if (i > 1) { - sb.Append('_'); - } - sb.Append(c); - } else { - sb.Append(toupper(c)); - } - } - - return sb.ToString(); -} - -String JsCodeEmitter::StubName( - /* [in] */ const String& name) -{ - return name.StartsWith("I") ? (name.Substring(1) + "Stub") : (name + "Stub"); -} - -const std::string JsCodeEmitter::UnderlineAdded(const String& originName) -{ - std::string underline("_"); - return underline + std::string(originName.string()); -} - -} -} diff --git a/zidl/codegen/js_code_emitter.h b/zidl/codegen/js_code_emitter.h deleted file mode 100644 index ad822f91448..00000000000 --- a/zidl/codegen/js_code_emitter.h +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_JSCODEEMITTER_H -#define OHOS_ZIDL_JSCODEEMITTER_H - -#include - -#include "codegen/code_emitter.h" -#include "util/string_builder.h" - -namespace OHOS { -namespace Zidl { - -class JsCodeEmitter : public CodeEmitter { -public: - JsCodeEmitter( - /* [in] */ MetaComponent* mc) - : CodeEmitter(mc) - {} - - void EmitInterface() override; - - void EmitInterfaceProxy() override; - - void EmitInterfaceStub() override; - -private: - void EmitInterfaceImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceCorelibImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceDBinderImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceSelfDefinedTypeImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceDefinition( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceMethods( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceMethod( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceProxyCorelibImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceProxySelfDefinedTypeImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceProxyDBinderImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceProxyParametersImports( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceProxyImpl( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceProxyConstants( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyConstructor( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyMethodImpls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyMethodImpl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceProxyMethodBody( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitWriteMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ const String& parcelName, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReadMethodParameter( - /* [in] */ MetaParameter* mp, - /* [in] */ const String& parcelName, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceStubImpl( - /* [in] */ StringBuilder& sb); - - void EmitInterfaceStubConstants(/* [in] */ StringBuilder& sb); - - void EmitJsCallBack(/* [in] */ StringBuilder& sb); - - void EmitInterfaceStubConstructor( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceStubMethodImpls( - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceStubMethodImpl( - /* [in] */ MetaMethod* mm, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitInterfaceMethodCommands(/* [in] */ StringBuilder& sb); - - void EmitLicense( - /* [in] */ StringBuilder& sb); - - void EmitPackage( - /* [in] */ StringBuilder& sb); - - void EmitWriteVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReadVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ unsigned int attributes, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReadVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& returnName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ unsigned int attributes, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReadOutVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReadArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ unsigned int attributes, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitWriteArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitWriteOutArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitReadOutArrayVariable( - /* [in] */ const String& parcelName, - /* [in] */ const std::string& name, - /* [in] */ MetaType* mt, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - void EmitLocalVariable( - /* [in] */ MetaParameter* mp, - /* [in] */ StringBuilder& sb, - /* [in] */ const String& prefix); - - String EmitType( - /* [in] */ MetaType* mt); - - String FileName( - /* [in] */ const String& name); - - String MethodName( - /* [in] */ const String& name); - - String ConstantName( - /* [in] */ const String& name); - - String StubName( - /* [in] */ const String& name); - - const std::string UnderlineAdded(const String& name); -}; - -} -} - -#endif // OHOS_ZIDL_JSCODEEMITTER_H diff --git a/zidl/main.cpp b/zidl/main.cpp deleted file mode 100644 index c0e314a6ce9..00000000000 --- a/zidl/main.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "codegen/code_generator.h" -#include "metadata/metadata_builder.h" -#include "metadata/metadata_dumper.h" -#include "metadata/metadata_reader.h" -#include "metadata/metadata_serializer.h" -#include "parser/parser.h" -#include "util/logger.h" -#include "util/options.h" - -using namespace OHOS::Zidl; - -static const char* TAG = "zidl"; - -int main(int argc, char** argv) -{ - Options options(argc, argv); - - if (options.DoShowUsage()) { - options.ShowUsage(); - return 0; - } - - if (options.DoShowVersion()) { - options.ShowVersion(); - return 0; - } - - if (options.HasErrors()) { - options.ShowErrors(); - return 0; - } - - std::shared_ptr metadata; - - if (options.DoCompile()) { - Parser parser(options); - if (!parser.Parse(options.GetSourceFile())) { - Logger::E(TAG, "Parsing .zidl failed."); - return -1; - } - - MetadataBuilder builder(parser.GetModule()); - metadata = builder.Build(); - if (metadata == nullptr) { - Logger::E(TAG, "Generate metadata failed."); - return -1; - } - } - - if (options.DoDumpMetadata()) { - MetadataDumper dumper(metadata.get()); - dumper.Dump(""); - } - - if (options.DoSaveMetadata()) { - File metadataFile(options.GetMetadataFile(), File::WRITE); - if (!metadataFile.IsValid()) { - Logger::E(TAG, "Create metadata file failed."); - return -1; - } - - MetadataSerializer serializer(metadata.get()); - serializer.Serialize(); - uintptr_t data = serializer.GetData(); - int size = serializer.GetDataSize(); - - metadataFile.WriteData(reinterpret_cast(data), size); - metadataFile.Flush(); - metadataFile.Close(); - } - - if (options.DoGenerateCode()) { - if (metadata == nullptr) { - String metadataFile = options.GetMetadataFile(); - metadata = MetadataReader::ReadMetadataFromFile(metadataFile); - if (metadata == nullptr) { - Logger::E(TAG, "Get metadata from \"%s\" failed.", metadataFile.string()); - return -1; - } - } - - CodeGenerator codeGen(metadata.get(), options.GetTargetLanguage(), - options.GetGenerationDirectory()); - if (!codeGen.Generate()) { - Logger::E(TAG, "Generate \"%s\" codes failed.", options.GetTargetLanguage().string()); - return -1; - } - } - - return 0; -} diff --git a/zidl/metadata/CMakeLists.txt b/zidl/metadata/CMakeLists.txt deleted file mode 100644 index 448c9d75914..00000000000 --- a/zidl/metadata/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -include_directories( - ${ZIDL_DIR}) - -set(SOURCES - metadata_builder.cpp - metadata_dumper.cpp - metadata_reader.cpp - metadata_serializer.cpp) - -add_library(metadata STATIC - ${SOURCES}) \ No newline at end of file diff --git a/zidl/metadata/metadata.h b/zidl/metadata/metadata.h deleted file mode 100644 index 0b405f06e4c..00000000000 --- a/zidl/metadata/metadata.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_METADATA_H -#define OHOS_ZIDL_METADATA_H - -namespace OHOS { -namespace Zidl { - -static constexpr int METADATA_MAGIC_NUMBER = 0x1DF02ED1; - -enum class TypeKind { - Unknown = 0, - Char = 1, - Boolean = 2, - Byte = 3, - Short = 4, - Integer = 5, - Long = 6, - Float = 7, - Double = 8, - String = 9, - Void = 10, - Sequenceable = 11, - Interface = 12, - List = 13, - Map = 14, - Array = 15, -}; - -struct MetaNamespace; -struct MetaSequenceable; -struct MetaInterface; -struct MetaMethod; -struct MetaParameter; -struct MetaType; - -struct MetaComponent { - int magic_; - int size_; - char* name_; - int namespaceNumber_; - int sequenceableNumber_; - int interfaceNumber_; - int typeNumber_; - MetaNamespace** namespaces_; - MetaSequenceable** sequenceables_; - MetaInterface** interfaces_; - MetaType** types_; - int stringPoolSize_; - char* stringPool_; -}; - -struct MetaNamespace { - char* name_; - int sequenceableNumber_; - int interfaceNumber_; - int namespaceNumber_; - int* sequenceableIndexes_; - int* interfaceIndexes_; - MetaNamespace** namespaces_; -}; - -struct MetaSequenceable { - char* name_; - char* namespace_; -}; - -static constexpr unsigned int INTERFACE_PROPERTY_ONEWAY = 0x1; - -struct MetaInterface { - char* license_; - char* name_; - char* namespace_; - unsigned int properties_; - int methodNumber_; - MetaMethod** methods_; - bool external_; -}; - -static constexpr unsigned int METHOD_PROPERTY_ONEWAY = 0x1; - -struct MetaMethod { - char* name_; - char* signature_; - unsigned int properties_; - int returnTypeIndex_; - int parameterNumber_; - MetaParameter** parameters_; -}; - -static constexpr unsigned int ATTR_IN = 0x1; -static constexpr unsigned int ATTR_OUT = 0x2; -static constexpr unsigned int ATTR_MASK = 0x3; - -struct MetaParameter { - char* name_; - unsigned int attributes_; - int typeIndex_; -}; - -struct MetaType { - TypeKind kind_; - int index_; - int nestedTypeNumber_; - int* nestedTypeIndexes_; -}; - -} -} - -#endif // OHOS_ZIDL_METADATA_H diff --git a/zidl/metadata/metadata_builder.cpp b/zidl/metadata/metadata_builder.cpp deleted file mode 100644 index 6ba08529d4f..00000000000 --- a/zidl/metadata/metadata_builder.cpp +++ /dev/null @@ -1,502 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "metadata/metadata_builder.h" -#include -#include "securec.h" -#include "ast/ast_array_type.h" -#include "ast/ast_list_type.h" -#include "ast/ast_map_type.h" -#include "util/logger.h" - -#define ALIGN8(v) (((v) + 7) & ~7) - -namespace OHOS { -namespace Zidl { - -const char* MetadataBuilder::TAG = "MetadataBuilder"; - -std::shared_ptr MetadataBuilder::Build() -{ - if (!module_->IsValid()) { - Logger::E(TAG, "The module is not validate."); - return nullptr; - } - - size_ = CalculateMetadataSize(); - void* metadata = calloc(size_, 1); - if (metadata == nullptr) { - Logger::E(TAG, "Out of memory."); - return nullptr; - } - - metaComponent_.reset( - new(metadata) MetaComponent, - [](MetaComponent* p){ free(p); }); - - WriteMetadata(reinterpret_cast(metadata)); - - return metaComponent_; -} - -size_t MetadataBuilder::CalculateMetadataSize() -{ - baseAddr_ = 0; - CalculateMetaComponent(module_); - return baseAddr_; -} - -void MetadataBuilder::CalculateMetaComponent( - /* [in] */ ASTModule* module) -{ - int namespaceNumber = module->GetNamespaceNumber(); - int sequenceableNumber = module->GetSequenceableNumber(); - int interfaceNumber = module->GetInterfaceNumber(); - int typeNumber = module->GetTypeNumber(); - - // begin address - baseAddr_ = ALIGN8(baseAddr_); - stringPool_.Add(module_->GetName()); - // namespaces_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaComponent)); - // sequenceables_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaNamespace*) * namespaceNumber); - // interfaces_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaSequenceable*) * sequenceableNumber); - // types_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaInterface*) * interfaceNumber); - // stringPool_'s address - baseAddr_ = baseAddr_ + sizeof(MetaType*) * typeNumber; - - for (int i = 0; i < namespaceNumber; i++) { - CalculateMetaNamespace(module->GetNamespace(i)); - } - - for (int i = 0; i < sequenceableNumber; i++) { - CalculateMetaSequenceable(module->GetSequenceable(i)); - } - - for (int i = 0; i < interfaceNumber; i++) { - CalculateMetaInterface(module->GetInterface(i)); - } - - const ASTModule::TypeStringMap& types = module_->GetTypes(); - for (const auto& pair : types) { - CalculateMetaType(pair.second); - } - - // end address - CalculateStringPool(); -} - -void MetadataBuilder::CalculateMetaNamespace( - /* [in] */ ASTNamespace* nspace) -{ - int sequenceableNumber = nspace->GetSequenceableNumber(); - int interfaceNumber = nspace->GetInterfaceNumber(); - int namespaceNumber = nspace->GetNamespaceNumber(); - - // begin address - baseAddr_ = ALIGN8(baseAddr_); - stringPool_.Add(nspace->GetName()); - // sequenceables_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaNamespace)); - // interfaces_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(int) * sequenceableNumber); - // namespaces_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(int) * interfaceNumber); - // end address - baseAddr_ = baseAddr_ + sizeof(MetaNamespace*) * namespaceNumber; - - for (int i = 0; i < namespaceNumber; i++) { - CalculateMetaNamespace(nspace->GetNamespace(i)); - } -} - -void MetadataBuilder::CalculateMetaSequenceable( - /* [in] */ ASTSequenceableType* sequenceable) -{ - // begin address - baseAddr_ = ALIGN8(baseAddr_); - stringPool_.Add(sequenceable->GetName()); - stringPool_.Add(sequenceable->GetNamespace()->ToString()); - // end address - baseAddr_ = baseAddr_ + sizeof(MetaSequenceable); -} - -void MetadataBuilder::CalculateMetaInterface( - /* [in] */ ASTInterfaceType* interface) -{ - int methodNumber = interface->GetMethodNumber(); - - // begin address - baseAddr_ = ALIGN8(baseAddr_); - stringPool_.Add(interface->GetLicense()); - stringPool_.Add(interface->GetName()); - stringPool_.Add(interface->GetNamespace()->ToString()); - // methods_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaInterface)); - // end address - baseAddr_ = baseAddr_ + sizeof(MetaMethod*) * methodNumber; - - for (int i = 0; i < methodNumber; i++) { - CalculateMetaMethod(interface->GetMethod(i)); - } -} - -void MetadataBuilder::CalculateMetaMethod( - /* [in] */ ASTMethod* method) -{ - int parameterNumber = method->GetParameterNumber(); - - // begin address - baseAddr_ = ALIGN8(baseAddr_); - stringPool_.Add(method->GetName()); - stringPool_.Add(method->GetSignature()); - // parameters_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaMethod)); - // end address - baseAddr_ = baseAddr_ + sizeof(MetaParameter*) * parameterNumber; - - for (int i = 0; i < parameterNumber; i++) { - CalculateMetaParameter(method->GetParameter(i)); - } -} - -void MetadataBuilder::CalculateMetaParameter( - /* [in] */ ASTParameter* parameter) -{ - // begin address - baseAddr_ = ALIGN8(baseAddr_); - stringPool_.Add(parameter->GetName()); - // end address - baseAddr_ = baseAddr_ + sizeof(MetaParameter); -} - -void MetadataBuilder::CalculateMetaType( - /* [in] */ ASTType* type) -{ - // begin address - baseAddr_ = ALIGN8(baseAddr_); - // nestedTypeIndexes_'s address - baseAddr_ = baseAddr_ + sizeof(MetaType); - if (type->IsListType()) { - baseAddr_ = ALIGN8(baseAddr_); - // end address - baseAddr_ = baseAddr_ + sizeof(int*); - } else if (type->IsMapType()) { - // end address - baseAddr_ = baseAddr_ + sizeof(int*) * 2; - } -} - -void MetadataBuilder::CalculateStringPool() -{ - // begin address - baseAddr_ = ALIGN8(baseAddr_); - // end address - baseAddr_ = baseAddr_ + stringPool_.GetSize(); -} - -void MetadataBuilder::WriteMetadata( - /* [in] */ uintptr_t base) -{ - baseAddr_ = base; - WriteMetaComponent(module_); -} - -void MetadataBuilder::WriteMetaComponent( - /* [in] */ ASTModule* module) -{ - int namespaceNumber = module->GetNamespaceNumber(); - int sequenceableNumber = module->GetSequenceableNumber(); - int interfaceNumber = module->GetInterfaceNumber(); - int typeNumber = module->GetTypeNumber(); - - // begin address - baseAddr_ = ALIGN8(baseAddr_); - MetaComponent* mc = reinterpret_cast(baseAddr_); - mc->magic_ = METADATA_MAGIC_NUMBER; - mc->size_ = size_; - mc->namespaceNumber_ = namespaceNumber; - mc->sequenceableNumber_ = sequenceableNumber; - mc->interfaceNumber_ = interfaceNumber; - mc->typeNumber_ = typeNumber; - mc->stringPoolSize_ = stringPool_.GetSize(); - // namespaces_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaComponent)); - mc->namespaces_ = reinterpret_cast(baseAddr_); - // sequenceables_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaNamespace*) * namespaceNumber); - mc->sequenceables_ = reinterpret_cast(baseAddr_); - // interfaces_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaSequenceable*) * sequenceableNumber); - mc->interfaces_ = reinterpret_cast(baseAddr_); - // types_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaInterface*) * interfaceNumber); - mc->types_ = reinterpret_cast(baseAddr_); - // stringPool_'s address - baseAddr_ = baseAddr_ + sizeof(MetaType*) * typeNumber; - mc->stringPool_ = reinterpret_cast(baseAddr_); - // end address - baseAddr_ = baseAddr_ + stringPool_.GetSize(); - (void)memcpy_s(mc->stringPool_, stringPool_.GetSize(), stringPool_.GetData(), stringPool_.GetSize()); - - mc->name_ = WriteString(module->GetName()); - - for (int i = 0; i < namespaceNumber; i++) { - mc->namespaces_[i] = WriteMetaNamespace(module->GetNamespace(i)); - } - - for (int i = 0; i < sequenceableNumber; i++) { - mc->sequenceables_[i] = WriteMetaSequenceable(module->GetSequenceable(i)); - } - - for (int i = 0; i < interfaceNumber; i++) { - mc->interfaces_[i] = WriteMetaInterface(module->GetInterface(i)); - } - - const ASTModule::TypeStringMap& types = module->GetTypes(); - int i = 0; - for (const auto& pair : types) { - mc->types_[i++] = WriteMetaType(pair.second); - } -} - -MetaNamespace* MetadataBuilder::WriteMetaNamespace( - /* [in] */ ASTNamespace* nspace) -{ - int sequenceableNumber = nspace->GetSequenceableNumber(); - int interfaceNumber = nspace->GetInterfaceNumber(); - int namespaceNumber = nspace->GetNamespaceNumber(); - - // begin address - baseAddr_ = ALIGN8(baseAddr_); - MetaNamespace* mn = reinterpret_cast(baseAddr_); - mn->name_ = WriteString(nspace->GetName()); - mn->sequenceableNumber_ = sequenceableNumber; - mn->interfaceNumber_ = interfaceNumber; - mn->namespaceNumber_ = namespaceNumber; - // sequenceables_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaNamespace)); - mn->sequenceableIndexes_ = reinterpret_cast(baseAddr_); - // interfaces_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(int) * sequenceableNumber); - mn->interfaceIndexes_ = reinterpret_cast(baseAddr_); - // namespaces_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(int) * interfaceNumber); - mn->namespaces_ = reinterpret_cast(baseAddr_); - // end address - baseAddr_ = baseAddr_ + sizeof(MetaNamespace*) * namespaceNumber; - - for (int i = 0; i < sequenceableNumber; i++) { - AutoPtr sequenceable = nspace->GetSequenceable(i); - mn->sequenceableIndexes_[i] = module_->IndexOf(sequenceable); - } - - for (int i = 0; i < interfaceNumber; i++) { - AutoPtr interface = nspace->GetInterface(i); - mn->interfaceIndexes_[i] = module_->IndexOf(interface); - } - - for (int i = 0; i < namespaceNumber; i++) { - AutoPtr inner = nspace->GetNamespace(i); - mn->namespaces_[i] = WriteMetaNamespace(inner); - } - - return mn; -} - -MetaSequenceable* MetadataBuilder::WriteMetaSequenceable( - /* [in] */ ASTSequenceableType* parcelabe) -{ - // begin address - baseAddr_ = ALIGN8(baseAddr_); - MetaSequenceable* mp = reinterpret_cast(baseAddr_); - mp->name_ = WriteString(parcelabe->GetName()); - mp->namespace_ = WriteString(parcelabe->GetNamespace()->ToString()); - // end address - baseAddr_ = baseAddr_ + sizeof(MetaSequenceable); - - return mp; -} - -MetaInterface* MetadataBuilder::WriteMetaInterface( - /* [in] */ ASTInterfaceType* interface) -{ - int methodNumber = interface->GetMethodNumber(); - - // begin address - baseAddr_ = ALIGN8(baseAddr_); - MetaInterface* mi = reinterpret_cast(baseAddr_); - mi->license_ = WriteString(interface->GetLicense()); - mi->name_ = WriteString(interface->GetName()); - mi->namespace_ = WriteString(interface->GetNamespace()->ToString()); - mi->properties_ = interface->IsOneway() ? INTERFACE_PROPERTY_ONEWAY : 0; - mi->methodNumber_ = methodNumber; - mi->external_ = interface->IsExternal(); - // methods_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaInterface)); - mi->methods_ = reinterpret_cast(baseAddr_); - // end address - baseAddr_ = baseAddr_ + sizeof(MetaMethod*) * methodNumber; - - for (int i = 0; i < methodNumber; i++) { - mi->methods_[i] = WriteMetaMethod(interface->GetMethod(i)); - } - - return mi; -} - -MetaMethod* MetadataBuilder::WriteMetaMethod( - /* [in] */ ASTMethod* method) -{ - int parameterNumber = method->GetParameterNumber(); - - // begin address - baseAddr_ = ALIGN8(baseAddr_); - MetaMethod* mm = reinterpret_cast(baseAddr_); - mm->name_ = WriteString(method->GetName()); - mm->signature_ = WriteString(method->GetSignature()); - mm->properties_ = method->IsOneway() ? METHOD_PROPERTY_ONEWAY : 0; - mm->returnTypeIndex_ = module_->IndexOf(method->GetReturnType()); - mm->parameterNumber_ = parameterNumber; - // parameters_'s address - baseAddr_ = ALIGN8(baseAddr_ + sizeof(MetaMethod)); - mm->parameters_ = reinterpret_cast(baseAddr_); - // end address - baseAddr_ = baseAddr_ + sizeof(MetaParameter*) * parameterNumber; - - for (int i = 0; i < parameterNumber; i++) { - mm->parameters_[i] = WriteMetaParameter(method->GetParameter(i)); - } - - return mm; -} - -MetaParameter* MetadataBuilder::WriteMetaParameter( - /* [in] */ ASTParameter* parameter) -{ - // begin address - baseAddr_ = ALIGN8(baseAddr_); - MetaParameter* mp = reinterpret_cast(baseAddr_); - mp->name_ = WriteString(parameter->GetName()); - if (parameter->IsInParameter()) { - mp->attributes_ |= ATTR_IN; - } - if (parameter->IsOutParameter()) { - mp->attributes_ |= ATTR_OUT; - } - mp->typeIndex_ = module_->IndexOf(parameter->GetType()); - // end address - baseAddr_ = baseAddr_ + sizeof(MetaParameter); - - return mp; -} - -MetaType* MetadataBuilder::WriteMetaType( - /* [in] */ ASTType* type) -{ - // begin address - baseAddr_ = ALIGN8(baseAddr_); - MetaType* mt = reinterpret_cast(baseAddr_); - mt->kind_ = Type2Kind(type); - if (type->IsSequenceableType()) { - mt->index_ = module_->IndexOf(static_cast(type)); - } else if (type->IsInterfaceType()) { - mt->index_ = module_->IndexOf(static_cast(type)); - } else { - mt->index_ = module_->IndexOf(type); - } - baseAddr_ = baseAddr_ + sizeof(MetaType); - if (type->IsListType()) { - mt->nestedTypeNumber_ = 1; - // nestedTypeIndexes_'s address - baseAddr_ = ALIGN8(baseAddr_); - mt->nestedTypeIndexes_ = reinterpret_cast(baseAddr_); - AutoPtr elementType = (static_cast(type))->GetElementType(); - mt->nestedTypeIndexes_[0] = module_->IndexOf(elementType); - // end address - baseAddr_ = baseAddr_ + sizeof(int*); - } else if (type->IsMapType()) { - mt->nestedTypeNumber_ = 2; - // nestedTypeIndexes_'s address - baseAddr_ = ALIGN8(baseAddr_); - mt->nestedTypeIndexes_ = reinterpret_cast(baseAddr_); - AutoPtr keyType = (static_cast(type))->GetKeyType(); - AutoPtr valueType = (static_cast(type))->GetValueType(); - mt->nestedTypeIndexes_[0] = module_->IndexOf(keyType); - mt->nestedTypeIndexes_[1] = module_->IndexOf(valueType); - // end address - baseAddr_ = baseAddr_ + sizeof(int*) * 2; - } else if (type->IsArrayType()) { - mt->nestedTypeNumber_ = 1; - // nestedTypeIndexes_'s address - baseAddr_ = ALIGN8(baseAddr_); - mt->nestedTypeIndexes_ = reinterpret_cast(baseAddr_); - AutoPtr elementType = (static_cast(type))->GetElementType(); - mt->nestedTypeIndexes_[0] = module_->IndexOf(elementType); - // end address - baseAddr_ = baseAddr_ + sizeof(int*); - } - - return mt; -} - -char* MetadataBuilder::WriteString( - /* [in] */ const String& string) -{ - return string.IsNull() ? nullptr : metaComponent_->stringPool_ + stringPool_.GetOffset(string); -} - -TypeKind MetadataBuilder::Type2Kind( - /* [in] */ ASTType* type) -{ - if (type->IsCharType()) { - return TypeKind::Char; - } else if (type->IsBooleanType()) { - return TypeKind::Boolean; - } else if (type->IsByteType()) { - return TypeKind::Byte; - } else if (type->IsShortType()) { - return TypeKind::Short; - } else if (type->IsIntegerType()) { - return TypeKind::Integer; - } else if (type->IsLongType()) { - return TypeKind::Long; - } else if (type->IsFloatType()) { - return TypeKind::Float; - } else if (type->IsDoubleType()) { - return TypeKind::Double; - } else if (type->IsStringType()) { - return TypeKind::String; - } else if (type->IsVoidType()) { - return TypeKind::Void; - } else if (type->IsSequenceableType()) { - return TypeKind::Sequenceable; - } else if (type->IsInterfaceType()) { - return TypeKind::Interface; - } else if (type->IsListType()) { - return TypeKind::List; - } else if (type->IsMapType()) { - return TypeKind::Map; - } else if (type->IsArrayType()) { - return TypeKind::Array; - } - return TypeKind::Unknown; -} - -} -} diff --git a/zidl/metadata/metadata_builder.h b/zidl/metadata/metadata_builder.h deleted file mode 100644 index 1d0801fbef6..00000000000 --- a/zidl/metadata/metadata_builder.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_METADATABUILDER_H -#define OHOS_ZIDL_METADATABUILDER_H - -#include -#include "ast/ast_module.h" -#include "metadata/metadata.h" -#include "util/autoptr.h" -#include "util/string.h" -#include "util/string_pool.h" - -namespace OHOS { -namespace Zidl { - -class MetadataBuilder { -public: - explicit MetadataBuilder( - /* [in] */ ASTModule* module) - : module_(module) - {} - - ~MetadataBuilder() = default; - - std::shared_ptr Build(); - -private: - size_t CalculateMetadataSize(); - - void CalculateMetaComponent( - /* [in] */ ASTModule* module); - - void CalculateMetaNamespace( - /* [in] */ ASTNamespace* nspace); - - void CalculateMetaSequenceable( - /* [in] */ ASTSequenceableType* sequenceable); - - void CalculateMetaInterface( - /* [in] */ ASTInterfaceType* interface); - - void CalculateMetaMethod( - /* [in] */ ASTMethod* method); - - void CalculateMetaParameter( - /* [in] */ ASTParameter* parameter); - - void CalculateMetaType( - /* [in] */ ASTType* type); - - void CalculateStringPool(); - - void WriteMetadata( - /* [in] */ uintptr_t base); - - void WriteMetaComponent( - /* [in] */ ASTModule* module); - - MetaNamespace* WriteMetaNamespace( - /* [in] */ ASTNamespace* nspace); - - MetaSequenceable* WriteMetaSequenceable( - /* [in] */ ASTSequenceableType* parcelabe); - - MetaInterface* WriteMetaInterface( - /* [in] */ ASTInterfaceType* interface); - - MetaMethod* WriteMetaMethod( - /* [in] */ ASTMethod* method); - - MetaParameter* WriteMetaParameter( - /* [in] */ ASTParameter* parameter); - - MetaType* WriteMetaType( - /* [in] */ ASTType* type); - - char* WriteString( - /* [in] */ const String& string); - - TypeKind Type2Kind( - /* [in] */ ASTType* type); - - static const char* TAG; - AutoPtr module_; - std::shared_ptr metaComponent_; - uintptr_t baseAddr_ = 0; - size_t size_ = 0; - StringPool stringPool_; -}; - -} -} - -#endif // OHOS_ZIDL_METADATABUILDER_H diff --git a/zidl/metadata/metadata_dumper.cpp b/zidl/metadata/metadata_dumper.cpp deleted file mode 100644 index cba7aec6990..00000000000 --- a/zidl/metadata/metadata_dumper.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "metadata/metadata_dumper.h" -#include -#include "util/string_builder.h" - -namespace OHOS { -namespace Zidl { - -const char* MetadataDumper::TAB = " "; - -void MetadataDumper::Dump( - /* [in] */ const String& prefix) -{ - if (metaComponent_ == nullptr) { - return; - } - - String dumpStr = DumpMetaComponent(metaComponent_, prefix); - printf("%s\n", dumpStr.string()); -} - -String MetadataDumper::DumpMetaComponent( - /* [in] */ MetaComponent* mc, - /* [in] */ const String& prefix) -{ - StringBuilder sb; - - sb.Append(prefix).Append("MetaComponent\n"); - sb.Append(prefix).Append("{\n"); - sb.Append(prefix + TAB).AppendFormat("\"magic_\" : \"0x%x\",\n", mc->magic_); - sb.Append(prefix + TAB).AppendFormat("\"size_\" : \"%d\",\n", mc->size_); - sb.Append(prefix + TAB).AppendFormat("\"name_\" : \"%s\",\n", mc->name_); - sb.Append(prefix + TAB).AppendFormat("\"namespaceNumber_\" : \"%d\",\n", mc->namespaceNumber_); - sb.Append(prefix + TAB).AppendFormat("\"sequenceableNumber_\" : \"%d\",\n", mc->sequenceableNumber_); - sb.Append(prefix + TAB).AppendFormat("\"interfaceNumber_\" : \"%d\",\n", mc->interfaceNumber_); - sb.Append(prefix + TAB).AppendFormat("\"typeNumber_\" : \"%d\",\n", mc->typeNumber_); - - if (mc->namespaceNumber_ == 0) { - sb.Append(prefix + TAB).Append("\"namespaces_\" : [],\n"); - } else { - sb.Append(prefix + TAB).Append("\"namespaces_\" : [\n"); - for (int i = 0; i < mc->namespaceNumber_; i++) { - DumpMetaNamespace(sb, mc->namespaces_[i], prefix + TAB + TAB); - if (i != mc->namespaceNumber_ - 1) { - sb.Append(",\n"); - } - } - sb.Append("\n" + prefix + TAB).Append("],\n"); - } - - if (mc->sequenceableNumber_ == 0) { - sb.Append(prefix + TAB).Append("\"sequenceables_\" : [],\n"); - } else { - sb.Append(prefix + TAB).Append("\"sequenceables_\" : [\n"); - for (int i = 0; i < mc->sequenceableNumber_; i++) { - DumpMetaSequenceable(sb, mc->sequenceables_[i], prefix + TAB + TAB); - if (i != mc->sequenceableNumber_ - 1) { - sb.Append(",\n"); - } - } - sb.Append("\n" + prefix + TAB).Append("],\n"); - } - - if (mc->interfaceNumber_ == 0) { - sb.Append(prefix + TAB).Append("\"interfaces_\" : [],\n"); - } else { - sb.Append(prefix + TAB).Append("\"interfaces_\" : [\n"); - for (int i = 0; i < mc->interfaceNumber_; i++) { - DumpMetaInterface(sb, mc->interfaces_[i], prefix + TAB + TAB); - if (i != mc->interfaceNumber_ - 1) { - sb.Append(",\n"); - } - } - sb.Append("\n" + prefix + TAB).Append("],\n"); - } - - sb.Append(prefix + TAB).AppendFormat("\"stringPoolSize_\" : \"%d\"\n", mc->stringPoolSize_); - - sb.Append(prefix).Append("}\n"); - - return sb.ToString(); -} - -void MetadataDumper::DumpMetaNamespace( - /* [in] */ StringBuilder& sb, - /* [in] */ MetaNamespace* mn, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).Append("{\n"); - sb.Append(prefix + TAB).AppendFormat("\"name_\" : \"%s\",\n", mn->name_); - sb.Append(prefix + TAB).AppendFormat("\"sequenceableNumber_\" : \"%d\",\n", mn->sequenceableNumber_); - sb.Append(prefix + TAB).AppendFormat("\"interfaceNumber_\" : \"%d\",\n", mn->interfaceNumber_); - sb.Append(prefix + TAB).AppendFormat("\"namespaceNumber_\" : \"%d\",\n", mn->namespaceNumber_); - - if (mn->sequenceableNumber_ == 0) { - sb.Append(prefix + TAB).Append("\"sequenceableIndexes_\" : [],\n"); - } else { - sb.Append(prefix + TAB).Append("\"sequenceableIndexes_\" : [\n"); - for (int i = 0; i < mn->sequenceableNumber_; i++) { - MetaSequenceable* mp = metaComponent_->sequenceables_[mn->sequenceableIndexes_[i]]; - sb.Append(prefix + TAB + TAB).AppendFormat("{ \"name\" : \"%s\" }", mp->name_); - if (i != mn->sequenceableNumber_ - 1) { - sb.Append(",\n"); - } - } - sb.Append("\n" + prefix + TAB).Append("],\n"); - } - - if (mn->interfaceNumber_ == 0) { - sb.Append(prefix + TAB).Append("\"interfaceIndexes_\" : [],\n"); - } else { - sb.Append(prefix + TAB).Append("\"interfaceIndexes_\" : [\n"); - for (int i = 0; i < mn->interfaceNumber_; i++) { - MetaInterface* mi = metaComponent_->interfaces_[mn->interfaceIndexes_[i]]; - sb.Append(prefix + TAB + TAB).AppendFormat("{ \"name\" : \"%s\" }", mi->name_); - if (i != mn->interfaceNumber_ - 1) { - sb.Append(",\n"); - } - } - sb.Append("\n" + prefix + TAB).Append("],\n"); - } - - if (mn->namespaceNumber_ == 0) { - sb.Append(prefix + TAB).Append("\"namespaces_\" : []\n"); - } else { - sb.Append(prefix + TAB).Append("\"namespaces_\" : [\n"); - for (int i = 0; i < mn->namespaceNumber_; i++) { - MetaNamespace* innermn = mn->namespaces_[i]; - DumpMetaNamespace(sb, innermn, prefix + TAB + TAB); - if (i != mn->namespaceNumber_ - 1) { - sb.Append(",\n"); - } - } - sb.Append("\n" + prefix + TAB).Append("]\n"); - } - - sb.Append(prefix).Append("}"); -} - -void MetadataDumper::DumpMetaSequenceable( - /* [in] */ StringBuilder& sb, - /* [in] */ MetaSequenceable* mp, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).Append("{\n"); - sb.Append(prefix + TAB).AppendFormat("\"name_\" : \"%s\",\n", mp->name_); - sb.Append(prefix + TAB).AppendFormat("\"namespace_\" : \"%s\"\n", mp->namespace_); - sb.Append(prefix).Append("}"); -} - -void MetadataDumper::DumpMetaInterface( - /* [in] */ StringBuilder& sb, - /* [in] */ MetaInterface* mi, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).Append("{\n"); - sb.Append(prefix + TAB).AppendFormat("\"name_\" : \"%s\",\n", mi->name_); - sb.Append(prefix + TAB).AppendFormat("\"namespace_\" : \"%s\",\n", mi->namespace_); - sb.Append(prefix + TAB).AppendFormat("\"properties_\" : \"%s\",\n", - (mi->properties_ & INTERFACE_PROPERTY_ONEWAY) != 0 ? "oneway" : ""); - sb.Append(prefix + TAB).AppendFormat("\"methodNumber_\" : \"%d\",\n", mi->methodNumber_); - sb.Append(prefix + TAB).AppendFormat("\"external_\" : \"%d\",\n", mi->external_); - - if (mi->methodNumber_ == 0) { - sb.Append(prefix + TAB).Append("\"methods_\" : []\n"); - } else { - sb.Append(prefix + TAB).Append("\"methods_\" : [\n"); - for (int i = 0; i < mi->methodNumber_; i++) { - DumpMetaMethod(sb, mi->methods_[i], prefix + TAB + TAB); - if (i != mi->methodNumber_ - 1) { - sb.Append(",\n"); - } - } - sb.Append("\n" + prefix + TAB).Append("]\n"); - } - - sb.Append(prefix).Append("}"); -} - -void MetadataDumper::DumpMetaMethod( - /* [in] */ StringBuilder& sb, - /* [in] */ MetaMethod* mm, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).Append("{\n"); - sb.Append(prefix + TAB).AppendFormat("\"name_\" : \"%s\",\n", mm->name_); - sb.Append(prefix + TAB).AppendFormat("\"signature_\" : \"%s\",\n", mm->signature_); - sb.Append(prefix + TAB).AppendFormat("\"properties_\" : \"%s\",\n", - (mm->properties_ & METHOD_PROPERTY_ONEWAY) != 0 ? "oneway" : ""); - MetaType* type = metaComponent_->types_[mm->returnTypeIndex_]; - sb.Append(prefix + TAB).AppendFormat("\"returnType_\" : \"%s\",\n", DumpMetaType(type).string()); - sb.Append(prefix + TAB).AppendFormat("\"parameterNumber_\" : \"%d\",\n", mm->parameterNumber_); - - if (mm->parameterNumber_ == 0) { - sb.Append(prefix + TAB).Append("\"parameters_\" : []\n"); - } else { - sb.Append(prefix + TAB).Append("\"parameters_\" : [\n"); - for (int i = 0; i < mm->parameterNumber_; i++) { - DumpMetaParameter(sb, mm->parameters_[i], prefix + TAB + TAB); - if (i != mm->parameterNumber_ - 1) { - sb.Append(",\n"); - } - } - sb.Append("\n" + prefix + TAB).Append("]\n"); - } - - sb.Append(prefix).Append("}"); -} - -void MetadataDumper::DumpMetaParameter( - /* [in] */ StringBuilder& sb, - /* [in] */ MetaParameter* mp, - /* [in] */ const String& prefix) -{ - sb.Append(prefix).Append("{\n"); - sb.Append(prefix + TAB).AppendFormat("\"name_\" : \"%s\",\n", mp->name_); - sb.Append(prefix + TAB).Append("\"attributes_\" : \""); - bool addComma = false; - if ((mp->attributes_ & ATTR_IN) == ATTR_IN) { - sb.Append("in"); - addComma = true; - } - if ((mp->attributes_ & ATTR_OUT) == ATTR_OUT) { - sb.Append(addComma ? ", out" : "out"); - } - sb.Append("\",\n"); - MetaType* type = metaComponent_->types_[mp->typeIndex_]; - sb.Append(prefix + TAB).AppendFormat("\"type_\" : \"%s\"\n", DumpMetaType(type).string()); - - sb.Append(prefix).Append("}"); -} - -String MetadataDumper::DumpMetaType( - /* [in] */ MetaType* mt) -{ - switch (mt->kind_) { - case TypeKind::Char: - return "char"; - case TypeKind::Boolean: - return "boolean"; - case TypeKind::Byte: - return "byte"; - case TypeKind::Short: - return "short"; - case TypeKind::Integer: - return "int"; - case TypeKind::Long: - return "long"; - case TypeKind::Float: - return "float"; - case TypeKind::Double: - return "double"; - case TypeKind::String: - return "String"; - case TypeKind::Void: - return "void"; - case TypeKind::Sequenceable: { - MetaSequenceable* mp = metaComponent_->sequenceables_[mt->index_]; - return mp->name_; - } - case TypeKind::Interface: { - MetaInterface* mi = metaComponent_->interfaces_[mt->index_]; - return mi->name_; - } - case TypeKind::List: { - MetaType* elementMt = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - return "List<" + DumpMetaType(elementMt) + ">"; - } - case TypeKind::Map: { - MetaType* keyMt = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - MetaType* valueMt = metaComponent_->types_[mt->nestedTypeIndexes_[1]]; - return "Map<" + DumpMetaType(keyMt) + ", " + DumpMetaType(valueMt) + ">"; - } - case TypeKind::Array: { - MetaType* elementMt = metaComponent_->types_[mt->nestedTypeIndexes_[0]]; - return DumpMetaType(elementMt) + "[]"; - } - case TypeKind::Unknown: - default: - return "unknown"; - } -} - -} -} diff --git a/zidl/metadata/metadata_dumper.h b/zidl/metadata/metadata_dumper.h deleted file mode 100644 index ec30a2b6537..00000000000 --- a/zidl/metadata/metadata_dumper.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_METADATADUMPER_H -#define OHOS_ZIDL_METADATADUMPER_H - -#include "metadata/metadata.h" -#include "util/string.h" -#include "util/string_builder.h" - -namespace OHOS { -namespace Zidl { - -class MetadataDumper { -public: - explicit MetadataDumper( - /* [in] */ MetaComponent* mc) - : metaComponent_(mc) - {} - - ~MetadataDumper() = default; - - void Dump( - /* [in] */ const String& prefix); - -private: - String DumpMetaComponent( - /* [in] */ MetaComponent* mc, - /* [in] */ const String& prefix); - - void DumpMetaNamespace( - /* [in] */ StringBuilder& sb, - /* [in] */ MetaNamespace* mn, - /* [in] */ const String& prefix); - - void DumpMetaSequenceable( - /* [in] */ StringBuilder& sb, - /* [in] */ MetaSequenceable* mp, - /* [in] */ const String& prefix); - - void DumpMetaInterface( - /* [in] */ StringBuilder& sb, - /* [in] */ MetaInterface* mi, - /* [in] */ const String& prefix); - - void DumpMetaMethod( - /* [in] */ StringBuilder& sb, - /* [in] */ MetaMethod* mm, - /* [in] */ const String& prefix); - - void DumpMetaParameter( - /* [in] */ StringBuilder& sb, - /* [in] */ MetaParameter* mp, - /* [in] */ const String& prefix); - - String DumpMetaType( - /* [in] */ MetaType* mt); - - static const char* TAB; - MetaComponent* metaComponent_; -}; - -} -} - -#endif // OHOS_ZIDL_METADATADUMPER_H diff --git a/zidl/metadata/metadata_reader.cpp b/zidl/metadata/metadata_reader.cpp deleted file mode 100644 index fcd1250bae4..00000000000 --- a/zidl/metadata/metadata_reader.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "metadata/metadata_reader.h" -#include "metadata/metadata_serializer.h" -#include "util/file.h" -#include "util/logger.h" - -namespace OHOS { -namespace Zidl { - -const char* MetadataReader::TAG = "MetadataReader"; - -std::shared_ptr MetadataReader::ReadMetadataFromFile( - /* [in] */ const String& filePath) -{ - File file(filePath, File::READ); - if (!file.IsValid()) { - Logger::E(TAG, "Open \"%s\" file failed.", filePath.string()); - return nullptr; - } - - if (!file.Reset()) { - Logger::E(TAG, "Reset \"%s\" file failed.", filePath.string()); - return nullptr; - } - - MetaComponent header; - - if (!file.ReadData((void*)&header, sizeof(MetaComponent))) { - Logger::E(TAG, "Read \"%s\" file failed.", filePath.string()); - return nullptr; - } - - if (header.magic_ != METADATA_MAGIC_NUMBER || header.size_ < 0) { - Logger::E(TAG, "The metadata in \"%s\" file is bad.", filePath.string()); - return nullptr; - } - - if (!file.Reset()) { - Logger::E(TAG, "Reset \"%s\" file failed.", filePath.string()); - return nullptr; - } - - void* data = malloc(header.size_); - if (data == nullptr) { - Logger::E(TAG, "Malloc metadata failed."); - return nullptr; - } - - if (!file.ReadData(data, header.size_)) { - Logger::E(TAG, "Read \"%s\" file failed.", filePath.string()); - free(data); - return nullptr; - } - - std::shared_ptr metadata( - (MetaComponent*)data, - [](MetaComponent* p){ free(p); }); - - MetadataSerializer serializer((uintptr_t)data); - serializer.Deserialize(); - - return metadata; -} - -} -} diff --git a/zidl/metadata/metadata_reader.h b/zidl/metadata/metadata_reader.h deleted file mode 100644 index 1d7054b67d4..00000000000 --- a/zidl/metadata/metadata_reader.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_METADATAREADER_H -#define OHOS_ZIDL_METADATAREADER_H - -#include -#include "metadata/metadata.h" -#include "util/string.h" - -namespace OHOS { -namespace Zidl { - -class MetadataReader { -public: - static std::shared_ptr ReadMetadataFromFile( - /* [in] */ const String& filePath); - -private: - static const char* TAG; -}; - -} -} - -#endif // OHOS_ZIDL_METADATAREADER_H diff --git a/zidl/metadata/metadata_serializer.cpp b/zidl/metadata/metadata_serializer.cpp deleted file mode 100644 index 8ee9031e5b6..00000000000 --- a/zidl/metadata/metadata_serializer.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "metadata/metadata_serializer.h" - -namespace OHOS { -namespace Zidl { - -void MetadataSerializer::Serialize() -{ - SerializeMetaComponent(metaComponent_); -} - -void MetadataSerializer::SerializeMetaComponent( - /* [in] */ MetaComponent* mc) -{ - mc->name_ = reinterpret_cast(SerializeAdjust(mc->name_)); - - for (int i = 0; i < mc->namespaceNumber_; i++) { - MetaNamespace* mn = mc->namespaces_[i]; - SerializeMetaNamespace(mn); - mc->namespaces_[i] = reinterpret_cast(SerializeAdjust(mn)); - } - mc->namespaces_ = reinterpret_cast(SerializeAdjust(mc->namespaces_)); - - for (int i = 0; i < mc->sequenceableNumber_; i++) { - MetaSequenceable* mp = mc->sequenceables_[i]; - SerializeMetaSequenceable(mp); - mc->sequenceables_[i] = reinterpret_cast(SerializeAdjust(mp)); - } - mc->sequenceables_ = reinterpret_cast(SerializeAdjust(mc->sequenceables_)); - - for (int i = 0; i < mc->interfaceNumber_; i++) { - MetaInterface* mi = mc->interfaces_[i]; - SerializeMetaInterface(mi); - mc->interfaces_[i] = reinterpret_cast(SerializeAdjust(mi)); - } - mc->interfaces_ = reinterpret_cast(SerializeAdjust(mc->interfaces_)); - - for (int i = 0; i < mc->typeNumber_; i++) { - MetaType* mt = mc->types_[i]; - SerializeMetaType(mt); - mc->types_[i] = reinterpret_cast(SerializeAdjust(mt)); - } - mc->types_ = reinterpret_cast(SerializeAdjust(mc->types_)); - - mc->stringPool_ = reinterpret_cast(SerializeAdjust(mc->stringPool_)); -} - -void MetadataSerializer::SerializeMetaNamespace( - /* [in] */ MetaNamespace* mn) -{ - mn->name_ = reinterpret_cast(SerializeAdjust(mn->name_)); - mn->sequenceableIndexes_ = reinterpret_cast(SerializeAdjust(mn->sequenceableIndexes_)); - mn->interfaceIndexes_ = reinterpret_cast(SerializeAdjust(mn->interfaceIndexes_)); - - for (int i = 0; i < mn->namespaceNumber_; i++) { - MetaNamespace* innermn = mn->namespaces_[i]; - SerializeMetaNamespace(innermn); - mn->namespaces_[i] = reinterpret_cast(SerializeAdjust(innermn)); - } - mn->namespaces_ = reinterpret_cast(SerializeAdjust(mn->namespaces_)); -} - -void MetadataSerializer::SerializeMetaSequenceable( - /* [in] */ MetaSequenceable* mp) -{ - mp->name_ = reinterpret_cast(SerializeAdjust(mp->name_)); - mp->namespace_ = reinterpret_cast(SerializeAdjust(mp->namespace_)); -} - -void MetadataSerializer::SerializeMetaInterface( - /* [in] */ MetaInterface* mi) -{ - mi->license_ = reinterpret_cast(SerializeAdjust(mi->license_)); - mi->name_ = reinterpret_cast(SerializeAdjust(mi->name_)); - mi->namespace_ = reinterpret_cast(SerializeAdjust(mi->namespace_)); - - for (int i = 0; i < mi->methodNumber_; i++) { - MetaMethod* mm = mi->methods_[i]; - SerializeMetaMethod(mm); - mi->methods_[i] = reinterpret_cast(SerializeAdjust(mm)); - } - mi->methods_ = reinterpret_cast(SerializeAdjust(mi->methods_)); -} - -void MetadataSerializer::SerializeMetaMethod( - /* [in] */ MetaMethod* mm) -{ - mm->name_ = reinterpret_cast(SerializeAdjust(mm->name_)); - mm->signature_ = reinterpret_cast(SerializeAdjust(mm->signature_)); - - for (int i = 0; i < mm->parameterNumber_; i++) { - MetaParameter* mp = mm->parameters_[i]; - SerializeMetaParameter(mp); - mm->parameters_[i] = reinterpret_cast(SerializeAdjust(mp)); - } - mm->parameters_ = reinterpret_cast(SerializeAdjust(mm->parameters_)); -} - -void MetadataSerializer::SerializeMetaParameter( - /* [in] */ MetaParameter* mp) -{ - mp->name_ = reinterpret_cast(SerializeAdjust(mp->name_)); -} - -void MetadataSerializer::SerializeMetaType( - /* [in] */ MetaType* mt) -{ - mt->nestedTypeIndexes_ = reinterpret_cast(SerializeAdjust(mt->nestedTypeIndexes_)); -} - -ptrdiff_t MetadataSerializer::SerializeAdjust( - /* [in] */ const void* addr) -{ - return reinterpret_cast(addr) - baseAddr_; -} - -void MetadataSerializer::Deserialize() -{ - DeserializeMetaComponent(metaComponent_); -} - -void MetadataSerializer::DeserializeMetaComponent( - /* [in] */ MetaComponent* mc) -{ - mc->name_ = reinterpret_cast(DeserializeAdjust(mc->name_)); - - mc->namespaces_ = reinterpret_cast(DeserializeAdjust(mc->namespaces_)); - for (int i = 0; i < mc->namespaceNumber_; i++) { - mc->namespaces_[i] = reinterpret_cast(DeserializeAdjust(mc->namespaces_[i])); - MetaNamespace* mn = mc->namespaces_[i]; - DeserializeMetaNamespace(mn); - } - - mc->sequenceables_ = reinterpret_cast(DeserializeAdjust(mc->sequenceables_)); - for (int i = 0; i < mc->sequenceableNumber_; i++) { - mc->sequenceables_[i] = reinterpret_cast(DeserializeAdjust(mc->sequenceables_[i])); - MetaSequenceable* mp = mc->sequenceables_[i]; - DeserializeMetaSequenceable(mp); - } - - mc->interfaces_ = reinterpret_cast(DeserializeAdjust(mc->interfaces_)); - for (int i = 0; i < mc->interfaceNumber_; i++) { - mc->interfaces_[i] = reinterpret_cast(DeserializeAdjust(mc->interfaces_[i])); - MetaInterface* mi = mc->interfaces_[i]; - DeserializeMetaInterface(mi); - } - - mc->types_ = reinterpret_cast(DeserializeAdjust(mc->types_)); - for (int i = 0; i < mc->typeNumber_; i++) { - mc->types_[i] = reinterpret_cast(DeserializeAdjust(mc->types_[i])); - MetaType* mt = mc->types_[i]; - DeserializeMetaType(mt); - } - - mc->stringPool_ = reinterpret_cast(DeserializeAdjust(mc->stringPool_)); -} - -void MetadataSerializer::DeserializeMetaNamespace( - /* [in] */ MetaNamespace* mn) -{ - mn->name_ = reinterpret_cast(DeserializeAdjust(mn->name_)); - mn->sequenceableIndexes_ = reinterpret_cast(DeserializeAdjust(mn->sequenceableIndexes_)); - mn->interfaceIndexes_ = reinterpret_cast(DeserializeAdjust(mn->interfaceIndexes_)); - - mn->namespaces_ = reinterpret_cast(DeserializeAdjust(mn->namespaces_)); - for (int i = 0; i < mn->namespaceNumber_; i++) { - mn->namespaces_[i] = reinterpret_cast(DeserializeAdjust(mn->namespaces_[i])); - MetaNamespace* innermn = mn->namespaces_[i]; - DeserializeMetaNamespace(innermn); - } -} - -void MetadataSerializer::DeserializeMetaSequenceable( - /* [in] */ MetaSequenceable* mp) -{ - mp->name_ = reinterpret_cast(DeserializeAdjust(mp->name_)); - mp->namespace_ = reinterpret_cast(DeserializeAdjust(mp->namespace_)); -} - -void MetadataSerializer::DeserializeMetaInterface( - /* [in] */ MetaInterface* mi) -{ - mi->license_ = reinterpret_cast(DeserializeAdjust(mi->license_)); - mi->name_ = reinterpret_cast(DeserializeAdjust(mi->name_)); - mi->namespace_ = reinterpret_cast(DeserializeAdjust(mi->namespace_)); - - mi->methods_ = reinterpret_cast(DeserializeAdjust(mi->methods_)); - for (int i = 0; i < mi->methodNumber_; i++) { - mi->methods_[i] = reinterpret_cast(DeserializeAdjust(mi->methods_[i])); - MetaMethod* mm = mi->methods_[i]; - DeserializeMetaMethod(mm); - } -} - -void MetadataSerializer::DeserializeMetaMethod( - /* [in] */ MetaMethod* mm) -{ - mm->name_ = reinterpret_cast(DeserializeAdjust(mm->name_)); - mm->signature_ = reinterpret_cast(DeserializeAdjust(mm->signature_)); - - mm->parameters_ = reinterpret_cast(DeserializeAdjust(mm->parameters_)); - for (int i = 0; i < mm->parameterNumber_; i++) { - mm->parameters_[i] = reinterpret_cast(DeserializeAdjust(mm->parameters_[i])); - MetaParameter* mp = mm->parameters_[i]; - DeserializeMetaParameter(mp); - } -} - -void MetadataSerializer::DeserializeMetaParameter( - /* [in] */ MetaParameter* mp) -{ - mp->name_ = reinterpret_cast(DeserializeAdjust(mp->name_)); -} - -void MetadataSerializer::DeserializeMetaType( - /* [in] */ MetaType* mt) -{ - mt->nestedTypeIndexes_ = reinterpret_cast(DeserializeAdjust(mt->nestedTypeIndexes_)); -} - -uintptr_t MetadataSerializer::DeserializeAdjust( - /* [in] */ const void* addr) -{ - return reinterpret_cast(addr) + baseAddr_; -} - -} -} diff --git a/zidl/metadata/metadata_serializer.h b/zidl/metadata/metadata_serializer.h deleted file mode 100644 index 7a5e3a51899..00000000000 --- a/zidl/metadata/metadata_serializer.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_METADATASERIALIZER_H -#define OHOS_ZIDL_METADATASERIALIZER_H - -#include -#include -#include "metadata/metadata.h" - -namespace OHOS { -namespace Zidl { - -class MetadataSerializer { -public: - explicit MetadataSerializer( - /* [in] */ MetaComponent* mc) - : metaComponent_(mc), - baseAddr_(reinterpret_cast(mc)) - {} - - explicit MetadataSerializer( - /* [in] */ uintptr_t addr) - : metaComponent_(reinterpret_cast(addr)), - baseAddr_(addr) - {} - - ~MetadataSerializer() = default; - - void Serialize(); - - void Deserialize(); - - inline uintptr_t GetData() const - { - return baseAddr_; - } - - inline int GetDataSize() const - { - return metaComponent_->size_; - } - -private: - void SerializeMetaComponent( - /* [in] */ MetaComponent* mc); - - void SerializeMetaNamespace( - /* [in] */ MetaNamespace* mn); - - void SerializeMetaSequenceable( - /* [in] */ MetaSequenceable* mp); - - void SerializeMetaInterface( - /* [in] */ MetaInterface* mi); - - void SerializeMetaMethod( - /* [in] */ MetaMethod* mm); - - void SerializeMetaParameter( - /* [in] */ MetaParameter* mp); - - void SerializeMetaType( - /* [in] */ MetaType* mt); - - ptrdiff_t SerializeAdjust( - /* [in] */ const void* addr); - - void DeserializeMetaComponent( - /* [in] */ MetaComponent* mc); - - void DeserializeMetaNamespace( - /* [in] */ MetaNamespace* mn); - - void DeserializeMetaSequenceable( - /* [in] */ MetaSequenceable* mp); - - void DeserializeMetaInterface( - /* [in] */ MetaInterface* mi); - - void DeserializeMetaMethod( - /* [in] */ MetaMethod* mm); - - void DeserializeMetaParameter( - /* [in] */ MetaParameter* mp); - - void DeserializeMetaType( - /* [in] */ MetaType* mt); - - uintptr_t DeserializeAdjust( - /* [in] */ const void* addr); - - MetaComponent* metaComponent_; - uintptr_t baseAddr_; -}; - -} -} - -#endif // OHOS_ZIDL_METADATASERIALIZER_H diff --git a/zidl/parser/CMakeLists.txt b/zidl/parser/CMakeLists.txt deleted file mode 100644 index 40b2194801e..00000000000 --- a/zidl/parser/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -include_directories( - ${ZIDL_DIR}) - -set(SOURCES - lexer.cpp - parser.cpp) - -add_library(parser STATIC - ${SOURCES}) \ No newline at end of file diff --git a/zidl/parser/lexer.cpp b/zidl/parser/lexer.cpp deleted file mode 100644 index c8680d4a6dc..00000000000 --- a/zidl/parser/lexer.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "parser/lexer.h" - -#include -#include "util/string_builder.h" - -namespace OHOS { -namespace Zidl { - -static struct Keywords { - String key_; - Token token_; -} g_keywords[] = { - { String("boolean"), Token::BOOLEAN }, - { String("byte"), Token::BYTE }, - { String("char"), Token::CHAR }, - { String("double"), Token::DOUBLE }, - { String("float"), Token::FLOAT }, - { String("in"), Token::IN }, - { String("inout"), Token::INOUT }, - { String("int"), Token::INTEGER }, - { String("interface"), Token::INTERFACE }, - { String("List"), Token::LIST }, - { String("long"), Token::LONG }, - { String("Map"), Token::MAP }, - { String("oneway"), Token::ONEWAY }, - { String("out"), Token::OUT }, - { String("sequenceable"), Token::SEQUENCEABLE }, - { String("short"), Token::SHORT }, - { String("String"), Token::STRING }, -}; - -Lexer::Lexer() -{ - InitializeKeywords(); -} - -Lexer::~Lexer() -{ - if (currentFile_ != nullptr) { - currentFile_->Close(); - } -} - -void Lexer::InitializeKeywords() -{ - for (size_t i = 0; i < sizeof(g_keywords) / sizeof(struct Keywords); i++) { - keywords_[g_keywords[i].key_] = g_keywords[i].token_; - } -} - -bool Lexer::OpenSourceFile( - /* [in] */ const String& filePath) -{ - currentFile_ = std::make_shared(filePath, File::READ); - if (!currentFile_->IsValid()) { - return false; - } - - return true; -} - -Token Lexer::GetToken( - /* [in] */ bool skipComment) -{ - if (!havePeek_) { - currentToken_ = ReadToken(skipComment); - } - havePeek_ = false; - return currentToken_; -} - -Token Lexer::PeekToken( - /* [in] */ bool skipComment) -{ - if (!havePeek_) { - currentToken_ = ReadToken(skipComment); - havePeek_ = true; - } - return currentToken_; -} - -Token Lexer::ReadToken( - /* [in] */ bool skipComment) -{ - while (!currentFile_->IsEof()) { - char c = currentFile_->GetChar(); - tokenLineNo_ = currentFile_->GetCharLineNumber(); - tokenColumnNo_ = currentFile_->GetCharColumnNumber(); - if (IsSpace(c)) { - continue; - } else if (IsAlphabet(c) || c == '_') { - return ReadIdentifier(c); - } - switch (c) { - case '<': - currentToken_ = Token::ANGLE_BRACKETS_LEFT; - return currentToken_; - case '>': - currentToken_ = Token::ANGLE_BRACKETS_RIGHT; - return currentToken_; - case '{': - currentToken_ = Token::BRACES_LEFT; - return currentToken_; - case '}': - currentToken_ = Token::BRACES_RIGHT; - return currentToken_; - case '[': - currentToken_ = Token::BRACKETS_LEFT; - return currentToken_; - case ']': - currentToken_ = Token::BRACKETS_RIGHT; - return currentToken_; - case ',': - currentToken_ = Token::COMMA; - return currentToken_; - case '/': - if (currentFile_->PeekChar() == '/') { - ReadLineComment(c); - if (!skipComment) { - return currentToken_; - } - continue; - } else if (currentFile_->PeekChar() == '*') { - ReadBlockComment(c); - if (!skipComment) { - return currentToken_; - } - continue; - } - currentToken_ = Token::UNKNOWN; - return currentToken_; - case '(': - currentToken_ = Token::PARENTHESES_LEFT; - return currentToken_; - case ')': - currentToken_ = Token::PARENTHESES_RIGHT; - return currentToken_; - case '.': - currentToken_ = Token::DOT; - return currentToken_; - case ';': - currentToken_ = Token::SEMICOLON; - return currentToken_; - default: - currentToken_ = Token::UNKNOWN; - return currentToken_; - } - } - currentToken_ = Token::END_OF_FILE; - return currentToken_; -} - -Token Lexer::ReadIdentifier( - /* [in] */ char c) -{ - StringBuilder sb; - - sb.Append(c); - while (!currentFile_->IsEof()) { - c = currentFile_->PeekChar(); - if (IsAlphabet(c) || c == '_' || IsDecimalDigital(c) || c == '.') { - c = currentFile_->GetChar(); - sb.Append(c); - continue; - } - if (IsSpace(c)) { - currentFile_->GetChar(); - } - break; - } - String key = sb.ToString(); - auto it = keywords_.find(key); - if (it == keywords_.end()) { - identifier_ = key; - currentToken_ = Token::IDENTIFIER; - } else { - currentToken_ = it->second; - } - return currentToken_; -} - -Token Lexer::ReadLineComment( - /* [in] */ char c) -{ - StringBuilder sb; - - sb.Append(c); - while (!currentFile_->IsEof()) { - c = currentFile_->GetChar(); - if (c == '\n') { - break; - } - sb.Append(c); - } - comment_ = sb.ToString(); - currentToken_ = Token::COMMENT_LINE; - return currentToken_; -} - -Token Lexer::ReadBlockComment( - /* [in] */ char c) -{ - StringBuilder sb; - - sb.Append(c); - while (!currentFile_->IsEof()) { - c = currentFile_->GetChar(); - sb.Append(c); - if (c == '*' && currentFile_->PeekChar() == '/') { - c = currentFile_->GetChar(); - sb.Append(c); - break; - } - } - comment_ = sb.ToString(); - currentToken_ = Token::COMMENT_BLOCK; - return currentToken_; -} - -void Lexer::SkipCurrentLine() -{ - while (!currentFile_->IsEof()) { - char c = currentFile_->GetChar(); - if (c == '\n') { - currentFile_->GetChar(); - return; - } - } -} - -bool Lexer::SkipCurrentLine( - /* [in] */ char untilChar) -{ - while (!currentFile_->IsEof()) { - int c = currentFile_->GetChar(); - if (c == untilChar) { - return true; - } - if (c == '\n') { - currentFile_->GetChar(); - return false; - } - } - return true; -} - -int Lexer::TokenToChar( - /* [in] */ Token token) -{ - switch (token) { - case Token::ANGLE_BRACKETS_LEFT: - return '<'; - case Token::ANGLE_BRACKETS_RIGHT: - return '>'; - case Token::BRACES_LEFT: - return '{'; - case Token::BRACES_RIGHT: - return '}'; - case Token::BRACKETS_LEFT: - return '['; - case Token::BRACKETS_RIGHT: - return ']'; - case Token::COMMA: - return ','; - case Token::DOT: - return '.'; - case Token::PARENTHESES_LEFT: - return '('; - case Token::PARENTHESES_RIGHT: - return ')'; - case Token::SEMICOLON: - return ';'; - case Token::BOOLEAN: - case Token::BYTE: - case Token::CHAR: - case Token::COMMENT_BLOCK: - case Token::COMMENT_LINE: - case Token::DOUBLE: - case Token::END_OF_FILE: - case Token::FLOAT: - case Token::IDENTIFIER: - case Token::IN: - case Token::INOUT: - case Token::INTEGER: - case Token::LIST: - case Token::LONG: - case Token::MAP: - case Token::ONEWAY: - case Token::OUT: - case Token::SEQUENCEABLE: - case Token::SHORT: - case Token::STRING: - default: - return -1; - } -} - -String Lexer::DumpToken() const -{ - switch (currentToken_) { - case Token::ANGLE_BRACKETS_LEFT: - return "<"; - case Token::ANGLE_BRACKETS_RIGHT: - return ">"; - case Token::BOOLEAN: - return "boolean"; - case Token::BRACES_LEFT: - return "{"; - case Token::BRACES_RIGHT: - return "}"; - case Token::BRACKETS_LEFT: - return "["; - case Token::BRACKETS_RIGHT: - return "]"; - case Token::BYTE: - return "byte"; - case Token::CHAR: - return "char"; - case Token::COMMA: - return ","; - case Token::COMMENT_BLOCK: - case Token::COMMENT_LINE: - return comment_; - case Token::DOT: - return "."; - case Token::DOUBLE: - return "double"; - case Token::END_OF_FILE: - return "eof"; - case Token::FLOAT: - return "float"; - case Token::IDENTIFIER: - return identifier_; - case Token::IN: - return "in"; - case Token::INOUT: - return "inout"; - case Token::INTEGER: - return "int"; - case Token::LIST: - return "List"; - case Token::LONG: - return "long"; - case Token::MAP: - return "Map"; - case Token::ONEWAY: - return "oneway"; - case Token::OUT: - return "out"; - case Token::SEQUENCEABLE: - return "sequenceable"; - case Token::PARENTHESES_LEFT: - return "("; - case Token::PARENTHESES_RIGHT: - return ")"; - case Token::SEMICOLON: - return ";"; - case Token::SHORT: - return "short"; - case Token::STRING: - return "String"; - default: - return "unknown token"; - } -} - -} -} diff --git a/zidl/parser/lexer.h b/zidl/parser/lexer.h deleted file mode 100644 index d43c7050ceb..00000000000 --- a/zidl/parser/lexer.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_LEXER_H -#define OHOS_ZIDL_LEXER_H - -#include -#include -#include - -#include "parser/token.h" -#include "util/file.h" -#include "util/string.h" - -namespace OHOS { -namespace Zidl { - -class Lexer { -public: - Lexer(); - - ~Lexer(); - - bool OpenSourceFile( - /* [in] */ const String& filePath); - - Token GetToken( - /* [in] */ bool skipComment = true); - - Token PeekToken( - /* [in] */ bool skipComment = true); - - inline String GetIdentifier() const - { - return identifier_; - } - - inline String GetComment() const - { - return comment_; - } - - void SkipCurrentLine(); - - bool SkipCurrentLine( - /* [in] */ char untilChar); - - inline std::shared_ptr GetSourceFile() const - { - return currentFile_; - } - - String DumpToken() const; - - inline int GetTokenLineNumber() const - { - return tokenLineNo_; - } - - inline int GetTokenColumnNumber() const - { - return tokenColumnNo_; - } - - static int TokenToChar( - /* [in] */ Token token); - -private: - void InitializeKeywords(); - - Token ReadToken( - /* [in] */ bool skipComment); - - Token ReadIdentifier( - /* [in] */ char c); - - Token ReadLineComment( - /* [in] */ char c); - - Token ReadBlockComment( - /* [in] */ char c); - - inline static bool IsAlphabet( - /* [in] */ char c) - { - return isalpha(c); - } - - inline static bool IsDecimalDigital( - /* [in] */ char c) - { - return isdigit(c); - } - - inline static bool IsSpace( - /* [in] */ char c) - { - return isspace(c); - } - - static const char* TAG; - std::unordered_map keywords_; - Token currentToken_ = Token::UNKNOWN; - int tokenLineNo_ = 0; - int tokenColumnNo_ = 0; - String identifier_; - String comment_; - bool havePeek_ = false; - std::shared_ptr currentFile_; -}; - -} -} - -#endif // OHOS_ZIDL_LEXER_H diff --git a/zidl/parser/parser.cpp b/zidl/parser/parser.cpp deleted file mode 100644 index 43bc428c659..00000000000 --- a/zidl/parser/parser.cpp +++ /dev/null @@ -1,688 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "parser/parser.h" -#include "ast/ast_array_type.h" -#include "ast/ast_list_type.h" -#include "ast/ast_map_type.h" -#include "ast/ast_parameter.h" -#include "ast/ast_sequenceable_type.h" -#include "util/logger.h" -#include "util/string_builder.h" -#include - -namespace OHOS { -namespace Zidl { - -const char* Parser::TAG = "Parser"; - -Parser::Parser( - /* [in] */ const Options& options) - : options_(options) -{} - -bool Parser::Parse( - /* [in] */ const String& sourceFile) -{ - bool ret = lexer_.OpenSourceFile(sourceFile); - if (!ret) { - Logger::E(TAG, "Fail to open file \"%s\".", sourceFile.string()); - return false; - } - - ret = ParseFile(); - ret = CheckIntegrity() && ret; - - if (!ret) { - ShowError(); - return false; - } - - if (options_.DoDumpAST()) { - String astStr = module_->Dump(""); - printf("%s\n", astStr.string()); - } - - return ret; -} - -bool Parser::ParseFile() -{ - bool ret = true; - - module_ = new ASTModule(); - module_->SetZidlFile(lexer_.GetSourceFile()->GetPath()); - - ParseLicense(); - - Token token; - while ((token = lexer_.PeekToken()) != Token::END_OF_FILE) { - switch (token) { - case Token::BRACKETS_LEFT: - case Token::INTERFACE: - ret = ParseInterface() && ret; - continue; - case Token::SEQUENCEABLE: - ret = ParseSequenceable() && ret; - continue; - case Token::COMMENT_LINE: - lexer_.GetToken(); - continue; - default: - LogError(token, String::Format("%s is not expected.", lexer_.DumpToken().string())); - lexer_.GetToken(); - ret = false; - continue; - } - } - lexer_.GetToken(); - - return ret; -} - -bool Parser::ParseLicense() -{ - Token token = lexer_.PeekToken(false); - if (token != Token::COMMENT_BLOCK) { - return false; - } - - lexer_.GetToken(false); - - module_->SetLicense(lexer_.GetComment()); - - return true; -} - -bool Parser::ParseInterface() -{ - bool ret = true; - bool hasProperties = false; - bool oneway = false; - Token token = lexer_.GetToken(); - if (token == Token::BRACKETS_LEFT) { - token = lexer_.PeekToken(); - if (token != Token::ONEWAY) { - LogError(Token::IDENTIFIER, String::Format("\"%s\" is an illegal interface property.", lexer_.DumpToken().string())); - - if (token != Token::BRACKETS_RIGHT) { - lexer_.SkipCurrentLine(Lexer::TokenToChar(Token::BRACKETS_RIGHT)); - } - ret = false; - } - lexer_.GetToken(); - - oneway = true; - hasProperties = true; - - token = lexer_.PeekToken(); - if (token != Token::BRACKETS_RIGHT) { - LogError(Token::IDENTIFIER, String("\"]\" is expected.")); - while (token != Token::BRACKETS_RIGHT && token != Token::INTERFACE && token != Token::END_OF_FILE) { - lexer_.GetToken(); - token = lexer_.PeekToken(); - } - ret = false; - } else { - lexer_.GetToken(); - } - - token = lexer_.PeekToken(); - if (token != Token::INTERFACE) { - LogError(Token::IDENTIFIER, String("\"interface\" is expected.")); - ret = false; - } else { - lexer_.GetToken(); - } - } - - String interfaceFullName; - - token = lexer_.PeekToken(); - - if (token != Token::IDENTIFIER) { - LogError(token, String::Format("%s is not expected.", lexer_.DumpToken().string())); - lexer_.SkipCurrentLine(); - return false; - } else { - lexer_.GetToken(); - interfaceFullName = lexer_.GetIdentifier(); - token = lexer_.PeekToken(); - } - if (token != Token::SEMICOLON && token != Token::BRACES_LEFT) { - LogError(token, String::Format("%s is not expected.", lexer_.DumpToken().string())); - lexer_.SkipCurrentLine(); - return false; - } - - if (interfaceFullName.IsEmpty()) { - LogError(Token::IDENTIFIER, String("Interface name is expected.")); - return false; - } else if (!IsValidTypeName(interfaceFullName)) { - LogError(Token::IDENTIFIER, String::Format("Interface name \"%s\" is illegal.", interfaceFullName.string())); - return false; - } else if (interfaceFullName.IndexOf(".") == -1) { - LogError(Token::IDENTIFIER, String::Format("Interface name \"%s\" does not have namespace.", - interfaceFullName.string())); - return false; - } - - AutoPtr interface = new ASTInterfaceType(); - parsingInterface_ = interface; - int index = interfaceFullName.LastIndexOf('.'); - if (index != -1) { - interface->SetName(interfaceFullName.Substring(index + 1)); - interface->SetNamespace(module_->ParseNamespace(interfaceFullName.Substring(0, index + 1))); - } else { - interface->SetName(interfaceFullName); - } - - // read ';' - lexer_.GetToken(); - if (token == Token::SEMICOLON) { - if (hasProperties) { - LogError(Token::IDENTIFIER, String("Interface forward declaration should not have properties.")); - return false; - } - interface->SetExternal(true); - module_->AddInterface(interface); - return true; - } else { - if (!interface->GetName().Equals(module_->GetName())) { - LogError(Token::IDENTIFIER, String::Format("Module name \"%s\" is not equal to interface name \"%s\".", - module_->GetName().string(), interface->GetName().string())); - return false; - } - - interface->SetLicense(module_->GetLicense()); - interface->SetOneway(oneway); - - while (token != Token::BRACES_RIGHT && token != Token::END_OF_FILE) { - ret = ParseMethod(interface) && ret; - token = lexer_.PeekToken(); - } - - if (token != Token::BRACES_RIGHT) { - ret = false; - } else { - lexer_.GetToken(); - module_->AddInterface(interface); - } - - return ret; - } -} - -bool Parser::ParseMethod( - /* [in] */ ASTInterfaceType* interface) -{ - bool ret = true; - bool oneway = false; - Token token; - - token = lexer_.PeekToken(); - if (token == Token::BRACKETS_LEFT) { - lexer_.GetToken(); - token = lexer_.PeekToken(); - if (token != Token::ONEWAY) { - LogError(Token::IDENTIFIER, String::Format("\"%s\" is an illegal method property.", - lexer_.DumpToken().string())); - - if (token != Token::BRACKETS_RIGHT) { - lexer_.SkipCurrentLine(Lexer::TokenToChar(Token::BRACKETS_RIGHT)); - } - ret = false; - } - lexer_.GetToken(); - - oneway = true; - - token = lexer_.PeekToken(); - if (token != Token::BRACKETS_RIGHT) { - LogError(Token::IDENTIFIER, String("\"]\" is expected.")); - ret = false; - } else { - lexer_.GetToken(); - } - } - AutoPtr type = ParseType(); - if (type == nullptr) { - token = lexer_.PeekToken(); - if (token != Token::BRACES_RIGHT) { - // jump over colon - lexer_.GetToken(); - while (token != Token::SEMICOLON && token != Token::END_OF_FILE) { - token = lexer_.PeekToken(); - if (token == Token::BRACES_RIGHT) { - break; - } - lexer_.GetToken(); - } - } - return false; - } - - token = lexer_.PeekToken(); - if (token != Token::IDENTIFIER) { - LogError(token, String("Method name is expected.")); - if (token != Token::BRACES_RIGHT) { - // jump over colon - lexer_.GetToken(); - while (token != Token::SEMICOLON && token != Token::END_OF_FILE) { - token = lexer_.PeekToken(); - if (token == Token::BRACES_RIGHT) { - break; - } - lexer_.GetToken(); - } - } - return false; - } - token = lexer_.GetToken(); - - AutoPtr method = new ASTMethod(); - method->SetName(lexer_.GetIdentifier()); - method->SetOneway(oneway); - method->SetReturnType(type); - - token = lexer_.PeekToken(); - if (token != Token::PARENTHESES_LEFT) { - LogError(token, String("\"(\" is expected.")); - if (token != Token::BRACES_RIGHT) { - // jump over colon - lexer_.GetToken(); - while (token != Token::SEMICOLON && token != Token::END_OF_FILE) { - token = lexer_.PeekToken(); - if (token == Token::BRACES_RIGHT) { - break; - } - lexer_.GetToken(); - } - } - return false; - } - token = lexer_.GetToken(); - - token = lexer_.PeekToken(); - while (token != Token::PARENTHESES_RIGHT && token != Token::END_OF_FILE) { - ret = ParseParameter(method) && ret; - token = lexer_.PeekToken(); - if (token == Token::COMMA) { - lexer_.GetToken(); - token = lexer_.PeekToken(); - } - } - lexer_.GetToken(); - if (!ret) { - lexer_.SkipCurrentLine(); - return false; - } - - token = lexer_.PeekToken(); - if (token != Token::SEMICOLON) { - LogError(token, String("\";\" is expected.")); - if (token != Token::BRACES_RIGHT) { - lexer_.SkipCurrentLine(Lexer::TokenToChar(Token::BRACES_RIGHT)); - } - return false; - } - lexer_.GetToken(); - - interface->AddMethod(method); - - return ret; -} - -bool Parser::ParseParameter( - /* [in] */ ASTMethod* method) -{ - Token token = lexer_.PeekToken(); - if (token != Token::BRACKETS_LEFT) { - LogError(token, String("\"[\" is expected.")); - // jump to ',' or ')' - while (token != Token::COMMA && token != Token::PARENTHESES_RIGHT && token != Token::END_OF_FILE) { - lexer_.GetToken(); - token = lexer_.PeekToken(); - } - return false; - } - lexer_.GetToken(); - - AutoPtr parameter = new ASTParameter(); - - token = lexer_.PeekToken(); - while (token != Token::BRACKETS_RIGHT && token != Token::END_OF_FILE) { - switch (token) { - case Token::IN: - lexer_.GetToken(); - parameter->SetInParameter(true); - break; - case Token::OUT: - lexer_.GetToken(); - parameter->SetOutParameter(true); - break; - case Token::INOUT: - lexer_.GetToken(); - parameter->SetInParameter(true); - parameter->SetOutParameter(true); - break; - default: - LogError(token, String("\"in\" or \"out\" or \"inout\" is expected.")); - break; - } - token = lexer_.PeekToken(); - if (token == Token::COMMA) { - lexer_.GetToken(); - token = lexer_.PeekToken(); - continue; - } - if (token != Token::BRACKETS_RIGHT) { - LogError(token, String("\",\" or \"]\" is expected.")); - // jump to ',' or ')' - while (token != Token::COMMA && token != Token::PARENTHESES_RIGHT && token != Token::END_OF_FILE) { - lexer_.GetToken(); - token = lexer_.PeekToken(); - } - return false; - } - } - // read ']' - lexer_.GetToken(); - - AutoPtr type = ParseType(); - if (type == nullptr) { - // jump to ',' or ')' - while (token != Token::COMMA && token != Token::PARENTHESES_RIGHT && token != Token::END_OF_FILE) { - lexer_.GetToken(); - token = lexer_.PeekToken(); - } - return false; - } - - token = lexer_.PeekToken(); - if (token != Token::IDENTIFIER) { - LogError(token, String("Parameter name is expected.")); - // jump to ',' or ')' - while (token != Token::COMMA && token != Token::PARENTHESES_RIGHT && token != Token::END_OF_FILE) { - lexer_.GetToken(); - token = lexer_.PeekToken(); - } - return false; - } - lexer_.GetToken(); - - parameter->SetName(lexer_.GetIdentifier()); - parameter->SetType(type); - method->AddParameter(parameter); - - return true; -} - -AutoPtr Parser::ParseType() -{ - AutoPtr type; - - Token token = lexer_.PeekToken(); - if (IsPrimitiveType(token)) { - lexer_.GetToken(); - type = module_->FindType(lexer_.DumpToken()); - } else if (token == Token::LIST) { - type = ParseList(); - } else if (token == Token::MAP) { - type = ParseMap(); - } else if (token == Token::IDENTIFIER) { - lexer_.GetToken(); - if (parsingInterface_ != nullptr && - parsingInterface_->GetName().Equals(lexer_.GetIdentifier())) { - type = parsingInterface_.Get(); - } else { - type = module_->FindType(lexer_.GetIdentifier()); - } - } else { - LogError(token, String("Type name is expected.")); - return nullptr; - } - - if (type == nullptr) { - LogError(token, String::Format("Type \"%s\" was not declared in the module.", lexer_.DumpToken().string())); - } - - token = lexer_.PeekToken(); - if (token == Token::BRACKETS_LEFT) { - lexer_.GetToken(); - token = lexer_.PeekToken(); - if (token != Token::BRACKETS_RIGHT) { - LogError(token, String("\"]\" is expected.")); - return nullptr; - } - lexer_.GetToken(); - - AutoPtr arrayType = new ASTArrayType(); - arrayType->SetElementType(type); - - type = module_->FindType(arrayType->ToString()); - if (type == nullptr) { - module_->AddType(arrayType); - type = static_cast(arrayType.Get()); - } - } - - return type; -} - -AutoPtr Parser::ParseList() -{ - lexer_.GetToken(); - - Token token = lexer_.PeekToken(); - if (token != Token::ANGLE_BRACKETS_LEFT) { - LogError(token, String("\"<\" is expected.")); - return nullptr; - } - lexer_.GetToken(); - - AutoPtr type = ParseType(); - if (type == nullptr) { - lexer_.SkipCurrentLine('>'); - return nullptr; - } - - token = lexer_.PeekToken(); - if (token != Token::ANGLE_BRACKETS_RIGHT) { - LogError(token, String("\">\" is expected.")); - return nullptr; - } - lexer_.GetToken(); - - AutoPtr list = new ASTListType(); - list->SetElementType(type); - - AutoPtr ret = module_->FindType(list->ToString()); - if (ret == nullptr) { - module_->AddType(list); - ret = list.Get(); - } - - return ret; -} - -AutoPtr Parser::ParseMap() -{ - lexer_.GetToken(); - - Token token = lexer_.PeekToken(); - if (token != Token::ANGLE_BRACKETS_LEFT) { - LogError(token, String("\"<\" is expected.")); - return nullptr; - } - lexer_.GetToken(); - - AutoPtr keyType = ParseType(); - if (keyType == nullptr) { - lexer_.SkipCurrentLine('>'); - return nullptr; - } - - token = lexer_.PeekToken(); - if (token != Token::COMMA) { - LogError(token, String("\",\" is expected.")); - return nullptr; - } - lexer_.GetToken(); - - AutoPtr valueType = ParseType(); - if (valueType == nullptr) { - lexer_.SkipCurrentLine('>'); - return nullptr; - } - - token = lexer_.PeekToken(); - if (token != Token::ANGLE_BRACKETS_RIGHT) { - LogError(token, String("\">\" is expected.")); - return nullptr; - } - lexer_.GetToken(); - - AutoPtr map = new ASTMapType(); - map->SetKeyType(keyType); - map->SetValueType(valueType); - - AutoPtr ret = module_->FindType(map->ToString()); - if (ret == nullptr) { - module_->AddType(map); - ret = map.Get(); - } - - return ret; -} - -bool Parser::ParseSequenceable() -{ - lexer_.GetToken(); - - String classFullName; - - Token token = lexer_.PeekToken(); - if (token != Token::IDENTIFIER) { - LogError(token, String::Format("%s is not expected.", lexer_.DumpToken().string())); - lexer_.SkipCurrentLine(); - return false; - } else { - lexer_.GetToken(); - classFullName = lexer_.GetIdentifier(); - token = lexer_.PeekToken(); - } - - if (token != Token::SEMICOLON) { - LogError(token, String::Format("%s is not expected.", lexer_.DumpToken().string())); - lexer_.SkipCurrentLine(); - return false; - } - - // read ';' - lexer_.GetToken(); - - if (classFullName.IsEmpty()) { - LogError(Token::IDENTIFIER, String("Class name is expected.")); - return false; - } else if (!IsValidTypeName(classFullName)) { - LogError(Token::IDENTIFIER, String::Format("Class name \"%s\" is illegal.", classFullName.string())); - return false; - } - - AutoPtr sequenceable = new ASTSequenceableType(); - int index = classFullName.LastIndexOf('.'); - if (index != -1) { - sequenceable->SetName(classFullName.Substring(index + 1)); - sequenceable->SetNamespace(module_->ParseNamespace(classFullName.Substring(0, index + 1))); - } else { - sequenceable->SetName(classFullName); - } - module_->AddSequenceable(sequenceable); - - return true; -} - -bool Parser::CheckIntegrity() -{ - bool definedInterface = false; - int interfaceNumber = module_->GetInterfaceNumber(); - for (int i = 0; i < interfaceNumber; i++) { - if (!module_->GetInterface(i)->IsExternal()) { - definedInterface = true; - break; - } - } - if (!definedInterface) { - LogError(Token::UNKNOWN, String("An interface is not defined.")); - return false; - } - - return true; -} - -bool Parser::IsValidTypeName( - /* [in] */ const String& typeName) -{ - if (typeName[0] == '.') { - return false; - } - - if (typeName[typeName.GetLength() - 1] == '.') { - return false; - } - - return true; -} - -void Parser::LogError( - /* [in] */ Token token, - /* [in] */ const String& message) -{ - AutoPtr error = new ErrorInfo(); - - String sourceFile = lexer_.GetSourceFile()->GetPath(); -#ifdef __MINGW32__ - error->file_ = sourceFile.Substring(sourceFile.LastIndexOf('\\') + 1); -#else - error->file_ = sourceFile.Substring(sourceFile.LastIndexOf('/') + 1); -#endif - error->lineNo_ = lexer_.GetTokenLineNumber(); - error->columnNo_ = lexer_.GetTokenColumnNumber(); - error->message_ = message; - - if (errors_ == nullptr) { - errors_ = error; - } else { - ErrorInfo* pos = errors_; - while (pos->next_ != nullptr) { - pos = pos->next_; - } - pos->next_ = error; - } -} - -void Parser::ShowError() -{ - ErrorInfo* error = errors_; - while (error != nullptr) { - Logger::E(TAG, "%s[line %d, column %d] %s", error->file_.string(), - error->lineNo_, error->columnNo_, error->message_.string()); - error = error->next_; - } -} - -} -} diff --git a/zidl/parser/parser.h b/zidl/parser/parser.h deleted file mode 100644 index b0e4f5ec3b1..00000000000 --- a/zidl/parser/parser.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_PARSER_H -#define OHOS_ZIDL_PARSER_H - -#include "ast/ast_interface_type.h" -#include "ast/ast_method.h" -#include "ast/ast_module.h" -#include "ast/ast_type.h" -#include "parser/lexer.h" -#include "parser/token.h" -#include "util/autoptr.h" -#include "util/light_refcount_base.h" -#include "util/options.h" -#include "util/string.h" - -namespace OHOS { -namespace Zidl { - -class Parser { -public: - explicit Parser( - /* [in] */ const Options& options); - - ~Parser() = default; - - bool Parse( - /* [in] */ const String& sourceFile); - - inline AutoPtr GetModule() const - { - return module_; - } - -private: - class ErrorInfo : public LightRefCountBase { - public: - String file_; - Token token_; - int lineNo_; - int columnNo_; - String message_; - AutoPtr next_; - }; - - bool ParseFile(); - - bool ParseLicense(); - - bool ParseInterface(); - - bool ParseMethod( - /* [in] */ ASTInterfaceType* interface); - - bool ParseParameter( - /* [in] */ ASTMethod* method); - - AutoPtr ParseType(); - - AutoPtr ParseList(); - - AutoPtr ParseMap(); - - bool ParseSequenceable(); - - bool CheckIntegrity(); - - bool IsValidTypeName( - /* [in] */ const String& typeName); - - inline static bool IsPrimitiveType( - /* [in] */ Token token) - { - return token >= Token::BOOLEAN && token <= Token::STRING; - } - - void LogError( - /* [in] */ Token token, - /* [in] */ const String& message); - - void ShowError(); - - static const char* TAG; - - const Options& options_; - AutoPtr module_; - AutoPtr parsingInterface_; - Lexer lexer_; - AutoPtr errors_; -}; - -} -} - -#endif // OHOS_ZIDL_PARSER_H diff --git a/zidl/parser/token.h b/zidl/parser/token.h deleted file mode 100644 index a121f147ef6..00000000000 --- a/zidl/parser/token.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_TOKEN_H -#define OHOS_ZIDL_TOKEN_H - -namespace OHOS { -namespace Zidl { - -enum class Token { - UNKNOWN = 0, - // types - BOOLEAN, - CHAR, - BYTE, - SHORT, - INTEGER, - LONG, - FLOAT, - DOUBLE, - STRING, - LIST, - MAP, - // keywords - IN, - INTERFACE, - ONEWAY, - OUT, - INOUT, - SEQUENCEABLE, - // symbols - DOT, // '.' - COMMA, // ',' - SEMICOLON, // ';' - BRACES_LEFT, // '{' - BRACES_RIGHT, // '}' - BRACKETS_LEFT, // '[' - BRACKETS_RIGHT, // ']' - PARENTHESES_LEFT, // '(' - PARENTHESES_RIGHT, // ')' - ANGLE_BRACKETS_LEFT, // '<' - ANGLE_BRACKETS_RIGHT, // '>' - // others - IDENTIFIER, - COMMENT_BLOCK, - COMMENT_LINE, - END_OF_FILE, -}; - -} -} - -#endif // OHOS_ZIDL_TOKEN_H diff --git a/zidl/test/native/BUILD.gn b/zidl/test/native/BUILD.gn deleted file mode 100644 index 8dc9839a534..00000000000 --- a/zidl/test/native/BUILD.gn +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") - -IPC_SUBSYSTEM_DIR = "//foundation/communication/ipc" -ZIDL_TEST_DIR = "//foundation/aafwk/standard/zidl/test/native" - -config("ipc_test_config") { - include_dirs = [ - "//utils/native/base/include", - "$ZIDL_TEST_DIR/include", - "$IPC_SUBSYSTEM_DIR/utils/include", - "$IPC_SUBSYSTEM_DIR/ipc/native/src/mock/include", - "//utils/system/safwk/native/include", - ] -} - -ohos_executable("zidl_server_test") { - sources = [ - "./src/main_server.cpp", - "./src/test_service.cpp", - "./src/zidl_test_service_stub.cpp", - ] - - configs = [ ":ipc_test_config" ] - - deps = [ "//utils/native/base:utils" ] - - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "samgr_standard:samgr_proxy", - ] - - subsystem_name = "aafwk" - part_name = "zidl" -} - -ohos_executable("zidl_client_test") { - sources = [ - "./src/main_client.cpp", - "./src/test_client.cpp", - "./src/zidl_test_service_proxy.cpp", - ] - - configs = [ ":ipc_test_config" ] - - deps = [ "//utils/native/base:utils" ] - - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "samgr_standard:samgr_proxy", - ] - - subsystem_name = "aafwk" - part_name = "zidl" -} diff --git a/zidl/test/native/include/izidl_test_service.h b/zidl/test/native/include/izidl_test_service.h deleted file mode 100644 index 3f6308363a8..00000000000 --- a/zidl/test/native/include/izidl_test_service.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_IZIDLTESTSERVICE_H -#define OHOS_IZIDLTESTSERVICE_H - -#include -#include - -namespace OHOS { -class IZidlTestService : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IZidlTestService"); - - virtual ErrCode TestIntTransaction( - /* [in] */ int _data, - /* [out] */ int& result) = 0; - - virtual ErrCode TestStringTransaction( - /* [in] */ const std::string& _data) = 0; -}; -} // namespace OHOS -#endif // OHOS_IZIDLTESTSERVICE_H - diff --git a/zidl/test/native/include/test_client.h b/zidl/test/native/include/test_client.h deleted file mode 100644 index 4d54213003b..00000000000 --- a/zidl/test/native/include/test_client.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_IPC_TEST_SERVICE_CLIENT_H -#define OHOS_IPC_TEST_SERVICE_CLIENT_H - -#include "ipc_debug.h" -#include "log_tags.h" -#include "zidl_test_service_proxy.h" - -namespace OHOS { -class TestClient { -public: - int ConnectService(); - void StartIntTransaction(); - void StartStringTransaction(); -private: - static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "TestClient" }; - sptr testService_; -}; -} // namespace OHOS -#endif // OHOS_IPC_TEST_SERVICE_CLIENT_H diff --git a/zidl/test/native/include/test_service.h b/zidl/test/native/include/test_service.h deleted file mode 100644 index 2c29658c761..00000000000 --- a/zidl/test/native/include/test_service.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_IPC_TEST_SERVICE_H -#define OHOS_IPC_TEST_SERVICE_H - -#include "hilog/log.h" -#include "log_tags.h" -#include "zidl_test_service_stub.h" - -namespace OHOS { -class TestService : public ZidlTestServiceStub { -public: - TestService(); - ~TestService(); - static int Instantiate(); - ErrCode TestIntTransaction(int data, int &rep) override; - ErrCode TestStringTransaction(const std::string& data) override; -private: - static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "TestService" }; -}; -} // namespace OHOS -#endif // OHOS_IPC_TEST_SERVICE_H - diff --git a/zidl/test/native/include/zidl_test_service_proxy.h b/zidl/test/native/include/zidl_test_service_proxy.h deleted file mode 100644 index 7e9ea4dcd58..00000000000 --- a/zidl/test/native/include/zidl_test_service_proxy.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDLTESTSERVICEPROXY_H -#define OHOS_ZIDLTESTSERVICEPROXY_H - -#include "izidl_test_service.h" -#include - -namespace OHOS { -class ZidlTestServiceProxy : public IRemoteProxy { -public: - explicit ZidlTestServiceProxy( - /* [in] */ const sptr& remote) - : IRemoteProxy(remote) - {} - - virtual ~ZidlTestServiceProxy() - {} - - ErrCode TestIntTransaction( - /* [in] */ int _data, - /* [out] */ int& result) override; - - ErrCode TestStringTransaction( - /* [in] */ const std::string& _data) override; - -private: - static constexpr int COMMAND_TEST_INT_TRANSACTION = MIN_TRANSACTION_ID + 0; - static constexpr int COMMAND_TEST_STRING_TRANSACTION = MIN_TRANSACTION_ID + 1; - - static inline BrokerDelegator delegator_; -}; -} // namespace OHOS -#endif // OHOS_ZIDLTESTSERVICEPROXY_H - diff --git a/zidl/test/native/include/zidl_test_service_stub.h b/zidl/test/native/include/zidl_test_service_stub.h deleted file mode 100644 index d88b615bb1f..00000000000 --- a/zidl/test/native/include/zidl_test_service_stub.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDLTESTSERVICESTUB_H -#define OHOS_ZIDLTESTSERVICESTUB_H - -#include "izidl_test_service.h" -#include - -namespace OHOS { -class ZidlTestServiceStub : public IRemoteStub { -public: - int OnRemoteRequest( - /* [in] */ uint32_t code, - /* [in] */ MessageParcel& data, - /* [out] */ MessageParcel& reply, - /* [in] */ MessageOption& option) override; - -private: - static constexpr int COMMAND_TEST_INT_TRANSACTION = MIN_TRANSACTION_ID + 0; - static constexpr int COMMAND_TEST_STRING_TRANSACTION = MIN_TRANSACTION_ID + 1; -}; -} // namespace OHOS -#endif // OHOS_ZIDLTESTSERVICESTUB_H - diff --git a/zidl/test/native/src/main_client.cpp b/zidl/test/native/src/main_client.cpp deleted file mode 100644 index 7238b197b76..00000000000 --- a/zidl/test/native/src/main_client.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "ipc_debug.h" -#include "ipc_skeleton.h" -#include "log_tags.h" -#include "test_client.h" - -using namespace OHOS; -using namespace OHOS::HiviewDFX; -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "IPCTestClient" }; - -enum TestCommand { - TEST_CMD_NONE = 0, - TEST_CMD_INT_TRANS = 1, - TEST_CMD_STRING_TRANS = 2 -}; - -namespace { -std::vector GetArgvOptions(int argc, char **argv) -{ - std::vector argvOptions; - for (int i = 1; i < argc; i++) { - argvOptions.emplace_back(std::string(argv[i])); - } - return argvOptions; -} -} - -int main(int argc, char *argv[]) -{ - TestCommand commandId = TestCommand::TEST_CMD_INT_TRANS; - if (argc > 1) { - commandId = TestCommand(atoi(argv[1])); - } else { - ZLOGE(LABEL, "unknown command"); - } - std::vector argvOptions; - argvOptions = GetArgvOptions(argc, argv); - std::unique_ptr testClient = std::make_unique(); - if (testClient->ConnectService()) { - return -1; - } - - ZLOGE(LABEL, "commandId= : %{public}d", commandId); - switch (commandId) { - case TestCommand::TEST_CMD_INT_TRANS: - testClient->StartIntTransaction(); - break; - case TestCommand::TEST_CMD_STRING_TRANS: - testClient->StartStringTransaction(); - break; - default: - ZLOGI(LABEL, "main arg error"); - break; - } - - IPCSkeleton::JoinWorkThread(); - return 0; -} diff --git a/zidl/test/native/src/main_server.cpp b/zidl/test/native/src/main_server.cpp deleted file mode 100644 index 0765721662f..00000000000 --- a/zidl/test/native/src/main_server.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ipc_debug.h" -#include "ipc_skeleton.h" -#include "log_tags.h" -#include "test_service.h" - -using namespace OHOS; -using namespace OHOS::HiviewDFX; - -[[maybe_unused]]static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "IPCTestServer" }; - -int main(int argc __attribute__((unused)), char **argv __attribute__((unused))) -{ - TestService::Instantiate(); - ZLOGI(LABEL, "call StartThreadPool"); - IPCSkeleton::JoinWorkThread(); -} diff --git a/zidl/test/native/src/test_client.cpp b/zidl/test/native/src/test_client.cpp deleted file mode 100644 index b2e7abd8e58..00000000000 --- a/zidl/test/native/src/test_client.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "test_client.h" - -#include "if_system_ability_manager.h" -#include "ipc_debug.h" -#include "ipc_skeleton.h" -#include "iservice_registry.h" -#include "system_ability_definition.h" - -namespace OHOS { -int TestClient::ConnectService() -{ - auto saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (saMgr == nullptr) { - ZLOGE(LABEL, "get registry fail"); - return -1; - } - - sptr object = saMgr->GetSystemAbility(IPC_TEST_SERVICE); - - if (object != nullptr) { - ZLOGE(LABEL, "Got test Service object"); - testService_ = (new (std::nothrow) ZidlTestServiceProxy(object)); - } - - if (testService_ == nullptr) { - ZLOGE(LABEL, "Could not find Test Service!"); - return -1; - } - - return 0; -} - -void TestClient::StartIntTransaction() -{ - if (testService_ != nullptr) { - ZLOGE(LABEL, "StartIntTransaction"); - [[maybe_unused]] int result = 0; - testService_->TestIntTransaction(1234, result); // 1234 : test number - ZLOGE(LABEL, "Rec result from server %{public}d.", result); - } -} - -void TestClient::StartStringTransaction() -{ - if (testService_ != nullptr) { - ZLOGI(LABEL, "StartIntTransaction"); - testService_->TestStringTransaction("ZIDL Test"); - } -} -} // namespace OHOS diff --git a/zidl/test/native/src/test_service.cpp b/zidl/test/native/src/test_service.cpp deleted file mode 100644 index acf2f6346c1..00000000000 --- a/zidl/test/native/src/test_service.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "test_service.h" - -#include - -#include "if_system_ability_manager.h" -#include "ipc_debug.h" -#include "ipc_skeleton.h" -#include "iservice_registry.h" -#include "system_ability_definition.h" - -namespace OHOS { -using namespace OHOS::HiviewDFX; - -int TestService::Instantiate() -{ - ZLOGI(LABEL, "%{public}s call in", __func__); - auto saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (saMgr == nullptr) { - ZLOGE(LABEL, "%{public}s:fail to get Registry", __func__); - return -ENODEV; - } - - sptr newInstance = new TestService(); - int result = saMgr->AddSystemAbility(IPC_TEST_SERVICE, newInstance); - ZLOGI(LABEL, "%{public}s: IPC_TEST_SERVICE result = %{public}d", __func__, result); - return result; -} - -TestService::TestService() -{ -} - -TestService::~TestService() -{ -} - -ErrCode TestService::TestIntTransaction(int data, int &rep) -{ - ZLOGE(LABEL, " TestService:read from client data = %{public}d", data); - rep = data + data; - return ERR_NONE; -} - -ErrCode TestService::TestStringTransaction(const std::string &data) -{ - ZLOGE(LABEL, "TestService:read string from client data = %{public}s", data.c_str()); - return data.size(); -} -} // namespace OHOS diff --git a/zidl/test/native/src/zidl_test_service_proxy.cpp b/zidl/test/native/src/zidl_test_service_proxy.cpp deleted file mode 100644 index 314cadb6a24..00000000000 --- a/zidl/test/native/src/zidl_test_service_proxy.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "zidl_test_service_proxy.h" - -namespace OHOS { -ErrCode ZidlTestServiceProxy::TestIntTransaction( - /* [in] */ int _data, - /* [out] */ int& result) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - - data.WriteInt32(_data); - - int32_t st = Remote()->SendRequest(COMMAND_TEST_INT_TRANSACTION, data, reply, option); - if (st != ERR_NONE) { - return st; - } - - ErrCode ec = reply.ReadInt32(); - if (FAILED(ec)) { - return ec; - } - - result = reply.ReadInt32(); - return ERR_OK; -} - -ErrCode ZidlTestServiceProxy::TestStringTransaction( - /* [in] */ const std::string& _data) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - - data.WriteString16(Str8ToStr16(_data)); - - int32_t st = Remote()->SendRequest(COMMAND_TEST_STRING_TRANSACTION, data, reply, option); - if (st != ERR_NONE) { - return st; - } - - ErrCode ec = reply.ReadInt32(); - if (FAILED(ec)) { - return ec; - } - - return ERR_OK; -} -} // namespace OHOS diff --git a/zidl/test/native/src/zidl_test_service_stub.cpp b/zidl/test/native/src/zidl_test_service_stub.cpp deleted file mode 100644 index adf63cd1dec..00000000000 --- a/zidl/test/native/src/zidl_test_service_stub.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "zidl_test_service_stub.h" - -namespace OHOS { -int ZidlTestServiceStub::OnRemoteRequest( - /* [in] */ uint32_t code, - /* [in] */ MessageParcel& data, - /* [out] */ MessageParcel& reply, - /* [in] */ MessageOption& option) -{ - switch (code) { - case COMMAND_TEST_INT_TRANSACTION: { - int _data = data.ReadInt32(); - int result; - ErrCode ec = TestIntTransaction(_data, result); - reply.WriteInt32(ec); - if (SUCCEEDED(ec)) { - reply.WriteInt32(result); - } - return ERR_NONE; - } - case COMMAND_TEST_STRING_TRANSACTION: { - std::string _data = Str16ToStr8(data.ReadString16()); - ErrCode ec = TestStringTransaction(_data); - reply.WriteInt32(ec); - return ERR_NONE; - } - default: - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - - return ERR_TRANSACTION_FAILED; -} -} // namespace OHOS diff --git a/zidl/test/zidlgen/IZidlTestService.zidl b/zidl/test/zidlgen/IZidlTestService.zidl deleted file mode 100644 index 8d2fa0b91c5..00000000000 --- a/zidl/test/zidlgen/IZidlTestService.zidl +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -interface OHOS.IZidlTestService { - int TestIntTransaction([in] int data); - void TestStringTransaction([in] String data); -} \ No newline at end of file diff --git a/zidl/test/zidlgen/zidl b/zidl/test/zidlgen/zidl deleted file mode 100644 index c3bde7295221617c5bdc4e7a695702a580ac0c22..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 216360 zcmeFa34ByV);?Sb0Ru*D6&;k!cnOOELP$b@u!s#wkU)S)0wRl@Ch3rdPSSRFASh~N zP*G7MqB4pamr+zkqoSfB#u*oMP&2N`fD?Db=)@fz)bFXPQ{DGg_f0@?-uM6g-U}zE z`>AtJovJ!@YPm~akY6}4J}!=_qYE3y_&4JMi8(1Dbz&DK!kjFJ9ge@rtT*chGy&wK zRGnAG%LK&}Nsepd=WU>LohOr=;>tqK`FVCn&l)MIICDrzj&=nZl&;FBcuTW9PjT~k zyo~KbW%=8uTX|zosb6vZyoNj}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wph=Ge3xQKy^7`TXmix{|w zfr}Wph=Ge3_%Fo(6-WHtvs}7Vl<{|FnRG39oC>Gng+D5|_=C-W2(jW(QIz_lVvN72 zFkVWgi;k22RE+UQg%N)+2od@5pca2rEb+H5DqSk>_$$bgE){qD4X&17R9x|Al}kk( zf4r@OKPuYzv&!owL7U$zKd6}FZ<%WE-@0Udo}VK9smS85qe^B-#T9>4xba8D7Juz3 zoQf>|EPPS1$KR(@WqK<1_{%GiaJy=M+YQnmDlSoz!K!>{s03``LB{%@_jln!)uG** zeuKhexpL4Z1pHl8~%H5{i7UjOF++)f;sod;oviyO{9j)9Olv}RcIm)e3 z?keRzs@$iP`t?=IE@=xK4rTC~_ymXQLVk%qV-78nx3h#Mv*-C${t#I*@1vRyc z?q9rM$vuGXT^1-@wYYZWean|E0C?Xr|Ki#eh`h+Zh}jg@E?3zhd0K3l;e+?f+Q^_K zi&ieN6)s!uUtH*(;T`K=bZ@daTcQ8{1=UNJFI&98zv%9zi&Z?9e|O-%rT2`z?;erm zqWkZwwiT{ig1RCe3SZ8;$Ql7L|Hn6O!?70{gdz}Z@0>~_`T&eeo3YyA7dl&)C+e&ZE*9mu=OxeAB3x8v~rMKp5%eCff zrste))!#~g8h)(Pc>L$D{eyJ(#fcKO{#x^`1>b}Zrnl<<{i|dPEjP=WcvS+c9aefC znoCXpe4$Klxl2o}n9{ZCZ~0O#Ure93@L!gelz-aC zNuTccvS7<)+1%8$(p&OXhf3eQJS!cNh#!R_=3%AJovq3(lJ4AY8FWv73~AYSR(eam zSXe53_Azt(taO%ZWy=l7)bfk&mg$OSNH;1{C;wRKEuWFy(p&QE;F&W08dbg(zk7N+ z!c)uNGF?HLbgg)n+r9h}1klfl-93FlxB7Q4|D%+& RRvC1y@^N=W+OHdE`#(nTh9Lj| diff --git a/zidl/util/CMakeLists.txt b/zidl/util/CMakeLists.txt deleted file mode 100644 index 753b0bb189b..00000000000 --- a/zidl/util/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -include_directories( - ${ZIDL_DIR}) - -set(SOURCES - file.cpp - light_refcount_base.cpp - logger.cpp - options.cpp - string.cpp - string_builder.cpp - string_pool.cpp) - -add_library(util STATIC - ${SOURCES}) \ No newline at end of file diff --git a/zidl/util/autoptr.h b/zidl/util/autoptr.h deleted file mode 100644 index 3574bf9f861..00000000000 --- a/zidl/util/autoptr.h +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_AUTOPTR_H -#define OHOS_ZIDL_AUTOPTR_H - -namespace OHOS { -namespace Zidl { - -template -class AutoPtr { -public: - inline AutoPtr() - : mPtr(nullptr) - {} - - AutoPtr( - /* [in] */ T* other); - - AutoPtr( - /* [in] */ const AutoPtr& other); - - AutoPtr( - /* [in] */ AutoPtr&& other); - - ~AutoPtr(); - - AutoPtr& operator=( - /* [in] */ T* other); - - AutoPtr& operator=( - /* [in] */ const AutoPtr& other); - - AutoPtr& operator=( - /* [in] */ AutoPtr&& other); - - void MoveTo( - /* [out] */ T** other); - - inline operator T*() const; - - inline T** operator&(); - - inline T* operator->() const; - - inline T& operator*() const; - - inline T* Get() const; - - inline bool operator==( - /* [in] */ T* other) const; - - inline bool operator==( - /* [in] */ const AutoPtr& other) const; - - inline bool operator!=( - /* [in] */ T* other) const; - - inline bool operator!=( - /* [in] */ const AutoPtr& other) const; - - inline bool operator>( - /* [in] */ T* other) const; - - inline bool operator>( - /* [in] */ const AutoPtr& other) const; - - inline bool operator<( - /* [in] */ T* other) const; - - inline bool operator<( - /* [in] */ const AutoPtr& other) const; - - inline bool operator<=( - /* [in] */ T* other) const; - - inline bool operator<=( - /* [in] */ const AutoPtr& other) const; - - inline bool operator>=( - /* [in] */ T* other) const; - - inline bool operator>=( - /* [in] */ const AutoPtr& other) const; - -private: - T* mPtr; -}; - -template -AutoPtr::AutoPtr( - /* [in] */ T* other) - : mPtr(other) -{ - if (mPtr != nullptr) { - mPtr->AddRef(); - } -} - -template -AutoPtr::AutoPtr( - /* [in] */ const AutoPtr& other) - : mPtr(other.mPtr) -{ - if (mPtr != nullptr) { - mPtr->AddRef(); - } -} - -template -AutoPtr::AutoPtr( - /* [in] */ AutoPtr&& other) - : mPtr(other.mPtr) -{ - other.mPtr = nullptr; -} - -template -AutoPtr::~AutoPtr() -{ - if (mPtr != nullptr) { - mPtr->Release(); - } -} - -template -AutoPtr& AutoPtr::operator=( - /* [in] */ T* other) -{ - if (mPtr == other) return *this; - - if (other != nullptr) { - other->AddRef(); - } - if (mPtr != nullptr) { - mPtr->Release(); - } - mPtr = other; - return *this; -} - -template -AutoPtr& AutoPtr::operator=( - /* [in] */ const AutoPtr& other) -{ - if (mPtr == other.mPtr) return *this; - - if (other.mPtr != nullptr) { - other.mPtr->AddRef(); - } - if (mPtr != nullptr) { - mPtr->Release(); - } - mPtr = other.mPtr; - return *this; -} - -template -AutoPtr& AutoPtr::operator=( - /* [in] */ AutoPtr&& other) -{ - if (mPtr != nullptr) { - mPtr->Release(); - } - mPtr = other.mPtr; - other.mPtr = nullptr; - return *this; -} - -template -void AutoPtr::MoveTo( - /* [out] */ T** other) -{ - if (other != nullptr) { - *other = mPtr; - mPtr = nullptr; - } -} - -template -AutoPtr::operator T*() const -{ - return mPtr; -} - -template -T** AutoPtr::operator&() -{ - return &mPtr; -} - -template -T* AutoPtr::operator->() const -{ - return mPtr; -} - -template -T& AutoPtr::operator*() const -{ - return *mPtr; -} - -template -T* AutoPtr::Get() const -{ - return mPtr; -} - -template -bool AutoPtr::operator==( - /* [in] */ T* other) const -{ - return mPtr == other; -} - -template -bool AutoPtr::operator==( - /* [in] */ const AutoPtr& other) const -{ - return mPtr == other.mPtr; -} - -template -bool AutoPtr::operator!=( - /* [in] */ T* other) const -{ - return mPtr != other; -} - -template -bool AutoPtr::operator!=( - /* [in] */ const AutoPtr& other) const -{ - return mPtr != other.mPtr; -} - -template -bool AutoPtr::operator>( - /* [in] */ T* other) const -{ - return mPtr > other; -} - -template -bool AutoPtr::operator>( - /* [in] */ const AutoPtr& other) const -{ - return mPtr > other.mPtr; -} - -template -bool AutoPtr::operator<( - /* [in] */ T* other) const -{ - return mPtr < other; -} - -template -bool AutoPtr::operator<( - /* [in] */ const AutoPtr& other) const -{ - return mPtr < other.mPtr; -} - -template -bool AutoPtr::operator<=( - /* [in] */ T* other) const -{ - return mPtr <= other; -} - -template -bool AutoPtr::operator<=( - /* [in] */ const AutoPtr& other) const -{ - return mPtr <= other.mPtr; -} - -template -bool AutoPtr::operator>=( - /* [in] */ T* other) const -{ - return mPtr >= other; -} - -template -bool AutoPtr::operator>=( - /* [in] */ const AutoPtr& other) const -{ - return mPtr >= other.mPtr; -} - -} -} - -#endif // OHOS_ZIDL_AUTOPTR_H diff --git a/zidl/util/file.cpp b/zidl/util/file.cpp deleted file mode 100644 index 1bba24f9127..00000000000 --- a/zidl/util/file.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "util/file.h" - -#include -#include -#include "securec.h" - -namespace OHOS { -namespace Zidl { - -#ifdef __MINGW32__ -constexpr unsigned int File::READ; -constexpr unsigned int File::WRITE; -constexpr unsigned int File::APPEND; -#endif - -File::File( - /* [in] */ const String& path, - /* [in] */ int mode) - : mode_(mode) -{ - if (path.IsEmpty()) { - return; - } - - if (mode_ & READ) { - fd_ = fopen(path.string(), "r"); - } else if (mode_ & WRITE) { - fd_ = fopen(path.string(), "w+"); - } else if (mode_ & APPEND) { - fd_ = fopen(path.string(), "a+"); - } - - if (fd_ != nullptr) { -#ifndef __MINGW32__ - char* absolutePath = realpath(path.string(), nullptr); - if (absolutePath != nullptr) { - path_ = absolutePath; - - free(absolutePath); - - } else { - path_ = path; - } -#else - char absolutePath[_MAX_PATH]; - _fullpath(absolutePath, path.string(), _MAX_PATH); - path_ = absolutePath; -#endif - } -} - -File::~File() -{ - Close(); -} - -char File::GetChar() -{ - char c = PeekChar(); - - if (position_ + 1 <= size_) { - position_++; - - if (c != '\n') { - columnNo_++; - } else { - columnNo_ = 0; - lineNo_++; - } - } - return c; -} - -char File::PeekChar() -{ - if (position_ + 1 > size_) { - int ret = Read(); - if (ret == -1) { - isEof_ = true; - } - } - - return buffer_[position_]; -} - -bool File::IsEof() const -{ - return isEof_ || buffer_[position_] == static_cast(-1); -} - -int File::Read() -{ - if (isEof_ || isError_) { - return -1; - } - - (void)memset_s(buffer_, BUFFER_SIZE, 0, BUFFER_SIZE); - size_t count = fread(buffer_, 1, BUFFER_SIZE - 1, fd_); - if (count < BUFFER_SIZE - 1) { - isError_ = ferror(fd_) != 0; - buffer_[count] = -1; - } - size_ = count; - position_ = 0; - return count != 0 ? count : -1; -} - -bool File::ReadData( - /* [out] */ void* data, - /* [in] */ size_t size) -{ - if (data == nullptr || size == 0) { - return true; - } - - if (fd_ == nullptr) { - return false; - } - - size_t count = fread(data, size, 1, fd_); - return count == 1; -} - -bool File::WriteData( - /* [in] */ const void* data, - /* [in] */ size_t size) -{ - if (data == nullptr || size == 0) { - return true; - } - - if (fd_ == nullptr || !(mode_ & (WRITE | APPEND))) { - return false; - } - - size_t count = fwrite(data, size, 1, fd_); - return count == 1; -} - -void File::Flush() -{ - if ((mode_ & (WRITE | APPEND)) && fd_ != nullptr) { - fflush(fd_); - } -} - -bool File::Reset() -{ - if (fd_ == nullptr) { - return false; - } - - return fseek(fd_, 0, SEEK_SET) == 0; -} - -bool File::Skip( - /* [in] */ long size) -{ - if (fd_ == nullptr) { - return false; - } - - return fseek(fd_, size, SEEK_CUR) == 0; -} - -void File::Close() -{ - if (fd_ != nullptr) { - fclose(fd_); - fd_ = nullptr; - } -} - -} -} diff --git a/zidl/util/file.h b/zidl/util/file.h deleted file mode 100644 index 1f5f3acc7bf..00000000000 --- a/zidl/util/file.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_FILE_H -#define OHOS_ZIDL_FILE_H - -#include -#include - -#include "util/string.h" - -namespace OHOS { -namespace Zidl { - -class File { -public: - File( - /* [in] */ const String& path, - /* [in] */ int mode); - - ~File(); - - inline bool IsValid() - { - return fd_ != nullptr; - } - - inline String GetPath() - { - return path_; - } - - char GetChar(); - - char PeekChar(); - - bool IsEof() const; - - inline int GetCharLineNumber() const - { - return lineNo_; - } - - inline int GetCharColumnNumber() const - { - return columnNo_; - } - - bool ReadData( - /* [out] */ void* data, - /* [in] */ size_t size); - - bool WriteData( - /* [in] */ const void* data, - /* [in] */ size_t size); - - void Flush(); - - bool Reset(); - - bool Skip( - /* [in] */ long size); - - void Close(); - - static constexpr unsigned int READ = 0x1; - static constexpr unsigned int WRITE = 0x2; - static constexpr unsigned int APPEND = 0x4; - -private: - int Read(); - - static constexpr int BUFFER_SIZE = 1024; - - char buffer_[BUFFER_SIZE] = {0}; - size_t size_ = 0; - size_t position_ = 0; - size_t columnNo_ = 1; - size_t lineNo_ = 1; - bool isEof_ = false; - bool isError_ = false; - - FILE* fd_ = nullptr; - String path_; - unsigned int mode_ = 0; -}; - -} -} - -#endif // OHOS_ZIDL_STRING_H diff --git a/zidl/util/light_refcount_base.cpp b/zidl/util/light_refcount_base.cpp deleted file mode 100644 index fb0bedd02ae..00000000000 --- a/zidl/util/light_refcount_base.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "util/light_refcount_base.h" - -namespace OHOS { -namespace Zidl { - -int LightRefCountBase::AddRef() -{ - const int beforeCount = refCount_.fetch_add(1, std::memory_order_relaxed); - return beforeCount + 1; -} - -int LightRefCountBase::Release() -{ - const int beforeCount = refCount_.fetch_sub(1, std::memory_order_release); - if (beforeCount - 1 == 0) { - delete this; - } - return beforeCount - 1; -} - -} -} diff --git a/zidl/util/light_refcount_base.h b/zidl/util/light_refcount_base.h deleted file mode 100644 index 55df3d3ece2..00000000000 --- a/zidl/util/light_refcount_base.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_LIGHTREFCOUNTBASE_H -#define OHOS_ZIDL_LIGHTREFCOUNTBASE_H - -#include - -namespace OHOS { -namespace Zidl { - -class LightRefCountBase { -public: - inline LightRefCountBase() - : refCount_(0) - {} - - int AddRef(); - - int Release(); - - inline int GetRefCount() const - { - return refCount_.load(std::memory_order_relaxed); - } - -protected: - inline virtual ~LightRefCountBase() - {} - -private: - std::atomic refCount_; -}; - -} -} - -#endif // OHOS_ZIDL_LIGHTREFCOUNTBASE_H diff --git a/zidl/util/logger.cpp b/zidl/util/logger.cpp deleted file mode 100644 index acc50e1edb3..00000000000 --- a/zidl/util/logger.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "util/logger.h" - -#include - -namespace OHOS { -namespace Zidl { - -int Logger::level_ = DEBUG; - -void Logger::D( - /* [in] */ const char* tag, - /* [in] */ const char* format, ...) -{ - if (level_ > DEBUG) return; - - va_list args; - va_start(args, format); - Log(tag, format, args); - va_end(args); -} - -void Logger::E( - /* [in] */ const char* tag, - /* [in] */ const char* format, ...) -{ - if (level_ > ERROR) return; - - va_list args; - va_start(args, format); - Err(tag, format, args); - va_end(args); -} - -void Logger::V( - /* [in] */ const char* tag, - /* [in] */ const char* format, ...) -{ - if (level_ > VERBOSE) return; - - va_list args; - va_start(args, format); - Log(tag, format, args); - va_end(args); -} - -void Logger::Log( - /* [in] */ const char* tag, - /* [in] */ const char* format, - /* [in] */ va_list args) -{ - printf("[%s]: ", tag); - vprintf(format, args); - printf("\n"); -} - -void Logger::Err( - /* [in] */ const char* tag, - /* [in] */ const char* format, - /* [in] */ va_list args) -{ - fprintf(stderr, "[%s]: ", tag); - vfprintf(stderr, format, args); - fprintf(stderr, "\n"); -} - -} -} diff --git a/zidl/util/logger.h b/zidl/util/logger.h deleted file mode 100644 index f31a20ad9a6..00000000000 --- a/zidl/util/logger.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_LOGGER_H -#define OHOS_ZIDL_LOGGER_H - -#include - -namespace OHOS { -namespace Zidl { - -class Logger { -public: - static void D( - /* [in] */ const char* tag, - /* [in] */ const char* format, ...); - - static void E( - /* [in] */ const char* tag, - /* [in] */ const char* format, ...); - - static void V( - /* [in] */ const char* tag, - /* [in] */ const char* format, ...); - - inline static void SetLevel( - /* [in] */ int level) - { - level_ = level; - } - - static constexpr int VERBOSE = 0; - static constexpr int DEBUG = 1; - static constexpr int ERROR = 2; - static constexpr int NOLOG = 3; - -private: - Logger(); - - ~Logger(); - - static void Log( - /* [in] */ const char* tag, - /* [in] */ const char* format, - /* [in] */ va_list args); - - static void Err( - /* [in] */ const char* tag, - /* [in] */ const char* format, - /* [in] */ va_list args); - - static int level_; -}; - -} -} - -#endif // OHOS_ZIDL_LOGGER_H diff --git a/zidl/util/options.cpp b/zidl/util/options.cpp deleted file mode 100644 index 1d210eac978..00000000000 --- a/zidl/util/options.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "options.h" -#include "util/string_builder.h" - -#include -#include - -namespace OHOS { -namespace Zidl { - -void Options::Parse( - /* [in] */ int argc, - /* [in] */ char** argv) -{ - StringBuilder errors; - program_ = argv[0]; - - int i = 1; - while (i < argc) { - String option(argv[i++]); - if (option.Equals("--help")) { - doShowUsage_ = true; - } else if (option.Equals("--version")) { - doShowVersion_ = true; - } else if (option.Equals("-c")) { - doCompile_ = true; - } else if (option.Equals("-dump-ast")) { - doDumpAST_ = true; - } else if (option.Equals("-dump-metadata")) { - doDumpMetadata_ = true; - } else if (option.Equals("-s")) { - doSaveMetadata_ = true; - metadataFile_ = argv[i++]; - } else if (option.Equals("-gen-cpp")) { - doGenerateCode_ = true; - targetLanguage_ = "cpp"; - } else if (option.Equals("-gen-java")) { - doGenerateCode_ = true; - targetLanguage_ = "java"; - } else if (option.Equals("-gen-js")) { - doGenerateCode_ = true; - targetLanguage_ = "js"; - }else if (option.Equals("-d")) { - generationDirectory_ = argv[i++]; - } else if (!option.StartsWith("-")) { - sourceFile_ = option; - } else { - errors.Append(option); - errors.Append(" "); - } - } - - illegalOptions_ = errors.ToString(); -} - -void Options::ShowErrors() -{ - if (!illegalOptions_.IsEmpty()) { - String options = illegalOptions_; - int index; - while ((index = options.IndexOf(' ')) != -1) { - printf("The Option \"%s\" is illegal.\n", options.Substring(0, index).string()); - options = options.Substring(index + 1); - } - } - printf("Use \"--help\" to show usage.\n"); -} - -void Options::ShowVersion() -{ - printf("zidl %d.%d\n" - "Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved.\n\n", - VERSION_MAJOR, VERSION_MINOR); -} - -void Options::ShowUsage() -{ - printf("Compile a .zidl file and generate metadata, or generate C++ and Java codes from metadata.\n" - "Usage: zidl [options] file\n" - "Options:\n" - " --help Display command line options\n" - " --version Display toolchain version information\n" - " -dump-ast Display the AST of the compiled file\n" - " -dump-metadata Display the metadata generated from the compiled file\n" - " -c Compile the .zidl file\n" - " -s Place the metadata into \n" - " -gen-cpp Generate C++ codes\n" - " -gen-java Generate Java codes\n" - " -gen-js Generate Js codes\n" - " -d Place generated codes into \n"); -} - -} -} diff --git a/zidl/util/options.h b/zidl/util/options.h deleted file mode 100644 index 9d7895052ef..00000000000 --- a/zidl/util/options.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_OPTIONS_H -#define OHOS_ZIDL_OPTIONS_H - -#include "util/string.h" - -namespace OHOS { -namespace Zidl { - -class Options { -public: - inline Options( - /* [in] */ int argc, - /* [in] */ char** argv) - { - Parse(argc, argv); - } - - ~Options() = default; - - inline bool DoShowUsage() const - { - return doShowUsage_; - } - - inline bool DoShowVersion() const - { - return doShowVersion_; - } - - inline bool DoCompile() const - { - return doCompile_; - } - - inline bool DoDumpAST() const - { - return doDumpAST_; - } - - inline bool DoDumpMetadata() const - { - return doDumpMetadata_; - } - - inline bool DoSaveMetadata() const - { - return doSaveMetadata_; - } - - inline bool DoGenerateCode() const - { - return doGenerateCode_; - } - - inline bool HasErrors() const - { - return !illegalOptions_.IsEmpty() || sourceFile_.IsEmpty(); - } - - inline String GetSourceFile() const - { - return sourceFile_; - } - - inline String GetMetadataFile() const - { - return metadataFile_; - } - - inline String GetTargetLanguage() const - { - return targetLanguage_; - } - - inline String GetGenerationDirectory() const - { - return generationDirectory_; - } - - void ShowErrors(); - - void ShowVersion(); - - void ShowUsage(); - -private: - void Parse( - /* [in] */ int argc, - /* [in] */ char** argv); - - static constexpr int VERSION_MAJOR = 0; - static constexpr int VERSION_MINOR = 1; - - String program_; - String sourceFile_; - String metadataFile_; - String targetLanguage_; - String generationDirectory_; - String illegalOptions_; - - bool doShowUsage_ = false; - bool doShowVersion_ = false; - bool doCompile_ = false; - bool doDumpAST_ = false; - bool doDumpMetadata_ = false; - bool doSaveMetadata_ = false; - bool doGenerateCode_ = false; -}; - -} -} - -#endif // OHOS_ZIDL_OPTIONS_H diff --git a/zidl/util/string.cpp b/zidl/util/string.cpp deleted file mode 100644 index d640223f146..00000000000 --- a/zidl/util/string.cpp +++ /dev/null @@ -1,720 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "util/string.h" -#include "util/string_builder.h" -#include -#include -#include -#include -#include -#include -#include -#include "securec.h" - -#include "util/logger.h" - -namespace OHOS { -namespace Zidl { -constexpr int LINE_MAX_SIZE = 1024; - -using SharedData = struct SharedData { - SharedData( - /* [in] */ int refCount, - /* [in] */ int size) - : refCount_(refCount), size_(size) - {} - - static SharedData* Allocate( - /* [in] */ int size); - - static void AddRef( - /* [in] */ const void* handle); - - static void Release( - /* [in] */ const void* handle); - - inline static char* ToString( - /* [in] */ SharedData* header) - { - return reinterpret_cast(header + 1); - } - - inline static SharedData* GetHeader( - /* [in] */ const void* handle) - { - return reinterpret_cast(const_cast(handle)) - 1; - } - - std::atomic refCount_; - int size_; -}; - -SharedData* SharedData::Allocate( - /* [in] */ int size) -{ - if (size < 0) { - Logger::E(String::TAG, "Size %d is illegal.", size); - return nullptr; - } - if (size > String::MAX_SIZE) { - Logger::E(String::TAG, "The string is too large to alloc."); - return nullptr; - } - - SharedData* handle = reinterpret_cast(malloc(sizeof(SharedData) + size + 1)); - if (handle == nullptr) { - Logger::E(String::TAG, "Fail to malloc %lu bytes memory", size); - return handle; - } - - new (handle)SharedData(1, size); - return handle; -} - -void SharedData::AddRef( - /* [in] */ const void* handle) -{ - if (handle == nullptr) { - return; - } - - SharedData* data = GetHeader(handle); - int before = data->refCount_.fetch_add(1); - if (before + 1 <= 1) { - Logger::E(String::TAG, "The refCount %d of %p is error in AddRef.", before, data); - }; -} - -void SharedData::Release( - /* [in] */ const void* handle) -{ - if (handle == nullptr) { - return; - } - - SharedData* data = GetHeader(handle); - int before = data->refCount_.fetch_sub(1); - if (before - 1 == 0) { - free(data); - } else if (before - 1 < 0) { - Logger::E(String::TAG, "The refCount %d of %p is error in Release.", before - 1, data); - }; -} - - -const char* String::TAG = "String"; - -String::String( - /* [in] */ const char* string) -{ - if (string != nullptr) { - string_ = SharedData::ToString(SharedData::Allocate(strlen(string))); - if (string_ != nullptr) { - (void)strcpy_s(string_, strlen(string) + 1, string); - } - } -} - -String::String( - /* [in] */ const char* string, - /* [in] */ size_t length) -{ - if (string != nullptr) { - string_ = SharedData::ToString(SharedData::Allocate(length)); - if (string_ != nullptr) { - errno_t ret = memcpy_s(string_, length + 1, string, length); - if (ret == EOK) { - string_[length] = '\0'; - } else { - free(string_); - string_ = nullptr; - } - } - } -} - -String::String( - /* [in] */ const String& other) -{ - string_ = other.string_; - SharedData::AddRef(string_); -} - -String::String( - /* [in] */ String&& other) -{ - string_ = other.string_; - other.string_ = nullptr; -} - -String::String( - /* [in] */ int size) -{ - string_ = SharedData::ToString(SharedData::Allocate(size)); - if (string_ != nullptr) { - (void)memset_s(string_, size + 1, 0, size + 1); - } -} - -String::~String() -{ - SharedData::Release(string_); -} - -int String::GetLength() const -{ - if (string_ == nullptr) { - return 0; - } - - return SharedData::GetHeader(string_)->size_; -} - -char String::operator[]( - /* [in] */ int index) const -{ - if (index < 0 || index >= GetLength()) { - return '\0'; - } - return string_[index]; -} - -bool String::Equals( - /* [in] */ const char* string) const -{ - if (string_ == nullptr && string == nullptr) { - return true; - } - - if (string != nullptr && string_ != nullptr) { - if ((size_t)GetLength() != strlen(string)) { - return false; - } - return strcmp(string, string_) == 0; - } - - return false; -} - -bool String::Equals( - /* [in] */ const String& other) const -{ - if (string_ == nullptr && other.string_ == nullptr) { - return true; - } - - if (string_ != nullptr && other.string_ != nullptr) { - if (GetLength() != other.GetLength()) { - return false; - } - return strcmp(string_, other.string_) == 0; - } - return false; -} - -int String::GetHashCode() const -{ - // BKDR Hash Function - unsigned int seed = 31; // 31 131 1313 13131 131313 etc.. - unsigned int hash = 0; - - const char* string = string_; - if (string != nullptr) { - for ( ; *string; ++string) { - hash = hash * seed + (*string); - } - } - return (hash & 0x7FFFFFFF); -} - -int String::IndexOf( - /* [in] */ char c, - /* [in] */ int fromIndex) const -{ - if (IsEmpty() || c == '\0') { - return -1; - } - - if (fromIndex < 0) { - fromIndex = 0; - } else if (fromIndex >= GetLength()) { - return -1; - } - - char* p = string_ + fromIndex; - char* end = string_ + GetLength(); - while (p != end) { - if (*p == c) { - return p - string_; - } - p++; - } - return -1; -} - -int String::IndexOf( - /* [in] */ const char* string, - /* [in] */ int fromIndex) const -{ - if (IsEmpty() || string == nullptr || string[0] == '\0') { - return -1; - } - - if (fromIndex < 0) { - fromIndex = 0; - } else if (fromIndex >= GetLength()) { - return -1; - } - - char* c = strstr(string_ + fromIndex, string); - return c != nullptr ? c - string_ : -1; -} - -int String::IndexOf( - /* [in] */ const String& other, - /* [in] */ int fromIndex) const -{ - if (IsEmpty() || other.IsEmpty()) { - return -1; - } - - if (fromIndex < 0) { - fromIndex = 0; - } else if (fromIndex >= GetLength()) { - return -1; - } - - char* c = strstr(string_ + fromIndex, other.string_); - return c != nullptr ? c - string_ : -1; -} - -int String::LastIndexOf( - /* [in] */ char c, - /* [in] */ int fromIndex) const -{ - if (IsEmpty() || c == '\0') { - return -1; - } - - if (fromIndex < 0) { - return -1; - } else if (fromIndex == 0 || fromIndex >= GetLength()) { - fromIndex = GetLength() - 1; - } - char* p = string_ + fromIndex; - while (p != string_) { - if (*p == c) { - return p - string_; - } - p--; - } - return -1; -} - -int String::LastIndexOf( - /* [in] */ const char* string, - /* [in] */ int fromIndex) const -{ - if (IsEmpty() || string == nullptr || string[0] == '\0') { - return -1; - } - - if (fromIndex < 0) { - return -1; - } else if (fromIndex == 0 || fromIndex >= GetLength()) { - fromIndex = GetLength() - 1; - } - - return LastIndexOfInternal(string, fromIndex); -} - -int String::LastIndexOf( - /* [in] */ const String& other, - /* [in] */ int fromIndex) const -{ - if (IsEmpty() || other.IsEmpty()) { - return -1; - } - - if (fromIndex < 0) { - return -1; - } else if (fromIndex == 0 || fromIndex >= GetLength()) { - fromIndex = GetLength() - 1; - } - - return LastIndexOfInternal(other.string(), fromIndex); -} - -int String::LastIndexOfInternal( - /* [in] */ const char* string, - /* [in] */ int fromIndex) const -{ - int sourceLen = GetLength(); - int stringLen = strlen(string); - int rightIndex = sourceLen - stringLen; - if (fromIndex > rightIndex) { - fromIndex = rightIndex; - } - - int stringLastIndex = stringLen - 1; - char stringLastChar = string[stringLastIndex]; - int min = stringLen - 1; - int i = min + fromIndex; - -startSearchLastChar: - while (true) { - while (i >= min && string_[i] != stringLastChar) { - i--; - } - if (i < min) { - return -1; - } - int j = i - 1; - int start = j - (stringLen - 1); - int k = stringLastIndex - 1; - - while (j > start) { - if (string_[j--] != string[k--]) { - i--; - goto startSearchLastChar; - } - } - return start + 1; - } -} - -bool String::StartsWith( - /* [in] */ const char* string) const -{ - if (string == nullptr || string_ == nullptr) { - return false; - } - - if (string[0] == '\0' && string_[0] == '\0') { - return true; - } - - size_t count = strlen(string); - if (count > (size_t)GetLength()) { - return false; - } - - return memcmp(string_, string, count) == 0; -} - -bool String::StartsWith( - /* [in] */ const String& other) const -{ - if (other.string_ == nullptr || string_ == nullptr) { - return false; - } - - if (other.string_[0] == '\0' && string_[0] == '\0') { - return true; - } - - size_t count = other.GetLength(); - if (count > (size_t)GetLength()) { - return false; - } - - return memcmp(string_, other.string_, count) == 0; -} - -bool String::EndsWith( - /* [in] */ const char* string) const -{ - if (string == nullptr || string_ == nullptr) { - return false; - } - - if (string[0] == '\0') { - return true; - } - - size_t count = strlen(string); - size_t len = GetLength(); - if (count > len) { - return false; - } - - return memcmp(string_ + len - count, string, count) == 0; -} - -bool String::EndsWith( - /* [in] */ const String& other) const -{ - if (other.string_ == nullptr || string_ == nullptr) { - return false; - } - - if (other.string_[0] == '\0') { - return true; - } - - size_t count = other.GetLength(); - size_t len = GetLength(); - if (count > len) { - return false; - } - - return memcmp(string_ + len - count, other.string_, count) == 0; -} - -String String::ToLowerCase() const -{ - if (IsEmpty()) { - return *this; - } - - size_t size = GetLength(); - for (size_t i = 0; i < size; i++) { - if (isupper(string_[i])) { - String newStr(string_); - for (size_t j = i; j < size; j++) { - newStr.string_[j] = tolower(newStr.string_[j]); - } - return newStr; - } - } - return *this; -} - -String String::ToUpperCase() const -{ - if (IsEmpty()) { - return *this; - } - - size_t size = GetLength(); - for (size_t i = 0; i < size; i++) { - if (islower(string_[i])) { - String newStr(string_); - for (size_t j = i; j < size; j++) { - newStr.string_[j] = toupper(newStr.string_[j]); - } - return newStr; - } - } - return *this; -} - -String String::Substring( - /* [in] */ int begin) const -{ - if (begin < 0 || begin >= GetLength()) { - return String(); - } - - return String(string_ + begin); -} - -String String::Substring( - /* [in] */ int begin, - /* [in] */ int end) const -{ - if (begin < 0 || end > GetLength() || begin > end) { - return String(); - } - - return String(string_ + begin, end - begin); -} - -String String::Replace( - /* [in] */ char oldChar, - /* [in] */ char newChar) const -{ - if (oldChar == newChar) { - return *this; - } - - size_t size = GetLength(); - for (size_t i = 0; i < size; i++) { - if (string_[i] == oldChar) { - String newStr(string_); - for (size_t j = i; j < size; j++) { - if (newStr.string_[j] == oldChar) { - newStr.string_[j] = newChar; - } - } - return newStr; - } - } - return *this; -} - -String String::Replace( - /* [in] */ const char* target, - /* [in] */ const char* replacement) const -{ - if (target == nullptr || target[0] == '\0' || replacement == nullptr) { - return *this; - } - - int index = IndexOf(target); - if (index == -1) { - return *this; - } - - StringBuilder sb; - int begin = 0; - int step = strlen(target); - while (index != -1) { - sb.Append(Substring(begin, index)); - sb.Append(replacement); - begin = index + step; - index = IndexOf(target, begin); - } - sb.Append(Substring(begin)); - return sb.ToString(); -} - -String String::Replace( - /* [in] */ const String& target, - /* [in] */ const String& replacement) const -{ - if (target.IsEmpty() || replacement.IsNull()) { - return *this; - } - - int index = IndexOf(target); - if (index== -1) { - return *this; - } - - StringBuilder sb; - int begin = 0; - int step = target.GetLength(); - while (index != -1) { - sb.Append(Substring(begin, index)); - sb.Append(replacement); - begin = index + step; - index = IndexOf(target, begin); - } - sb.Append(Substring(begin)); - return sb.ToString(); -} - -String& String::operator=( - /* [in] */ const char* string) -{ - SharedData::Release(string_); - - if (string == nullptr) { - string_ = nullptr; - return *this; - } - - string_ = SharedData::ToString(SharedData::Allocate(strlen(string))); - if (string_ != nullptr) { - (void)strcpy_s(string_, strlen(string) + 1, string); - } - return *this; -} - -String& String::operator=( - /* [in] */ const String& other) -{ - if (string_ == other.string_) { - return *this; - } - - SharedData::Release(string_); - SharedData::AddRef(other.string_); - string_ = other.string_; - return *this; -} - -String& String::operator=( - /* [in] */ String&& other) -{ - SharedData::Release(string_); - string_ = other.string_; - other.string_ = nullptr; - return *this; -} - -String String::operator+=( - /* [in] */ const char* string) const -{ - if (string == nullptr || string[0] == '\0') { - return *this; - } - - int thisSize = GetLength(); - int newSize = thisSize + strlen(string); - String newString(newSize); - if (newString.string_ != nullptr) { - (void)memcpy_s(newString.string_, newSize + 1, string_, thisSize); - (void)strcpy_s(newString.string_ + thisSize, newSize + 1 - thisSize, string); - } - return newString; -} - -String String::operator+=( - /* [in] */ const String& other) const -{ - if (other.IsEmpty()) { - return *this; - } - - int thisSize = GetLength(); - int newSize = thisSize + other.GetLength(); - String newString(newSize); - if (newString.string_ != nullptr) { - (void)memcpy_s(newString.string_, newSize + 1, string_, thisSize); - (void)strcpy_s(newString.string_ + thisSize, newSize + 1 - thisSize, other.string_); - } - return newString; -} - -String String::Format( - /* [in] */ const char* format, ...) -{ - va_list args, argsCopy; - - va_start(args, format); - va_copy(argsCopy, args); - - char buf[LINE_MAX_SIZE] = {0}; - int len = vsnprintf_s(buf, LINE_MAX_SIZE, LINE_MAX_SIZE - 1, format, args); - String string; - if (len <= 0) { - va_end(args); - va_end(argsCopy); - return string; - } - - string = String(len); - if (string.string_ == nullptr) { - va_end(args); - va_end(argsCopy); - return string; - } - - if (vsnprintf_s(string.string_, len + 1, len, format, argsCopy) < 0) { - va_end(args); - va_end(argsCopy); - return string; - } - - va_end(args); - va_end(argsCopy); - return string; -} - -} -} diff --git a/zidl/util/string.h b/zidl/util/string.h deleted file mode 100644 index d0f3250315b..00000000000 --- a/zidl/util/string.h +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_STRING_H -#define OHOS_ZIDL_STRING_H - -#include - -namespace OHOS { -namespace Zidl { - -class String { -public: - inline String() - {} - - String( - /* [in] */ const char* string); - - String( - /* [in] */ const char* string, - /* [in] */ size_t length); - - String( - /* [in] */ const String& other); - - String( - /* [in] */ String&& other); - - ~String(); - - inline const char* string() const - { - return string_; - } - - inline operator const char*() const - { - return string_; - } - - inline bool IsNull() const - { - return string_ == nullptr; - } - - inline bool IsEmpty() const - { - return string_ == nullptr || string_[0] == '\0'; - } - - int GetLength() const; - - char operator[]( - /* [in] */ int index) const; - - bool Equals( - /* [in] */ const char* string) const; - - bool Equals( - /* [in] */ const String& other) const; - - int GetHashCode() const; - - int IndexOf( - /* [in] */ char c, - /* [in] */ int fromIndex = 0) const; - - int IndexOf( - /* [in] */ const char* string, - /* [in] */ int fromIndex = 0) const; - - int IndexOf( - /* [in] */ const String& other, - /* [in] */ int fromIndex = 0) const; - - int LastIndexOf( - /* [in] */ char c, - /* [in] */ int fromIndex = 0) const; - - int LastIndexOf( - /* [in] */ const char* string, - /* [in] */ int fromIndex = 0) const; - - int LastIndexOf( - /* [in] */ const String& other, - /* [in] */ int fromIndex = 0) const; - - bool StartsWith( - /* [in] */ const char* string) const; - - bool StartsWith( - /* [in] */ const String& other) const; - - bool EndsWith( - /* [in] */ const char* string) const; - - bool EndsWith( - /* [in] */ const String& other) const; - - String ToLowerCase() const; - - String ToUpperCase() const; - - String Substring( - /* [in] */ int begin) const; - - String Substring( - /* [in] */ int begin, - /* [in] */ int end) const; - - String Replace( - /* [in] */ char oldChar, - /* [in] */ char newChar) const; - - String Replace( - /* [in] */ const char* target, - /* [in] */ const char* replacement) const; - - String Replace( - /* [in] */ const String& target, - /* [in] */ const String& replacement) const; - - String& operator=( - /* [in] */ const char* string); - - String& operator=( - /* [in] */ const String& other); - - String& operator=( - /* [in] */ String&& other); - - String operator+=( - /* [in] */ const char* string) const; - - String operator+=( - /* [in] */ const String& other) const; - - static String Format( - /* [in] */ const char* format, ...); - - static const char* TAG; - static constexpr int MAX_SIZE = 262144; // 2^18 - -private: - String( - /* [in] */ int size); - - int LastIndexOfInternal( - /* [in] */ const char* string, - /* [in] */ int fromIndex) const; - - char* string_ = nullptr; -}; - -inline String operator+( - /* [in] */ const String& string1, - /* [in] */ const char* string2) -{ - return string1 += string2; -} - -struct StringHashFunc { - int operator()(const String& key) const - { - return key.GetHashCode(); - } -}; - -struct StringEqualFunc { - bool operator()(const String& lhs, const String& rhs) const - { - return lhs.Equals(rhs); - } -}; - -} -} - -#endif // OHOS_ZIDL_STRING_H diff --git a/zidl/util/string_builder.cpp b/zidl/util/string_builder.cpp deleted file mode 100644 index e2caea4b583..00000000000 --- a/zidl/util/string_builder.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "util/string_builder.h" - -#include -#include -#include -#include "securec.h" - -#include "util/logger.h" - -namespace OHOS { -namespace Zidl { - -const char* StringBuilder::TAG = "StringBuilder"; -constexpr int LINE_MAX_SIZE = 1024; - -StringBuilder::~StringBuilder() -{ - if (buffer_ != nullptr) { - free(buffer_); - } -} - -StringBuilder& StringBuilder::Append( - /* [in] */ char c) -{ - if (position_ + 1 >= capacity_) { - if (!Grow(1)) { - return *this; - } - } - - buffer_[position_] = c; - position_ += 1; - return *this; -} - -StringBuilder& StringBuilder::Append( - /* [in] */ const char* string) -{ - if (string == nullptr || string[0] == '\0') { - return *this; - } - - size_t len = strlen(string); - if (position_ + len >= capacity_) { - if (!Grow(len)) { - return *this; - } - } - - (void)memcpy_s(buffer_ + position_, capacity_ - position_, string, len); - position_ += len; - return *this; -} - -StringBuilder& StringBuilder::Append( - /* [in] */ const String& string) -{ - if (string.IsEmpty()) { - return *this; - } - - size_t len = string.GetLength(); - if (position_ + len >= capacity_) { - if (!Grow(len)) { - return *this; - } - } - - (void)memcpy_s(buffer_ + position_, capacity_ - position_, string.string(), len); - position_ += len; - return *this; -} - -StringBuilder& StringBuilder::AppendFormat( - /* [in] */ const char* format, ...) -{ - va_list args, argsCopy; - - va_start(args, format); - va_copy(argsCopy, args); - - char buf[LINE_MAX_SIZE] = {0}; - int len = vsnprintf_s(buf, LINE_MAX_SIZE, LINE_MAX_SIZE - 1, format, args); - if (len <= 0) { - va_end(args); - va_end(argsCopy); - return *this; - } - - if (position_ + len >= capacity_) { - if (!Grow(len)) { - va_end(args); - va_end(argsCopy); - return *this; - } - } - - if (vsnprintf_s(buffer_ + position_, len + 1, len, format, argsCopy) < 0) { - va_end(args); - va_end(argsCopy); - return *this; - } - position_ += len; - va_end(args); - va_end(argsCopy); - - return *this; -} - -bool StringBuilder::Grow( - /* [in] */ size_t size) -{ - if (capacity_ > String::MAX_SIZE) { - Logger::E(TAG, "The StringBuilder is full."); - return false; - } - // 256->the default capacity. - size_t newSize = (capacity_ == 0 ? 256 : capacity_ * 2); - if (newSize < capacity_ + size) { - newSize = capacity_ + size; - } - if (newSize > String::MAX_SIZE) { - newSize = String::MAX_SIZE; - } - if (newSize <= capacity_) { - return false; - } - - char* newBuffer = reinterpret_cast(calloc(newSize, 1)); - if (newBuffer == nullptr) { - Logger::E(TAG, "Fail to malloc %lu bytes memory.", newSize); - return false; - } - - if (buffer_ != nullptr) { - errno_t ret = memcpy_s(newBuffer, newSize, buffer_, capacity_); - if (ret != EOK) { - free(newBuffer); - newBuffer = nullptr; - return false; - } - free(buffer_); - } - buffer_ = newBuffer; - capacity_ = newSize; - return true; -} - -String StringBuilder::ToString() const -{ - return String(buffer_, position_); -} - -} -} diff --git a/zidl/util/string_builder.h b/zidl/util/string_builder.h deleted file mode 100644 index 54f4331d27c..00000000000 --- a/zidl/util/string_builder.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_STRINGBUILDER_H -#define OHOS_ZIDL_STRINGBUILDER_H - -#include "util/string.h" - -namespace OHOS { -namespace Zidl { - -class StringBuilder { -public: - ~StringBuilder(); - - StringBuilder& Append( - /* [in] */ char c); - - StringBuilder& Append( - /* [in] */ const char* string); - - StringBuilder& Append( - /* [in] */ const String& string); - - StringBuilder& AppendFormat( - /* [in] */ const char* format, ...); - - String ToString() const; - -private: - bool Grow( - /* [in] */ size_t size); - - static const char* TAG; - char* buffer_ = nullptr; - size_t position_ = 0; - size_t capacity_ = 0; -}; - -} -} - -#endif // OHOS_ZIDL_STRINGBUILDER_H diff --git a/zidl/util/string_pool.cpp b/zidl/util/string_pool.cpp deleted file mode 100644 index 026bcffdeec..00000000000 --- a/zidl/util/string_pool.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "util/string_pool.h" -#include -#include "securec.h" -#include "util/logger.h" - -namespace OHOS { -namespace Zidl { - -const char* StringPool::TAG = "StringPool"; - -StringPool::StringPool() -{ - data_ = reinterpret_cast(calloc(1, dataCapacity_)); - if (data_ == nullptr) { - Logger::E(TAG, "Out of memory."); - } -} - -StringPool::~StringPool() -{ - if (data_ != nullptr) { - free(data_); - } -} - -void StringPool::Add( - /* [in] */ const String& string) -{ - if (string.IsEmpty() || stringOffsets_.find(string) != stringOffsets_.end()) { - return; - } - - ptrdiff_t offset = AddInternal(string); - if (offset != -1) { - stringOffsets_[string] = offset; - } -} - -ptrdiff_t StringPool::GetOffset( - /* [in] */ const String& string) -{ - return stringOffsets_[string]; -} - -ptrdiff_t StringPool::AddInternal( - /* [in] */ const String& string) -{ - if (!Grow(string.GetLength() + 1)) { - return -1; - } - - char* addr = data_ + dataOffset_; - (void)strcpy_s(addr, dataCapacity_ - dataOffset_, string.string()); - dataOffset_ += string.GetLength() + 1; - return addr - data_; -} - -bool StringPool::Grow( - /* [in] */ size_t expand) -{ - size_t newSize = dataOffset_ + expand; - if (newSize < dataCapacity_) { - return true; - } - // 3->3x capacity expansion - size_t step = dataCapacity_ * 3; - newSize = step > newSize ? step : step + newSize; - char* newData = reinterpret_cast(calloc(1, newSize)); - if (newData == nullptr) { - Logger::E(TAG, "Out of memory."); - return false; - } - errno_t ret = memcpy_s(newData, newSize, data_, dataOffset_); - if (ret != EOK) { - free(newData); - newData = nullptr; - return false; - } - free(data_); - data_ = newData; - dataCapacity_ = newSize; - return true; -} - -} -} diff --git a/zidl/util/string_pool.h b/zidl/util/string_pool.h deleted file mode 100644 index 7b991512c4c..00000000000 --- a/zidl/util/string_pool.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ZIDL_STRINGPOOL_H -#define OHOS_ZIDL_STRINGPOOL_H - -#include -#include "util/string.h" - -namespace OHOS { -namespace Zidl { - -class StringPool { -public: - StringPool(); - - ~StringPool(); - - void Add( - /* [in] */ const String& string); - - ptrdiff_t GetOffset( - /* [in] */ const String& string); - - inline size_t GetSize() - { - return dataOffset_; - } - - inline char* GetData() - { - return data_; - } - -private: - ptrdiff_t AddInternal( - /* [in] */ const String& string); - - bool Grow( - /* [in] */ size_t expand); - - static const char* TAG; - char* data_ = nullptr; - size_t dataCapacity_ = 256; - ptrdiff_t dataOffset_ = 0; - std::unordered_map stringOffsets_; -}; - -} -} - -#endif // OHOS_ZIDL_STRINGPOOL_H -- Gitee