YGEnums.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the LICENSE
  5. * file in the root directory of this source tree.
  6. */
  7. #pragma once
  8. #include "YGMacros.h"
  9. #ifdef __cplusplus
  10. namespace facebook {
  11. namespace yoga {
  12. namespace enums {
  13. template <typename T>
  14. constexpr int count(); // can't use `= delete` due to a defect in clang < 3.9
  15. namespace detail {
  16. template <int... xs>
  17. constexpr int n() {
  18. return sizeof...(xs);
  19. }
  20. } // namespace detail
  21. } // namespace enums
  22. } // namespace yoga
  23. } // namespace facebook
  24. #endif
  25. #define YG_ENUM_DECL(NAME, ...) \
  26. typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \
  27. WIN_EXPORT const char* NAME##ToString(NAME);
  28. #ifdef __cplusplus
  29. #define YG_ENUM_SEQ_DECL(NAME, ...) \
  30. YG_ENUM_DECL(NAME, __VA_ARGS__) \
  31. YG_EXTERN_C_END \
  32. namespace facebook { \
  33. namespace yoga { \
  34. namespace enums { \
  35. template <> \
  36. constexpr int count<NAME>() { \
  37. return detail::n<__VA_ARGS__>(); \
  38. } \
  39. } \
  40. } \
  41. } \
  42. YG_EXTERN_C_BEGIN
  43. #else
  44. #define YG_ENUM_SEQ_DECL YG_ENUM_DECL
  45. #endif
  46. YG_EXTERN_C_BEGIN
  47. YG_ENUM_SEQ_DECL(
  48. YGAlign,
  49. YGAlignAuto,
  50. YGAlignFlexStart,
  51. YGAlignCenter,
  52. YGAlignFlexEnd,
  53. YGAlignStretch,
  54. YGAlignBaseline,
  55. YGAlignSpaceBetween,
  56. YGAlignSpaceAround);
  57. YG_ENUM_SEQ_DECL(YGDimension, YGDimensionWidth, YGDimensionHeight)
  58. YG_ENUM_SEQ_DECL(
  59. YGDirection,
  60. YGDirectionInherit,
  61. YGDirectionLTR,
  62. YGDirectionRTL)
  63. YG_ENUM_SEQ_DECL(YGDisplay, YGDisplayFlex, YGDisplayNone)
  64. YG_ENUM_SEQ_DECL(
  65. YGEdge,
  66. YGEdgeLeft,
  67. YGEdgeTop,
  68. YGEdgeRight,
  69. YGEdgeBottom,
  70. YGEdgeStart,
  71. YGEdgeEnd,
  72. YGEdgeHorizontal,
  73. YGEdgeVertical,
  74. YGEdgeAll)
  75. YG_ENUM_SEQ_DECL(YGExperimentalFeature, YGExperimentalFeatureWebFlexBasis)
  76. YG_ENUM_SEQ_DECL(
  77. YGFlexDirection,
  78. YGFlexDirectionColumn,
  79. YGFlexDirectionColumnReverse,
  80. YGFlexDirectionRow,
  81. YGFlexDirectionRowReverse)
  82. YG_ENUM_SEQ_DECL(
  83. YGJustify,
  84. YGJustifyFlexStart,
  85. YGJustifyCenter,
  86. YGJustifyFlexEnd,
  87. YGJustifySpaceBetween,
  88. YGJustifySpaceAround,
  89. YGJustifySpaceEvenly)
  90. YG_ENUM_SEQ_DECL(
  91. YGLogLevel,
  92. YGLogLevelError,
  93. YGLogLevelWarn,
  94. YGLogLevelInfo,
  95. YGLogLevelDebug,
  96. YGLogLevelVerbose,
  97. YGLogLevelFatal)
  98. YG_ENUM_SEQ_DECL(
  99. YGMeasureMode,
  100. YGMeasureModeUndefined,
  101. YGMeasureModeExactly,
  102. YGMeasureModeAtMost)
  103. YG_ENUM_SEQ_DECL(YGNodeType, YGNodeTypeDefault, YGNodeTypeText)
  104. YG_ENUM_SEQ_DECL(
  105. YGOverflow,
  106. YGOverflowVisible,
  107. YGOverflowHidden,
  108. YGOverflowScroll)
  109. YG_ENUM_SEQ_DECL(YGPositionType, YGPositionTypeRelative, YGPositionTypeAbsolute)
  110. YG_ENUM_DECL(
  111. YGPrintOptions,
  112. YGPrintOptionsLayout = 1,
  113. YGPrintOptionsStyle = 2,
  114. YGPrintOptionsChildren = 4)
  115. YG_ENUM_SEQ_DECL(
  116. YGUnit,
  117. YGUnitUndefined,
  118. YGUnitPoint,
  119. YGUnitPercent,
  120. YGUnitAuto)
  121. YG_ENUM_SEQ_DECL(YGWrap, YGWrapNoWrap, YGWrapWrap, YGWrapWrapReverse)
  122. YG_EXTERN_C_END
  123. #undef YG_ENUM_DECL
  124. #undef YG_ENUM_SEQ_DECL