Skip to content

Commit b7c11ce

Browse files
NickGerlemanOthinn
authored andcommitted
Reuse Yoga enum ToString functions (facebook#41021)
Summary: Pull Request resolved: facebook#41021 Yoga has generated public `ToString` functions for enums already. Don't duplicate in Fabric. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D50347728 fbshipit-source-id: 353106091eb5a5ab6e98a816da876bb4ccadbd29
1 parent 319d11a commit b7c11ce

File tree

1 file changed

+6
-48
lines changed
  • packages/react-native/ReactCommon/react/renderer/components/view

1 file changed

+6
-48
lines changed

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

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -722,27 +722,11 @@ inline std::string toString(const std::array<float, N> vec) {
722722
}
723723

724724
inline std::string toString(const yoga::Direction& value) {
725-
switch (value) {
726-
case yoga::Direction::Inherit:
727-
return "inherit";
728-
case yoga::Direction::LTR:
729-
return "ltr";
730-
case yoga::Direction::RTL:
731-
return "rtl";
732-
}
725+
return YGDirectionToString(yoga::unscopedEnum(value));
733726
}
734727

735728
inline std::string toString(const yoga::FlexDirection& value) {
736-
switch (value) {
737-
case yoga::FlexDirection::Column:
738-
return "column";
739-
case yoga::FlexDirection::ColumnReverse:
740-
return "column-reverse";
741-
case yoga::FlexDirection::Row:
742-
return "row";
743-
case yoga::FlexDirection::RowReverse:
744-
return "row-reverse";
745-
}
729+
return YGFlexDirectionToString(yoga::unscopedEnum(value));
746730
}
747731

748732
inline std::string toString(const yoga::Justify& value) {
@@ -754,45 +738,19 @@ inline std::string toString(const yoga::Align& value) {
754738
}
755739

756740
inline std::string toString(const yoga::PositionType& value) {
757-
switch (value) {
758-
case yoga::PositionType::Static:
759-
return "static";
760-
case yoga::PositionType::Relative:
761-
return "relative";
762-
case yoga::PositionType::Absolute:
763-
return "absolute";
764-
}
741+
return YGPositionTypeToString(yoga::unscopedEnum(value));
765742
}
766743

767744
inline std::string toString(const yoga::Wrap& value) {
768-
switch (value) {
769-
case yoga::Wrap::NoWrap:
770-
return "no-wrap";
771-
case yoga::Wrap::Wrap:
772-
return "wrap";
773-
case yoga::Wrap::WrapReverse:
774-
return "wrap-reverse";
775-
}
745+
return YGWrapToString(yoga::unscopedEnum(value));
776746
}
777747

778748
inline std::string toString(const yoga::Overflow& value) {
779-
switch (value) {
780-
case yoga::Overflow::Visible:
781-
return "visible";
782-
case yoga::Overflow::Scroll:
783-
return "scroll";
784-
case yoga::Overflow::Hidden:
785-
return "hidden";
786-
}
749+
return YGOverflowToString(yoga::unscopedEnum(value));
787750
}
788751

789752
inline std::string toString(const yoga::Display& value) {
790-
switch (value) {
791-
case yoga::Display::Flex:
792-
return "flex";
793-
case yoga::Display::None:
794-
return "none";
795-
}
753+
return YGDisplayToString(yoga::unscopedEnum(value));
796754
}
797755

798756
inline std::string toString(const YGValue& value) {

0 commit comments

Comments
 (0)