digitalmars.D - missing: __traits(isPublic (private, etc...)
- Lloyd Dupont (26/26) Jun 20 2011 I am working a reflection / introspection library (dynamic / at runtime,...
I am working a reflection / introspection library (dynamic / at runtime, as opposed to compile time with template and mixin). Now I can create "PropertyInfo" classes for property with very little code and it all works well. I'm hitting a problem, trying to "register" all property of my class automatically. I have a vanilla implementation like that: ===== void RegisterProperties(T)() { foreach(mn ; __traits(derivedMembers, T)) GetProperty!(T, mn); } ===== The problem is, it's trying to register private properties! (and of course fail, due to access rights...) So far I have test like === static if(mixin("__traits(compiles, t." ~memberName ~")") ) { getter = &GETTER!(T, memberName); } ==== which test that the thing is a property. But how could I test it's a ***public*** property? if not possible, wouldn't it be a nice trait addition?
Jun 20 2011