Skip to content

Commit 5f9689a

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Fixup Enum Generator
Summary: facebook/yoga#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
1 parent 6cd3884 commit 5f9689a

19 files changed

+102
-54
lines changed

ReactAndroid/src/main/java/com/facebook/yoga/YogaAlign.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaAlign {

ReactAndroid/src/main/java/com/facebook/yoga/YogaDimension.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaDimension {

ReactAndroid/src/main/java/com/facebook/yoga/YogaDirection.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaDirection {

ReactAndroid/src/main/java/com/facebook/yoga/YogaDisplay.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaDisplay {

ReactAndroid/src/main/java/com/facebook/yoga/YogaEdge.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaEdge {

ReactAndroid/src/main/java/com/facebook/yoga/YogaExperimentalFeature.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaExperimentalFeature {

ReactAndroid/src/main/java/com/facebook/yoga/YogaFlexDirection.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaFlexDirection {

ReactAndroid/src/main/java/com/facebook/yoga/YogaJustify.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaJustify {
@@ -32,8 +34,7 @@ public static YogaJustify fromInt(int value) {
3234
case 2: return FLEX_END;
3335
case 3: return SPACE_BETWEEN;
3436
case 4: return SPACE_AROUND;
35-
case 5:
36-
return SPACE_EVENLY;
37+
case 5: return SPACE_EVENLY;
3738
default: throw new IllegalArgumentException("Unknown enum value: " + value);
3839
}
3940
}

ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
import com.facebook.proguard.annotations.DoNotStrip;

ReactAndroid/src/main/java/com/facebook/yoga/YogaMeasureMode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaMeasureMode {

ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeType.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaNodeType {

ReactAndroid/src/main/java/com/facebook/yoga/YogaOverflow.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaOverflow {

ReactAndroid/src/main/java/com/facebook/yoga/YogaPositionType.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaPositionType {

ReactAndroid/src/main/java/com/facebook/yoga/YogaPrintOptions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaPrintOptions {

ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaUnit {

ReactAndroid/src/main/java/com/facebook/yoga/YogaWrap.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
package com.facebook.yoga;
911

1012
public enum YogaWrap {

ReactCommon/yoga/yoga/YGEnums.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
#include "YGEnums.h"
911

1012
const char* YGAlignToString(const YGAlign value) {

ReactCommon/yoga/yoga/YGEnums.h

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,13 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
// @generated by enums.py
9+
810
#pragma once
11+
// clang-format: off
912

1013
#include "YGMacros.h"
1114

12-
#ifdef __cplusplus
13-
namespace facebook {
14-
namespace yoga {
15-
namespace enums {
16-
17-
template <typename T>
18-
constexpr int count(); // can't use `= delete` due to a defect in clang < 3.9
19-
20-
namespace detail {
21-
template <int... xs>
22-
constexpr int n() {
23-
return sizeof...(xs);
24-
}
25-
} // namespace detail
26-
27-
} // namespace enums
28-
} // namespace yoga
29-
} // namespace facebook
30-
#endif
31-
32-
#define YG_ENUM_DECL(NAME, ...) \
33-
typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \
34-
WIN_EXPORT const char* NAME##ToString(NAME);
35-
36-
#ifdef __cplusplus
37-
#define YG_ENUM_SEQ_DECL(NAME, ...) \
38-
YG_ENUM_DECL(NAME, __VA_ARGS__) \
39-
YG_EXTERN_C_END \
40-
namespace facebook { \
41-
namespace yoga { \
42-
namespace enums { \
43-
template <> \
44-
constexpr int count<NAME>() { \
45-
return detail::n<__VA_ARGS__>(); \
46-
} \
47-
} \
48-
} \
49-
} \
50-
YG_EXTERN_C_BEGIN
51-
#else
52-
#define YG_ENUM_SEQ_DECL YG_ENUM_DECL
53-
#endif
54-
5515
YG_EXTERN_C_BEGIN
5616

5717
YG_ENUM_SEQ_DECL(
@@ -63,17 +23,23 @@ YG_ENUM_SEQ_DECL(
6323
YGAlignStretch,
6424
YGAlignBaseline,
6525
YGAlignSpaceBetween,
66-
YGAlignSpaceAround);
26+
YGAlignSpaceAround)
6727

68-
YG_ENUM_SEQ_DECL(YGDimension, YGDimensionWidth, YGDimensionHeight)
28+
YG_ENUM_SEQ_DECL(
29+
YGDimension,
30+
YGDimensionWidth,
31+
YGDimensionHeight)
6932

7033
YG_ENUM_SEQ_DECL(
7134
YGDirection,
7235
YGDirectionInherit,
7336
YGDirectionLTR,
7437
YGDirectionRTL)
7538

76-
YG_ENUM_SEQ_DECL(YGDisplay, YGDisplayFlex, YGDisplayNone)
39+
YG_ENUM_SEQ_DECL(
40+
YGDisplay,
41+
YGDisplayFlex,
42+
YGDisplayNone)
7743

7844
YG_ENUM_SEQ_DECL(
7945
YGEdge,
@@ -87,7 +53,9 @@ YG_ENUM_SEQ_DECL(
8753
YGEdgeVertical,
8854
YGEdgeAll)
8955

90-
YG_ENUM_SEQ_DECL(YGExperimentalFeature, YGExperimentalFeatureWebFlexBasis)
56+
YG_ENUM_SEQ_DECL(
57+
YGExperimentalFeature,
58+
YGExperimentalFeatureWebFlexBasis)
9159

9260
YG_ENUM_SEQ_DECL(
9361
YGFlexDirection,
@@ -120,7 +88,10 @@ YG_ENUM_SEQ_DECL(
12088
YGMeasureModeExactly,
12189
YGMeasureModeAtMost)
12290

123-
YG_ENUM_SEQ_DECL(YGNodeType, YGNodeTypeDefault, YGNodeTypeText)
91+
YG_ENUM_SEQ_DECL(
92+
YGNodeType,
93+
YGNodeTypeDefault,
94+
YGNodeTypeText)
12495

12596
YG_ENUM_SEQ_DECL(
12697
YGOverflow,
@@ -147,9 +118,10 @@ YG_ENUM_SEQ_DECL(
147118
YGUnitPercent,
148119
YGUnitAuto)
149120

150-
YG_ENUM_SEQ_DECL(YGWrap, YGWrapNoWrap, YGWrapWrap, YGWrapWrapReverse)
121+
YG_ENUM_SEQ_DECL(
122+
YGWrap,
123+
YGWrapNoWrap,
124+
YGWrapWrap,
125+
YGWrapWrapReverse)
151126

152127
YG_EXTERN_C_END
153-
154-
#undef YG_ENUM_DECL
155-
#undef YG_ENUM_SEQ_DECL

ReactCommon/yoga/yoga/YGMacros.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,49 @@
4040
#define YG_ENUM_END(name) name
4141
#endif
4242

43+
#ifdef __cplusplus
44+
namespace facebook {
45+
namespace yoga {
46+
namespace enums {
47+
48+
template <typename T>
49+
constexpr int count(); // can't use `= delete` due to a defect in clang < 3.9
50+
51+
namespace detail {
52+
template <int... xs>
53+
constexpr int n() {
54+
return sizeof...(xs);
55+
}
56+
} // namespace detail
57+
58+
} // namespace enums
59+
} // namespace yoga
60+
} // namespace facebook
61+
#endif
62+
63+
#define YG_ENUM_DECL(NAME, ...) \
64+
typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \
65+
WIN_EXPORT const char* NAME##ToString(NAME);
66+
67+
#ifdef __cplusplus
68+
#define YG_ENUM_SEQ_DECL(NAME, ...) \
69+
YG_ENUM_DECL(NAME, __VA_ARGS__) \
70+
YG_EXTERN_C_END \
71+
namespace facebook { \
72+
namespace yoga { \
73+
namespace enums { \
74+
template <> \
75+
constexpr int count<NAME>() { \
76+
return detail::n<__VA_ARGS__>(); \
77+
} \
78+
} \
79+
} \
80+
} \
81+
YG_EXTERN_C_BEGIN
82+
#else
83+
#define YG_ENUM_SEQ_DECL YG_ENUM_DECL
84+
#endif
85+
4386
#ifdef __GNUC__
4487
#define YG_DEPRECATED __attribute__((deprecated))
4588
#elif defined(_MSC_VER)

0 commit comments

Comments
 (0)