Skip to content

Commit 8bc133c

Browse files
generatedunixname89002005287564facebook-github-bot
authored andcommitted
Fix CQS signal modernize-use-designated-initializers in xplat/js/react-native-github/packages (#53962)
Summary: Pull Request resolved: #53962 Reviewed By: javache Differential Revision: D83330024 fbshipit-source-id: f35898ba42dc06909b927d5c4b5477e7d8c8e966
1 parent f7ea40b commit 8bc133c

24 files changed

+464
-374
lines changed

packages/react-native/ReactCommon/react/renderer/components/view/FilterPropsConversions.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ inline std::optional<FilterFunction> parseDropShadow(
301301
}
302302
}
303303

304-
return FilterFunction{FilterType::DropShadow, dropShadowParams};
304+
return FilterFunction{
305+
.type = FilterType::DropShadow, .parameters = dropShadowParams};
305306
}
306307

307308
inline std::optional<FilterFunction> parseFilterRawValue(
@@ -326,20 +327,22 @@ inline std::optional<FilterFunction> parseFilterRawValue(
326327
if (*length < 0.0f) {
327328
return {};
328329
}
329-
return FilterFunction{FilterType::Blur, *length};
330+
return FilterFunction{.type = FilterType::Blur, .parameters = *length};
330331
}
331332
return {};
332333
} else if (filterKey == "hue-rotate") {
333334
if (auto angle = coerceAngle(rawFilter.begin()->second)) {
334-
return FilterFunction{FilterType::HueRotate, *angle};
335+
return FilterFunction{
336+
.type = FilterType::HueRotate, .parameters = *angle};
335337
}
336338
return {};
337339
} else {
338340
if (auto amount = coerceAmount(rawFilter.begin()->second)) {
339341
if (*amount < 0.0f) {
340342
return {};
341343
}
342-
return FilterFunction{filterTypeFromString(filterKey), *amount};
344+
return FilterFunction{
345+
.type = filterTypeFromString(filterKey), .parameters = *amount};
343346
}
344347
return {};
345348
}

packages/react-native/ReactCommon/react/renderer/components/view/PointerEvent.cpp

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,27 +58,46 @@ std::vector<DebugStringConvertibleObject> getDebugProps(
5858
const PointerEvent& pointerEvent,
5959
DebugStringConvertibleOptions options) {
6060
return {
61-
{"pointerId", getDebugDescription(pointerEvent.pointerId, options)},
62-
{"pressure", getDebugDescription(pointerEvent.pressure, options)},
63-
{"pointerType", getDebugDescription(pointerEvent.pointerType, options)},
64-
{"clientPoint", getDebugDescription(pointerEvent.clientPoint, options)},
65-
{"screenPoint", getDebugDescription(pointerEvent.screenPoint, options)},
66-
{"offsetPoint", getDebugDescription(pointerEvent.offsetPoint, options)},
67-
{"width", getDebugDescription(pointerEvent.width, options)},
68-
{"height", getDebugDescription(pointerEvent.height, options)},
69-
{"tiltX", getDebugDescription(pointerEvent.tiltX, options)},
70-
{"tiltY", getDebugDescription(pointerEvent.tiltY, options)},
71-
{"detail", getDebugDescription(pointerEvent.detail, options)},
72-
{"buttons", getDebugDescription(pointerEvent.buttons, options)},
73-
{"tangentialPressure",
74-
getDebugDescription(pointerEvent.tangentialPressure, options)},
75-
{"twist", getDebugDescription(pointerEvent.twist, options)},
76-
{"ctrlKey", getDebugDescription(pointerEvent.ctrlKey, options)},
77-
{"shiftKey", getDebugDescription(pointerEvent.shiftKey, options)},
78-
{"altKey", getDebugDescription(pointerEvent.altKey, options)},
79-
{"metaKey", getDebugDescription(pointerEvent.metaKey, options)},
80-
{"isPrimary", getDebugDescription(pointerEvent.isPrimary, options)},
81-
{"button", getDebugDescription(pointerEvent.button, options)},
61+
{.name = "pointerId",
62+
.value = getDebugDescription(pointerEvent.pointerId, options)},
63+
{.name = "pressure",
64+
.value = getDebugDescription(pointerEvent.pressure, options)},
65+
{.name = "pointerType",
66+
.value = getDebugDescription(pointerEvent.pointerType, options)},
67+
{.name = "clientPoint",
68+
.value = getDebugDescription(pointerEvent.clientPoint, options)},
69+
{.name = "screenPoint",
70+
.value = getDebugDescription(pointerEvent.screenPoint, options)},
71+
{.name = "offsetPoint",
72+
.value = getDebugDescription(pointerEvent.offsetPoint, options)},
73+
{.name = "width",
74+
.value = getDebugDescription(pointerEvent.width, options)},
75+
{.name = "height",
76+
.value = getDebugDescription(pointerEvent.height, options)},
77+
{.name = "tiltX",
78+
.value = getDebugDescription(pointerEvent.tiltX, options)},
79+
{.name = "tiltY",
80+
.value = getDebugDescription(pointerEvent.tiltY, options)},
81+
{.name = "detail",
82+
.value = getDebugDescription(pointerEvent.detail, options)},
83+
{.name = "buttons",
84+
.value = getDebugDescription(pointerEvent.buttons, options)},
85+
{.name = "tangentialPressure",
86+
.value = getDebugDescription(pointerEvent.tangentialPressure, options)},
87+
{.name = "twist",
88+
.value = getDebugDescription(pointerEvent.twist, options)},
89+
{.name = "ctrlKey",
90+
.value = getDebugDescription(pointerEvent.ctrlKey, options)},
91+
{.name = "shiftKey",
92+
.value = getDebugDescription(pointerEvent.shiftKey, options)},
93+
{.name = "altKey",
94+
.value = getDebugDescription(pointerEvent.altKey, options)},
95+
{.name = "metaKey",
96+
.value = getDebugDescription(pointerEvent.metaKey, options)},
97+
{.name = "isPrimary",
98+
.value = getDebugDescription(pointerEvent.isPrimary, options)},
99+
{.name = "button",
100+
.value = getDebugDescription(pointerEvent.button, options)},
82101
};
83102
}
84103

packages/react-native/ReactCommon/react/renderer/components/view/TouchEvent.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ std::vector<DebugStringConvertibleObject> getDebugProps(
1919
const TouchEvent& touchEvent,
2020
DebugStringConvertibleOptions options) {
2121
return {
22-
{"touches", getDebugDescription(touchEvent.touches, options)},
23-
{"changedTouches",
24-
getDebugDescription(touchEvent.changedTouches, options)},
25-
{"targetTouches", getDebugDescription(touchEvent.targetTouches, options)},
22+
{.name = "touches",
23+
.value = getDebugDescription(touchEvent.touches, options)},
24+
{.name = "changedTouches",
25+
.value = getDebugDescription(touchEvent.changedTouches, options)},
26+
{.name = "targetTouches",
27+
.value = getDebugDescription(touchEvent.targetTouches, options)},
2628
};
2729
}
2830

packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,9 @@ YogaLayoutableShadowNode& YogaLayoutableShadowNode::cloneChildInPlace(
531531
// TODO: Why does this not use `ShadowNodeFragment::statePlaceholder()` like
532532
// `adoptYogaChild()`?
533533
auto clonedChildNode = childNode.clone(
534-
{ShadowNodeFragment::propsPlaceholder(),
535-
ShadowNodeFragment::childrenPlaceholder(),
536-
childNode.getState()});
534+
{.props = ShadowNodeFragment::propsPlaceholder(),
535+
.children = ShadowNodeFragment::childrenPlaceholder(),
536+
.state = childNode.getState()});
537537

538538
replaceChild(childNode, clonedChildNode, layoutableChildIndex);
539539
return static_cast<YogaLayoutableShadowNode&>(*clonedChildNode);
@@ -814,10 +814,10 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector(
814814

815815
auto& shadowNode = shadowNodeFromContext(yogaNode);
816816

817-
auto minimumSize = Size{0, 0};
817+
auto minimumSize = Size{.width = 0, .height = 0};
818818
auto maximumSize = Size{
819-
std::numeric_limits<Float>::infinity(),
820-
std::numeric_limits<Float>::infinity()};
819+
.width = std::numeric_limits<Float>::infinity(),
820+
.height = std::numeric_limits<Float>::infinity()};
821821

822822
switch (widthMode) {
823823
case YGMeasureModeUndefined:
@@ -844,7 +844,8 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector(
844844
}
845845

846846
auto size = shadowNode.measureContent(
847-
threadLocalLayoutContext, {minimumSize, maximumSize});
847+
threadLocalLayoutContext,
848+
{.minimumSize = minimumSize, .maximumSize = maximumSize});
848849

849850
#ifdef REACT_NATIVE_DEBUG
850851
bool widthInBounds = size.width + kDefaultEpsilon >= minimumSize.width &&

packages/react-native/ReactCommon/react/renderer/components/view/conversions.h

Lines changed: 64 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,13 @@ inline LayoutMetrics layoutMetricsFromYogaNode(yoga::Node& yogaNode) {
131131
auto layoutMetrics = LayoutMetrics{};
132132

133133
layoutMetrics.frame = Rect{
134-
Point{
135-
floatFromYogaFloat(YGNodeLayoutGetLeft(&yogaNode)),
136-
floatFromYogaFloat(YGNodeLayoutGetTop(&yogaNode))},
137-
Size{
138-
floatFromYogaFloat(YGNodeLayoutGetWidth(&yogaNode)),
139-
floatFromYogaFloat(YGNodeLayoutGetHeight(&yogaNode))}};
134+
.origin =
135+
Point{
136+
.x = floatFromYogaFloat(YGNodeLayoutGetLeft(&yogaNode)),
137+
.y = floatFromYogaFloat(YGNodeLayoutGetTop(&yogaNode))},
138+
.size = Size{
139+
.width = floatFromYogaFloat(YGNodeLayoutGetWidth(&yogaNode)),
140+
.height = floatFromYogaFloat(YGNodeLayoutGetHeight(&yogaNode))}};
140141

141142
layoutMetrics.borderWidth = EdgeInsets{
142143
floatFromYogaFloat(YGNodeLayoutGetBorder(&yogaNode, YGEdgeLeft)),
@@ -645,18 +646,21 @@ inline void fromRawValue(
645646
transformMatrix.matrix[15] = numbers[8];
646647
}
647648
transformMatrix.operations.push_back(TransformOperation{
648-
TransformOperationType::Arbitrary, Zero, Zero, Zero});
649+
.type = TransformOperationType::Arbitrary,
650+
.x = Zero,
651+
.y = Zero,
652+
.z = Zero});
649653
} else if (operation == "perspective") {
650654
if (!parameters.hasType<Float>()) {
651655
result = {};
652656
return;
653657
}
654658

655659
transformMatrix.operations.push_back(TransformOperation{
656-
TransformOperationType::Perspective,
657-
ValueUnit((Float)parameters, UnitType::Point),
658-
Zero,
659-
Zero});
660+
.type = TransformOperationType::Perspective,
661+
.x = ValueUnit((Float)parameters, UnitType::Point),
662+
.y = Zero,
663+
.z = Zero});
660664
} else if (operation == "rotateX") {
661665
auto radians = toRadians(parameters);
662666
if (!radians.has_value()) {
@@ -665,10 +669,10 @@ inline void fromRawValue(
665669
}
666670

667671
transformMatrix.operations.push_back(TransformOperation{
668-
TransformOperationType::Rotate,
669-
ValueUnit(*radians, UnitType::Point),
670-
Zero,
671-
Zero});
672+
.type = TransformOperationType::Rotate,
673+
.x = ValueUnit(*radians, UnitType::Point),
674+
.y = Zero,
675+
.z = Zero});
672676
} else if (operation == "rotateY") {
673677
auto radians = toRadians(parameters);
674678
if (!radians.has_value()) {
@@ -677,10 +681,10 @@ inline void fromRawValue(
677681
}
678682

679683
transformMatrix.operations.push_back(TransformOperation{
680-
TransformOperationType::Rotate,
681-
Zero,
682-
ValueUnit(*radians, UnitType::Point),
683-
Zero});
684+
.type = TransformOperationType::Rotate,
685+
.x = Zero,
686+
.y = ValueUnit(*radians, UnitType::Point),
687+
.z = Zero});
684688
} else if (operation == "rotateZ" || operation == "rotate") {
685689
auto radians = toRadians(parameters);
686690
if (!radians.has_value()) {
@@ -689,10 +693,10 @@ inline void fromRawValue(
689693
}
690694

691695
transformMatrix.operations.push_back(TransformOperation{
692-
TransformOperationType::Rotate,
693-
Zero,
694-
Zero,
695-
ValueUnit(*radians, UnitType::Point)});
696+
.type = TransformOperationType::Rotate,
697+
.x = Zero,
698+
.y = Zero,
699+
.z = ValueUnit(*radians, UnitType::Point)});
696700
} else if (operation == "scale") {
697701
if (!parameters.hasType<Float>()) {
698702
result = {};
@@ -701,40 +705,43 @@ inline void fromRawValue(
701705

702706
auto number = ValueUnit((Float)parameters, UnitType::Point);
703707
transformMatrix.operations.push_back(TransformOperation{
704-
TransformOperationType::Scale, number, number, number});
708+
.type = TransformOperationType::Scale,
709+
.x = number,
710+
.y = number,
711+
.z = number});
705712
} else if (operation == "scaleX") {
706713
if (!parameters.hasType<Float>()) {
707714
result = {};
708715
return;
709716
}
710717

711718
transformMatrix.operations.push_back(TransformOperation{
712-
TransformOperationType::Scale,
713-
ValueUnit((Float)parameters, UnitType::Point),
714-
One,
715-
One});
719+
.type = TransformOperationType::Scale,
720+
.x = ValueUnit((Float)parameters, UnitType::Point),
721+
.y = One,
722+
.z = One});
716723
} else if (operation == "scaleY") {
717724
if (!parameters.hasType<Float>()) {
718725
result = {};
719726
return;
720727
}
721728

722729
transformMatrix.operations.push_back(TransformOperation{
723-
TransformOperationType::Scale,
724-
One,
725-
ValueUnit((Float)parameters, UnitType::Point),
726-
One});
730+
.type = TransformOperationType::Scale,
731+
.x = One,
732+
.y = ValueUnit((Float)parameters, UnitType::Point),
733+
.z = One});
727734
} else if (operation == "scaleZ") {
728735
if (!parameters.hasType<Float>()) {
729736
result = {};
730737
return;
731738
}
732739

733740
transformMatrix.operations.push_back(TransformOperation{
734-
TransformOperationType::Scale,
735-
One,
736-
One,
737-
ValueUnit((Float)parameters, UnitType::Point)});
741+
.type = TransformOperationType::Scale,
742+
.x = One,
743+
.y = One,
744+
.z = ValueUnit((Float)parameters, UnitType::Point)});
738745
} else if (operation == "translate") {
739746
if (!parameters.hasType<std::vector<RawValue>>()) {
740747
result = {};
@@ -760,7 +767,10 @@ inline void fromRawValue(
760767
}
761768

762769
transformMatrix.operations.push_back(TransformOperation{
763-
TransformOperationType::Translate, valueX, valueY, Zero});
770+
.type = TransformOperationType::Translate,
771+
.x = valueX,
772+
.y = valueY,
773+
.z = Zero});
764774
} else if (operation == "translateX") {
765775
auto valueX = toValueUnit(parameters);
766776
if (!valueX) {
@@ -769,7 +779,10 @@ inline void fromRawValue(
769779
}
770780

771781
transformMatrix.operations.push_back(TransformOperation{
772-
TransformOperationType::Translate, valueX, Zero, Zero});
782+
.type = TransformOperationType::Translate,
783+
.x = valueX,
784+
.y = Zero,
785+
.z = Zero});
773786
} else if (operation == "translateY") {
774787
auto valueY = toValueUnit(parameters);
775788
if (!valueY) {
@@ -778,7 +791,10 @@ inline void fromRawValue(
778791
}
779792

780793
transformMatrix.operations.push_back(TransformOperation{
781-
TransformOperationType::Translate, Zero, valueY, Zero});
794+
.type = TransformOperationType::Translate,
795+
.x = Zero,
796+
.y = valueY,
797+
.z = Zero});
782798
} else if (operation == "skewX") {
783799
auto radians = toRadians(parameters);
784800
if (!radians.has_value()) {
@@ -787,10 +803,10 @@ inline void fromRawValue(
787803
}
788804

789805
transformMatrix.operations.push_back(TransformOperation{
790-
TransformOperationType::Skew,
791-
ValueUnit(*radians, UnitType::Point),
792-
Zero,
793-
Zero});
806+
.type = TransformOperationType::Skew,
807+
.x = ValueUnit(*radians, UnitType::Point),
808+
.y = Zero,
809+
.z = Zero});
794810
} else if (operation == "skewY") {
795811
auto radians = toRadians(parameters);
796812
if (!radians.has_value()) {
@@ -799,10 +815,10 @@ inline void fromRawValue(
799815
}
800816

801817
transformMatrix.operations.push_back(TransformOperation{
802-
TransformOperationType::Skew,
803-
Zero,
804-
ValueUnit(*radians, UnitType::Point),
805-
Zero});
818+
.type = TransformOperationType::Skew,
819+
.x = Zero,
820+
.y = ValueUnit(*radians, UnitType::Point),
821+
.z = Zero});
806822
}
807823
}
808824

@@ -1332,7 +1348,7 @@ inline void fromRawValue(
13321348
if (xIt != sizeMap.end() && yIt != sizeMap.end()) {
13331349
RadialGradientSize sizeObj;
13341350
sizeObj.value = RadialGradientSize::Dimensions{
1335-
toValueUnit(xIt->second), toValueUnit(yIt->second)};
1351+
.x = toValueUnit(xIt->second), .y = toValueUnit(yIt->second)};
13361352
radialGradient.size = sizeObj;
13371353
}
13381354
}

packages/react-native/ReactCommon/react/renderer/components/view/tests/LayoutTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class LayoutTest : public ::testing::Test {
7575
.props([] {
7676
auto sharedProps = std::make_shared<RootProps>();
7777
auto &props = *sharedProps;
78-
props.layoutConstraints = LayoutConstraints{{0,0}, {500, 500}};
78+
props.layoutConstraints = LayoutConstraints{.minimumSize={.width=0,.height=0}, .maximumSize={.width=500, .height=500}};
7979
auto &yogaStyle = props.yogaStyle;
8080
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
8181
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(200));

0 commit comments

Comments
 (0)