1 module introspection.property;
2 
3 import introspection.type;
4 import introspection.protection;
5 import introspection.attribute;
6 
7 import std.traits;
8 
9 /// Stores information about properties
10 
11 struct Property {
12   ///
13   string name;
14 
15   ///
16   Type type;
17 
18   ///
19   Protection protection;
20 
21   ///
22   Attribute[] attributes;
23 
24   ///
25   bool isStatic;
26 }
27 
28 /// Describe a property
29 Property describeProperty(T, string member)() {
30   alias M = __traits(getMember, T, member);
31 
32   auto property = Property(member, describeType!(typeof(M)), __traits(getProtection, M).toProtection);
33   property.attributes = describeAttributeList!(__traits(getAttributes, M));
34   property.isStatic = hasStaticMember!(T, member);
35 
36   return property;
37 }
38 
39 /// ditto
40 Property describeProperty(alias T)() {
41   auto property = Property(T.stringof, describeType!(typeof(T)), __traits(getProtection, T).toProtection);
42   property.attributes = describeAttributeList!(__traits(getAttributes, T));
43 
44   return property;
45 }