Finding UDAs with Templates
Paul O'Neil
redballoon36 at gmail.com
Mon Jul 22 21:27:14 PDT 2013
I'm trying to write some code that finds all the members of a class that
have a particular user defined attribute. My current attempt is at
https://github.com/todayman/d_template_experiments/tree/8fccd27d7d5557ec6e2f0614374cf5f79fe80b4c
I would like to have a static method that returns an array of strings of
the names of the members with the "@Sync" attribute. I use the
allMembers trait to get the list of strings, then try to filter out the
ones I want. There are problems when I convert from the string to a
symbol / something to get the attributes. Right now, I'm getting errors
like:
> metadata.d(158): Error: template instance doesFieldSync_imp!(_hash) cannot use local '_hash' as parameter to non-global template doesFieldSync_imp(alias field)()
which I understand is related to
http://d.puremagic.com/issues/show_bug.cgi?id=5710
and
> metadata.d(160): Error: first argument is not a symbol
from
_traits(getAttributes, mxin("FileData."~key))
What's a good way to work around these? I'm also open to entirely
different ways of doing this.
Thanks,
Paul
More information about the Digitalmars-d-learn
mailing list