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/delegates.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/delegates.rs')
-rw-r--r-- | vendor/windows-bindgen/src/rust/delegates.rs | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/vendor/windows-bindgen/src/rust/delegates.rs b/vendor/windows-bindgen/src/rust/delegates.rs index 5b1b12022..479d8db62 100644 --- a/vendor/windows-bindgen/src/rust/delegates.rs +++ b/vendor/windows-bindgen/src/rust/delegates.rs @@ -1,7 +1,7 @@ use super::*; pub fn writer(writer: &Writer, def: TypeDef) -> TokenStream { - if writer.reader.type_def_flags(def).contains(TypeAttributes::WindowsRuntime) { + if def.flags().contains(TypeAttributes::WindowsRuntime) { gen_delegate(writer, def) } else { gen_callback(writer, def) @@ -9,13 +9,13 @@ pub fn writer(writer: &Writer, def: TypeDef) -> TokenStream { } fn gen_callback(writer: &Writer, def: TypeDef) -> TokenStream { - let name = to_ident(writer.reader.type_def_name(def)); - let method = type_def_invoke_method(writer.reader, def); + let name = to_ident(def.name()); + let method = type_def_invoke_method(def); - let signature = method_def_signature(writer.reader, writer.reader.type_def_namespace(def), method, &[]); + let signature = method_def_signature(def.namespace(), method, &[]); let return_type = writer.return_sig(&signature); - 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); @@ -34,7 +34,7 @@ fn gen_callback(writer: &Writer, def: TypeDef) -> TokenStream { fn gen_delegate(writer: &Writer, def: TypeDef) -> TokenStream { if writer.sys { - let name = to_ident(writer.reader.type_def_name(def)); + let name = to_ident(def.name()); quote! { pub type #name = *mut ::core::ffi::c_void; } @@ -44,23 +44,23 @@ fn gen_delegate(writer: &Writer, def: TypeDef) -> TokenStream { } fn gen_win_delegate(writer: &Writer, def: TypeDef) -> TokenStream { - let name = to_ident(writer.reader.type_def_name(def)); + let name = to_ident(def.name()); let vtbl = name.join("_Vtbl"); let boxed = name.join("Box"); - let generics = &type_def_generics(writer.reader, def); + let generics = &type_def_generics(def); let phantoms = writer.generic_phantoms(generics); let named_phantoms = writer.generic_named_phantoms(generics); let constraints = writer.generic_constraints(generics); let generic_names = writer.generic_names(generics); let ident = writer.type_def_name(def, generics); - let method = type_def_invoke_method(writer.reader, def); + let method = type_def_invoke_method(def); - let signature = method_def_signature(writer.reader, writer.reader.type_def_namespace(def), method, generics); + let signature = method_def_signature(def.namespace(), method, generics); let fn_constraint = gen_fn_constraint(writer, def, &signature); - let cfg = type_def_cfg(writer.reader, def, generics); + let cfg = type_def_cfg(def, generics); let doc = writer.cfg_doc(&cfg); let features = writer.cfg_features(&cfg); @@ -72,6 +72,7 @@ fn gen_win_delegate(writer: &Writer, def: TypeDef) -> TokenStream { #doc #features #[repr(transparent)] + #[derive(::core::cmp::PartialEq, ::core::cmp::Eq, ::core::fmt::Debug, ::core::clone::Clone)] pub struct #ident(pub ::windows_core::IUnknown, #phantoms) where #constraints; #features impl<#constraints> #ident { @@ -101,12 +102,16 @@ fn gen_win_delegate(writer: &Writer, def: TypeDef) -> TokenStream { Invoke: Self::Invoke, #(#named_phantoms)* }; - unsafe extern "system" fn QueryInterface(this: *mut ::core::ffi::c_void, iid: &::windows_core::GUID, interface: *mut *const ::core::ffi::c_void) -> ::windows_core::HRESULT { + unsafe extern "system" fn QueryInterface(this: *mut ::core::ffi::c_void, iid: *const ::windows_core::GUID, interface: *mut *mut ::core::ffi::c_void) -> ::windows_core::HRESULT { let this = this as *mut *mut ::core::ffi::c_void as *mut Self; - *interface = if iid == &<#ident as ::windows_core::ComInterface>::IID || - iid == &<::windows_core::IUnknown as ::windows_core::ComInterface>::IID || - iid == &<::windows_core::imp::IAgileObject as ::windows_core::ComInterface>::IID { + if iid.is_null() || interface.is_null() { + return ::windows_core::HRESULT(-2147467261); // E_POINTER + } + + *interface = if *iid == <#ident as ::windows_core::ComInterface>::IID || + *iid == <::windows_core::IUnknown as ::windows_core::ComInterface>::IID || + *iid == <::windows_core::imp::IAgileObject as ::windows_core::ComInterface>::IID { &mut (*this).vtable as *mut _ as _ } else { ::core::ptr::null_mut() @@ -142,7 +147,6 @@ fn gen_win_delegate(writer: &Writer, def: TypeDef) -> TokenStream { } }; - tokens.combine(&writer.interface_core_traits(def, generics, &ident, &constraints, &phantoms, &features)); tokens.combine(&writer.interface_trait(def, generics, &ident, &constraints, &features, true)); tokens.combine(&writer.interface_winrt_trait(def, generics, &ident, &constraints, &phantoms, &features)); tokens.combine(&writer.interface_vtbl(def, generics, &ident, &constraints, &features)); |