Remove repetition in YGEnums.h
Summary: @public Wraps enum definition in a single macro. Down the line, this will allow us to add more functionality: - Replace manual counts with `yoga::enums::count<YG...>()` - `yoga::enums::max<YG...>()` - A bitfield implementation with known memory layout using `max<>()` Reviewed By: SidharthGuglani Differential Revision: D13597259 fbshipit-source-id: 543a11a53090bedf1474d00328565ed57d059e23
This commit is contained in:
committed by
Facebook Github Bot
parent
ab9d06abf5
commit
4b97375524
114
yoga/YGEnums.h
114
yoga/YGEnums.h
@@ -8,10 +8,15 @@
|
|||||||
|
|
||||||
#include "YGMacros.h"
|
#include "YGMacros.h"
|
||||||
|
|
||||||
|
#define YG_ENUM_DECL(NAME, ...) \
|
||||||
|
typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \
|
||||||
|
WIN_EXPORT const char* NAME##ToString(NAME);
|
||||||
|
|
||||||
YG_EXTERN_C_BEGIN
|
YG_EXTERN_C_BEGIN
|
||||||
|
|
||||||
#define YGAlignCount 8
|
#define YGAlignCount 8
|
||||||
typedef YG_ENUM_BEGIN(YGAlign){
|
YG_ENUM_DECL(
|
||||||
|
YGAlign,
|
||||||
YGAlignAuto,
|
YGAlignAuto,
|
||||||
YGAlignFlexStart,
|
YGAlignFlexStart,
|
||||||
YGAlignCenter,
|
YGAlignCenter,
|
||||||
@@ -19,34 +24,20 @@ typedef YG_ENUM_BEGIN(YGAlign){
|
|||||||
YGAlignStretch,
|
YGAlignStretch,
|
||||||
YGAlignBaseline,
|
YGAlignBaseline,
|
||||||
YGAlignSpaceBetween,
|
YGAlignSpaceBetween,
|
||||||
YGAlignSpaceAround,
|
YGAlignSpaceAround);
|
||||||
} YG_ENUM_END(YGAlign);
|
|
||||||
WIN_EXPORT const char* YGAlignToString(const YGAlign value);
|
|
||||||
|
|
||||||
#define YGDimensionCount 2
|
#define YGDimensionCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGDimension){
|
YG_ENUM_DECL(YGDimension, YGDimensionWidth, YGDimensionHeight)
|
||||||
YGDimensionWidth,
|
|
||||||
YGDimensionHeight,
|
|
||||||
} YG_ENUM_END(YGDimension);
|
|
||||||
WIN_EXPORT const char* YGDimensionToString(const YGDimension value);
|
|
||||||
|
|
||||||
#define YGDirectionCount 3
|
#define YGDirectionCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGDirection){
|
YG_ENUM_DECL(YGDirection, YGDirectionInherit, YGDirectionLTR, YGDirectionRTL)
|
||||||
YGDirectionInherit,
|
|
||||||
YGDirectionLTR,
|
|
||||||
YGDirectionRTL,
|
|
||||||
} YG_ENUM_END(YGDirection);
|
|
||||||
WIN_EXPORT const char* YGDirectionToString(const YGDirection value);
|
|
||||||
|
|
||||||
#define YGDisplayCount 2
|
#define YGDisplayCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGDisplay){
|
YG_ENUM_DECL(YGDisplay, YGDisplayFlex, YGDisplayNone)
|
||||||
YGDisplayFlex,
|
|
||||||
YGDisplayNone,
|
|
||||||
} YG_ENUM_END(YGDisplay);
|
|
||||||
WIN_EXPORT const char* YGDisplayToString(const YGDisplay value);
|
|
||||||
|
|
||||||
#define YGEdgeCount 9
|
#define YGEdgeCount 9
|
||||||
typedef YG_ENUM_BEGIN(YGEdge){
|
YG_ENUM_DECL(
|
||||||
|
YGEdge,
|
||||||
YGEdgeLeft,
|
YGEdgeLeft,
|
||||||
YGEdgeTop,
|
YGEdgeTop,
|
||||||
YGEdgeRight,
|
YGEdgeRight,
|
||||||
@@ -55,101 +46,68 @@ typedef YG_ENUM_BEGIN(YGEdge){
|
|||||||
YGEdgeEnd,
|
YGEdgeEnd,
|
||||||
YGEdgeHorizontal,
|
YGEdgeHorizontal,
|
||||||
YGEdgeVertical,
|
YGEdgeVertical,
|
||||||
YGEdgeAll,
|
YGEdgeAll)
|
||||||
} YG_ENUM_END(YGEdge);
|
|
||||||
WIN_EXPORT const char* YGEdgeToString(const YGEdge value);
|
|
||||||
|
|
||||||
#define YGExperimentalFeatureCount 1
|
#define YGExperimentalFeatureCount 1
|
||||||
typedef YG_ENUM_BEGIN(YGExperimentalFeature){
|
YG_ENUM_DECL(YGExperimentalFeature, YGExperimentalFeatureWebFlexBasis)
|
||||||
YGExperimentalFeatureWebFlexBasis,
|
|
||||||
} YG_ENUM_END(YGExperimentalFeature);
|
|
||||||
WIN_EXPORT const char* YGExperimentalFeatureToString(
|
|
||||||
const YGExperimentalFeature value);
|
|
||||||
|
|
||||||
#define YGFlexDirectionCount 4
|
#define YGFlexDirectionCount 4
|
||||||
typedef YG_ENUM_BEGIN(YGFlexDirection){
|
YG_ENUM_DECL(
|
||||||
|
YGFlexDirection,
|
||||||
YGFlexDirectionColumn,
|
YGFlexDirectionColumn,
|
||||||
YGFlexDirectionColumnReverse,
|
YGFlexDirectionColumnReverse,
|
||||||
YGFlexDirectionRow,
|
YGFlexDirectionRow,
|
||||||
YGFlexDirectionRowReverse,
|
YGFlexDirectionRowReverse)
|
||||||
} YG_ENUM_END(YGFlexDirection);
|
|
||||||
WIN_EXPORT const char* YGFlexDirectionToString(const YGFlexDirection value);
|
|
||||||
|
|
||||||
#define YGJustifyCount 6
|
#define YGJustifyCount 6
|
||||||
typedef YG_ENUM_BEGIN(YGJustify){
|
YG_ENUM_DECL(
|
||||||
|
YGJustify,
|
||||||
YGJustifyFlexStart,
|
YGJustifyFlexStart,
|
||||||
YGJustifyCenter,
|
YGJustifyCenter,
|
||||||
YGJustifyFlexEnd,
|
YGJustifyFlexEnd,
|
||||||
YGJustifySpaceBetween,
|
YGJustifySpaceBetween,
|
||||||
YGJustifySpaceAround,
|
YGJustifySpaceAround,
|
||||||
YGJustifySpaceEvenly,
|
YGJustifySpaceEvenly)
|
||||||
} YG_ENUM_END(YGJustify);
|
|
||||||
WIN_EXPORT const char* YGJustifyToString(const YGJustify value);
|
|
||||||
|
|
||||||
#define YGLogLevelCount 6
|
#define YGLogLevelCount 6
|
||||||
typedef YG_ENUM_BEGIN(YGLogLevel){
|
YG_ENUM_DECL(
|
||||||
|
YGLogLevel,
|
||||||
YGLogLevelError,
|
YGLogLevelError,
|
||||||
YGLogLevelWarn,
|
YGLogLevelWarn,
|
||||||
YGLogLevelInfo,
|
YGLogLevelInfo,
|
||||||
YGLogLevelDebug,
|
YGLogLevelDebug,
|
||||||
YGLogLevelVerbose,
|
YGLogLevelVerbose,
|
||||||
YGLogLevelFatal,
|
YGLogLevelFatal)
|
||||||
} YG_ENUM_END(YGLogLevel);
|
|
||||||
WIN_EXPORT const char* YGLogLevelToString(const YGLogLevel value);
|
|
||||||
|
|
||||||
#define YGMeasureModeCount 3
|
#define YGMeasureModeCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGMeasureMode){
|
YG_ENUM_DECL(
|
||||||
|
YGMeasureMode,
|
||||||
YGMeasureModeUndefined,
|
YGMeasureModeUndefined,
|
||||||
YGMeasureModeExactly,
|
YGMeasureModeExactly,
|
||||||
YGMeasureModeAtMost,
|
YGMeasureModeAtMost)
|
||||||
} YG_ENUM_END(YGMeasureMode);
|
|
||||||
WIN_EXPORT const char* YGMeasureModeToString(const YGMeasureMode value);
|
|
||||||
|
|
||||||
#define YGNodeTypeCount 2
|
#define YGNodeTypeCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGNodeType){
|
YG_ENUM_DECL(YGNodeType, YGNodeTypeDefault, YGNodeTypeText)
|
||||||
YGNodeTypeDefault,
|
|
||||||
YGNodeTypeText,
|
|
||||||
} YG_ENUM_END(YGNodeType);
|
|
||||||
WIN_EXPORT const char* YGNodeTypeToString(const YGNodeType value);
|
|
||||||
|
|
||||||
#define YGOverflowCount 3
|
#define YGOverflowCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGOverflow){
|
YG_ENUM_DECL(YGOverflow, YGOverflowVisible, YGOverflowHidden, YGOverflowScroll)
|
||||||
YGOverflowVisible,
|
|
||||||
YGOverflowHidden,
|
|
||||||
YGOverflowScroll,
|
|
||||||
} YG_ENUM_END(YGOverflow);
|
|
||||||
WIN_EXPORT const char* YGOverflowToString(const YGOverflow value);
|
|
||||||
|
|
||||||
#define YGPositionTypeCount 2
|
#define YGPositionTypeCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGPositionType){
|
YG_ENUM_DECL(YGPositionType, YGPositionTypeRelative, YGPositionTypeAbsolute)
|
||||||
YGPositionTypeRelative,
|
|
||||||
YGPositionTypeAbsolute,
|
|
||||||
} YG_ENUM_END(YGPositionType);
|
|
||||||
WIN_EXPORT const char* YGPositionTypeToString(const YGPositionType value);
|
|
||||||
|
|
||||||
#define YGPrintOptionsCount 3
|
#define YGPrintOptionsCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGPrintOptions){
|
YG_ENUM_DECL(
|
||||||
|
YGPrintOptions,
|
||||||
YGPrintOptionsLayout = 1,
|
YGPrintOptionsLayout = 1,
|
||||||
YGPrintOptionsStyle = 2,
|
YGPrintOptionsStyle = 2,
|
||||||
YGPrintOptionsChildren = 4,
|
YGPrintOptionsChildren = 4)
|
||||||
} YG_ENUM_END(YGPrintOptions);
|
|
||||||
WIN_EXPORT const char* YGPrintOptionsToString(const YGPrintOptions value);
|
|
||||||
|
|
||||||
#define YGUnitCount 4
|
#define YGUnitCount 4
|
||||||
typedef YG_ENUM_BEGIN(YGUnit){
|
YG_ENUM_DECL(YGUnit, YGUnitUndefined, YGUnitPoint, YGUnitPercent, YGUnitAuto)
|
||||||
YGUnitUndefined,
|
|
||||||
YGUnitPoint,
|
|
||||||
YGUnitPercent,
|
|
||||||
YGUnitAuto,
|
|
||||||
} YG_ENUM_END(YGUnit);
|
|
||||||
WIN_EXPORT const char* YGUnitToString(const YGUnit value);
|
|
||||||
|
|
||||||
#define YGWrapCount 3
|
#define YGWrapCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGWrap){
|
YG_ENUM_DECL(YGWrap, YGWrapNoWrap, YGWrapWrap, YGWrapWrapReverse)
|
||||||
YGWrapNoWrap,
|
|
||||||
YGWrapWrap,
|
|
||||||
YGWrapWrapReverse,
|
|
||||||
} YG_ENUM_END(YGWrap);
|
|
||||||
WIN_EXPORT const char* YGWrapToString(const YGWrap value);
|
|
||||||
|
|
||||||
YG_EXTERN_C_END
|
YG_EXTERN_C_END
|
||||||
|
|
||||||
|
#undef YG_ENUM_DECL
|
||||||
|
Reference in New Issue
Block a user