mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 04:35:36 +08:00
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
This commit is contained in:
committed by
Facebook Github Bot
parent
a2f11cb01f
commit
cf2a289372
@@ -25,15 +25,19 @@ EventBeatBasedExecutor::EventBeatBasedExecutor(
|
|||||||
|
|
||||||
void EventBeatBasedExecutor::operator()(Routine routine, Mode mode) const {
|
void EventBeatBasedExecutor::operator()(Routine routine, Mode mode) const {
|
||||||
if (mode == Mode::Asynchronous) {
|
if (mode == Mode::Asynchronous) {
|
||||||
execute({.routine = std::move(routine)});
|
execute({
|
||||||
|
/* .routine = */ std::move(routine),
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
|
|
||||||
execute({.routine = std::move(routine),
|
execute({
|
||||||
.callback = [&mutex]() { mutex.unlock(); }});
|
/* .routine = */ std::move(routine),
|
||||||
|
/* .callback = */ [&mutex]() { mutex.unlock(); },
|
||||||
|
});
|
||||||
|
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ struct ShadowView final {
|
|||||||
ShadowView() = default;
|
ShadowView() = default;
|
||||||
ShadowView(const ShadowView &shadowView) = default;
|
ShadowView(const ShadowView &shadowView) = default;
|
||||||
|
|
||||||
|
~ShadowView(){};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructs a `ShadowView` from given `ShadowNode`.
|
* Constructs a `ShadowView` from given `ShadowNode`.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -11,32 +11,49 @@ namespace facebook {
|
|||||||
namespace react {
|
namespace react {
|
||||||
|
|
||||||
ShadowViewMutation ShadowViewMutation::CreateMutation(ShadowView shadowView) {
|
ShadowViewMutation ShadowViewMutation::CreateMutation(ShadowView shadowView) {
|
||||||
return ShadowViewMutation{
|
return {
|
||||||
.type = Create, .newChildShadowView = shadowView, .index = -1};
|
/* .type = */ Create,
|
||||||
|
/* .parentShadowView = */ {},
|
||||||
|
/* .newChildShadowView = */ shadowView,
|
||||||
|
/* .oldChildShadowView = */ {},
|
||||||
|
/* .index = */ -1,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ShadowViewMutation ShadowViewMutation::DeleteMutation(ShadowView shadowView) {
|
ShadowViewMutation ShadowViewMutation::DeleteMutation(ShadowView shadowView) {
|
||||||
return {.type = Delete, .oldChildShadowView = shadowView, .index = -1};
|
return {
|
||||||
|
/* .type = */ Delete,
|
||||||
|
/* .parentShadowView = */ {},
|
||||||
|
/* .oldChildShadowView = */ shadowView,
|
||||||
|
/* .newChildShadowView = */ {},
|
||||||
|
/* .index = */ -1,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ShadowViewMutation ShadowViewMutation::InsertMutation(
|
ShadowViewMutation ShadowViewMutation::InsertMutation(
|
||||||
ShadowView parentShadowView,
|
ShadowView parentShadowView,
|
||||||
ShadowView childShadowView,
|
ShadowView childShadowView,
|
||||||
int index) {
|
int index) {
|
||||||
return {.type = Insert,
|
return {
|
||||||
.parentShadowView = parentShadowView,
|
/* .type = */ Insert,
|
||||||
.newChildShadowView = childShadowView,
|
/* .parentShadowView = */ parentShadowView,
|
||||||
.index = index};
|
/* .oldChildShadowView = */ {},
|
||||||
|
/* .newChildShadowView = */ childShadowView,
|
||||||
|
/* .index = */ index,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ShadowViewMutation ShadowViewMutation::RemoveMutation(
|
ShadowViewMutation ShadowViewMutation::RemoveMutation(
|
||||||
ShadowView parentShadowView,
|
ShadowView parentShadowView,
|
||||||
ShadowView childShadowView,
|
ShadowView childShadowView,
|
||||||
int index) {
|
int index) {
|
||||||
return {.type = Remove,
|
return {
|
||||||
.parentShadowView = parentShadowView,
|
/* .type = */ Remove,
|
||||||
.oldChildShadowView = childShadowView,
|
/* .parentShadowView = */ parentShadowView,
|
||||||
.index = index};
|
/* .oldChildShadowView = */ childShadowView,
|
||||||
|
/* .newChildShadowView = */ {},
|
||||||
|
/* .index = */ index,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ShadowViewMutation ShadowViewMutation::UpdateMutation(
|
ShadowViewMutation ShadowViewMutation::UpdateMutation(
|
||||||
@@ -44,11 +61,13 @@ ShadowViewMutation ShadowViewMutation::UpdateMutation(
|
|||||||
ShadowView oldChildShadowView,
|
ShadowView oldChildShadowView,
|
||||||
ShadowView newChildShadowView,
|
ShadowView newChildShadowView,
|
||||||
int index) {
|
int index) {
|
||||||
return {.type = Update,
|
return {
|
||||||
.parentShadowView = parentShadowView,
|
/* .type = */ Update,
|
||||||
.oldChildShadowView = oldChildShadowView,
|
/* .parentShadowView = */ parentShadowView,
|
||||||
.newChildShadowView = newChildShadowView,
|
/* .oldChildShadowView = */ oldChildShadowView,
|
||||||
.index = index};
|
/* .newChildShadowView = */ newChildShadowView,
|
||||||
|
/* .index = */ index,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace react
|
} // namespace react
|
||||||
|
|||||||
Reference in New Issue
Block a user