Skip to content

Commit

Permalink
fix: update bindings to use the proper IAgileReference::Resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Feb 1, 2022
1 parent d1be595 commit a8da9d6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
9 changes: 1 addition & 8 deletions crates/libs/windows/src/core/agile_reference.rs
Expand Up @@ -16,14 +16,7 @@ impl<T: Interface> AgileReference<T> {
}

pub fn resolve(&self) -> Result<T> {
unsafe {
let mut ptr = core::ptr::null_mut();
self.reference.Resolve(&T::IID, &mut ptr)?;

let resolved = IUnknown(core::ptr::NonNull::new(ptr).ok_or_else(|| Error::from(E_NOINTERFACE))?);

resolved.cast()
}
unsafe { self.reference.Resolve() }
}
}

Expand Down
5 changes: 3 additions & 2 deletions crates/libs/windows/src/core/bindings.rs
Expand Up @@ -2100,8 +2100,9 @@ pub unsafe fn WaitForSingleObject<'a, Param0: ::windows::core::IntoParam<'a, HAN
#[repr(transparent)]
pub struct IAgileReference(::windows::core::IUnknown);
impl IAgileReference {
pub unsafe fn Resolve(&self, riid: *const ::windows::core::GUID, ppvobjectreference: *mut *mut ::core::ffi::c_void) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).Resolve)(::core::mem::transmute_copy(self), ::core::mem::transmute(riid), ::core::mem::transmute(ppvobjectreference)).ok()
pub unsafe fn Resolve<T: ::windows::core::Interface>(&self) -> ::windows::core::Result<T> {
let mut result__ = ::core::option::Option::None;
(::windows::core::Interface::vtable(self).Resolve)(::core::mem::transmute_copy(self), &<T as ::windows::core::Interface>::IID, &mut result__ as *mut _ as *mut _).and_some(result__)
}
}
impl ::core::convert::From<IAgileReference> for ::windows::core::IUnknown {
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/windows/src/core/unknown.rs
Expand Up @@ -5,7 +5,7 @@ use super::*;
/// under the hood to provide reference-counted lifetime management as well as the ability
/// to query for additional interfaces that the object may implement.
#[repr(transparent)]
pub struct IUnknown(pub(super) core::ptr::NonNull<core::ffi::c_void>);
pub struct IUnknown(core::ptr::NonNull<core::ffi::c_void>);

#[doc(hidden)]
#[repr(C)]
Expand Down

0 comments on commit a8da9d6

Please sign in to comment.