Skip to content

Commit 2542ec7

Browse files
authored
Improve enum code gen (#1457)
1 parent e1d2ed8 commit 2542ec7

File tree

107 files changed

+70
-18062
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+70
-18062
lines changed

crates/libs/bindgen/src/handles.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ pub fn gen_win_handle(def: &TypeDef, gen: &Gen) -> TokenStream {
7979
}
8080

8181
fn gen_signature(def: &TypeDef, gen: &Gen) -> TokenStream {
82-
if def.type_name() == TypeName::HANDLE {
83-
quote! { *mut ::core::ffi::c_void }
84-
} else {
85-
let signature = def.fields().next().map(|field| field.signature(Some(def))).unwrap();
86-
gen_sig(&signature, gen)
87-
}
82+
let signature = def.fields().next().map(|field| field.signature(Some(def))).unwrap();
83+
gen_sig(&signature, gen)
8884
}

crates/libs/reader/src/tables/type_def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl TypeDef {
430430
pub fn has_flags(&self) -> bool {
431431
// Win32 enums use the Flags attribute. WinRT enums don't have the Flags attribute but are paritioned merely based
432432
// on whether they are signed.
433-
self.has_attribute("FlagsAttribute") || self.underlying_type() == ElementType::U32
433+
self.has_attribute("FlagsAttribute") || (self.is_winrt() && self.underlying_type() == ElementType::U32)
434434
}
435435

436436
pub fn is_exclusive(&self) -> bool {

crates/libs/sys/src/Windows/Win32/Foundation/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3397,7 +3397,7 @@ pub const GCN_E_NO_REQUEST_HANDLERS: ::windows_sys::core::HRESULT = -2143616990i
33973397
pub const GCN_E_REQUEST_UNSUPPORTED: ::windows_sys::core::HRESULT = -2143616989i32;
33983398
#[doc = "*Required features: 'Win32_Foundation'*"]
33993399
pub const GCN_E_RUNTIMEKEYS_FAILED: ::windows_sys::core::HRESULT = -2143616988i32;
3400-
pub type HANDLE = *mut ::core::ffi::c_void;
3400+
pub type HANDLE = isize;
34013401
#[doc = "*Required features: 'Win32_Foundation'*"]
34023402
pub type HANDLE_FLAGS = u32;
34033403
#[doc = "*Required features: 'Win32_Foundation'*"]

crates/libs/windows/src/Windows/Win32/AI/MachineLearning/WinML/mod.rs

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,34 +1465,6 @@ impl ::core::fmt::Debug for MLOperatorAttributeType {
14651465
f.debug_tuple("MLOperatorAttributeType").field(&self.0).finish()
14661466
}
14671467
}
1468-
impl ::core::ops::BitOr for MLOperatorAttributeType {
1469-
type Output = Self;
1470-
fn bitor(self, other: Self) -> Self {
1471-
Self(self.0 | other.0)
1472-
}
1473-
}
1474-
impl ::core::ops::BitAnd for MLOperatorAttributeType {
1475-
type Output = Self;
1476-
fn bitand(self, other: Self) -> Self {
1477-
Self(self.0 & other.0)
1478-
}
1479-
}
1480-
impl ::core::ops::BitOrAssign for MLOperatorAttributeType {
1481-
fn bitor_assign(&mut self, other: Self) {
1482-
self.0.bitor_assign(other.0)
1483-
}
1484-
}
1485-
impl ::core::ops::BitAndAssign for MLOperatorAttributeType {
1486-
fn bitand_assign(&mut self, other: Self) {
1487-
self.0.bitand_assign(other.0)
1488-
}
1489-
}
1490-
impl ::core::ops::Not for MLOperatorAttributeType {
1491-
type Output = Self;
1492-
fn not(self) -> Self {
1493-
Self(self.0.not())
1494-
}
1495-
}
14961468
#[repr(C)]
14971469
#[doc = "*Required features: 'Win32_AI_MachineLearning_WinML'*"]
14981470
pub struct MLOperatorEdgeDescription {
@@ -1572,34 +1544,6 @@ impl ::core::fmt::Debug for MLOperatorEdgeType {
15721544
f.debug_tuple("MLOperatorEdgeType").field(&self.0).finish()
15731545
}
15741546
}
1575-
impl ::core::ops::BitOr for MLOperatorEdgeType {
1576-
type Output = Self;
1577-
fn bitor(self, other: Self) -> Self {
1578-
Self(self.0 | other.0)
1579-
}
1580-
}
1581-
impl ::core::ops::BitAnd for MLOperatorEdgeType {
1582-
type Output = Self;
1583-
fn bitand(self, other: Self) -> Self {
1584-
Self(self.0 & other.0)
1585-
}
1586-
}
1587-
impl ::core::ops::BitOrAssign for MLOperatorEdgeType {
1588-
fn bitor_assign(&mut self, other: Self) {
1589-
self.0.bitor_assign(other.0)
1590-
}
1591-
}
1592-
impl ::core::ops::BitAndAssign for MLOperatorEdgeType {
1593-
fn bitand_assign(&mut self, other: Self) {
1594-
self.0.bitand_assign(other.0)
1595-
}
1596-
}
1597-
impl ::core::ops::Not for MLOperatorEdgeType {
1598-
type Output = Self;
1599-
fn not(self) -> Self {
1600-
Self(self.0.not())
1601-
}
1602-
}
16031547
#[repr(C)]
16041548
#[doc = "*Required features: 'Win32_AI_MachineLearning_WinML', 'Win32_Foundation'*"]
16051549
#[cfg(feature = "Win32_Foundation")]
@@ -1668,34 +1612,6 @@ impl ::core::fmt::Debug for MLOperatorExecutionType {
16681612
f.debug_tuple("MLOperatorExecutionType").field(&self.0).finish()
16691613
}
16701614
}
1671-
impl ::core::ops::BitOr for MLOperatorExecutionType {
1672-
type Output = Self;
1673-
fn bitor(self, other: Self) -> Self {
1674-
Self(self.0 | other.0)
1675-
}
1676-
}
1677-
impl ::core::ops::BitAnd for MLOperatorExecutionType {
1678-
type Output = Self;
1679-
fn bitand(self, other: Self) -> Self {
1680-
Self(self.0 & other.0)
1681-
}
1682-
}
1683-
impl ::core::ops::BitOrAssign for MLOperatorExecutionType {
1684-
fn bitor_assign(&mut self, other: Self) {
1685-
self.0.bitor_assign(other.0)
1686-
}
1687-
}
1688-
impl ::core::ops::BitAndAssign for MLOperatorExecutionType {
1689-
fn bitand_assign(&mut self, other: Self) {
1690-
self.0.bitand_assign(other.0)
1691-
}
1692-
}
1693-
impl ::core::ops::Not for MLOperatorExecutionType {
1694-
type Output = Self;
1695-
fn not(self) -> Self {
1696-
Self(self.0.not())
1697-
}
1698-
}
16991615
#[repr(C)]
17001616
#[doc = "*Required features: 'Win32_AI_MachineLearning_WinML', 'Win32_Foundation'*"]
17011617
#[cfg(feature = "Win32_Foundation")]
@@ -2102,34 +2018,6 @@ impl ::core::fmt::Debug for MLOperatorTensorDataType {
21022018
f.debug_tuple("MLOperatorTensorDataType").field(&self.0).finish()
21032019
}
21042020
}
2105-
impl ::core::ops::BitOr for MLOperatorTensorDataType {
2106-
type Output = Self;
2107-
fn bitor(self, other: Self) -> Self {
2108-
Self(self.0 | other.0)
2109-
}
2110-
}
2111-
impl ::core::ops::BitAnd for MLOperatorTensorDataType {
2112-
type Output = Self;
2113-
fn bitand(self, other: Self) -> Self {
2114-
Self(self.0 & other.0)
2115-
}
2116-
}
2117-
impl ::core::ops::BitOrAssign for MLOperatorTensorDataType {
2118-
fn bitor_assign(&mut self, other: Self) {
2119-
self.0.bitor_assign(other.0)
2120-
}
2121-
}
2122-
impl ::core::ops::BitAndAssign for MLOperatorTensorDataType {
2123-
fn bitand_assign(&mut self, other: Self) {
2124-
self.0.bitand_assign(other.0)
2125-
}
2126-
}
2127-
impl ::core::ops::Not for MLOperatorTensorDataType {
2128-
type Output = Self;
2129-
fn not(self) -> Self {
2130-
Self(self.0.not())
2131-
}
2132-
}
21332021
#[repr(C)]
21342022
#[doc = "*Required features: 'Win32_AI_MachineLearning_WinML', 'Win32_Foundation', 'Win32_Graphics_Direct3D12'*"]
21352023
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Direct3D12"))]

crates/libs/windows/src/Windows/Win32/Data/Xml/MsXml/mod.rs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -20659,34 +20659,6 @@ impl ::core::fmt::Debug for XHR_CERT_ERROR_FLAG {
2065920659
f.debug_tuple("XHR_CERT_ERROR_FLAG").field(&self.0).finish()
2066020660
}
2066120661
}
20662-
impl ::core::ops::BitOr for XHR_CERT_ERROR_FLAG {
20663-
type Output = Self;
20664-
fn bitor(self, other: Self) -> Self {
20665-
Self(self.0 | other.0)
20666-
}
20667-
}
20668-
impl ::core::ops::BitAnd for XHR_CERT_ERROR_FLAG {
20669-
type Output = Self;
20670-
fn bitand(self, other: Self) -> Self {
20671-
Self(self.0 & other.0)
20672-
}
20673-
}
20674-
impl ::core::ops::BitOrAssign for XHR_CERT_ERROR_FLAG {
20675-
fn bitor_assign(&mut self, other: Self) {
20676-
self.0.bitor_assign(other.0)
20677-
}
20678-
}
20679-
impl ::core::ops::BitAndAssign for XHR_CERT_ERROR_FLAG {
20680-
fn bitand_assign(&mut self, other: Self) {
20681-
self.0.bitand_assign(other.0)
20682-
}
20683-
}
20684-
impl ::core::ops::Not for XHR_CERT_ERROR_FLAG {
20685-
type Output = Self;
20686-
fn not(self) -> Self {
20687-
Self(self.0.not())
20688-
}
20689-
}
2069020662
#[doc = "*Required features: 'Win32_Data_Xml_MsXml'*"]
2069120663
#[repr(transparent)]
2069220664
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)]
@@ -20720,34 +20692,6 @@ impl ::core::fmt::Debug for XHR_CERT_IGNORE_FLAG {
2072020692
f.debug_tuple("XHR_CERT_IGNORE_FLAG").field(&self.0).finish()
2072120693
}
2072220694
}
20723-
impl ::core::ops::BitOr for XHR_CERT_IGNORE_FLAG {
20724-
type Output = Self;
20725-
fn bitor(self, other: Self) -> Self {
20726-
Self(self.0 | other.0)
20727-
}
20728-
}
20729-
impl ::core::ops::BitAnd for XHR_CERT_IGNORE_FLAG {
20730-
type Output = Self;
20731-
fn bitand(self, other: Self) -> Self {
20732-
Self(self.0 & other.0)
20733-
}
20734-
}
20735-
impl ::core::ops::BitOrAssign for XHR_CERT_IGNORE_FLAG {
20736-
fn bitor_assign(&mut self, other: Self) {
20737-
self.0.bitor_assign(other.0)
20738-
}
20739-
}
20740-
impl ::core::ops::BitAndAssign for XHR_CERT_IGNORE_FLAG {
20741-
fn bitand_assign(&mut self, other: Self) {
20742-
self.0.bitand_assign(other.0)
20743-
}
20744-
}
20745-
impl ::core::ops::Not for XHR_CERT_IGNORE_FLAG {
20746-
type Output = Self;
20747-
fn not(self) -> Self {
20748-
Self(self.0.not())
20749-
}
20750-
}
2075120695
#[repr(C)]
2075220696
#[doc = "*Required features: 'Win32_Data_Xml_MsXml', 'Win32_Foundation'*"]
2075320697
#[cfg(feature = "Win32_Foundation")]

crates/libs/windows/src/Windows/Win32/Devices/BiometricFramework/mod.rs

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,34 +1856,6 @@ impl ::core::fmt::Debug for WINBIO_COMPONENT {
18561856
f.debug_tuple("WINBIO_COMPONENT").field(&self.0).finish()
18571857
}
18581858
}
1859-
impl ::core::ops::BitOr for WINBIO_COMPONENT {
1860-
type Output = Self;
1861-
fn bitor(self, other: Self) -> Self {
1862-
Self(self.0 | other.0)
1863-
}
1864-
}
1865-
impl ::core::ops::BitAnd for WINBIO_COMPONENT {
1866-
type Output = Self;
1867-
fn bitand(self, other: Self) -> Self {
1868-
Self(self.0 & other.0)
1869-
}
1870-
}
1871-
impl ::core::ops::BitOrAssign for WINBIO_COMPONENT {
1872-
fn bitor_assign(&mut self, other: Self) {
1873-
self.0.bitor_assign(other.0)
1874-
}
1875-
}
1876-
impl ::core::ops::BitAndAssign for WINBIO_COMPONENT {
1877-
fn bitand_assign(&mut self, other: Self) {
1878-
self.0.bitand_assign(other.0)
1879-
}
1880-
}
1881-
impl ::core::ops::Not for WINBIO_COMPONENT {
1882-
type Output = Self;
1883-
fn not(self) -> Self {
1884-
Self(self.0.not())
1885-
}
1886-
}
18871859
#[doc = "*Required features: 'Win32_Devices_BiometricFramework'*"]
18881860
#[repr(transparent)]
18891861
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)]
@@ -4121,34 +4093,6 @@ impl ::core::fmt::Debug for WINBIO_POOL {
41214093
f.debug_tuple("WINBIO_POOL").field(&self.0).finish()
41224094
}
41234095
}
4124-
impl ::core::ops::BitOr for WINBIO_POOL {
4125-
type Output = Self;
4126-
fn bitor(self, other: Self) -> Self {
4127-
Self(self.0 | other.0)
4128-
}
4129-
}
4130-
impl ::core::ops::BitAnd for WINBIO_POOL {
4131-
type Output = Self;
4132-
fn bitand(self, other: Self) -> Self {
4133-
Self(self.0 & other.0)
4134-
}
4135-
}
4136-
impl ::core::ops::BitOrAssign for WINBIO_POOL {
4137-
fn bitor_assign(&mut self, other: Self) {
4138-
self.0.bitor_assign(other.0)
4139-
}
4140-
}
4141-
impl ::core::ops::BitAndAssign for WINBIO_POOL {
4142-
fn bitand_assign(&mut self, other: Self) {
4143-
self.0.bitand_assign(other.0)
4144-
}
4145-
}
4146-
impl ::core::ops::Not for WINBIO_POOL {
4147-
type Output = Self;
4148-
fn not(self) -> Self {
4149-
Self(self.0.not())
4150-
}
4151-
}
41524096
#[repr(C)]
41534097
#[doc = "*Required features: 'Win32_Devices_BiometricFramework', 'Win32_Foundation'*"]
41544098
#[cfg(feature = "Win32_Foundation")]
@@ -4786,34 +4730,6 @@ impl ::core::fmt::Debug for WINBIO_SETTING_SOURCE {
47864730
f.debug_tuple("WINBIO_SETTING_SOURCE").field(&self.0).finish()
47874731
}
47884732
}
4789-
impl ::core::ops::BitOr for WINBIO_SETTING_SOURCE {
4790-
type Output = Self;
4791-
fn bitor(self, other: Self) -> Self {
4792-
Self(self.0 | other.0)
4793-
}
4794-
}
4795-
impl ::core::ops::BitAnd for WINBIO_SETTING_SOURCE {
4796-
type Output = Self;
4797-
fn bitand(self, other: Self) -> Self {
4798-
Self(self.0 & other.0)
4799-
}
4800-
}
4801-
impl ::core::ops::BitOrAssign for WINBIO_SETTING_SOURCE {
4802-
fn bitor_assign(&mut self, other: Self) {
4803-
self.0.bitor_assign(other.0)
4804-
}
4805-
}
4806-
impl ::core::ops::BitAndAssign for WINBIO_SETTING_SOURCE {
4807-
fn bitand_assign(&mut self, other: Self) {
4808-
self.0.bitand_assign(other.0)
4809-
}
4810-
}
4811-
impl ::core::ops::Not for WINBIO_SETTING_SOURCE {
4812-
type Output = Self;
4813-
fn not(self) -> Self {
4814-
Self(self.0.not())
4815-
}
4816-
}
48174733
#[repr(C)]
48184734
#[doc = "*Required features: 'Win32_Devices_BiometricFramework'*"]
48194735
pub struct WINBIO_SET_INDICATOR {

0 commit comments

Comments
 (0)