Skip to content

Commit

Permalink
[ci] More enum reflection improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Oct 15, 2024
1 parent f1cfece commit 0526595
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions cmake/avendish.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ set(AVENDISH_SOURCES
"${AVND_SOURCE_DIR}/include/avnd/common/coroutines.hpp"
"${AVND_SOURCE_DIR}/include/avnd/common/dummy.hpp"
"${AVND_SOURCE_DIR}/include/avnd/common/errors.hpp"
"${AVND_SOURCE_DIR}/include/avnd/common/enum_reflection.hpp"
"${AVND_SOURCE_DIR}/include/avnd/common/export.hpp"
"${AVND_SOURCE_DIR}/include/avnd/common/for_nth.hpp"
"${AVND_SOURCE_DIR}/include/avnd/common/function_reflection.hpp"
Expand Down
10 changes: 6 additions & 4 deletions include/avnd/binding/max/from_atoms.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#pragma once

#include <avnd/common/concepts_polyfill.hpp>
#include <avnd/common/aggregates.hpp>
#include <avnd/common/for_nth.hpp>
#include <avnd/common/arithmetic.hpp>
#include <avnd/common/concepts_polyfill.hpp>
#include <avnd/common/enum_reflection.hpp>
#include <avnd/common/for_nth.hpp>

#if !defined(__cpp_lib_to_chars)
#include <boost/lexical_cast.hpp>
#else
#include <charconv>
#endif
#include <magic_enum.hpp>
#include <string>
#include <ext.h>

#include <string>

namespace max
{

Expand Down
2 changes: 1 addition & 1 deletion include/avnd/binding/max/to_atoms.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once
#include <avnd/binding/max/helpers.hpp>
#include <avnd/common/aggregates.hpp>
#include <avnd/common/enum_reflection.hpp>
#include <avnd/common/for_nth.hpp>
#include <avnd/concepts/field_names.hpp>
#include <boost/container/small_vector.hpp>
#include <ext.h>
#include <magic_enum.hpp>

namespace max
{
Expand Down
2 changes: 1 addition & 1 deletion include/avnd/binding/pd/inputs.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include <avnd/binding/pd/helpers.hpp>
#include <avnd/common/arithmetic.hpp>
#include <magic_enum.hpp>
#include <avnd/common/enum_reflection.hpp>

#if !defined(__cpp_lib_to_chars)
#include <boost/lexical_cast.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/avnd/binding/pd/outputs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */

#include <avnd/binding/pd/helpers.hpp>
#include <avnd/common/enum_reflection.hpp>
#include <avnd/concepts/parameter.hpp>
#include <avnd/introspection/output.hpp>
#include <avnd/introspection/vecf.hpp>
#include <boost/container/small_vector.hpp>
#include <magic_enum.hpp>

#include <array>
#include <vector>
Expand Down
9 changes: 9 additions & 0 deletions include/avnd/common/enum_reflection.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#if __has_include(<magic_enum.hpp>)
#include <magic_enum.hpp>
#elif __has_include(<magic_enum/magic_enum.hpp>)
#include <magic_enum/magic_enum.hpp>
#else
#error magic_enum is required
#endif
14 changes: 9 additions & 5 deletions include/halp/controls.enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <type_traits>
#if __has_include(<magic_enum.hpp>)
#include <magic_enum.hpp>
#elif __has_include(<magic_enum/magic_enum.hpp>)
#include <magic_enum/magic_enum.hpp>
#else
#error magic_enum is required
#endif

namespace halp
Expand All @@ -27,7 +31,7 @@ struct enum_t
{
struct enum_setup
{
#if __has_include(<magic_enum.hpp>)
#if MAGIC_ENUM_SUPPORTED
decltype(magic_enum::enum_names<Enum>()) values = magic_enum::enum_names<Enum>();
#endif
Enum init{};
Expand All @@ -48,7 +52,7 @@ struct enum_t
}
auto& operator=(std::string_view t) noexcept
{
#if __has_include(<magic_enum.hpp>)
#if MAGIC_ENUM_SUPPORTED
if(auto res = magic_enum::enum_cast<Enum>(t))
value = *res;
#endif
Expand All @@ -70,7 +74,7 @@ struct string_enum_t
{
struct enum_setup
{
#if __has_include(<magic_enum.hpp>)
#if MAGIC_ENUM_SUPPORTED
decltype(magic_enum::enum_names<Enum>()) values = magic_enum::enum_names<Enum>();
#endif
Enum init{};
Expand All @@ -91,14 +95,14 @@ struct string_enum_t
}
auto& operator=(Enum t) noexcept
{
#if __has_include(<magic_enum.hpp>)
#if MAGIC_ENUM_SUPPORTED
value = magic_enum::enum_name(t);
#endif
return *this;
}
auto& operator=(std::integral auto t) noexcept
{
#if __has_include(<magic_enum.hpp>)
#if MAGIC_ENUM_SUPPORTED
value = magic_enum::enum_name(static_cast<Enum>(t));
#endif
return *this;
Expand Down

0 comments on commit 0526595

Please sign in to comment.