Skip to content

Commit

Permalink
Treat CanReturnErrorsAsSuccess as PreserveSig
Browse files Browse the repository at this point in the history
  • Loading branch information
riverar committed Dec 6, 2023
1 parent 5c5c82a commit 7c5c16f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 77 deletions.
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl SignatureParam {

impl Signature {
pub fn kind(&self) -> SignatureKind {
if self.def.has_attribute("CanReturnMultipleSuccessValuesAttribute") {
if self.def.has_attribute("CanReturnMultipleSuccessValuesAttribute") || self.def.has_attribute("CanReturnErrorsAsSuccessAttribute") {
return SignatureKind::PreserveSig;
}
match &self.return_type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4492,7 +4492,7 @@ pub trait ID2D1RenderTarget_Impl: Sized + ID2D1Resource_Impl {
fn PopAxisAlignedClip(&self);
fn Clear(&self, clearcolor: *const Common::D2D1_COLOR_F);
fn BeginDraw(&self);
fn EndDraw(&self, tag1: *mut u64, tag2: *mut u64) -> ::windows_core::Result<()>;
fn EndDraw(&self, tag1: *mut u64, tag2: *mut u64) -> ::windows_core::HRESULT;
fn GetPixelFormat(&self) -> Common::D2D1_PIXEL_FORMAT;
fn SetDpi(&self, dpix: f32, dpiy: f32);
fn GetDpi(&self, dpix: *mut f32, dpiy: *mut f32);
Expand Down Expand Up @@ -4794,7 +4794,7 @@ impl ID2D1RenderTarget_Vtbl {
unsafe extern "system" fn EndDraw<Identity: ::windows_core::IUnknownImpl<Impl = Impl>, Impl: ID2D1RenderTarget_Impl, const OFFSET: isize>(this: *mut ::core::ffi::c_void, tag1: *mut u64, tag2: *mut u64) -> ::windows_core::HRESULT {
let this = (this as *const *const ()).offset(OFFSET) as *const Identity;
let this = (*this).get_impl();
this.EndDraw(::core::mem::transmute_copy(&tag1), ::core::mem::transmute_copy(&tag2)).into()
this.EndDraw(::core::mem::transmute_copy(&tag1), ::core::mem::transmute_copy(&tag2))
}
unsafe extern "system" fn GetPixelFormat<Identity: ::windows_core::IUnknownImpl<Impl = Impl>, Impl: ID2D1RenderTarget_Impl, const OFFSET: isize>(this: *mut ::core::ffi::c_void, result__: *mut Common::D2D1_PIXEL_FORMAT) {
let this = (this as *const *const ()).offset(OFFSET) as *const Identity;
Expand Down
44 changes: 22 additions & 22 deletions crates/libs/windows/src/Windows/Win32/Graphics/Direct2D/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,8 @@ impl ID2D1BitmapRenderTarget {
pub unsafe fn BeginDraw(&self) {
(::windows_core::Interface::vtable(self).base__.BeginDraw)(::windows_core::Interface::as_raw(self))
}
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::Result<()> {
(::windows_core::Interface::vtable(self).base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut()))).ok()
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::HRESULT {
(::windows_core::Interface::vtable(self).base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut())))
}
#[doc = "Required features: `\"Win32_Graphics_Direct2D_Common\"`, `\"Win32_Graphics_Dxgi_Common\"`"]
#[cfg(all(feature = "Win32_Graphics_Direct2D_Common", feature = "Win32_Graphics_Dxgi_Common"))]
Expand Down Expand Up @@ -2781,8 +2781,8 @@ impl ID2D1DCRenderTarget {
pub unsafe fn BeginDraw(&self) {
(::windows_core::Interface::vtable(self).base__.BeginDraw)(::windows_core::Interface::as_raw(self))
}
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::Result<()> {
(::windows_core::Interface::vtable(self).base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut()))).ok()
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::HRESULT {
(::windows_core::Interface::vtable(self).base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut())))
}
#[doc = "Required features: `\"Win32_Graphics_Direct2D_Common\"`, `\"Win32_Graphics_Dxgi_Common\"`"]
#[cfg(all(feature = "Win32_Graphics_Direct2D_Common", feature = "Win32_Graphics_Dxgi_Common"))]
Expand Down Expand Up @@ -3691,8 +3691,8 @@ impl ID2D1DeviceContext {
pub unsafe fn BeginDraw(&self) {
(::windows_core::Interface::vtable(self).base__.BeginDraw)(::windows_core::Interface::as_raw(self))
}
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::Result<()> {
(::windows_core::Interface::vtable(self).base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut()))).ok()
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::HRESULT {
(::windows_core::Interface::vtable(self).base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut())))
}
#[doc = "Required features: `\"Win32_Graphics_Direct2D_Common\"`, `\"Win32_Graphics_Dxgi_Common\"`"]
#[cfg(all(feature = "Win32_Graphics_Direct2D_Common", feature = "Win32_Graphics_Dxgi_Common"))]
Expand Down Expand Up @@ -4373,8 +4373,8 @@ impl ID2D1DeviceContext1 {
pub unsafe fn BeginDraw(&self) {
(::windows_core::Interface::vtable(self).base__.base__.BeginDraw)(::windows_core::Interface::as_raw(self))
}
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::Result<()> {
(::windows_core::Interface::vtable(self).base__.base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut()))).ok()
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::HRESULT {
(::windows_core::Interface::vtable(self).base__.base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut())))
}
#[doc = "Required features: `\"Win32_Graphics_Direct2D_Common\"`, `\"Win32_Graphics_Dxgi_Common\"`"]
#[cfg(all(feature = "Win32_Graphics_Direct2D_Common", feature = "Win32_Graphics_Dxgi_Common"))]
Expand Down Expand Up @@ -4976,8 +4976,8 @@ impl ID2D1DeviceContext2 {
pub unsafe fn BeginDraw(&self) {
(::windows_core::Interface::vtable(self).base__.base__.base__.BeginDraw)(::windows_core::Interface::as_raw(self))
}
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::Result<()> {
(::windows_core::Interface::vtable(self).base__.base__.base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut()))).ok()
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::HRESULT {
(::windows_core::Interface::vtable(self).base__.base__.base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut())))
}
#[doc = "Required features: `\"Win32_Graphics_Direct2D_Common\"`, `\"Win32_Graphics_Dxgi_Common\"`"]
#[cfg(all(feature = "Win32_Graphics_Direct2D_Common", feature = "Win32_Graphics_Dxgi_Common"))]
Expand Down Expand Up @@ -5678,8 +5678,8 @@ impl ID2D1DeviceContext3 {
pub unsafe fn BeginDraw(&self) {
(::windows_core::Interface::vtable(self).base__.base__.base__.base__.BeginDraw)(::windows_core::Interface::as_raw(self))
}
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::Result<()> {
(::windows_core::Interface::vtable(self).base__.base__.base__.base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut()))).ok()
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::HRESULT {
(::windows_core::Interface::vtable(self).base__.base__.base__.base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut())))
}
#[doc = "Required features: `\"Win32_Graphics_Direct2D_Common\"`, `\"Win32_Graphics_Dxgi_Common\"`"]
#[cfg(all(feature = "Win32_Graphics_Direct2D_Common", feature = "Win32_Graphics_Dxgi_Common"))]
Expand Down Expand Up @@ -6364,8 +6364,8 @@ impl ID2D1DeviceContext4 {
pub unsafe fn BeginDraw(&self) {
(::windows_core::Interface::vtable(self).base__.base__.base__.base__.base__.BeginDraw)(::windows_core::Interface::as_raw(self))
}
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::Result<()> {
(::windows_core::Interface::vtable(self).base__.base__.base__.base__.base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut()))).ok()
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::HRESULT {
(::windows_core::Interface::vtable(self).base__.base__.base__.base__.base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut())))
}
#[doc = "Required features: `\"Win32_Graphics_Direct2D_Common\"`, `\"Win32_Graphics_Dxgi_Common\"`"]
#[cfg(all(feature = "Win32_Graphics_Direct2D_Common", feature = "Win32_Graphics_Dxgi_Common"))]
Expand Down Expand Up @@ -7131,8 +7131,8 @@ impl ID2D1DeviceContext5 {
pub unsafe fn BeginDraw(&self) {
(::windows_core::Interface::vtable(self).base__.base__.base__.base__.base__.base__.BeginDraw)(::windows_core::Interface::as_raw(self))
}
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::Result<()> {
(::windows_core::Interface::vtable(self).base__.base__.base__.base__.base__.base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut()))).ok()
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::HRESULT {
(::windows_core::Interface::vtable(self).base__.base__.base__.base__.base__.base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut())))
}
#[doc = "Required features: `\"Win32_Graphics_Direct2D_Common\"`, `\"Win32_Graphics_Dxgi_Common\"`"]
#[cfg(all(feature = "Win32_Graphics_Direct2D_Common", feature = "Win32_Graphics_Dxgi_Common"))]
Expand Down Expand Up @@ -7913,8 +7913,8 @@ impl ID2D1DeviceContext6 {
pub unsafe fn BeginDraw(&self) {
(::windows_core::Interface::vtable(self).base__.base__.base__.base__.base__.base__.base__.BeginDraw)(::windows_core::Interface::as_raw(self))
}
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::Result<()> {
(::windows_core::Interface::vtable(self).base__.base__.base__.base__.base__.base__.base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut()))).ok()
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::HRESULT {
(::windows_core::Interface::vtable(self).base__.base__.base__.base__.base__.base__.base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut())))
}
#[doc = "Required features: `\"Win32_Graphics_Direct2D_Common\"`, `\"Win32_Graphics_Dxgi_Common\"`"]
#[cfg(all(feature = "Win32_Graphics_Direct2D_Common", feature = "Win32_Graphics_Dxgi_Common"))]
Expand Down Expand Up @@ -11927,8 +11927,8 @@ impl ID2D1HwndRenderTarget {
pub unsafe fn BeginDraw(&self) {
(::windows_core::Interface::vtable(self).base__.BeginDraw)(::windows_core::Interface::as_raw(self))
}
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::Result<()> {
(::windows_core::Interface::vtable(self).base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut()))).ok()
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::HRESULT {
(::windows_core::Interface::vtable(self).base__.EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut())))
}
#[doc = "Required features: `\"Win32_Graphics_Direct2D_Common\"`, `\"Win32_Graphics_Dxgi_Common\"`"]
#[cfg(all(feature = "Win32_Graphics_Direct2D_Common", feature = "Win32_Graphics_Dxgi_Common"))]
Expand Down Expand Up @@ -13598,8 +13598,8 @@ impl ID2D1RenderTarget {
pub unsafe fn BeginDraw(&self) {
(::windows_core::Interface::vtable(self).BeginDraw)(::windows_core::Interface::as_raw(self))
}
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::Result<()> {
(::windows_core::Interface::vtable(self).EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut()))).ok()
pub unsafe fn EndDraw(&self, tag1: ::core::option::Option<*mut u64>, tag2: ::core::option::Option<*mut u64>) -> ::windows_core::HRESULT {
(::windows_core::Interface::vtable(self).EndDraw)(::windows_core::Interface::as_raw(self), ::core::mem::transmute(tag1.unwrap_or(::std::ptr::null_mut())), ::core::mem::transmute(tag2.unwrap_or(::std::ptr::null_mut())))
}
#[doc = "Required features: `\"Win32_Graphics_Direct2D_Common\"`, `\"Win32_Graphics_Dxgi_Common\"`"]
#[cfg(all(feature = "Win32_Graphics_Direct2D_Common", feature = "Win32_Graphics_Dxgi_Common"))]
Expand Down
20 changes: 4 additions & 16 deletions crates/libs/windows/src/Windows/Win32/Graphics/Dxgi/impl.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[doc = "Required features: `\"Win32_Foundation\"`"]
#[cfg(feature = "Win32_Foundation")]
pub trait IDXGIAdapter_Impl: Sized + IDXGIObject_Impl {
fn EnumOutputs(&self, output: u32) -> ::windows_core::Result<IDXGIOutput>;
fn EnumOutputs(&self, output: u32, ppoutput: *mut ::core::option::Option<IDXGIOutput>) -> ::windows_core::HRESULT;
fn GetDesc(&self, pdesc: *mut DXGI_ADAPTER_DESC) -> ::windows_core::Result<()>;
fn CheckInterfaceSupport(&self, interfacename: *const ::windows_core::GUID) -> ::windows_core::Result<i64>;
}
Expand All @@ -13,13 +13,7 @@ impl IDXGIAdapter_Vtbl {
unsafe extern "system" fn EnumOutputs<Identity: ::windows_core::IUnknownImpl<Impl = Impl>, Impl: IDXGIAdapter_Impl, const OFFSET: isize>(this: *mut ::core::ffi::c_void, output: u32, ppoutput: *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();
match this.EnumOutputs(::core::mem::transmute_copy(&output)) {
::core::result::Result::Ok(ok__) => {
::core::ptr::write(ppoutput, ::core::mem::transmute(ok__));
::windows_core::HRESULT(0)
}
::core::result::Result::Err(err) => err.into(),
}
this.EnumOutputs(::core::mem::transmute_copy(&output), ::core::mem::transmute_copy(&ppoutput))
}
unsafe extern "system" fn GetDesc<Identity: ::windows_core::IUnknownImpl<Impl = Impl>, Impl: IDXGIAdapter_Impl, const OFFSET: isize>(this: *mut ::core::ffi::c_void, pdesc: *mut DXGI_ADAPTER_DESC) -> ::windows_core::HRESULT {
let this = (this as *const *const ()).offset(OFFSET) as *const Identity;
Expand Down Expand Up @@ -641,7 +635,7 @@ impl IDXGIFactory_Vtbl {
#[doc = "Required features: `\"Win32_Foundation\"`, `\"Win32_Graphics_Dxgi_Common\"`"]
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Dxgi_Common"))]
pub trait IDXGIFactory1_Impl: Sized + IDXGIFactory_Impl {
fn EnumAdapters1(&self, adapter: u32) -> ::windows_core::Result<IDXGIAdapter1>;
fn EnumAdapters1(&self, adapter: u32, ppadapter: *mut ::core::option::Option<IDXGIAdapter1>) -> ::windows_core::HRESULT;
fn IsCurrent(&self) -> super::super::Foundation::BOOL;
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Dxgi_Common"))]
Expand All @@ -652,13 +646,7 @@ impl IDXGIFactory1_Vtbl {
unsafe extern "system" fn EnumAdapters1<Identity: ::windows_core::IUnknownImpl<Impl = Impl>, Impl: IDXGIFactory1_Impl, const OFFSET: isize>(this: *mut ::core::ffi::c_void, adapter: u32, ppadapter: *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();
match this.EnumAdapters1(::core::mem::transmute_copy(&adapter)) {
::core::result::Result::Ok(ok__) => {
::core::ptr::write(ppadapter, ::core::mem::transmute(ok__));
::windows_core::HRESULT(0)
}
::core::result::Result::Err(err) => err.into(),
}
this.EnumAdapters1(::core::mem::transmute_copy(&adapter), ::core::mem::transmute_copy(&ppadapter))
}
unsafe extern "system" fn IsCurrent<Identity: ::windows_core::IUnknownImpl<Impl = Impl>, Impl: IDXGIFactory1_Impl, const OFFSET: isize>(this: *mut ::core::ffi::c_void) -> super::super::Foundation::BOOL {
let this = (this as *const *const ()).offset(OFFSET) as *const Identity;
Expand Down
Loading

0 comments on commit 7c5c16f

Please sign in to comment.