Skip to content

Simpler code gen for Boolean parameters#3373

Merged
kennykerr merged 8 commits intomasterfrom
simpler2
Dec 10, 2024
Merged

Simpler code gen for Boolean parameters#3373
kennykerr merged 8 commits intomasterfrom
simpler2

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
@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