Skip to content

Commit e0cb6df

Browse files
hartbitfacebook-github-bot
authored andcommitted
Improved the objective-c and swift api
Summary: Compared to what was planned, I added the `overflow` value which seemed missing. I had to modify the implementation a bit for all values which are backed by a `YGValue`, but we should probably enable the pixel dimensions in Objective-C and Swift somehow later. Closes facebook/yoga#322 Reviewed By: dshahidehpour Differential Revision: D4386906 Pulled By: emilsjolander fbshipit-source-id: 05ac0e571ef3a8ff0be31469e449a7b23f102218
1 parent 48623f7 commit e0cb6df

File tree

2 files changed

+44
-28
lines changed

2 files changed

+44
-28
lines changed

ReactCommon/yoga/yoga/YGEnums.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@
1414
YG_EXTERN_C_BEGIN
1515

1616
#define YGFlexDirectionCount 4
17-
typedef enum YGFlexDirection {
17+
typedef YG_ENUM_BEGIN(YGFlexDirection) {
1818
YGFlexDirectionColumn,
1919
YGFlexDirectionColumnReverse,
2020
YGFlexDirectionRow,
2121
YGFlexDirectionRowReverse,
22-
} YGFlexDirection;
22+
} YG_ENUM_END(YGFlexDirection);
2323

2424
#define YGMeasureModeCount 3
25-
typedef enum YGMeasureMode {
25+
typedef YG_ENUM_BEGIN(YGMeasureMode) {
2626
YGMeasureModeUndefined,
2727
YGMeasureModeExactly,
2828
YGMeasureModeAtMost,
29-
} YGMeasureMode;
29+
} YG_ENUM_END(YGMeasureMode);
3030

3131
#define YGPrintOptionsCount 3
32-
typedef enum YGPrintOptions {
32+
typedef YG_ENUM_BEGIN(YGPrintOptions) {
3333
YGPrintOptionsLayout = 1,
3434
YGPrintOptionsStyle = 2,
3535
YGPrintOptionsChildren = 4,
36-
} YGPrintOptions;
36+
} YG_ENUM_END(YGPrintOptions);
3737

3838
#define YGEdgeCount 9
39-
typedef enum YGEdge {
39+
typedef YG_ENUM_BEGIN(YGEdge) {
4040
YGEdgeLeft,
4141
YGEdgeTop,
4242
YGEdgeRight,
@@ -46,79 +46,79 @@ typedef enum YGEdge {
4646
YGEdgeHorizontal,
4747
YGEdgeVertical,
4848
YGEdgeAll,
49-
} YGEdge;
49+
} YG_ENUM_END(YGEdge);
5050

5151
#define YGPositionTypeCount 2
52-
typedef enum YGPositionType {
52+
typedef YG_ENUM_BEGIN(YGPositionType) {
5353
YGPositionTypeRelative,
5454
YGPositionTypeAbsolute,
55-
} YGPositionType;
55+
} YG_ENUM_END(YGPositionType);
5656

5757
#define YGDimensionCount 2
58-
typedef enum YGDimension {
58+
typedef YG_ENUM_BEGIN(YGDimension) {
5959
YGDimensionWidth,
6060
YGDimensionHeight,
61-
} YGDimension;
61+
} YG_ENUM_END(YGDimension);
6262

6363
#define YGJustifyCount 5
64-
typedef enum YGJustify {
64+
typedef YG_ENUM_BEGIN(YGJustify) {
6565
YGJustifyFlexStart,
6666
YGJustifyCenter,
6767
YGJustifyFlexEnd,
6868
YGJustifySpaceBetween,
6969
YGJustifySpaceAround,
70-
} YGJustify;
70+
} YG_ENUM_END(YGJustify);
7171

7272
#define YGDirectionCount 3
73-
typedef enum YGDirection {
73+
typedef YG_ENUM_BEGIN(YGDirection) {
7474
YGDirectionInherit,
7575
YGDirectionLTR,
7676
YGDirectionRTL,
77-
} YGDirection;
77+
} YG_ENUM_END(YGDirection);
7878

7979
#define YGLogLevelCount 5
80-
typedef enum YGLogLevel {
80+
typedef YG_ENUM_BEGIN(YGLogLevel) {
8181
YGLogLevelError,
8282
YGLogLevelWarn,
8383
YGLogLevelInfo,
8484
YGLogLevelDebug,
8585
YGLogLevelVerbose,
86-
} YGLogLevel;
86+
} YG_ENUM_END(YGLogLevel);
8787

8888
#define YGWrapCount 2
89-
typedef enum YGWrap {
89+
typedef YG_ENUM_BEGIN(YGWrap) {
9090
YGWrapNoWrap,
9191
YGWrapWrap,
92-
} YGWrap;
92+
} YG_ENUM_END(YGWrap);
9393

9494
#define YGOverflowCount 3
95-
typedef enum YGOverflow {
95+
typedef YG_ENUM_BEGIN(YGOverflow) {
9696
YGOverflowVisible,
9797
YGOverflowHidden,
9898
YGOverflowScroll,
99-
} YGOverflow;
99+
} YG_ENUM_END(YGOverflow);
100100

101101
#define YGExperimentalFeatureCount 2
102-
typedef enum YGExperimentalFeature {
102+
typedef YG_ENUM_BEGIN(YGExperimentalFeature) {
103103
YGExperimentalFeatureRounding,
104104
YGExperimentalFeatureWebFlexBasis,
105-
} YGExperimentalFeature;
105+
} YG_ENUM_END(YGExperimentalFeature);
106106

107107
#define YGAlignCount 6
108-
typedef enum YGAlign {
108+
typedef YG_ENUM_BEGIN(YGAlign) {
109109
YGAlignAuto,
110110
YGAlignFlexStart,
111111
YGAlignCenter,
112112
YGAlignFlexEnd,
113113
YGAlignStretch,
114114
YGAlignBaseline,
115-
} YGAlign;
115+
} YG_ENUM_END(YGAlign);
116116

117117
#define YGUnitCount 3
118-
typedef enum YGUnit {
118+
typedef YG_ENUM_BEGIN(YGUnit) {
119119
YGUnitUndefined,
120120
YGUnitPixel,
121121
YGUnitPercent,
122-
} YGUnit;
122+
} YG_ENUM_END(YGUnit);
123123

124124
YG_EXTERN_C_END

ReactCommon/yoga/yoga/YGMacros.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,19 @@
4040
YG_ABORT(); \
4141
}
4242
#endif
43+
44+
#ifndef YG_ENUM_BEGIN
45+
#ifndef NS_ENUM
46+
#define YG_ENUM_BEGIN(name) enum name
47+
#else
48+
#define YG_ENUM_BEGIN(name) NS_ENUM(NSInteger, name)
49+
#endif
50+
#endif
51+
52+
#ifndef YG_ENUM_END
53+
#ifndef NS_ENUM
54+
#define YG_ENUM_END(name) name
55+
#else
56+
#define YG_ENUM_END(name)
57+
#endif
58+
#endif

0 commit comments

Comments
 (0)