From 30e596e1a0b06849ada8a08fe7cb6e2933f1607d Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Mon, 16 Oct 2023 18:13:43 -0700 Subject: [PATCH] Reuse Yoga enum ToString functions Summary: Yoga has generated public `ToString` functions for enums already. Don't duplicate in Fabric. Changelog: [Internal] Differential Revision: D50347728 fbshipit-source-id: 5dcd1f847b22dc9771fad4b0aa625794b911e324 --- .../renderer/components/view/conversions.h | 54 +++---------------- 1 file changed, 6 insertions(+), 48 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h b/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h index d33d6daa01442c..49662454c9242a 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h @@ -723,27 +723,11 @@ inline std::string toString(const std::array vec) { } inline std::string toString(const yoga::Direction& value) { - switch (value) { - case yoga::Direction::Inherit: - return "inherit"; - case yoga::Direction::LTR: - return "ltr"; - case yoga::Direction::RTL: - return "rtl"; - } + return YGDirectionToString(yoga::unscopedEnum(value)); } inline std::string toString(const yoga::FlexDirection& value) { - switch (value) { - case yoga::FlexDirection::Column: - return "column"; - case yoga::FlexDirection::ColumnReverse: - return "column-reverse"; - case yoga::FlexDirection::Row: - return "row"; - case yoga::FlexDirection::RowReverse: - return "row-reverse"; - } + return YGFlexDirectionToString(yoga::unscopedEnum(value)); } inline std::string toString(const yoga::Justify& value) { @@ -755,45 +739,19 @@ inline std::string toString(const yoga::Align& value) { } inline std::string toString(const yoga::PositionType& value) { - switch (value) { - case yoga::PositionType::Static: - return "static"; - case yoga::PositionType::Relative: - return "relative"; - case yoga::PositionType::Absolute: - return "absolute"; - } + return YGPositionTypeToString(yoga::unscopedEnum(value)); } inline std::string toString(const yoga::Wrap& value) { - switch (value) { - case yoga::Wrap::NoWrap: - return "no-wrap"; - case yoga::Wrap::Wrap: - return "wrap"; - case yoga::Wrap::WrapReverse: - return "wrap-reverse"; - } + return YGWrapToString(yoga::unscopedEnum(value)); } inline std::string toString(const yoga::Overflow& value) { - switch (value) { - case yoga::Overflow::Visible: - return "visible"; - case yoga::Overflow::Scroll: - return "scroll"; - case yoga::Overflow::Hidden: - return "hidden"; - } + return YGOverflowToString(yoga::unscopedEnum(value)); } inline std::string toString(const yoga::Display& value) { - switch (value) { - case yoga::Display::Flex: - return "flex"; - case yoga::Display::None: - return "none"; - } + return YGDisplayToString(yoga::unscopedEnum(value)); } inline std::string toString(const YGValue& value) {