Skip to content

Commit

Permalink
Remove NumericBitfield (facebook#1463)
Browse files Browse the repository at this point in the history
Summary:
X-link: facebook/react-native#41394

Pull Request resolved: facebook#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.

Differential Revision: D51159415

fbshipit-source-id: ca0639d47bc68f2d895e72aaaad1cbdb17294be2
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Nov 10, 2023
1 parent dd8d997 commit 9fe977b
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 398 deletions.
5 changes: 1 addition & 4 deletions enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,7 @@ def to_hyphenated_lower(symbol):
f.write("YG_EXTERN_C_BEGIN\n\n")
items = sorted(ENUMS.items())
for name, values in items:
if isinstance(values[0], tuple):
f.write("YG_ENUM_DECL(\n")
else:
f.write("YG_ENUM_SEQ_DECL(\n")
f.write("YG_ENUM_DECL(\n")

f.write(" YG%s,\n" % name)
for value in values:
Expand Down
205 changes: 0 additions & 205 deletions tests/NumericBitfieldTest.cpp

This file was deleted.

32 changes: 16 additions & 16 deletions 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 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
Loading

0 comments on commit 9fe977b

Please sign in to comment.