Skip to content

Commit

Permalink
Remove NumericBitfield (#41394)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #41394

X-link: facebook/yoga#1463

Now that are enums are unsigned, and we don't have BitfieldRef, we can convert the last remaining user of NumericBitfield to a plain old bitfield,  for better readability (e.g. the default values), debugability, and less complexity. We also break a cycle which lets us properly group public vs private members.

Reviewed By: joevilches

Differential Revision: D51159415

fbshipit-source-id: 7842a8330eed6061b863de3f175c761dcf4aa2be
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Nov 28, 2023
1 parent 495fee4 commit 9078db7
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 189 deletions.
32 changes: 16 additions & 16 deletions packages/react-native/ReactCommon/yoga/yoga/YGEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

YG_EXTERN_C_BEGIN

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGAlign,
YGAlignAuto,
YGAlignFlexStart,
Expand All @@ -24,23 +24,23 @@ YG_ENUM_SEQ_DECL(
YGAlignSpaceAround,
YGAlignSpaceEvenly)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGDimension,
YGDimensionWidth,
YGDimensionHeight)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGDirection,
YGDirectionInherit,
YGDirectionLTR,
YGDirectionRTL)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGDisplay,
YGDisplayFlex,
YGDisplayNone)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGEdge,
YGEdgeLeft,
YGEdgeTop,
Expand All @@ -62,25 +62,25 @@ YG_ENUM_DECL(
YGErrataClassic = 2147483646)
YG_DEFINE_ENUM_FLAG_OPERATORS(YGErrata)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGExperimentalFeature,
YGExperimentalFeatureWebFlexBasis,
YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGFlexDirection,
YGFlexDirectionColumn,
YGFlexDirectionColumnReverse,
YGFlexDirectionRow,
YGFlexDirectionRowReverse)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGGutter,
YGGutterColumn,
YGGutterRow,
YGGutterAll)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGJustify,
YGJustifyFlexStart,
YGJustifyCenter,
Expand All @@ -89,7 +89,7 @@ YG_ENUM_SEQ_DECL(
YGJustifySpaceAround,
YGJustifySpaceEvenly)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGLogLevel,
YGLogLevelError,
YGLogLevelWarn,
Expand All @@ -98,24 +98,24 @@ YG_ENUM_SEQ_DECL(
YGLogLevelVerbose,
YGLogLevelFatal)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGMeasureMode,
YGMeasureModeUndefined,
YGMeasureModeExactly,
YGMeasureModeAtMost)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGNodeType,
YGNodeTypeDefault,
YGNodeTypeText)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGOverflow,
YGOverflowVisible,
YGOverflowHidden,
YGOverflowScroll)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGPositionType,
YGPositionTypeStatic,
YGPositionTypeRelative,
Expand All @@ -128,14 +128,14 @@ YG_ENUM_DECL(
YGPrintOptionsChildren = 4)
YG_DEFINE_ENUM_FLAG_OPERATORS(YGPrintOptions)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGUnit,
YGUnitUndefined,
YGUnitPoint,
YGUnitPercent,
YGUnitAuto)

YG_ENUM_SEQ_DECL(
YG_ENUM_DECL(
YGWrap,
YGWrapNoWrap,
YGWrapWrap,
Expand Down
34 changes: 0 additions & 34 deletions packages/react-native/ReactCommon/yoga/yoga/YGMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,40 +88,6 @@
#define YG_DEFINE_ENUM_FLAG_OPERATORS(name)
#endif

#ifdef __cplusplus

namespace facebook::yoga {

template <typename T>
constexpr int
ordinalCount(); // can't use `= delete` due to a defect in clang < 3.9

namespace detail {
template <int... xs>
constexpr int n() {
return sizeof...(xs);
}
} // namespace detail

} // namespace facebook::yoga
#endif

#define YG_ENUM_DECL(NAME, ...) \
typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \
YG_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::yoga { \
template <> \
constexpr int ordinalCount<NAME>() { \
return detail::n<__VA_ARGS__>(); \
} \
} \
YG_EXTERN_C_BEGIN
#else
#define YG_ENUM_SEQ_DECL YG_ENUM_DECL
#endif
67 changes: 0 additions & 67 deletions packages/react-native/ReactCommon/yoga/yoga/bits/NumericBitfield.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include <array>

#include <yoga/bits/NumericBitfield.h>
#include <yoga/debug/AssertFatal.h>
#include <yoga/enums/Dimension.h>
#include <yoga/enums/Direction.h>
Expand Down
Loading

0 comments on commit 9078db7

Please sign in to comment.