From 5f9689a0d041d2ca81cd2e8e407d97db330b2c95 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Thu, 29 Sep 2022 22:25:24 -0700 Subject: [PATCH] Fixup Enum Generator Summary: https://github.com/facebook/yoga/pull/1116 adds a new enum. The enum generator is out of date with copyright header, and some codemods, but it also looks like there were manual changes, types added, etc since generation. I fixed up the script to incorporate generating the changes folks made manually, and also added an enum that was previously only added manually to the C ABI. Changelog: [General][Fixed] - Fixup Yoga Enum Generator Reviewed By: yungsters Differential Revision: D39922252 fbshipit-source-id: b678fa9a43a896873d8c434745bdaf3f16fd991f --- .../java/com/facebook/yoga/YogaAlign.java | 2 + .../java/com/facebook/yoga/YogaDimension.java | 2 + .../java/com/facebook/yoga/YogaDirection.java | 2 + .../java/com/facebook/yoga/YogaDisplay.java | 2 + .../main/java/com/facebook/yoga/YogaEdge.java | 2 + .../yoga/YogaExperimentalFeature.java | 2 + .../com/facebook/yoga/YogaFlexDirection.java | 2 + .../java/com/facebook/yoga/YogaJustify.java | 5 +- .../java/com/facebook/yoga/YogaLogLevel.java | 2 + .../com/facebook/yoga/YogaMeasureMode.java | 2 + .../java/com/facebook/yoga/YogaNodeType.java | 2 + .../java/com/facebook/yoga/YogaOverflow.java | 2 + .../com/facebook/yoga/YogaPositionType.java | 2 + .../com/facebook/yoga/YogaPrintOptions.java | 2 + .../main/java/com/facebook/yoga/YogaUnit.java | 2 + .../main/java/com/facebook/yoga/YogaWrap.java | 2 + ReactCommon/yoga/yoga/YGEnums.cpp | 2 + ReactCommon/yoga/yoga/YGEnums.h | 76 ++++++------------- ReactCommon/yoga/yoga/YGMacros.h | 43 +++++++++++ 19 files changed, 102 insertions(+), 54 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaAlign.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaAlign.java index 5411e39f2efeaa..a60d77e0f294b3 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaAlign.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaAlign.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaAlign { diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaDimension.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaDimension.java index eeecd85ed47c16..a949ddc3ce1cc5 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaDimension.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaDimension.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaDimension { diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaDirection.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaDirection.java index 344c0f8079e9af..7cedba3a05e6a4 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaDirection.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaDirection.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaDirection { diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaDisplay.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaDisplay.java index aa94b0536a9e99..d4c4685fcb220d 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaDisplay.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaDisplay.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaDisplay { diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaEdge.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaEdge.java index 929b3315b332f2..6b915348230d28 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaEdge.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaEdge.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaEdge { diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaExperimentalFeature.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaExperimentalFeature.java index f54c7b6e1cd277..3fabbb91729263 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaExperimentalFeature.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaExperimentalFeature.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaExperimentalFeature { diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaFlexDirection.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaFlexDirection.java index c314c0cf03cd47..719888a1864e3b 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaFlexDirection.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaFlexDirection.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaFlexDirection { diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaJustify.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaJustify.java index e19213f7e8b6e5..4be1ed71d39d3e 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaJustify.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaJustify.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaJustify { @@ -32,8 +34,7 @@ public static YogaJustify fromInt(int value) { case 2: return FLEX_END; case 3: return SPACE_BETWEEN; case 4: return SPACE_AROUND; - case 5: - return SPACE_EVENLY; + case 5: return SPACE_EVENLY; default: throw new IllegalArgumentException("Unknown enum value: " + value); } } diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.java index f105145aea425f..85076706c3786b 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaMeasureMode.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaMeasureMode.java index 1750d2a1f4314d..0c77c23897e75d 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaMeasureMode.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaMeasureMode.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaMeasureMode { diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeType.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeType.java index 1d90eec34c5be7..b8828014cf86e9 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeType.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeType.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaNodeType { diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaOverflow.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaOverflow.java index 321d4e00a655b6..8e59966b9a9d84 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaOverflow.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaOverflow.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaOverflow { diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaPositionType.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaPositionType.java index 6663a0ee66d4b1..cf735fbe073df0 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaPositionType.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaPositionType.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaPositionType { diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaPrintOptions.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaPrintOptions.java index 8c1a34d955911e..54eacc51d3a19e 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaPrintOptions.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaPrintOptions.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaPrintOptions { diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.java index e2ab8bffb72fc6..3614ec1059d2a7 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaUnit { diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaWrap.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaWrap.java index e7e6014328ca9f..cf87e9ef5eca79 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaWrap.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaWrap.java @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + package com.facebook.yoga; public enum YogaWrap { diff --git a/ReactCommon/yoga/yoga/YGEnums.cpp b/ReactCommon/yoga/yoga/YGEnums.cpp index b97342d8c279f6..b67b0dac6dd718 100644 --- a/ReactCommon/yoga/yoga/YGEnums.cpp +++ b/ReactCommon/yoga/yoga/YGEnums.cpp @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + #include "YGEnums.h" const char* YGAlignToString(const YGAlign value) { diff --git a/ReactCommon/yoga/yoga/YGEnums.h b/ReactCommon/yoga/yoga/YGEnums.h index c14daaa1a678a4..9d6abfb1075ad6 100644 --- a/ReactCommon/yoga/yoga/YGEnums.h +++ b/ReactCommon/yoga/yoga/YGEnums.h @@ -5,53 +5,13 @@ * LICENSE file in the root directory of this source tree. */ +// @generated by enums.py + #pragma once +// clang-format: off #include "YGMacros.h" -#ifdef __cplusplus -namespace facebook { -namespace yoga { -namespace enums { - -template -constexpr int count(); // can't use `= delete` due to a defect in clang < 3.9 - -namespace detail { -template -constexpr int n() { - return sizeof...(xs); -} -} // namespace detail - -} // namespace enums -} // namespace yoga -} // namespace facebook -#endif - -#define YG_ENUM_DECL(NAME, ...) \ - typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \ - WIN_EXPORT const char* NAME##ToString(NAME); - -#ifdef __cplusplus -#define YG_ENUM_SEQ_DECL(NAME, ...) \ - YG_ENUM_DECL(NAME, __VA_ARGS__) \ - YG_EXTERN_C_END \ - namespace facebook { \ - namespace yoga { \ - namespace enums { \ - template <> \ - constexpr int count() { \ - return detail::n<__VA_ARGS__>(); \ - } \ - } \ - } \ - } \ - YG_EXTERN_C_BEGIN -#else -#define YG_ENUM_SEQ_DECL YG_ENUM_DECL -#endif - YG_EXTERN_C_BEGIN YG_ENUM_SEQ_DECL( @@ -63,9 +23,12 @@ YG_ENUM_SEQ_DECL( YGAlignStretch, YGAlignBaseline, YGAlignSpaceBetween, - YGAlignSpaceAround); + YGAlignSpaceAround) -YG_ENUM_SEQ_DECL(YGDimension, YGDimensionWidth, YGDimensionHeight) +YG_ENUM_SEQ_DECL( + YGDimension, + YGDimensionWidth, + YGDimensionHeight) YG_ENUM_SEQ_DECL( YGDirection, @@ -73,7 +36,10 @@ YG_ENUM_SEQ_DECL( YGDirectionLTR, YGDirectionRTL) -YG_ENUM_SEQ_DECL(YGDisplay, YGDisplayFlex, YGDisplayNone) +YG_ENUM_SEQ_DECL( + YGDisplay, + YGDisplayFlex, + YGDisplayNone) YG_ENUM_SEQ_DECL( YGEdge, @@ -87,7 +53,9 @@ YG_ENUM_SEQ_DECL( YGEdgeVertical, YGEdgeAll) -YG_ENUM_SEQ_DECL(YGExperimentalFeature, YGExperimentalFeatureWebFlexBasis) +YG_ENUM_SEQ_DECL( + YGExperimentalFeature, + YGExperimentalFeatureWebFlexBasis) YG_ENUM_SEQ_DECL( YGFlexDirection, @@ -120,7 +88,10 @@ YG_ENUM_SEQ_DECL( YGMeasureModeExactly, YGMeasureModeAtMost) -YG_ENUM_SEQ_DECL(YGNodeType, YGNodeTypeDefault, YGNodeTypeText) +YG_ENUM_SEQ_DECL( + YGNodeType, + YGNodeTypeDefault, + YGNodeTypeText) YG_ENUM_SEQ_DECL( YGOverflow, @@ -147,9 +118,10 @@ YG_ENUM_SEQ_DECL( YGUnitPercent, YGUnitAuto) -YG_ENUM_SEQ_DECL(YGWrap, YGWrapNoWrap, YGWrapWrap, YGWrapWrapReverse) +YG_ENUM_SEQ_DECL( + YGWrap, + YGWrapNoWrap, + YGWrapWrap, + YGWrapWrapReverse) YG_EXTERN_C_END - -#undef YG_ENUM_DECL -#undef YG_ENUM_SEQ_DECL diff --git a/ReactCommon/yoga/yoga/YGMacros.h b/ReactCommon/yoga/yoga/YGMacros.h index 9211c87b317bae..ee143c29ffa2a2 100644 --- a/ReactCommon/yoga/yoga/YGMacros.h +++ b/ReactCommon/yoga/yoga/YGMacros.h @@ -40,6 +40,49 @@ #define YG_ENUM_END(name) name #endif +#ifdef __cplusplus +namespace facebook { +namespace yoga { +namespace enums { + +template +constexpr int count(); // can't use `= delete` due to a defect in clang < 3.9 + +namespace detail { +template +constexpr int n() { + return sizeof...(xs); +} +} // namespace detail + +} // namespace enums +} // namespace yoga +} // namespace facebook +#endif + +#define YG_ENUM_DECL(NAME, ...) \ + typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \ + WIN_EXPORT const char* NAME##ToString(NAME); + +#ifdef __cplusplus +#define YG_ENUM_SEQ_DECL(NAME, ...) \ + YG_ENUM_DECL(NAME, __VA_ARGS__) \ + YG_EXTERN_C_END \ + namespace facebook { \ + namespace yoga { \ + namespace enums { \ + template <> \ + constexpr int count() { \ + return detail::n<__VA_ARGS__>(); \ + } \ + } \ + } \ + } \ + YG_EXTERN_C_BEGIN +#else +#define YG_ENUM_SEQ_DECL YG_ENUM_DECL +#endif + #ifdef __GNUC__ #define YG_DEPRECATED __attribute__((deprecated)) #elif defined(_MSC_VER)