@@ -30,8 +30,9 @@ using std::string;
3030using std::unique_ptr;
3131using 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
3637template <typename T>
3738struct 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;
0 commit comments