diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
commit | 9918693037dce8aa4bb6f08741b6812923486c18 (patch) | |
tree | 21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/windows-bindgen/src/rust/interfaces.rs | |
parent | Releasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff) | |
download | rustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip |
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/windows-bindgen/src/rust/interfaces.rs')
-rw-r--r-- | vendor/windows-bindgen/src/rust/interfaces.rs | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/vendor/windows-bindgen/src/rust/interfaces.rs b/vendor/windows-bindgen/src/rust/interfaces.rs index a552af433..05ef63e01 100644 --- a/vendor/windows-bindgen/src/rust/interfaces.rs +++ b/vendor/windows-bindgen/src/rust/interfaces.rs @@ -2,17 +2,17 @@ use super::*; pub fn writer(writer: &Writer, def: TypeDef) -> TokenStream { if writer.sys { - gen_sys_interface(writer, def) + gen_sys_interface(def) } else { gen_win_interface(writer, def) } } -fn gen_sys_interface(writer: &Writer, def: TypeDef) -> TokenStream { - let name = writer.reader.type_def_name(def); +fn gen_sys_interface(def: TypeDef) -> TokenStream { + let name = def.name(); let ident = to_ident(name); - if type_def_is_exclusive(writer.reader, def) { + if type_def_is_exclusive(def) { quote! {} } else { quote! { @@ -22,16 +22,16 @@ fn gen_sys_interface(writer: &Writer, def: TypeDef) -> TokenStream { } fn gen_win_interface(writer: &Writer, def: TypeDef) -> TokenStream { - let generics = &type_def_generics(writer.reader, def); + let generics = &type_def_generics(def); let ident = writer.type_def_name(def, generics); - let is_exclusive = type_def_is_exclusive(writer.reader, def); + let is_exclusive = type_def_is_exclusive(def); let phantoms = writer.generic_phantoms(generics); let constraints = writer.generic_constraints(generics); - let cfg = type_def_cfg(writer.reader, def, &[]); + let cfg = type_def_cfg(def, &[]); let doc = writer.cfg_doc(&cfg); let features = writer.cfg_features(&cfg); - let interfaces = type_interfaces(writer.reader, &Type::TypeDef(def, generics.to_vec())); - let vtables = type_def_vtables(writer.reader, def); + let interfaces = type_interfaces(&Type::TypeDef(def, generics.to_vec())); + let vtables = type_def_vtables(def); let has_unknown_base = matches!(vtables.first(), Some(Type::IUnknown)); let mut tokens = if is_exclusive { @@ -44,12 +44,14 @@ fn gen_win_interface(writer: &Writer, def: TypeDef) -> TokenStream { tokens.combine("e! { #features #[repr(transparent)] + #[derive(::core::cmp::PartialEq, ::core::cmp::Eq, ::core::fmt::Debug, ::core::clone::Clone)] pub struct #ident(::windows_core::IUnknown, #phantoms) where #constraints; }); } else { tokens.combine("e! { #features #[repr(transparent)] + #[derive(::core::cmp::PartialEq, ::core::cmp::Eq, ::core::fmt::Debug, ::core::clone::Clone)] pub struct #ident(::std::ptr::NonNull<::std::ffi::c_void>); }); } @@ -61,13 +63,13 @@ fn gen_win_interface(writer: &Writer, def: TypeDef) -> TokenStream { let method_names = &mut MethodNames::new(); let virtual_names = &mut MethodNames::new(); - if writer.reader.type_def_flags(def).contains(TypeAttributes::WindowsRuntime) { - for method in writer.reader.type_def_methods(def) { + if def.flags().contains(TypeAttributes::WindowsRuntime) { + for method in def.methods() { methods.combine(&winrt_methods::writer(writer, def, generics, InterfaceKind::Default, method, method_names, virtual_names)); } for interface in &interfaces { if let Type::TypeDef(def, generics) = &interface.ty { - for method in writer.reader.type_def_methods(*def) { + for method in def.methods() { methods.combine(&winrt_methods::writer(writer, *def, generics, InterfaceKind::None, method, method_names, virtual_names)); } } @@ -78,8 +80,8 @@ fn gen_win_interface(writer: &Writer, def: TypeDef) -> TokenStream { match ty { Type::IUnknown | Type::IInspectable => {} Type::TypeDef(def, _) => { - let kind = if writer.reader.type_def_type_name(*def) == TypeName::IDispatch { InterfaceKind::None } else { InterfaceKind::Default }; - for method in writer.reader.type_def_methods(*def) { + let kind = if def.type_name() == TypeName::IDispatch { InterfaceKind::None } else { InterfaceKind::Default }; + for method in def.methods() { methods.combine(&com_methods::writer(writer, *def, kind, method, method_names, virtual_names, bases)); } } @@ -88,7 +90,7 @@ fn gen_win_interface(writer: &Writer, def: TypeDef) -> TokenStream { bases -= 1; } - for method in writer.reader.type_def_methods(def) { + for method in def.methods() { methods.combine(&com_methods::writer(writer, def, InterfaceKind::Default, method, method_names, virtual_names, 0)); } } @@ -108,7 +110,7 @@ fn gen_win_interface(writer: &Writer, def: TypeDef) -> TokenStream { let into = writer.type_name(ty); write!(&mut hierarchy, ", {into}").unwrap(); - hierarchy_cfg = hierarchy_cfg.union(&type_cfg(writer.reader, ty)); + hierarchy_cfg = hierarchy_cfg.union(&type_cfg(ty)); } hierarchy.push_str(");"); @@ -117,7 +119,7 @@ fn gen_win_interface(writer: &Writer, def: TypeDef) -> TokenStream { } else { for ty in &vtables { let into = writer.type_name(ty); - let cfg = writer.cfg_features(&cfg.union(&type_cfg(writer.reader, ty))); + let cfg = writer.cfg_features(&cfg.union(&type_cfg(ty))); tokens.combine("e! { #cfg impl<#constraints> ::windows_core::CanInto<#into> for #ident {} @@ -125,10 +127,10 @@ fn gen_win_interface(writer: &Writer, def: TypeDef) -> TokenStream { } } - if writer.reader.type_def_flags(def).contains(TypeAttributes::WindowsRuntime) { + if def.flags().contains(TypeAttributes::WindowsRuntime) { for interface in &interfaces { let into = writer.type_name(&interface.ty); - let cfg = writer.cfg_features(&cfg.union(&type_cfg(writer.reader, &interface.ty))); + let cfg = writer.cfg_features(&cfg.union(&type_cfg(&interface.ty))); tokens.combine("e! { #cfg impl<#constraints> ::windows_core::CanTryInto<#into> for #ident {} @@ -136,7 +138,6 @@ fn gen_win_interface(writer: &Writer, def: TypeDef) -> TokenStream { } } - tokens.combine(&writer.interface_core_traits(def, generics, &ident, &constraints, &phantoms, &features)); tokens.combine(&writer.interface_winrt_trait(def, generics, &ident, &constraints, &phantoms, &features)); tokens.combine(&writer.async_get(def, generics, &ident, &constraints, &phantoms, &features)); tokens.combine(&iterators::writer(writer, def, generics, &ident, &constraints, &phantoms, &cfg)); |