Skip to content

Commit c7ccd25

Browse files
2.4.0
* Added `destroy<>()` * switched msbuild workflow to the premake solution
1 parent d993031 commit c7ccd25

File tree

80 files changed

+2106
-5593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2106
-5593
lines changed

.github/workflows/msbuild.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ master ]
88

99
env:
10-
SOLUTION_FILE_PATH: projects\visual-studio\hfsm2-vs.sln
10+
SOLUTION_FILE_PATH: projects\premake\hfsm2-vs.sln
1111

1212
jobs:
1313
build:
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
BUILD_CONFIG: [ Release, Debug ]
19-
BUILD_PLATFORM: [ x86, x64 ]
19+
BUILD_PLATFORM: [ 32, 64 ]
2020

2121
steps:
2222
- uses: actions/checkout@v4
@@ -31,4 +31,4 @@ jobs:
3131

3232
- name: Test
3333
working-directory: ${{env.GITHUB_WORKSPACE}}
34-
run: binaries-${{matrix.BUILD_PLATFORM}}\test-17-${{matrix.BUILD_CONFIG}}-${{matrix.BUILD_PLATFORM}}.exe
34+
run: "binaries/test-17-${{matrix.BUILD_CONFIG}}-${{matrix.BUILD_PLATFORM}}.exe"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ cmake-*
1818
/projects/code-lite/test/test.mk
1919
/projects/visual-studio/.opencppcov
2020
/projects/visual-studio/*.log
21+
/pull.cmd
22+
/push.cmd

development/hfsm2/detail/features/logger_interface.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct LoggerInterfaceT {
3535
void
3636
recordMethod(const Context& HFSM2_UNUSED(context),
3737
const StateID HFSM2_UNUSED(origin),
38-
const Method HFSM2_UNUSED(method)) noexcept
38+
const Method HFSM2_UNUSED(method))
3939
{}
4040

4141
HFSM2_CONSTEXPR(NO)
@@ -44,7 +44,7 @@ struct LoggerInterfaceT {
4444
recordTransition(const Context& HFSM2_UNUSED(context),
4545
const StateID HFSM2_UNUSED(origin),
4646
const TransitionType HFSM2_UNUSED(transitionType),
47-
const StateID HFSM2_UNUSED(target)) noexcept
47+
const StateID HFSM2_UNUSED(target))
4848
{}
4949

5050
#if HFSM2_PLANS_AVAILABLE()
@@ -55,15 +55,15 @@ struct LoggerInterfaceT {
5555
recordTaskStatus(const Context& HFSM2_UNUSED(context),
5656
const RegionID HFSM2_UNUSED(region),
5757
const StateID HFSM2_UNUSED(origin),
58-
const StatusEvent HFSM2_UNUSED(event)) noexcept
58+
const StatusEvent HFSM2_UNUSED(event))
5959
{}
6060

6161
HFSM2_CONSTEXPR(NO)
6262
virtual
6363
void
6464
recordPlanStatus(const Context& HFSM2_UNUSED(context),
6565
const RegionID HFSM2_UNUSED(region),
66-
const StatusEvent HFSM2_UNUSED(event)) noexcept
66+
const StatusEvent HFSM2_UNUSED(event))
6767
{}
6868

6969
#endif
@@ -72,15 +72,15 @@ struct LoggerInterfaceT {
7272
virtual
7373
void
7474
recordCancelledPending(const Context& HFSM2_UNUSED(context),
75-
const StateID HFSM2_UNUSED(origin)) noexcept
75+
const StateID HFSM2_UNUSED(origin))
7676
{}
7777

7878
HFSM2_CONSTEXPR(NO)
7979
virtual
8080
void
8181
recordSelectResolution(const Context& HFSM2_UNUSED(context),
8282
const StateID HFSM2_UNUSED(head),
83-
const Prong HFSM2_UNUSED(prong)) noexcept
83+
const Prong HFSM2_UNUSED(prong))
8484
{}
8585

8686
#if HFSM2_UTILITY_THEORY_AVAILABLE()
@@ -91,7 +91,7 @@ struct LoggerInterfaceT {
9191
recordUtilityResolution(const Context& HFSM2_UNUSED(context),
9292
const StateID HFSM2_UNUSED(head),
9393
const Prong HFSM2_UNUSED(prong),
94-
const Utilty HFSM2_UNUSED(utilty)) noexcept
94+
const Utilty HFSM2_UNUSED(utilty))
9595
{}
9696

9797
HFSM2_CONSTEXPR(NO)
@@ -100,7 +100,7 @@ struct LoggerInterfaceT {
100100
recordRandomResolution(const Context& HFSM2_UNUSED(context),
101101
const StateID HFSM2_UNUSED(head),
102102
const Prong HFSM2_UNUSED(prong),
103-
const Utilty HFSM2_UNUSED(utilty)) noexcept
103+
const Utilty HFSM2_UNUSED(utilty))
104104
{}
105105

106106
#endif

development/hfsm2/detail/shared/utility.hpp

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ using Undecorate = RemoveConst<RemoveReference<T>>;
108108

109109
template <typename T>
110110
struct IsValueReferenceT final {
111-
static constexpr bool VALUE = false;
111+
static const bool VALUE = false;
112112
};
113113

114114
template <typename T>
115115
struct IsValueReferenceT<T&> final {
116-
static constexpr bool VALUE = true;
116+
static const bool VALUE = true;
117117
};
118118

119119
////////////////////////////////////////////////////////////////////////////////
@@ -187,8 +187,10 @@ move(T&& t) noexcept {
187187

188188
////////////////////////////////////////////////////////////////////////////////
189189

190-
template <typename T0,
191-
typename T1>
190+
template <
191+
typename T0
192+
, typename T1
193+
>
192194
HFSM2_CONSTEXPR(11)
193195
T0
194196
min(const T0 t0,
@@ -200,8 +202,10 @@ min(const T0 t0,
200202

201203
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
202204

203-
template <typename T0,
204-
typename T1>
205+
template <
206+
typename T0
207+
, typename T1
208+
>
205209
HFSM2_CONSTEXPR(11)
206210
T0
207211
max(const T0 t0,
@@ -213,9 +217,11 @@ max(const T0 t0,
213217

214218
//------------------------------------------------------------------------------
215219

216-
template <typename TIndex,
217-
typename TElement,
218-
TIndex NCount>
220+
template <
221+
typename TIndex
222+
, typename TElement
223+
, TIndex NCount
224+
>
219225
HFSM2_CONSTEXPR(11)
220226
TIndex
221227
count(const TElement (&)[NCount]) noexcept {
@@ -224,8 +230,10 @@ count(const TElement (&)[NCount]) noexcept {
224230

225231
//------------------------------------------------------------------------------
226232

227-
template <typename T,
228-
typename TT>
233+
template <
234+
typename T
235+
, typename TT
236+
>
229237
HFSM2_CONSTEXPR(11)
230238
T
231239
contain(const T x,
@@ -238,8 +246,7 @@ contain(const T x,
238246

239247
HFSM2_CONSTEXPR(11)
240248
uint64_t
241-
widen(const uint32_t x, const uint32_t y) noexcept
242-
{
249+
widen(const uint32_t x, const uint32_t y) noexcept {
243250
return static_cast<uint64_t>(x) << 32 | y;
244251
}
245252

@@ -297,6 +304,14 @@ reinterpret(const TI& in) noexcept {
297304
return out;
298305
}
299306

307+
//------------------------------------------------------------------------------
308+
309+
template<class T>
310+
HFSM2_CONSTEXPR(14)
311+
void destroy(T& t) noexcept {
312+
t.~T();
313+
}
314+
300315
////////////////////////////////////////////////////////////////////////////////
301316

302317
template <int>

development/hfsm2/machine_dev.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// HFSM2 (hierarchical state machine for games and interactive applications)
2-
// 2.3.3 (2023-12-21)
2+
// 2.4.0 (2023-12-25)
33
//
44
// Created by Andrew Gresyk
55
//
@@ -32,8 +32,8 @@
3232
#pragma once
3333

3434
#define HFSM2_VERSION_MAJOR 2
35-
#define HFSM2_VERSION_MINOR 3
36-
#define HFSM2_VERSION_PATCH 3
35+
#define HFSM2_VERSION_MINOR 4
36+
#define HFSM2_VERSION_PATCH 0
3737

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

examples/advanced_event_handling/main.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ struct Reactive
9494
: FSM::State
9595
{
9696
// handle a single event type - TransitionEvent
97-
void react(const TransitionEvent&, FullControl& control) noexcept {
97+
void react(const TransitionEvent&, FullControl& control) {
9898
std::cout << " Reactive: reacting to TransitionEvent\n";
9999

100100
control.changeTo<Target>();
@@ -118,12 +118,12 @@ struct ConcreteHandler
118118
: FSM::State
119119
{
120120
// handle two event types - PrimaryEvent
121-
void react(const PrimaryEvent&, FullControl&) noexcept {
121+
void react(const PrimaryEvent&, FullControl&) {
122122
std::cout << " ConcreteHandler: reacting to PrimaryEvent\n";
123123
}
124124

125125
// and SecondaryEvent
126-
void react(const SecondaryEvent&, FullControl&) noexcept {
126+
void react(const SecondaryEvent&, FullControl&) {
127127
std::cout << " ConcreteHandler: reacting to SecondaryEvent\n";
128128
}
129129

@@ -138,7 +138,7 @@ struct TemplateHandler
138138
{
139139
// handle all possible event types
140140
template <typename TEvent>
141-
void react(const TEvent&, FullControl&) noexcept {
141+
void react(const TEvent&, FullControl&) {
142142
std::cout << " TemplateHandler: reacting to TEvent\n";
143143
}
144144
};
@@ -151,14 +151,14 @@ struct EnableIfHandler
151151
// use std::enable_if to build more complex conditional event handling
152152
template <typename TEvent>
153153
typename std::enable_if<std::is_class<TEvent>::value>::type
154-
react(const TEvent&, FullControl&) noexcept {
154+
react(const TEvent&, FullControl&) {
155155
std::cout << " EnableIfHandler: reacting to a <class event>\n";
156156
}
157157

158158
// but remember to cover all the remaining cases
159159
template <typename TEvent>
160160
typename std::enable_if<!std::is_class<TEvent>::value>::type
161-
react(const TEvent&, FullControl&) noexcept {
161+
react(const TEvent&, FullControl&) {
162162
std::cout << " EnableIfHandler: reacting to a <non-class event>\n";
163163
}
164164
};
@@ -168,15 +168,14 @@ struct EnableIfHandler
168168
struct Target
169169
: FSM::State
170170
{
171-
void enter(Control&) noexcept {
171+
void enter(Control&) {
172172
std::cout << " changed to Target\n";
173173
}
174174
};
175175

176176
////////////////////////////////////////////////////////////////////////////////
177177

178-
int
179-
main() noexcept {
178+
int main() {
180179
FSM::Instance machine;
181180

182181
std::cout << "sending PrimaryEvent:\n";

examples/basic_audio_player/main.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
// An HFSM2 port of https://gist.github.com/martinmoene/797b1923f9c6c1ae355bb2d6870be25e
55
// by Martin Moene (see https://twitter.com/MartinMoene/status/1118453128834232320)
66

7-
#include <assert.h>
8-
97
#include <iostream>
108
#include <string>
119

10+
#include <assert.h>
11+
1212
#define HFSM2_ENABLE_LOG_INTERFACE
1313
#define HFSM2_ENABLE_STRUCTURE_REPORT
1414
#include <hfsm2/machine.hpp>
@@ -64,7 +64,7 @@ static_assert(FSM::stateId<Paused>() == 3, "");
6464
struct Logger
6565
: M::LoggerInterface
6666
{
67-
static const char* stateName(const StateID stateId) noexcept {
67+
static const char* stateName(const StateID stateId) {
6868
switch (stateId) {
6969
case 1:
7070
return "Idle";
@@ -81,7 +81,7 @@ struct Logger
8181
void recordTransition(const Context& /*context*/,
8282
const StateID origin,
8383
const TransitionType /*transition*/,
84-
const StateID target) noexcept override
84+
const StateID target) override
8585
{
8686
std::cout << stateName(origin) << " -> " << stateName(target) << "\n";
8787
}
@@ -94,7 +94,7 @@ struct Base
9494
: FSM::State
9595
{
9696
template <typename Event>
97-
void react(const Event&, FullControl&) noexcept {
97+
void react(const Event&, FullControl&) {
9898
std::cout << "[unsupported transition]\n";
9999
}
100100
};
@@ -105,7 +105,7 @@ struct Idle
105105
{
106106
using Base::react;
107107

108-
void react(const Play& event, FullControl& control) noexcept {
108+
void react(const Play& event, FullControl& control) {
109109
control.context() = event.title;
110110
control.changeTo<Playing>();
111111
}
@@ -116,11 +116,11 @@ struct Playing
116116
{
117117
using Base::react;
118118

119-
void react(const Pause&, FullControl& control) noexcept {
119+
void react(const Pause&, FullControl& control) {
120120
control.changeTo<Paused>();
121121
}
122122

123-
void react(const Stop&, FullControl& control) noexcept {
123+
void react(const Stop&, FullControl& control) {
124124
control.changeTo<Idle>();
125125
}
126126
};
@@ -130,19 +130,18 @@ struct Paused
130130
{
131131
using Base::react;
132132

133-
void react(const Resume&, FullControl& control) noexcept {
133+
void react(const Resume&, FullControl& control) {
134134
control.changeTo<Playing>();
135135
}
136136

137-
void react(const Stop&, FullControl& control) noexcept {
137+
void react(const Stop&, FullControl& control) {
138138
control.changeTo<Idle>();
139139
}
140140
};
141141

142142
//------------------------------------------------------------------------------
143143

144-
int
145-
main() noexcept {
144+
int main() {
146145
// construct everything
147146
Context title;
148147
Logger logger;

0 commit comments

Comments
 (0)