microsoft / win32metadata

Tooling to generate metadata for Win32 APIs in the Windows SDK.
Other
1.34k stars 118 forks source link

`IExplorerCommand:` Methods could return flag type instead of `u32` and flag types should be marked as flags #2007

Closed Fulgen301 closed 2 weeks ago

Fulgen301 commented 1 month ago

IExplorerCommand::GetState returns EXPCMDSTATE in C, which is a typedef to DWORD, while all the values are part of the _EXPCMDSTATE enum, necessitating extra casts when used in Rust. As all the valid values are part of that enum, the function could return that type directly, similar to #1674. The same applies to IExplorerCommand::GetFlags and EXPCMDSTATE / _EXPCMDSTATE.

Additionally, _EXPCMDSTATE / _EXPCMDFLAGS aren't marked as flags, so combining them via bitwise operations is impossible without casts in windows-rs.

riverar commented 1 month ago

The underlying type of _EXPCMDSTATE is int sadly. We might be able to use the associated enum attribute here, haven't looked yet. Will leave this open for others to chime in.

enum _EXPCMDSTATE
    {
        ECS_ENABLED = 0,
        ECS_DISABLED    = 0x1,
        ECS_HIDDEN  = 0x2,
        ECS_CHECKBOX    = 0x4,
        ECS_CHECKED = 0x8,
        ECS_RADIOCHECK  = 0x10
    } ;