From 218aa217d2d3e7ca3c058814d814b062bd5698f6 Mon Sep 17 00:00:00 2001 From: Caoruihong Date: Tue, 28 Nov 2023 23:32:16 +0800 Subject: [PATCH] opt: move container consts to container_consts.h Signed-off-by: Caoruihong --- frameworks/core/common/container.h | 19 +--------- frameworks/core/common/container_consts.h | 41 ++++++++++++++++++++++ frameworks/core/common/container_scope.cpp | 2 +- frameworks/core/common/hdc_register.cpp | 3 +- 4 files changed, 44 insertions(+), 21 deletions(-) create mode 100755 frameworks/core/common/container_consts.h diff --git a/frameworks/core/common/container.h b/frameworks/core/common/container.h index b1414f44278..c639ea0684b 100755 --- a/frameworks/core/common/container.h +++ b/frameworks/core/common/container.h @@ -40,6 +40,7 @@ #include "core/components_ng/pattern/navigator/navigator_event_hub.h" #include "core/event/pointer_event.h" #include "core/pipeline/pipeline_base.h" +#include "core/common/container_consts.h" namespace OHOS::Ace { @@ -53,24 +54,6 @@ using CardViewPositionCallBack = std::function; using StopDragCallback = std::function; -enum ContainerType { - STAGE_CONTAINER = 1, - FA_CONTAINER, - PA_SERVICE_CONTAINER, - PA_DATA_CONTAINER, - PA_FORM_CONTAINER, - FA_SUBWINDOW_CONTAINER, - COMPONENT_SUBWINDOW_CONTAINER = 10, - PLUGIN_SUBCONTAINER = 20, -}; - -constexpr int32_t INSTANCE_ID_UNDEFINED = -1; -constexpr int32_t INSTANCE_ID_PLATFORM = -2; -constexpr int32_t CONTAINER_ID_DIVIDE_SIZE = 100000; -constexpr int32_t MIN_PLUGIN_SUBCONTAINER_ID = PLUGIN_SUBCONTAINER * CONTAINER_ID_DIVIDE_SIZE; -constexpr int32_t MIN_SUBCONTAINER_ID = COMPONENT_SUBWINDOW_CONTAINER * CONTAINER_ID_DIVIDE_SIZE; -constexpr int32_t MIN_PA_SERVICE_ID = PA_SERVICE_CONTAINER * CONTAINER_ID_DIVIDE_SIZE; - class ACE_FORCE_EXPORT Container : public virtual AceType { DECLARE_ACE_TYPE(Container, AceType); diff --git a/frameworks/core/common/container_consts.h b/frameworks/core/common/container_consts.h new file mode 100755 index 00000000000..473cf608240 --- /dev/null +++ b/frameworks/core/common/container_consts.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_CONTAINER_CONSTS_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_CONTAINER_CONSTS_H + +#include + +namespace OHOS::Ace { +enum ContainerType { + STAGE_CONTAINER = 1, + FA_CONTAINER, + PA_SERVICE_CONTAINER, + PA_DATA_CONTAINER, + PA_FORM_CONTAINER, + FA_SUBWINDOW_CONTAINER, + COMPONENT_SUBWINDOW_CONTAINER = 10, + PLUGIN_SUBCONTAINER = 20, +}; + +constexpr int32_t INSTANCE_ID_UNDEFINED = -1; +constexpr int32_t INSTANCE_ID_PLATFORM = -2; +constexpr int32_t CONTAINER_ID_DIVIDE_SIZE = 100000; +constexpr int32_t MIN_PLUGIN_SUBCONTAINER_ID = PLUGIN_SUBCONTAINER * CONTAINER_ID_DIVIDE_SIZE; +constexpr int32_t MIN_SUBCONTAINER_ID = COMPONENT_SUBWINDOW_CONTAINER * CONTAINER_ID_DIVIDE_SIZE; +constexpr int32_t MIN_PA_SERVICE_ID = PA_SERVICE_CONTAINER * CONTAINER_ID_DIVIDE_SIZE; +} // namespace OHOS::Ace + +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_CONTAINER_CONSTS_H diff --git a/frameworks/core/common/container_scope.cpp b/frameworks/core/common/container_scope.cpp index 61415453826..5aec2206a40 100644 --- a/frameworks/core/common/container_scope.cpp +++ b/frameworks/core/common/container_scope.cpp @@ -14,7 +14,7 @@ */ #include "core/common/container_scope.h" -#include "core/common/container.h" +#include "core/common/container_consts.h" #include "base/utils/utils.h" namespace OHOS::Ace { diff --git a/frameworks/core/common/hdc_register.cpp b/frameworks/core/common/hdc_register.cpp index 362693e5f60..9e4eb380282 100644 --- a/frameworks/core/common/hdc_register.cpp +++ b/frameworks/core/common/hdc_register.cpp @@ -22,14 +22,13 @@ #include "base/log/log.h" #include "base/utils/utils.h" #include "core/common/ace_application_info.h" +#include "core/common/container_consts.h" namespace OHOS::Ace { namespace { using StartRegister = void (*)( const std::string& processName, const std::string& pkgName, bool debugApp, const Callback& callbac); using StopRegister = void (*)(); -// defined in container.h -constexpr int32_t CONTAINER_ID_DIVIDE_SIZE = 100000; } // namespace HdcRegister::HdcRegister(): registerHandler_(nullptr) -- Gitee