Fix CQS signal modernize-use-designated-initializers in xplat/js/react-native-github/packages [A] (#53969)

Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53969

Reviewed By: rshest

Differential Revision: D83350635
This commit is contained in:
CodemodService Bot
2025-09-29 09:15:48 -07:00
committed by Facebook GitHub Bot
parent 3fb6c12ec8
commit e99e3bb32a
11 changed files with 723 additions and 326 deletions
@@ -190,7 +190,7 @@ std::optional<ModuleConfig> ModuleRegistry::getConfig(const std::string& name) {
// no constants or methods
return std::nullopt;
} else {
return ModuleConfig{index, std::move(config)};
return ModuleConfig{.index = index, .config = std::move(config)};
}
}
@@ -70,8 +70,8 @@ JSModulesUnbundle::Module RAMBundleRegistry::getModule(
}
return {
"seg-" + std::to_string(bundleId) + '_' + module.name,
std::move(module.code),
.name = "seg-" + std::to_string(bundleId) + '_' + module.name,
.code = std::move(module.code),
};
}
File diff suppressed because it is too large Load Diff
@@ -137,8 +137,10 @@ class Stream : public NetworkRequestListener,
// called with it.
if (initCb_) {
auto cb = std::move(initCb_);
(*cb)(
InitStreamResult{httpStatusCode, headers, this->shared_from_this()});
(*cb)(InitStreamResult{
.httpStatusCode = httpStatusCode,
.headers = headers,
.stream = this->shared_from_this()});
}
}
@@ -51,8 +51,8 @@ bool BoundedRequestBuffer::put(
// `data` is copied at the point of insertion
responses_.emplace(
requestId,
std::make_shared<ResponseBody>(
ResponseBody{std::string(data), base64Encoded}));
std::make_shared<ResponseBody>(ResponseBody{
.data = std::string(data), .base64Encoded = base64Encoded}));
order_.push_back(requestId);
return true;
@@ -14,9 +14,13 @@ namespace facebook::react::jsinspector_modern::tracing {
TEST(ProfileTreeNodeTest, OnlyAddsUniqueChildren) {
auto fooCallFrame = RuntimeSamplingProfile::SampleCallStackFrame{
RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, 0, "foo"};
.kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction,
.scriptId = 0,
.functionName = "foo"};
auto barCallFrame = RuntimeSamplingProfile::SampleCallStackFrame{
RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, 0, "bar"};
.kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction,
.scriptId = 0,
.functionName = "bar"};
ProfileTreeNode parent(
1, ProfileTreeNode::CodeType::JavaScript, fooCallFrame);
@@ -34,9 +38,13 @@ TEST(ProfileTreeNodeTest, OnlyAddsUniqueChildren) {
TEST(ProfileTreeNodeTest, ConsidersCodeTypeOfChild) {
auto parentCallFrame = RuntimeSamplingProfile::SampleCallStackFrame{
RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, 0, "foo"};
.kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction,
.scriptId = 0,
.functionName = "foo"};
auto childCallFrame = RuntimeSamplingProfile::SampleCallStackFrame{
RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, 0, "bar"};
.kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction,
.scriptId = 0,
.functionName = "bar"};
ProfileTreeNode parent(
1, ProfileTreeNode::CodeType::JavaScript, parentCallFrame);
@@ -26,9 +26,10 @@ std::shared_ptr<const ShadowNode> findAndClone(
if (maybeClone != child) {
children[i] = maybeClone;
return node->clone(
{ShadowNodeFragment::propsPlaceholder(),
std::make_shared<std::vector<std::shared_ptr<const ShadowNode>>>(
children)});
{.props = ShadowNodeFragment::propsPlaceholder(),
.children =
std::make_shared<std::vector<std::shared_ptr<const ShadowNode>>>(
children)});
}
}
@@ -123,13 +123,13 @@ void LayoutAnimationKeyFrameManager::uiManagerDidConfigureNextLayoutAnimation(
std::scoped_lock lock(currentAnimationMutex_);
uiManagerDidConfigureNextLayoutAnimation(LayoutAnimation{
-1,
0,
false,
*layoutAnimationConfig,
successCallback,
failureCallback,
{}});
.surfaceId = -1,
.startTime = 0,
.completed = false,
.layoutAnimationConfig = *layoutAnimationConfig,
.successCallback = successCallback,
.failureCallback = failureCallback,
.keyFrames = {}});
} else {
LOG(ERROR) << "Parsing LayoutAnimationConfig failed: "
<< (folly::dynamic)config;
@@ -500,14 +500,15 @@ LayoutAnimationKeyFrameManager::pullTransaction(
mutation);
keyFrame = AnimationKeyFrame{
/* .finalMutationsForKeyFrame = */ {},
/* .type = */ AnimationConfigurationType::Create,
/* .tag = */ tag,
/* .parentTag = */ parentTag,
/* .viewStart = */ viewStart,
/* .viewEnd = */ viewFinal,
/* .viewPrev = */ baselineShadowView,
/* .initialProgress = */ 0};
/* .finalMutationsForKeyFrame = */ .finalMutationsForKeyFrame =
{},
/* .type = */ .type = AnimationConfigurationType::Create,
/* .tag = */ .tag = tag,
/* .parentTag = */ .parentTag = parentTag,
/* .viewStart = */ .viewStart = viewStart,
/* .viewEnd = */ .viewEnd = viewFinal,
/* .viewPrev = */ .viewPrev = baselineShadowView,
/* .initialProgress = */ .initialProgress = 0};
} else if (mutation.type == ShadowViewMutation::Type::Delete) {
// This is just for assertion purposes.
// The NDEBUG check here is to satisfy the compiler in certain environments
@@ -538,14 +539,15 @@ LayoutAnimationKeyFrameManager::pullTransaction(
mutation);
keyFrame = AnimationKeyFrame{
/* .finalMutationsForKeyFrame = */ {mutation},
/* .type = */ AnimationConfigurationType::Update,
/* .tag = */ tag,
/* .parentTag = */ parentTag,
/* .viewStart = */ viewStart,
/* .viewEnd = */ viewFinal,
/* .viewPrev = */ baselineShadowView,
/* .initialProgress = */ 0};
/* .finalMutationsForKeyFrame = */ .finalMutationsForKeyFrame =
{mutation},
/* .type = */ .type = AnimationConfigurationType::Update,
/* .tag = */ .tag = tag,
/* .parentTag = */ .parentTag = parentTag,
/* .viewStart = */ .viewStart = viewStart,
/* .viewEnd = */ .viewEnd = viewFinal,
/* .viewPrev = */ .viewPrev = baselineShadowView,
/* .initialProgress = */ .initialProgress = 0};
} else {
// This should just be "Remove" instructions that are not animated
// (either this is a "move", or there's a corresponding "Delete"
@@ -624,14 +626,15 @@ LayoutAnimationKeyFrameManager::pullTransaction(
mutation);
keyFrame = AnimationKeyFrame{
/* .finalMutationsForKeyFrame */ {mutation, deleteMutation},
/* .type */ AnimationConfigurationType::Delete,
/* .tag */ tag,
/* .parentTag */ parentTag,
/* .viewStart */ viewStart,
/* .viewEnd */ viewFinal,
/* .viewPrev */ baselineShadowView,
/* .initialProgress */ 0};
/* .finalMutationsForKeyFrame */ .finalMutationsForKeyFrame =
{mutation, deleteMutation},
/* .type */ .type = AnimationConfigurationType::Delete,
/* .tag */ .tag = tag,
/* .parentTag */ .parentTag = parentTag,
/* .viewStart */ .viewStart = viewStart,
/* .viewEnd */ .viewEnd = viewFinal,
/* .viewPrev */ .viewPrev = baselineShadowView,
/* .initialProgress */ .initialProgress = 0};
} else {
PrintMutationInstruction(
"Executing Remove Immediately, due to reordering operation",
@@ -64,12 +64,12 @@ static inline std::optional<AnimationConfig> parseAnimationConfig(
bool parsePropertyType) {
if (config.empty() || !config.isObject()) {
return AnimationConfig{
AnimationType::Linear,
AnimationProperty::NotApplicable,
defaultDuration,
0,
0,
0};
.animationType = AnimationType::Linear,
.animationProperty = AnimationProperty::NotApplicable,
.duration = defaultDuration,
.delay = 0,
.springDamping = 0,
.initialVelocity = 0};
}
const auto typeIt = config.find("type");
@@ -165,12 +165,12 @@ static inline std::optional<AnimationConfig> parseAnimationConfig(
}
return std::optional<AnimationConfig>(AnimationConfig{
*animationType,
animationProperty,
duration,
delay,
springDamping,
initialVelocity});
.animationType = *animationType,
.animationProperty = animationProperty,
.duration = duration,
.delay = delay,
.springDamping = springDamping,
.initialVelocity = initialVelocity});
}
// Parse animation config from JS
@@ -206,7 +206,10 @@ static inline std::optional<LayoutAnimationConfig> parseLayoutAnimationConfig(
}
return LayoutAnimationConfig{
duration, *createConfig, *updateConfig, *deleteConfig};
.duration = duration,
.createConfig = *createConfig,
.updateConfig = *updateConfig,
.deleteConfig = *deleteConfig};
}
} // namespace facebook::react
@@ -50,8 +50,10 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations(
auto eventDispatcher = EventDispatcher::Shared{};
auto contextContainer = std::make_shared<const ContextContainer>();
auto componentDescriptorParameters =
ComponentDescriptorParameters{eventDispatcher, contextContainer, nullptr};
auto componentDescriptorParameters = ComponentDescriptorParameters{
.eventDispatcher = eventDispatcher,
.contextContainer = contextContainer,
.flavor = nullptr};
auto viewComponentDescriptor =
ViewComponentDescriptor(componentDescriptorParameters);
auto rootComponentDescriptor =
@@ -93,20 +95,27 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations(
auto surfaceId = SurfaceId(surfaceIdInt);
auto family = rootComponentDescriptor.createFamily(
{Tag(surfaceIdInt), surfaceId, nullptr});
{.tag = Tag(surfaceIdInt),
.surfaceId = surfaceId,
.instanceHandle = nullptr});
// Creating an initial root shadow node.
auto emptyRootNode = std::const_pointer_cast<RootShadowNode>(
std::static_pointer_cast<const RootShadowNode>(
rootComponentDescriptor.createShadowNode(
ShadowNodeFragment{RootShadowNode::defaultSharedProps()},
ShadowNodeFragment{
.props = RootShadowNode::defaultSharedProps()},
family)));
// Applying size constraints.
emptyRootNode = emptyRootNode->clone(
parserContext,
LayoutConstraints{
Size{512, 0}, Size{512, std::numeric_limits<Float>::infinity()}},
.minimumSize = Size{.width = 512, .height = 0},
.maximumSize =
Size{
.width = 512,
.height = std::numeric_limits<Float>::infinity()}},
LayoutContext{});
// Generation of a random tree.
@@ -116,8 +125,9 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations(
// Injecting a tree into the root node.
auto currentRootNode = std::static_pointer_cast<const RootShadowNode>(
emptyRootNode->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<std::vector<std::shared_ptr<const ShadowNode>>>(
.props = ShadowNodeFragment::propsPlaceholder(),
.children = std::make_shared<
std::vector<std::shared_ptr<const ShadowNode>>>(
std::vector<std::shared_ptr<const ShadowNode>>{
singleRootChildNode})}));
@@ -169,31 +179,35 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations(
// Configure animation
animationDriver->uiManagerDidConfigureNextLayoutAnimation(
{surfaceId,
0,
false,
{(double)animation_duration,
{/* Create */ AnimationType::EaseInEaseOut,
AnimationProperty::Opacity,
(double)animation_duration,
0,
0,
0},
{/* Update */ AnimationType::EaseInEaseOut,
AnimationProperty::ScaleXY,
(double)animation_duration,
0,
0,
0},
{/* Delete */ AnimationType::EaseInEaseOut,
AnimationProperty::Opacity,
(double)animation_duration,
0,
0,
0}},
{},
{},
{}});
{.surfaceId = surfaceId,
.startTime = 0,
.completed = false,
.layoutAnimationConfig =
{.duration = (double)animation_duration,
.createConfig = {
/* Create */ .animationType = AnimationType::EaseInEaseOut,
.animationProperty = AnimationProperty::Opacity,
.duration = (double)animation_duration,
.delay = 0,
.springDamping = 0,
.initialVelocity = 0},
.updateConfig = {
/* Update */ .animationType = AnimationType::EaseInEaseOut,
.animationProperty = AnimationProperty::ScaleXY,
.duration = (double)animation_duration,
.delay = 0,
.springDamping = 0,
.initialVelocity = 0},
.deleteConfig = {
/* Delete */ .animationType = AnimationType::EaseInEaseOut,
.animationProperty = AnimationProperty::Opacity,
.duration = (double)animation_duration,
.delay = 0,
.springDamping = 0,
.initialVelocity = 0}},
.successCallback = {},
.failureCallback = {},
.keyFrames = {}});
// Get mutations for each frame
for (int k = 0; k < animation_frames + 2; k++) {
@@ -33,9 +33,9 @@ void ComponentDescriptorRegistry::add(
std::unique_lock lock(mutex_);
auto componentDescriptor = componentDescriptorProvider.constructor(
{parameters_.eventDispatcher,
parameters_.contextContainer,
componentDescriptorProvider.flavor});
{.eventDispatcher = parameters_.eventDispatcher,
.contextContainer = parameters_.contextContainer,
.flavor = componentDescriptorProvider.flavor});
react_native_assert(
componentDescriptor->getComponentHandle() ==
componentDescriptorProvider.handle);