Skip to content

Commit

Permalink
magic_enum does not support enum values above 128
Browse files Browse the repository at this point in the history
by default. When changing MAGIC_ENUM_RANGE_MAX
to 30000, compilation becomes super slow. Therefore
adding a hack to support larger values
  • Loading branch information
Werni2A committed Dec 30, 2023
1 parent 9286404 commit d33c72a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Enums/ComponentType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
// types?
enum class ComponentType
{
CT_0 = 0, // @todo Unknown
Graphic = 2,

Cell = 6,

View = 9,
CT_10 = 10, // @todo Unknown

Part = 24,

Expand All @@ -37,6 +39,14 @@ enum class ComponentType

PinShapeSymbol = 98,

// This value is returned by ToComponentType
// in case the passed integer is > 100 to
// cope with magic_enums limitations and keep
// compile times at a reasonable level
// https://github.com/Neargye/magic_enum/blob/master/doc/limitations.md
HACKY_VALUE = 100,

CT_257 = 257, // @todo completly unknown and strange looking
CT_3820 = 3820, // @todo completly unknown and strange looking
CT_4704 = 4704, // @todo completly unknown and strange looking
CT_11904 = 11904, // @todo completly unknown and strange looking
Expand All @@ -53,6 +63,12 @@ enum class ComponentType
[[maybe_unused]]
static constexpr ComponentType ToComponentType(uint16_t aVal)
{
// See the explanation at HACKY_VALUE for this hack
if(aVal > 100U)
{
aVal = 100U;
}

return ToEnum<ComponentType, decltype(aVal)>(aVal);
}

Expand Down

0 comments on commit d33c72a

Please sign in to comment.