Cairo Deimos bindings

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Apr 26 16:44:00 PDT 2012


On 4/27/12, Trass3r <un at known.com> wrote:
> //! bring named enum members into current scope
> string flattenNamedEnum(EnumType)()
> if (is (EnumType == enum))
> {
> 	string s = "";
> 	foreach (i, e; __traits(allMembers, EnumType))
> 	{
> 		s ~= "alias " ~ EnumType.stringof ~ "." ~ __traits(allMembers,
> EnumType)[i] ~ " " ~ __traits(allMembers, EnumType)[i] ~ ";\n";
> 	}
>
> 	return s;
> }

I used something similar for a custom DLL symbol loader. I defined all
extern(C) function pointers inside of a struct, then mixed in the
loader code for each function by iterating all fields of the struct,
and then used a "flattenName" type template to make all the function
pointers global.


More information about the Digitalmars-d mailing list