[7ee5d6d] | 1 | // Only Limited features are supported currently |
---|
| 2 | |
---|
| 3 | enum Days; |
---|
| 4 | enum Days { Mon, Tues, Wed, Num }; // int type, integral type => auto number |
---|
| 5 | Days x0; |
---|
| 6 | enum Days x1; |
---|
| 7 | enum( char ) { A = 'A', B, C, D }; // char type, integral type => auto number |
---|
| 8 | enum( double ) { F = 3.5, G = 7.7 }; // double type, non-integral type => programmer must assign ALL enums |
---|
| 9 | enum( double ) X { R = 3.5, QQ = 7.7 }; // double type, non-integral type => programmer must assign ALL enums |
---|
| 10 | enum( char * ) names { X = "X", Y = "Y" }; // char * type, non-integral type => programmer must assign ALL enums |
---|
| 11 | enum( int ) { Q, W, E }; // int type, integral type => auto number |
---|
| 12 | |
---|
| 13 | int w; |
---|
| 14 | enum( int * ) addr { W = &w }; // int * type, non-integral type => programmer must assign ALL enums |
---|
| 15 | enum( * int ) addr2 { WW = &w }; // int * type, non-integral type => programmer must assign ALL enums |
---|
| 16 | |
---|
| 17 | /* |
---|
| 18 | void f() {} |
---|
| 19 | void g() {} |
---|
| 20 | enum( void (*)() ) { FF = f, FG = g }; // void (*)() type, non-integral type => programmer must assign ALL enums |
---|
| 21 | enum( void (*)() ) funs { FF = f, FG = g }; // void (*)() type, non-integral type => programmer must assign ALL enums |
---|
| 22 | enum( * [void] () ) { FF1 = f, FG1 = g }; // void (*)() type, non-integral type => programmer must assign ALL enums |
---|
| 23 | enum( * [void] () ) funs1 { FF1 = f, FG1 = g }; // void (*)() type, non-integral type => programmer must assign ALL enums |
---|
| 24 | |
---|
| 25 | enum( [int, int] ) { XXX = [1,2] }; |
---|
| 26 | enum( [int, int] ) na { XXX = [1,2] }; |
---|
| 27 | |
---|
| 28 | enum fred; |
---|
| 29 | struct S {}; |
---|
| 30 | |
---|
| 31 | enum S { UX = { { 3 }, 4 }, UY = { { 7 }, 8 } }; |
---|
| 32 | enum( struct S ) mary { MX }; |
---|
| 33 | enum mary { MX }; |
---|
| 34 | enum( struct S * ) mary { MX = { { 3 }, 4 }, MY = { { 7 }, 8 } }; |
---|
| 35 | enum( S * ) mary { MX = { { 3 }, 4 }, MY = { { 7 }, 8 } }; |
---|
| 36 | enum( * S ) mary { MX = { { 3 }, 4 }, MY = { { 7 }, 8 } }; |
---|
| 37 | enum( enum fred ) mary { C }; |
---|
| 38 | |
---|
| 39 | struct HH { |
---|
| 40 | enum hh { h }; |
---|
| 41 | }; |
---|
| 42 | //enum HH.hh h; |
---|
| 43 | |
---|
| 44 | // Fred is a subset of char * |
---|
| 45 | enum( char * ) Fred { A = "A", B = "B", C = "C" }; |
---|
| 46 | |
---|
| 47 | // Jack is a subset of Fred |
---|
| 48 | // these are same |
---|
| 49 | enum( enum Fred ) Jack { W = A, Y = C}; |
---|
| 50 | enum( enum Fred ) Jack { W, Y = C}; |
---|
| 51 | enum( Fred ) Jack { W, Y = C}; // desirable, but hard to parse |
---|
| 52 | |
---|
| 53 | // Mack is a subset of char * |
---|
| 54 | // these are same |
---|
| 55 | enum( char * ) Mack { W1 = A, Y1 = "whee" }; |
---|
| 56 | |
---|
| 57 | // Mary is a SUPERSET of Fred |
---|
| 58 | // these are same |
---|
| 59 | enum Mary { inline Fred, D = "hello" }; |
---|
| 60 | enum( char * ) Mary { inline Fred, D = "hello" }; |
---|
| 61 | |
---|
| 62 | enum( char * ) Charlie { G = "G", H = "H" }; |
---|
| 63 | enum Jane { inline Fred, inline Charlie, K = "K" }; |
---|
| 64 | enum( char * ) Jane { inline Fred, inline Charlie, K = "K" }; |
---|
| 65 | |
---|
| 66 | typedef long int size_t; |
---|
| 67 | enum( size_t ) Lisa { L1, L2, L3}; |
---|
| 68 | |
---|
| 69 | // bad: Fred is char*; Lisa is size_t |
---|
| 70 | enum Jane { inline Fred, inline Lisa, M = "M" }; |
---|
| 71 | enum( char * ) Jane { inline Fred, inline Lisa, M = "M" }; |
---|
| 72 | |
---|
| 73 | enum( char ) Steve { steveA = 'A' }; |
---|
| 74 | enum Don1 { inline Steve, daveB = (char) 2 }; // ok |
---|
| 75 | enum Don2 { inline Steve, daveB = 2 }; // typeof( readLine() ? steveA : 2 ) |
---|
| 76 | |
---|
| 77 | // desirable, may cause constexpr problems |
---|
| 78 | enum( struct vec3f ) Axis { Up @= {1,0,0}, Left @= {0,1,1}, Front @= {0,1,0} }; |
---|
| 79 | */ |
---|
| 80 | |
---|
| 81 | // enum struct S.T jane { JX = { 3 } }; |
---|
| 82 | // enum S.T jane2 { JX = { 3 } }; |
---|
| 83 | |
---|
| 84 | // enum Fred { A, B, C }; |
---|
| 85 | // enum enum Fred Mary { D, E, F }; // enumeration inheritance, auto number starting at C + 1 |
---|
| 86 | // enum enum Fred Mary { D, E, F }; // enumeration inheritance, auto number starting at C + 1 |
---|
| 87 | // Fred f = A; |
---|
| 88 | // //Mary m1 = A, m2 = D; |
---|
| 89 | // #if 0 |
---|
| 90 | // #endif // 0 |
---|
| 91 | |
---|
| 92 | // enum Fred Jane { D = C, E = B, F = A } // alternate reverse names |
---|
| 93 | // Jane j1 = A, J2 = F; // both value 0 |
---|
| 94 | |
---|
| 95 | // struct Color { // C++ scoped enumerations |
---|
| 96 | // enum { red, green = 20, blue }; |
---|
| 97 | // }; |
---|
| 98 | // //Color color = Color.red; |
---|
| 99 | |
---|
| 100 | // Local Variables: // |
---|
| 101 | // tab-width: 4 // |
---|
| 102 | // compile-command: "~/software/mary/cfa-cc/driver/cfa -XCFA -P -XCFA parse -XCFA -n test_enum.cfa" // |
---|
| 103 | // End: // |
---|