1 2 module witchcraft.impl.interfaces; 3 4 version(aggressive): 5 6 import witchcraft; 7 8 template InterfaceTypeImpl(T) 9 { 10 // TODO : Determine this more reliably. 11 static if(__traits(getProtection, T) == "public") 12 { 13 // In this context, use field-impl. 14 template FieldMixin(T, string name) 15 { 16 alias FieldMixin = FieldImpl!(T, name); 17 } 18 19 // In this context, use method-impl. 20 template MethodMixin(T, string name, size_t overload) 21 { 22 alias MethodMixin = MethodImpl!(T, name, overload); 23 } 24 25 mixin WitchcraftInterface; 26 27 alias InterfaceTypeImpl = InterfaceTypeMixin!T; 28 } 29 else 30 { 31 class InterfaceTypeImpl : InterfaceType 32 { 33 const(Attribute)[] getAttributes() const 34 { 35 assert(0, "Interface " ~ T.stringof ~ " is inaccessible."); 36 } 37 38 const(Type) getDeclaringType() const 39 { 40 assert(0, "Interface " ~ T.stringof ~ " is inaccessible."); 41 } 42 43 const(TypeInfo) getDeclaringTypeInfo() const 44 { 45 assert(0, "Interface " ~ T.stringof ~ " is inaccessible."); 46 } 47 48 string getFullName() const 49 { 50 assert(0, "Interface " ~ T.stringof ~ " is inaccessible."); 51 } 52 53 string getName() const 54 { 55 return T.stringof; 56 } 57 58 string getProtection() const 59 { 60 return __traits(getProtection, T); 61 } 62 63 override const(TypeInfo) getTypeInfo() const 64 { 65 assert(0, "Interface " ~ T.stringof ~ " is inaccessible."); 66 } 67 68 @property 69 final bool isAccessible() const 70 { 71 return false; 72 } 73 } 74 } 75 }