diff --git a/crates/samples/components/json_validator_winrt/src/bindings.rs b/crates/samples/components/json_validator_winrt/src/bindings.rs index c9c9457c41..8b78210a8f 100644 --- a/crates/samples/components/json_validator_winrt/src/bindings.rs +++ b/crates/samples/components/json_validator_winrt/src/bindings.rs @@ -8,6 +8,62 @@ clippy::all )] +#[repr(transparent)] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct JsonValidator(windows_core::IUnknown); +windows_core::imp::interface_hierarchy!( + JsonValidator, + windows_core::IUnknown, + windows_core::IInspectable +); +impl JsonValidator { + pub fn Validate( + &self, + value: &windows_core::HSTRING, + ) -> windows_core::Result { + let this = self; + unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).Validate)( + windows_core::Interface::as_raw(this), + core::mem::transmute_copy(value), + &mut result__, + ) + .map(|| core::mem::transmute(result__)) + } + } + pub fn CreateInstance(schema: &windows_core::HSTRING) -> windows_core::Result { + Self::IJsonValidatorFactory(|this| unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).CreateInstance)( + windows_core::Interface::as_raw(this), + core::mem::transmute_copy(schema), + &mut result__, + ) + .and_then(|| windows_core::Type::from_abi(result__)) + }) + } + fn IJsonValidatorFactory windows_core::Result>( + callback: F, + ) -> windows_core::Result { + static SHARED: windows_core::imp::FactoryCache = + windows_core::imp::FactoryCache::new(); + SHARED.call(callback) + } +} +impl windows_core::RuntimeType for JsonValidator { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_class::(); +} +unsafe impl windows_core::Interface for JsonValidator { + type Vtable = ::Vtable; + const IID: windows_core::GUID = ::IID; +} +impl windows_core::RuntimeName for JsonValidator { + const NAME: &'static str = "Sample.JsonValidator"; +} +unsafe impl Send for JsonValidator {} +unsafe impl Sync for JsonValidator {} windows_core::imp::define_interface!( IJsonValidator, IJsonValidator_Vtbl, @@ -116,59 +172,3 @@ pub struct IJsonValidatorFactory_Vtbl { *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT, } -#[repr(transparent)] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct JsonValidator(windows_core::IUnknown); -windows_core::imp::interface_hierarchy!( - JsonValidator, - windows_core::IUnknown, - windows_core::IInspectable -); -impl JsonValidator { - pub fn Validate( - &self, - value: &windows_core::HSTRING, - ) -> windows_core::Result { - let this = self; - unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).Validate)( - windows_core::Interface::as_raw(this), - core::mem::transmute_copy(value), - &mut result__, - ) - .map(|| core::mem::transmute(result__)) - } - } - pub fn CreateInstance(schema: &windows_core::HSTRING) -> windows_core::Result { - Self::IJsonValidatorFactory(|this| unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).CreateInstance)( - windows_core::Interface::as_raw(this), - core::mem::transmute_copy(schema), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - }) - } - fn IJsonValidatorFactory windows_core::Result>( - callback: F, - ) -> windows_core::Result { - static SHARED: windows_core::imp::FactoryCache = - windows_core::imp::FactoryCache::new(); - SHARED.call(callback) - } -} -impl windows_core::RuntimeType for JsonValidator { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_class::(); -} -unsafe impl windows_core::Interface for JsonValidator { - type Vtable = ::Vtable; - const IID: windows_core::GUID = ::IID; -} -impl windows_core::RuntimeName for JsonValidator { - const NAME: &'static str = "Sample.JsonValidator"; -} -unsafe impl Send for JsonValidator {} -unsafe impl Sync for JsonValidator {} diff --git a/crates/samples/components/json_validator_winrt_client/src/bindings.rs b/crates/samples/components/json_validator_winrt_client/src/bindings.rs index 35f0bac3b7..96829f9d38 100644 --- a/crates/samples/components/json_validator_winrt_client/src/bindings.rs +++ b/crates/samples/components/json_validator_winrt_client/src/bindings.rs @@ -8,42 +8,6 @@ clippy::all )] -windows_core::imp::define_interface!( - IJsonValidator, - IJsonValidator_Vtbl, - 0xe09cb12b_b13c_5139_8c99_6140bf80deb9 -); -impl windows_core::RuntimeType for IJsonValidator { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -#[repr(C)] -pub struct IJsonValidator_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, - pub Validate: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, -} -windows_core::imp::define_interface!( - IJsonValidatorFactory, - IJsonValidatorFactory_Vtbl, - 0x1cf4464e_ae9e_55d5_9539_0af4d8fc35aa -); -impl windows_core::RuntimeType for IJsonValidatorFactory { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -#[repr(C)] -pub struct IJsonValidatorFactory_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, - pub CreateInstance: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, -} #[repr(transparent)] #[derive(Clone, Debug, Eq, PartialEq)] pub struct JsonValidator(windows_core::IUnknown); @@ -100,3 +64,39 @@ impl windows_core::RuntimeName for JsonValidator { } unsafe impl Send for JsonValidator {} unsafe impl Sync for JsonValidator {} +windows_core::imp::define_interface!( + IJsonValidator, + IJsonValidator_Vtbl, + 0xe09cb12b_b13c_5139_8c99_6140bf80deb9 +); +impl windows_core::RuntimeType for IJsonValidator { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +#[repr(C)] +pub struct IJsonValidator_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, + pub Validate: unsafe extern "system" fn( + *mut core::ffi::c_void, + *mut core::ffi::c_void, + *mut *mut core::ffi::c_void, + ) -> windows_core::HRESULT, +} +windows_core::imp::define_interface!( + IJsonValidatorFactory, + IJsonValidatorFactory_Vtbl, + 0x1cf4464e_ae9e_55d5_9539_0af4d8fc35aa +); +impl windows_core::RuntimeType for IJsonValidatorFactory { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +#[repr(C)] +pub struct IJsonValidatorFactory_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, + pub CreateInstance: unsafe extern "system" fn( + *mut core::ffi::c_void, + *mut core::ffi::c_void, + *mut *mut core::ffi::c_void, + ) -> windows_core::HRESULT, +} diff --git a/crates/tests/misc/component/src/bindings.rs b/crates/tests/misc/component/src/bindings.rs index 0508e190f1..cd13066d34 100644 --- a/crates/tests/misc/component/src/bindings.rs +++ b/crates/tests/misc/component/src/bindings.rs @@ -6,6 +6,137 @@ clippy::all )] +#[repr(transparent)] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Class(windows_core::IUnknown); +windows_core::imp::interface_hierarchy!(Class, windows_core::IUnknown, windows_core::IInspectable); +impl Class { + pub fn new() -> windows_core::Result { + Self::IActivationFactory(|f| f.ActivateInstance::()) + } + fn IActivationFactory< + R, + F: FnOnce(&windows_core::imp::IGenericFactory) -> windows_core::Result, + >( + callback: F, + ) -> windows_core::Result { + static SHARED: windows_core::imp::FactoryCache = + windows_core::imp::FactoryCache::new(); + SHARED.call(callback) + } + pub fn Property(&self) -> windows_core::Result { + let this = self; + unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).Property)( + windows_core::Interface::as_raw(this), + &mut result__, + ) + .map(|| result__) + } + } + pub fn SetProperty(&self, value: i32) -> windows_core::Result<()> { + let this = self; + unsafe { + (windows_core::Interface::vtable(this).SetProperty)( + windows_core::Interface::as_raw(this), + value, + ) + .ok() + } + } + pub fn Flags(&self) -> windows_core::Result { + let this = self; + unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).Flags)( + windows_core::Interface::as_raw(this), + &mut result__, + ) + .map(|| result__) + } + } + pub fn Int32Array( + &self, + a: &[i32], + b: &mut [i32], + c: &mut windows_core::Array, + ) -> windows_core::Result> { + let this = self; + unsafe { + let mut result__ = core::mem::MaybeUninit::zeroed(); + (windows_core::Interface::vtable(this).Int32Array)( + windows_core::Interface::as_raw(this), + a.len().try_into().unwrap(), + a.as_ptr(), + b.len().try_into().unwrap(), + b.as_mut_ptr(), + c.set_abi_len(), + c as *mut _ as _, + windows_core::Array::::set_abi_len(core::mem::transmute(&mut result__)), + result__.as_mut_ptr() as *mut _ as _, + ) + .map(|| result__.assume_init()) + } + } + pub fn StringArray( + &self, + a: &[windows_core::HSTRING], + b: &mut [windows_core::HSTRING], + c: &mut windows_core::Array, + ) -> windows_core::Result> { + let this = self; + unsafe { + let mut result__ = core::mem::MaybeUninit::zeroed(); + (windows_core::Interface::vtable(this).StringArray)( + windows_core::Interface::as_raw(this), + a.len().try_into().unwrap(), + core::mem::transmute(a.as_ptr()), + b.len().try_into().unwrap(), + core::mem::transmute_copy(&b), + c.set_abi_len(), + c as *mut _ as _, + windows_core::Array::::set_abi_len(core::mem::transmute( + &mut result__, + )), + result__.as_mut_ptr() as *mut _ as _, + ) + .map(|| result__.assume_init()) + } + } + pub fn Input(&self, a: P0, b: P1, c: P2, d: P3) -> windows_core::Result<()> + where + P0: windows_core::Param, + P1: windows_core::Param, + P2: windows_core::Param, + P3: windows_core::Param, + { + let this = self; + unsafe { + (windows_core::Interface::vtable(this).Input)( + windows_core::Interface::as_raw(this), + a.param().abi(), + b.param().abi(), + c.param().abi(), + d.param().abi(), + ) + .ok() + } + } +} +impl windows_core::RuntimeType for Class { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_class::(); +} +unsafe impl windows_core::Interface for Class { + type Vtable = ::Vtable; + const IID: windows_core::GUID = ::IID; +} +impl windows_core::RuntimeName for Class { + const NAME: &'static str = "test_component.Class"; +} +unsafe impl Send for Class {} +unsafe impl Sync for Class {} windows_core::imp::define_interface!(IClass, IClass_Vtbl, 0x97540591_1323_59c0_9ae0_f510cae62e54); impl windows_core::RuntimeType for IClass { const SIGNATURE: windows_core::imp::ConstBuffer = @@ -254,137 +385,6 @@ pub struct IThing_Vtbl { pub base__: windows_core::IInspectable_Vtbl, pub Method: unsafe extern "system" fn(*mut core::ffi::c_void) -> windows_core::HRESULT, } -#[repr(transparent)] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct Class(windows_core::IUnknown); -windows_core::imp::interface_hierarchy!(Class, windows_core::IUnknown, windows_core::IInspectable); -impl Class { - pub fn new() -> windows_core::Result { - Self::IActivationFactory(|f| f.ActivateInstance::()) - } - fn IActivationFactory< - R, - F: FnOnce(&windows_core::imp::IGenericFactory) -> windows_core::Result, - >( - callback: F, - ) -> windows_core::Result { - static SHARED: windows_core::imp::FactoryCache = - windows_core::imp::FactoryCache::new(); - SHARED.call(callback) - } - pub fn Property(&self) -> windows_core::Result { - let this = self; - unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).Property)( - windows_core::Interface::as_raw(this), - &mut result__, - ) - .map(|| result__) - } - } - pub fn SetProperty(&self, value: i32) -> windows_core::Result<()> { - let this = self; - unsafe { - (windows_core::Interface::vtable(this).SetProperty)( - windows_core::Interface::as_raw(this), - value, - ) - .ok() - } - } - pub fn Flags(&self) -> windows_core::Result { - let this = self; - unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).Flags)( - windows_core::Interface::as_raw(this), - &mut result__, - ) - .map(|| result__) - } - } - pub fn Int32Array( - &self, - a: &[i32], - b: &mut [i32], - c: &mut windows_core::Array, - ) -> windows_core::Result> { - let this = self; - unsafe { - let mut result__ = core::mem::MaybeUninit::zeroed(); - (windows_core::Interface::vtable(this).Int32Array)( - windows_core::Interface::as_raw(this), - a.len().try_into().unwrap(), - a.as_ptr(), - b.len().try_into().unwrap(), - b.as_mut_ptr(), - c.set_abi_len(), - c as *mut _ as _, - windows_core::Array::::set_abi_len(core::mem::transmute(&mut result__)), - result__.as_mut_ptr() as *mut _ as _, - ) - .map(|| result__.assume_init()) - } - } - pub fn StringArray( - &self, - a: &[windows_core::HSTRING], - b: &mut [windows_core::HSTRING], - c: &mut windows_core::Array, - ) -> windows_core::Result> { - let this = self; - unsafe { - let mut result__ = core::mem::MaybeUninit::zeroed(); - (windows_core::Interface::vtable(this).StringArray)( - windows_core::Interface::as_raw(this), - a.len().try_into().unwrap(), - core::mem::transmute(a.as_ptr()), - b.len().try_into().unwrap(), - core::mem::transmute_copy(&b), - c.set_abi_len(), - c as *mut _ as _, - windows_core::Array::::set_abi_len(core::mem::transmute( - &mut result__, - )), - result__.as_mut_ptr() as *mut _ as _, - ) - .map(|| result__.assume_init()) - } - } - pub fn Input(&self, a: P0, b: P1, c: P2, d: P3) -> windows_core::Result<()> - where - P0: windows_core::Param, - P1: windows_core::Param, - P2: windows_core::Param, - P3: windows_core::Param, - { - let this = self; - unsafe { - (windows_core::Interface::vtable(this).Input)( - windows_core::Interface::as_raw(this), - a.param().abi(), - b.param().abi(), - c.param().abi(), - d.param().abi(), - ) - .ok() - } - } -} -impl windows_core::RuntimeType for Class { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_class::(); -} -unsafe impl windows_core::Interface for Class { - type Vtable = ::Vtable; - const IID: windows_core::GUID = ::IID; -} -impl windows_core::RuntimeName for Class { - const NAME: &'static str = "test_component.Class"; -} -unsafe impl Send for Class {} -unsafe impl Sync for Class {} windows_core::imp::define_interface!( Callback, Callback_Vtbl, diff --git a/crates/tests/misc/component_client/src/bindings.rs b/crates/tests/misc/component_client/src/bindings.rs index 4c959b8542..69665b96d4 100644 --- a/crates/tests/misc/component_client/src/bindings.rs +++ b/crates/tests/misc/component_client/src/bindings.rs @@ -6,93 +6,6 @@ clippy::all )] -windows_core::imp::define_interface!(IClass, IClass_Vtbl, 0x97540591_1323_59c0_9ae0_f510cae62e54); -impl windows_core::RuntimeType for IClass { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -#[repr(C)] -pub struct IClass_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, - pub Property: - unsafe extern "system" fn(*mut core::ffi::c_void, *mut i32) -> windows_core::HRESULT, - pub SetProperty: - unsafe extern "system" fn(*mut core::ffi::c_void, i32) -> windows_core::HRESULT, - pub Flags: - unsafe extern "system" fn(*mut core::ffi::c_void, *mut Flags) -> windows_core::HRESULT, - pub Int32Array: unsafe extern "system" fn( - *mut core::ffi::c_void, - u32, - *const i32, - u32, - *mut i32, - *mut u32, - *mut *mut i32, - *mut u32, - *mut *mut i32, - ) -> windows_core::HRESULT, - pub StringArray: unsafe extern "system" fn( - *mut core::ffi::c_void, - u32, - *const windows_core::HSTRING, - u32, - *mut windows_core::HSTRING, - *mut u32, - *mut *mut windows_core::HSTRING, - *mut u32, - *mut *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub Input: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - *mut core::ffi::c_void, - *mut core::ffi::c_void, - *mut core::ffi::c_void, - ) -> windows_core::HRESULT, -} -windows_core::imp::define_interface!(IThing, IThing_Vtbl, 0x5448be22_9873_5ae6_9106_f6e8455d2fdd); -impl windows_core::RuntimeType for IThing { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -windows_core::imp::interface_hierarchy!(IThing, windows_core::IUnknown, windows_core::IInspectable); -impl IThing { - pub fn Method(&self) -> windows_core::Result<()> { - let this = self; - unsafe { - (windows_core::Interface::vtable(this).Method)(windows_core::Interface::as_raw(this)) - .ok() - } - } -} -impl windows_core::RuntimeName for IThing { - const NAME: &'static str = "test_component.Nested.IThing"; -} -pub trait IThing_Impl: windows_core::IUnknownImpl { - fn Method(&self) -> windows_core::Result<()>; -} -impl IThing_Vtbl { - pub const fn new() -> Self { - unsafe extern "system" fn Method( - this: *mut core::ffi::c_void, - ) -> windows_core::HRESULT { - let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); - IThing_Impl::Method(this).into() - } - Self { - base__: windows_core::IInspectable_Vtbl::new::(), - Method: Method::, - } - } - pub fn matches(iid: &windows_core::GUID) -> bool { - iid == &::IID - } -} -#[repr(C)] -pub struct IThing_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, - pub Method: unsafe extern "system" fn(*mut core::ffi::c_void) -> windows_core::HRESULT, -} #[repr(transparent)] #[derive(Clone, Debug, Eq, PartialEq)] pub struct Class(windows_core::IUnknown); @@ -224,6 +137,93 @@ impl windows_core::RuntimeName for Class { } unsafe impl Send for Class {} unsafe impl Sync for Class {} +windows_core::imp::define_interface!(IClass, IClass_Vtbl, 0x97540591_1323_59c0_9ae0_f510cae62e54); +impl windows_core::RuntimeType for IClass { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +#[repr(C)] +pub struct IClass_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, + pub Property: + unsafe extern "system" fn(*mut core::ffi::c_void, *mut i32) -> windows_core::HRESULT, + pub SetProperty: + unsafe extern "system" fn(*mut core::ffi::c_void, i32) -> windows_core::HRESULT, + pub Flags: + unsafe extern "system" fn(*mut core::ffi::c_void, *mut Flags) -> windows_core::HRESULT, + pub Int32Array: unsafe extern "system" fn( + *mut core::ffi::c_void, + u32, + *const i32, + u32, + *mut i32, + *mut u32, + *mut *mut i32, + *mut u32, + *mut *mut i32, + ) -> windows_core::HRESULT, + pub StringArray: unsafe extern "system" fn( + *mut core::ffi::c_void, + u32, + *const windows_core::HSTRING, + u32, + *mut windows_core::HSTRING, + *mut u32, + *mut *mut windows_core::HSTRING, + *mut u32, + *mut *mut *mut core::ffi::c_void, + ) -> windows_core::HRESULT, + pub Input: unsafe extern "system" fn( + *mut core::ffi::c_void, + *mut core::ffi::c_void, + *mut core::ffi::c_void, + *mut core::ffi::c_void, + *mut core::ffi::c_void, + ) -> windows_core::HRESULT, +} +windows_core::imp::define_interface!(IThing, IThing_Vtbl, 0x5448be22_9873_5ae6_9106_f6e8455d2fdd); +impl windows_core::RuntimeType for IThing { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +windows_core::imp::interface_hierarchy!(IThing, windows_core::IUnknown, windows_core::IInspectable); +impl IThing { + pub fn Method(&self) -> windows_core::Result<()> { + let this = self; + unsafe { + (windows_core::Interface::vtable(this).Method)(windows_core::Interface::as_raw(this)) + .ok() + } + } +} +impl windows_core::RuntimeName for IThing { + const NAME: &'static str = "test_component.Nested.IThing"; +} +pub trait IThing_Impl: windows_core::IUnknownImpl { + fn Method(&self) -> windows_core::Result<()>; +} +impl IThing_Vtbl { + pub const fn new() -> Self { + unsafe extern "system" fn Method( + this: *mut core::ffi::c_void, + ) -> windows_core::HRESULT { + let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity); + IThing_Impl::Method(this).into() + } + Self { + base__: windows_core::IInspectable_Vtbl::new::(), + Method: Method::, + } + } + pub fn matches(iid: &windows_core::GUID) -> bool { + iid == &::IID + } +} +#[repr(C)] +pub struct IThing_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, + pub Method: unsafe extern "system" fn(*mut core::ffi::c_void) -> windows_core::HRESULT, +} windows_core::imp::define_interface!( Callback, Callback_Vtbl, diff --git a/crates/tests/winrt/composable/src/bindings.rs b/crates/tests/winrt/composable/src/bindings.rs index 325f31a069..78a27a0721 100644 --- a/crates/tests/winrt/composable/src/bindings.rs +++ b/crates/tests/winrt/composable/src/bindings.rs @@ -6,6 +6,204 @@ clippy::all )] +#[repr(transparent)] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct SpriteVisual(windows_core::IUnknown); +windows_core::imp::interface_hierarchy!( + SpriteVisual, + windows_core::IUnknown, + windows_core::IInspectable +); +windows_core::imp::required_hierarchy!(SpriteVisual, ContainerVisual, Visual); +impl SpriteVisual { + pub fn Children(&self) -> i32 { + let this = &windows_core::Interface::cast::(self).unwrap(); + unsafe { + let mut result__ = core::mem::zeroed(); + let hresult__ = (windows_core::Interface::vtable(this).Children)( + windows_core::Interface::as_raw(this), + &mut result__, + ); + debug_assert!(hresult__.0 == 0); + result__ + } + } + pub fn Brush(&self) -> i32 { + let this = self; + unsafe { + let mut result__ = core::mem::zeroed(); + let hresult__ = (windows_core::Interface::vtable(this).Brush)( + windows_core::Interface::as_raw(this), + &mut result__, + ); + debug_assert!(hresult__.0 == 0); + result__ + } + } + pub fn Compositor(&self) -> windows_core::Result { + let this = &windows_core::Interface::cast::(self)?; + unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).Compositor)( + windows_core::Interface::as_raw(this), + &mut result__, + ) + .and_then(|| windows_core::Type::from_abi(result__)) + } + } +} +impl windows_core::RuntimeType for SpriteVisual { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_class::(); +} +unsafe impl windows_core::Interface for SpriteVisual { + type Vtable = ::Vtable; + const IID: windows_core::GUID = ::IID; +} +impl windows_core::RuntimeName for SpriteVisual { + const NAME: &'static str = "test_composable.SpriteVisual"; +} +unsafe impl Send for SpriteVisual {} +unsafe impl Sync for SpriteVisual {} +#[repr(transparent)] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ContainerVisual(windows_core::IUnknown); +windows_core::imp::interface_hierarchy!( + ContainerVisual, + windows_core::IUnknown, + windows_core::IInspectable +); +windows_core::imp::required_hierarchy!(ContainerVisual, Visual); +impl ContainerVisual { + pub fn Children(&self) -> i32 { + let this = self; + unsafe { + let mut result__ = core::mem::zeroed(); + let hresult__ = (windows_core::Interface::vtable(this).Children)( + windows_core::Interface::as_raw(this), + &mut result__, + ); + debug_assert!(hresult__.0 == 0); + result__ + } + } + pub fn Compositor(&self) -> windows_core::Result { + let this = &windows_core::Interface::cast::(self)?; + unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).Compositor)( + windows_core::Interface::as_raw(this), + &mut result__, + ) + .and_then(|| windows_core::Type::from_abi(result__)) + } + } +} +impl windows_core::RuntimeType for ContainerVisual { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_class::(); +} +unsafe impl windows_core::Interface for ContainerVisual { + type Vtable = ::Vtable; + const IID: windows_core::GUID = ::IID; +} +impl windows_core::RuntimeName for ContainerVisual { + const NAME: &'static str = "test_composable.ContainerVisual"; +} +unsafe impl Send for ContainerVisual {} +unsafe impl Sync for ContainerVisual {} +#[repr(transparent)] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Compositor(windows_core::IUnknown); +windows_core::imp::interface_hierarchy!( + Compositor, + windows_core::IUnknown, + windows_core::IInspectable +); +impl Compositor { + pub fn new() -> windows_core::Result { + Self::IActivationFactory(|f| f.ActivateInstance::()) + } + fn IActivationFactory< + R, + F: FnOnce(&windows_core::imp::IGenericFactory) -> windows_core::Result, + >( + callback: F, + ) -> windows_core::Result { + static SHARED: windows_core::imp::FactoryCache< + Compositor, + windows_core::imp::IGenericFactory, + > = windows_core::imp::FactoryCache::new(); + SHARED.call(callback) + } + pub fn CreateSpriteVisual(&self, brush: i32) -> windows_core::Result { + let this = self; + unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).CreateSpriteVisual)( + windows_core::Interface::as_raw(this), + brush, + &mut result__, + ) + .and_then(|| windows_core::Type::from_abi(result__)) + } + } + pub fn CreateContainerVisual(&self, children: i32) -> windows_core::Result { + let this = self; + unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).CreateContainerVisual)( + windows_core::Interface::as_raw(this), + children, + &mut result__, + ) + .and_then(|| windows_core::Type::from_abi(result__)) + } + } +} +impl windows_core::RuntimeType for Compositor { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_class::(); +} +unsafe impl windows_core::Interface for Compositor { + type Vtable = ::Vtable; + const IID: windows_core::GUID = ::IID; +} +impl windows_core::RuntimeName for Compositor { + const NAME: &'static str = "test_composable.Compositor"; +} +unsafe impl Send for Compositor {} +unsafe impl Sync for Compositor {} +#[repr(transparent)] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Visual(windows_core::IUnknown); +windows_core::imp::interface_hierarchy!(Visual, windows_core::IUnknown, windows_core::IInspectable); +impl Visual { + pub fn Compositor(&self) -> windows_core::Result { + let this = self; + unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).Compositor)( + windows_core::Interface::as_raw(this), + &mut result__, + ) + .and_then(|| windows_core::Type::from_abi(result__)) + } + } +} +impl windows_core::RuntimeType for Visual { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_class::(); +} +unsafe impl windows_core::Interface for Visual { + type Vtable = ::Vtable; + const IID: windows_core::GUID = ::IID; +} +impl windows_core::RuntimeName for Visual { + const NAME: &'static str = "test_composable.Visual"; +} +unsafe impl Send for Visual {} +unsafe impl Sync for Visual {} windows_core::imp::define_interface!( ICompositor, ICompositor_Vtbl, @@ -268,201 +466,3 @@ impl IVisualFactory_Vtbl { pub struct IVisualFactory_Vtbl { pub base__: windows_core::IInspectable_Vtbl, } -#[repr(transparent)] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct SpriteVisual(windows_core::IUnknown); -windows_core::imp::interface_hierarchy!( - SpriteVisual, - windows_core::IUnknown, - windows_core::IInspectable -); -windows_core::imp::required_hierarchy!(SpriteVisual, ContainerVisual, Visual); -impl SpriteVisual { - pub fn Children(&self) -> i32 { - let this = &windows_core::Interface::cast::(self).unwrap(); - unsafe { - let mut result__ = core::mem::zeroed(); - let hresult__ = (windows_core::Interface::vtable(this).Children)( - windows_core::Interface::as_raw(this), - &mut result__, - ); - debug_assert!(hresult__.0 == 0); - result__ - } - } - pub fn Brush(&self) -> i32 { - let this = self; - unsafe { - let mut result__ = core::mem::zeroed(); - let hresult__ = (windows_core::Interface::vtable(this).Brush)( - windows_core::Interface::as_raw(this), - &mut result__, - ); - debug_assert!(hresult__.0 == 0); - result__ - } - } - pub fn Compositor(&self) -> windows_core::Result { - let this = &windows_core::Interface::cast::(self)?; - unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).Compositor)( - windows_core::Interface::as_raw(this), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - } -} -impl windows_core::RuntimeType for SpriteVisual { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_class::(); -} -unsafe impl windows_core::Interface for SpriteVisual { - type Vtable = ::Vtable; - const IID: windows_core::GUID = ::IID; -} -impl windows_core::RuntimeName for SpriteVisual { - const NAME: &'static str = "test_composable.SpriteVisual"; -} -unsafe impl Send for SpriteVisual {} -unsafe impl Sync for SpriteVisual {} -#[repr(transparent)] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct ContainerVisual(windows_core::IUnknown); -windows_core::imp::interface_hierarchy!( - ContainerVisual, - windows_core::IUnknown, - windows_core::IInspectable -); -windows_core::imp::required_hierarchy!(ContainerVisual, Visual); -impl ContainerVisual { - pub fn Children(&self) -> i32 { - let this = self; - unsafe { - let mut result__ = core::mem::zeroed(); - let hresult__ = (windows_core::Interface::vtable(this).Children)( - windows_core::Interface::as_raw(this), - &mut result__, - ); - debug_assert!(hresult__.0 == 0); - result__ - } - } - pub fn Compositor(&self) -> windows_core::Result { - let this = &windows_core::Interface::cast::(self)?; - unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).Compositor)( - windows_core::Interface::as_raw(this), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - } -} -impl windows_core::RuntimeType for ContainerVisual { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_class::(); -} -unsafe impl windows_core::Interface for ContainerVisual { - type Vtable = ::Vtable; - const IID: windows_core::GUID = ::IID; -} -impl windows_core::RuntimeName for ContainerVisual { - const NAME: &'static str = "test_composable.ContainerVisual"; -} -unsafe impl Send for ContainerVisual {} -unsafe impl Sync for ContainerVisual {} -#[repr(transparent)] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct Compositor(windows_core::IUnknown); -windows_core::imp::interface_hierarchy!( - Compositor, - windows_core::IUnknown, - windows_core::IInspectable -); -impl Compositor { - pub fn new() -> windows_core::Result { - Self::IActivationFactory(|f| f.ActivateInstance::()) - } - fn IActivationFactory< - R, - F: FnOnce(&windows_core::imp::IGenericFactory) -> windows_core::Result, - >( - callback: F, - ) -> windows_core::Result { - static SHARED: windows_core::imp::FactoryCache< - Compositor, - windows_core::imp::IGenericFactory, - > = windows_core::imp::FactoryCache::new(); - SHARED.call(callback) - } - pub fn CreateSpriteVisual(&self, brush: i32) -> windows_core::Result { - let this = self; - unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).CreateSpriteVisual)( - windows_core::Interface::as_raw(this), - brush, - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - } - pub fn CreateContainerVisual(&self, children: i32) -> windows_core::Result { - let this = self; - unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).CreateContainerVisual)( - windows_core::Interface::as_raw(this), - children, - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - } -} -impl windows_core::RuntimeType for Compositor { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_class::(); -} -unsafe impl windows_core::Interface for Compositor { - type Vtable = ::Vtable; - const IID: windows_core::GUID = ::IID; -} -impl windows_core::RuntimeName for Compositor { - const NAME: &'static str = "test_composable.Compositor"; -} -unsafe impl Send for Compositor {} -unsafe impl Sync for Compositor {} -#[repr(transparent)] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct Visual(windows_core::IUnknown); -windows_core::imp::interface_hierarchy!(Visual, windows_core::IUnknown, windows_core::IInspectable); -impl Visual { - pub fn Compositor(&self) -> windows_core::Result { - let this = self; - unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).Compositor)( - windows_core::Interface::as_raw(this), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - } - } -} -impl windows_core::RuntimeType for Visual { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_class::(); -} -unsafe impl windows_core::Interface for Visual { - type Vtable = ::Vtable; - const IID: windows_core::GUID = ::IID; -} -impl windows_core::RuntimeName for Visual { - const NAME: &'static str = "test_composable.Visual"; -} -unsafe impl Send for Visual {} -unsafe impl Sync for Visual {} diff --git a/crates/tests/winrt/composable_client/src/bindings.rs b/crates/tests/winrt/composable_client/src/bindings.rs index bdb27cc792..aa91d28ce3 100644 --- a/crates/tests/winrt/composable_client/src/bindings.rs +++ b/crates/tests/winrt/composable_client/src/bindings.rs @@ -6,101 +6,6 @@ clippy::all )] -windows_core::imp::define_interface!( - ICompositor, - ICompositor_Vtbl, - 0xac7b49b8_e092_52ad_8456_48696a5a258e -); -impl windows_core::RuntimeType for ICompositor { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -#[repr(C)] -pub struct ICompositor_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, - pub CreateSpriteVisual: unsafe extern "system" fn( - *mut core::ffi::c_void, - i32, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub CreateContainerVisual: unsafe extern "system" fn( - *mut core::ffi::c_void, - i32, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, -} -windows_core::imp::define_interface!( - IContainerVisual, - IContainerVisual_Vtbl, - 0xb8accc46_3ff7_5a24_8247_f5a52e1f5a8d -); -impl windows_core::RuntimeType for IContainerVisual { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -#[repr(C)] -pub struct IContainerVisual_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, - pub Children: - unsafe extern "system" fn(*mut core::ffi::c_void, *mut i32) -> windows_core::HRESULT, -} -windows_core::imp::define_interface!( - IContainerVisualFactory, - IContainerVisualFactory_Vtbl, - 0x558b6180_1a65_5f01_8be2_2cc0b2034c0e -); -impl windows_core::RuntimeType for IContainerVisualFactory { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -#[repr(C)] -pub struct IContainerVisualFactory_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, -} -windows_core::imp::define_interface!( - ISpriteVisual, - ISpriteVisual_Vtbl, - 0x25f23ebe_4cd3_5349_b16d_d88c4d852ea1 -); -impl windows_core::RuntimeType for ISpriteVisual { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -#[repr(C)] -pub struct ISpriteVisual_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, - pub Brush: unsafe extern "system" fn(*mut core::ffi::c_void, *mut i32) -> windows_core::HRESULT, -} -windows_core::imp::define_interface!( - IVisual, - IVisual_Vtbl, - 0xce89606a_5b03_5861_af26_9dced3aab7e6 -); -impl windows_core::RuntimeType for IVisual { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -#[repr(C)] -pub struct IVisual_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, - pub Compositor: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, -} -windows_core::imp::define_interface!( - IVisualFactory, - IVisualFactory_Vtbl, - 0x1974545d_259f_553c_8ea0_e505f897df81 -); -impl windows_core::RuntimeType for IVisualFactory { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -#[repr(C)] -pub struct IVisualFactory_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, -} #[repr(transparent)] #[derive(Clone, Debug, Eq, PartialEq)] pub struct SpriteVisual(windows_core::IUnknown); @@ -299,3 +204,98 @@ impl windows_core::RuntimeName for Visual { } unsafe impl Send for Visual {} unsafe impl Sync for Visual {} +windows_core::imp::define_interface!( + ICompositor, + ICompositor_Vtbl, + 0xac7b49b8_e092_52ad_8456_48696a5a258e +); +impl windows_core::RuntimeType for ICompositor { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +#[repr(C)] +pub struct ICompositor_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, + pub CreateSpriteVisual: unsafe extern "system" fn( + *mut core::ffi::c_void, + i32, + *mut *mut core::ffi::c_void, + ) -> windows_core::HRESULT, + pub CreateContainerVisual: unsafe extern "system" fn( + *mut core::ffi::c_void, + i32, + *mut *mut core::ffi::c_void, + ) -> windows_core::HRESULT, +} +windows_core::imp::define_interface!( + IContainerVisual, + IContainerVisual_Vtbl, + 0xb8accc46_3ff7_5a24_8247_f5a52e1f5a8d +); +impl windows_core::RuntimeType for IContainerVisual { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +#[repr(C)] +pub struct IContainerVisual_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, + pub Children: + unsafe extern "system" fn(*mut core::ffi::c_void, *mut i32) -> windows_core::HRESULT, +} +windows_core::imp::define_interface!( + IContainerVisualFactory, + IContainerVisualFactory_Vtbl, + 0x558b6180_1a65_5f01_8be2_2cc0b2034c0e +); +impl windows_core::RuntimeType for IContainerVisualFactory { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +#[repr(C)] +pub struct IContainerVisualFactory_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, +} +windows_core::imp::define_interface!( + ISpriteVisual, + ISpriteVisual_Vtbl, + 0x25f23ebe_4cd3_5349_b16d_d88c4d852ea1 +); +impl windows_core::RuntimeType for ISpriteVisual { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +#[repr(C)] +pub struct ISpriteVisual_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, + pub Brush: unsafe extern "system" fn(*mut core::ffi::c_void, *mut i32) -> windows_core::HRESULT, +} +windows_core::imp::define_interface!( + IVisual, + IVisual_Vtbl, + 0xce89606a_5b03_5861_af26_9dced3aab7e6 +); +impl windows_core::RuntimeType for IVisual { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +#[repr(C)] +pub struct IVisual_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, + pub Compositor: unsafe extern "system" fn( + *mut core::ffi::c_void, + *mut *mut core::ffi::c_void, + ) -> windows_core::HRESULT, +} +windows_core::imp::define_interface!( + IVisualFactory, + IVisualFactory_Vtbl, + 0x1974545d_259f_553c_8ea0_e505f897df81 +); +impl windows_core::RuntimeType for IVisualFactory { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +#[repr(C)] +pub struct IVisualFactory_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, +} diff --git a/crates/tests/winrt/constructors/src/bindings.rs b/crates/tests/winrt/constructors/src/bindings.rs index 079c1fdb63..9a559df2bb 100644 --- a/crates/tests/winrt/constructors/src/bindings.rs +++ b/crates/tests/winrt/constructors/src/bindings.rs @@ -6,6 +6,139 @@ clippy::all )] +#[repr(transparent)] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Activatable(windows_core::IUnknown); +windows_core::imp::interface_hierarchy!( + Activatable, + windows_core::IUnknown, + windows_core::IInspectable +); +impl Activatable { + pub fn new() -> windows_core::Result { + Self::IActivationFactory(|f| f.ActivateInstance::()) + } + fn IActivationFactory< + R, + F: FnOnce(&windows_core::imp::IGenericFactory) -> windows_core::Result, + >( + callback: F, + ) -> windows_core::Result { + static SHARED: windows_core::imp::FactoryCache< + Activatable, + windows_core::imp::IGenericFactory, + > = windows_core::imp::FactoryCache::new(); + SHARED.call(callback) + } + pub fn Property(&self) -> windows_core::Result { + let this = self; + unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).Property)( + windows_core::Interface::as_raw(this), + &mut result__, + ) + .map(|| result__) + } + } + pub fn WithValue(arg: i32) -> windows_core::Result { + Self::IActivatableFactory(|this| unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).WithValue)( + windows_core::Interface::as_raw(this), + arg, + &mut result__, + ) + .and_then(|| windows_core::Type::from_abi(result__)) + }) + } + fn IActivatableFactory windows_core::Result>( + callback: F, + ) -> windows_core::Result { + static SHARED: windows_core::imp::FactoryCache = + windows_core::imp::FactoryCache::new(); + SHARED.call(callback) + } +} +impl windows_core::RuntimeType for Activatable { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_class::(); +} +unsafe impl windows_core::Interface for Activatable { + type Vtable = ::Vtable; + const IID: windows_core::GUID = ::IID; +} +impl windows_core::RuntimeName for Activatable { + const NAME: &'static str = "test_constructors.Activatable"; +} +unsafe impl Send for Activatable {} +unsafe impl Sync for Activatable {} +#[repr(transparent)] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Composable(windows_core::IUnknown); +windows_core::imp::interface_hierarchy!( + Composable, + windows_core::IUnknown, + windows_core::IInspectable +); +impl Composable { + pub fn Property(&self) -> windows_core::Result { + let this = self; + unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).Property)( + windows_core::Interface::as_raw(this), + &mut result__, + ) + .map(|| result__) + } + } + pub fn new() -> windows_core::Result { + Self::IComposableFactory(|this| unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).CreateInstance)( + windows_core::Interface::as_raw(this), + core::ptr::null_mut(), + &mut core::ptr::null_mut(), + &mut result__, + ) + .and_then(|| windows_core::Type::from_abi(result__)) + }) + } + pub fn WithValue(arg: i32) -> windows_core::Result { + Self::IComposableFactory(|this| unsafe { + let mut result__ = core::mem::zeroed(); + (windows_core::Interface::vtable(this).WithValue)( + windows_core::Interface::as_raw(this), + arg, + core::ptr::null_mut(), + &mut core::ptr::null_mut(), + &mut result__, + ) + .and_then(|| windows_core::Type::from_abi(result__)) + }) + } + fn IComposableFactory windows_core::Result>( + callback: F, + ) -> windows_core::Result { + static SHARED: windows_core::imp::FactoryCache = + windows_core::imp::FactoryCache::new(); + SHARED.call(callback) + } +} +impl windows_core::RuntimeType for Composable { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_class::(); +} +unsafe impl windows_core::Interface for Composable { + type Vtable = ::Vtable; + const IID: windows_core::GUID = ::IID; +} +impl windows_core::RuntimeName for Composable { + const NAME: &'static str = "test_constructors.Composable"; +} +unsafe impl Send for Composable {} +unsafe impl Sync for Composable {} windows_core::imp::define_interface!( IActivatable, IActivatable_Vtbl, @@ -251,136 +384,3 @@ pub struct IComposableFactory_Vtbl { *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT, } -#[repr(transparent)] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct Activatable(windows_core::IUnknown); -windows_core::imp::interface_hierarchy!( - Activatable, - windows_core::IUnknown, - windows_core::IInspectable -); -impl Activatable { - pub fn new() -> windows_core::Result { - Self::IActivationFactory(|f| f.ActivateInstance::()) - } - fn IActivationFactory< - R, - F: FnOnce(&windows_core::imp::IGenericFactory) -> windows_core::Result, - >( - callback: F, - ) -> windows_core::Result { - static SHARED: windows_core::imp::FactoryCache< - Activatable, - windows_core::imp::IGenericFactory, - > = windows_core::imp::FactoryCache::new(); - SHARED.call(callback) - } - pub fn Property(&self) -> windows_core::Result { - let this = self; - unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).Property)( - windows_core::Interface::as_raw(this), - &mut result__, - ) - .map(|| result__) - } - } - pub fn WithValue(arg: i32) -> windows_core::Result { - Self::IActivatableFactory(|this| unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).WithValue)( - windows_core::Interface::as_raw(this), - arg, - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - }) - } - fn IActivatableFactory windows_core::Result>( - callback: F, - ) -> windows_core::Result { - static SHARED: windows_core::imp::FactoryCache = - windows_core::imp::FactoryCache::new(); - SHARED.call(callback) - } -} -impl windows_core::RuntimeType for Activatable { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_class::(); -} -unsafe impl windows_core::Interface for Activatable { - type Vtable = ::Vtable; - const IID: windows_core::GUID = ::IID; -} -impl windows_core::RuntimeName for Activatable { - const NAME: &'static str = "test_constructors.Activatable"; -} -unsafe impl Send for Activatable {} -unsafe impl Sync for Activatable {} -#[repr(transparent)] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct Composable(windows_core::IUnknown); -windows_core::imp::interface_hierarchy!( - Composable, - windows_core::IUnknown, - windows_core::IInspectable -); -impl Composable { - pub fn Property(&self) -> windows_core::Result { - let this = self; - unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).Property)( - windows_core::Interface::as_raw(this), - &mut result__, - ) - .map(|| result__) - } - } - pub fn new() -> windows_core::Result { - Self::IComposableFactory(|this| unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).CreateInstance)( - windows_core::Interface::as_raw(this), - core::ptr::null_mut(), - &mut core::ptr::null_mut(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - }) - } - pub fn WithValue(arg: i32) -> windows_core::Result { - Self::IComposableFactory(|this| unsafe { - let mut result__ = core::mem::zeroed(); - (windows_core::Interface::vtable(this).WithValue)( - windows_core::Interface::as_raw(this), - arg, - core::ptr::null_mut(), - &mut core::ptr::null_mut(), - &mut result__, - ) - .and_then(|| windows_core::Type::from_abi(result__)) - }) - } - fn IComposableFactory windows_core::Result>( - callback: F, - ) -> windows_core::Result { - static SHARED: windows_core::imp::FactoryCache = - windows_core::imp::FactoryCache::new(); - SHARED.call(callback) - } -} -impl windows_core::RuntimeType for Composable { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_class::(); -} -unsafe impl windows_core::Interface for Composable { - type Vtable = ::Vtable; - const IID: windows_core::GUID = ::IID; -} -impl windows_core::RuntimeName for Composable { - const NAME: &'static str = "test_constructors.Composable"; -} -unsafe impl Send for Composable {} -unsafe impl Sync for Composable {} diff --git a/crates/tests/winrt/constructors_client/src/bindings.rs b/crates/tests/winrt/constructors_client/src/bindings.rs index 1e8119819e..bfa268c220 100644 --- a/crates/tests/winrt/constructors_client/src/bindings.rs +++ b/crates/tests/winrt/constructors_client/src/bindings.rs @@ -6,80 +6,6 @@ clippy::all )] -windows_core::imp::define_interface!( - IActivatable, - IActivatable_Vtbl, - 0xe566522b_9c26_582b_950d_177b05d36efd -); -impl windows_core::RuntimeType for IActivatable { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -#[repr(C)] -pub struct IActivatable_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, - pub Property: - unsafe extern "system" fn(*mut core::ffi::c_void, *mut i32) -> windows_core::HRESULT, -} -windows_core::imp::define_interface!( - IActivatableFactory, - IActivatableFactory_Vtbl, - 0xafc5aee9_aa78_5da6_85a2_69e67b45c620 -); -impl windows_core::RuntimeType for IActivatableFactory { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -#[repr(C)] -pub struct IActivatableFactory_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, - pub WithValue: unsafe extern "system" fn( - *mut core::ffi::c_void, - i32, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, -} -windows_core::imp::define_interface!( - IComposable, - IComposable_Vtbl, - 0xff2595d6_461d_5118_9296_f2a2b1e64544 -); -impl windows_core::RuntimeType for IComposable { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -#[repr(C)] -pub struct IComposable_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, - pub Property: - unsafe extern "system" fn(*mut core::ffi::c_void, *mut i32) -> windows_core::HRESULT, -} -windows_core::imp::define_interface!( - IComposableFactory, - IComposableFactory_Vtbl, - 0x6a461099_83c0_5810_9e20_2e8b9521d143 -); -impl windows_core::RuntimeType for IComposableFactory { - const SIGNATURE: windows_core::imp::ConstBuffer = - windows_core::imp::ConstBuffer::for_interface::(); -} -#[repr(C)] -pub struct IComposableFactory_Vtbl { - pub base__: windows_core::IInspectable_Vtbl, - pub CreateInstance: unsafe extern "system" fn( - *mut core::ffi::c_void, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, - pub WithValue: unsafe extern "system" fn( - *mut core::ffi::c_void, - i32, - *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT, -} #[repr(transparent)] #[derive(Clone, Debug, Eq, PartialEq)] pub struct Activatable(windows_core::IUnknown); @@ -213,3 +139,77 @@ impl windows_core::RuntimeName for Composable { } unsafe impl Send for Composable {} unsafe impl Sync for Composable {} +windows_core::imp::define_interface!( + IActivatable, + IActivatable_Vtbl, + 0xe566522b_9c26_582b_950d_177b05d36efd +); +impl windows_core::RuntimeType for IActivatable { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +#[repr(C)] +pub struct IActivatable_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, + pub Property: + unsafe extern "system" fn(*mut core::ffi::c_void, *mut i32) -> windows_core::HRESULT, +} +windows_core::imp::define_interface!( + IActivatableFactory, + IActivatableFactory_Vtbl, + 0xafc5aee9_aa78_5da6_85a2_69e67b45c620 +); +impl windows_core::RuntimeType for IActivatableFactory { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +#[repr(C)] +pub struct IActivatableFactory_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, + pub WithValue: unsafe extern "system" fn( + *mut core::ffi::c_void, + i32, + *mut *mut core::ffi::c_void, + ) -> windows_core::HRESULT, +} +windows_core::imp::define_interface!( + IComposable, + IComposable_Vtbl, + 0xff2595d6_461d_5118_9296_f2a2b1e64544 +); +impl windows_core::RuntimeType for IComposable { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +#[repr(C)] +pub struct IComposable_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, + pub Property: + unsafe extern "system" fn(*mut core::ffi::c_void, *mut i32) -> windows_core::HRESULT, +} +windows_core::imp::define_interface!( + IComposableFactory, + IComposableFactory_Vtbl, + 0x6a461099_83c0_5810_9e20_2e8b9521d143 +); +impl windows_core::RuntimeType for IComposableFactory { + const SIGNATURE: windows_core::imp::ConstBuffer = + windows_core::imp::ConstBuffer::for_interface::(); +} +#[repr(C)] +pub struct IComposableFactory_Vtbl { + pub base__: windows_core::IInspectable_Vtbl, + pub CreateInstance: unsafe extern "system" fn( + *mut core::ffi::c_void, + *mut core::ffi::c_void, + *mut *mut core::ffi::c_void, + *mut *mut core::ffi::c_void, + ) -> windows_core::HRESULT, + pub WithValue: unsafe extern "system" fn( + *mut core::ffi::c_void, + i32, + *mut core::ffi::c_void, + *mut *mut core::ffi::c_void, + *mut *mut core::ffi::c_void, + ) -> windows_core::HRESULT, +}