On Friday, 5 April 2013 at 15:52:43 UTC, Dicebot wrote:
On Friday, 5 April 2013 at 15:20:06 UTC, Jacob Carlborg wrote:
On 2013-04-05 16:03, Vadim Lopatin wrote:
2) Read/write property
@property T someProperty() { ... }
@property xxx someProperty(T value) { ... }
treated as property with name 'someProperty'
BTW, I don't know how to check if property is read/write in
compile time.
If there's no better way you can always use
__traits(compiles), something like this:
__traits(compiles, { auto c = new Class; T v = c.someProperty;
c.someProperty = T.init; });
Currently that will compile regardless of @property or not.
Quoting
https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/http/restutil.d
:
template isPropertyGetter(T)
{
enum isPropertyGetter = (functionAttributes!(T) &
FunctionAttribute.property) != 0
&& !is(ReturnType!T == void);
}
template isPropertySetter(T)
{
enum isPropertySetter = (functionAttributes!(T) &
FunctionAttribute.property) != 0
&& is(ReturnType!T == void);
}
I'm iterating through class members using __traits(allMembers,
T), then accessing member using _traits(getMember,T,memberName)
I'm not sure which one of the members with the same name will be
returned by getMember... Property getter and setter have the same
name...
Is there any better way to iterate through members of class?