Skip to content

Commit 5295356

Browse files
committed
GCC rejects the enum classes here. Replacing them with ints for now.
1 parent 3999db1 commit 5295356

2 files changed

Lines changed: 27 additions & 26 deletions

File tree

‎benchmarks/src/BenchmarkLifeSim.h‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ using std::string;
3030
using std::unique_ptr;
3131
using std::vector;
3232

33-
enum class Seasons { summer, winter };
34-
enum class Migration { enter, leave };
33+
// FIXME: GCC doesn't like enum class in MakeEventSource
34+
enum { summer, winter };
35+
enum { enter, leave };
3536

3637
template <typename T>
3738
struct Incrementer { T operator()(Token,T v) const { return v+1; } };
@@ -53,10 +54,10 @@ class Time
5354
SignalT<int> TotalDays = Iterate(NewDay, 0, Incrementer<int>());
5455
SignalT<int> DayOfYear = TotalDays % 365;
5556

56-
SignalT<Seasons> Season = MakeSignal(
57+
SignalT<int> Season = MakeSignal(
5758
DayOfYear,
58-
[] (int day) {
59-
return day < 180 ? Seasons::winter : Seasons::summer;
59+
[] (int day) -> int {
60+
return day < 180 ? winter : summer;
6061
});
6162
};
6263

@@ -71,19 +72,19 @@ class Region
7172

7273
BoundsT Bounds;
7374

74-
EventSourceT<Migration> EnterOrLeave = MakeEventSource<D,Migration>();
75+
EventSourceT<int> EnterOrLeave = MakeEventSource<D,int>();
7576

7677
SignalT<int> AnimalCount = Iterate(
7778
EnterOrLeave,
7879
0,
79-
[] (Migration m, int count) {
80-
return m == Migration::enter ? count + 1 : count - 1;
80+
[] (int m, int count) {
81+
return m == enter ? count + 1 : count - 1;
8182
});
8283

8384
SignalT<int> FoodPerDay = MakeSignal(
8485
theTime.Season,
85-
[] (Seasons season) {
86-
return season == Seasons::summer ? 20 : 10;
86+
[] (int season) {
87+
return season == summer ? 20 : 10;
8788
});
8889

8990
SignalT<int> FoodOutputPerDay = MakeSignal(
@@ -95,8 +96,8 @@ class Region
9596
EventsT<int> FoodOutput = Pulse(theTime.NewDay, FoodOutputPerDay);
9697

9798
Region(Time<D>& time, int x, int y) :
98-
theTime( time ),
99-
Bounds( x*10, x*10+9, y*10, y*10+9 )
99+
Bounds( x*10, x*10+9, y*10, y*10+9 ),
100+
theTime( time )
100101
{}
101102

102103
PositionT Center() const
@@ -195,7 +196,7 @@ class Animal
195196
SignalT<PositionT> Position;
196197
SignalT<Region<D>*> NewRegion;
197198

198-
EventsT<Region<D>*> RegionChanged = Monitor(NewRegion);;
199+
EventsT<Region<D>*> RegionChanged = Monitor(NewRegion);
199200

200201
SignalT<int> Age = Iterate(theTime.NewDay, 0, Incrementer<int>());
201202

@@ -240,14 +241,14 @@ class Animal
240241
})
241242
)
242243
{
243-
initRegion->EnterOrLeave(Migration::enter);
244+
initRegion->EnterOrLeave(enter);
244245

245246
Observe(
246247
RegionChanged,
247248
With(CurrentRegion),
248249
[this] (Region<D>* newRegion, Region<D>* oldRegion) {
249-
oldRegion->EnterOrLeave(Migration::leave);
250-
newRegion->EnterOrLeave(Migration::enter);
250+
oldRegion->EnterOrLeave(leave);
251+
newRegion->EnterOrLeave(enter);
251252

252253
// Change region in continuation
253254
CurrentRegion <<= newRegion;

‎examples/src/BasicAlgorithms.cpp‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,25 +183,25 @@ namespace example5
183183

184184
REACTIVE_DOMAIN(D)
185185

186-
enum class ECmd { increment, decrement, reset };
186+
enum ECmd { increment, decrement, reset };
187187

188188
class Counter
189189
{
190190
public:
191191
USING_REACTIVE_DOMAIN(D)
192192

193-
EventSourceT<ECmd> Update = MakeEventSource<D,ECmd>();
193+
EventSourceT<int> Update = MakeEventSource<D,int>();
194194
VarSignalT<int> Delta = MakeVar<D>(1);
195195
VarSignalT<int> Start = MakeVar<D>(0);
196196

197197
SignalT<int> Count = Iterate(
198198
Update,
199199
Start.Value(),
200200
With(Delta, Start),
201-
[] (ECmd cmd, int oldCount, int delta, int start) {
202-
if (cmd == ECmd::increment)
201+
[] (int cmd, int oldCount, int delta, int start) {
202+
if (cmd == increment)
203203
return oldCount + delta;
204-
else if (cmd == ECmd::decrement)
204+
else if (cmd == decrement)
205205
return oldCount - delta;
206206
else
207207
return start;
@@ -216,19 +216,19 @@ namespace example5
216216

217217
cout << "Start: " << myCounter.Count() << endl; // output: 0
218218

219-
myCounter.Update(ECmd::increment);
220-
myCounter.Update(ECmd::increment);
221-
myCounter.Update(ECmd::increment);
219+
myCounter.Update(increment);
220+
myCounter.Update(increment);
221+
myCounter.Update(increment);
222222

223223
cout << "3x increment by 1: " << myCounter.Count() << endl; // output: 3
224224

225225
myCounter.Delta <<= 5;
226-
myCounter.Update(ECmd::decrement);
226+
myCounter.Update(decrement);
227227

228228
cout << "1x decrement by 5: " << myCounter.Count() << endl; // output: -2
229229

230230
myCounter.Start <<= 100;
231-
myCounter.Update(ECmd::reset);
231+
myCounter.Update(reset);
232232

233233
cout << "reset to 100: " << myCounter.Count() << endl; // output: 100
234234

0 commit comments

Comments
 (0)