Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Feb 3, 2025
1 parent e078dd8 commit 02eb56b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions crates/libs/bindgen/src/winmd/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,8 @@ flags!(TypeAttributes, u32);
impl TypeAttributes {
pub const ExplicitLayout: Self = Self(0x10);
pub const WindowsRuntime: Self = Self(0x4000);

pub fn is_nested(&self) -> bool {
(self.0 & 0x00000006) != 0
}
}
6 changes: 4 additions & 2 deletions crates/libs/bindgen/src/winmd/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ impl Reader {
}

for def in file.table::<TypeDef>() {
if def.nested().is_some() {
let flags = def.flags();

if flags.is_nested() || def.nested().is_some() {
// This skips the nested types as we've already retrieved them.
continue;
}
Expand All @@ -43,7 +45,7 @@ impl Reader {
let types = reader.0.entry(type_name.namespace()).or_default();
let category = Category::new(def);

if def.flags().contains(TypeAttributes::WindowsRuntime) {
if flags.contains(TypeAttributes::WindowsRuntime) {
let ty = match category {
Category::Attribute => continue,
Category::Class => Type::Class(Class { def }),
Expand Down

0 comments on commit 02eb56b

Please sign in to comment.