-
Notifications
You must be signed in to change notification settings - Fork 562
Make BOOL
a core type
#3441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Make BOOL
a core type
#3441
Conversation
This file contains hidden or 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 394 out of 409 changed files in this pull request and generated no comments.
Files not reviewed (15)
- crates/libs/sys/src/Windows/Wdk/Graphics/Direct3D/mod.rs: Evaluated as low risk
- crates/libs/sys/src/Windows/Win32/Devices/SerialCommunication/mod.rs: Evaluated as low risk
- crates/libs/sys/src/Windows/Win32/Data/HtmlHelp/mod.rs: Evaluated as low risk
- crates/libs/sys/src/Windows/Win32/Devices/Sensors/mod.rs: Evaluated as low risk
- crates/libs/sys/src/Windows/Win32/Devices/HumanInterfaceDevice/mod.rs: Evaluated as low risk
- crates/libs/sys/src/Windows/Win32/Devices/Usb/mod.rs: Evaluated as low risk
- crates/libs/sys/src/Windows/Win32/Devices/AllJoyn/mod.rs: Evaluated as low risk
- crates/libs/sys/src/Windows/Win32/Devices/Display/mod.rs: Evaluated as low risk
- crates/libs/sys/src/Windows/Win32/Devices/Communication/mod.rs: Evaluated as low risk
- crates/libs/sys/src/Windows/Win32/Devices/Enumeration/Pnp/mod.rs: Evaluated as low risk
- crates/libs/sys/src/Windows/Win32/Data/RightsManagement/mod.rs: Evaluated as low risk
- crates/libs/sys/src/Windows/Win32/Devices/WebServicesOnDevices/mod.rs: Evaluated as low risk
- crates/libs/sys/src/Windows/Win32/Devices/Bluetooth/mod.rs: Evaluated as low risk
- crates/libs/sys/src/Windows/Win32/Devices/BiometricFramework/mod.rs: Evaluated as low risk
- crates/libs/bindgen/src/writer/cpp_handle.rs: Evaluated as low risk
Comments suppressed due to low confidence (1)
crates/libs/result/src/bool.rs:7
- The behavior of the newly added BOOL type and its methods is not explicitly covered by tests.
pub struct BOOL(pub i32);
riverar
approved these changes
Jan 14, 2025
Merged
EliahKagan
added a commit
to EliahKagan/gitoxide
that referenced
this pull request
Apr 10, 2025
Bumping the `windows` dev-dependency of `gix-path` from 0.58.0 to 0.61.1 broke the use of `windows::Win32::Foundation::BOOL`, since `BOOL` is now `windows::core::BOOL` (and also available through the `windows_core` crate). It is not immediately obvious from the changelog at what point the change occurred. (A seemingly related change is described for the newer version microsoft/windows-rs#3441. See microsoft/windows-rs#3441 for context.) This imports `BOOL` from `windows::core` to adjust.
EliahKagan
added a commit
to EliahKagan/gitoxide
that referenced
this pull request
Apr 10, 2025
Bumping the `windows` dev-dependency of `gix-path` from 0.58.0 to 0.61.1 broke the use of `windows::Win32::Foundation::BOOL`, since `BOOL` is now `windows::core::BOOL` (and also available through the `windows_core` crate). It is not immediately obvious from the changelog at what point the change occurred. (A seemingly related change is described for the newer version microsoft/windows-rs#3441. See microsoft/windows-rs#3441 for context.) This imports `BOOL` from `windows::core` to adjust.
EliahKagan
added a commit
to GitoxideLabs/gitoxide
that referenced
this pull request
Apr 11, 2025
Bumping the `windows` dev-dependency of `gix-path` from 0.58.0 to 0.61.1 broke the use of `windows::Win32::Foundation::BOOL`, since `BOOL` is now `windows::core::BOOL` (and also available through the `windows_core` crate). It is not immediately obvious from the changelog at what point the change occurred. (A seemingly related change is described for the newer version microsoft/windows-rs#3441. See microsoft/windows-rs#3441 for context.) This imports `BOOL` from `windows::core` to adjust.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This update elevates
BOOL
to a "core type" in thewindows-bindgen
crate. Consider the following simple example generating bindings for theEnableMouseInPointer
function from a build script.That's pretty simple. The
windows-targets
crate provides linker support but otherwise these bindings are dependency-free. But what if I remove the--sys
option?"--in default --out src/bindings.rs --flat --filter EnableMouseInPointer"
This looks mostly right. The richer bindings take care of a bit of type conversion and error handling. The trouble is that the wrapper function expects the
BOOL
type to provide anok
method for retrieving the Win32 error code and converting it to aResult
value. The parameter also expects anInto
implementation to convert frombool
toBOOL
.One option is to use the new
--reference
option to explicitly tellwindows-bindgen
where to find theBOOL
implementation rather than simply generating it as a simple struct."--in default --out src/bindings.rs --flat --filter EnableMouseInPointer --reference windows,skip-root,Windows"
This works, but does require that you add a dependency on the
windows
crate with the "Win32_Foundation" feature enabled. The main drawback here is the sheer size of thewindows
crate. Its great for apps but doesn't work well as a dependency of a library crate that isn't entirely focused on Windows development.Well by elevating
BOOL
to a core type, the following produce bindings that only depend on the tinywindows-core
crate and avoids thewindows
crate entirely."--in default --out src/bindings.rs --flat --filter EnableMouseInPointer"
I considered a few other approaches but ultimately
BOOL
is just too foundational and important of a Windows type and this "just works" for the most common scenarios.Fixes: #3439