- Timestamp:
- Aug 4, 2024, 9:49:25 PM (5 months ago)
- Branches:
- master
- Children:
- 7db4fcd4
- Parents:
- 7ab24fef
- Location:
- libcfa/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/enum.cfa
r7ab24fef r5f210c0 6 6 7 7 forall( E | Serial( E ) ) { 8 E fromInt( unsignedi ) {8 E fromInt( int i ) { 9 9 E upper = upperBound(); 10 10 E lower = lowerBound(); -
libcfa/src/enum.hfa
r7ab24fef r5f210c0 9 9 10 10 forall( E | Bounded( E ) ) trait Serial { 11 unsignedfromInstance( E e );12 E fromInt_unsafe( unsignedi );11 int fromInstance( E e ); 12 E fromInt_unsafe( int i ); 13 13 E succ_unsafe( E e ); 14 14 E pred_unsafe( E e ); … … 16 16 17 17 forall( E | Serial( E ) ) { 18 E fromInt( unsignedi );18 E fromInt( int i ); 19 19 E succ( E e ); 20 20 E pred( E e ); … … 36 36 forall( E ) trait CfaEnum { 37 37 const char * label( E e ); 38 unsignedint posn( E e );38 int posn( E e ); 39 39 }; 40 40 … … 63 63 64 64 E ++?( E & l ) { // increment operators 65 l = succ( l ); 65 int pos = posn(l); 66 l = fromInt_unsafe(pos+1); 67 return l; 68 } 69 70 E --?( E & l ) { 71 int pos = posn(l); 72 l = fromInt_unsafe(pos-1); 66 73 return l; 67 74 } 68 75 69 76 E ?+=? ( E & l, one_t ) { 70 l = succ(l); 77 int pos = posn(l); 78 l = fromInt_unsafe(pos+1); 71 79 return l; 72 80 } 73 81 74 82 E ?-=? ( E & l, one_t ) { 75 l = pred(l); 83 int pos = posn(l); 84 l = fromInt_unsafe(pos-1); 76 85 return l; 77 86 } 78 87 79 88 E ?+=? ( E & l, int i ) { 80 int pos = posn(l) + i; 89 int pos = posn(l); 90 l = fromInt_unsafe(pos+i); 81 91 return fromInt(pos); 82 92 } 83 93 84 94 E ?-=? ( E & l, int i ) { 85 int pos = posn(l) - i; 86 return fromInt(pos); 87 } 88 89 E ?++( E & l ) { 90 E ret = l; 91 l = succ( l ); 92 return ret; 93 } 94 95 E --?( E & l ) { 96 l = pred( l ); 95 int pos = posn(l); 96 l = fromInt_unsafe(pos-i); 97 97 return l; 98 98 } 99 99 100 E ?++( E & l ) { 101 int pos = posn(l); 102 l = fromInt_unsafe(pos+1); 103 return fromInt_unsafe(pos); 104 } 105 100 106 E ?--( E & l ) { 101 E ret = l;102 l = pred( l);103 return ret;107 int pos = posn(l); 108 l = fromInt_unsafe(pos-1); 109 return fromInt_unsafe(pos); 104 110 } 105 111 }
Note: See TracChangeset
for help on using the changeset viewer.