Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Ref unused lifetime type parameter #3433

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/types/cpp_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ fn write_produce_type(writer: &Writer, ty: &Type, param: Param) -> TokenStream {

if !param.flags().contains(ParamAttributes::Out) && ty.is_interface() {
let type_name = ty.write_name(writer);
quote! { #name: windows_core::Ref<'_, #type_name>, }
quote! { #name: windows_core::Ref<#type_name>, }
} else if param.flags().contains(ParamAttributes::Out) && ty.deref().is_interface() {
let type_name = ty.deref().write_name(writer);
quote! { #name: windows_core::OutRef<'_, #type_name>, }
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/types/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl Method {
quote! { #default_type }
} else if p.0.is_interface() {
let type_name = p.0.write_name(writer);
quote! { windows_core::Ref<'_, #type_name> }
quote! { windows_core::Ref<#type_name> }
} else {
quote! { &#default_type }
}
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/core/src/param_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl<T: Type<T>> ParamValue<T> {
}
}

pub fn borrow(&self) -> Ref<'_, T> {
pub fn borrow(&self) -> Ref<T> {
unsafe { transmute_copy(&self.abi()) }
}
}
7 changes: 3 additions & 4 deletions crates/libs/core/src/ref.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use super::*;
use core::marker::PhantomData;
use core::mem::transmute;

/// A borrowed type with the same memory layout as the type itself that can be used to construct ABI-compatible function signatures.
#[repr(transparent)]
pub struct Ref<'a, T: Type<T>>(T::Abi, PhantomData<&'a T>);
pub struct Ref<T: Type<T>>(T::Abi);

impl<T: Type<T>> Ref<'_, T> {
impl<T: Type<T>> Ref<T> {
/// Returns `true` if the argument is null.
pub fn is_null(&self) -> bool {
T::is_null(&self.0)
Expand Down Expand Up @@ -47,7 +46,7 @@ impl<T: Type<T>> Ref<'_, T> {
}
}

impl<T: Type<T>> core::ops::Deref for Ref<'_, T> {
impl<T: Type<T>> core::ops::Deref for Ref<T> {
type Target = T::Default;
fn deref(&self) -> &Self::Target {
unsafe { transmute(&self.0) }
Expand Down
26 changes: 13 additions & 13 deletions crates/libs/windows/src/Windows/ApplicationModel/Background/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ impl windows_core::RuntimeType for BackgroundTaskCanceledEventHandler {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
impl BackgroundTaskCanceledEventHandler {
pub fn new<F: FnMut(windows_core::Ref<'_, IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> windows_core::Result<()> + Send + 'static>(invoke: F) -> Self {
pub fn new<F: FnMut(windows_core::Ref<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> windows_core::Result<()> + Send + 'static>(invoke: F) -> Self {
let com = BackgroundTaskCanceledEventHandlerBox { vtable: &BackgroundTaskCanceledEventHandlerBox::<F>::VTABLE, count: windows_core::imp::RefCount::new(1), invoke };
unsafe { core::mem::transmute(windows_core::imp::Box::new(com)) }
}
Expand All @@ -600,12 +600,12 @@ pub struct BackgroundTaskCanceledEventHandler_Vtbl {
Invoke: unsafe extern "system" fn(this: *mut core::ffi::c_void, sender: *mut core::ffi::c_void, reason: BackgroundTaskCancellationReason) -> windows_core::HRESULT,
}
#[repr(C)]
struct BackgroundTaskCanceledEventHandlerBox<F: FnMut(windows_core::Ref<'_, IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> windows_core::Result<()> + Send + 'static> {
struct BackgroundTaskCanceledEventHandlerBox<F: FnMut(windows_core::Ref<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> windows_core::Result<()> + Send + 'static> {
vtable: *const BackgroundTaskCanceledEventHandler_Vtbl,
invoke: F,
count: windows_core::imp::RefCount,
}
impl<F: FnMut(windows_core::Ref<'_, IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> windows_core::Result<()> + Send + 'static> BackgroundTaskCanceledEventHandlerBox<F> {
impl<F: FnMut(windows_core::Ref<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> windows_core::Result<()> + Send + 'static> BackgroundTaskCanceledEventHandlerBox<F> {
const VTABLE: BackgroundTaskCanceledEventHandler_Vtbl = BackgroundTaskCanceledEventHandler_Vtbl { base__: windows_core::IUnknown_Vtbl { QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release }, Invoke: Self::Invoke };
unsafe extern "system" fn QueryInterface(this: *mut core::ffi::c_void, iid: *const windows_core::GUID, interface: *mut *mut core::ffi::c_void) -> windows_core::HRESULT {
unsafe {
Expand Down Expand Up @@ -702,7 +702,7 @@ impl windows_core::RuntimeType for BackgroundTaskCompletedEventHandler {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
impl BackgroundTaskCompletedEventHandler {
pub fn new<F: FnMut(windows_core::Ref<'_, BackgroundTaskRegistration>, windows_core::Ref<'_, BackgroundTaskCompletedEventArgs>) -> windows_core::Result<()> + Send + 'static>(invoke: F) -> Self {
pub fn new<F: FnMut(windows_core::Ref<BackgroundTaskRegistration>, windows_core::Ref<BackgroundTaskCompletedEventArgs>) -> windows_core::Result<()> + Send + 'static>(invoke: F) -> Self {
let com = BackgroundTaskCompletedEventHandlerBox { vtable: &BackgroundTaskCompletedEventHandlerBox::<F>::VTABLE, count: windows_core::imp::RefCount::new(1), invoke };
unsafe { core::mem::transmute(windows_core::imp::Box::new(com)) }
}
Expand All @@ -721,12 +721,12 @@ pub struct BackgroundTaskCompletedEventHandler_Vtbl {
Invoke: unsafe extern "system" fn(this: *mut core::ffi::c_void, sender: *mut core::ffi::c_void, args: *mut core::ffi::c_void) -> windows_core::HRESULT,
}
#[repr(C)]
struct BackgroundTaskCompletedEventHandlerBox<F: FnMut(windows_core::Ref<'_, BackgroundTaskRegistration>, windows_core::Ref<'_, BackgroundTaskCompletedEventArgs>) -> windows_core::Result<()> + Send + 'static> {
struct BackgroundTaskCompletedEventHandlerBox<F: FnMut(windows_core::Ref<BackgroundTaskRegistration>, windows_core::Ref<BackgroundTaskCompletedEventArgs>) -> windows_core::Result<()> + Send + 'static> {
vtable: *const BackgroundTaskCompletedEventHandler_Vtbl,
invoke: F,
count: windows_core::imp::RefCount,
}
impl<F: FnMut(windows_core::Ref<'_, BackgroundTaskRegistration>, windows_core::Ref<'_, BackgroundTaskCompletedEventArgs>) -> windows_core::Result<()> + Send + 'static> BackgroundTaskCompletedEventHandlerBox<F> {
impl<F: FnMut(windows_core::Ref<BackgroundTaskRegistration>, windows_core::Ref<BackgroundTaskCompletedEventArgs>) -> windows_core::Result<()> + Send + 'static> BackgroundTaskCompletedEventHandlerBox<F> {
const VTABLE: BackgroundTaskCompletedEventHandler_Vtbl = BackgroundTaskCompletedEventHandler_Vtbl { base__: windows_core::IUnknown_Vtbl { QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release }, Invoke: Self::Invoke };
unsafe extern "system" fn QueryInterface(this: *mut core::ffi::c_void, iid: *const windows_core::GUID, interface: *mut *mut core::ffi::c_void) -> windows_core::HRESULT {
unsafe {
Expand Down Expand Up @@ -825,7 +825,7 @@ impl windows_core::RuntimeType for BackgroundTaskProgressEventHandler {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
impl BackgroundTaskProgressEventHandler {
pub fn new<F: FnMut(windows_core::Ref<'_, BackgroundTaskRegistration>, windows_core::Ref<'_, BackgroundTaskProgressEventArgs>) -> windows_core::Result<()> + Send + 'static>(invoke: F) -> Self {
pub fn new<F: FnMut(windows_core::Ref<BackgroundTaskRegistration>, windows_core::Ref<BackgroundTaskProgressEventArgs>) -> windows_core::Result<()> + Send + 'static>(invoke: F) -> Self {
let com = BackgroundTaskProgressEventHandlerBox { vtable: &BackgroundTaskProgressEventHandlerBox::<F>::VTABLE, count: windows_core::imp::RefCount::new(1), invoke };
unsafe { core::mem::transmute(windows_core::imp::Box::new(com)) }
}
Expand All @@ -844,12 +844,12 @@ pub struct BackgroundTaskProgressEventHandler_Vtbl {
Invoke: unsafe extern "system" fn(this: *mut core::ffi::c_void, sender: *mut core::ffi::c_void, args: *mut core::ffi::c_void) -> windows_core::HRESULT,
}
#[repr(C)]
struct BackgroundTaskProgressEventHandlerBox<F: FnMut(windows_core::Ref<'_, BackgroundTaskRegistration>, windows_core::Ref<'_, BackgroundTaskProgressEventArgs>) -> windows_core::Result<()> + Send + 'static> {
struct BackgroundTaskProgressEventHandlerBox<F: FnMut(windows_core::Ref<BackgroundTaskRegistration>, windows_core::Ref<BackgroundTaskProgressEventArgs>) -> windows_core::Result<()> + Send + 'static> {
vtable: *const BackgroundTaskProgressEventHandler_Vtbl,
invoke: F,
count: windows_core::imp::RefCount,
}
impl<F: FnMut(windows_core::Ref<'_, BackgroundTaskRegistration>, windows_core::Ref<'_, BackgroundTaskProgressEventArgs>) -> windows_core::Result<()> + Send + 'static> BackgroundTaskProgressEventHandlerBox<F> {
impl<F: FnMut(windows_core::Ref<BackgroundTaskRegistration>, windows_core::Ref<BackgroundTaskProgressEventArgs>) -> windows_core::Result<()> + Send + 'static> BackgroundTaskProgressEventHandlerBox<F> {
const VTABLE: BackgroundTaskProgressEventHandler_Vtbl = BackgroundTaskProgressEventHandler_Vtbl { base__: windows_core::IUnknown_Vtbl { QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release }, Invoke: Self::Invoke };
unsafe extern "system" fn QueryInterface(this: *mut core::ffi::c_void, iid: *const windows_core::GUID, interface: *mut *mut core::ffi::c_void) -> windows_core::HRESULT {
unsafe {
Expand Down Expand Up @@ -2245,7 +2245,7 @@ impl windows_core::RuntimeName for IBackgroundTask {
const NAME: &'static str = "Windows.ApplicationModel.Background.IBackgroundTask";
}
pub trait IBackgroundTask_Impl: windows_core::IUnknownImpl {
fn Run(&self, taskInstance: windows_core::Ref<'_, IBackgroundTaskInstance>) -> windows_core::Result<()>;
fn Run(&self, taskInstance: windows_core::Ref<IBackgroundTaskInstance>) -> windows_core::Result<()>;
}
impl IBackgroundTask_Vtbl {
pub const fn new<Identity: IBackgroundTask_Impl, const OFFSET: isize>() -> Self {
Expand Down Expand Up @@ -2436,7 +2436,7 @@ pub trait IBackgroundTaskInstance_Impl: windows_core::IUnknownImpl {
fn Progress(&self) -> windows_core::Result<u32>;
fn SetProgress(&self, value: u32) -> windows_core::Result<()>;
fn TriggerDetails(&self) -> windows_core::Result<windows_core::IInspectable>;
fn Canceled(&self, cancelHandler: windows_core::Ref<'_, BackgroundTaskCanceledEventHandler>) -> windows_core::Result<i64>;
fn Canceled(&self, cancelHandler: windows_core::Ref<BackgroundTaskCanceledEventHandler>) -> windows_core::Result<i64>;
fn RemoveCanceled(&self, cookie: i64) -> windows_core::Result<()>;
fn SuspendedCount(&self) -> windows_core::Result<u32>;
fn GetDeferral(&self) -> windows_core::Result<BackgroundTaskDeferral>;
Expand Down Expand Up @@ -2864,9 +2864,9 @@ impl windows_core::RuntimeName for IBackgroundTaskRegistration {
pub trait IBackgroundTaskRegistration_Impl: windows_core::IUnknownImpl {
fn TaskId(&self) -> windows_core::Result<windows_core::GUID>;
fn Name(&self) -> windows_core::Result<windows_core::HSTRING>;
fn Progress(&self, handler: windows_core::Ref<'_, BackgroundTaskProgressEventHandler>) -> windows_core::Result<i64>;
fn Progress(&self, handler: windows_core::Ref<BackgroundTaskProgressEventHandler>) -> windows_core::Result<i64>;
fn RemoveProgress(&self, cookie: i64) -> windows_core::Result<()>;
fn Completed(&self, handler: windows_core::Ref<'_, BackgroundTaskCompletedEventHandler>) -> windows_core::Result<i64>;
fn Completed(&self, handler: windows_core::Ref<BackgroundTaskCompletedEventHandler>) -> windows_core::Result<i64>;
fn RemoveCompleted(&self, cookie: i64) -> windows_core::Result<()>;
fn Unregister(&self, cancelTask: bool) -> windows_core::Result<()>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4952,7 +4952,7 @@ impl windows_core::RuntimeName for IContactInstantMessageFieldFactory {
pub trait IContactInstantMessageFieldFactory_Impl: windows_core::IUnknownImpl {
fn CreateInstantMessage_Default(&self, userName: &windows_core::HSTRING) -> windows_core::Result<ContactInstantMessageField>;
fn CreateInstantMessage_Category(&self, userName: &windows_core::HSTRING, category: ContactFieldCategory) -> windows_core::Result<ContactInstantMessageField>;
fn CreateInstantMessage_All(&self, userName: &windows_core::HSTRING, category: ContactFieldCategory, service: &windows_core::HSTRING, displayText: &windows_core::HSTRING, verb: windows_core::Ref<'_, super::super::Foundation::Uri>) -> windows_core::Result<ContactInstantMessageField>;
fn CreateInstantMessage_All(&self, userName: &windows_core::HSTRING, category: ContactFieldCategory, service: &windows_core::HSTRING, displayText: &windows_core::HSTRING, verb: windows_core::Ref<super::super::Foundation::Uri>) -> windows_core::Result<ContactInstantMessageField>;
}
impl IContactInstantMessageFieldFactory_Vtbl {
pub const fn new<Identity: IContactInstantMessageFieldFactory_Impl, const OFFSET: isize>() -> Self {
Expand Down
6 changes: 3 additions & 3 deletions crates/libs/windows/src/Windows/ApplicationModel/Core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ impl windows_core::RuntimeName for ICoreApplicationUnhandledError {
const NAME: &'static str = "Windows.ApplicationModel.Core.ICoreApplicationUnhandledError";
}
pub trait ICoreApplicationUnhandledError_Impl: windows_core::IUnknownImpl {
fn UnhandledErrorDetected(&self, handler: windows_core::Ref<'_, super::super::Foundation::EventHandler<UnhandledErrorDetectedEventArgs>>) -> windows_core::Result<i64>;
fn UnhandledErrorDetected(&self, handler: windows_core::Ref<super::super::Foundation::EventHandler<UnhandledErrorDetectedEventArgs>>) -> windows_core::Result<i64>;
fn RemoveUnhandledErrorDetected(&self, token: i64) -> windows_core::Result<()>;
}
impl ICoreApplicationUnhandledError_Vtbl {
Expand Down Expand Up @@ -836,8 +836,8 @@ impl windows_core::RuntimeName for IFrameworkView {
}
#[cfg(feature = "UI_Core")]
pub trait IFrameworkView_Impl: windows_core::IUnknownImpl {
fn Initialize(&self, applicationView: windows_core::Ref<'_, CoreApplicationView>) -> windows_core::Result<()>;
fn SetWindow(&self, window: windows_core::Ref<'_, super::super::UI::Core::CoreWindow>) -> windows_core::Result<()>;
fn Initialize(&self, applicationView: windows_core::Ref<CoreApplicationView>) -> windows_core::Result<()>;
fn SetWindow(&self, window: windows_core::Ref<super::super::UI::Core::CoreWindow>) -> windows_core::Result<()>;
fn Load(&self, entryPoint: &windows_core::HSTRING) -> windows_core::Result<()>;
fn Run(&self) -> windows_core::Result<()>;
fn Uninitialize(&self) -> windows_core::Result<()>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,10 @@ impl windows_core::RuntimeName for ICoreDropOperationTarget {
const NAME: &'static str = "Windows.ApplicationModel.DataTransfer.DragDrop.Core.ICoreDropOperationTarget";
}
pub trait ICoreDropOperationTarget_Impl: windows_core::IUnknownImpl {
fn EnterAsync(&self, dragInfo: windows_core::Ref<'_, CoreDragInfo>, dragUIOverride: windows_core::Ref<'_, CoreDragUIOverride>) -> windows_core::Result<super::super::super::super::Foundation::IAsyncOperation<super::super::DataPackageOperation>>;
fn OverAsync(&self, dragInfo: windows_core::Ref<'_, CoreDragInfo>, dragUIOverride: windows_core::Ref<'_, CoreDragUIOverride>) -> windows_core::Result<super::super::super::super::Foundation::IAsyncOperation<super::super::DataPackageOperation>>;
fn LeaveAsync(&self, dragInfo: windows_core::Ref<'_, CoreDragInfo>) -> windows_core::Result<super::super::super::super::Foundation::IAsyncAction>;
fn DropAsync(&self, dragInfo: windows_core::Ref<'_, CoreDragInfo>) -> windows_core::Result<super::super::super::super::Foundation::IAsyncOperation<super::super::DataPackageOperation>>;
fn EnterAsync(&self, dragInfo: windows_core::Ref<CoreDragInfo>, dragUIOverride: windows_core::Ref<CoreDragUIOverride>) -> windows_core::Result<super::super::super::super::Foundation::IAsyncOperation<super::super::DataPackageOperation>>;
fn OverAsync(&self, dragInfo: windows_core::Ref<CoreDragInfo>, dragUIOverride: windows_core::Ref<CoreDragUIOverride>) -> windows_core::Result<super::super::super::super::Foundation::IAsyncOperation<super::super::DataPackageOperation>>;
fn LeaveAsync(&self, dragInfo: windows_core::Ref<CoreDragInfo>) -> windows_core::Result<super::super::super::super::Foundation::IAsyncAction>;
fn DropAsync(&self, dragInfo: windows_core::Ref<CoreDragInfo>) -> windows_core::Result<super::super::super::super::Foundation::IAsyncOperation<super::super::DataPackageOperation>>;
}
impl ICoreDropOperationTarget_Vtbl {
pub const fn new<Identity: ICoreDropOperationTarget_Impl, const OFFSET: isize>() -> Self {
Expand Down
Loading