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 https://github.com/facebook/yoga/pull/322

Reviewed By: dshahidehpour

Differential Revision: D4386906

Pulled By: emilsjolander

fbshipit-source-id: 05ac0e571ef3a8ff0be31469e449a7b23f102218
This commit is contained in:
David Hart 2017-01-07 08:22:43 -08:00 committed by Facebook Github Bot
parent 48623f749c
commit e0cb6dff76
2 changed files with 44 additions and 28 deletions

View File

@ -14,29 +14,29 @@
YG_EXTERN_C_BEGIN YG_EXTERN_C_BEGIN
#define YGFlexDirectionCount 4 #define YGFlexDirectionCount 4
typedef enum YGFlexDirection { typedef YG_ENUM_BEGIN(YGFlexDirection) {
YGFlexDirectionColumn, YGFlexDirectionColumn,
YGFlexDirectionColumnReverse, YGFlexDirectionColumnReverse,
YGFlexDirectionRow, YGFlexDirectionRow,
YGFlexDirectionRowReverse, YGFlexDirectionRowReverse,
} YGFlexDirection; } YG_ENUM_END(YGFlexDirection);
#define YGMeasureModeCount 3 #define YGMeasureModeCount 3
typedef enum YGMeasureMode { typedef YG_ENUM_BEGIN(YGMeasureMode) {
YGMeasureModeUndefined, YGMeasureModeUndefined,
YGMeasureModeExactly, YGMeasureModeExactly,
YGMeasureModeAtMost, YGMeasureModeAtMost,
} YGMeasureMode; } YG_ENUM_END(YGMeasureMode);
#define YGPrintOptionsCount 3 #define YGPrintOptionsCount 3
typedef enum YGPrintOptions { typedef YG_ENUM_BEGIN(YGPrintOptions) {
YGPrintOptionsLayout = 1, YGPrintOptionsLayout = 1,
YGPrintOptionsStyle = 2, YGPrintOptionsStyle = 2,
YGPrintOptionsChildren = 4, YGPrintOptionsChildren = 4,
} YGPrintOptions; } YG_ENUM_END(YGPrintOptions);
#define YGEdgeCount 9 #define YGEdgeCount 9
typedef enum YGEdge { typedef YG_ENUM_BEGIN(YGEdge) {
YGEdgeLeft, YGEdgeLeft,
YGEdgeTop, YGEdgeTop,
YGEdgeRight, YGEdgeRight,
@ -46,79 +46,79 @@ typedef enum YGEdge {
YGEdgeHorizontal, YGEdgeHorizontal,
YGEdgeVertical, YGEdgeVertical,
YGEdgeAll, YGEdgeAll,
} YGEdge; } YG_ENUM_END(YGEdge);
#define YGPositionTypeCount 2 #define YGPositionTypeCount 2
typedef enum YGPositionType { typedef YG_ENUM_BEGIN(YGPositionType) {
YGPositionTypeRelative, YGPositionTypeRelative,
YGPositionTypeAbsolute, YGPositionTypeAbsolute,
} YGPositionType; } YG_ENUM_END(YGPositionType);
#define YGDimensionCount 2 #define YGDimensionCount 2
typedef enum YGDimension { typedef YG_ENUM_BEGIN(YGDimension) {
YGDimensionWidth, YGDimensionWidth,
YGDimensionHeight, YGDimensionHeight,
} YGDimension; } YG_ENUM_END(YGDimension);
#define YGJustifyCount 5 #define YGJustifyCount 5
typedef enum YGJustify { typedef YG_ENUM_BEGIN(YGJustify) {
YGJustifyFlexStart, YGJustifyFlexStart,
YGJustifyCenter, YGJustifyCenter,
YGJustifyFlexEnd, YGJustifyFlexEnd,
YGJustifySpaceBetween, YGJustifySpaceBetween,
YGJustifySpaceAround, YGJustifySpaceAround,
} YGJustify; } YG_ENUM_END(YGJustify);
#define YGDirectionCount 3 #define YGDirectionCount 3
typedef enum YGDirection { typedef YG_ENUM_BEGIN(YGDirection) {
YGDirectionInherit, YGDirectionInherit,
YGDirectionLTR, YGDirectionLTR,
YGDirectionRTL, YGDirectionRTL,
} YGDirection; } YG_ENUM_END(YGDirection);
#define YGLogLevelCount 5 #define YGLogLevelCount 5
typedef enum YGLogLevel { typedef YG_ENUM_BEGIN(YGLogLevel) {
YGLogLevelError, YGLogLevelError,
YGLogLevelWarn, YGLogLevelWarn,
YGLogLevelInfo, YGLogLevelInfo,
YGLogLevelDebug, YGLogLevelDebug,
YGLogLevelVerbose, YGLogLevelVerbose,
} YGLogLevel; } YG_ENUM_END(YGLogLevel);
#define YGWrapCount 2 #define YGWrapCount 2
typedef enum YGWrap { typedef YG_ENUM_BEGIN(YGWrap) {
YGWrapNoWrap, YGWrapNoWrap,
YGWrapWrap, YGWrapWrap,
} YGWrap; } YG_ENUM_END(YGWrap);
#define YGOverflowCount 3 #define YGOverflowCount 3
typedef enum YGOverflow { typedef YG_ENUM_BEGIN(YGOverflow) {
YGOverflowVisible, YGOverflowVisible,
YGOverflowHidden, YGOverflowHidden,
YGOverflowScroll, YGOverflowScroll,
} YGOverflow; } YG_ENUM_END(YGOverflow);
#define YGExperimentalFeatureCount 2 #define YGExperimentalFeatureCount 2
typedef enum YGExperimentalFeature { typedef YG_ENUM_BEGIN(YGExperimentalFeature) {
YGExperimentalFeatureRounding, YGExperimentalFeatureRounding,
YGExperimentalFeatureWebFlexBasis, YGExperimentalFeatureWebFlexBasis,
} YGExperimentalFeature; } YG_ENUM_END(YGExperimentalFeature);
#define YGAlignCount 6 #define YGAlignCount 6
typedef enum YGAlign { typedef YG_ENUM_BEGIN(YGAlign) {
YGAlignAuto, YGAlignAuto,
YGAlignFlexStart, YGAlignFlexStart,
YGAlignCenter, YGAlignCenter,
YGAlignFlexEnd, YGAlignFlexEnd,
YGAlignStretch, YGAlignStretch,
YGAlignBaseline, YGAlignBaseline,
} YGAlign; } YG_ENUM_END(YGAlign);
#define YGUnitCount 3 #define YGUnitCount 3
typedef enum YGUnit { typedef YG_ENUM_BEGIN(YGUnit) {
YGUnitUndefined, YGUnitUndefined,
YGUnitPixel, YGUnitPixel,
YGUnitPercent, YGUnitPercent,
} YGUnit; } YG_ENUM_END(YGUnit);
YG_EXTERN_C_END YG_EXTERN_C_END

View File

@ -40,3 +40,19 @@
YG_ABORT(); \ YG_ABORT(); \
} }
#endif #endif
#ifndef YG_ENUM_BEGIN
#ifndef NS_ENUM
#define YG_ENUM_BEGIN(name) enum name
#else
#define YG_ENUM_BEGIN(name) NS_ENUM(NSInteger, name)
#endif
#endif
#ifndef YG_ENUM_END
#ifndef NS_ENUM
#define YG_ENUM_END(name) name
#else
#define YG_ENUM_END(name)
#endif
#endif