marlersoft / zigwin32

Zig bindings for Win32 generated by https://github.com/marlersoft/zigwin32gen
MIT License
257 stars 31 forks source link

WINDOW_LONG_PTR_INDEX should probably be a non-exhaustive enum #5

Closed Flaminator closed 3 years ago

Flaminator commented 3 years ago

Not sure if this is the right repository to report this in.

Before registering a window one can set the cbWndExtra in WNDCLASSEX to a number bigger than 0 to allocate extra window memory to be used in GetWindowLongPtrW and SetWindowLongPtrW.

The documentation of GetWindowLongPtr and SetWindowLongPtr state the following:

GetWindowLongPtrW:

nIndex The zero-based offset to the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window memory, minus the size of a LONG_PTR. To retrieve any other value, specify one of the following values.

SetWindowLongPtrW:

nIndex The zero-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra window memory, minus the size of a LONG_PTR. To set any other value, specify one of the following values

Currently WINDOW_LONG_PTR_INDEX which is the type of nIndex in this library is a normal enum. So I think WINDOW_LONG_PTR_INDEX should probably be made non-exhaustive.

marler8997 commented 3 years ago

zigwin32gen fix here: https://github.com/marlersoft/zigwin32gen/commit/c45713f1a298ded3d9bba66eeadf54eece66dbb7 resulting generated code fix here: aa954945e3f78ba149ff3828d151f54b4fc5ce0d

There's been some discussion in the metadata repo about the concept of exhaustive enums, but I don't think there's been any progress. For now, I'm defining all enums as exhaustive by default, and adding exceptions when I find them. I've added this enum as an exception.