Files
yoga/yoga/enums/Dimension.h
Nick Gerleman 1f4c524b0e C++ style enums 1/N: Generator
Summary:
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

Differential Revision: D49267996

fbshipit-source-id: 0ba9a79e19616f55abdc15012fbfd26933c6d179
2023-09-14 20:50:01 -07:00

46 lines
951 B
C++

/*
* 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