Mercurial > projects > dang
view basic/Attribute.d @ 167:cbebde9ba2c8
proper patch for llvm bindings
author | dan amlund <danamlund@gmail.com> |
---|---|
date | Wed, 23 Jul 2008 00:31:11 +0200 |
parents | 6ec686d9c87d |
children |
line wrap: on
line source
module basic.Attribute; import tango.core.BitManip; import Integer = tango.text.convert.Integer; import tango.io.Stdout; enum Protection : uint { Private = 1<<0, Public = 1<<1, Package = 1<<2, Protected = 1<<3, Export = 1<<4, } enum Extern : uint { C = 1<<12, CPlusPlus = 1<<13, D = 1<<14, Windows = 1<<15, Pascal = 1<<16, System = 1<<17, } struct Attribute { void setProtection(Protection p) { att &= 0xFFFFFFE0; att |= p; } Protection getProtection() { Protection p = Protection.Public; switch(bsf(0xF0000000 | att)) { case 0: p = Protection.Private; break; case 1: p = Protection.Public; break; case 2: p = Protection.Package; break; case 3: p = Protection.Protected; break; case 4: p = Protection.Export; break; default: break; } return p; } void setExtern(Extern e) { att &= 0xFF7C0FFF; att |= e; } Extern getExtern() { Extern e = Extern.D; switch(bsf(0xF0000000 | att >> 12)) { case 0: e = Extern.C; break; case 1: e = Extern.CPlusPlus; break; case 2: e = Extern.D; break; case 3: e = Extern.Windows; break; case 4: e = Extern.Pascal; break; case 5: e = Extern.System; break; default: break; } return e; } void setStatic() { att |= Static; } bool getStatic() { return att & Static ? true : false; } void setFinal() { att |= Final; } bool getFinal() { return att & Final ? true : false; } void setConst() { att |= Const; } bool getConst() { return att & Const ? true : false; } void setAbstract() { att |= Abstract; } bool getAbstract() { return att & Abstract ? true : false; } void setOverride() { att |= Override; } bool getOverride() { return att & Override ? true : false; } void setDeprecated(){ att |= Deprecated; } bool getDeprecated(){ return att & Deprecated ? true : false; } void setAuto() { att |= Auto; } bool getAuto() { return att & Auto ? true : false; } char[] toString() { return Integer.toString(att); } private: uint att; static const uint Static = 1<<5; static const uint Final = 1<<6; static const uint Const = 1<<7; static const uint Abstract = 1<<8; static const uint Override = 1<<9; static const uint Deprecated = 1<<10; static const uint Auto = 1<<11; }