Last change
on this file since c2a4b62 was
c2a4b62,
checked in by JiadaL <j82liang@…>, 2 months ago
|
Refactor based type from operator assertion
|
-
Property mode set to
100644
|
File size:
907 bytes
|
Line | |
---|
1 | #pragma once |
---|
2 | |
---|
3 | forall(T) { // T is the based type of enum(T) |
---|
4 | forall(E) trait Bounded { |
---|
5 | E lowerBound(); |
---|
6 | E upperBound(); |
---|
7 | }; |
---|
8 | |
---|
9 | forall(E| Bounded(E, T)) trait Serial { |
---|
10 | unsigned fromInstance(E e); |
---|
11 | E fromInt(unsigned i); |
---|
12 | E succ(E e); |
---|
13 | E pred(E e); |
---|
14 | }; |
---|
15 | |
---|
16 | // Opague Enum + TypedEnum |
---|
17 | forall(E | Serial(E, T)) trait CfaEnum { |
---|
18 | char * labelE(E e); |
---|
19 | unsigned int posE(E e); |
---|
20 | }; |
---|
21 | |
---|
22 | forall(E | CfaEnum(E, T)) trait TypedEnum { |
---|
23 | T valueE(E e); |
---|
24 | }; |
---|
25 | |
---|
26 | forall(E | TypedEnum(E, T)) { |
---|
27 | // comparison |
---|
28 | int ?==?(E l, E r); |
---|
29 | int ?!=?(E l, E r); |
---|
30 | int ?!=?(E l, zero_t); |
---|
31 | int ?<?(E l, E r); |
---|
32 | int ?<=?(E l, E r); |
---|
33 | int ?>?(E l, E r); |
---|
34 | int ?>=?(E l, E r); |
---|
35 | |
---|
36 | // for testing; To be removed |
---|
37 | // char * typeEnumString(E e); |
---|
38 | char * typeEnumString(E e); |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
Note: See
TracBrowser
for help on using the repository browser.