1 2 module witchcraft.impl.structs; 3 4 version(aggressive): 5 6 import witchcraft; 7 8 template StructImpl(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 // In this context, use constructor-impl. 26 template ConstructorMixin(T, size_t overload) 27 { 28 alias ConstructorMixin = ConstructorImpl!(T, overload); 29 } 30 31 mixin WitchcraftStruct; 32 33 alias StructImpl = StructMixin!T; 34 } 35 else 36 { 37 class StructImpl : Struct 38 { 39 const(Attribute)[] getAttributes() const 40 { 41 assert(0, "Struct " ~ T.stringof ~ " is inaccessible."); 42 } 43 44 override const(Constructor)[] getConstructors() const 45 { 46 assert(0, "Struct " ~ T.stringof ~ " is inaccessible."); 47 } 48 49 const(Type) getDeclaringType() const 50 { 51 assert(0, "Struct " ~ T.stringof ~ " is inaccessible."); 52 } 53 54 const(TypeInfo) getDeclaringTypeInfo() const 55 { 56 assert(0, "Struct " ~ T.stringof ~ " is inaccessible."); 57 } 58 59 string getFullName() const 60 { 61 assert(0, "Struct " ~ T.stringof ~ " is inaccessible."); 62 } 63 64 string getName() const 65 { 66 return T.stringof; 67 } 68 69 string getProtection() const 70 { 71 return __traits(getProtection, T); 72 } 73 74 override const(TypeInfo) getTypeInfo() const 75 { 76 assert(0, "Struct " ~ T.stringof ~ " is inaccessible."); 77 } 78 79 @property 80 final bool isAccessible() const 81 { 82 return false; 83 } 84 } 85 } 86 }