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

Improve enum code gen #1457

Merged
merged 4 commits into from Jan 25, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions crates/libs/bindgen/src/handles.rs
Expand Up @@ -79,10 +79,6 @@ pub fn gen_win_handle(def: &TypeDef, gen: &Gen) -> TokenStream {
}

fn gen_signature(def: &TypeDef, gen: &Gen) -> TokenStream {
if def.type_name() == TypeName::HANDLE {
quote! { *mut ::core::ffi::c_void }
} else {
let signature = def.fields().next().map(|field| field.signature(Some(def))).unwrap();
gen_sig(&signature, gen)
}
let signature = def.fields().next().map(|field| field.signature(Some(def))).unwrap();
gen_sig(&signature, gen)
}
2 changes: 1 addition & 1 deletion crates/libs/reader/src/tables/type_def.rs
Expand Up @@ -430,7 +430,7 @@ impl TypeDef {
pub fn has_flags(&self) -> bool {
// Win32 enums use the Flags attribute. WinRT enums don't have the Flags attribute but are paritioned merely based
// on whether they are signed.
self.has_attribute("FlagsAttribute") || self.underlying_type() == ElementType::U32
self.has_attribute("FlagsAttribute") || (self.is_winrt() && self.underlying_type() == ElementType::U32)
}

pub fn is_exclusive(&self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/sys/src/Windows/Win32/Foundation/mod.rs
Expand Up @@ -3397,7 +3397,7 @@ pub const GCN_E_NO_REQUEST_HANDLERS: ::windows_sys::core::HRESULT = -2143616990i
pub const GCN_E_REQUEST_UNSUPPORTED: ::windows_sys::core::HRESULT = -2143616989i32;
#[doc = "*Required features: 'Win32_Foundation'*"]
pub const GCN_E_RUNTIMEKEYS_FAILED: ::windows_sys::core::HRESULT = -2143616988i32;
pub type HANDLE = *mut ::core::ffi::c_void;
pub type HANDLE = isize;
#[doc = "*Required features: 'Win32_Foundation'*"]
pub type HANDLE_FLAGS = u32;
#[doc = "*Required features: 'Win32_Foundation'*"]
Expand Down
112 changes: 0 additions & 112 deletions crates/libs/windows/src/Windows/Win32/AI/MachineLearning/WinML/mod.rs
Expand Up @@ -1465,34 +1465,6 @@ impl ::core::fmt::Debug for MLOperatorAttributeType {
f.debug_tuple("MLOperatorAttributeType").field(&self.0).finish()
}
}
impl ::core::ops::BitOr for MLOperatorAttributeType {
type Output = Self;
fn bitor(self, other: Self) -> Self {
Self(self.0 | other.0)
}
}
impl ::core::ops::BitAnd for MLOperatorAttributeType {
type Output = Self;
fn bitand(self, other: Self) -> Self {
Self(self.0 & other.0)
}
}
impl ::core::ops::BitOrAssign for MLOperatorAttributeType {
fn bitor_assign(&mut self, other: Self) {
self.0.bitor_assign(other.0)
}
}
impl ::core::ops::BitAndAssign for MLOperatorAttributeType {
fn bitand_assign(&mut self, other: Self) {
self.0.bitand_assign(other.0)
}
}
impl ::core::ops::Not for MLOperatorAttributeType {
type Output = Self;
fn not(self) -> Self {
Self(self.0.not())
}
}
#[repr(C)]
#[doc = "*Required features: 'Win32_AI_MachineLearning_WinML'*"]
pub struct MLOperatorEdgeDescription {
Expand Down Expand Up @@ -1572,34 +1544,6 @@ impl ::core::fmt::Debug for MLOperatorEdgeType {
f.debug_tuple("MLOperatorEdgeType").field(&self.0).finish()
}
}
impl ::core::ops::BitOr for MLOperatorEdgeType {
type Output = Self;
fn bitor(self, other: Self) -> Self {
Self(self.0 | other.0)
}
}
impl ::core::ops::BitAnd for MLOperatorEdgeType {
type Output = Self;
fn bitand(self, other: Self) -> Self {
Self(self.0 & other.0)
}
}
impl ::core::ops::BitOrAssign for MLOperatorEdgeType {
fn bitor_assign(&mut self, other: Self) {
self.0.bitor_assign(other.0)
}
}
impl ::core::ops::BitAndAssign for MLOperatorEdgeType {
fn bitand_assign(&mut self, other: Self) {
self.0.bitand_assign(other.0)
}
}
impl ::core::ops::Not for MLOperatorEdgeType {
type Output = Self;
fn not(self) -> Self {
Self(self.0.not())
}
}
#[repr(C)]
#[doc = "*Required features: 'Win32_AI_MachineLearning_WinML', 'Win32_Foundation'*"]
#[cfg(feature = "Win32_Foundation")]
Expand Down Expand Up @@ -1668,34 +1612,6 @@ impl ::core::fmt::Debug for MLOperatorExecutionType {
f.debug_tuple("MLOperatorExecutionType").field(&self.0).finish()
}
}
impl ::core::ops::BitOr for MLOperatorExecutionType {
type Output = Self;
fn bitor(self, other: Self) -> Self {
Self(self.0 | other.0)
}
}
impl ::core::ops::BitAnd for MLOperatorExecutionType {
type Output = Self;
fn bitand(self, other: Self) -> Self {
Self(self.0 & other.0)
}
}
impl ::core::ops::BitOrAssign for MLOperatorExecutionType {
fn bitor_assign(&mut self, other: Self) {
self.0.bitor_assign(other.0)
}
}
impl ::core::ops::BitAndAssign for MLOperatorExecutionType {
fn bitand_assign(&mut self, other: Self) {
self.0.bitand_assign(other.0)
}
}
impl ::core::ops::Not for MLOperatorExecutionType {
type Output = Self;
fn not(self) -> Self {
Self(self.0.not())
}
}
#[repr(C)]
#[doc = "*Required features: 'Win32_AI_MachineLearning_WinML', 'Win32_Foundation'*"]
#[cfg(feature = "Win32_Foundation")]
Expand Down Expand Up @@ -2102,34 +2018,6 @@ impl ::core::fmt::Debug for MLOperatorTensorDataType {
f.debug_tuple("MLOperatorTensorDataType").field(&self.0).finish()
}
}
impl ::core::ops::BitOr for MLOperatorTensorDataType {
type Output = Self;
fn bitor(self, other: Self) -> Self {
Self(self.0 | other.0)
}
}
impl ::core::ops::BitAnd for MLOperatorTensorDataType {
type Output = Self;
fn bitand(self, other: Self) -> Self {
Self(self.0 & other.0)
}
}
impl ::core::ops::BitOrAssign for MLOperatorTensorDataType {
fn bitor_assign(&mut self, other: Self) {
self.0.bitor_assign(other.0)
}
}
impl ::core::ops::BitAndAssign for MLOperatorTensorDataType {
fn bitand_assign(&mut self, other: Self) {
self.0.bitand_assign(other.0)
}
}
impl ::core::ops::Not for MLOperatorTensorDataType {
type Output = Self;
fn not(self) -> Self {
Self(self.0.not())
}
}
#[repr(C)]
#[doc = "*Required features: 'Win32_AI_MachineLearning_WinML', 'Win32_Foundation', 'Win32_Graphics_Direct3D12'*"]
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Direct3D12"))]
Expand Down
56 changes: 0 additions & 56 deletions crates/libs/windows/src/Windows/Win32/Data/Xml/MsXml/mod.rs
Expand Up @@ -20659,34 +20659,6 @@ impl ::core::fmt::Debug for XHR_CERT_ERROR_FLAG {
f.debug_tuple("XHR_CERT_ERROR_FLAG").field(&self.0).finish()
}
}
impl ::core::ops::BitOr for XHR_CERT_ERROR_FLAG {
type Output = Self;
fn bitor(self, other: Self) -> Self {
Self(self.0 | other.0)
}
}
impl ::core::ops::BitAnd for XHR_CERT_ERROR_FLAG {
type Output = Self;
fn bitand(self, other: Self) -> Self {
Self(self.0 & other.0)
}
}
impl ::core::ops::BitOrAssign for XHR_CERT_ERROR_FLAG {
fn bitor_assign(&mut self, other: Self) {
self.0.bitor_assign(other.0)
}
}
impl ::core::ops::BitAndAssign for XHR_CERT_ERROR_FLAG {
fn bitand_assign(&mut self, other: Self) {
self.0.bitand_assign(other.0)
}
}
impl ::core::ops::Not for XHR_CERT_ERROR_FLAG {
type Output = Self;
fn not(self) -> Self {
Self(self.0.not())
}
}
#[doc = "*Required features: 'Win32_Data_Xml_MsXml'*"]
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)]
Expand Down Expand Up @@ -20720,34 +20692,6 @@ impl ::core::fmt::Debug for XHR_CERT_IGNORE_FLAG {
f.debug_tuple("XHR_CERT_IGNORE_FLAG").field(&self.0).finish()
}
}
impl ::core::ops::BitOr for XHR_CERT_IGNORE_FLAG {
type Output = Self;
fn bitor(self, other: Self) -> Self {
Self(self.0 | other.0)
}
}
impl ::core::ops::BitAnd for XHR_CERT_IGNORE_FLAG {
type Output = Self;
fn bitand(self, other: Self) -> Self {
Self(self.0 & other.0)
}
}
impl ::core::ops::BitOrAssign for XHR_CERT_IGNORE_FLAG {
fn bitor_assign(&mut self, other: Self) {
self.0.bitor_assign(other.0)
}
}
impl ::core::ops::BitAndAssign for XHR_CERT_IGNORE_FLAG {
fn bitand_assign(&mut self, other: Self) {
self.0.bitand_assign(other.0)
}
}
impl ::core::ops::Not for XHR_CERT_IGNORE_FLAG {
type Output = Self;
fn not(self) -> Self {
Self(self.0.not())
}
}
#[repr(C)]
#[doc = "*Required features: 'Win32_Data_Xml_MsXml', 'Win32_Foundation'*"]
#[cfg(feature = "Win32_Foundation")]
Expand Down
Expand Up @@ -1856,34 +1856,6 @@ impl ::core::fmt::Debug for WINBIO_COMPONENT {
f.debug_tuple("WINBIO_COMPONENT").field(&self.0).finish()
}
}
impl ::core::ops::BitOr for WINBIO_COMPONENT {
type Output = Self;
fn bitor(self, other: Self) -> Self {
Self(self.0 | other.0)
}
}
impl ::core::ops::BitAnd for WINBIO_COMPONENT {
type Output = Self;
fn bitand(self, other: Self) -> Self {
Self(self.0 & other.0)
}
}
impl ::core::ops::BitOrAssign for WINBIO_COMPONENT {
fn bitor_assign(&mut self, other: Self) {
self.0.bitor_assign(other.0)
}
}
impl ::core::ops::BitAndAssign for WINBIO_COMPONENT {
fn bitand_assign(&mut self, other: Self) {
self.0.bitand_assign(other.0)
}
}
impl ::core::ops::Not for WINBIO_COMPONENT {
type Output = Self;
fn not(self) -> Self {
Self(self.0.not())
}
}
#[doc = "*Required features: 'Win32_Devices_BiometricFramework'*"]
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)]
Expand Down Expand Up @@ -4121,34 +4093,6 @@ impl ::core::fmt::Debug for WINBIO_POOL {
f.debug_tuple("WINBIO_POOL").field(&self.0).finish()
}
}
impl ::core::ops::BitOr for WINBIO_POOL {
type Output = Self;
fn bitor(self, other: Self) -> Self {
Self(self.0 | other.0)
}
}
impl ::core::ops::BitAnd for WINBIO_POOL {
type Output = Self;
fn bitand(self, other: Self) -> Self {
Self(self.0 & other.0)
}
}
impl ::core::ops::BitOrAssign for WINBIO_POOL {
fn bitor_assign(&mut self, other: Self) {
self.0.bitor_assign(other.0)
}
}
impl ::core::ops::BitAndAssign for WINBIO_POOL {
fn bitand_assign(&mut self, other: Self) {
self.0.bitand_assign(other.0)
}
}
impl ::core::ops::Not for WINBIO_POOL {
type Output = Self;
fn not(self) -> Self {
Self(self.0.not())
}
}
#[repr(C)]
#[doc = "*Required features: 'Win32_Devices_BiometricFramework', 'Win32_Foundation'*"]
#[cfg(feature = "Win32_Foundation")]
Expand Down Expand Up @@ -4786,34 +4730,6 @@ impl ::core::fmt::Debug for WINBIO_SETTING_SOURCE {
f.debug_tuple("WINBIO_SETTING_SOURCE").field(&self.0).finish()
}
}
impl ::core::ops::BitOr for WINBIO_SETTING_SOURCE {
type Output = Self;
fn bitor(self, other: Self) -> Self {
Self(self.0 | other.0)
}
}
impl ::core::ops::BitAnd for WINBIO_SETTING_SOURCE {
type Output = Self;
fn bitand(self, other: Self) -> Self {
Self(self.0 & other.0)
}
}
impl ::core::ops::BitOrAssign for WINBIO_SETTING_SOURCE {
fn bitor_assign(&mut self, other: Self) {
self.0.bitor_assign(other.0)
}
}
impl ::core::ops::BitAndAssign for WINBIO_SETTING_SOURCE {
fn bitand_assign(&mut self, other: Self) {
self.0.bitand_assign(other.0)
}
}
impl ::core::ops::Not for WINBIO_SETTING_SOURCE {
type Output = Self;
fn not(self) -> Self {
Self(self.0.not())
}
}
#[repr(C)]
#[doc = "*Required features: 'Win32_Devices_BiometricFramework'*"]
pub struct WINBIO_SET_INDICATOR {
Expand Down