diff --git a/dom/include/dom/animation/animation_manager.h b/dom/include/dom/animation/animation_manager.h index 1b812b4f7..71b72ff1e 100644 --- a/dom/include/dom/animation/animation_manager.h +++ b/dom/include/dom/animation/animation_manager.h @@ -48,6 +48,9 @@ class AnimationManager public: AnimationManager(); + AnimationManager(AnimationManager&) = delete; + AnimationManager& operator=(AnimationManager&) = delete; + inline std::weak_ptr GetRootNode() { return root_node_; } @@ -132,8 +135,6 @@ class AnimationManager */ std::unordered_map> node_animation_props_map_; uint64_t listener_id_; - - FOOTSTONE_DISALLOW_COPY_AND_ASSIGN(AnimationManager); }; } // namespace dom } // namespace hippy diff --git a/dom/include/dom/dom_manager.h b/dom/include/dom/dom_manager.h index 46bb46f55..4ebe406da 100644 --- a/dom/include/dom/dom_manager.h +++ b/dom/include/dom/dom_manager.h @@ -75,6 +75,9 @@ class DomManager : public std::enable_shared_from_this { DomManager(); ~DomManager(); + DomManager(DomManager&) = delete; + DomManager& operator=(DomManager&) = delete; + inline int32_t GetId() { return id_; } inline std::weak_ptr GetRenderManager() { return render_manager_; } inline std::shared_ptr GetTaskRunner() { return dom_task_runner_; } @@ -134,8 +137,6 @@ class DomManager : public std::enable_shared_from_this { std::weak_ptr render_manager_; std::shared_ptr dom_task_runner_; - FOOTSTONE_DISALLOW_COPY_AND_ASSIGN(DomManager); - friend DomNode; }; diff --git a/dom/include/dom/macro.h b/dom/include/dom/macro.h deleted file mode 100644 index 3a0f0ea49..000000000 --- a/dom/include/dom/macro.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) 2020 Tencent Corporation. All rights reserved. -// - -#define WEAK_THIS weak_this = weak_from_this() -#define SHARED_THIS self = this->shared_from_this() -// 表明该lambda不会被存储,可以安全使用this -#define THIS_NO_STORE this -#define HAS_SELF(type) auto self = std::static_pointer_cast(weak_this.lock()) -#define DEFINE_SELF(type) HAS_SELF(type); -#define DEFINE_AND_CHECK_SELF(type) \ - DEFINE_SELF(type) \ - if (!self) { \ - return; \ - } diff --git a/dom/src/dom/animation/animation_manager.cc b/dom/src/dom/animation/animation_manager.cc index 856373e46..8ab1b78ad 100644 --- a/dom/src/dom/animation/animation_manager.cc +++ b/dom/src/dom/animation/animation_manager.cc @@ -11,7 +11,6 @@ #include "footstone/base_time.h" #include "dom/dom_node.h" -#include "dom/macro.h" #include "dom/node_props.h" #include "dom/render_manager.h" #include "dom/root_node.h" diff --git a/dom/src/dom/dom_manager.cc b/dom/src/dom/dom_manager.cc index 295f2d9ad..be617e9f3 100644 --- a/dom/src/dom/dom_manager.cc +++ b/dom/src/dom/dom_manager.cc @@ -12,7 +12,6 @@ #include "dom/dom_event.h" #include "dom/dom_node.h" #include "dom/layer_optimized_render_manager.h" -#include "dom/macro.h" #include "dom/render_manager.h" #include "dom/root_node.h" #include "footstone/serializer.h" diff --git a/dom/src/dom/dom_node.cc b/dom/src/dom/dom_node.cc index da163bbc3..449a20320 100644 --- a/dom/src/dom/dom_node.cc +++ b/dom/src/dom/dom_node.cc @@ -4,7 +4,6 @@ #include #include "footstone/logging.h" #include "dom/diff_utils.h" -#include "dom/macro.h" #include "dom/node_props.h" #include "dom/render_manager.h" #include "dom/root_node.h" diff --git a/driver/js/core/src/devtools/adapter/impl/hippy_screen_adapter.cc b/driver/js/core/src/devtools/adapter/impl/hippy_screen_adapter.cc index 685bb4568..f538e9516 100644 --- a/driver/js/core/src/devtools/adapter/impl/hippy_screen_adapter.cc +++ b/driver/js/core/src/devtools/adapter/impl/hippy_screen_adapter.cc @@ -22,7 +22,6 @@ #include "dom/dom_manager.h" #include "dom/dom_node.h" -#include "dom/macro.h" namespace hippy::devtools { constexpr char kScreenShot[] = "screenShot"; diff --git a/modules/footstone/include/footstone/base_timer.h b/modules/footstone/include/footstone/base_timer.h index 5fedd0354..f3df9a532 100644 --- a/modules/footstone/include/footstone/base_timer.h +++ b/modules/footstone/include/footstone/base_timer.h @@ -40,6 +40,9 @@ class BaseTimer { explicit BaseTimer(const std::shared_ptr& task_runner); virtual ~BaseTimer(); + BaseTimer(BaseTimer&) = delete; + BaseTimer& operator=(BaseTimer&) = delete; + void Stop(); void Reset(); inline void BindTaskRunner(std::shared_ptr task_runner) { @@ -65,8 +68,6 @@ class BaseTimer { bool is_running_; TimePoint desired_run_time_; TimePoint scheduled_run_time_; - - FOOTSTONE_DISALLOW_COPY_AND_ASSIGN(BaseTimer); }; } // namespace timer diff --git a/modules/footstone/include/footstone/idle_timer.h b/modules/footstone/include/footstone/idle_timer.h index a9a0c6c24..37ca57630 100644 --- a/modules/footstone/include/footstone/idle_timer.h +++ b/modules/footstone/include/footstone/idle_timer.h @@ -35,6 +35,9 @@ class IdleTimer : public BaseTimer { explicit IdleTimer(std::shared_ptr task_runner); virtual ~IdleTimer(); + IdleTimer(IdleTimer&) = delete; + IdleTimer& operator=(IdleTimer&) = delete; + virtual void Start(std::unique_ptr idle_task, TimeDelta timeout); virtual void Start(std::unique_ptr idle_task); @@ -43,8 +46,6 @@ class IdleTimer : public BaseTimer { void RunUserTask() final; std::shared_ptr idle_task_ ; - - FOOTSTONE_DISALLOW_COPY_AND_ASSIGN(IdleTimer); }; } diff --git a/modules/footstone/include/footstone/logging.h b/modules/footstone/include/footstone/logging.h index 328944d6f..ce54039b9 100644 --- a/modules/footstone/include/footstone/logging.h +++ b/modules/footstone/include/footstone/logging.h @@ -90,6 +90,9 @@ class LogMessage { LogMessage(LogSeverity severity, const char* file, int line, const char* condition); ~LogMessage(); + LogMessage(LogMessage&) = delete; + LogMessage& operator=(LogMessage&) = delete; + inline static void InitializeDelegate( std::function delegate) { if (!delegate) { @@ -114,8 +117,6 @@ class LogMessage { const LogSeverity severity_; const char* file_; const int line_; - - FOOTSTONE_DISALLOW_COPY_AND_ASSIGN(LogMessage); }; int GetVlogVerbosity(); diff --git a/modules/footstone/include/footstone/macros.h b/modules/footstone/include/footstone/macros.h index 577c9a6f3..fb3a6a588 100644 --- a/modules/footstone/include/footstone/macros.h +++ b/modules/footstone/include/footstone/macros.h @@ -20,42 +20,16 @@ #pragma once -#define FOOTSTONE_EMBEDDER_ONLY - -#define FOOTSTONE_DISALLOW_COPY(TypeName) TypeName(const TypeName&) = delete - -#define FOOTSTONE_DISALLOW_ASSIGN(TypeName) TypeName& operator=(const TypeName&) = delete - -#define FOOTSTONE_DISALLOW_MOVE(TypeName) \ - TypeName(TypeName&&) = delete; \ - TypeName& operator=(TypeName&&) = delete - -#define FOOTSTONE_DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&) = delete; \ - TypeName& operator=(const TypeName&) = delete - -#define FOOTSTONE_DISALLOW_COPY_ASSIGN_AND_MOVE(TypeName) \ - TypeName(const TypeName&) = delete; \ - TypeName(TypeName&&) = delete; \ - TypeName& operator=(const TypeName&) = delete; \ - TypeName& operator=(TypeName&&) = delete - -#define FOOTSTONE_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ - TypeName() = delete; \ - FOOTSTONE_DISALLOW_COPY_ASSIGN_AND_MOVE(TypeName) - -#ifdef NDEBUG -#define assert_fn(fn) ((void)0) -#else -#define assert_fn(fn) \ - do { \ - auto b = fn(); \ - assert(b); \ - } while (0) -#endif - -#define RETURN_IF(x) \ - if (x) { \ - return; \ +#define WEAK_THIS weak_this = weak_from_this() +#define SHARED_THIS self = this->shared_from_this() +// 表明该lambda不会被存储,可以安全使用this +#define THIS_NO_STORE this +#define HAS_SELF(type) auto self = std::static_pointer_cast(weak_this.lock()) +#define DEFINE_SELF(type) HAS_SELF(type); +#define DEFINE_AND_CHECK_SELF(type) \ + DEFINE_SELF(type) \ + if (!self) { \ + return; \ } + diff --git a/modules/footstone/include/footstone/one_shot_timer.h b/modules/footstone/include/footstone/one_shot_timer.h index 324ca8b94..885f271dc 100644 --- a/modules/footstone/include/footstone/one_shot_timer.h +++ b/modules/footstone/include/footstone/one_shot_timer.h @@ -35,6 +35,9 @@ inline namespace timer { explicit OneShotTimer(const std::shared_ptr& task_runner); virtual ~OneShotTimer(); + OneShotTimer(OneShotTimer&) = delete; + OneShotTimer& operator=(OneShotTimer&) = delete; + void Start(std::unique_ptr user_task, TimeDelta delay); void FireNow(); @@ -45,8 +48,6 @@ inline namespace timer { void RunUserTask() final; std::unique_ptr user_task_; - - FOOTSTONE_DISALLOW_COPY_AND_ASSIGN(OneShotTimer); }; } // namespace base diff --git a/modules/footstone/include/footstone/repeating_timer.h b/modules/footstone/include/footstone/repeating_timer.h index 69fa4883c..c5dbf5057 100644 --- a/modules/footstone/include/footstone/repeating_timer.h +++ b/modules/footstone/include/footstone/repeating_timer.h @@ -33,14 +33,15 @@ inline namespace timer { explicit RepeatingTimer(const std::shared_ptr& task_runner); virtual ~RepeatingTimer(); + RepeatingTimer(RepeatingTimer&) = delete; + RepeatingTimer& operator=(RepeatingTimer&) = delete; + void Start(std::unique_ptr user_task, TimeDelta delay); virtual std::shared_ptr GetWeakSelf() override; private: void OnStop() final; void RunUserTask() override; - - FOOTSTONE_DISALLOW_COPY_AND_ASSIGN(RepeatingTimer); }; } // namespace base diff --git a/modules/footstone/include/footstone/task_runner.h b/modules/footstone/include/footstone/task_runner.h index a4b528731..7a45d1a03 100644 --- a/modules/footstone/include/footstone/task_runner.h +++ b/modules/footstone/include/footstone/task_runner.h @@ -49,6 +49,9 @@ class TaskRunner { bool is_schedulable = true, std::string name = ""); ~TaskRunner(); + TaskRunner(TaskRunner&) = delete; + TaskRunner& operator=(TaskRunner&) = delete; + void Clear(); bool AddSubTaskRunner(const std::shared_ptr &sub_runner, bool is_task_running = false); @@ -145,7 +148,6 @@ class TaskRunner { * 不可调度的TaskRunner不会被迁移,但其所在的Worker还是可以加入其他TaskRunner */ bool is_schedulable_; - FOOTSTONE_DISALLOW_COPY_AND_ASSIGN(TaskRunner); }; } // namespace runner diff --git a/modules/footstone/include/footstone/worker_manager.h b/modules/footstone/include/footstone/worker_manager.h index dee62268c..a7ec06a90 100644 --- a/modules/footstone/include/footstone/worker_manager.h +++ b/modules/footstone/include/footstone/worker_manager.h @@ -32,6 +32,10 @@ class WorkerManager { public: explicit WorkerManager(uint32_t size); ~WorkerManager(); + + WorkerManager(WorkerManager&) = delete; + WorkerManager& operator=(WorkerManager&) = delete; + void Terminate(); void Resize(uint32_t size); void AddWorker(const std::shared_ptr& worker); @@ -58,8 +62,6 @@ class WorkerManager { int32_t index_; uint32_t size_; std::mutex mutex_; - - FOOTSTONE_DISALLOW_COPY_AND_ASSIGN(WorkerManager); }; } // namespace runner