Skip to content
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

Simpler code gen for Boolean parameters #3373

Merged
merged 8 commits into from
Dec 10, 2024
Merged

Simpler code gen for Boolean parameters #3373

merged 8 commits into from
Dec 10, 2024

Conversation

kennykerr
Copy link
Collaborator

@kennykerr kennykerr commented Dec 10, 2024

Building on #3370, this further eliminates the need for the TypeKind trait on Win32 handle types by using a new parameter hint for directly supporting BOOL and BOOLEAN parameters. This greatly simplifies many common Win32 APIs. More work needs to be done to streamline BOOL but this is a big step and this way I can keep this PR focused. Here's a representative "before and after". Note that this does not change sys-style bindings.

Before:

#[inline]
pub unsafe fn EnableMouseInPointer<P0>(fenable: P0) -> Result<()>
where
    P0: Param<BOOL>,
{
    link!("user32.dll" "system" fn EnableMouseInPointer(fenable: BOOL) -> BOOL);
    EnableMouseInPointer(fenable.param().abi()).ok()
}

After:

#[inline]
pub unsafe fn EnableMouseInPointer(fenable: bool) -> Result<()> {
    link!("user32.dll" "system" fn EnableMouseInPointer(fenable: BOOL) -> BOOL);
    EnableMouseInPointer(fenable.into()).ok()
}

@kennykerr kennykerr merged commit 1332b65 into master Dec 10, 2024
75 checks passed
@kennykerr kennykerr deleted the simpler2 branch December 10, 2024 18:31
@kennykerr kennykerr mentioned this pull request Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

windows-bindgen should write BOOL/BOOLEAN parameters directly as bool
1 participant