enums cause issues because the C enum:

    enum Status {
       STATUS_SUCCESS
    }

has type enum Status and the members are access like STATUS_SUCCESS. The same enum in D is

    enum Status {
       STATUS_SUCCESS
    }

has type Status and the members are accessed using Status.STATUS_SUCCESS

//! 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 proposed 'extern(C) enum' to get rid of all those manual aliases but as always nothing happened.


htod is not a useful tool, especially if you want to do any sort of cross-platform, robust binding, manual binding is really the only way to do it properly and properly reflect the original binding and api of the library.

It doesn't take that long, I did the binding for the 3000 line cairo.h file in about 3 hours, through judicious use of regex replaces and macros (I love Vim).

Exactly.

Reply via email to