1 2 module witchcraft.impl.attributes; 3 4 import witchcraft; 5 6 import std.variant; 7 8 class AttributeImpl(alias attribute) : Attribute 9 { 10 override Variant get() const 11 { 12 static if(is(typeof(attribute))) 13 { 14 return Variant(attribute); 15 } 16 else 17 { 18 return Variant(null); 19 } 20 } 21 22 override const(Type) getAttributeType() const 23 { 24 static if(is(typeof(attribute))) 25 { 26 static if(__traits(compiles, typeof(attribute).metaof)) 27 { 28 return typeof(attribute).metaof; 29 } 30 else 31 { 32 return null; 33 } 34 } 35 else 36 { 37 static if(__traits(compiles, attribute.metaof)) 38 { 39 return attribute.metaof; 40 } 41 else 42 { 43 return null; 44 } 45 } 46 } 47 48 override const(TypeInfo) getAttributeTypeInfo() const 49 { 50 static if(is(typeof(attribute))) 51 { 52 return typeid(typeof(attribute)); 53 } 54 else 55 { 56 return typeid(attribute); 57 } 58 } 59 60 override bool isExpression() const 61 { 62 return is(typeof(attribute)); 63 } 64 65 override bool isType() const 66 { 67 return !isExpression; 68 } 69 }