Created
January 11, 2015 00:24
-
-
Save Laeeth/e5a772175d6fa6daba1a to your computer and use it in GitHub Desktop.
reflection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module deneme; | |
import std.string; | |
import std.traits; | |
struct MyAttr | |
{} | |
@MyAttr | |
void foo(int i, double d) pure @nogc nothrow @property | |
{} | |
void main() | |
{ | |
foreach (m; __traits(allMembers, deneme)) { | |
pragma(msg, format("module member: %s", m)); | |
static if (mixin ("isCallable!" ~ m)) { | |
pragma(msg, format("%s is callable", m)); | |
foreach (funcAttr; | |
mixin (format("__traits(getFunctionAttributes, | |
%s)", m))) { | |
pragma(msg, format(" function attribute: %s", funcAttr)); | |
} | |
foreach (attr; mixin (format("__traits(getAttributes, %s)", | |
m))) { | |
static if (is (attr == MyAttr)) { | |
pragma(msg, format(" uda: %s", attr.stringof)); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment