Mercurial > projects > dang
comparison src/basic/Attribute.d @ 207:e0551773a005
Added the correct version.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Tue, 12 Aug 2008 18:19:34 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
206:d3c148ca429b | 207:e0551773a005 |
---|---|
1 module basic.Attribute; | |
2 | |
3 import tango.core.BitManip; | |
4 import Integer = tango.text.convert.Integer; | |
5 | |
6 import tango.io.Stdout; | |
7 | |
8 enum Protection : uint | |
9 { | |
10 Private = 1<<0, | |
11 Public = 1<<1, | |
12 Package = 1<<2, | |
13 Protected = 1<<3, | |
14 Export = 1<<4, | |
15 } | |
16 | |
17 enum Extern : uint | |
18 { | |
19 C = 1<<12, | |
20 CPlusPlus = 1<<13, | |
21 D = 1<<14, | |
22 Windows = 1<<15, | |
23 Pascal = 1<<16, | |
24 System = 1<<17, | |
25 } | |
26 | |
27 struct Attribute | |
28 { | |
29 | |
30 void setProtection(Protection p) | |
31 { | |
32 att &= 0xFFFFFFE0; | |
33 att |= p; | |
34 } | |
35 | |
36 Protection getProtection() | |
37 { | |
38 Protection p = Protection.Public; | |
39 switch(bsf(0xF0000000 | att)) | |
40 { | |
41 case 0: | |
42 p = Protection.Private; | |
43 break; | |
44 case 1: | |
45 p = Protection.Public; | |
46 break; | |
47 case 2: | |
48 p = Protection.Package; | |
49 break; | |
50 case 3: | |
51 p = Protection.Protected; | |
52 break; | |
53 case 4: | |
54 p = Protection.Export; | |
55 break; | |
56 default: | |
57 break; | |
58 } | |
59 return p; | |
60 } | |
61 | |
62 void setExtern(Extern e) | |
63 { | |
64 att &= 0xFF7C0FFF; | |
65 att |= e; | |
66 } | |
67 | |
68 Extern getExtern() | |
69 { | |
70 Extern e = Extern.D; | |
71 switch(bsf(0xF0000000 | att >> 12)) | |
72 { | |
73 case 0: | |
74 e = Extern.C; | |
75 break; | |
76 case 1: | |
77 e = Extern.CPlusPlus; | |
78 break; | |
79 case 2: | |
80 e = Extern.D; | |
81 break; | |
82 case 3: | |
83 e = Extern.Windows; | |
84 break; | |
85 case 4: | |
86 e = Extern.Pascal; | |
87 break; | |
88 case 5: | |
89 e = Extern.System; | |
90 break; | |
91 default: | |
92 break; | |
93 } | |
94 return e; | |
95 } | |
96 | |
97 void setStatic() { att |= Static; } | |
98 bool getStatic() { return att & Static ? true : false; } | |
99 void setFinal() { att |= Final; } | |
100 bool getFinal() { return att & Final ? true : false; } | |
101 void setConst() { att |= Const; } | |
102 bool getConst() { return att & Const ? true : false; } | |
103 void setAbstract() { att |= Abstract; } | |
104 bool getAbstract() { return att & Abstract ? true : false; } | |
105 void setOverride() { att |= Override; } | |
106 bool getOverride() { return att & Override ? true : false; } | |
107 void setDeprecated(){ att |= Deprecated; } | |
108 bool getDeprecated(){ return att & Deprecated ? true : false; } | |
109 void setAuto() { att |= Auto; } | |
110 bool getAuto() { return att & Auto ? true : false; } | |
111 | |
112 char[] toString() | |
113 { | |
114 return Integer.toString(att); | |
115 } | |
116 | |
117 private: | |
118 uint att; | |
119 | |
120 | |
121 static const uint Static = 1<<5; | |
122 static const uint Final = 1<<6; | |
123 static const uint Const = 1<<7; | |
124 static const uint Abstract = 1<<8; | |
125 static const uint Override = 1<<9; | |
126 static const uint Deprecated = 1<<10; | |
127 static const uint Auto = 1<<11; | |
128 } |