From 021fd1e4e170b9c923c3d20d3399743e5f959151 Mon Sep 17 00:00:00 2001 From: Arlie Davis Date: Mon, 3 Jun 2024 15:25:25 -0700 Subject: [PATCH] more bindings updated --- .../json_validator_winrt/src/bindings.rs | 50 ++++--- crates/tests/component/src/bindings.rs | 130 +++++++++++------- 2 files changed, 114 insertions(+), 66 deletions(-) diff --git a/crates/samples/components/json_validator_winrt/src/bindings.rs b/crates/samples/components/json_validator_winrt/src/bindings.rs index 02f20d94d94..54b4ff70978 100644 --- a/crates/samples/components/json_validator_winrt/src/bindings.rs +++ b/crates/samples/components/json_validator_winrt/src/bindings.rs @@ -114,21 +114,28 @@ impl windows_core::RuntimeName for IJsonValidator { } impl IJsonValidator_Vtbl { pub const fn new< - Identity: windows_core::IUnknownImpl, - Impl: IJsonValidator_Impl, + Identity: windows_core::IUnknownImpl, + OuterToImpl: ::windows_core::ComGetImpl, const OFFSET: isize, - >() -> IJsonValidator_Vtbl { + >() -> IJsonValidator_Vtbl + where + OuterToImpl::Impl: IJsonValidator_Impl, + { unsafe extern "system" fn Validate< - Identity: windows_core::IUnknownImpl, - Impl: IJsonValidator_Impl, + Identity: windows_core::IUnknownImpl, + OuterToImpl: ::windows_core::ComGetImpl, const OFFSET: isize, >( this: *mut core::ffi::c_void, value: core::mem::MaybeUninit, result__: *mut core::mem::MaybeUninit, - ) -> windows_core::HRESULT { - let this = (this as *const *const ()).offset(OFFSET) as *const Identity; - let this = (*this).get_impl(); + ) -> windows_core::HRESULT + where + OuterToImpl::Impl: IJsonValidator_Impl, + { + let this_outer: &Identity = + &*((this as *const *const ()).offset(OFFSET) as *const Identity); + let this = OuterToImpl::get_impl(this_outer); match IJsonValidator_Impl::Validate(this, core::mem::transmute(&value)) { Ok(ok__) => { core::ptr::write(result__, core::mem::transmute_copy(&ok__)); @@ -140,7 +147,7 @@ impl IJsonValidator_Vtbl { } Self { base__: windows_core::IInspectable_Vtbl::new::(), - Validate: Validate::, + Validate: Validate::, } } pub fn matches(iid: &windows_core::GUID) -> bool { @@ -156,21 +163,28 @@ impl windows_core::RuntimeName for IJsonValidatorFactory { } impl IJsonValidatorFactory_Vtbl { pub const fn new< - Identity: windows_core::IUnknownImpl, - Impl: IJsonValidatorFactory_Impl, + Identity: windows_core::IUnknownImpl, + OuterToImpl: ::windows_core::ComGetImpl, const OFFSET: isize, - >() -> IJsonValidatorFactory_Vtbl { + >() -> IJsonValidatorFactory_Vtbl + where + OuterToImpl::Impl: IJsonValidatorFactory_Impl, + { unsafe extern "system" fn CreateInstance< - Identity: windows_core::IUnknownImpl, - Impl: IJsonValidatorFactory_Impl, + Identity: windows_core::IUnknownImpl, + OuterToImpl: ::windows_core::ComGetImpl, const OFFSET: isize, >( this: *mut core::ffi::c_void, schema: core::mem::MaybeUninit, result__: *mut *mut core::ffi::c_void, - ) -> windows_core::HRESULT { - let this = (this as *const *const ()).offset(OFFSET) as *const Identity; - let this = (*this).get_impl(); + ) -> windows_core::HRESULT + where + OuterToImpl::Impl: IJsonValidatorFactory_Impl, + { + let this_outer: &Identity = + &*((this as *const *const ()).offset(OFFSET) as *const Identity); + let this = OuterToImpl::get_impl(this_outer); match IJsonValidatorFactory_Impl::CreateInstance(this, core::mem::transmute(&schema)) { Ok(ok__) => { core::ptr::write(result__, core::mem::transmute_copy(&ok__)); @@ -183,7 +197,7 @@ impl IJsonValidatorFactory_Vtbl { Self { base__: windows_core::IInspectable_Vtbl::new::( ), - CreateInstance: CreateInstance::, + CreateInstance: CreateInstance::, } } pub fn matches(iid: &windows_core::GUID) -> bool { diff --git a/crates/tests/component/src/bindings.rs b/crates/tests/component/src/bindings.rs index 187a8710aa9..1135c49674e 100644 --- a/crates/tests/component/src/bindings.rs +++ b/crates/tests/component/src/bindings.rs @@ -50,24 +50,31 @@ pub mod Nested { } impl IThing_Vtbl { pub const fn new< - Identity: windows_core::IUnknownImpl, - Impl: IThing_Impl, + Identity: windows_core::IUnknownImpl, + OuterToImpl: ::windows_core::ComGetImpl, const OFFSET: isize, - >() -> IThing_Vtbl { + >() -> IThing_Vtbl + where + OuterToImpl::Impl: IThing_Impl, + { unsafe extern "system" fn Method< - Identity: windows_core::IUnknownImpl, - Impl: IThing_Impl, + Identity: windows_core::IUnknownImpl, + OuterToImpl: ::windows_core::ComGetImpl, const OFFSET: isize, >( this: *mut core::ffi::c_void, - ) -> windows_core::HRESULT { - let this = (this as *const *const ()).offset(OFFSET) as *const Identity; - let this = (*this).get_impl(); + ) -> windows_core::HRESULT + where + OuterToImpl::Impl: IThing_Impl, + { + let this_outer: &Identity = + &*((this as *const *const ()).offset(OFFSET) as *const Identity); + let this = OuterToImpl::get_impl(this_outer); IThing_Impl::Method(this).into() } Self { base__: windows_core::IInspectable_Vtbl::new::(), - Method: Method::, + Method: Method::, } } pub fn matches(iid: &windows_core::GUID) -> bool { @@ -433,20 +440,27 @@ impl windows_core::RuntimeName for IClass { } impl IClass_Vtbl { pub const fn new< - Identity: windows_core::IUnknownImpl, - Impl: IClass_Impl, + Identity: windows_core::IUnknownImpl, + OuterToImpl: ::windows_core::ComGetImpl, const OFFSET: isize, - >() -> IClass_Vtbl { + >() -> IClass_Vtbl + where + OuterToImpl::Impl: IClass_Impl, + { unsafe extern "system" fn Property< - Identity: windows_core::IUnknownImpl, - Impl: IClass_Impl, + Identity: windows_core::IUnknownImpl, + OuterToImpl: ::windows_core::ComGetImpl, const OFFSET: isize, >( this: *mut core::ffi::c_void, result__: *mut i32, - ) -> windows_core::HRESULT { - let this = (this as *const *const ()).offset(OFFSET) as *const Identity; - let this = (*this).get_impl(); + ) -> windows_core::HRESULT + where + OuterToImpl::Impl: IClass_Impl, + { + let this_outer: &Identity = + &*((this as *const *const ()).offset(OFFSET) as *const Identity); + let this = OuterToImpl::get_impl(this_outer); match IClass_Impl::Property(this) { Ok(ok__) => { core::ptr::write(result__, core::mem::transmute_copy(&ok__)); @@ -456,27 +470,35 @@ impl IClass_Vtbl { } } unsafe extern "system" fn SetProperty< - Identity: windows_core::IUnknownImpl, - Impl: IClass_Impl, + Identity: windows_core::IUnknownImpl, + OuterToImpl: ::windows_core::ComGetImpl, const OFFSET: isize, >( this: *mut core::ffi::c_void, value: i32, - ) -> windows_core::HRESULT { - let this = (this as *const *const ()).offset(OFFSET) as *const Identity; - let this = (*this).get_impl(); + ) -> windows_core::HRESULT + where + OuterToImpl::Impl: IClass_Impl, + { + let this_outer: &Identity = + &*((this as *const *const ()).offset(OFFSET) as *const Identity); + let this = OuterToImpl::get_impl(this_outer); IClass_Impl::SetProperty(this, value).into() } unsafe extern "system" fn Flags< - Identity: windows_core::IUnknownImpl, - Impl: IClass_Impl, + Identity: windows_core::IUnknownImpl, + OuterToImpl: ::windows_core::ComGetImpl, const OFFSET: isize, >( this: *mut core::ffi::c_void, result__: *mut Flags, - ) -> windows_core::HRESULT { - let this = (this as *const *const ()).offset(OFFSET) as *const Identity; - let this = (*this).get_impl(); + ) -> windows_core::HRESULT + where + OuterToImpl::Impl: IClass_Impl, + { + let this_outer: &Identity = + &*((this as *const *const ()).offset(OFFSET) as *const Identity); + let this = OuterToImpl::get_impl(this_outer); match IClass_Impl::Flags(this) { Ok(ok__) => { core::ptr::write(result__, core::mem::transmute_copy(&ok__)); @@ -486,8 +508,8 @@ impl IClass_Vtbl { } } unsafe extern "system" fn Int32Array< - Identity: windows_core::IUnknownImpl, - Impl: IClass_Impl, + Identity: windows_core::IUnknownImpl, + OuterToImpl: ::windows_core::ComGetImpl, const OFFSET: isize, >( this: *mut core::ffi::c_void, @@ -499,9 +521,13 @@ impl IClass_Vtbl { c: *mut *mut i32, result_size__: *mut u32, result__: *mut *mut i32, - ) -> windows_core::HRESULT { - let this = (this as *const *const ()).offset(OFFSET) as *const Identity; - let this = (*this).get_impl(); + ) -> windows_core::HRESULT + where + OuterToImpl::Impl: IClass_Impl, + { + let this_outer: &Identity = + &*((this as *const *const ()).offset(OFFSET) as *const Identity); + let this = OuterToImpl::get_impl(this_outer); match IClass_Impl::Int32Array( this, core::slice::from_raw_parts(core::mem::transmute_copy(&a), a_array_size as usize), @@ -525,8 +551,8 @@ impl IClass_Vtbl { } } unsafe extern "system" fn StringArray< - Identity: windows_core::IUnknownImpl, - Impl: IClass_Impl, + Identity: windows_core::IUnknownImpl, + OuterToImpl: ::windows_core::ComGetImpl, const OFFSET: isize, >( this: *mut core::ffi::c_void, @@ -538,9 +564,13 @@ impl IClass_Vtbl { c: *mut *mut core::mem::MaybeUninit, result_size__: *mut u32, result__: *mut *mut core::mem::MaybeUninit, - ) -> windows_core::HRESULT { - let this = (this as *const *const ()).offset(OFFSET) as *const Identity; - let this = (*this).get_impl(); + ) -> windows_core::HRESULT + where + OuterToImpl::Impl: IClass_Impl, + { + let this_outer: &Identity = + &*((this as *const *const ()).offset(OFFSET) as *const Identity); + let this = OuterToImpl::get_impl(this_outer); match IClass_Impl::StringArray( this, core::slice::from_raw_parts(core::mem::transmute_copy(&a), a_array_size as usize), @@ -564,8 +594,8 @@ impl IClass_Vtbl { } } unsafe extern "system" fn Input< - Identity: windows_core::IUnknownImpl, - Impl: IClass_Impl, + Identity: windows_core::IUnknownImpl, + OuterToImpl: ::windows_core::ComGetImpl, const OFFSET: isize, >( this: *mut core::ffi::c_void, @@ -573,9 +603,13 @@ impl IClass_Vtbl { b: *mut core::ffi::c_void, c: *mut core::ffi::c_void, d: *mut core::ffi::c_void, - ) -> windows_core::HRESULT { - let this = (this as *const *const ()).offset(OFFSET) as *const Identity; - let this = (*this).get_impl(); + ) -> windows_core::HRESULT + where + OuterToImpl::Impl: IClass_Impl, + { + let this_outer: &Identity = + &*((this as *const *const ()).offset(OFFSET) as *const Identity); + let this = OuterToImpl::get_impl(this_outer); IClass_Impl::Input( this, windows_core::from_raw_borrowed(&a), @@ -587,12 +621,12 @@ impl IClass_Vtbl { } Self { base__: windows_core::IInspectable_Vtbl::new::(), - Property: Property::, - SetProperty: SetProperty::, - Flags: Flags::, - Int32Array: Int32Array::, - StringArray: StringArray::, - Input: Input::, + Property: Property::, + SetProperty: SetProperty::, + Flags: Flags::, + Int32Array: Int32Array::, + StringArray: StringArray::, + Input: Input::, } } pub fn matches(iid: &windows_core::GUID) -> bool {