This commit is contained in:
Ryan Levick 2019-09-19 14:31:13 +02:00
Родитель e045e2fc2e
Коммит 45a870e9b5
1 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -10,15 +10,16 @@ pub fn generate(trait_item: &ItemTrait) -> HelperTokenStream {
let vptr_ident = vptr::ident(&interface_ident.to_string());
let iid_ident = iid::ident(interface_ident);
let vtable_macro = vtable_macro::ident(&interface_ident);
let iid_check = quote! { com::_winapi::shared::guiddef::IsEqualGUID(riid, &Self::IID) };
let recursive_iid_check = if let Some(TypeParamBound::Trait(t)) = trait_item.supertraits.first()
{
let supertrait_ident = t.path.get_ident().unwrap();
quote!(com::_winapi::shared::guiddef::IsEqualGUID(riid, &Self::IID) | #supertrait_ident::is_iid_in_inheritance_chain(riid))
quote! { #iid_check || <dyn #supertrait_ident as com::ComInterface>::is_iid_in_inheritance_chain(riid) }
} else {
quote!(com::_winapi::shared::guiddef::IsEqualGUID(riid, &Self::IID))
iid_check
};
quote!(
quote! {
unsafe impl com::ComInterface for dyn #interface_ident {
type VTable = #vtable_ident;
type VPtr = #vptr_ident;
@ -34,5 +35,5 @@ pub fn generate(trait_item: &ItemTrait) -> HelperTokenStream {
#vtable_macro!(C, O)
}
}
)
}
}