Skip to content

Commit

Permalink
Fix generic class signature calculation (#2927)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Mar 12, 2024
1 parent 6f4a726 commit d9cc52e
Show file tree
Hide file tree
Showing 314 changed files with 19,193 additions and 3,372 deletions.
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/rust/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ fn gen_win_interface(writer: &Writer, def: metadata::TypeDef) -> TokenStream {
}
});

tokens.combine(&writer.interface_winrt_trait(def, generics, &ident, &constraints, &phantoms, &features));
tokens.combine(&writer.async_get(def, generics, &ident, &constraints, &phantoms, &features));
tokens.combine(&iterators::writer(writer, def, generics, &ident, &constraints, &phantoms, &cfg));
tokens.combine(&writer.agile(def, &ident, &constraints, &features));
}

tokens.combine(&writer.interface_winrt_trait(def, generics, &ident, &constraints, &phantoms, &features));
tokens.combine(&writer.interface_trait(def, generics, &ident, &constraints, &features, has_unknown_base));
tokens.combine(&writer.interface_vtbl(def, generics, &constraints, &features));
tokens
Expand Down
4 changes: 3 additions & 1 deletion crates/libs/bindgen/src/rust/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,9 @@ impl Writer {
pub fn interface_winrt_trait(&self, def: metadata::TypeDef, generics: &[metadata::Type], ident: &TokenStream, constraints: &TokenStream, _phantoms: &TokenStream, features: &TokenStream) -> TokenStream {
if def.flags().contains(metadata::TypeAttributes::WindowsRuntime) {
let type_signature = if def.kind() == metadata::TypeKind::Class {
quote! { windows_core::imp::ConstBuffer::for_class::<Self>() }
let default = metadata::type_def_default_interface(def).expect("missing default interface");
let default_name = self.type_name(&default);
quote! { windows_core::imp::ConstBuffer::for_class::<Self, #default_name>() }
} else if generics.is_empty() {
quote! { windows_core::imp::ConstBuffer::for_interface::<Self>() }
} else {
Expand Down
3 changes: 3 additions & 0 deletions crates/libs/core/src/imp/com_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ pub struct IPropertyValue_Vtbl {
pub GetRectArray: unsafe extern "system" fn(*mut core::ffi::c_void, *mut u32, *mut *mut Rect) -> windows_core::HRESULT,
}
windows_core::imp::define_interface!(IPropertyValueStatics, IPropertyValueStatics_Vtbl, 0x629bdbc8_d932_4ff4_96b9_8d96c5c1e858);
impl windows_core::RuntimeType for IPropertyValueStatics {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IPropertyValueStatics_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
Expand Down
4 changes: 2 additions & 2 deletions crates/libs/core/src/imp/sha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ pub struct ConstBuffer {
}

impl ConstBuffer {
pub const fn for_class<T: crate::RuntimeName + crate::Interface>() -> Self {
Self::new().push_slice(b"rc(").push_slice(T::NAME.as_bytes()).push(b';').push_guid(&T::IID).push(b')')
pub const fn for_class<C: crate::RuntimeName, I: crate::RuntimeType>() -> Self {
Self::new().push_slice(b"rc(").push_slice(C::NAME.as_bytes()).push(b';').push_other(I::SIGNATURE).push(b')')
}

pub const fn for_interface<T: crate::Interface>() -> Self {
Expand Down
228 changes: 204 additions & 24 deletions crates/libs/windows/src/Windows/AI/MachineLearning/mod.rs

Large diffs are not rendered by default.

107 changes: 58 additions & 49 deletions crates/libs/windows/src/Windows/ApplicationModel/Activation/mod.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
windows_core::imp::define_interface!(IAppExtension, IAppExtension_Vtbl, 0x8450902c_15ed_4faf_93ea_2237bbf8cbd6);
impl windows_core::RuntimeType for IAppExtension {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IAppExtension_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
Expand All @@ -17,12 +20,18 @@ pub struct IAppExtension_Vtbl {
GetPublicFolderAsync: usize,
}
windows_core::imp::define_interface!(IAppExtension2, IAppExtension2_Vtbl, 0xab3b15f0_14f9_4b9f_9419_a349a242ef38);
impl windows_core::RuntimeType for IAppExtension2 {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IAppExtension2_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
pub AppUserModelId: unsafe extern "system" fn(*mut core::ffi::c_void, *mut std::mem::MaybeUninit<windows_core::HSTRING>) -> windows_core::HRESULT,
}
windows_core::imp::define_interface!(IAppExtensionCatalog, IAppExtensionCatalog_Vtbl, 0x97872032_8426_4ad1_9084_92e88c2da200);
impl windows_core::RuntimeType for IAppExtensionCatalog {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IAppExtensionCatalog_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
Expand All @@ -43,12 +52,18 @@ pub struct IAppExtensionCatalog_Vtbl {
pub RemovePackageStatusChanged: unsafe extern "system" fn(*mut core::ffi::c_void, super::super::Foundation::EventRegistrationToken) -> windows_core::HRESULT,
}
windows_core::imp::define_interface!(IAppExtensionCatalogStatics, IAppExtensionCatalogStatics_Vtbl, 0x3c36668a_5f18_4f0b_9ce5_cab61d196f11);
impl windows_core::RuntimeType for IAppExtensionCatalogStatics {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IAppExtensionCatalogStatics_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
pub Open: unsafe extern "system" fn(*mut core::ffi::c_void, std::mem::MaybeUninit<windows_core::HSTRING>, *mut *mut core::ffi::c_void) -> windows_core::HRESULT,
}
windows_core::imp::define_interface!(IAppExtensionPackageInstalledEventArgs, IAppExtensionPackageInstalledEventArgs_Vtbl, 0x39e59234_3351_4a8d_9745_e7d3dd45bc48);
impl windows_core::RuntimeType for IAppExtensionPackageInstalledEventArgs {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IAppExtensionPackageInstalledEventArgs_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
Expand All @@ -60,20 +75,29 @@ pub struct IAppExtensionPackageInstalledEventArgs_Vtbl {
Extensions: usize,
}
windows_core::imp::define_interface!(IAppExtensionPackageStatusChangedEventArgs, IAppExtensionPackageStatusChangedEventArgs_Vtbl, 0x1ce17433_1153_44fd_87b1_8ae1050303df);
impl windows_core::RuntimeType for IAppExtensionPackageStatusChangedEventArgs {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IAppExtensionPackageStatusChangedEventArgs_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
pub AppExtensionName: unsafe extern "system" fn(*mut core::ffi::c_void, *mut std::mem::MaybeUninit<windows_core::HSTRING>) -> windows_core::HRESULT,
pub Package: unsafe extern "system" fn(*mut core::ffi::c_void, *mut *mut core::ffi::c_void) -> windows_core::HRESULT,
}
windows_core::imp::define_interface!(IAppExtensionPackageUninstallingEventArgs, IAppExtensionPackageUninstallingEventArgs_Vtbl, 0x60f160c5_171e_40ff_ae98_ab2c20dd4d75);
impl windows_core::RuntimeType for IAppExtensionPackageUninstallingEventArgs {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IAppExtensionPackageUninstallingEventArgs_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
pub AppExtensionName: unsafe extern "system" fn(*mut core::ffi::c_void, *mut std::mem::MaybeUninit<windows_core::HSTRING>) -> windows_core::HRESULT,
pub Package: unsafe extern "system" fn(*mut core::ffi::c_void, *mut *mut core::ffi::c_void) -> windows_core::HRESULT,
}
windows_core::imp::define_interface!(IAppExtensionPackageUpdatedEventArgs, IAppExtensionPackageUpdatedEventArgs_Vtbl, 0x3a83c43f_797e_44b5_ba24_a4c8b5a543d7);
impl windows_core::RuntimeType for IAppExtensionPackageUpdatedEventArgs {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IAppExtensionPackageUpdatedEventArgs_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
Expand All @@ -85,6 +109,9 @@ pub struct IAppExtensionPackageUpdatedEventArgs_Vtbl {
Extensions: usize,
}
windows_core::imp::define_interface!(IAppExtensionPackageUpdatingEventArgs, IAppExtensionPackageUpdatingEventArgs_Vtbl, 0x7ed59329_1a65_4800_a700_b321009e306a);
impl windows_core::RuntimeType for IAppExtensionPackageUpdatingEventArgs {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IAppExtensionPackageUpdatingEventArgs_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
Expand Down Expand Up @@ -156,7 +183,7 @@ impl AppExtension {
}
}
impl windows_core::RuntimeType for AppExtension {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self>();
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self, IAppExtension>();
}
unsafe impl windows_core::Interface for AppExtension {
type Vtable = IAppExtension_Vtbl;
Expand Down Expand Up @@ -270,7 +297,7 @@ impl AppExtensionCatalog {
}
}
impl windows_core::RuntimeType for AppExtensionCatalog {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self>();
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self, IAppExtensionCatalog>();
}
unsafe impl windows_core::Interface for AppExtensionCatalog {
type Vtable = IAppExtensionCatalog_Vtbl;
Expand Down Expand Up @@ -308,7 +335,7 @@ impl AppExtensionPackageInstalledEventArgs {
}
}
impl windows_core::RuntimeType for AppExtensionPackageInstalledEventArgs {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self>();
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self, IAppExtensionPackageInstalledEventArgs>();
}
unsafe impl windows_core::Interface for AppExtensionPackageInstalledEventArgs {
type Vtable = IAppExtensionPackageInstalledEventArgs_Vtbl;
Expand Down Expand Up @@ -340,7 +367,7 @@ impl AppExtensionPackageStatusChangedEventArgs {
}
}
impl windows_core::RuntimeType for AppExtensionPackageStatusChangedEventArgs {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self>();
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self, IAppExtensionPackageStatusChangedEventArgs>();
}
unsafe impl windows_core::Interface for AppExtensionPackageStatusChangedEventArgs {
type Vtable = IAppExtensionPackageStatusChangedEventArgs_Vtbl;
Expand Down Expand Up @@ -372,7 +399,7 @@ impl AppExtensionPackageUninstallingEventArgs {
}
}
impl windows_core::RuntimeType for AppExtensionPackageUninstallingEventArgs {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self>();
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self, IAppExtensionPackageUninstallingEventArgs>();
}
unsafe impl windows_core::Interface for AppExtensionPackageUninstallingEventArgs {
type Vtable = IAppExtensionPackageUninstallingEventArgs_Vtbl;
Expand Down Expand Up @@ -412,7 +439,7 @@ impl AppExtensionPackageUpdatedEventArgs {
}
}
impl windows_core::RuntimeType for AppExtensionPackageUpdatedEventArgs {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self>();
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self, IAppExtensionPackageUpdatedEventArgs>();
}
unsafe impl windows_core::Interface for AppExtensionPackageUpdatedEventArgs {
type Vtable = IAppExtensionPackageUpdatedEventArgs_Vtbl;
Expand Down Expand Up @@ -444,7 +471,7 @@ impl AppExtensionPackageUpdatingEventArgs {
}
}
impl windows_core::RuntimeType for AppExtensionPackageUpdatingEventArgs {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self>();
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_class::<Self, IAppExtensionPackageUpdatingEventArgs>();
}
unsafe impl windows_core::Interface for AppExtensionPackageUpdatingEventArgs {
type Vtable = IAppExtensionPackageUpdatingEventArgs_Vtbl;
Expand Down
Loading

0 comments on commit d9cc52e

Please sign in to comment.