Skip to content

Commit

Permalink
Fix standalone generation of individual enumerators (#2434)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Apr 7, 2023
1 parent 59f7bdc commit 81b7b8c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/libs/bindgen/src/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn standalone(names: &[&str]) -> String {

let mut type_names = BTreeSet::new();
let mut core_types = BTreeSet::new();
let mut enums = BTreeMap::new();
let mut enums = BTreeSet::new();

for name in names {
let type_name = TypeName::parse(name);
Expand Down Expand Up @@ -95,7 +95,7 @@ pub fn standalone(names: &[&str]) -> String {
found = true;
let enum_name = gen.reader.type_def_type_name(def);
type_names.insert(enum_name);
enums.insert(enum_name, type_name.name);
enums.insert((enum_name, type_name.name));
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion crates/tests/standalone/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ fn main() {

write(
"src/b_enumerator.rs",
&["Windows.Win32.Foundation.WAIT_IO_COMPLETION"],
&[
"Windows.Win32.Foundation.WAIT_IO_COMPLETION",
"Windows.Win32.Foundation.WAIT_TIMEOUT",
],
);

write(
Expand Down
1 change: 1 addition & 0 deletions crates/tests/standalone/src/b_enumerator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
)]
pub type WIN32_ERROR = u32;
pub const WAIT_IO_COMPLETION: WIN32_ERROR = 192u32;
pub const WAIT_TIMEOUT: WIN32_ERROR = 258u32;
6 changes: 6 additions & 0 deletions crates/tests/standalone/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ fn unknown() {
}
}

#[test]
fn enumerator() {
assert_eq!(b_enumerator::WAIT_IO_COMPLETION, 192);
assert_eq!(b_enumerator::WAIT_TIMEOUT, 258);
}

#[test]
fn test() {
use b_test::*;
Expand Down

0 comments on commit 81b7b8c

Please sign in to comment.