In my code I iterate in CT over class methods marked as @property and I have a probleme that one of methods is @disable. So I just want to skip @disable members. I found possible solution, but it's interesting to we if we have more clear and obvious way to test for @disable without using __traits( compile ) for it? @disable "looks" like attribute but seems that I cant't get it through __traits( getAttributes ) or __traits( getFunctionAttributes ). Maybe we could add something to test for @disable if it's not already exists?

void fillProperties(Ctrl)(Ctrl ctrl, IDirectiveStatement statement, Interpreter interp)
{
        import std.meta: Alias, AliasSeq;
        import std.traits;
        import std.conv;

TDataNode[string] attrDict = getNamedAttributesValues(statement, interp);

foreach( memberName; AliasSeq!( __traits( allMembers, Ctrl ) ) )
        {
static if( __traits( compiles, __traits(getOverloads, Ctrl.init, memberName) ) )
                {
alias Overloads = AliasSeq!(__traits( getOverloads, Ctrl.init, memberName ));
                        foreach( overload; Overloads )
                        {

static if( (functionAttributes!(overload) & FunctionAttribute.property) )
                                {

                                        alias params = Parameters!(overload);
                                        static if( params.length == 1 )
                                        {

                                                alias propType = params[0];
static if( __traits(compiles, mixin("{ ctrl."~memberName~" = propType.init; }") ) )
                                                {
                                                        pragma( msg, memberName, ":  
",  typeof(&overload) );
TDataNode attrValue = attrDict.get( memberName, TDataNode(null) );
                                                        if( !attrValue.empty ) {
mixin( "ctrl." ~ memberName ~ " = nodeToDValue!(propType)(attrValue);" );
                                                        }
                                                }
                                        }
                                }
                        }
                }
        }
}

Reply via email to