Skip to content

Commit

Permalink
Transform BOOL and Win32 return values (#2476)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Apr 26, 2023
1 parent 311b080 commit 97efa32
Show file tree
Hide file tree
Showing 93 changed files with 5,360 additions and 5,346 deletions.
13 changes: 13 additions & 0 deletions crates/libs/metadata/src/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,13 @@ impl<'a> Reader<'a> {
};
self.module_ref_name(self.impl_map_scope(impl_map)).to_lowercase()
}
pub fn method_def_last_error(&self, row: MethodDef) -> bool {
if let Some(map) = self.method_def_impl_map(row) {
self.impl_map_flags(map).contains(PInvokeAttributes::LAST_ERROR)
} else {
false
}
}
pub fn method_def_signature(&self, row: MethodDef, generics: &[Type]) -> Signature {
let mut blob = self.row_blob(row.0, 4);
let vararg = blob.read_usize() == 0x05;
Expand Down Expand Up @@ -1437,6 +1444,12 @@ impl<'a> Reader<'a> {
Type::TypeDef((def, _)) if self.type_def_type_name(*def) == TypeName::NTSTATUS => {
return SignatureKind::ResultVoid;
}
Type::TypeDef((def, _)) if self.type_def_type_name(*def) == TypeName::WIN32_ERROR => {
return SignatureKind::ResultVoid;
}
Type::TypeDef((def, _)) if self.type_def_type_name(*def) == TypeName::BOOL && self.method_def_last_error(signature.def) => {
return SignatureKind::ResultVoid;
}
_ if self.type_is_struct(return_type) => {
return SignatureKind::ReturnStruct;
}
Expand Down
2 changes: 2 additions & 0 deletions crates/libs/metadata/src/reader/type_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ impl<'a> TypeName<'a> {
pub const HANDLE: Self = Self::from_const("Windows.Win32.Foundation", "HANDLE");
pub const HRESULT: Self = Self::from_const("Windows.Win32.Foundation", "HRESULT");
pub const CHAR: Self = Self::from_const("Windows.Win32.Foundation", "CHAR");
pub const BOOL: Self = Self::from_const("Windows.Win32.Foundation", "BOOL");
pub const WIN32_ERROR: Self = Self::from_const("Windows.Win32.Foundation", "WIN32_ERROR");

pub const D2D_MATRIX_3X2_F: Self = Self::from_const("Windows.Win32.Graphics.Direct2D.Common", "D2D_MATRIX_3X2_F");
pub const D3DMATRIX: Self = Self::from_const("Windows.Win32.Graphics.Direct3D", "D3DMATRIX");
Expand Down
95 changes: 48 additions & 47 deletions crates/libs/windows/src/Windows/Wdk/System/OfflineRegistry/mod.rs

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions crates/libs/windows/src/Windows/Win32/Devices/AllJoyn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ where
#[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn AllJoynCloseBusHandle<P0>(bushandle: P0) -> super::super::Foundation::BOOL
pub unsafe fn AllJoynCloseBusHandle<P0>(bushandle: P0) -> ::windows_core::Result<()>
where
P0: ::windows_core::IntoParam<super::super::Foundation::HANDLE>,
{
::windows_targets::link!("msajapi.dll" "system" fn AllJoynCloseBusHandle(bushandle : super::super::Foundation:: HANDLE) -> super::super::Foundation:: BOOL);
AllJoynCloseBusHandle(bushandle.into_param().abi())
AllJoynCloseBusHandle(bushandle.into_param().abi()).ok()
}
#[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
Expand All @@ -40,44 +40,44 @@ pub unsafe fn AllJoynCreateBus(outbuffersize: u32, inbuffersize: u32, lpsecurity
#[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn AllJoynEnumEvents<P0, P1>(connectedbushandle: P0, eventtoreset: P1, eventtypes: *mut u32) -> super::super::Foundation::BOOL
pub unsafe fn AllJoynEnumEvents<P0, P1>(connectedbushandle: P0, eventtoreset: P1, eventtypes: *mut u32) -> ::windows_core::Result<()>
where
P0: ::windows_core::IntoParam<super::super::Foundation::HANDLE>,
P1: ::windows_core::IntoParam<super::super::Foundation::HANDLE>,
{
::windows_targets::link!("msajapi.dll" "system" fn AllJoynEnumEvents(connectedbushandle : super::super::Foundation:: HANDLE, eventtoreset : super::super::Foundation:: HANDLE, eventtypes : *mut u32) -> super::super::Foundation:: BOOL);
AllJoynEnumEvents(connectedbushandle.into_param().abi(), eventtoreset.into_param().abi(), eventtypes)
AllJoynEnumEvents(connectedbushandle.into_param().abi(), eventtoreset.into_param().abi(), eventtypes).ok()
}
#[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn AllJoynEventSelect<P0, P1>(connectedbushandle: P0, eventhandle: P1, eventtypes: u32) -> super::super::Foundation::BOOL
pub unsafe fn AllJoynEventSelect<P0, P1>(connectedbushandle: P0, eventhandle: P1, eventtypes: u32) -> ::windows_core::Result<()>
where
P0: ::windows_core::IntoParam<super::super::Foundation::HANDLE>,
P1: ::windows_core::IntoParam<super::super::Foundation::HANDLE>,
{
::windows_targets::link!("msajapi.dll" "system" fn AllJoynEventSelect(connectedbushandle : super::super::Foundation:: HANDLE, eventhandle : super::super::Foundation:: HANDLE, eventtypes : u32) -> super::super::Foundation:: BOOL);
AllJoynEventSelect(connectedbushandle.into_param().abi(), eventhandle.into_param().abi(), eventtypes)
AllJoynEventSelect(connectedbushandle.into_param().abi(), eventhandle.into_param().abi(), eventtypes).ok()
}
#[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn AllJoynReceiveFromBus<P0>(connectedbushandle: P0, buffer: ::core::option::Option<*mut ::core::ffi::c_void>, bytestoread: u32, bytestransferred: ::core::option::Option<*mut u32>, reserved: *mut ::core::ffi::c_void) -> super::super::Foundation::BOOL
pub unsafe fn AllJoynReceiveFromBus<P0>(connectedbushandle: P0, buffer: ::core::option::Option<*mut ::core::ffi::c_void>, bytestoread: u32, bytestransferred: ::core::option::Option<*mut u32>, reserved: *mut ::core::ffi::c_void) -> ::windows_core::Result<()>
where
P0: ::windows_core::IntoParam<super::super::Foundation::HANDLE>,
{
::windows_targets::link!("msajapi.dll" "system" fn AllJoynReceiveFromBus(connectedbushandle : super::super::Foundation:: HANDLE, buffer : *mut ::core::ffi::c_void, bytestoread : u32, bytestransferred : *mut u32, reserved : *mut ::core::ffi::c_void) -> super::super::Foundation:: BOOL);
AllJoynReceiveFromBus(connectedbushandle.into_param().abi(), ::core::mem::transmute(buffer.unwrap_or(::std::ptr::null_mut())), bytestoread, ::core::mem::transmute(bytestransferred.unwrap_or(::std::ptr::null_mut())), reserved)
AllJoynReceiveFromBus(connectedbushandle.into_param().abi(), ::core::mem::transmute(buffer.unwrap_or(::std::ptr::null_mut())), bytestoread, ::core::mem::transmute(bytestransferred.unwrap_or(::std::ptr::null_mut())), reserved).ok()
}
#[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn AllJoynSendToBus<P0>(connectedbushandle: P0, buffer: ::core::option::Option<*const ::core::ffi::c_void>, bytestowrite: u32, bytestransferred: ::core::option::Option<*mut u32>, reserved: *mut ::core::ffi::c_void) -> super::super::Foundation::BOOL
pub unsafe fn AllJoynSendToBus<P0>(connectedbushandle: P0, buffer: ::core::option::Option<*const ::core::ffi::c_void>, bytestowrite: u32, bytestransferred: ::core::option::Option<*mut u32>, reserved: *mut ::core::ffi::c_void) -> ::windows_core::Result<()>
where
P0: ::windows_core::IntoParam<super::super::Foundation::HANDLE>,
{
::windows_targets::link!("msajapi.dll" "system" fn AllJoynSendToBus(connectedbushandle : super::super::Foundation:: HANDLE, buffer : *const ::core::ffi::c_void, bytestowrite : u32, bytestransferred : *mut u32, reserved : *mut ::core::ffi::c_void) -> super::super::Foundation:: BOOL);
AllJoynSendToBus(connectedbushandle.into_param().abi(), ::core::mem::transmute(buffer.unwrap_or(::std::ptr::null())), bytestowrite, ::core::mem::transmute(bytestransferred.unwrap_or(::std::ptr::null_mut())), reserved)
AllJoynSendToBus(connectedbushandle.into_param().abi(), ::core::mem::transmute(buffer.unwrap_or(::std::ptr::null())), bytestowrite, ::core::mem::transmute(bytestransferred.unwrap_or(::std::ptr::null_mut())), reserved).ok()
}
#[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"]
#[inline]
Expand Down
32 changes: 16 additions & 16 deletions crates/libs/windows/src/Windows/Win32/Devices/Bluetooth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ where
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn BluetoothDisplayDeviceProperties<P0>(hwndparent: P0, pbtdi: *mut BLUETOOTH_DEVICE_INFO) -> super::super::Foundation::BOOL
pub unsafe fn BluetoothDisplayDeviceProperties<P0>(hwndparent: P0, pbtdi: *mut BLUETOOTH_DEVICE_INFO) -> ::windows_core::Result<()>
where
P0: ::windows_core::IntoParam<super::super::Foundation::HWND>,
{
::windows_targets::link!("bthprops.cpl" "system" fn BluetoothDisplayDeviceProperties(hwndparent : super::super::Foundation:: HWND, pbtdi : *mut BLUETOOTH_DEVICE_INFO) -> super::super::Foundation:: BOOL);
BluetoothDisplayDeviceProperties(hwndparent.into_param().abi(), pbtdi)
BluetoothDisplayDeviceProperties(hwndparent.into_param().abi(), pbtdi).ok()
}
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
Expand Down Expand Up @@ -76,12 +76,12 @@ where
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn BluetoothFindDeviceClose<P0>(hfind: P0) -> super::super::Foundation::BOOL
pub unsafe fn BluetoothFindDeviceClose<P0>(hfind: P0) -> ::windows_core::Result<()>
where
P0: ::windows_core::IntoParam<HBLUETOOTH_DEVICE_FIND>,
{
::windows_targets::link!("bluetoothapis.dll" "system" fn BluetoothFindDeviceClose(hfind : HBLUETOOTH_DEVICE_FIND) -> super::super::Foundation:: BOOL);
BluetoothFindDeviceClose(hfind.into_param().abi())
BluetoothFindDeviceClose(hfind.into_param().abi()).ok()
}
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
Expand All @@ -102,32 +102,32 @@ pub unsafe fn BluetoothFindFirstRadio(pbtfrp: *const BLUETOOTH_FIND_RADIO_PARAMS
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn BluetoothFindNextDevice<P0>(hfind: P0, pbtdi: *mut BLUETOOTH_DEVICE_INFO) -> super::super::Foundation::BOOL
pub unsafe fn BluetoothFindNextDevice<P0>(hfind: P0, pbtdi: *mut BLUETOOTH_DEVICE_INFO) -> ::windows_core::Result<()>
where
P0: ::windows_core::IntoParam<HBLUETOOTH_DEVICE_FIND>,
{
::windows_targets::link!("bluetoothapis.dll" "system" fn BluetoothFindNextDevice(hfind : HBLUETOOTH_DEVICE_FIND, pbtdi : *mut BLUETOOTH_DEVICE_INFO) -> super::super::Foundation:: BOOL);
BluetoothFindNextDevice(hfind.into_param().abi(), pbtdi)
BluetoothFindNextDevice(hfind.into_param().abi(), pbtdi).ok()
}
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn BluetoothFindNextRadio<P0>(hfind: P0, phradio: *mut super::super::Foundation::HANDLE) -> super::super::Foundation::BOOL
pub unsafe fn BluetoothFindNextRadio<P0>(hfind: P0, phradio: *mut super::super::Foundation::HANDLE) -> ::windows_core::Result<()>
where
P0: ::windows_core::IntoParam<HBLUETOOTH_RADIO_FIND>,
{
::windows_targets::link!("bluetoothapis.dll" "system" fn BluetoothFindNextRadio(hfind : HBLUETOOTH_RADIO_FIND, phradio : *mut super::super::Foundation:: HANDLE) -> super::super::Foundation:: BOOL);
BluetoothFindNextRadio(hfind.into_param().abi(), phradio)
BluetoothFindNextRadio(hfind.into_param().abi(), phradio).ok()
}
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn BluetoothFindRadioClose<P0>(hfind: P0) -> super::super::Foundation::BOOL
pub unsafe fn BluetoothFindRadioClose<P0>(hfind: P0) -> ::windows_core::Result<()>
where
P0: ::windows_core::IntoParam<HBLUETOOTH_RADIO_FIND>,
{
::windows_targets::link!("bluetoothapis.dll" "system" fn BluetoothFindRadioClose(hfind : HBLUETOOTH_RADIO_FIND) -> super::super::Foundation:: BOOL);
BluetoothFindRadioClose(hfind.into_param().abi())
BluetoothFindRadioClose(hfind.into_param().abi()).ok()
}
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
Expand Down Expand Up @@ -325,9 +325,9 @@ pub unsafe fn BluetoothRemoveDevice(paddress: *const BLUETOOTH_ADDRESS) -> u32 {
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn BluetoothSdpEnumAttributes(psdpstream: &[u8], pfncallback: PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK, pvparam: *const ::core::ffi::c_void) -> super::super::Foundation::BOOL {
pub unsafe fn BluetoothSdpEnumAttributes(psdpstream: &[u8], pfncallback: PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK, pvparam: *const ::core::ffi::c_void) -> ::windows_core::Result<()> {
::windows_targets::link!("bluetoothapis.dll" "system" fn BluetoothSdpEnumAttributes(psdpstream : *const u8, cbstreamsize : u32, pfncallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK, pvparam : *const ::core::ffi::c_void) -> super::super::Foundation:: BOOL);
BluetoothSdpEnumAttributes(::core::mem::transmute(psdpstream.as_ptr()), psdpstream.len() as _, pfncallback, pvparam)
BluetoothSdpEnumAttributes(::core::mem::transmute(psdpstream.as_ptr()), psdpstream.len() as _, pfncallback, pvparam).ok()
}
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`*"]
#[inline]
Expand Down Expand Up @@ -356,9 +356,9 @@ pub unsafe fn BluetoothSdpGetString(precordstream: &[u8], pstringdata: ::core::o
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn BluetoothSelectDevices(pbtsdp: *mut BLUETOOTH_SELECT_DEVICE_PARAMS) -> super::super::Foundation::BOOL {
pub unsafe fn BluetoothSelectDevices(pbtsdp: *mut BLUETOOTH_SELECT_DEVICE_PARAMS) -> ::windows_core::Result<()> {
::windows_targets::link!("bthprops.cpl" "system" fn BluetoothSelectDevices(pbtsdp : *mut BLUETOOTH_SELECT_DEVICE_PARAMS) -> super::super::Foundation:: BOOL);
BluetoothSelectDevices(pbtsdp)
BluetoothSelectDevices(pbtsdp).ok()
}
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
Expand Down Expand Up @@ -411,9 +411,9 @@ where
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn BluetoothUnregisterAuthentication(hreghandle: isize) -> super::super::Foundation::BOOL {
pub unsafe fn BluetoothUnregisterAuthentication(hreghandle: isize) -> ::windows_core::Result<()> {
::windows_targets::link!("bluetoothapis.dll" "system" fn BluetoothUnregisterAuthentication(hreghandle : isize) -> super::super::Foundation:: BOOL);
BluetoothUnregisterAuthentication(hreghandle)
BluetoothUnregisterAuthentication(hreghandle).ok()
}
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
Expand Down
Loading

0 comments on commit 97efa32

Please sign in to comment.