On 2017-07-19 13:49, Andrew Edwards wrote:
Thanks Jacob and Nicholas... Brian Schott helped me out a bit on IRC
earlier. I'm still not getting exactly what I'm looking for though so
wanted to experiment a bit more before posting an update here. I'll
check out the warp.d examples Nicholas linked to above.
Here's an example:
module mainMod;
import std.meta;
@(1, 2) void foo() {}
@("asd") void bar() {}
void main()
{
foreach (m ; __traits(allMembers, mainMod))
{
alias udas = AliasSeq!(__traits(getAttributes, mixin(m)));
static if (udas.length > 0)
pragma(msg, udas);
}
}
And in runnable form [1]. This will iterate all members of the "mainMod"
module and print all the UDAs, if the member has any. IF you want to
access the UDAs of any classes or structs, then you need to recursively
iterate the members.
[1] https://is.gd/segmDD
--
/Jacob Carlborg