Skip to content

Commit

Permalink
bindgen
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Aug 20, 2024
1 parent 1e662ff commit b49a9d5
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions crates/libs/bindgen/src/rust/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,32 @@ fn gen_conversions(
cfg: &cfg::Cfg,
) -> TokenStream {
let features = writer.cfg_features(cfg);
let mut tokens = quote! {
#features
windows_core::imp::interface_hierarchy!(#ident, windows_core::IUnknown, windows_core::IInspectable);

let mut tokens = if let Some(default) = interfaces.iter().find(|interface| {
!type_is_exclusive(&interface.ty) && interface.kind == metadata::InterfaceKind::Default
}) {
let default = writer.type_name(&default.ty);
quote! {
#features
windows_core::imp::interface_hierarchy!(#ident, windows_core::IUnknown, windows_core::IInspectable, #default);
}
} else {
quote! {
#features
windows_core::imp::interface_hierarchy!(#ident, windows_core::IUnknown, windows_core::IInspectable);
}
};

let mut hierarchy = format!("windows_core::imp::required_hierarchy!({ident}");
let mut hierarchy_cfg = cfg.clone();
let mut hierarchy_added = false;

for interface in interfaces {
if type_is_exclusive(&interface.ty) {
if type_is_exclusive(&interface.ty) || interface.kind == metadata::InterfaceKind::Default {
continue;
}

if interface.kind != metadata::InterfaceKind::Default
&& interface.kind != metadata::InterfaceKind::None
if interface.kind != metadata::InterfaceKind::None
&& interface.kind != metadata::InterfaceKind::Base
{
continue;
Expand Down

0 comments on commit b49a9d5

Please sign in to comment.