C++ style enums 1/N: Generator (#1384)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1384 X-link: https://github.com/facebook/react-native/pull/39446 This adds logic to the enum generator to generate C++ style scoped enums. This gives us a few nicities over C enums, even if both must exist: 1. We can add types and keep unsgined enums directly in bitfields 2. Style/readability 3. Avoiding implicit int conversion Reviewed By: rozele Differential Revision: D49267996 fbshipit-source-id: 1c41164c377b317c1fef97811c46cbc00b5a837e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c60050d0cb
commit
4cd45ac5d5
@@ -1 +0,0 @@
|
||||
^lib/.*
|
47
enums.py
47
enums.py
@@ -4,6 +4,7 @@
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
import math
|
||||
import os
|
||||
|
||||
ENUMS = {
|
||||
@@ -88,7 +89,7 @@ def get_license(ext):
|
||||
*/
|
||||
|
||||
// @{"generated"} by enums.py
|
||||
|
||||
{"// clang-format off" if ext == "cpp" else ""}
|
||||
"""
|
||||
|
||||
|
||||
@@ -121,7 +122,6 @@ with open(root + "/yoga/YGEnums.h", "w") as f:
|
||||
f.write(get_license("cpp"))
|
||||
f.write("#pragma once\n")
|
||||
f.write("#include <yoga/YGMacros.h>\n\n")
|
||||
f.write("// clang-format off\n\n\n")
|
||||
|
||||
f.write("YG_EXTERN_C_BEGIN\n\n")
|
||||
items = sorted(ENUMS.items())
|
||||
@@ -146,6 +146,49 @@ with open(root + "/yoga/YGEnums.h", "w") as f:
|
||||
f.write("\n")
|
||||
f.write("YG_EXTERN_C_END\n")
|
||||
|
||||
# Write out C++ scoped enums
|
||||
for name, values in sorted(ENUMS.items()):
|
||||
with open(f"{root}/yoga/enums/{name}.h", "w") as f:
|
||||
f.write(get_license("cpp"))
|
||||
f.write("#pragma once\n\n")
|
||||
|
||||
f.write("#include <cstdint>\n")
|
||||
f.write("#include <yoga/YGEnums.h>\n")
|
||||
f.write("#include <yoga/enums/YogaEnums.h>\n\n")
|
||||
|
||||
f.write("namespace facebook::yoga {\n\n")
|
||||
|
||||
width = "uint32_t" if name in BITSET_ENUMS else "uint8_t"
|
||||
f.write(f"enum class {name} : {width} {{\n")
|
||||
for value in values:
|
||||
ordinal = value[0] if isinstance(value, tuple) else value
|
||||
f.write(f" {ordinal} = YG{name}{ordinal},\n")
|
||||
f.write("};\n\n")
|
||||
|
||||
f.write("template <>\n")
|
||||
f.write(f"constexpr inline int32_t ordinalCount<{name}>() {{\n")
|
||||
f.write(f" return {len(values)};\n")
|
||||
f.write("} \n\n")
|
||||
|
||||
f.write("template <>\n")
|
||||
f.write(f"constexpr inline int32_t bitCount<{name}>() {{\n")
|
||||
f.write(f" return {math.ceil(math.log(len(values), 2))};\n")
|
||||
f.write("} \n\n")
|
||||
|
||||
f.write(f"constexpr inline {name} scopedEnum(YG{name} unscoped) {{\n")
|
||||
f.write(f" return static_cast<{name}>(unscoped);\n")
|
||||
f.write("}\n\n")
|
||||
|
||||
f.write(f"constexpr inline YG{name} unscopedEnum({name} scoped) {{\n")
|
||||
f.write(f" return static_cast<YG{name}>(scoped);\n")
|
||||
f.write("}\n\n")
|
||||
|
||||
f.write(f"inline const char* toString({name} e) {{\n")
|
||||
f.write(f" return YG{name}ToString(unscopedEnum(e));\n")
|
||||
f.write("}\n\n")
|
||||
|
||||
f.write("} // namespace facebook::yoga\n")
|
||||
|
||||
# write out C body for printing
|
||||
with open(root + "/yoga/YGEnums.cpp", "w") as f:
|
||||
f.write(get_license("cpp"))
|
||||
|
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
|
||||
// clang-format off
|
||||
#include <yoga/YGEnums.h>
|
||||
|
||||
const char* YGAlignToString(const YGAlign value) {
|
||||
|
@@ -6,13 +6,10 @@
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
|
||||
// clang-format off
|
||||
#pragma once
|
||||
#include <yoga/YGMacros.h>
|
||||
|
||||
// clang-format off
|
||||
|
||||
|
||||
YG_EXTERN_C_BEGIN
|
||||
|
||||
YG_ENUM_SEQ_DECL(
|
||||
|
51
yoga/enums/Align.h
Normal file
51
yoga/enums/Align.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class Align : uint8_t {
|
||||
Auto = YGAlignAuto,
|
||||
FlexStart = YGAlignFlexStart,
|
||||
Center = YGAlignCenter,
|
||||
FlexEnd = YGAlignFlexEnd,
|
||||
Stretch = YGAlignStretch,
|
||||
Baseline = YGAlignBaseline,
|
||||
SpaceBetween = YGAlignSpaceBetween,
|
||||
SpaceAround = YGAlignSpaceAround,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<Align>() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<Align>() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
constexpr inline Align scopedEnum(YGAlign unscoped) {
|
||||
return static_cast<Align>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGAlign unscopedEnum(Align scoped) {
|
||||
return static_cast<YGAlign>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(Align e) {
|
||||
return YGAlignToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
45
yoga/enums/Dimension.h
Normal file
45
yoga/enums/Dimension.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class Dimension : uint8_t {
|
||||
Width = YGDimensionWidth,
|
||||
Height = YGDimensionHeight,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<Dimension>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<Dimension>() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
constexpr inline Dimension scopedEnum(YGDimension unscoped) {
|
||||
return static_cast<Dimension>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGDimension unscopedEnum(Dimension scoped) {
|
||||
return static_cast<YGDimension>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(Dimension e) {
|
||||
return YGDimensionToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
46
yoga/enums/Direction.h
Normal file
46
yoga/enums/Direction.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class Direction : uint8_t {
|
||||
Inherit = YGDirectionInherit,
|
||||
LTR = YGDirectionLTR,
|
||||
RTL = YGDirectionRTL,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<Direction>() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<Direction>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
constexpr inline Direction scopedEnum(YGDirection unscoped) {
|
||||
return static_cast<Direction>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGDirection unscopedEnum(Direction scoped) {
|
||||
return static_cast<YGDirection>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(Direction e) {
|
||||
return YGDirectionToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
45
yoga/enums/Display.h
Normal file
45
yoga/enums/Display.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class Display : uint8_t {
|
||||
Flex = YGDisplayFlex,
|
||||
None = YGDisplayNone,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<Display>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<Display>() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
constexpr inline Display scopedEnum(YGDisplay unscoped) {
|
||||
return static_cast<Display>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGDisplay unscopedEnum(Display scoped) {
|
||||
return static_cast<YGDisplay>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(Display e) {
|
||||
return YGDisplayToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
52
yoga/enums/Edge.h
Normal file
52
yoga/enums/Edge.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class Edge : uint8_t {
|
||||
Left = YGEdgeLeft,
|
||||
Top = YGEdgeTop,
|
||||
Right = YGEdgeRight,
|
||||
Bottom = YGEdgeBottom,
|
||||
Start = YGEdgeStart,
|
||||
End = YGEdgeEnd,
|
||||
Horizontal = YGEdgeHorizontal,
|
||||
Vertical = YGEdgeVertical,
|
||||
All = YGEdgeAll,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<Edge>() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<Edge>() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
constexpr inline Edge scopedEnum(YGEdge unscoped) {
|
||||
return static_cast<Edge>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGEdge unscopedEnum(Edge scoped) {
|
||||
return static_cast<YGEdge>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(Edge e) {
|
||||
return YGEdgeToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
47
yoga/enums/Errata.h
Normal file
47
yoga/enums/Errata.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class Errata : uint32_t {
|
||||
None = YGErrataNone,
|
||||
StretchFlexBasis = YGErrataStretchFlexBasis,
|
||||
All = YGErrataAll,
|
||||
Classic = YGErrataClassic,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<Errata>() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<Errata>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
constexpr inline Errata scopedEnum(YGErrata unscoped) {
|
||||
return static_cast<Errata>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGErrata unscopedEnum(Errata scoped) {
|
||||
return static_cast<YGErrata>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(Errata e) {
|
||||
return YGErrataToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
45
yoga/enums/ExperimentalFeature.h
Normal file
45
yoga/enums/ExperimentalFeature.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class ExperimentalFeature : uint8_t {
|
||||
WebFlexBasis = YGExperimentalFeatureWebFlexBasis,
|
||||
AbsolutePercentageAgainstPaddingEdge = YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<ExperimentalFeature>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<ExperimentalFeature>() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
constexpr inline ExperimentalFeature scopedEnum(YGExperimentalFeature unscoped) {
|
||||
return static_cast<ExperimentalFeature>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGExperimentalFeature unscopedEnum(ExperimentalFeature scoped) {
|
||||
return static_cast<YGExperimentalFeature>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(ExperimentalFeature e) {
|
||||
return YGExperimentalFeatureToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
47
yoga/enums/FlexDirection.h
Normal file
47
yoga/enums/FlexDirection.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class FlexDirection : uint8_t {
|
||||
Column = YGFlexDirectionColumn,
|
||||
ColumnReverse = YGFlexDirectionColumnReverse,
|
||||
Row = YGFlexDirectionRow,
|
||||
RowReverse = YGFlexDirectionRowReverse,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<FlexDirection>() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<FlexDirection>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
constexpr inline FlexDirection scopedEnum(YGFlexDirection unscoped) {
|
||||
return static_cast<FlexDirection>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGFlexDirection unscopedEnum(FlexDirection scoped) {
|
||||
return static_cast<YGFlexDirection>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(FlexDirection e) {
|
||||
return YGFlexDirectionToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
46
yoga/enums/Gutter.h
Normal file
46
yoga/enums/Gutter.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class Gutter : uint8_t {
|
||||
Column = YGGutterColumn,
|
||||
Row = YGGutterRow,
|
||||
All = YGGutterAll,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<Gutter>() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<Gutter>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
constexpr inline Gutter scopedEnum(YGGutter unscoped) {
|
||||
return static_cast<Gutter>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGGutter unscopedEnum(Gutter scoped) {
|
||||
return static_cast<YGGutter>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(Gutter e) {
|
||||
return YGGutterToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
49
yoga/enums/Justify.h
Normal file
49
yoga/enums/Justify.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class Justify : uint8_t {
|
||||
FlexStart = YGJustifyFlexStart,
|
||||
Center = YGJustifyCenter,
|
||||
FlexEnd = YGJustifyFlexEnd,
|
||||
SpaceBetween = YGJustifySpaceBetween,
|
||||
SpaceAround = YGJustifySpaceAround,
|
||||
SpaceEvenly = YGJustifySpaceEvenly,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<Justify>() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<Justify>() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
constexpr inline Justify scopedEnum(YGJustify unscoped) {
|
||||
return static_cast<Justify>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGJustify unscopedEnum(Justify scoped) {
|
||||
return static_cast<YGJustify>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(Justify e) {
|
||||
return YGJustifyToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
49
yoga/enums/LogLevel.h
Normal file
49
yoga/enums/LogLevel.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class LogLevel : uint8_t {
|
||||
Error = YGLogLevelError,
|
||||
Warn = YGLogLevelWarn,
|
||||
Info = YGLogLevelInfo,
|
||||
Debug = YGLogLevelDebug,
|
||||
Verbose = YGLogLevelVerbose,
|
||||
Fatal = YGLogLevelFatal,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<LogLevel>() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<LogLevel>() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
constexpr inline LogLevel scopedEnum(YGLogLevel unscoped) {
|
||||
return static_cast<LogLevel>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGLogLevel unscopedEnum(LogLevel scoped) {
|
||||
return static_cast<YGLogLevel>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(LogLevel e) {
|
||||
return YGLogLevelToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
46
yoga/enums/MeasureMode.h
Normal file
46
yoga/enums/MeasureMode.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class MeasureMode : uint8_t {
|
||||
Undefined = YGMeasureModeUndefined,
|
||||
Exactly = YGMeasureModeExactly,
|
||||
AtMost = YGMeasureModeAtMost,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<MeasureMode>() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<MeasureMode>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
constexpr inline MeasureMode scopedEnum(YGMeasureMode unscoped) {
|
||||
return static_cast<MeasureMode>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGMeasureMode unscopedEnum(MeasureMode scoped) {
|
||||
return static_cast<YGMeasureMode>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(MeasureMode e) {
|
||||
return YGMeasureModeToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
45
yoga/enums/NodeType.h
Normal file
45
yoga/enums/NodeType.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class NodeType : uint8_t {
|
||||
Default = YGNodeTypeDefault,
|
||||
Text = YGNodeTypeText,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<NodeType>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<NodeType>() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
constexpr inline NodeType scopedEnum(YGNodeType unscoped) {
|
||||
return static_cast<NodeType>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGNodeType unscopedEnum(NodeType scoped) {
|
||||
return static_cast<YGNodeType>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(NodeType e) {
|
||||
return YGNodeTypeToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
46
yoga/enums/Overflow.h
Normal file
46
yoga/enums/Overflow.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class Overflow : uint8_t {
|
||||
Visible = YGOverflowVisible,
|
||||
Hidden = YGOverflowHidden,
|
||||
Scroll = YGOverflowScroll,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<Overflow>() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<Overflow>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
constexpr inline Overflow scopedEnum(YGOverflow unscoped) {
|
||||
return static_cast<Overflow>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGOverflow unscopedEnum(Overflow scoped) {
|
||||
return static_cast<YGOverflow>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(Overflow e) {
|
||||
return YGOverflowToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
46
yoga/enums/PositionType.h
Normal file
46
yoga/enums/PositionType.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class PositionType : uint8_t {
|
||||
Static = YGPositionTypeStatic,
|
||||
Relative = YGPositionTypeRelative,
|
||||
Absolute = YGPositionTypeAbsolute,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<PositionType>() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<PositionType>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
constexpr inline PositionType scopedEnum(YGPositionType unscoped) {
|
||||
return static_cast<PositionType>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGPositionType unscopedEnum(PositionType scoped) {
|
||||
return static_cast<YGPositionType>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(PositionType e) {
|
||||
return YGPositionTypeToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
46
yoga/enums/PrintOptions.h
Normal file
46
yoga/enums/PrintOptions.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class PrintOptions : uint32_t {
|
||||
Layout = YGPrintOptionsLayout,
|
||||
Style = YGPrintOptionsStyle,
|
||||
Children = YGPrintOptionsChildren,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<PrintOptions>() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<PrintOptions>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
constexpr inline PrintOptions scopedEnum(YGPrintOptions unscoped) {
|
||||
return static_cast<PrintOptions>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGPrintOptions unscopedEnum(PrintOptions scoped) {
|
||||
return static_cast<YGPrintOptions>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(PrintOptions e) {
|
||||
return YGPrintOptionsToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
47
yoga/enums/Unit.h
Normal file
47
yoga/enums/Unit.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class Unit : uint8_t {
|
||||
Undefined = YGUnitUndefined,
|
||||
Point = YGUnitPoint,
|
||||
Percent = YGUnitPercent,
|
||||
Auto = YGUnitAuto,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<Unit>() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<Unit>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
constexpr inline Unit scopedEnum(YGUnit unscoped) {
|
||||
return static_cast<Unit>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGUnit unscopedEnum(Unit scoped) {
|
||||
return static_cast<YGUnit>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(Unit e) {
|
||||
return YGUnitToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
46
yoga/enums/Wrap.h
Normal file
46
yoga/enums/Wrap.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/enums/YogaEnums.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum class Wrap : uint8_t {
|
||||
NoWrap = YGWrapNoWrap,
|
||||
Wrap = YGWrapWrap,
|
||||
WrapReverse = YGWrapWrapReverse,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t ordinalCount<Wrap>() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr inline int32_t bitCount<Wrap>() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
constexpr inline Wrap scopedEnum(YGWrap unscoped) {
|
||||
return static_cast<Wrap>(unscoped);
|
||||
}
|
||||
|
||||
constexpr inline YGWrap unscopedEnum(Wrap scoped) {
|
||||
return static_cast<YGWrap>(scoped);
|
||||
}
|
||||
|
||||
inline const char* toString(Wrap e) {
|
||||
return YGWrapToString(unscopedEnum(e));
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
18
yoga/enums/YogaEnums.h
Normal file
18
yoga/enums/YogaEnums.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
template <typename EnumT>
|
||||
constexpr inline int32_t ordinalCount() = delete;
|
||||
|
||||
template <typename EnumT>
|
||||
constexpr inline int32_t bitCount() = delete;
|
||||
|
||||
} // namespace facebook::yoga
|
Reference in New Issue
Block a user