Skip to content

Commit

Permalink
2.3.2
Browse files Browse the repository at this point in the history
* removed superfluous #include
  • Loading branch information
andrew-gresyk authored Oct 25, 2023
1 parent d4a0666 commit 92735e2
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
VERSION: '11'
}
- {
OS: ubuntu-22.04,
OS: ubuntu-20.04,
CC: clang-12,
CXX: clang++-12
}
Expand Down
12 changes: 12 additions & 0 deletions development/hfsm2/detail/shared/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ template <bool B,
typename TF>
using Conditional = typename ConditionalT<B, TT, TF>::Type;

//------------------------------------------------------------------------------

template <typename, typename>
struct IsSameT final {
static constexpr bool Value = false;
};

template <typename T>
struct IsSameT<T, T> final {
static constexpr bool Value = true;
};

////////////////////////////////////////////////////////////////////////////////

template <typename T>
Expand Down
2 changes: 1 addition & 1 deletion development/hfsm2/detail/structure/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ struct S_

using Empty = EmptyT<TArgs>;

static HFSM2_CONSTEXPR(11) bool isBare() noexcept { return std::is_base_of<Head, Empty>::value; }
static HFSM2_CONSTEXPR(11) bool isBare() noexcept { return IsSameT<Head, Empty>::Value; }

HFSM2_IF_TYPEINDEX(const std::type_index TYPE = isBare() ? typeid(None) : typeid(Head));

Expand Down
5 changes: 2 additions & 3 deletions development/hfsm2/machine_dev.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// HFSM2 (hierarchical state machine for games and interactive applications)
// 2.3.1 (2023-09-23)
// 2.3.2 (2023-10-25)
//
// Created by Andrew Gresyk
//
Expand Down Expand Up @@ -33,7 +33,7 @@

#define HFSM2_VERSION_MAJOR 2
#define HFSM2_VERSION_MINOR 3
#define HFSM2_VERSION_PATCH 1
#define HFSM2_VERSION_PATCH 2

#define HFSM2_VERSION (10000 * HFSM2_VERSION_MAJOR + 100 * HFSM2_VERSION_MINOR + HFSM2_VERSION_PATCH)

Expand All @@ -44,7 +44,6 @@
#ifndef HFSM2_DISABLE_TYPEINDEX
#include <typeindex>
#endif
#include <type_traits> // std::aligned_storage<>

#if defined _DEBUG && _MSC_VER
#include <intrin.h> // __debugbreak()
Expand Down
17 changes: 13 additions & 4 deletions include/hfsm2/machine.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// HFSM2 (hierarchical state machine for games and interactive applications)
// 2.3.1 (2023-09-23)
// 2.3.2 (2023-10-25)
//
// Created by Andrew Gresyk
//
Expand Down Expand Up @@ -33,7 +33,7 @@

#define HFSM2_VERSION_MAJOR 2
#define HFSM2_VERSION_MINOR 3
#define HFSM2_VERSION_PATCH 1
#define HFSM2_VERSION_PATCH 2

#define HFSM2_VERSION (10000 * HFSM2_VERSION_MAJOR + 100 * HFSM2_VERSION_MINOR + HFSM2_VERSION_PATCH)

Expand All @@ -44,7 +44,6 @@
#ifndef HFSM2_DISABLE_TYPEINDEX
#include <typeindex>
#endif
#include <type_traits> // std::aligned_storage<>

#if defined _DEBUG && _MSC_VER
#include <intrin.h> // __debugbreak()
Expand Down Expand Up @@ -408,6 +407,16 @@ template <bool B,
typename TF>
using Conditional = typename ConditionalT<B, TT, TF>::Type;

template <typename, typename>
struct IsSameT final {
static constexpr bool Value = false;
};

template <typename T>
struct IsSameT<T, T> final {
static constexpr bool Value = true;
};

template <typename T>
struct RemoveConstT final {
using Type = T;
Expand Down Expand Up @@ -7798,7 +7807,7 @@ struct S_

using Empty = EmptyT<TArgs>;

static HFSM2_CONSTEXPR(11) bool isBare() noexcept { return std::is_base_of<Head, Empty>::value; }
static HFSM2_CONSTEXPR(11) bool isBare() noexcept { return IsSameT<Head, Empty>::Value; }

HFSM2_IF_TYPEINDEX(const std::type_index TYPE = isBare() ? typeid(None) : typeid(Head));

Expand Down
37 changes: 6 additions & 31 deletions test/test_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using FSM = M::Root<S(Apex),
S(R_1),
S(R_2)
>,
M::Composite<S(C),
M::CompositePeers<
S(C_1),
S(C_2)
>,
Expand All @@ -55,7 +55,6 @@ using FSM = M::Root<S(Apex),
static_assert(FSM::regionId<Apex>() == 0, "");
static_assert(FSM::regionId<O >() == 1, "");
static_assert(FSM::regionId<R >() == 2, "");
static_assert(FSM::regionId<C >() == 3, "");
static_assert(FSM::regionId<U >() == 4, "");
static_assert(FSM::regionId<N >() == 5, "");

Expand All @@ -65,7 +64,6 @@ static_assert(FSM::stateId<O >() == 2, "");
static_assert(FSM::stateId<R >() == 3, "");
static_assert(FSM::stateId<R_1 >() == 4, "");
static_assert(FSM::stateId<R_2 >() == 5, "");
static_assert(FSM::stateId<C >() == 6, "");
static_assert(FSM::stateId<C_1 >() == 7, "");
static_assert(FSM::stateId<C_2 >() == 8, "");
static_assert(FSM::stateId<U >() == 9, "");
Expand All @@ -83,7 +81,6 @@ struct O : FSM::State {};
struct R : FSM::State {};
struct R_1 : FSM::State {};
struct R_2 : FSM::State {};
struct C : FSM::State {};
struct C_1 : FSM::State {};
struct C_2 : FSM::State {};
struct U : FSM::State {};
Expand Down Expand Up @@ -159,7 +156,6 @@ const Types all = {
FSM::stateId<R >(),
FSM::stateId<R_1>(),
FSM::stateId<R_2>(),
FSM::stateId<C >(),
FSM::stateId<C_1>(),
FSM::stateId<C_2>(),
FSM::stateId<U >(),
Expand Down Expand Up @@ -200,8 +196,7 @@ TEST_CASE("FSM.Debug") {
hfsm2::StructureEntry{ false, L"", "R"},
hfsm2::StructureEntry{ false, L" ║ ├ ", "R_1"},
hfsm2::StructureEntry{ false, L" ║ └ ", "R_2"},
hfsm2::StructureEntry{ false, L"", "C"},
hfsm2::StructureEntry{ false, L" ║ ├ ", "C_1"},
hfsm2::StructureEntry{ false, L" ╟ ┬ ", "C_1"},
hfsm2::StructureEntry{ false, L" ║ └ ", "C_2"},
hfsm2::StructureEntry{ false, L"", "U"},
hfsm2::StructureEntry{ false, L" ║ ├ ", "U_1"},
Expand All @@ -226,7 +221,6 @@ TEST_CASE("FSM.Debug") {
-1,
-1,
-1,
-1,
});
}

Expand All @@ -252,7 +246,7 @@ TEST_CASE("FSM.Debug") {
{ FSM::stateId<O >(), Event::Type::ENTRY_GUARD },
{ FSM::stateId<R >(), Event::Type::ENTRY_GUARD },
{ FSM::stateId<R_1 >(), Event::Type::ENTRY_GUARD },
{ FSM::stateId<C >(), Event::Type::ENTRY_GUARD },
{ hfsm2::StateID{6} , Event::Type::ENTRY_GUARD },
{ FSM::stateId<C_1 >(), Event::Type::ENTRY_GUARD },
{ FSM::stateId<U >(), Event::Type::ENTRY_GUARD },
{ FSM::stateId<U_1 >(), Event::Type::ENTRY_GUARD },
Expand All @@ -264,7 +258,7 @@ TEST_CASE("FSM.Debug") {
{ FSM::stateId<O >(), Event::Type::ENTER },
{ FSM::stateId<R >(), Event::Type::ENTER },
{ FSM::stateId<R_1 >(), Event::Type::ENTER },
{ FSM::stateId<C >(), Event::Type::ENTER },
{ hfsm2::StateID{6} , Event::Type::ENTER },
{ FSM::stateId<C_1 >(), Event::Type::ENTER },
{ FSM::stateId<U >(), Event::Type::ENTER },
{ FSM::stateId<U_1 >(), Event::Type::ENTER },
Expand All @@ -276,7 +270,7 @@ TEST_CASE("FSM.Debug") {
FSM::stateId<O >(),
FSM::stateId<R >(),
FSM::stateId<R_1 >(),
FSM::stateId<C >(),
hfsm2::StateID{6} ,
FSM::stateId<C_1 >(),
FSM::stateId<U >(),
FSM::stateId<U_1 >(),
Expand All @@ -288,24 +282,6 @@ TEST_CASE("FSM.Debug") {
FSM::stateId<I >(),
});

assertStructure(machine.structure(), {
hfsm2::StructureEntry{ true, L"", "Apex"},
hfsm2::StructureEntry{ false, L"", "I"},
hfsm2::StructureEntry{ true, L"", "O"},
hfsm2::StructureEntry{ true, L"", "R"},
hfsm2::StructureEntry{ true, L" ║ ├ ", "R_1"},
hfsm2::StructureEntry{ false, L" ║ └ ", "R_2"},
hfsm2::StructureEntry{ true, L"", "C"},
hfsm2::StructureEntry{ true, L" ║ ├ ", "C_1"},
hfsm2::StructureEntry{ false, L" ║ └ ", "C_2"},
hfsm2::StructureEntry{ true, L"", "U"},
hfsm2::StructureEntry{ true, L" ║ ├ ", "U_1"},
hfsm2::StructureEntry{ false, L" ║ └ ", "U_2"},
hfsm2::StructureEntry{ true, L"", "N"},
hfsm2::StructureEntry{ false, L"", "N_1"},
hfsm2::StructureEntry{ true, L"", "N_2"},
});

assertActivity(machine.activityHistory(), {
+2,
-1,
Expand All @@ -314,7 +290,6 @@ TEST_CASE("FSM.Debug") {
+1,
-2,
+1,
+1,
-2,
+1,
+1,
Expand All @@ -332,7 +307,7 @@ TEST_CASE("FSM.Debug") {
{ FSM::stateId<R_1 >(), Event::Type::EXIT },
{ FSM::stateId<R >(), Event::Type::EXIT },
{ FSM::stateId<C_1 >(), Event::Type::EXIT },
{ FSM::stateId<C >(), Event::Type::EXIT },
{ hfsm2::StateID{6} , Event::Type::EXIT },
{ FSM::stateId<U_1 >(), Event::Type::EXIT },
{ FSM::stateId<U >(), Event::Type::EXIT },
{ FSM::stateId<N_2 >(), Event::Type::EXIT },
Expand Down

0 comments on commit 92735e2

Please sign in to comment.