Skip to content

Commit ed74536

Browse files
Fixed first test failure: Make sure that enum ranges work
1 parent aaca276 commit ed74536

7 files changed

Lines changed: 38 additions & 32 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#ifndef RFL_INTERNAL_ENUMS_CPP20_ENCHANTUM_HPP_
2+
#define RFL_INTERNAL_ENUMS_CPP20_ENCHANTUM_HPP_
3+
4+
// Enum values must be greater than or equal to RFL_ENUM_RANGE_MIN.
5+
// By default, RFL_ENUM_RANGE_MIN is set to -256.
6+
// To change the default minimum range for all enum types, redefine the macro
7+
// RFL_ENUM_RANGE_MIN.
8+
#if !defined(RFL_ENUM_RANGE_MIN)
9+
#define RFL_ENUM_RANGE_MIN -256
10+
#endif
11+
12+
// Enum values must be less than or equal to RFL_ENUM_RANGE_MAX.
13+
// By default, RFL_ENUM_RANGE_MAX is set to 256.
14+
// To change the default maximum range for all enum types, redefine the macro
15+
// RFL_ENUM_RANGE_MAX.
16+
#if !defined(RFL_ENUM_RANGE_MAX)
17+
#define RFL_ENUM_RANGE_MAX 256
18+
#endif
19+
20+
#ifdef ENCHANTUM_MIN_RANGE
21+
#undef ENCHANTUM_MIN_RANGE
22+
#endif
23+
#define ENCHANTUM_MIN_RANGE RFL_ENUM_RANGE_MIN
24+
25+
#ifdef ENCHANTUM_MAX_RANGE
26+
#undef ENCHANTUM_MAX_RANGE
27+
#endif
28+
#define ENCHANTUM_MAX_RANGE RFL_ENUM_RANGE_MAX
29+
30+
#include "../../../thirdparty/enchantum/enchantum.hpp"
31+
32+
#endif

‎include/rfl/internal/enums/cpp20/from_string.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <string>
55
#include <type_traits>
66

7-
#include "../../../thirdparty/enchantum/enchantum.hpp" // NOLINT(unused-includes)
7+
#include "enchantum.hpp" // NOLINT(unused-includes)
88

99
namespace rfl::internal::enums::cpp20 {
1010

‎include/rfl/internal/enums/cpp20/get_enum_names.hpp‎

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,13 @@
11
#ifndef RFL_INTERNAL_ENUMS_CPP20_GET_ENUM_NAMES_HPP_
22
#define RFL_INTERNAL_ENUMS_CPP20_GET_ENUM_NAMES_HPP_
33

4-
// Enum values must be greater than or equal to RFL_ENUM_RANGE_MIN.
5-
// By default, RFL_ENUM_RANGE_MIN is set to -256.
6-
// To change the default minimum range for all enum types, redefine the macro
7-
// RFL_ENUM_RANGE_MIN.
8-
#if !defined(RFL_ENUM_RANGE_MIN)
9-
#define RFL_ENUM_RANGE_MIN -256
10-
#endif
11-
12-
// Enum values must be less than or equal to RFL_ENUM_RANGE_MAX.
13-
// By default, RFL_ENUM_RANGE_MAX is set to 256.
14-
// To change the default maximum range for all enum types, redefine the macro
15-
// RFL_ENUM_RANGE_MAX.
16-
#if !defined(RFL_ENUM_RANGE_MAX)
17-
#define RFL_ENUM_RANGE_MAX 256
18-
#endif
19-
20-
#ifdef ENCHANTUM_MIN_RANGE
21-
#undef ENCHANTUM_MIN_RANGE
22-
#endif
23-
#define ENCHANTUM_MIN_RANGE RFL_ENUM_RANGE_MIN
24-
25-
#ifdef ENCHANTUM_MAX_RANGE
26-
#undef ENCHANTUM_MAX_RANGE
27-
#endif
28-
#define ENCHANTUM_MAX_RANGE RFL_ENUM_RANGE_MAX
29-
304
#include <concepts>
315
#include <utility>
326

337
#include "../../../Literal.hpp"
34-
#include "../../../thirdparty/enchantum/enchantum.hpp" // NOLINT(unused-includes)
358
#include "../Names.hpp"
369
#include "../is_flag_enum.hpp"
10+
#include "enchantum.hpp"
3711
#include "range_defined.hpp"
3812

3913
// https://en.cppreference.com/w/cpp/language/static_cast:

‎include/rfl/internal/enums/cpp20/get_enum_range.hpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
#include <utility>
55

6-
#include "../../../thirdparty/enchantum/enchantum.hpp" // NOLINT(unused-includes)
6+
// Necessary to use enchantum::enum_traits
7+
#include "get_enum_names.hpp"
78

89
namespace rfl::internal::enums::cpp20 {
910

‎include/rfl/internal/enums/cpp20/to_string.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <string>
55
#include <type_traits>
66

7-
#include "../../../thirdparty/enchantum/enchantum.hpp" // NOLINT(unused-includes)
7+
#include "enchantum.hpp" // NOLINT(unused-includes)
88

99
namespace rfl::internal::enums::cpp20 {
1010

‎include/rfl/parsing/ParserBasicType.hpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "../internal/processed_t.hpp"
2020
#include "../internal/ptr_cast.hpp"
2121
#include "../internal/to_ptr_named_tuple.hpp"
22-
#include "../thirdparty/enchantum/enchantum.hpp"
2322
#include "../to_view.hpp"
2423
#include "AreReaderAndWriter.hpp"
2524
#include "Parent.hpp"

‎include/rfl/parsing/ParserEnum.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#include "../Result.hpp"
88
#include "../config.hpp"
99
#include "../enums.hpp"
10+
#include "../internal/enums/cpp20/enchantum.hpp" // TODO: Replace this
1011
#include "../internal/has_reflector.hpp"
1112
#include "../internal/underlying_enums_v.hpp"
12-
#include "../thirdparty/enchantum/enchantum.hpp"
1313
#include "AreReaderAndWriter.hpp"
1414
#include "Parent.hpp"
1515
#include "Parser_base.hpp"

0 commit comments

Comments
 (0)