Changeset b006c51e
- Timestamp:
- Nov 3, 2024, 2:47:59 PM (6 weeks ago)
- Branches:
- master
- Children:
- 10a9479d
- Parents:
- ad9f593
- Location:
- libcfa
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/prelude/builtins.c
rad9f593 rb006c51e 184 184 static inline quasi_void ?=?(quasi_void &, quasi_void & _src) { return _src; } 185 185 186 forall( E ) trait Bounded { 187 E lowerBound(void); 188 E upperBound(void); 189 }; 190 191 forall( E | Bounded( E ) ) trait Serial { 192 int fromInstance( E e ); 193 E fromInt_unsafe( int i ); 194 E succ_unsafe( E e ); 195 E pred_unsafe( E e ); 196 }; 197 198 forall( E | Serial( E ) ) { 199 E fromInt( int i ); 200 E succ( E e ); 201 E pred( E e ); 202 int Countof( E ); 203 } 204 205 206 forall( E ) trait CfaEnum { 207 const char * label( E e ); 208 int posn( E e ); 209 }; 210 211 forall( E, V | CfaEnum( E ) ) trait TypedEnum { 212 V value( E e ); 213 }; 214 186 215 // Local Variables: // 187 216 // mode: c // -
libcfa/src/enum.hfa
rad9f593 rb006c51e 2 2 3 3 #include "iostream.hfa" 4 5 forall( E ) trait Bounded {6 E lowerBound(void);7 E upperBound(void);8 };9 10 forall( E | Bounded( E ) ) trait Serial {11 int fromInstance( E e );12 E fromInt_unsafe( int i );13 E succ_unsafe( E e );14 E pred_unsafe( E e );15 };16 17 forall( E | Serial( E ) ) {18 E fromInt( int i );19 E succ( E e );20 E pred( E e );21 int Countof( E );22 }23 24 // forall( E | Bounded(E) ) trait SafeSerial {25 // // unsigned fromInstance( E e );26 // E fromInt_unsafe( unsigned i );27 // // E succ_unsafe( E e );28 // //E pred_unsafe( E e );29 30 // unsigned fromInstance( E e );31 // E fromInt( unsigned i );32 // E succ( E e );33 // E pred( E e );34 // };35 36 forall( E ) trait CfaEnum {37 const char * label( E e );38 int posn( E e );39 };40 41 forall( E, V | CfaEnum( E ) ) trait TypedEnum {42 V value( E e );43 };44 45 // I/O46 4 47 5 forall( istype & | istream( istype ), E | CfaEnum( E ) | Serial(E) )
Note: See TracChangeset
for help on using the changeset viewer.