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:
empyrical 2019-03-03 22:29:28 -08:00 коммит произвёл Facebook Github Bot
Родитель a2f11cb01f
Коммит cf2a289372
3 изменённых файлов: 44 добавлений и 19 удалений

Просмотреть файл

@ -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();
}

Просмотреть файл

@ -23,6 +23,8 @@ struct ShadowView final {
ShadowView() = default;
ShadowView(const ShadowView &shadowView) = default;
~ShadowView(){};
/*
* Constructs a `ShadowView` from given `ShadowNode`.
*/

Просмотреть файл

@ -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