Revert D13597449: [Yoga][cleanup] Remove enum count macros
Differential Revision: D13597449 Original commit changeset: edcee225ada4 fbshipit-source-id: 1afc24833c8657a8a198bc4529d98c8f605b7fbd
This commit is contained in:
committed by
Facebook Github Bot
parent
3467308874
commit
866bf101b2
@@ -10,8 +10,7 @@
|
|||||||
#include "Yoga.h"
|
#include "Yoga.h"
|
||||||
|
|
||||||
struct YGConfig {
|
struct YGConfig {
|
||||||
std::array<bool, facebook::yoga::enums::count<YGExperimentalFeature>()>
|
std::array<bool, YGExperimentalFeatureCount> experimentalFeatures = {};
|
||||||
experimentalFeatures = {};
|
|
||||||
bool useWebDefaults = false;
|
bool useWebDefaults = false;
|
||||||
bool useLegacyStretchBehaviour = false;
|
bool useLegacyStretchBehaviour = false;
|
||||||
bool shouldDiffLayoutWithoutLegacyStretchBehaviour = false;
|
bool shouldDiffLayoutWithoutLegacyStretchBehaviour = false;
|
||||||
|
@@ -8,52 +8,14 @@
|
|||||||
|
|
||||||
#include "YGMacros.h"
|
#include "YGMacros.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
namespace facebook {
|
|
||||||
namespace yoga {
|
|
||||||
namespace enums {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
constexpr int count() = delete;
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
template <int... xs>
|
|
||||||
constexpr int n() {
|
|
||||||
return sizeof...(xs);
|
|
||||||
}
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
} // namespace enums
|
|
||||||
} // namespace yoga
|
|
||||||
} // namespace facebook
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YG_ENUM_DECL(NAME, ...) \
|
#define YG_ENUM_DECL(NAME, ...) \
|
||||||
typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \
|
typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \
|
||||||
WIN_EXPORT const char* NAME##ToString(NAME);
|
WIN_EXPORT const char* NAME##ToString(NAME);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#define YG_ENUM_SEQ_DECL(NAME, ...) \
|
|
||||||
YG_ENUM_DECL(NAME, __VA_ARGS__) \
|
|
||||||
YG_EXTERN_C_END \
|
|
||||||
namespace facebook { \
|
|
||||||
namespace yoga { \
|
|
||||||
namespace enums { \
|
|
||||||
template <> \
|
|
||||||
constexpr int count<NAME>() { \
|
|
||||||
return detail::n<__VA_ARGS__>(); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
YG_EXTERN_C_BEGIN
|
|
||||||
#else
|
|
||||||
#define YG_ENUM_SEQ_DECL YG_ENUM_DECL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
YG_EXTERN_C_BEGIN
|
YG_EXTERN_C_BEGIN
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(
|
#define YGAlignCount 8
|
||||||
|
YG_ENUM_DECL(
|
||||||
YGAlign,
|
YGAlign,
|
||||||
YGAlignAuto,
|
YGAlignAuto,
|
||||||
YGAlignFlexStart,
|
YGAlignFlexStart,
|
||||||
@@ -64,17 +26,17 @@ YG_ENUM_SEQ_DECL(
|
|||||||
YGAlignSpaceBetween,
|
YGAlignSpaceBetween,
|
||||||
YGAlignSpaceAround);
|
YGAlignSpaceAround);
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(YGDimension, YGDimensionWidth, YGDimensionHeight)
|
#define YGDimensionCount 2
|
||||||
|
YG_ENUM_DECL(YGDimension, YGDimensionWidth, YGDimensionHeight)
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(
|
#define YGDirectionCount 3
|
||||||
YGDirection,
|
YG_ENUM_DECL(YGDirection, YGDirectionInherit, YGDirectionLTR, YGDirectionRTL)
|
||||||
YGDirectionInherit,
|
|
||||||
YGDirectionLTR,
|
|
||||||
YGDirectionRTL)
|
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(YGDisplay, YGDisplayFlex, YGDisplayNone)
|
#define YGDisplayCount 2
|
||||||
|
YG_ENUM_DECL(YGDisplay, YGDisplayFlex, YGDisplayNone)
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(
|
#define YGEdgeCount 9
|
||||||
|
YG_ENUM_DECL(
|
||||||
YGEdge,
|
YGEdge,
|
||||||
YGEdgeLeft,
|
YGEdgeLeft,
|
||||||
YGEdgeTop,
|
YGEdgeTop,
|
||||||
@@ -86,16 +48,19 @@ YG_ENUM_SEQ_DECL(
|
|||||||
YGEdgeVertical,
|
YGEdgeVertical,
|
||||||
YGEdgeAll)
|
YGEdgeAll)
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(YGExperimentalFeature, YGExperimentalFeatureWebFlexBasis)
|
#define YGExperimentalFeatureCount 1
|
||||||
|
YG_ENUM_DECL(YGExperimentalFeature, YGExperimentalFeatureWebFlexBasis)
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(
|
#define YGFlexDirectionCount 4
|
||||||
|
YG_ENUM_DECL(
|
||||||
YGFlexDirection,
|
YGFlexDirection,
|
||||||
YGFlexDirectionColumn,
|
YGFlexDirectionColumn,
|
||||||
YGFlexDirectionColumnReverse,
|
YGFlexDirectionColumnReverse,
|
||||||
YGFlexDirectionRow,
|
YGFlexDirectionRow,
|
||||||
YGFlexDirectionRowReverse)
|
YGFlexDirectionRowReverse)
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(
|
#define YGJustifyCount 6
|
||||||
|
YG_ENUM_DECL(
|
||||||
YGJustify,
|
YGJustify,
|
||||||
YGJustifyFlexStart,
|
YGJustifyFlexStart,
|
||||||
YGJustifyCenter,
|
YGJustifyCenter,
|
||||||
@@ -104,7 +69,8 @@ YG_ENUM_SEQ_DECL(
|
|||||||
YGJustifySpaceAround,
|
YGJustifySpaceAround,
|
||||||
YGJustifySpaceEvenly)
|
YGJustifySpaceEvenly)
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(
|
#define YGLogLevelCount 6
|
||||||
|
YG_ENUM_DECL(
|
||||||
YGLogLevel,
|
YGLogLevel,
|
||||||
YGLogLevelError,
|
YGLogLevelError,
|
||||||
YGLogLevelWarn,
|
YGLogLevelWarn,
|
||||||
@@ -113,38 +79,35 @@ YG_ENUM_SEQ_DECL(
|
|||||||
YGLogLevelVerbose,
|
YGLogLevelVerbose,
|
||||||
YGLogLevelFatal)
|
YGLogLevelFatal)
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(
|
#define YGMeasureModeCount 3
|
||||||
|
YG_ENUM_DECL(
|
||||||
YGMeasureMode,
|
YGMeasureMode,
|
||||||
YGMeasureModeUndefined,
|
YGMeasureModeUndefined,
|
||||||
YGMeasureModeExactly,
|
YGMeasureModeExactly,
|
||||||
YGMeasureModeAtMost)
|
YGMeasureModeAtMost)
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(YGNodeType, YGNodeTypeDefault, YGNodeTypeText)
|
#define YGNodeTypeCount 2
|
||||||
|
YG_ENUM_DECL(YGNodeType, YGNodeTypeDefault, YGNodeTypeText)
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(
|
#define YGOverflowCount 3
|
||||||
YGOverflow,
|
YG_ENUM_DECL(YGOverflow, YGOverflowVisible, YGOverflowHidden, YGOverflowScroll)
|
||||||
YGOverflowVisible,
|
|
||||||
YGOverflowHidden,
|
|
||||||
YGOverflowScroll)
|
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(YGPositionType, YGPositionTypeRelative, YGPositionTypeAbsolute)
|
#define YGPositionTypeCount 2
|
||||||
|
YG_ENUM_DECL(YGPositionType, YGPositionTypeRelative, YGPositionTypeAbsolute)
|
||||||
|
|
||||||
|
#define YGPrintOptionsCount 3
|
||||||
YG_ENUM_DECL(
|
YG_ENUM_DECL(
|
||||||
YGPrintOptions,
|
YGPrintOptions,
|
||||||
YGPrintOptionsLayout = 1,
|
YGPrintOptionsLayout = 1,
|
||||||
YGPrintOptionsStyle = 2,
|
YGPrintOptionsStyle = 2,
|
||||||
YGPrintOptionsChildren = 4)
|
YGPrintOptionsChildren = 4)
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(
|
#define YGUnitCount 4
|
||||||
YGUnit,
|
YG_ENUM_DECL(YGUnit, YGUnitUndefined, YGUnitPoint, YGUnitPercent, YGUnitAuto)
|
||||||
YGUnitUndefined,
|
|
||||||
YGUnitPoint,
|
|
||||||
YGUnitPercent,
|
|
||||||
YGUnitAuto)
|
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(YGWrap, YGWrapNoWrap, YGWrapWrap, YGWrapWrapReverse)
|
#define YGWrapCount 3
|
||||||
|
YG_ENUM_DECL(YGWrap, YGWrapNoWrap, YGWrapWrap, YGWrapWrapReverse)
|
||||||
|
|
||||||
YG_EXTERN_C_END
|
YG_EXTERN_C_END
|
||||||
|
|
||||||
#undef YG_ENUM_DECL
|
#undef YG_ENUM_DECL
|
||||||
#undef YG_ENUM_SEQ_DECL
|
|
||||||
|
@@ -313,8 +313,7 @@ YGValue YGNode::resolveFlexBasisPtr() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void YGNode::resolveDimension() {
|
void YGNode::resolveDimension() {
|
||||||
using namespace yoga;
|
for (uint32_t dim = YGDimensionWidth; dim < YGDimensionCount; dim++) {
|
||||||
for (int dim = YGDimensionWidth; dim < enums::count<YGDimension>(); dim++) {
|
|
||||||
if (!getStyle().maxDimensions[dim].isUndefined() &&
|
if (!getStyle().maxDimensions[dim].isUndefined() &&
|
||||||
YGValueEqual(
|
YGValueEqual(
|
||||||
getStyle().maxDimensions[dim], style_.minDimensions[dim])) {
|
getStyle().maxDimensions[dim], style_.minDimensions[dim])) {
|
||||||
|
@@ -20,7 +20,8 @@ static void indent(string& base, uint32_t level) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool areFourValuesEqual(const YGStyle::Edges& four) {
|
static bool areFourValuesEqual(
|
||||||
|
const facebook::yoga::detail::Values<YGEdgeCount>& four) {
|
||||||
return YGValueEqual(four[0], four[1]) && YGValueEqual(four[0], four[2]) &&
|
return YGValueEqual(four[0], four[1]) && YGValueEqual(four[0], four[2]) &&
|
||||||
YGValueEqual(four[0], four[3]);
|
YGValueEqual(four[0], four[3]);
|
||||||
}
|
}
|
||||||
@@ -85,7 +86,7 @@ static void appendNumberIfNotZero(
|
|||||||
static void appendEdges(
|
static void appendEdges(
|
||||||
string& base,
|
string& base,
|
||||||
const string& key,
|
const string& key,
|
||||||
const YGStyle::Edges& edges) {
|
const facebook::yoga::detail::Values<YGEdgeCount>& edges) {
|
||||||
if (areFourValuesEqual(edges)) {
|
if (areFourValuesEqual(edges)) {
|
||||||
appendNumberIfNotZero(base, key, edges[YGEdgeLeft]);
|
appendNumberIfNotZero(base, key, edges[YGEdgeLeft]);
|
||||||
} else {
|
} else {
|
||||||
@@ -99,7 +100,7 @@ static void appendEdges(
|
|||||||
static void appendEdgeIfNotUndefined(
|
static void appendEdgeIfNotUndefined(
|
||||||
string& base,
|
string& base,
|
||||||
const string& str,
|
const string& str,
|
||||||
const YGStyle::Edges& edges,
|
const facebook::yoga::detail::Values<YGEdgeCount>& edges,
|
||||||
const YGEdge edge) {
|
const YGEdge edge) {
|
||||||
appendNumberIfNotUndefined(
|
appendNumberIfNotUndefined(
|
||||||
base,
|
base,
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include "CompactValue.h"
|
#include "CompactValue.h"
|
||||||
#include "YGEnums.h"
|
|
||||||
#include "YGFloatOptional.h"
|
#include "YGFloatOptional.h"
|
||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
#include "Yoga.h"
|
#include "Yoga.h"
|
||||||
@@ -30,8 +29,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
using Dimensions = facebook::yoga::detail::Values<2>;
|
using Dimensions = facebook::yoga::detail::Values<2>;
|
||||||
using Edges =
|
using Edges = facebook::yoga::detail::Values<YGEdgeCount>;
|
||||||
facebook::yoga::detail::Values<facebook::yoga::enums::count<YGEdge>()>;
|
|
||||||
|
|
||||||
/* Some platforms don't support enum bitfields,
|
/* Some platforms don't support enum bitfields,
|
||||||
so please use BITFIELD_ENUM_SIZED(BITS_COUNT) */
|
so please use BITFIELD_ENUM_SIZED(BITS_COUNT) */
|
||||||
|
@@ -149,7 +149,6 @@ static const float kWebDefaultFlexShrink = 1.0f;
|
|||||||
extern bool YGFloatsEqual(const float a, const float b);
|
extern bool YGFloatsEqual(const float a, const float b);
|
||||||
extern bool YGValueEqual(const YGValue a, const YGValue b);
|
extern bool YGValueEqual(const YGValue a, const YGValue b);
|
||||||
extern facebook::yoga::detail::CompactValue YGComputedEdgeValue(
|
extern facebook::yoga::detail::CompactValue YGComputedEdgeValue(
|
||||||
const facebook::yoga::detail::Values<
|
const facebook::yoga::detail::Values<YGEdgeCount>& edges,
|
||||||
facebook::yoga::enums::count<YGEdge>()>& edges,
|
|
||||||
YGEdge edge,
|
YGEdge edge,
|
||||||
facebook::yoga::detail::CompactValue defaultValue);
|
facebook::yoga::detail::CompactValue defaultValue);
|
||||||
|
@@ -105,7 +105,7 @@ bool YGFloatIsUndefined(const float value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
detail::CompactValue YGComputedEdgeValue(
|
detail::CompactValue YGComputedEdgeValue(
|
||||||
const YGStyle::Edges& edges,
|
const facebook::yoga::detail::Values<YGEdgeCount>& edges,
|
||||||
YGEdge edge,
|
YGEdge edge,
|
||||||
detail::CompactValue defaultValue) {
|
detail::CompactValue defaultValue) {
|
||||||
if (!edges[edge].isUndefined()) {
|
if (!edges[edge].isUndefined()) {
|
||||||
@@ -3546,12 +3546,14 @@ static const char* YGSpacer(const unsigned long level) {
|
|||||||
static const char* YGMeasureModeName(
|
static const char* YGMeasureModeName(
|
||||||
const YGMeasureMode mode,
|
const YGMeasureMode mode,
|
||||||
const bool performLayout) {
|
const bool performLayout) {
|
||||||
constexpr auto N = enums::count<YGMeasureMode>();
|
const char* kMeasureModeNames[YGMeasureModeCount] = {
|
||||||
const char* kMeasureModeNames[N] = {"UNDEFINED", "EXACTLY", "AT_MOST"};
|
"UNDEFINED", "EXACTLY", "AT_MOST"};
|
||||||
const char* kLayoutModeNames[N] = {
|
const char* kLayoutModeNames[YGMeasureModeCount] = {"LAY_UNDEFINED",
|
||||||
"LAY_UNDEFINED", "LAY_EXACTLY", "LAY_AT_MOST"};
|
"LAY_EXACTLY",
|
||||||
|
"LAY_AT_"
|
||||||
|
"MOST"};
|
||||||
|
|
||||||
if (mode >= N) {
|
if (mode >= YGMeasureModeCount) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user