Skip to content

Commit

Permalink
Fix constant type collection (#2505)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle authored May 12, 2023
1 parent ad2838a commit 21785db
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/libs/bindgen/src/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ fn standalone_imp(gen: &mut Gen, names: &[&str]) -> String {
.find(|field| gen.reader.field_name(*field) == type_name.name)
{
constants.insert(field);
gen.reader
.type_collect_standalone(&gen.reader.field_type(field, None), &mut types);
gen.reader.type_collect_standalone(
&gen.reader.field_type(field, None).to_const_type(),
&mut types,
);
}

if let Some(field) = gen
Expand Down
9 changes: 9 additions & 0 deletions crates/tests/standalone/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ fn main() {
"src/b_overloads.rs",
&["Windows.Win32.NetworkManagement.NetManagement.AE_RESACCESS"],
);

// Ensures that constant types are properly collected
write_sys(
"src/b_constant_types.rs",
&[
"Windows.Win32.UI.WindowsAndMessaging.IDC_UPARROW",
"Windows.Win32.Security.Cryptography.CMC_ADD_ATTRIBUTES",
],
);
}

fn write_sys(filename: &str, apis: &[&str]) {
Expand Down
13 changes: 13 additions & 0 deletions crates/tests/standalone/src/b_constant_types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Bindings generated by `windows-bindgen` 0.49.0

#![allow(
non_snake_case,
non_upper_case_globals,
non_camel_case_types,
dead_code,
clippy::all
)]
pub const CMC_ADD_ATTRIBUTES: PCSTR = 63i32 as _;
pub const IDC_UPARROW: PCWSTR = 32516u16 as _;
pub type PCSTR = *const u8;
pub type PCWSTR = *const u16;
1 change: 1 addition & 0 deletions crates/tests/standalone/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod b_arch;
mod b_arch_dependencies;
mod b_bstr;
mod b_calendar;
mod b_constant_types;
mod b_depends;
mod b_enumeration;
mod b_enumerator;
Expand Down

0 comments on commit 21785db

Please sign in to comment.