1 2 module witchcraft.impl.classes; 3 4 version(aggressive): 5 6 import witchcraft; 7 8 template ClassImpl(T) 9 if(is(T == class)) 10 { 11 // TODO : Determine this more reliably. 12 static if(__traits(getProtection, T) == "public") 13 { 14 // In this context, use field-impl. 15 template FieldMixin(T, string name) 16 { 17 alias FieldMixin = FieldImpl!(T, name); 18 } 19 20 // In this context, use method-impl. 21 template MethodMixin(T, string name, size_t overload) 22 { 23 alias MethodMixin = MethodImpl!(T, name, overload); 24 } 25 26 // In this context, use constructor-impl. 27 template ConstructorMixin(T, size_t overload) 28 { 29 alias ConstructorMixin = ConstructorImpl!(T, overload); 30 } 31 32 mixin WitchcraftClass; 33 34 alias ClassImpl = ClassMixin!T; 35 } 36 else 37 { 38 class ClassImpl : Class 39 { 40 @property 41 override Object create() const 42 { 43 assert(0, "Class " ~ T.stringof ~ " is inaccessible."); 44 } 45 46 const(Attribute)[] getAttributes() const 47 { 48 assert(0, "Class " ~ T.stringof ~ " is inaccessible."); 49 } 50 51 override const(Constructor)[] getConstructors() const 52 { 53 assert(0, "Class " ~ T.stringof ~ " is inaccessible."); 54 } 55 56 const(Type) getDeclaringType() const 57 { 58 assert(0, "Class " ~ T.stringof ~ " is inaccessible."); 59 } 60 61 const(TypeInfo) getDeclaringTypeInfo() const 62 { 63 assert(0, "Class " ~ T.stringof ~ " is inaccessible."); 64 } 65 66 override const(InterfaceType)[] getInterfaces() const 67 { 68 assert(0, "Class " ~ T.stringof ~ " is inaccessible."); 69 } 70 71 string getFullName() const 72 { 73 assert(0, "Class " ~ T.stringof ~ " is inaccessible."); 74 } 75 76 string getName() const 77 { 78 return T.stringof; 79 } 80 81 string getProtection() const 82 { 83 return __traits(getProtection, T); 84 } 85 86 override const(Class) getSuperClass() const 87 { 88 assert(0, "Class " ~ T.stringof ~ " is inaccessible."); 89 } 90 91 override const(TypeInfo) getSuperTypeInfo() const 92 { 93 assert(0, "Class " ~ T.stringof ~ " is inaccessible."); 94 } 95 96 override const(TypeInfo) getTypeInfo() const 97 { 98 assert(0, "Class " ~ T.stringof ~ " is inaccessible."); 99 } 100 101 @property 102 override bool isAbstract() const 103 { 104 assert(0, "Class " ~ T.stringof ~ " is inaccessible."); 105 } 106 107 @property 108 override bool isFinal() const 109 { 110 assert(0, "Class " ~ T.stringof ~ " is inaccessible."); 111 } 112 113 @property 114 final bool isAccessible() const 115 { 116 return false; 117 } 118 } 119 } 120 }