From cf2a289372257ff2a7ba582117eef019f45344cd Mon Sep 17 00:00:00 2001 From: empyrical Date: Sun, 3 Mar 2019 22:29:28 -0800 Subject: [PATCH] Fabric: Remove designated initializers in Events and Mounting (#23441) Summary: This pull request removes the designated initializers in `react/mounting/**` and `react/events/**` to improve portability. A destructor was also defined for `ShadowView` to fix this error: ``` ShadowViewMutation.cpp:14: error: undefined reference to 'facebook::react::ShadowView::~ShadowView()' ShadowViewMutation.cpp:24: error: undefined reference to 'facebook::react::ShadowView::~ShadowView()' clang++: error: linker command failed with exit code 1 (use -v to see invocation) ``` [General] [Changed] - Fabric: Remove designated initializers in Events and Mounting Pull Request resolved: https://github.com/facebook/react-native/pull/23441 Differential Revision: D14298890 Pulled By: shergin fbshipit-source-id: f5d8fc6e1f5968b94e8bb3ca0c3f0e81cf892f83 --- .../core/events/EventBeatBasedExecutor.cpp | 10 ++-- ReactCommon/fabric/mounting/ShadowView.h | 2 + .../fabric/mounting/ShadowViewMutation.cpp | 51 +++++++++++++------ 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/ReactCommon/fabric/core/events/EventBeatBasedExecutor.cpp b/ReactCommon/fabric/core/events/EventBeatBasedExecutor.cpp index 6a5299763..d9b630c4f 100644 --- a/ReactCommon/fabric/core/events/EventBeatBasedExecutor.cpp +++ b/ReactCommon/fabric/core/events/EventBeatBasedExecutor.cpp @@ -25,15 +25,19 @@ EventBeatBasedExecutor::EventBeatBasedExecutor( void EventBeatBasedExecutor::operator()(Routine routine, Mode mode) const { if (mode == Mode::Asynchronous) { - execute({.routine = std::move(routine)}); + execute({ + /* .routine = */ std::move(routine), + }); return; } std::mutex mutex; mutex.lock(); - execute({.routine = std::move(routine), - .callback = [&mutex]() { mutex.unlock(); }}); + execute({ + /* .routine = */ std::move(routine), + /* .callback = */ [&mutex]() { mutex.unlock(); }, + }); mutex.lock(); } diff --git a/ReactCommon/fabric/mounting/ShadowView.h b/ReactCommon/fabric/mounting/ShadowView.h index 12a2f239b..bfa972cda 100644 --- a/ReactCommon/fabric/mounting/ShadowView.h +++ b/ReactCommon/fabric/mounting/ShadowView.h @@ -23,6 +23,8 @@ struct ShadowView final { ShadowView() = default; ShadowView(const ShadowView &shadowView) = default; + ~ShadowView(){}; + /* * Constructs a `ShadowView` from given `ShadowNode`. */ diff --git a/ReactCommon/fabric/mounting/ShadowViewMutation.cpp b/ReactCommon/fabric/mounting/ShadowViewMutation.cpp index 023107a5f..3cd25a4ca 100644 --- a/ReactCommon/fabric/mounting/ShadowViewMutation.cpp +++ b/ReactCommon/fabric/mounting/ShadowViewMutation.cpp @@ -11,32 +11,49 @@ namespace facebook { namespace react { ShadowViewMutation ShadowViewMutation::CreateMutation(ShadowView shadowView) { - return ShadowViewMutation{ - .type = Create, .newChildShadowView = shadowView, .index = -1}; + return { + /* .type = */ Create, + /* .parentShadowView = */ {}, + /* .newChildShadowView = */ shadowView, + /* .oldChildShadowView = */ {}, + /* .index = */ -1, + }; } ShadowViewMutation ShadowViewMutation::DeleteMutation(ShadowView shadowView) { - return {.type = Delete, .oldChildShadowView = shadowView, .index = -1}; + return { + /* .type = */ Delete, + /* .parentShadowView = */ {}, + /* .oldChildShadowView = */ shadowView, + /* .newChildShadowView = */ {}, + /* .index = */ -1, + }; } ShadowViewMutation ShadowViewMutation::InsertMutation( ShadowView parentShadowView, ShadowView childShadowView, int index) { - return {.type = Insert, - .parentShadowView = parentShadowView, - .newChildShadowView = childShadowView, - .index = index}; + return { + /* .type = */ Insert, + /* .parentShadowView = */ parentShadowView, + /* .oldChildShadowView = */ {}, + /* .newChildShadowView = */ childShadowView, + /* .index = */ index, + }; } ShadowViewMutation ShadowViewMutation::RemoveMutation( ShadowView parentShadowView, ShadowView childShadowView, int index) { - return {.type = Remove, - .parentShadowView = parentShadowView, - .oldChildShadowView = childShadowView, - .index = index}; + return { + /* .type = */ Remove, + /* .parentShadowView = */ parentShadowView, + /* .oldChildShadowView = */ childShadowView, + /* .newChildShadowView = */ {}, + /* .index = */ index, + }; } ShadowViewMutation ShadowViewMutation::UpdateMutation( @@ -44,11 +61,13 @@ ShadowViewMutation ShadowViewMutation::UpdateMutation( ShadowView oldChildShadowView, ShadowView newChildShadowView, int index) { - return {.type = Update, - .parentShadowView = parentShadowView, - .oldChildShadowView = oldChildShadowView, - .newChildShadowView = newChildShadowView, - .index = index}; + return { + /* .type = */ Update, + /* .parentShadowView = */ parentShadowView, + /* .oldChildShadowView = */ oldChildShadowView, + /* .newChildShadowView = */ newChildShadowView, + /* .index = */ index, + }; } } // namespace react