diff --git a/.cargo/config.toml b/.cargo/config.toml index 0973ccb656..cff486357e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -2,4 +2,5 @@ rustflags = [ # "--cfg", "windows_debugger_visualizer", # "--cfg", "windows_raw_dylib", + # "-C", "target-feature=+crt-static", ] diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index 528d49c1a1..acc796c79c 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -127,6 +127,7 @@ jobs: cargo clippy -p tool_gnu && cargo clippy -p tool_lib && cargo clippy -p tool_license && + cargo clippy -p tool_metadata && cargo clippy -p tool_msvc && cargo clippy -p tool_sys && cargo clippy -p tool_windows && diff --git a/.github/workflows/gen.yml b/.github/workflows/gen.yml index e0482095fe..611e7c7fbc 100644 --- a/.github/workflows/gen.yml +++ b/.github/workflows/gen.yml @@ -15,7 +15,7 @@ jobs: runs-on: windows-latest strategy: matrix: - tool: [windows, sys, yml, license, core] + tool: [windows, sys, yml, license, core, metadata] steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e267e2bc5a..437ba0477d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -134,6 +134,7 @@ jobs: cargo test -p tool_gnu && cargo test -p tool_lib && cargo test -p tool_license && + cargo test -p tool_metadata && cargo test -p tool_msvc && cargo test -p tool_sys && cargo test -p tool_windows && diff --git a/.gitignore b/.gitignore index 364c29f527..4b438598c7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ bin *.user *.filters *.bin +*.idl +*.winmd diff --git a/crates/libs/bindgen/src/com_methods.rs b/crates/libs/bindgen/src/com_methods.rs index 06abd10aae..b9189acdf8 100644 --- a/crates/libs/bindgen/src/com_methods.rs +++ b/crates/libs/bindgen/src/com_methods.rs @@ -121,7 +121,7 @@ pub fn gen( SignatureKind::ReturnStruct => { let args = gen.win32_args(&signature.params, kind); let params = gen.win32_params(&signature.params, kind); - let return_type = gen.type_name(&signature.return_type.unwrap()); + let return_type = gen.type_name(&signature.return_type); quote! { #doc diff --git a/crates/libs/bindgen/src/functions.rs b/crates/libs/bindgen/src/functions.rs index 7dde5e798a..cf3d45707e 100644 --- a/crates/libs/bindgen/src/functions.rs +++ b/crates/libs/bindgen/src/functions.rs @@ -132,7 +132,7 @@ fn gen_win_function(gen: &Gen, def: MethodDef) -> TokenStream { if handle_last_error(gen, def, &signature) { let args = gen.win32_args(&signature.params, kind); let params = gen.win32_params(&signature.params, kind); - let return_type = gen.type_name(&signature.return_type.unwrap()); + let return_type = gen.type_name(&signature.return_type); quote! { #doc @@ -272,7 +272,7 @@ fn handle_last_error(gen: &Gen, def: MethodDef, signature: &Signature) -> bool { .impl_map_flags(map) .contains(PInvokeAttributes::LAST_ERROR) { - if let Some(Type::TypeDef((return_type, _))) = &signature.return_type { + if let Type::TypeDef((return_type, _)) = &signature.return_type { if gen.reader.type_def_is_handle(*return_type) { if gen .reader diff --git a/crates/libs/bindgen/src/gen.rs b/crates/libs/bindgen/src/gen.rs index d27dc5181c..34e441aa02 100644 --- a/crates/libs/bindgen/src/gen.rs +++ b/crates/libs/bindgen/src/gen.rs @@ -155,7 +155,7 @@ impl<'a> Gen<'a> { } Type::WinrtArray(ty) => self.type_name(ty), Type::WinrtArrayRef(ty) => self.type_name(ty), - Type::WinrtConstRef(ty) => self.type_name(ty), + Type::ConstRef(ty) => self.type_name(ty), _ => unimplemented!(), } } @@ -919,38 +919,36 @@ impl<'a> Gen<'a> { .reader .type_def_flags(def) .contains(TypeAttributes::WINRT); - let hresult = self.type_name(&Type::HRESULT); - - let (trailing_return_type, return_type, udt_return_type) = if is_winrt { - if let Some(return_type) = &signature.return_type { - if let Type::WinrtArray(kind) = return_type { - let tokens = self.type_abi_name(kind); - ( - quote! { result_size__: *mut u32, result__: *mut *mut #tokens }, - quote! { -> #hresult }, - quote! {}, - ) - } else { - let tokens = self.type_abi_name(return_type); - ( - quote! { result__: *mut #tokens }, - quote! { -> #hresult }, - quote! {}, - ) - } - } else { - (quote! {}, quote! { -> #hresult }, quote! {}) + + let crate_name = self.crate_name(); + + let (trailing_return_type, return_type, udt_return_type) = match &signature.return_type { + Type::Void if is_winrt => (quote! {}, quote! { -> #crate_name HRESULT }, quote! {}), + Type::Void => (quote! {}, quote! {}, quote! {}), + Type::WinrtArray(kind) => { + let tokens = self.type_abi_name(kind); + ( + quote! { result_size__: *mut u32, result__: *mut *mut #tokens }, + quote! { -> #crate_name HRESULT }, + quote! {}, + ) + } + _ if is_winrt => { + let tokens = self.type_abi_name(&signature.return_type); + ( + quote! { result__: *mut #tokens }, + quote! { -> #crate_name HRESULT }, + quote! {}, + ) } - } else if let Some(return_type) = &signature.return_type { - if self.reader.type_is_struct(return_type) { - let tokens = self.type_abi_name(return_type); + _ if self.reader.type_is_struct(&signature.return_type) => { + let tokens = self.type_abi_name(&signature.return_type); (quote! {}, quote! {}, quote! { result__: *mut #tokens, }) - } else { - let tokens = self.type_default_name(return_type); + } + _ => { + let tokens = self.type_default_name(&signature.return_type); (quote! {}, quote! { -> #tokens }, quote! {}) } - } else { - (quote! {}, quote! {}, quote! {}) }; let params = signature.params.iter().map(|p| { @@ -967,7 +965,7 @@ impl<'a> Gen<'a> { { if p.ty.is_winrt_array() { quote! { #abi_size_name: u32, #name: *const #abi, } - } else if p.ty.is_winrt_const_ref() { + } else if p.ty.is_const_ref() { quote! { #name: &#abi, } } else { quote! { #name: #abi, } @@ -1001,13 +999,13 @@ impl<'a> Gen<'a> { to_ident(&self.reader.param_name(param).to_lowercase()) } pub fn return_sig(&self, signature: &Signature) -> TokenStream { - if let Some(return_type) = &signature.return_type { - let tokens = self.type_default_name(return_type); - format!(" -> {}", tokens.as_str()).into() - } else if self.reader.method_def_does_not_return(signature.def) { - " -> !".into() - } else { - " -> ()".into() + match &signature.return_type { + Type::Void if self.reader.method_def_does_not_return(signature.def) => " -> !".into(), + Type::Void => " -> ()".into(), + _ => { + let tokens = self.type_default_name(&signature.return_type); + format!(" -> {}", tokens.as_str()).into() + } } } pub fn win32_args(&self, params: &[SignatureParam], kind: SignatureKind) -> TokenStream { @@ -1207,16 +1205,17 @@ impl<'a> Gen<'a> { .iter() .map(|p| self.winrt_produce_type(p, !is_delegate)); - let return_type = if let Some(return_type) = &signature.return_type { - let tokens = self.type_name(return_type); + let return_type = match &signature.return_type { + Type::Void => quote! { () }, + _ => { + let tokens = self.type_name(&signature.return_type); - if return_type.is_winrt_array() { - quote! { ::windows_core::Array<#tokens> } - } else { - tokens + if signature.return_type.is_winrt_array() { + quote! { ::windows_core::Array<#tokens> } + } else { + tokens + } } - } else { - quote! { () } }; let this = if is_delegate { diff --git a/crates/libs/bindgen/src/standalone.rs b/crates/libs/bindgen/src/standalone.rs index 161db4fdd6..bfff19a6e2 100644 --- a/crates/libs/bindgen/src/standalone.rs +++ b/crates/libs/bindgen/src/standalone.rs @@ -37,9 +37,11 @@ fn standalone_imp(gen: &mut Gen, names: &[&str]) -> String { let mut constants = BTreeSet::new(); for name in names { + let mut found = false; let type_name = TypeName::parse(name); for def in gen.reader.get(type_name) { + found = true; gen.reader .type_collect_standalone(&Type::TypeDef((def, vec![])), &mut types); } @@ -49,12 +51,11 @@ fn standalone_imp(gen: &mut Gen, names: &[&str]) -> String { .namespace_functions(type_name.namespace) .filter(|method| gen.reader.method_def_name(*method) == type_name.name) { + found = true; functions.insert(method); let signature = gen.reader.method_def_signature(method, &[]); - signature - .return_type - .iter() - .for_each(|ty| gen.reader.type_collect_standalone(ty, &mut types)); + gen.reader + .type_collect_standalone(&signature.return_type, &mut types); signature .params .iter() @@ -66,6 +67,7 @@ fn standalone_imp(gen: &mut Gen, names: &[&str]) -> String { .namespace_constants(type_name.namespace) .find(|field| gen.reader.field_name(*field) == type_name.name) { + found = true; constants.insert(field); gen.reader.type_collect_standalone( &gen.reader.field_type(field, None).to_const_type(), @@ -86,10 +88,13 @@ fn standalone_imp(gen: &mut Gen, names: &[&str]) -> String { None }) { + found = true; constants.insert(field); gen.reader .type_collect_standalone(&gen.reader.field_type(field, None), &mut types); } + + assert!(found, "{} not found", type_name); } let mut sorted = SortedTokens::default(); @@ -173,9 +178,9 @@ fn standalone_imp(gen: &mut Gen, names: &[&str]) -> String { sorted.insert(gen.reader.type_def_name(def), enums::gen(gen, def)); } TypeKind::Struct => { + let name = gen.reader.type_def_name(def); if gen.reader.type_def_fields(def).next().is_none() { if let Some(guid) = gen.reader.type_def_guid(def) { - let name = gen.reader.type_def_name(def); let ident = to_ident(name); let value = gen.guid(&guid); let guid = gen.type_name(&Type::GUID); @@ -188,7 +193,7 @@ fn standalone_imp(gen: &mut Gen, names: &[&str]) -> String { continue; } } - sorted.insert(gen.reader.type_def_name(def), structs::gen(gen, def)); + sorted.insert(name, structs::gen(gen, def)); } TypeKind::Delegate => { sorted.insert(gen.reader.type_def_name(def), delegates::gen(gen, def)); @@ -212,7 +217,7 @@ fn standalone_imp(gen: &mut Gen, names: &[&str]) -> String { for constant in constants { sorted.insert( - &format!("{}", gen.reader.field_name(constant)), + gen.reader.field_name(constant), constants::gen(gen, constant), ); } diff --git a/crates/libs/bindgen/src/winrt_methods.rs b/crates/libs/bindgen/src/winrt_methods.rs index 46b12bccde..2cc906f145 100644 --- a/crates/libs/bindgen/src/winrt_methods.rs +++ b/crates/libs/bindgen/src/winrt_methods.rs @@ -25,47 +25,51 @@ pub fn gen( let args = gen_winrt_abi_args(gen, params); let params = gen_winrt_params(gen, params); - let return_type_tokens = if let Some(return_type) = &signature.return_type { - let tokens = gen.type_name(return_type); - if return_type.is_winrt_array() { - quote! { ::windows_core::Array<#tokens> } - } else { - quote! { #tokens } + let return_type_tokens = match &signature.return_type { + Type::Void => quote! { () }, + _ => { + let tokens = gen.type_name(&signature.return_type); + if signature.return_type.is_winrt_array() { + quote! { ::windows_core::Array<#tokens> } + } else { + quote! { #tokens } + } } - } else { - quote! { () } }; - let return_arg = if let Some(return_type) = &signature.return_type { - if return_type.is_winrt_array() { - let return_type = gen.type_name(return_type); - quote! { ::windows_core::Array::<#return_type>::set_abi_len(::std::mem::transmute(&mut result__)), result__.as_mut_ptr() as *mut _ as _ } - } else { - quote! { &mut result__ } + let return_arg = match &signature.return_type { + Type::Void => quote! {}, + _ => { + if signature.return_type.is_winrt_array() { + let return_type = gen.type_name(&signature.return_type); + quote! { ::windows_core::Array::<#return_type>::set_abi_len(::std::mem::transmute(&mut result__)), result__.as_mut_ptr() as *mut _ as _ } + } else { + quote! { &mut result__ } + } } - } else { - quote! {} }; - let vcall = if let Some(return_type) = &signature.return_type { - if return_type.is_winrt_array() { + let vcall = match &signature.return_type { + Type::Void => { + quote! { + (::windows_core::Interface::vtable(this).#vname)(::windows_core::Interface::as_raw(this), #args).ok() + } + } + _ if signature.return_type.is_winrt_array() => { quote! { let mut result__ = ::core::mem::MaybeUninit::zeroed(); (::windows_core::Interface::vtable(this).#vname)(::windows_core::Interface::as_raw(this), #args #return_arg) .and_then(|| result__.assume_init()) } - } else { - let return_type = gen.type_name(return_type); + } + _ => { + let return_type = gen.type_name(&signature.return_type); quote! { let mut result__ = ::windows_core::zeroed::<#return_type>(); (::windows_core::Interface::vtable(this).#vname)(::windows_core::Interface::as_raw(this), #args #return_arg) .from_abi(result__) } } - } else { - quote! { - (::windows_core::Interface::vtable(this).#vname)(::windows_core::Interface::as_raw(this), #args).ok() - } }; match kind { @@ -161,7 +165,7 @@ fn gen_winrt_abi_args(gen: &Gen, params: &[SignatureParam]) -> TokenStream { } else if gen.reader.signature_param_is_borrowed(param) { quote! { #name.into_param().abi(), } } else if gen.reader.type_is_blittable(¶m.ty) { - if param.ty.is_winrt_const_ref() { + if param.ty.is_const_ref() { quote! { &#name, } } else { quote! { #name, } @@ -194,7 +198,10 @@ pub fn gen_upcall(gen: &Gen, sig: &Signature, inner: TokenStream) -> TokenStream .map(|param| gen_winrt_invoke_arg(gen, param)); match &sig.return_type { - Some(return_type) if return_type.is_winrt_array() => { + Type::Void => quote! { + #inner(#(#invoke_args,)*).into() + }, + _ if sig.return_type.is_winrt_array() => { quote! { match #inner(#(#invoke_args,)*) { ::core::result::Result::Ok(ok__) => { @@ -208,22 +215,25 @@ pub fn gen_upcall(gen: &Gen, sig: &Signature, inner: TokenStream) -> TokenStream } } } - Some(_) => { + _ => { + let forget = if gen.reader.type_is_blittable(&sig.return_type) { + quote! {} + } else { + quote! { ::core::mem::forget(ok__); } + }; + quote! { match #inner(#(#invoke_args,)*) { ::core::result::Result::Ok(ok__) => { // use `core::ptr::write` since `result` could be uninitialized ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); + #forget ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into() } } } - None => quote! { - #inner(#(#invoke_args,)*).into() - }, } } @@ -241,7 +251,7 @@ fn gen_winrt_invoke_arg(gen: &Gen, param: &SignatureParam) -> TokenStream { quote! { ::core::slice::from_raw_parts(::core::mem::transmute_copy(&#name), #abi_size_name as _) } } else if gen.reader.type_is_primitive(¶m.ty) { quote! { #name } - } else if param.ty.is_winrt_const_ref() { + } else if param.ty.is_const_ref() { quote! { ::core::mem::transmute_copy(&#name) } } else if gen.reader.type_is_nullable(¶m.ty) { quote! { ::windows_core::from_raw_borrowed(&#name) } diff --git a/crates/libs/metadata/Cargo.toml b/crates/libs/metadata/Cargo.toml index acaa5e3a74..d6c139f222 100644 --- a/crates/libs/metadata/Cargo.toml +++ b/crates/libs/metadata/Cargo.toml @@ -10,3 +10,16 @@ repository = "https://github.com/microsoft/windows-rs" [package.metadata.docs.rs] default-target = "x86_64-pc-windows-msvc" targets = [] + +[dependencies.tokens] +package = "windows-tokens" +path = "../tokens" +version = "0.48.0" + +[dependencies.syn] +version = "1.0" +features = ["full", "extra-traits"] + +[dependencies.proc-macro2] +version = "1.0" +features = ["span-locations"] diff --git a/crates/libs/metadata/src/bindings.rs b/crates/libs/metadata/src/bindings.rs index 9e25db9286..667f12b63e 100644 --- a/crates/libs/metadata/src/bindings.rs +++ b/crates/libs/metadata/src/bindings.rs @@ -1,28 +1,83 @@ -// Note: these definitions are taken from `windows-sys` to avoid a circular dependency. -#![allow(non_snake_case, non_camel_case_types)] +// Bindings generated by `windows-bindgen` 0.49.0 -pub type IMAGE_DIRECTORY_ENTRY = u32; -pub type IMAGE_DLL_CHARACTERISTICS = u16; -pub type IMAGE_FILE_CHARACTERISTICS = u16; -pub type IMAGE_FILE_MACHINE = u16; -pub type IMAGE_OPTIONAL_HEADER_MAGIC = u16; -pub type IMAGE_SECTION_CHARACTERISTICS = u32; -pub type IMAGE_SUBSYSTEM = u16; - -pub const IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR: IMAGE_DIRECTORY_ENTRY = 14u32; +#![allow(non_snake_case, non_upper_case_globals, non_camel_case_types, dead_code, clippy::all)] +pub type CorElementType = i32; +pub const ELEMENT_TYPE_ARRAY: CorElementType = 20i32; +pub const ELEMENT_TYPE_BOOLEAN: CorElementType = 2i32; +pub const ELEMENT_TYPE_BYREF: CorElementType = 16i32; +pub const ELEMENT_TYPE_CHAR: CorElementType = 3i32; +pub const ELEMENT_TYPE_CLASS: CorElementType = 18i32; +pub const ELEMENT_TYPE_CMOD_OPT: CorElementType = 32i32; +pub const ELEMENT_TYPE_CMOD_REQD: CorElementType = 31i32; +pub const ELEMENT_TYPE_GENERICINST: CorElementType = 21i32; +pub const ELEMENT_TYPE_I: CorElementType = 24i32; +pub const ELEMENT_TYPE_I1: CorElementType = 4i32; +pub const ELEMENT_TYPE_I2: CorElementType = 6i32; +pub const ELEMENT_TYPE_I4: CorElementType = 8i32; +pub const ELEMENT_TYPE_I8: CorElementType = 10i32; +pub const ELEMENT_TYPE_OBJECT: CorElementType = 28i32; +pub const ELEMENT_TYPE_PTR: CorElementType = 15i32; +pub const ELEMENT_TYPE_R4: CorElementType = 12i32; +pub const ELEMENT_TYPE_R8: CorElementType = 13i32; +pub const ELEMENT_TYPE_STRING: CorElementType = 14i32; +pub const ELEMENT_TYPE_SZARRAY: CorElementType = 29i32; +pub const ELEMENT_TYPE_U: CorElementType = 25i32; +pub const ELEMENT_TYPE_U1: CorElementType = 5i32; +pub const ELEMENT_TYPE_U2: CorElementType = 7i32; +pub const ELEMENT_TYPE_U4: CorElementType = 9i32; +pub const ELEMENT_TYPE_U8: CorElementType = 11i32; +pub const ELEMENT_TYPE_VALUETYPE: CorElementType = 17i32; +pub const ELEMENT_TYPE_VAR: CorElementType = 19i32; +pub const ELEMENT_TYPE_VOID: CorElementType = 1i32; +#[repr(C)] +pub struct IMAGE_COR20_HEADER { + pub cb: u32, + pub MajorRuntimeVersion: u16, + pub MinorRuntimeVersion: u16, + pub MetaData: IMAGE_DATA_DIRECTORY, + pub Flags: u32, + pub Anonymous: IMAGE_COR20_HEADER_0, + pub Resources: IMAGE_DATA_DIRECTORY, + pub StrongNameSignature: IMAGE_DATA_DIRECTORY, + pub CodeManagerTable: IMAGE_DATA_DIRECTORY, + pub VTableFixups: IMAGE_DATA_DIRECTORY, + pub ExportAddressTableJumps: IMAGE_DATA_DIRECTORY, + pub ManagedNativeHeader: IMAGE_DATA_DIRECTORY, +} +impl ::core::marker::Copy for IMAGE_COR20_HEADER {} +impl ::core::clone::Clone for IMAGE_COR20_HEADER { + fn clone(&self) -> Self { + *self + } +} +#[repr(C)] +pub union IMAGE_COR20_HEADER_0 { + pub EntryPointToken: u32, + pub EntryPointRVA: u32, +} +impl ::core::marker::Copy for IMAGE_COR20_HEADER_0 {} +impl ::core::clone::Clone for IMAGE_COR20_HEADER_0 { + fn clone(&self) -> Self { + *self + } +} +#[repr(C)] +pub struct IMAGE_DATA_DIRECTORY { + pub VirtualAddress: u32, + pub Size: u32, +} +impl ::core::marker::Copy for IMAGE_DATA_DIRECTORY {} +impl ::core::clone::Clone for IMAGE_DATA_DIRECTORY { + fn clone(&self) -> Self { + *self + } +} +pub type IMAGE_DIRECTORY_ENTRY = u16; +pub const IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR: IMAGE_DIRECTORY_ENTRY = 14u16; pub const IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE: IMAGE_DLL_CHARACTERISTICS = 64u16; pub const IMAGE_DLLCHARACTERISTICS_NO_SEH: IMAGE_DLL_CHARACTERISTICS = 1024u16; pub const IMAGE_DLLCHARACTERISTICS_NX_COMPAT: IMAGE_DLL_CHARACTERISTICS = 256u16; -pub const IMAGE_DOS_SIGNATURE: u16 = 23117u16; -pub const IMAGE_FILE_32BIT_MACHINE: IMAGE_FILE_CHARACTERISTICS = 256u16; -pub const IMAGE_FILE_DLL: IMAGE_FILE_CHARACTERISTICS = 8192u16; -pub const IMAGE_FILE_EXECUTABLE_IMAGE: IMAGE_FILE_CHARACTERISTICS = 2u16; -pub const IMAGE_FILE_MACHINE_I386: IMAGE_FILE_MACHINE = 332u16; -pub const IMAGE_NT_OPTIONAL_HDR32_MAGIC: IMAGE_OPTIONAL_HEADER_MAGIC = 267u16; -pub const IMAGE_NT_OPTIONAL_HDR64_MAGIC: IMAGE_OPTIONAL_HEADER_MAGIC = 523u16; -pub const IMAGE_NT_SIGNATURE: u32 = 17744u32; -pub const IMAGE_SUBSYSTEM_WINDOWS_CUI: IMAGE_SUBSYSTEM = 3u16; - +pub type IMAGE_DLL_CHARACTERISTICS = u16; #[repr(C, packed(2))] pub struct IMAGE_DOS_HEADER { pub e_magic: u16, @@ -45,7 +100,17 @@ pub struct IMAGE_DOS_HEADER { pub e_res2: [u16; 10], pub e_lfanew: i32, } - +impl ::core::marker::Copy for IMAGE_DOS_HEADER {} +impl ::core::clone::Clone for IMAGE_DOS_HEADER { + fn clone(&self) -> Self { + *self + } +} +pub const IMAGE_DOS_SIGNATURE: u16 = 23117u16; +pub const IMAGE_FILE_32BIT_MACHINE: IMAGE_FILE_CHARACTERISTICS = 256u16; +pub type IMAGE_FILE_CHARACTERISTICS = u16; +pub const IMAGE_FILE_DLL: IMAGE_FILE_CHARACTERISTICS = 8192u16; +pub const IMAGE_FILE_EXECUTABLE_IMAGE: IMAGE_FILE_CHARACTERISTICS = 2u16; #[repr(C)] pub struct IMAGE_FILE_HEADER { pub Machine: IMAGE_FILE_MACHINE, @@ -56,7 +121,17 @@ pub struct IMAGE_FILE_HEADER { pub SizeOfOptionalHeader: u16, pub Characteristics: IMAGE_FILE_CHARACTERISTICS, } - +impl ::core::marker::Copy for IMAGE_FILE_HEADER {} +impl ::core::clone::Clone for IMAGE_FILE_HEADER { + fn clone(&self) -> Self { + *self + } +} +pub type IMAGE_FILE_MACHINE = u16; +pub const IMAGE_FILE_MACHINE_I386: IMAGE_FILE_MACHINE = 332u16; +pub const IMAGE_NT_OPTIONAL_HDR32_MAGIC: IMAGE_OPTIONAL_HEADER_MAGIC = 267u16; +pub const IMAGE_NT_OPTIONAL_HDR64_MAGIC: IMAGE_OPTIONAL_HEADER_MAGIC = 523u16; +pub const IMAGE_NT_SIGNATURE: u32 = 17744u32; #[repr(C)] pub struct IMAGE_OPTIONAL_HEADER32 { pub Magic: IMAGE_OPTIONAL_HEADER_MAGIC, @@ -91,7 +166,12 @@ pub struct IMAGE_OPTIONAL_HEADER32 { pub NumberOfRvaAndSizes: u32, pub DataDirectory: [IMAGE_DATA_DIRECTORY; 16], } - +impl ::core::marker::Copy for IMAGE_OPTIONAL_HEADER32 {} +impl ::core::clone::Clone for IMAGE_OPTIONAL_HEADER32 { + fn clone(&self) -> Self { + *self + } +} #[repr(C, packed(4))] pub struct IMAGE_OPTIONAL_HEADER64 { pub Magic: IMAGE_OPTIONAL_HEADER_MAGIC, @@ -125,7 +205,14 @@ pub struct IMAGE_OPTIONAL_HEADER64 { pub NumberOfRvaAndSizes: u32, pub DataDirectory: [IMAGE_DATA_DIRECTORY; 16], } - +impl ::core::marker::Copy for IMAGE_OPTIONAL_HEADER64 {} +impl ::core::clone::Clone for IMAGE_OPTIONAL_HEADER64 { + fn clone(&self) -> Self { + *self + } +} +pub type IMAGE_OPTIONAL_HEADER_MAGIC = u16; +pub type IMAGE_SECTION_CHARACTERISTICS = u32; #[repr(C)] pub struct IMAGE_SECTION_HEADER { pub Name: [u8; 8], @@ -139,37 +226,22 @@ pub struct IMAGE_SECTION_HEADER { pub NumberOfLinenumbers: u16, pub Characteristics: IMAGE_SECTION_CHARACTERISTICS, } - +impl ::core::marker::Copy for IMAGE_SECTION_HEADER {} +impl ::core::clone::Clone for IMAGE_SECTION_HEADER { + fn clone(&self) -> Self { + *self + } +} #[repr(C)] pub union IMAGE_SECTION_HEADER_0 { pub PhysicalAddress: u32, pub VirtualSize: u32, } - -#[repr(C)] -pub struct IMAGE_DATA_DIRECTORY { - pub VirtualAddress: u32, - pub Size: u32, -} - -#[repr(C)] -pub struct IMAGE_COR20_HEADER { - pub cb: u32, - pub MajorRuntimeVersion: u16, - pub MinorRuntimeVersion: u16, - pub MetaData: IMAGE_DATA_DIRECTORY, - pub Flags: u32, - pub Anonymous: IMAGE_COR20_HEADER_0, - pub Resources: IMAGE_DATA_DIRECTORY, - pub StrongNameSignature: IMAGE_DATA_DIRECTORY, - pub CodeManagerTable: IMAGE_DATA_DIRECTORY, - pub VTableFixups: IMAGE_DATA_DIRECTORY, - pub ExportAddressTableJumps: IMAGE_DATA_DIRECTORY, - pub ManagedNativeHeader: IMAGE_DATA_DIRECTORY, -} - -#[repr(C)] -pub union IMAGE_COR20_HEADER_0 { - pub EntryPointToken: u32, - pub EntryPointRVA: u32, +impl ::core::marker::Copy for IMAGE_SECTION_HEADER_0 {} +impl ::core::clone::Clone for IMAGE_SECTION_HEADER_0 { + fn clone(&self) -> Self { + *self + } } +pub type IMAGE_SUBSYSTEM = u16; +pub const IMAGE_SUBSYSTEM_WINDOWS_CUI: IMAGE_SUBSYSTEM = 3u16; diff --git a/crates/libs/metadata/src/error.rs b/crates/libs/metadata/src/error.rs new file mode 100644 index 0000000000..31926e938b --- /dev/null +++ b/crates/libs/metadata/src/error.rs @@ -0,0 +1,84 @@ +pub type Result = std::result::Result; + +#[derive(Default, Debug)] +pub struct Error { + message: String, + path: String, + span: Option<(usize, usize)>, +} + +impl From for std::io::Error { + fn from(error: Error) -> Self { + std::io::Error::new(std::io::ErrorKind::Other, error.message.as_str()) + } +} + +impl From for Error { + fn from(error: syn::Error) -> Self { + let start = error.span().start(); + Self { message: error.to_string(), span: Some((start.line, start.column)), ..Self::default() } + } +} + +impl std::fmt::Display for Error { + fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + writeln!(fmt, "error: {}", self.message)?; + if !self.path.is_empty() { + if let Some((line, column)) = self.span { + writeln!(fmt, " --> {}:{line}:{column}", self.path)?; + } else { + writeln!(fmt, " --> {}", self.path)?; + } + } + Ok(()) + } +} + +impl Error { + pub fn new(message: &str) -> Self { + Self { message: message.to_string(), ..Self::default() } + } + + pub fn with_path(self, path: &str) -> Self { + Self { path: path.to_string(), ..self } + } + + pub fn with_span(self, span: proc_macro2::Span) -> Self { + let start = span.start(); + Self { span: Some((start.line, start.column)), ..self } + } +} + +pub fn read_file(path: &str) -> Result> { + std::fs::read(path).map_err(|_| Error::new("failed to read file").with_path(path)) +} + +pub fn read_to_string(path: &str) -> Result { + std::fs::read_to_string(path).map_err(|_| Error::new("failed to read file").with_path(path)) +} + +pub fn write_to_file>(path: &str, contents: C) -> Result<()> { + if let Some(parent) = std::path::Path::new(path).parent() { + std::fs::create_dir_all(parent).map_err(|_| Error::new("failed to create directory").with_path(path))?; + } + + std::fs::write(path, contents).map_err(|_| Error::new("failed to write file").with_path(path)) +} + +pub fn canonicalize(path: &str) -> Result { + let path = std::fs::canonicalize(path).map_err(|_| Error::new("failed to find path").with_path(path))?; + let path = path.to_string_lossy().trim_start_matches(r#"\\?\"#).to_string(); + + match extension(&path) { + (_, "") => Ok(path), + (file, extension) => Ok(format!("{file}.{}", extension.to_lowercase())), + } +} + +pub fn extension(path: &str) -> (&str, &str) { + if let Some((file, extension)) = path.rsplit_once('.') { + (file, extension) + } else { + ("", "") + } +} diff --git a/crates/libs/metadata/src/reader/filter.rs b/crates/libs/metadata/src/filter.rs similarity index 94% rename from crates/libs/metadata/src/reader/filter.rs rename to crates/libs/metadata/src/filter.rs index 4b6651fb66..eb9e97e79d 100644 --- a/crates/libs/metadata/src/reader/filter.rs +++ b/crates/libs/metadata/src/filter.rs @@ -49,11 +49,11 @@ impl<'a> Filter<'a> { false } - pub fn includes_type(&self, reader: &Reader, ty: TypeDef) -> bool { + pub fn includes_type(&self, reader: &reader::Reader, ty: reader::TypeDef) -> bool { self.includes_type_name(reader.type_def_type_name(ty)) } - fn includes_type_name(&self, type_name: TypeName) -> bool { + pub fn includes_type_name(&self, type_name: reader::TypeName) -> bool { if self.is_empty() { return true; } @@ -93,7 +93,7 @@ mod tests { use super::*; fn includes_type_name(filter: &Filter, full_name: &str) -> bool { - filter.includes_type_name(TypeName::parse(full_name)) + filter.includes_type_name(reader::TypeName::parse(full_name)) } #[test] diff --git a/crates/libs/metadata/src/lib.rs b/crates/libs/metadata/src/lib.rs index 0e832603ca..52717013b7 100644 --- a/crates/libs/metadata/src/lib.rs +++ b/crates/libs/metadata/src/lib.rs @@ -3,20 +3,21 @@ use std::collections::*; mod attributes; mod bindings; +mod error; +mod filter; mod imp; pub mod reader; pub mod writer; pub use attributes::*; use bindings::*; +pub use error::*; +pub use filter::*; use imp::*; -use std::io::*; -use std::mem::*; -use std::ptr::*; macro_rules! flags { ($name:ident, $size:ty) => { - #[derive(Default, Copy, Clone, PartialEq, Eq)] + #[derive(Default, Copy, Clone, PartialEq, Eq, Debug)] pub struct $name(pub $size); impl $name { pub fn contains(&self, contains: Self) -> bool { diff --git a/crates/libs/metadata/src/reader/blob.rs b/crates/libs/metadata/src/reader/blob.rs index b7d4880d0e..4e8788d0aa 100644 --- a/crates/libs/metadata/src/reader/blob.rs +++ b/crates/libs/metadata/src/reader/blob.rs @@ -45,7 +45,7 @@ impl<'a> Blob<'a> { let mut mods = vec![]; loop { let (value, offset) = self.peek_usize(); - if value != 32 && value != 31 { + if value != ELEMENT_TYPE_CMOD_OPT as _ && value != ELEMENT_TYPE_CMOD_REQD as _ { break; } else { self.offset(offset); diff --git a/crates/libs/metadata/src/reader/file.rs b/crates/libs/metadata/src/reader/file.rs index b00b4fc52d..3d987a327d 100644 --- a/crates/libs/metadata/src/reader/file.rs +++ b/crates/libs/metadata/src/reader/file.rs @@ -42,12 +42,8 @@ pub const TABLE_ASSEMBLYREF: usize = 15; pub const TABLE_CLASSLAYOUT: usize = 16; pub const TABLE_LEN: usize = 17; -fn error(message: &str) -> Error { - Error::new(ErrorKind::Other, message) -} - fn error_invalid_winmd() -> Error { - error("File is not a valid `winmd` file") + Error::new("not a valid `winmd` file") } impl File { @@ -55,14 +51,14 @@ impl File { let mut files = vec![Self::from_buffer(std::include_bytes!("../../default/Windows.winmd").to_vec())?, Self::from_buffer(std::include_bytes!("../../default/Windows.Wdk.winmd").to_vec())?, Self::from_buffer(std::include_bytes!("../../default/Windows.Win32.winmd").to_vec())?]; for path in paths { - files.push(Self::new(std::path::Path::new(path))?); + files.push(Self::new(path)?); } Ok(files) } - pub fn new>(path: P) -> Result { - Self::from_buffer(std::fs::read(&path)?) + pub fn new(path: &str) -> Result { + Self::from_buffer(read_file(path)?).map_err(|error| error.with_path(path)) } pub fn from_buffer(bytes: Vec) -> Result { @@ -74,26 +70,26 @@ impl File { return Err(error_invalid_winmd()); } - let file_offset = dos.e_lfanew as usize + size_of::(); + let file_offset = dos.e_lfanew as usize + std::mem::size_of::(); let file = result.bytes.view_as::(file_offset); - let optional_offset = file_offset + size_of::(); + let optional_offset = file_offset + std::mem::size_of::(); let (com_virtual_address, sections) = match result.bytes.copy_as::(optional_offset) { IMAGE_NT_OPTIONAL_HDR32_MAGIC => { let optional = result.bytes.view_as::(optional_offset); - (optional.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR as usize].VirtualAddress, result.bytes.view_as_slice_of::(optional_offset + size_of::(), file.NumberOfSections as usize)) + (optional.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR as usize].VirtualAddress, result.bytes.view_as_slice_of::(optional_offset + std::mem::size_of::(), file.NumberOfSections as usize)) } IMAGE_NT_OPTIONAL_HDR64_MAGIC => { let optional = result.bytes.view_as::(optional_offset); - (optional.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR as usize].VirtualAddress, result.bytes.view_as_slice_of::(optional_offset + size_of::(), file.NumberOfSections as usize)) + (optional.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR as usize].VirtualAddress, result.bytes.view_as_slice_of::(optional_offset + std::mem::size_of::(), file.NumberOfSections as usize)) } _ => return Err(error_invalid_winmd()), }; let clr = result.bytes.view_as::(offset_from_rva(section_from_rva(sections, com_virtual_address)?, com_virtual_address) as _); - if clr.cb != size_of::() as _ { + if clr.cb != std::mem::size_of::() as _ { return Err(error_invalid_winmd()); } @@ -488,7 +484,7 @@ macro_rules! assert_proper_length_and_alignment { ($self:expr, $t:ty, $offset:expr, $size:expr) => {{ assert_proper_length!($self, $t, $offset, $size); let ptr = &$self[$offset] as *const u8 as *const $t; - let properly_aligned = ptr.align_offset(align_of::<$t>()) == 0; + let properly_aligned = ptr.align_offset(std::mem::align_of::<$t>()) == 0; assert!(properly_aligned, "Invalid file: offset {} is not properly aligned to T", $offset); ptr }}; @@ -503,20 +499,20 @@ trait View { impl View for [u8] { fn view_as(&self, offset: usize) -> &T { - let ptr = assert_proper_length_and_alignment!(self, T, offset, size_of::()); + let ptr = assert_proper_length_and_alignment!(self, T, offset, std::mem::size_of::()); unsafe { &*ptr } } fn view_as_slice_of(&self, offset: usize, len: usize) -> &[T] { - let ptr = assert_proper_length_and_alignment!(self, T, offset, size_of::() * len); + let ptr = assert_proper_length_and_alignment!(self, T, offset, std::mem::size_of::() * len); unsafe { std::slice::from_raw_parts(ptr, len) } } fn copy_as(&self, offset: usize) -> T { - assert_proper_length!(self, T, offset, size_of::()); + assert_proper_length!(self, T, offset, std::mem::size_of::()); unsafe { - let mut data = MaybeUninit::zeroed().assume_init(); - copy_nonoverlapping(self[offset..].as_ptr(), &mut data as *mut T as *mut u8, size_of::()); + let mut data = std::mem::MaybeUninit::zeroed().assume_init(); + std::ptr::copy_nonoverlapping(self[offset..].as_ptr(), &mut data as *mut T as *mut u8, std::mem::size_of::()); data } } diff --git a/crates/libs/metadata/src/reader/mod.rs b/crates/libs/metadata/src/reader/mod.rs index b76717242e..842459fd68 100644 --- a/crates/libs/metadata/src/reader/mod.rs +++ b/crates/libs/metadata/src/reader/mod.rs @@ -1,7 +1,6 @@ mod blob; mod codes; mod file; -mod filter; mod guid; mod row; mod tree; @@ -12,7 +11,6 @@ pub use super::*; pub use blob::*; pub use codes::*; pub use file::*; -pub use filter::*; pub use guid::*; pub use r#type::*; pub use row::*; @@ -145,7 +143,7 @@ pub enum Integer { pub struct Signature { pub def: MethodDef, pub params: Vec, - pub return_type: Option, + pub return_type: Type, pub vararg: bool, } @@ -321,7 +319,7 @@ impl<'a> Reader<'a> { let mut args: Vec<(String, Value)> = Vec::with_capacity(fixed_arg_count); for _ in 0..fixed_arg_count { - let arg = match self.type_from_blob(&mut sig, None, &[]).expect("Type not found") { + let arg = match self.type_from_blob(&mut sig, None, &[]) { Type::Bool => Value::Bool(values.read_bool()), Type::I8 => Value::I8(values.read_i8()), Type::U8 => Value::U8(values.read_u8()), @@ -347,12 +345,12 @@ impl<'a> Reader<'a> { let _id = values.read_u8(); let arg_type = values.read_u8(); let mut name = values.read_str().to_string(); - let arg = match arg_type { - 0x02 => Value::Bool(values.read_bool()), - 0x06 => Value::I16(values.read_i16()), - 0x08 => Value::I32(values.read_i32()), - 0x09 => Value::U32(values.read_u32()), - 0x0E => Value::String(values.read_str().to_string()), + let arg = match arg_type as _ { + ELEMENT_TYPE_BOOLEAN => Value::Bool(values.read_bool()), + ELEMENT_TYPE_I2 => Value::I16(values.read_i16()), + ELEMENT_TYPE_I4 => Value::I32(values.read_i32()), + ELEMENT_TYPE_U4 => Value::U32(values.read_u32()), + ELEMENT_TYPE_STRING => Value::String(values.read_str().to_string()), 0x50 => Value::TypeDef(self.get(TypeName::parse(values.read_str())).next().expect("Type not found")), 0x55 => { let def = self.get(TypeName::parse(&name)).next().expect("Type not found"); @@ -424,7 +422,7 @@ impl<'a> Reader<'a> { let mut blob = self.row_blob(row.0, 2); blob.read_usize(); blob.read_modifiers(); - let def = self.type_from_blob(&mut blob, enclosing, &[]).expect("Type not found"); + let def = self.type_from_blob(&mut blob, enclosing, &[]); if self.field_is_const(row) { def.to_const_type().to_const_ptr() @@ -618,12 +616,12 @@ impl<'a> Reader<'a> { .filter_map(|param| { if self.param_sequence(param) == 0 { if self.param_is_const(param) { - return_type = return_type.clone().map(|ty| ty.to_const_type()); + return_type = return_type.clone().to_const_type(); } None } else { let is_output = self.param_flags(param).contains(ParamAttributes::OUTPUT); - let mut ty = self.type_from_blob(&mut blob, None, generics).expect("Parameter type not found"); + let mut ty = self.type_from_blob(&mut blob, None, generics); if self.param_is_const(param) || !is_output { ty = ty.to_const_type(); } @@ -1272,11 +1270,13 @@ impl<'a> Reader<'a> { cfg } pub fn type_def_cfg_combine(&'a self, row: TypeDef, generics: &[Type], cfg: &mut Cfg<'a>) { + let type_name = self.type_def_type_name(row); + for generic in generics { self.type_cfg_combine(generic, cfg); } - if cfg.types.entry(self.type_def_namespace(row)).or_default().insert(row) { + if cfg.types.entry(type_name.namespace).or_default().insert(row) { match self.type_def_kind(row) { TypeKind::Class => { if let Some(default_interface) = self.type_def_default_interface(row) { @@ -1294,7 +1294,6 @@ impl<'a> Reader<'a> { } TypeKind::Struct => { self.type_def_fields(row).for_each(|field| self.field_cfg_combine(field, Some(row), cfg)); - let type_name = self.type_def_type_name(row); if !type_name.namespace.is_empty() { for def in self.get(type_name) { if def != row { @@ -1372,7 +1371,7 @@ impl<'a> Reader<'a> { cfg } fn signature_cfg_combine(&'a self, signature: &Signature, cfg: &mut Cfg<'a>) { - signature.return_type.iter().for_each(|ty| self.type_cfg_combine(ty, cfg)); + self.type_cfg_combine(&signature.return_type, cfg); signature.params.iter().for_each(|param| self.type_cfg_combine(¶m.ty, cfg)); } pub fn signature_param_is_borrowed(&self, param: &SignatureParam) -> bool { @@ -1418,48 +1417,33 @@ impl<'a> Reader<'a> { if self.method_def_can_return_multiple_success_values(signature.def) { return SignatureKind::PreserveSig; } - if let Some(return_type) = &signature.return_type { - match return_type { - Type::HRESULT => { - if signature.params.len() >= 2 { - if let Some(guid) = self.signature_param_is_query_guid(&signature.params) { - if let Some(object) = self.signature_param_is_query_object(&signature.params) { - if self.param_flags(signature.params[object].def).contains(ParamAttributes::OPTIONAL) { - return SignatureKind::QueryOptional(QueryPosition { object, guid }); - } else { - return SignatureKind::Query(QueryPosition { object, guid }); - } + match &signature.return_type { + Type::Void if self.signature_is_retval(signature) => SignatureKind::ReturnValue, + Type::Void => SignatureKind::ReturnVoid, + Type::HRESULT => { + if signature.params.len() >= 2 { + if let Some(guid) = self.signature_param_is_query_guid(&signature.params) { + if let Some(object) = self.signature_param_is_query_object(&signature.params) { + if self.param_flags(signature.params[object].def).contains(ParamAttributes::OPTIONAL) { + return SignatureKind::QueryOptional(QueryPosition { object, guid }); + } else { + return SignatureKind::Query(QueryPosition { object, guid }); } } } - - if self.signature_is_retval(signature) { - return SignatureKind::ResultValue; - } - - return SignatureKind::ResultVoid; - } - 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; + if self.signature_is_retval(signature) { + SignatureKind::ResultValue + } else { + SignatureKind::ResultVoid } - _ => return SignatureKind::PreserveSig, } + Type::TypeDef((def, _)) if self.type_def_type_name(*def) == TypeName::NTSTATUS => SignatureKind::ResultVoid, + Type::TypeDef((def, _)) if self.type_def_type_name(*def) == TypeName::WIN32_ERROR => SignatureKind::ResultVoid, + Type::TypeDef((def, _)) if self.type_def_type_name(*def) == TypeName::BOOL && self.method_def_last_error(signature.def) => SignatureKind::ResultVoid, + _ if self.type_is_struct(&signature.return_type) => SignatureKind::ReturnStruct, + _ => SignatureKind::PreserveSig, } - - if self.signature_is_retval(signature) { - return SignatureKind::ReturnValue; - } - - SignatureKind::ReturnVoid } fn signature_is_retval(&self, signature: &Signature) -> bool { signature.params.last().map_or(false, |param| self.signature_param_is_retval(param)) @@ -1545,7 +1529,7 @@ impl<'a> Reader<'a> { continue; } let signature = self.method_def_signature(method, generics); - signature.return_type.iter().for_each(|ty| self.type_collect_standalone(ty, set)); + self.type_collect_standalone(&signature.return_type, set); signature.params.iter().for_each(|param| self.type_collect_standalone(¶m.ty, set)); } for interface in self.type_interfaces(&ty) { @@ -1748,38 +1732,41 @@ impl<'a> Reader<'a> { panic!("Type not found: {}", full_name); } } - fn type_from_blob(&self, blob: &mut Blob, enclosing: Option, generics: &[Type]) -> Option { - let is_winrt_const_ref = blob.read_modifiers().iter().any(|def| self.type_def_or_ref(*def) == TypeName::IsConst); - let is_winrt_array_ref = blob.read_expected(0x10); - if blob.read_expected(0x01) { - return None; + fn type_from_blob(&self, blob: &mut Blob, enclosing: Option, generics: &[Type]) -> Type { + // Used by WinRT to indicate that a struct input parameter is passed by reference rather than by value on the ABI. + let is_const = blob.read_modifiers().iter().any(|def| self.type_def_or_ref(*def) == TypeName::IsConst); + + // Used by WinRT to indicate an output parameter, but there are other ways to determine this direction so here + // it is only used to distinguish between slices and heap-allocated arrays. + let is_ref = blob.read_expected(ELEMENT_TYPE_BYREF as _); + + if blob.read_expected(ELEMENT_TYPE_VOID as _) { + return Type::Void; } - let is_winrt_array = blob.read_expected(0x1D); + let is_array = blob.read_expected(ELEMENT_TYPE_SZARRAY as _); // Used by WinRT to indicate an array let mut pointers = 0; - while blob.read_expected(0x0f) { + while blob.read_expected(ELEMENT_TYPE_PTR as _) { pointers += 1; } - let mut kind = self.type_from_blob_impl(blob, enclosing, generics); + let kind = self.type_from_blob_impl(blob, enclosing, generics); if pointers > 0 { - kind = Type::MutPtr((Box::new(kind), pointers)); - } - - Some(if is_winrt_array { - if is_winrt_array_ref { + Type::MutPtr((Box::new(kind), pointers)) + } else if is_const { + Type::ConstRef(Box::new(kind)) + } else if is_array { + if is_ref { Type::WinrtArrayRef(Box::new(kind)) } else { Type::WinrtArray(Box::new(kind)) } - } else if is_winrt_const_ref { - Type::WinrtConstRef(Box::new(kind)) } else { kind - }) + } } fn type_from_blob_impl(&self, blob: &mut Blob, enclosing: Option, generics: &[Type]) -> Type { let code = blob.read_usize(); @@ -1788,17 +1775,17 @@ impl<'a> Reader<'a> { return code; } - match code { - 0x11 | 0x12 => self.type_from_ref(TypeDefOrRef::decode(blob.file, blob.read_usize()), enclosing, generics), - 0x13 => generics.get(blob.read_usize()).unwrap_or(&Type::Void).clone(), - 0x14 => { - let kind = self.type_from_blob(blob, enclosing, generics).unwrap(); + match code as _ { + ELEMENT_TYPE_VALUETYPE | ELEMENT_TYPE_CLASS => self.type_from_ref(TypeDefOrRef::decode(blob.file, blob.read_usize()), enclosing, generics), + ELEMENT_TYPE_VAR => generics.get(blob.read_usize()).unwrap_or(&Type::Void).clone(), + ELEMENT_TYPE_ARRAY => { + let kind = self.type_from_blob(blob, enclosing, generics); let _rank = blob.read_usize(); - let _bounds_count = blob.read_usize(); + let _count = blob.read_usize(); let bounds = blob.read_usize(); Type::Win32Array((Box::new(kind), bounds)) } - 0x15 => { + ELEMENT_TYPE_GENERICINST => { blob.read_usize(); let def = self.get(self.type_def_or_ref(TypeDefOrRef::decode(blob.file, blob.read_usize()))).next().expect("Type not found"); diff --git a/crates/libs/metadata/src/reader/type.rs b/crates/libs/metadata/src/reader/type.rs index fca31f9ac0..4d52f8146c 100644 --- a/crates/libs/metadata/src/reader/type.rs +++ b/crates/libs/metadata/src/reader/type.rs @@ -35,31 +35,31 @@ pub enum Type { Win32Array((Box, usize)), WinrtArray(Box), WinrtArrayRef(Box), - WinrtConstRef(Box), + ConstRef(Box), } impl Type { /// Creates a `Type` object from an `ELEMENT_TYPE` (see ECMA-335) type constant, typically /// used to indicate the type of a constant or primitive type signature. pub fn from_code(code: usize) -> Option { - match code { - 0x01 => Some(Self::Void), - 0x02 => Some(Self::Bool), - 0x03 => Some(Self::Char), - 0x04 => Some(Self::I8), - 0x05 => Some(Self::U8), - 0x06 => Some(Self::I16), - 0x07 => Some(Self::U16), - 0x08 => Some(Self::I32), - 0x09 => Some(Self::U32), - 0x0a => Some(Self::I64), - 0x0b => Some(Self::U64), - 0x0c => Some(Self::F32), - 0x0d => Some(Self::F64), - 0x18 => Some(Self::ISize), - 0x19 => Some(Self::USize), - 0x0e => Some(Self::String), - 0x1c => Some(Self::IInspectable), + match code as _ { + ELEMENT_TYPE_VOID => Some(Self::Void), + ELEMENT_TYPE_BOOLEAN => Some(Self::Bool), + ELEMENT_TYPE_CHAR => Some(Self::Char), + ELEMENT_TYPE_I1 => Some(Self::I8), + ELEMENT_TYPE_U1 => Some(Self::U8), + ELEMENT_TYPE_I2 => Some(Self::I16), + ELEMENT_TYPE_U2 => Some(Self::U16), + ELEMENT_TYPE_I4 => Some(Self::I32), + ELEMENT_TYPE_U4 => Some(Self::U32), + ELEMENT_TYPE_I8 => Some(Self::I64), + ELEMENT_TYPE_U8 => Some(Self::U64), + ELEMENT_TYPE_R4 => Some(Self::F32), + ELEMENT_TYPE_R8 => Some(Self::F64), + ELEMENT_TYPE_I => Some(Self::ISize), + ELEMENT_TYPE_U => Some(Self::USize), + ELEMENT_TYPE_STRING => Some(Self::String), + ELEMENT_TYPE_OBJECT => Some(Self::IInspectable), _ => None, } } @@ -82,7 +82,7 @@ impl Type { Type::Win32Array((ty, _)) => *ty.clone(), Type::WinrtArray(ty) => *ty.clone(), Type::WinrtArrayRef(ty) => *ty.clone(), - Type::WinrtConstRef(ty) => *ty.clone(), + Type::ConstRef(ty) => *ty.clone(), _ => self.clone(), } } @@ -125,8 +125,8 @@ impl Type { } /// Returns `true` if the `Type` represents an immutable WinRT array reference. - pub fn is_winrt_const_ref(&self) -> bool { - matches!(self, Type::WinrtConstRef(_)) + pub fn is_const_ref(&self) -> bool { + matches!(self, Type::ConstRef(_)) } /// Returns `true` if the `Type` is a generic parameter. diff --git a/crates/libs/metadata/src/reader/type_name.rs b/crates/libs/metadata/src/reader/type_name.rs index 2f6f96d77d..c4d72e3986 100644 --- a/crates/libs/metadata/src/reader/type_name.rs +++ b/crates/libs/metadata/src/reader/type_name.rs @@ -6,7 +6,6 @@ pub struct TypeName<'a> { #[allow(non_upper_case_globals)] impl<'a> TypeName<'a> { - pub const None: Self = Self::from_const("", ""); pub const Enum: Self = Self::from_const("System", "Enum"); pub const Delegate: Self = Self::from_const("System", "MulticastDelegate"); pub const Struct: Self = Self::from_const("System", "ValueType"); diff --git a/crates/libs/metadata/src/writer/extend.rs b/crates/libs/metadata/src/writer/extend.rs new file mode 100644 index 0000000000..74d2a487fc --- /dev/null +++ b/crates/libs/metadata/src/writer/extend.rs @@ -0,0 +1,16 @@ +use super::*; + +// TODO: for the scraper we need a per-module toml file that can contain the mapping of headers and other info +// used to filter/transform the data for that module. This can be used by third parties to generate idl/metadata +// for their APIs too. + +pub fn extend(_base: &mut Module, _other: Module) { + // Adds any `new` declarations to `prev` leaving existing declarations intact. + // May be used by tool that parses other sources, like .h and .idl files from the Windows SDK + // to keep a canonical rs/idl style repo updated. + // The resulting `Module` can then be written out as idl with `to_idl` and to update the repo + // in place. + // Maybe return a list of differences that were ignored + + todo!() +} diff --git a/crates/libs/metadata/src/writer/idl/format.rs b/crates/libs/metadata/src/writer/idl/format.rs new file mode 100644 index 0000000000..04ff4faf9f --- /dev/null +++ b/crates/libs/metadata/src/writer/idl/format.rs @@ -0,0 +1,305 @@ +use super::*; + +pub fn format_idl(source: &str) -> Result { + let mut printer = Printer::new(); + printer.idl_file(&IdlFile::parse_str(source)?); + Ok(printer.out) + // TODO: workaround until we have complete formatting support + //Ok(source.to_string()) +} + +#[derive(Default)] +struct Printer { + out: String, + indent: usize, + newline: bool, +} + +impl Printer { + fn new() -> Self { + Self::default() + } + + fn word(&mut self, value: &str) { + if self.newline { + self.newline = false; + self.out.push('\n'); + for _ in 0..self.indent { + self.out.push_str(" "); + } + } + + self.out.push_str(value); + } + + fn newline(&mut self) { + self.newline = true; + } + + fn idl_file(&mut self, file: &IdlFile) { + for reference in &file.references { + self.item_use(reference); + } + + for module in &file.modules { + self.idl_module(module); + } + } + + fn idl_module(&mut self, module: &IdlModule) { + self.word("mod "); + self.ident(&module.ident); + self.word(" {"); + self.newline(); + self.indent += 1; + + for member in &module.members { + self.idl_module_member(member); + self.newline(); + } + + self.indent -= 1; + self.newline(); + self.word("}"); + } + + fn idl_module_member(&mut self, member: &IdlModuleMember) { + match member { + IdlModuleMember::Module(member) => self.idl_module(member), + IdlModuleMember::Interface(member) => self.idl_interface(member), + IdlModuleMember::Struct(member) => self.idl_struct(member), + IdlModuleMember::Enum(member) => self.idl_enum(member), + IdlModuleMember::Class(member) => self.idl_class(member), + } + } + + fn idl_interface(&mut self, member: &IdlInterface) { + self.word("interface "); + self.ident(&member.ident); + self.word(" {"); + self.newline(); + self.indent += 1; + + for method in &member.methods { + self.trait_item_method(method); + self.word(";"); + self.newline(); + } + + self.indent -= 1; + self.newline(); + self.word("}"); + } + + fn idl_struct(&mut self, member: &IdlStruct) { + self.word("struct "); + self.ident(&member.item.ident); + self.word(" {"); + self.newline(); + self.indent += 1; + + if let syn::Fields::Named(fields) = &member.item.fields { + for field in &fields.named { + self.field(field); + self.word(","); + self.newline(); + } + } + + self.indent -= 1; + self.newline(); + self.word("}"); + } + + fn idl_enum(&mut self, member: &IdlEnum) { + self.word("enum "); + self.ident(&member.item.ident); + self.word(" {"); + self.newline(); + self.indent += 1; + + for variant in &member.item.variants { + self.ident(&variant.ident); + if let Some((_, expr)) = &variant.discriminant { + self.word(" = "); + self.expr(expr); + } + self.word(","); + self.newline(); + } + + self.indent -= 1; + self.newline(); + self.word("}"); + } + + fn idl_class(&mut self, _member: &IdlClass) {} + + fn trait_item_method(&mut self, method: &syn::TraitItemMethod) { + self.signature(&method.sig); + } + + fn signature(&mut self, signature: &syn::Signature) { + self.word("fn "); + self.ident(&signature.ident); + self.word("("); + + let mut first = true; + for input in &signature.inputs { + if first { + first = false; + } else { + self.word(", "); + } + self.fn_arg(input); + } + + self.word(")"); + + if let syn::ReturnType::Type(_, ty) = &signature.output { + self.word(" -> "); + self.ty(ty); + } + } + + fn fn_arg(&mut self, fn_arg: &syn::FnArg) { + if let syn::FnArg::Typed(pat_type) = fn_arg { + self.pat_type(pat_type); + } + } + + fn pat_type(&mut self, pat_type: &syn::PatType) { + self.pat(&pat_type.pat); + self.word(": "); + self.ty(&pat_type.ty); + } + + fn pat(&mut self, pat: &syn::Pat) { + match pat { + syn::Pat::Ident(pat_ident) => self.pat_ident(pat_ident), + _ => todo!("{:?}", pat), + } + } + + fn pat_ident(&mut self, pat_ident: &syn::PatIdent) { + self.ident(&pat_ident.ident); + } + + fn field(&mut self, field: &syn::Field) { + if let Some(ref ident) = field.ident { + self.ident(ident); + self.word(": "); + self.ty(&field.ty); + } + } + + fn ty(&mut self, ty: &syn::Type) { + match ty { + syn::Type::Path(ty) => self.type_path(ty), + syn::Type::Ptr(ptr) => self.type_ptr(ptr), + syn::Type::Array(array) => self.type_array(array), + _ => todo!("{:?}", ty), + } + } + + fn type_array(&mut self, array: &syn::TypeArray) { + self.word("["); + self.ty(&array.elem); + self.word("; "); + self.expr(&array.len); + self.word("]"); + } + + fn expr(&mut self, expr: &syn::Expr) { + match expr { + syn::Expr::Lit(lit) => self.expr_lit(lit), + syn::Expr::Unary(unary) => self.expr_unary(unary), + _ => todo!("{:?}", expr), + } + } + + fn expr_unary(&mut self, unary: &syn::ExprUnary) { + self.word("-"); + self.expr(&unary.expr); + } + + fn expr_lit(&mut self, expr: &syn::ExprLit) { + self.lit(&expr.lit); + } + + fn lit(&mut self, lit: &syn::Lit) { + match lit { + syn::Lit::Int(lit) => self.lit_int(lit), + syn::Lit::Str(lit) => self.lit_str(lit), + _ => _ = dbg!(lit), + } + } + + fn lit_str(&mut self, lit: &syn::LitStr) { + self.word("\""); + self.word(&lit.value()); + self.word("\""); + } + + fn lit_int(&mut self, lit: &syn::LitInt) { + self.word(&lit.token().to_string()); + } + + fn type_ptr(&mut self, ptr: &syn::TypePtr) { + if ptr.mutability.is_some() { + self.word("*mut "); + } else { + self.word("*const "); + } + self.ty(&ptr.elem); + } + + fn type_path(&mut self, ty: &syn::TypePath) { + self.path(&ty.path); + } + + fn path(&mut self, path: &syn::Path) { + let mut first = true; + for segment in &path.segments { + if first { + first = false; + } else { + self.word("::"); + } + self.path_segment(segment); + } + } + + pub fn path_segment(&mut self, segment: &syn::PathSegment) { + self.ident(&segment.ident); + } + + fn item_use(&mut self, item: &syn::ItemUse) { + self.word("use "); + self.use_tree(&item.tree); + self.word(";"); + self.newline(); + } + + fn use_tree(&mut self, use_tree: &syn::UseTree) { + match use_tree { + syn::UseTree::Path(use_path) => self.use_path(use_path), + syn::UseTree::Name(use_name) => self.use_name(use_name), + _ => {} + } + } + + fn use_path(&mut self, use_path: &syn::UsePath) { + self.ident(&use_path.ident); + self.word("::"); + self.use_tree(&use_path.tree); + } + + fn use_name(&mut self, use_name: &syn::UseName) { + self.ident(&use_name.ident); + } + + pub fn ident(&mut self, ident: &syn::Ident) { + self.word(&ident.to_string()); + } +} diff --git a/crates/libs/metadata/src/writer/idl/mod.rs b/crates/libs/metadata/src/writer/idl/mod.rs new file mode 100644 index 0000000000..dd8f572019 --- /dev/null +++ b/crates/libs/metadata/src/writer/idl/mod.rs @@ -0,0 +1,49 @@ +mod format; +mod parse; +mod read; +mod write; + +use super::*; +pub use format::*; +pub use read::*; +pub use write::*; + +pub struct IdlFile { + references: Vec, + modules: Vec, +} + +pub struct IdlModule { + attributes: Vec, // winrt/win32 + ident: syn::Ident, + members: Vec, +} + +pub enum IdlModuleMember { + Module(IdlModule), + Interface(IdlInterface), + Struct(IdlStruct), + Enum(IdlEnum), + Class(IdlClass), + // Function and Delegate +} + +pub struct IdlEnum { + item: syn::ItemEnum, +} + +pub struct IdlStruct { + item: syn::ItemStruct, +} + +pub struct IdlClass { + attributes: Vec, + ident: syn::Ident, + extends: Vec, +} + +pub struct IdlInterface { + attributes: Vec, + ident: syn::Ident, + methods: Vec, +} diff --git a/crates/libs/metadata/src/writer/idl/parse.rs b/crates/libs/metadata/src/writer/idl/parse.rs new file mode 100644 index 0000000000..7495ac11ba --- /dev/null +++ b/crates/libs/metadata/src/writer/idl/parse.rs @@ -0,0 +1,120 @@ +use super::*; +use syn::spanned::Spanned; + +// TODO: always set the winrt bit on the assembly but only set the winrt bit on the TypeDef if its a WinRT type. +// Also, use a file-level attribute in the IDL file to indicate whether it contains WinRT or Win32 types +// e.g. #![win32|winrt] - with default being winrt - that way Win32 and WinRT types could conceivably share a +// namespace but live in separate IDL files to simplify the IDL syntax. + +syn::custom_keyword!(interface); +syn::custom_keyword!(class); + +impl IdlFile { + pub fn parse_str(source: &str) -> Result { + Ok(syn::parse_str::(source)?) + } +} + +impl syn::parse::Parse for IdlFile { + fn parse(input: syn::parse::ParseStream) -> syn::Result { + let mut references = vec![]; + let mut modules = vec![]; + while !input.is_empty() { + let lookahead = input.lookahead1(); + if lookahead.peek(syn::Token![mod]) { + modules.push(input.parse()?); + } else if lookahead.peek(syn::Token![use]) { + references.push(input.parse()?); + } else { + return Err(lookahead.error()); + } + } + Ok(Self { references, modules }) + } +} + +impl syn::parse::Parse for IdlModule { + fn parse(input: syn::parse::ParseStream) -> syn::Result { + input.parse::()?; + let ident = input.parse::()?; + let content; + syn::braced!(content in input); + let mut members = vec![]; + while !content.is_empty() { + members.push(content.parse::()?); + } + Ok(Self { attributes: vec![], ident, members }) + } +} + +impl syn::parse::Parse for IdlModuleMember { + fn parse(input: syn::parse::ParseStream) -> syn::Result { + let attributes: Vec = input.call(syn::Attribute::parse_outer)?; + let lookahead = input.lookahead1(); + if lookahead.peek(syn::Token![mod]) { + if let Some(attribute) = attributes.first() { + return Err(syn::Error::new(attribute.span(), "module attribute are not supported")); + } + Ok(IdlModuleMember::Module(input.parse()?)) + } else if lookahead.peek(interface) { + Ok(IdlModuleMember::Interface(IdlInterface::parse(attributes, input)?)) + } else if lookahead.peek(syn::Token![struct]) { + Ok(IdlModuleMember::Struct(IdlStruct::parse(attributes, input)?)) + } else if lookahead.peek(syn::Token![enum]) { + Ok(IdlModuleMember::Enum(IdlEnum::parse(attributes, input)?)) + } else if lookahead.peek(class) { + Ok(IdlModuleMember::Class(IdlClass::parse(attributes, input)?)) + } else { + Err(lookahead.error()) + } + } +} + +impl IdlClass { + fn parse(attributes: Vec, input: syn::parse::ParseStream) -> syn::Result { + input.parse::()?; + let ident = input.parse::()?; + let mut extends = Vec::new(); + + if input.peek(syn::Token![:]) { + input.parse::()?; + while input.peek(syn::Ident) { + extends.push(input.parse::()?); + _ = input.parse::(); + } + } + + input.parse::()?; + Ok(Self { attributes, ident, extends }) + } +} + +impl IdlInterface { + fn parse(attributes: Vec, input: syn::parse::ParseStream) -> syn::Result { + input.parse::()?; + let ident = input.parse::()?; + let content; + syn::braced!(content in input); + let mut methods = vec![]; + while !content.is_empty() { + methods.push(content.parse::()?); + } + Ok(Self { attributes, ident, methods }) + } +} + +impl IdlStruct { + fn parse(attributes: Vec, input: syn::parse::ParseStream) -> syn::Result { + let mut item: syn::ItemStruct = input.parse()?; + item.attrs = attributes; + Ok(Self { item }) + } +} + +impl IdlEnum { + fn parse(attributes: Vec, input: syn::parse::ParseStream) -> syn::Result { + let mut item: syn::ItemEnum = input.parse()?; + item.attrs = attributes; + Ok(Self { item }) + } +} diff --git a/crates/libs/metadata/src/writer/idl/read.rs b/crates/libs/metadata/src/writer/idl/read.rs new file mode 100644 index 0000000000..bef19a68d9 --- /dev/null +++ b/crates/libs/metadata/src/writer/idl/read.rs @@ -0,0 +1,303 @@ +use super::*; +use syn::spanned::Spanned; + +#[derive(PartialEq, Copy, Clone)] +enum ReadPhase { + Index, + Define, +} + +pub fn read_idl(tree: &mut Module, paths: &[String], filter: &Filter) -> Result<()> { + let mut files = vec![]; + + for path in paths { + if extension(path).1 == "idl" { + files.push((path.as_str(), IdlFile::parse_str(&read_to_string(path)?).map_err(|error| error.with_path(path))?)); + } + } + + for (path, file) in &files { + read_file(tree, file, filter, ReadPhase::Index).map_err(|error| error.with_path(path))?; + } + + for (path, file) in &files { + read_file(tree, file, filter, ReadPhase::Define).map_err(|error| error.with_path(path))?; + } + + Ok(()) +} + +fn read_file(tree: &mut Module, file: &IdlFile, filter: &Filter, phase: ReadPhase) -> Result<()> { + for module in &file.modules { + read_module(tree, file, module, &module.ident.to_string(), filter, phase)?; + } + + Ok(()) +} + +fn read_module(tree: &mut Module, file: &IdlFile, module: &IdlModule, namespace: &str, filter: &Filter, phase: ReadPhase) -> Result<()> { + if filter.includes_namespace(namespace) { + for member in &module.members { + read_member(tree, file, member, namespace, filter, phase)?; + } + } + + Ok(()) +} + +fn read_member(tree: &mut Module, file: &IdlFile, member: &IdlModuleMember, namespace: &str, filter: &Filter, phase: ReadPhase) -> Result<()> { + match member { + IdlModuleMember::Module(member) => read_module(tree, file, member, &format!("{namespace}.{}", member.ident), filter, phase), + IdlModuleMember::Interface(member) => read_interface(tree, file, member, namespace, filter, phase), + IdlModuleMember::Struct(member) => read_struct(tree, file, member, namespace, filter, phase), + IdlModuleMember::Enum(member) => read_enum(tree, file, member, namespace, filter, phase), + IdlModuleMember::Class(member) => read_class(tree, file, member, namespace, filter, phase), + } +} + +fn read_interface(tree: &mut Module, _file: &IdlFile, ty: &IdlInterface, namespace: &str, filter: &Filter, phase: ReadPhase) -> Result<()> { + let ident = ty.ident.to_string(); + + if filter.includes_type_name(reader::TypeName::new(namespace, &ident)) { + let vec = tree.insert(namespace, 0).types.entry(ident).or_default(); + + if phase == ReadPhase::Define { + let mut def = TypeDef { extends: None, ..Default::default() }; + + for method in &ty.methods { + let name = method.sig.ident.to_string(); + let mut params = vec![]; + + for input in &method.sig.inputs { + let syn::FnArg::Typed(pat_type) = input else { + todo!(); + }; + + let syn::Pat::Ident(ref pat_ident) = *pat_type.pat else { + todo!(); + }; + + let name = pat_ident.ident.to_string(); + let ty = read_ty(namespace, &pat_type.ty)?; + params.push(Param { name, ty, ..Default::default() }); + } + + let ty = if let syn::ReturnType::Type(_, ty) = &method.sig.output { read_ty(namespace, ty)? } else { Type::Void }; + let return_type = Param { ty, ..Default::default() }; + + def.methods.push(Method { name, params, return_type, ..Default::default() }); + } + + vec.push(def); + } + } + + Ok(()) +} + +fn read_struct(tree: &mut Module, _file: &IdlFile, ty: &IdlStruct, namespace: &str, filter: &Filter, phase: ReadPhase) -> Result<()> { + let ident = ty.item.ident.to_string(); + + if filter.includes_type_name(reader::TypeName::new(namespace, &ident)) { + let vec = tree.insert(namespace, 0).types.entry(ident).or_default(); + + if phase == ReadPhase::Define { + let mut def = TypeDef { extends: Some(TypeRef { namespace: "System".to_string(), name: "ValueType".to_string(), ..Default::default() }), ..Default::default() }; + + let syn::Fields::Named(fields) = &ty.item.fields else { + unimplemented!(); + }; + + for field in &fields.named { + let Some(ref ident) = field.ident else { + unimplemented!(); + }; + + let flags = FieldAttributes::PUBLIC; + let name = ident.to_string(); + let ty = read_ty(namespace, &field.ty)?; + def.fields.push(Field { flags, name, ty, ..Default::default() }); + } + + vec.push(def); + } + } + + Ok(()) +} + +fn read_enum(tree: &mut Module, _file: &IdlFile, ty: &IdlEnum, namespace: &str, filter: &Filter, phase: ReadPhase) -> Result<()> { + let ident = ty.item.ident.to_string(); + + if filter.includes_type_name(reader::TypeName::new(namespace, &ident)) { + let vec = tree.insert(namespace, 0).types.entry(ident.clone()).or_default(); + + if phase == ReadPhase::Define { + let mut def = TypeDef { extends: Some(TypeRef { namespace: "System".to_string(), name: "Enum".to_string(), ..Default::default() }), ..Default::default() }; + let enum_type = Type::TypeRef(TypeRef { namespace: namespace.to_string(), name: ident, ..Default::default() }); + + for variant in &ty.item.variants { + if let Some((_, expr)) = &variant.discriminant { + let flags = FieldAttributes::PUBLIC; + let name = variant.ident.to_string(); + let value = read_expr(expr, false)?; + + def.fields.push(Field { flags, name, ty: enum_type.clone(), value: Some(value) }); + } + } + + vec.push(def); + } + } + + Ok(()) +} + +fn read_class(tree: &mut Module, _file: &IdlFile, ty: &IdlClass, namespace: &str, filter: &Filter, _phase: ReadPhase) -> Result<()> { + let ident = ty.ident.to_string(); + + if filter.includes_type_name(reader::TypeName::new(namespace, &ident)) { + tree.insert(namespace, 0).types.entry(ident).or_default(); + } + + Ok(()) +} + +fn read_expr(expr: &syn::Expr, neg: bool) -> Result { + match expr { + syn::Expr::Lit(lit) => read_expr_lit(lit, neg), + syn::Expr::Unary(unary) => read_expr_unary(unary), + _ => todo!("{:?}", expr), + } +} + +fn read_expr_unary(unary: &syn::ExprUnary) -> Result { + read_expr(&unary.expr, true) +} + +fn read_expr_lit(expr: &syn::ExprLit, neg: bool) -> Result { + read_lit(&expr.lit, neg) +} + +fn read_lit(lit: &syn::Lit, neg: bool) -> Result { + match lit { + syn::Lit::Int(lit) => read_lit_int(lit, neg), + syn::Lit::Str(lit) => read_lit_str(lit), + _ => todo!("{:?}", lit), + } +} + +fn read_lit_str(lit: &syn::LitStr) -> Result { + Ok(Value::String(lit.value())) +} + +fn read_lit_int(lit: &syn::LitInt, neg: bool) -> Result { + fn parse(lit: &syn::LitInt, neg: bool) -> Result { + let raw = if neg { format!("-{}", lit.base10_digits()) } else { lit.base10_digits().to_string() }; + raw.parse().map_err(|_| Error::new("failed to parse literal").with_span(lit.span())) + } + + match lit.suffix() { + "i8" => Ok(Value::I8(parse(lit, neg)?)), + "u8" => Ok(Value::U8(parse(lit, neg)?)), + "i16" => Ok(Value::I16(parse(lit, neg)?)), + "u16" => Ok(Value::U16(parse(lit, neg)?)), + "i32" => Ok(Value::I32(parse(lit, neg)?)), + "u32" => Ok(Value::U32(parse(lit, neg)?)), + "i64" => Ok(Value::I64(parse(lit, neg)?)), + "u64" => Ok(Value::U64(parse(lit, neg)?)), + suffix => todo!("suffix {:?}", suffix), + } +} + +fn read_ty(namespace: &str, ty: &syn::Type) -> Result { + match ty { + syn::Type::Path(ty) => read_type_path(namespace, ty), + syn::Type::Ptr(ptr) => read_type_ptr(namespace, ptr), + syn::Type::Array(array) => read_type_array(namespace, array), + _ => unimplemented!(), + } +} + +fn read_type_array(namespace: &str, array: &syn::TypeArray) -> Result { + let ty = read_ty(namespace, &array.elem)?; + + if let syn::Expr::Lit(lit) = &array.len { + if let syn::Lit::Int(lit) = &lit.lit { + return Ok(ty.into_array(lit.base10_parse()?)); + } + } + + todo!() +} + +fn read_type_ptr(namespace: &str, ptr: &syn::TypePtr) -> Result { + let ty = read_ty(namespace, &ptr.elem)?; + if ptr.mutability.is_some() { + Ok(ty.into_mut_ptr()) + } else { + Ok(ty.into_const_ptr()) + } +} + +fn read_type_path(namespace: &str, ty: &syn::TypePath) -> Result { + if ty.qself.is_some() { + unimplemented!(); + } + + read_path(namespace, &ty.path) +} + +fn read_path(current: &str, path: &syn::Path) -> Result { + if let Some(segment) = path.segments.first() { + if path.segments.len() == 1 { + let name = segment.ident.to_string(); + + return match name.as_str() { + "void" => Ok(Type::Void), + "bool" => Ok(Type::Bool), + "char" => Ok(Type::Char), + "i8" => Ok(Type::I8), + "u8" => Ok(Type::U8), + "i16" => Ok(Type::I16), + "u16" => Ok(Type::U16), + "i32" => Ok(Type::I32), + "u32" => Ok(Type::U32), + "i64" => Ok(Type::I64), + "u64" => Ok(Type::U64), + "f32" => Ok(Type::F32), + "f64" => Ok(Type::F64), + "isize" => Ok(Type::ISize), + "usize" => Ok(Type::USize), + "HSTRING" => Ok(Type::String), + "GUID" => Ok(Type::GUID), + "IUnknown" => Ok(Type::IUnknown), + "IInspectable" => Ok(Type::IInspectable), + "HRESULT" => Ok(Type::HRESULT), + "PSTR" => Ok(Type::PSTR), + "PWSTR" => Ok(Type::PWSTR), + "PCSTR" => Ok(Type::PCSTR), + "PCWSTR" => Ok(Type::PCWSTR), + "BSTR" => Ok(Type::BSTR), + _ => Ok(Type::TypeRef(TypeRef { namespace: current.to_string(), name, ..Default::default() })), + }; + } + } + + let mut current: Vec = current.split('.').map(|segment| segment.to_string()).collect(); + let mut name = vec![]; + + for segment in &path.segments { + let segment = segment.ident.to_string(); + if segment == "super" { + current.pop().ok_or_else(|| syn::Error::new(path.span(), "no parent module"))?; + } else { + name.append(&mut current); + name.push(segment); + } + } + + let (last, rest) = name.split_last().ok_or_else(|| syn::Error::new(path.span(), "no type name"))?; + + Ok(Type::TypeRef(TypeRef { namespace: rest.join("."), name: last.to_string(), ..Default::default() })) +} diff --git a/crates/libs/metadata/src/writer/idl/write.rs b/crates/libs/metadata/src/writer/idl/write.rs new file mode 100644 index 0000000000..c49e3ba9ee --- /dev/null +++ b/crates/libs/metadata/src/writer/idl/write.rs @@ -0,0 +1,264 @@ +use super::*; +use tokens::*; + +pub fn write_idl(module: &Module, path: &str) -> Result<()> { + write_to_file(path, format_idl(&module_to_idl("", module).to_string()).map_err(|error| error.with_path(path))?) +} + +fn module_to_idl(name: &str, module: &Module) -> TokenStream { + let modules = module.modules.iter().map(|(name, module)| module_to_idl(name, module)); + + if name.is_empty() { + quote! { #(#modules)* } + } else { + let name = to_ident(name); + let types = module.types.iter().flat_map(|(name, ty)| ty.iter().map(move |ty| (name, ty))).map(|(name, ty)| type_def_to_idl(module, name, ty)); + + quote! { + mod #name { + #(#modules)* + #(#types)* + } + } + } +} + +fn type_def_to_idl(module: &Module, name: &str, ty: &TypeDef) -> TokenStream { + if let Some(extends) = &ty.extends { + if extends.namespace == "System" { + if extends.name == "Enum" { + enum_to_idl(module, name, ty) + } else if extends.name == "ValueType" { + struct_to_idl(module, name, ty) + } else if extends.name == "MulticastDelegate" { + delegate_to_idl(module, name, ty) + } else { + class_to_idl(module, name, ty) + } + } else { + class_to_idl(module, name, ty) + } + } else { + interface_to_idl(module, name, ty) + } +} + +fn enum_to_idl(_module: &Module, name: &str, ty: &TypeDef) -> TokenStream { + let name = to_ident(name); + + let constants = ty.fields.iter().filter_map(|field| { + let Some(value) = &field.value else { + return None; + }; + + let name = to_ident(&field.name); + let value: TokenStream = value.to_expr().into(); + + Some(quote! { + #name = #value + }) + }); + + quote! { + enum #name { + #(#constants),* + } + } +} + +fn struct_to_idl(module: &Module, name: &str, ty: &TypeDef) -> TokenStream { + let name = to_ident(name); + + let fields = ty.fields.iter().map(|field| { + let name = to_ident(&field.name); + let ty = type_to_idl(module, &field.ty); + quote! { + #name: #ty + } + }); + + quote! { + struct #name { + #(#fields),* + } + } +} + +fn delegate_to_idl(_module: &Module, name: &str, _ty: &TypeDef) -> TokenStream { + let name = to_ident(name); + + quote! { + struct #name(); + } +} + +fn class_to_idl(_module: &Module, name: &str, _ty: &TypeDef) -> TokenStream { + let name = to_ident(name); + + quote! { + struct #name { + } + } +} + +fn interface_to_idl(module: &Module, name: &str, ty: &TypeDef) -> TokenStream { + let name = to_ident(name); + + let methods = ty.methods.iter().map(|method| { + let name = to_ident(&method.name); + let params = method.params.iter().map(|param| { + let name = to_ident(¶m.name); + let ty = type_to_idl(module, ¶m.ty); + quote! { #name: #ty } + }); + let return_type = if method.return_type.ty != Type::Void { + let ty = type_to_idl(module, &method.return_type.ty); + quote! { -> #ty } + } else { + quote! {} + }; + quote! { + fn #name(#(#params),*) #return_type; + } + }); + + quote! { + interface #name { + #(#methods)* + } + } +} + +fn type_to_idl(module: &Module, ty: &Type) -> TokenStream { + match ty { + Type::Void => quote! { ::core::ffi::c_void }, + Type::Bool => quote! { bool }, + Type::Char => quote! { u16 }, + Type::I8 => quote! { i8 }, + Type::U8 => quote! { u8 }, + Type::I16 => quote! { i16 }, + Type::U16 => quote! { u16 }, + Type::I32 => quote! { i32 }, + Type::U32 => quote! { u32 }, + Type::I64 => quote! { i64 }, + Type::U64 => quote! { u64 }, + Type::F32 => quote! { f32 }, + Type::F64 => quote! { f64 }, + Type::ISize => quote! { isize }, + Type::USize => quote! { usize }, + Type::String => { + quote! { HSTRING } + } + Type::BSTR => { + quote! { BSTR } + } + Type::IInspectable => { + quote! { IInspectable } + } + Type::GUID => { + quote! { GUID } + } + Type::IUnknown => { + quote! { IUnknown } + } + Type::HRESULT => { + quote! { HRESULT } + } + Type::PSTR => { + quote! { PSTR } + } + Type::PWSTR => { + quote! { PWSTR } + } + Type::PCSTR => { + quote! { PCSTR } + } + Type::PCWSTR => { + quote! { PCWSTR } + } + Type::Win32Array((ty, len)) => { + let ty = type_to_idl(module, ty); + let len = Literal::usize_unsuffixed(*len); + quote! { [#ty; #len] } + } + Type::GenericParam(generic) => { + let generic = to_ident(generic); + quote! { #generic } + } + Type::TypeRef(ty) => { + let namespace = namespace_to_idl(module, &ty.namespace); + let name = to_ident(&ty.name); + if ty.generics.is_empty() { + quote! { #namespace#name } + } else { + let generics = ty.generics.iter().map(|ty| type_to_idl(module, ty)); + quote! { #namespace#name<#(#generics,)*> } + } + } + Type::MutPtr((ty, pointers)) => { + let pointers = mut_ptrs(*pointers); + let ty = type_to_idl(module, ty); + quote! { #pointers #ty } + } + Type::ConstPtr((ty, pointers)) => { + let pointers = const_ptrs(*pointers); + let ty = type_to_idl(module, ty); + quote! { #pointers #ty } + } + Type::WinrtArray(ty) => type_to_idl(module, ty), + Type::WinrtArrayRef(ty) => type_to_idl(module, ty), + Type::ConstRef(ty) => type_to_idl(module, ty), + _ => todo!(), + } +} + +fn namespace_to_idl(module: &Module, namespace: &str) -> TokenStream { + // TODO: handle nested structs? + if namespace.is_empty() || namespace == module.namespace { + quote! {} + } else { + let mut relative = module.namespace.split('.').peekable(); + let mut namespace = namespace.split('.').peekable(); + + while relative.peek() == namespace.peek() { + if relative.next().is_none() { + break; + } + + namespace.next(); + } + + let mut tokens = TokenStream::new(); + + for _ in 0..relative.count() { + tokens.push_str("super::"); + } + + for namespace in namespace { + tokens.push_str(namespace); + tokens.push_str("::"); + } + + tokens + } +} + +// TODO: maybe move these into `tokens` crate as they duplicated in bindgen + +pub fn to_ident(name: &str) -> TokenStream { + // keywords list based on https://doc.rust-lang.org/reference/keywords.html + match name { + "abstract" | "as" | "become" | "box" | "break" | "const" | "continue" | "crate" | "do" | "else" | "enum" | "extern" | "false" | "final" | "fn" | "for" | "if" | "impl" | "in" | "let" | "loop" | "macro" | "match" | "mod" | "move" | "mut" | "override" | "priv" | "pub" | "ref" | "return" | "static" | "struct" | "super" | "trait" | "true" | "type" | "typeof" | "unsafe" | "unsized" | "use" | "virtual" | "where" | "while" | "yield" | "try" | "async" | "await" | "dyn" => format!("r#{name}").into(), + "Self" | "self" => format!("{name}_").into(), + "_" => "unused".into(), + _ => reader::trim_tick(name).into(), + } +} + +fn mut_ptrs(pointers: usize) -> TokenStream { + "*mut ".repeat(pointers).into() +} + +fn const_ptrs(pointers: usize) -> TokenStream { + "*const ".repeat(pointers).into() +} diff --git a/crates/libs/metadata/src/writer/imp/blobs.rs b/crates/libs/metadata/src/writer/imp/blobs.rs deleted file mode 100644 index 08bad113d2..0000000000 --- a/crates/libs/metadata/src/writer/imp/blobs.rs +++ /dev/null @@ -1,60 +0,0 @@ -use super::*; - -#[derive(Default)] -pub struct Blobs { - // Blobs don't need to be sorted. A map is used to collapse duplicates. A `BTreeMap` in particular is used to help with reproducible builds. - map: BTreeMap, u32>, - stream: Vec, -} - -pub struct StagedBlobs(Blobs); - -impl Blobs { - pub fn insert(&mut self, value: Vec) { - if !value.is_empty() { - self.map.entry(value).or_default(); - } - } - - pub fn stage(mut self) -> StagedBlobs { - self.stream = vec![0]; - - for (value, index) in self.map.iter_mut() { - *index = self.stream.len() as _; - - match value.len() { - 0..=0x7F => self.stream.push(value.len() as _), - 0x80..=0x3FFF => { - self.stream.push((0x80 | value.len() >> 8) as _); - self.stream.push((0xFF & value.len()) as _); - } - _ => { - self.stream.push((0xC0 | value.len() >> 24) as _); - self.stream.push((0xFF & value.len() >> 16) as _); - self.stream.push((0xFF & value.len() >> 8) as _); - self.stream.push((0xFF & value.len()) as _); - } - } - - self.stream.extend_from_slice(value); - } - - self.stream.resize(round(self.stream.len(), 4), 0); - StagedBlobs(self) - } -} - -impl StagedBlobs { - pub fn stream(self) -> Vec { - self.0.stream - } - - #[track_caller] - pub fn index(&self, value: &[u8]) -> u32 { - if value.is_empty() { - 0 - } else { - self.0.map[value] - } - } -} diff --git a/crates/libs/metadata/src/writer/imp/definitions.rs b/crates/libs/metadata/src/writer/imp/definitions.rs deleted file mode 100644 index 476e3ed52d..0000000000 --- a/crates/libs/metadata/src/writer/imp/definitions.rs +++ /dev/null @@ -1,43 +0,0 @@ -use super::*; - -#[derive(Default)] -pub struct Definitions<'a> { - map: BTreeMap<(&'a str, &'a str), Definition<'a>>, -} - -pub struct Definition<'a> { - pub item: &'a Item, - pub index: u32, - pub value_type: bool, -} - -pub struct StagedDefinitions<'a>(Definitions<'a>); - -impl<'a> Definitions<'a> { - pub fn insert(&mut self, item: &'a Item) { - if self.map.insert(item_type_name(item), Definition { item, index: 0, value_type: item_value_type(item) }).is_some() { - panic!("Duplicate type found"); - } - } - - pub fn stage(mut self) -> StagedDefinitions<'a> { - for (index, value) in self.map.values_mut().enumerate() { - value.index = index as _; - } - StagedDefinitions(self) - } -} - -impl<'a> StagedDefinitions<'a> { - pub fn get(&self, namespace: &'a str, name: &'a str) -> Option<&'a Definition> { - self.0.map.get(&(namespace, name)) - } - - pub fn items(&self) -> impl Iterator { - self.0.map.values().map(|value| value.item) - } - - pub fn iter(&self) -> impl Iterator { - self.0.map.values().map(|value| (value.index, value.item)) - } -} diff --git a/crates/libs/metadata/src/writer/imp/mod.rs b/crates/libs/metadata/src/writer/imp/mod.rs deleted file mode 100644 index adecde371a..0000000000 --- a/crates/libs/metadata/src/writer/imp/mod.rs +++ /dev/null @@ -1,408 +0,0 @@ -mod blobs; -mod codes; -mod definitions; -mod file; -mod references; -mod strings; -mod tables; - -use super::*; -use blobs::*; -use codes::*; -use definitions::*; -use references::*; -use strings::*; -use tables::Tables; - -use std::collections::BTreeMap; - -pub fn round(size: usize, round: usize) -> usize { - let round = round - 1; - (size + round) & !round -} - -pub fn write(name: &str, winrt: bool, definitions: &[Item], assemblies: &[&str]) -> Vec { - // Index assemblies used to resolve references to existing winmd files. - let assemblies: Vec = assemblies.iter().map(|file| reader::File::new(file).expect("Assemblies could not be loaded")).collect(); - let assemblies = &reader::Reader::new(&assemblies); - - // Build sorted list of definitions. - let definitions = &{ - let mut index = Definitions::default(); - definitions.iter().for_each(|item| index.insert(item)); - index.stage() - }; - - // Build sorted list of references. - let references = &{ - let mut index = References::default(); - for item in definitions.items() { - match item { - Item::Struct(ty) => ty.fields.iter().for_each(|field| type_reference(&field.ty, definitions, assemblies, &mut index)), - Item::Interface(_ty) => {} - _ => {} - } - } - index.stage() - }; - - // Now that we have stable type indexes, build blobs and index strings. - let (blobs, strings) = { - let mut blobs = Blobs::default(); - let mut strings = Strings::default(); - strings.insert(name); - strings.insert(""); - strings.insert("mscorlib"); - strings.insert("System"); - strings.insert("ValueType"); - strings.insert("Enum"); - strings.insert("value__"); - - for item in definitions.items() { - match item { - Item::Struct(ty) => { - strings.insert(&ty.namespace); - strings.insert(&ty.name); - ty.fields.iter().for_each(|field| { - strings.insert(&field.name); - blobs.insert(field_blob(&field.ty, definitions, references)); - }); - } - Item::Enum(ty) => { - strings.insert(&ty.namespace); - strings.insert(&ty.name); - let enum_type = Type::Named((ty.namespace.clone(), ty.name.clone())); - blobs.insert(field_blob(&enum_type, definitions, references)); - blobs.insert(field_blob(&value_to_type(&ty.constants[0].value), definitions, references)); - ty.constants.iter().for_each(|constant| { - strings.insert(&constant.name); - blobs.insert(value_blob(&constant.value)); - }); - } - Item::Interface(ty) => { - strings.insert(&ty.namespace); - strings.insert(&ty.name); - ty.methods.iter().for_each(|method| { - strings.insert(&method.name); - blobs.insert(method_blob(method, definitions, references)); - method.params.iter().for_each(|param| { - strings.insert(¶m.name); - }); - }); - } - } - } - - (blobs.stage(), strings.stage()) - }; - - // Now that everything is indexed in various heaps, write out the table records. - let tables = { - let mut tables = Tables::default(); - tables.Module.push(tables::Module { Name: strings.index(name), Mvid: 1, ..Default::default() }); - tables.TypeDef.push(tables::TypeDef { TypeName: strings.index(""), ..Default::default() }); - let mscorlib = tables.AssemblyRef.push2(tables::AssemblyRef { MajorVersion: 4, Name: strings.index("mscorlib"), ..Default::default() }); - let value_type = tables.TypeRef.push2(tables::TypeRef { TypeName: strings.index("ValueType"), TypeNamespace: strings.index("System"), ResolutionScope: ResolutionScope::AssemblyRef(mscorlib).encode() }); - let enum_type = tables.TypeRef.push2(tables::TypeRef { TypeName: strings.index("Enum"), TypeNamespace: strings.index("System"), ResolutionScope: ResolutionScope::AssemblyRef(mscorlib).encode() }); - - for (_index, item) in definitions.iter() { - match item { - Item::Struct(ty) => { - let mut flags = TypeAttributes::PUBLIC | TypeAttributes::SEQUENTIAL_LAYOUT | TypeAttributes::SEALED; - if winrt { - flags |= TypeAttributes::WINRT; - } - tables.TypeDef.push(tables::TypeDef { - Flags: flags.0, - TypeName: strings.index(&ty.name), - TypeNamespace: strings.index(&ty.namespace), - Extends: TypeDefOrRef::TypeRef(value_type).encode(), - FieldList: tables.Field.len() as _, - MethodList: tables.MethodDef.len() as _, - }); - for field in &ty.fields { - let flags = FieldAttributes::PUBLIC; - tables.Field.push(tables::Field { Flags: flags.0, Name: strings.index(&field.name), Signature: blobs.index(&field_blob(&field.ty, definitions, references)) }); - } - } - Item::Enum(ty) => { - let mut flags = TypeAttributes::PUBLIC | TypeAttributes::SEALED; - if winrt { - flags |= TypeAttributes::WINRT; - } - tables.TypeDef.push(tables::TypeDef { - Flags: flags.0, - TypeName: strings.index(&ty.name), - TypeNamespace: strings.index(&ty.namespace), - Extends: TypeDefOrRef::TypeRef(enum_type).encode(), - FieldList: tables.Field.len() as _, - MethodList: tables.MethodDef.len() as _, - }); - let enum_type = Type::Named((ty.namespace.clone(), ty.name.clone())); - let flags = FieldAttributes::PRIVATE | FieldAttributes::SPECIAL | FieldAttributes::RUNTIME_SPECIAL; - tables.Field.push2(tables::Field { - Flags: flags.0, - Name: strings.index("value__"), - Signature: blobs.index(&field_blob(&value_to_type(&ty.constants[0].value), definitions, references)), - }); - for constant in &ty.constants { - let flags = FieldAttributes::PUBLIC | FieldAttributes::STATIC | FieldAttributes::LITERAL | FieldAttributes::HAS_DEFAULT; - let field = tables.Field.push2(tables::Field { Flags: flags.0, Name: strings.index(&constant.name), Signature: blobs.index(&field_blob(&enum_type, definitions, references)) }); - tables.Constant.push(tables::Constant { Type: value_type_code(&constant.value), Parent: HasConstant::Field(field).encode(), Value: blobs.index(&value_blob(&constant.value)) }); - } - } - Item::Interface(ty) => { - let mut flags = TypeAttributes::PUBLIC | TypeAttributes::INTERFACE | TypeAttributes::ABSTRACT; - if winrt { - flags |= TypeAttributes::WINRT; - } - tables.TypeDef.push(tables::TypeDef { - Flags: flags.0, - TypeName: strings.index(&ty.name), - TypeNamespace: strings.index(&ty.namespace), - Extends: 0, - FieldList: tables.Field.len() as _, - MethodList: tables.MethodDef.len() as _, - }); - for method in &ty.methods { - let flags = MethodAttributes::ABSTRACT | MethodAttributes::HIDE_BY_SIG | MethodAttributes::NEW_SLOT | MethodAttributes::PUBLIC | MethodAttributes::VIRTUAL; - tables.MethodDef.push(tables::MethodDef { - RVA: 0, - ImplFlags: 0, - Flags: flags.0, - Name: strings.index(&method.name), - Signature: blobs.index(&method_blob(method, definitions, references)), - ParamList: tables.Param.len() as _, - }); - for (sequence, param) in method.params.iter().enumerate() { - tables.Param.push(tables::Param { Flags: param_flags_to_attributes(param.flags).0, Sequence: (sequence + 1) as _, Name: strings.index(¶m.name) }); - } - } - } - } - } - - tables - }; - - // With all of the streams prepared, write out ECMA-335 file format. - file::write(tables, strings, blobs) -} - -fn type_reference<'a>(ty: &'a Type, definitions: &StagedDefinitions, assemblies: &reader::Reader, references: &mut References<'a>) { - // TODO: More matches to come... - #[allow(clippy::single_match)] - match ty { - Type::Named((namespace, name)) => { - if definitions.get(namespace, name).is_none() { - references.insert(namespace, name, assemblies); - } - } - _ => {} - } -} - -fn param_flags_to_attributes(flags: ParamFlags) -> ParamAttributes { - let mut attributes = ParamAttributes(0); - if flags.contains(ParamFlags::INPUT) { - attributes |= ParamAttributes::INPUT; - } - if flags.contains(ParamFlags::OUTPUT) { - attributes |= ParamAttributes::OUTPUT; - } - if flags.contains(ParamFlags::OPTIONAL) { - attributes |= ParamAttributes::OPTIONAL; - } - attributes -} - -fn item_type_name(item: &Item) -> (&str, &str) { - match item { - Item::Struct(ty) => (ty.namespace.as_str(), ty.name.as_str()), - Item::Enum(ty) => (ty.namespace.as_str(), ty.name.as_str()), - Item::Interface(ty) => (ty.namespace.as_str(), ty.name.as_str()), - } -} - -fn item_value_type(item: &Item) -> bool { - match item { - Item::Struct(_) | Item::Enum(_) => true, - Item::Interface(_) => false, - } -} - -fn method_blob(method: &Method, definitions: &StagedDefinitions, references: &StagedReferences) -> Vec { - let mut blob = vec![0x20]; // HASTHIS - u32_blob(method.params.len() as _, &mut blob); - for param in &method.params { - type_blob(¶m.ty, &mut blob, definitions, references); - } - type_blob(&method.return_type, &mut blob, definitions, references); - blob -} - -fn field_blob(ty: &Type, definitions: &StagedDefinitions, references: &StagedReferences) -> Vec { - let mut blob = vec![0x6]; - type_blob(ty, &mut blob, definitions, references); - blob -} - -fn value_blob(value: &Value) -> Vec { - match value { - Value::I8(value) => value.to_le_bytes().to_vec(), - Value::U8(value) => value.to_le_bytes().to_vec(), - Value::I16(value) => value.to_le_bytes().to_vec(), - Value::U16(value) => value.to_le_bytes().to_vec(), - Value::I32(value) => value.to_le_bytes().to_vec(), - Value::U32(value) => value.to_le_bytes().to_vec(), - Value::I64(value) => value.to_le_bytes().to_vec(), - Value::U64(value) => value.to_le_bytes().to_vec(), - _ => panic!("Unsupported value type"), - } -} - -fn value_to_type(value: &Value) -> Type { - match value { - Value::I8(_) => Type::I8, - Value::U8(_) => Type::U8, - Value::I16(_) => Type::I16, - Value::U16(_) => Type::U16, - Value::I32(_) => Type::I32, - Value::U32(_) => Type::U32, - Value::I64(_) => Type::I64, - Value::U64(_) => Type::U64, - _ => panic!("Unsupported value type"), - } -} - -fn value_type_code(value: &Value) -> u16 { - match value { - Value::I8(_) => 0x04, - Value::U8(_) => 0x05, - Value::I16(_) => 0x06, - Value::U16(_) => 0x07, - Value::I32(_) => 0x08, - Value::U32(_) => 0x09, - Value::I64(_) => 0x0a, - Value::U64(_) => 0x0b, - _ => panic!("Unsupported value type"), - } -} - -fn type_blob(ty: &Type, blob: &mut Vec, definitions: &StagedDefinitions, references: &StagedReferences) { - match ty { - Type::Void => blob.push(0x01), - Type::Bool => blob.push(0x02), - Type::Char => blob.push(0x03), - Type::I8 => blob.push(0x04), - Type::U8 => blob.push(0x05), - Type::I16 => blob.push(0x06), - Type::U16 => blob.push(0x07), - Type::I32 => blob.push(0x08), - Type::U32 => blob.push(0x09), - Type::I64 => blob.push(0x0a), - Type::U64 => blob.push(0x0b), - Type::F32 => blob.push(0x0c), - Type::F64 => blob.push(0x0d), - Type::ISize => blob.push(0x18), - Type::USize => blob.push(0x19), - Type::String => blob.push(0x0e), - //Type::IInspectable => blob.push(0x1c), - Type::Named((namespace, name)) => { - let (value_type, code) = type_name_encode(namespace, name, definitions, references); - value_type_blob(value_type, blob); - u32_blob(code, blob); - } - } -} - -fn value_type_blob(value_type: bool, blob: &mut Vec) { - if value_type { - blob.push(0x11); - } else { - blob.push(0x12); - } -} - -fn u32_blob(value: u32, blob: &mut Vec) { - if value < 0x80 { - blob.push(value as _); - } else if value < 0x4000 { - blob.push((0x40 | (value & 0xFF00)) as _); - blob.push((value | 0xFF) as _); - } else { - blob.push((0x60 | (value & 0xFF000000)) as _); - blob.push((value | 0xFF0000) as _); - blob.push((value | 0xFF00) as _); - blob.push((value | 0xFF) as _); - } -} - -/// Returns the TypeDefOrRef-encoded value for the type name as well as whether the type is a value type, needed -/// in some cases like when a TypeDefOrRef appears in a signature. -fn type_name_encode(namespace: &str, name: &str, definitions: &StagedDefinitions, references: &StagedReferences) -> (bool, u32) { - if let Some(definition) = definitions.get(namespace, name) { - return (definition.value_type, TypeDefOrRef::TypeDef(definition.index + 1).encode()); - } - let reference = references.get(namespace, name).expect("Type not found"); - (reference.value_type, TypeDefOrRef::TypeRef(reference.index + 1).encode()) -} - -pub trait Write { - unsafe fn write_header(&mut self, value: &T); - fn write_u8(&mut self, value: u8); - fn write_u16(&mut self, value: u16); - fn write_u32(&mut self, value: u32); - fn write_u64(&mut self, value: u64); - fn write_code(&mut self, value: u32, size: usize); - fn write_index(&mut self, index: u32, len: usize); -} - -impl Write for Vec { - unsafe fn write_header(&mut self, value: &T) { - self.extend_from_slice(std::slice::from_raw_parts(value as *const _ as _, std::mem::size_of::())); - } - - fn write_u8(&mut self, value: u8) { - self.extend_from_slice(&value.to_le_bytes()); - } - - fn write_u16(&mut self, value: u16) { - self.extend_from_slice(&value.to_le_bytes()); - } - - fn write_u32(&mut self, value: u32) { - self.extend_from_slice(&value.to_le_bytes()); - } - - fn write_u64(&mut self, value: u64) { - self.extend_from_slice(&value.to_le_bytes()); - } - - fn write_code(&mut self, value: u32, size: usize) { - if size == 2 { - self.write_u16(value as _); - } else { - self.write_u32(value); - } - } - - fn write_index(&mut self, index: u32, len: usize) { - if len < (1 << 16) { - self.write_u16(index as u16 + 1); - } else { - self.write_u32(index + 1); - } - } -} - -trait Push2 { - fn push2(&mut self, value: T) -> u32; -} - -impl Push2 for Vec { - fn push2(&mut self, value: T) -> u32 { - self.push(value); - (self.len() - 1) as _ - } -} diff --git a/crates/libs/metadata/src/writer/imp/references.rs b/crates/libs/metadata/src/writer/imp/references.rs deleted file mode 100644 index b35a8a2754..0000000000 --- a/crates/libs/metadata/src/writer/imp/references.rs +++ /dev/null @@ -1,36 +0,0 @@ -use super::*; - -#[derive(Default)] -pub struct References<'a> { - map: BTreeMap<(&'a str, &'a str), Reference>, -} - -pub struct Reference { - pub index: u32, - pub value_type: bool, -} - -pub struct StagedReferences<'a>(References<'a>); - -impl<'a> References<'a> { - pub fn insert(&mut self, namespace: &'a str, name: &'a str, assemblies: &reader::Reader) { - self.map.entry((namespace, name)).or_insert_with(|| { - let type_def = assemblies.get(reader::TypeName::new(namespace, name)).next().expect("Type not found"); - let value_type = matches!(assemblies.type_def_kind(type_def), reader::TypeKind::Struct | reader::TypeKind::Enum); - Reference { value_type, index: 0 } - }); - } - - pub fn stage(mut self) -> StagedReferences<'a> { - for (index, value) in self.map.values_mut().enumerate() { - value.index = index as _; - } - StagedReferences(self) - } -} - -impl<'a> StagedReferences<'a> { - pub fn get(&'a self, namespace: &'a str, name: &'a str) -> Option<&'a Reference> { - self.0.map.get(&(namespace, name)) - } -} diff --git a/crates/libs/metadata/src/writer/imp/strings.rs b/crates/libs/metadata/src/writer/imp/strings.rs deleted file mode 100644 index da20e8cde8..0000000000 --- a/crates/libs/metadata/src/writer/imp/strings.rs +++ /dev/null @@ -1,46 +0,0 @@ -use super::*; - -#[derive(Default)] -pub struct Strings<'a> { - // Strings don't need to be sorted. A map is used to collapse duplicates. A `BTreeMap` in particular is used to help with reproducible builds. - map: BTreeMap<&'a str, u32>, - stream: Vec, -} - -pub struct StagedStrings<'a>(Strings<'a>); - -impl<'a> Strings<'a> { - pub fn insert(&mut self, value: &'a str) { - if !value.is_empty() { - self.map.entry(value).or_default(); - } - } - - pub fn stage(mut self) -> StagedStrings<'a> { - self.stream = vec![0]; - - for (value, index) in self.map.iter_mut() { - *index = self.stream.len() as _; - - self.stream.extend_from_slice(value.as_bytes()); - self.stream.push(0); // terminator - } - - self.stream.resize(round(self.stream.len(), 4), 0); - StagedStrings(self) - } -} - -impl<'a> StagedStrings<'a> { - pub fn stream(self) -> Vec { - self.0.stream - } - - pub fn index(&self, value: &str) -> u32 { - if value.is_empty() { - 0 - } else { - self.0.map[value] - } - } -} diff --git a/crates/libs/metadata/src/writer/mod.rs b/crates/libs/metadata/src/writer/mod.rs index 8dcf332b8d..46bbdb946b 100644 --- a/crates/libs/metadata/src/writer/mod.rs +++ b/crates/libs/metadata/src/writer/mod.rs @@ -1,64 +1,112 @@ -mod imp; +mod extend; +mod idl; +mod validate; +mod winmd; + +// TODO: this "writer" is really both a reader and a writer that is more generalized than "reader". The "reader" should be the raw or low-level reader +// that is secondary while this should be the main metadata API. + use super::*; +pub use idl::format_idl; -// Generates an in-memory .winmd file. -pub fn write(name: &str, winrt: bool, items: &[Item], assemblies: &[&str]) -> Vec { - imp::write(name, winrt, items, assemblies) -} +impl Module { + pub(crate) fn new(namespace: &str) -> Self { + Self { namespace: namespace.to_string(), ..Default::default() } + } -pub enum Item { - Struct(Struct), - Enum(Enum), - Interface(Interface), -} + pub(crate) fn insert(&mut self, namespace: &str, pos: usize) -> &mut Self { + if let Some(next) = namespace[pos..].find('.') { + let next = pos + next; + self.modules.entry(namespace[pos..next].to_string()).or_insert_with(|| Self::new(&namespace[..next])).insert(namespace, next + 1) + } else { + self.modules.entry(namespace[pos..].to_string()).or_insert_with(|| Self::new(namespace)) + } + } -pub struct Struct { - pub namespace: String, - pub name: String, - pub fields: Vec, -} + pub fn read(input: &[String], filter: &Filter) -> Result { + let mut module = Module::default(); + winmd::read_winmd(&mut module, input, filter)?; + idl::read_idl(&mut module, input, filter)?; + Ok(module) + } -pub struct Enum { - pub namespace: String, - pub name: String, - pub constants: Vec, -} + pub fn extend(&mut self, other: Module) { + extend::extend(self, other) + } -pub struct Interface { - pub namespace: String, - pub name: String, - pub methods: Vec, + pub fn validate(&self) -> Result<()> { + validate::validate(self) + } + + pub fn write(&self, path: &str) -> Result<()> { + match extension(path) { + (_, "idl") => idl::write_idl(self, path), + (_, "winmd") => winmd::write_winmd(self, path), + _ => Err(Error::new("output extension must be either .winmd or .idl")), + } + } + + pub fn contains_type(&self, namespace: &str, name: &str) -> bool { + if let Some(next) = namespace.find('.') { + if let Some(module) = self.modules.get(&namespace[..next]) { + module.contains_type(&namespace[next + 1..], name) + } else { + false + } + } else if let Some(module) = self.modules.get(namespace) { + module.types.contains_key(name) + } else { + false + } + } + + // TODO: add a `write_rust` method and get rid of the `bindgen` crate? } -pub struct Field { - pub name: String, - pub ty: Type, +#[derive(Default, Debug)] +pub struct Module { + pub namespace: String, // TODO: call this name for clarity + pub modules: BTreeMap, + + // Note that a `Vec` is used since Win32 structs may have per-architecture definitions + pub types: BTreeMap>, } -pub struct Constant { - pub name: String, - pub value: Value, +#[derive(Default, Debug)] +pub struct TypeDef { + pub flags: TypeAttributes, + pub attributes: Vec, + pub generics: Vec, + pub extends: Option, + pub fields: Vec, + pub methods: Vec, + pub interfaces: Vec, } -pub struct Method { +#[derive(Debug, Clone, Default, PartialEq)] +pub struct TypeRef { + pub namespace: String, pub name: String, - pub return_type: Type, - pub params: Vec, + pub generics: Vec, + // store an optional `assembly` for the name of the winmd/idl file where the type originates } -pub struct Param { - pub name: String, - pub ty: Type, - pub flags: ParamFlags, +#[derive(Debug, Clone)] +pub(crate) enum TypeRefIndex { + None, + TypeDef(usize), + TypeRef(usize), } -flags!(ParamFlags, u32); -impl ParamFlags { - pub const INPUT: Self = Self(0x1); - pub const OUTPUT: Self = Self(0x2); - pub const OPTIONAL: Self = Self(0x10); +impl Default for TypeRefIndex { + fn default() -> Self { + Self::None + } } +// TODO: why not use 'syn' types directly? + +#[derive(Debug, Clone, PartialEq)] pub enum Type { Void, Bool, @@ -76,9 +124,84 @@ pub enum Type { ISize, USize, String, - Named((String, String)), + GUID, + IUnknown, + IInspectable, + HRESULT, + PSTR, + PWSTR, + PCSTR, + PCWSTR, + BSTR, + TypeName, + GenericParam(String), // TODO: need this in the writer? + TypeRef(TypeRef), + MutPtr((Box, usize)), + ConstPtr((Box, usize)), + Win32Array((Box, usize)), + WinrtArray(Box), + WinrtArrayRef(Box), + ConstRef(Box), +} + +impl Default for Type { + fn default() -> Self { + Self::Void + } +} + +impl Type { + fn into_mut_ptr(self) -> Self { + match self { + Self::MutPtr((ty, count)) => Self::MutPtr((ty, count + 1)), + Self::ConstPtr((ty, count)) => Self::MutPtr((ty, count + 1)), + _ => Self::MutPtr((Box::new(self), 1)), + } + } + + fn into_const_ptr(self) -> Self { + match self { + Self::MutPtr((ty, count)) => Self::ConstPtr((ty, count + 1)), + Self::ConstPtr((ty, count)) => Self::ConstPtr((ty, count + 1)), + _ => Self::ConstPtr((Box::new(self), 1)), + } + } + + fn into_array(self, len: usize) -> Self { + Self::Win32Array((Box::new(self), len)) + } } +#[derive(Debug)] +pub struct Attribute {} + +#[derive(Default, Debug)] +pub struct Field { + flags: FieldAttributes, + name: String, + ty: Type, + value: Option, +} + +#[derive(Default, Debug)] +pub struct Param { + flags: ParamAttributes, + name: String, + ty: Type, +} + +#[derive(Default, Debug)] +pub struct Method { + flags: MethodAttributes, + name: String, + params: Vec, + return_type: Param, + //attributes: Vec, + //impl_flags: MethodImplAttributes, + vararg: bool, +} + +#[derive(Debug)] pub enum Value { Bool(bool), U8(u8), @@ -93,3 +216,56 @@ pub enum Value { F64(f64), String(String), } + +impl Value { + // TODO: should return u8 + fn to_code(&self) -> u16 { + match self { + Self::Bool(_) => ELEMENT_TYPE_BOOLEAN as _, + Self::I8(_) => ELEMENT_TYPE_I1 as _, + Self::U8(_) => ELEMENT_TYPE_U1 as _, + Self::I16(_) => ELEMENT_TYPE_I2 as _, + Self::U16(_) => ELEMENT_TYPE_U2 as _, + Self::I32(_) => ELEMENT_TYPE_I4 as _, + Self::U32(_) => ELEMENT_TYPE_U4 as _, + Self::I64(_) => ELEMENT_TYPE_I8 as _, + Self::U64(_) => ELEMENT_TYPE_U8 as _, + Self::F32(_) => ELEMENT_TYPE_R4 as _, + Self::F64(_) => ELEMENT_TYPE_R8 as _, + Self::String(_) => ELEMENT_TYPE_STRING as _, + } + } + fn to_expr(&self) -> String { + match self { + Self::Bool(value) => value.to_string(), + Self::U8(value) => format!("{value}u8"), + Self::I8(value) => format!("{value}i8"), + Self::U16(value) => format!("{value}u16"), + Self::I16(value) => format!("{value}i16"), + Self::U32(value) => format!("{value}u32"), + Self::I32(value) => format!("{value}i32"), + Self::U64(value) => format!("{value}u64"), + Self::I64(value) => format!("{value}i64"), + Self::F32(value) => format!("{value}f32"), + Self::F64(value) => format!("{value}f64"), + Self::String(value) => value.clone(), + } + } + fn neg(&self) -> Self { + use std::ops::Neg; + match self { + Self::Bool(value) => Self::Bool(!value), + Self::U8(value) => Self::U8(*value), + Self::I8(value) => Self::I8(value.neg()), + Self::U16(value) => Self::U16(*value), + Self::I16(value) => Self::I16(value.neg()), + Self::U32(value) => Self::U32(*value), + Self::I32(value) => Self::I32(value.neg()), + Self::U64(value) => Self::U64(*value), + Self::I64(value) => Self::I64(value.neg()), + Self::F32(value) => Self::F32(value.neg()), + Self::F64(value) => Self::F64(value.neg()), + Self::String(value) => Self::String(value.clone()), + } + } +} diff --git a/crates/libs/metadata/src/writer/validate.rs b/crates/libs/metadata/src/writer/validate.rs new file mode 100644 index 0000000000..0381e1ba2f --- /dev/null +++ b/crates/libs/metadata/src/writer/validate.rs @@ -0,0 +1,9 @@ +use super::*; + +pub fn validate(_module: &Module) -> Result<()> { + // TODO: + // *. if a TypeDef is WinRT then there shall only be one for a given name - MIDLRT may be produce more but that should be removed before `validate` is run. + // *. if a TypeDef is not WinRT then there can be more - check that they have non-overlapping supported architectures. + // *. + Ok(()) +} diff --git a/crates/libs/metadata/src/writer/winmd/mod.rs b/crates/libs/metadata/src/writer/winmd/mod.rs new file mode 100644 index 0000000000..7214a3b4dc --- /dev/null +++ b/crates/libs/metadata/src/writer/winmd/mod.rs @@ -0,0 +1,6 @@ +mod read; +mod write; + +use super::*; +pub use read::*; +pub use write::*; diff --git a/crates/libs/metadata/src/writer/winmd/read.rs b/crates/libs/metadata/src/writer/winmd/read.rs new file mode 100644 index 0000000000..d33084c6d2 --- /dev/null +++ b/crates/libs/metadata/src/writer/winmd/read.rs @@ -0,0 +1,128 @@ +use super::*; + +pub fn read_winmd(module: &mut Module, paths: &[String], filter: &Filter) -> Result<()> { + let mut files = vec![]; + + for path in paths { + if extension(path).1 == "winmd" { + files.push(reader::File::new(path)?); + } + } + + let reader = reader::Reader::new(&files); + + for ns in reader.namespaces() { + if filter.includes_namespace(ns) { + for ty in reader.namespace_types(ns, filter) { + module.insert(reader.type_def_namespace(ty), 0).types.entry(crate::reader::trim_tick(reader.type_def_name(ty)).to_string()).or_default().push(read_type_def(&reader, ty)?); + } + } + } + + Ok(()) +} + +fn read_type_def(reader: &reader::Reader, ty: reader::TypeDef) -> Result { + let mut result = TypeDef { flags: reader.type_def_flags(ty), ..Default::default() }; + + result.extends = reader.type_def_extends(ty).map(|extends| TypeRef { namespace: extends.namespace.to_string(), name: extends.name.to_string(), ..Default::default() }); + + for method in reader.type_def_methods(ty) { + let flags = reader.method_def_flags(method); + let sig = reader.method_def_signature(method, &[]); + let name = reader.method_def_name(method).to_string(); + let mut params = vec![]; + + for param in sig.params { + let flags = reader.param_flags(param.def); + let name = reader.param_name(param.def).to_string(); + let ty = read_type(reader, ¶m.ty)?; + params.push(Param { flags, name, ty }); + } + + let return_type = Param { ty: read_type(reader, &sig.return_type)?, ..Default::default() }; + result.methods.push(Method { flags, name, params, return_type, ..Default::default() }); + } + + for field in reader.type_def_fields(ty) { + let flags = reader.field_flags(field); + let name = reader.field_name(field).to_string(); + let ty = read_type(reader, &reader.field_type(field, Some(ty)))?; + + let value = if flags.contains(FieldAttributes::LITERAL) { + let constant = reader.field_constant(field).unwrap(); + read_value(&reader.constant_value(constant)).ok() + } else { + None + }; + + result.fields.push(Field { flags, name, ty, value }); + } + + Ok(result) +} + +fn read_value(value: &reader::Value) -> Result { + match value { + reader::Value::Bool(value) => Ok(Value::Bool(*value)), + reader::Value::U8(value) => Ok(Value::U8(*value)), + reader::Value::I8(value) => Ok(Value::I8(*value)), + reader::Value::U16(value) => Ok(Value::U16(*value)), + reader::Value::I16(value) => Ok(Value::I16(*value)), + reader::Value::U32(value) => Ok(Value::U32(*value)), + reader::Value::I32(value) => Ok(Value::I32(*value)), + reader::Value::U64(value) => Ok(Value::U64(*value)), + reader::Value::I64(value) => Ok(Value::I64(*value)), + reader::Value::F32(value) => Ok(Value::F32(*value)), + reader::Value::F64(value) => Ok(Value::F64(*value)), + reader::Value::String(value) => Ok(Value::String(value.clone())), + _ => todo!(), + } +} + +fn read_type(reader: &reader::Reader, ty: &reader::Type) -> Result { + Ok(match ty { + reader::Type::Void => Type::Void, + reader::Type::Bool => Type::Bool, + reader::Type::Char => Type::Char, + reader::Type::I8 => Type::I8, + reader::Type::U8 => Type::U8, + reader::Type::I16 => Type::I16, + reader::Type::U16 => Type::U16, + reader::Type::I32 => Type::I32, + reader::Type::U32 => Type::U32, + reader::Type::I64 => Type::I64, + reader::Type::U64 => Type::U64, + reader::Type::F32 => Type::F32, + reader::Type::F64 => Type::F64, + reader::Type::ISize => Type::ISize, + reader::Type::USize => Type::USize, + reader::Type::String => Type::String, + reader::Type::GUID => Type::GUID, + reader::Type::IUnknown => Type::IUnknown, + reader::Type::IInspectable => Type::IInspectable, + reader::Type::HRESULT => Type::HRESULT, + reader::Type::PSTR => Type::PSTR, + reader::Type::PWSTR => Type::PWSTR, + reader::Type::PCSTR => Type::PCSTR, + reader::Type::PCWSTR => Type::PCWSTR, + reader::Type::BSTR => Type::BSTR, + reader::Type::TypeName => Type::TypeName, + reader::Type::GenericParam(param) => Type::GenericParam(reader.generic_param_name(*param).to_string()), + reader::Type::TypeDef((ty, reader_generics)) => { + let mut generics = vec![]; + + for ty in reader_generics { + generics.push(read_type(reader, ty)?); + } + + Type::TypeRef(TypeRef { namespace: reader.type_def_namespace(*ty).to_string(), name: reader.type_def_name(*ty).to_string(), generics }) + } + reader::Type::MutPtr((ty, pointers)) => Type::MutPtr((Box::new(read_type(reader, ty)?), *pointers)), + reader::Type::ConstPtr((ty, pointers)) => Type::ConstPtr((Box::new(read_type(reader, ty)?), *pointers)), + reader::Type::Win32Array((ty, pointers)) => Type::Win32Array((Box::new(read_type(reader, ty)?), *pointers)), + reader::Type::WinrtArray(ty) => Type::WinrtArray(Box::new(read_type(reader, ty)?)), + reader::Type::WinrtArrayRef(ty) => Type::WinrtArrayRef(Box::new(read_type(reader, ty)?)), + reader::Type::ConstRef(ty) => Type::ConstRef(Box::new(read_type(reader, ty)?)), + }) +} diff --git a/crates/libs/metadata/src/writer/winmd/write/blobs.rs b/crates/libs/metadata/src/writer/winmd/write/blobs.rs new file mode 100644 index 0000000000..9b817836af --- /dev/null +++ b/crates/libs/metadata/src/writer/winmd/write/blobs.rs @@ -0,0 +1,48 @@ +use super::Write; +use std::collections::hash_map::*; + +pub struct Blobs { + map: HashMap, u32>, + stream: Vec, +} + +impl Default for Blobs { + fn default() -> Self { + Self { map: Default::default(), stream: vec![0] } + } +} + +impl Blobs { + pub fn insert(&mut self, value: &[u8]) -> u32 { + if value.is_empty() { + return 0; + } + + match self.map.entry(value.to_vec()) { + Entry::Vacant(entry) => { + let offset = *entry.insert(self.stream.len() as _); + let len = value.len(); + match len { + 0..=0x7F => self.stream.push(len as _), + 0x80..=0x3FFF => { + self.stream.push((0x80 | len >> 8) as _); + self.stream.push((0xFF & len) as _); + } + _ => { + self.stream.push((0xC0 | len >> 24) as _); + self.stream.push((0xFF & len >> 16) as _); + self.stream.push((0xFF & len >> 8) as _); + self.stream.push((0xFF & len) as _); + } + } + self.stream.extend_from_slice(value); + offset + } + Entry::Occupied(entry) => *entry.get(), + } + } + + pub fn into_stream(self) -> Vec { + self.stream.into_stream() + } +} diff --git a/crates/libs/metadata/src/writer/imp/codes.rs b/crates/libs/metadata/src/writer/winmd/write/codes.rs similarity index 100% rename from crates/libs/metadata/src/writer/imp/codes.rs rename to crates/libs/metadata/src/writer/winmd/write/codes.rs diff --git a/crates/libs/metadata/src/writer/imp/file.rs b/crates/libs/metadata/src/writer/winmd/write/file.rs similarity index 96% rename from crates/libs/metadata/src/writer/imp/file.rs rename to crates/libs/metadata/src/writer/winmd/write/file.rs index 2f25f942b3..920089dee1 100644 --- a/crates/libs/metadata/src/writer/imp/file.rs +++ b/crates/libs/metadata/src/writer/winmd/write/file.rs @@ -1,11 +1,8 @@ use super::*; use std::mem::*; -pub fn write(tables: Tables, strings: StagedStrings, blobs: StagedBlobs) -> Vec { +pub fn write(mut tables: Vec, mut strings: Vec, mut blobs: Vec) -> Vec { unsafe { - let mut tables = tables.stream(); - let mut strings = strings.stream(); - let mut blobs = blobs.stream(); let mut guids = vec![0; 16]; // zero guid let size_of_streams = tables.len() + guids.len() + strings.len() + blobs.len(); diff --git a/crates/libs/metadata/src/writer/winmd/write/mod.rs b/crates/libs/metadata/src/writer/winmd/write/mod.rs new file mode 100644 index 0000000000..54f786d804 --- /dev/null +++ b/crates/libs/metadata/src/writer/winmd/write/mod.rs @@ -0,0 +1,272 @@ +mod blobs; +mod codes; +mod file; +mod strings; +mod tables; +mod traits; + +use super::*; +use blobs::Blobs; +use codes::*; +use strings::Strings; +use traits::*; + +struct Gen<'a> { + blobs: Blobs, + strings: Strings<'a>, + tables: tables::Tables, + module: &'a Module, + module_scope: u32, + scopes: HashMap<&'a str, u32>, + references: HashMap<(&'a str, &'a str), u32>, +} + +pub fn write_winmd(module: &Module, path: &str) -> Result<()> { + let mut gen = Gen::new(module); + + gen.tables.TypeDef.push(tables::TypeDef { TypeName: gen.strings.insert(""), ..Default::default() }); + gen.module_scope = ResolutionScope::Module(gen.tables.Module.push2(tables::Module { Mvid: 1, ..Default::default() })).encode(); + + // Some winmd parsers will fail to read without an `mscorlib` reference. The `insert_module_types` funciton will typically include it + // automatically but a minimal `Module` tree may not add this dependency. + gen.insert_scope("System"); + + gen.insert_module_types(module); + + let file = file::write(gen.tables.into_stream(), gen.strings.into_stream(), gen.blobs.into_stream()); + write_to_file(path, file) +} + +impl<'a> Gen<'a> { + fn new(module: &'a Module) -> Self { + Self { + blobs: Default::default(), + strings: Default::default(), + tables: Default::default(), + module, + module_scope: 0, + scopes: Default::default(), + references: Default::default(), + } + } + + fn insert_module_types(&mut self, module: &'a Module) { + for (name, def) in &module.types { + self.insert_type_def(&module.namespace, name, def); + } + module.modules.values().for_each(|module| self.insert_module_types(module)); + } + + fn insert_type_def(&mut self, namespace: &'a str, name: &'a str, def: &'a [TypeDef]) { + for def in def { + let extends = if let Some(extends) = &def.extends { self.insert_type_ref(&extends.namespace, &extends.name) } else { 0 }; + self.tables.TypeDef.push(tables::TypeDef { + Flags: def.flags.0, + TypeName: self.strings.insert(name), + TypeNamespace: self.strings.insert(namespace), + Extends: extends, + FieldList: self.tables.Field.len() as _, + MethodList: self.tables.MethodDef.len() as _, + }); + for field in &def.fields { + let blob = self.insert_field_sig(&field.ty); + let parent = self.tables.Field.push2(tables::Field { Flags: field.flags.0, Name: self.strings.insert(&field.name), Signature: blob }); + if let Some(value) = &field.value { + let blob = self.insert_value_blob(value); + self.tables.Constant.push(tables::Constant { Type: value.to_code(), Parent: HasConstant::Field(parent).encode(), Value: blob }); + } + } + for method in &def.methods { + let blob = self.insert_method_sig(method); + self.tables.MethodDef.push(tables::MethodDef { RVA: 0, ImplFlags: 0, Flags: method.flags.0, Name: self.strings.insert(&method.name), Signature: blob, ParamList: self.tables.Param.len() as _ }); + for (sequence, param) in method.params.iter().enumerate() { + self.tables.Param.push(tables::Param { Flags: param.flags.0, Sequence: (sequence + 1) as _, Name: self.strings.insert(¶m.name) }); + } + } + } + } + + fn insert_value_blob(&mut self, value: &Value) -> u32 { + // TODO: can either cache in Gen, like we do for scopes and references, or regenerate each time. + // Profile once we can stress test this with field/method signatures. + + let blob = match value { + Value::I8(value) => value.to_le_bytes().to_vec(), + Value::U8(value) => value.to_le_bytes().to_vec(), + Value::I16(value) => value.to_le_bytes().to_vec(), + Value::U16(value) => value.to_le_bytes().to_vec(), + Value::I32(value) => value.to_le_bytes().to_vec(), + Value::U32(value) => value.to_le_bytes().to_vec(), + Value::I64(value) => value.to_le_bytes().to_vec(), + Value::U64(value) => value.to_le_bytes().to_vec(), + Value::F32(value) => value.to_le_bytes().to_vec(), + Value::F64(value) => value.to_le_bytes().to_vec(), + Value::String(value) => { + let mut blob = vec![]; + u32_blob(value.len() as _, &mut blob); + blob.extend_from_slice(value.as_bytes()); + blob + } + _ => todo!("{:?}", value), + }; + + self.blobs.insert(&blob) + } + + fn insert_method_sig(&mut self, method: &'a Method) -> u32 { + // TODO: can either cache in Gen, like we do for scopes and references, or regenerate each time. + // Profile once we can stress test this with field/method signatures. + + let mut blob = vec![0x20]; // HASTHIS + u32_blob(method.params.len() as _, &mut blob); + self.type_blob(&method.return_type.ty, &mut blob); + for param in &method.params { + self.type_blob(¶m.ty, &mut blob); + } + + self.blobs.insert(&blob) + } + + fn insert_field_sig(&mut self, ty: &'a Type) -> u32 { + // TODO: can either cache in Gen, like we do for scopes and references, or regenerate each time. + // Profile once we can stress test this with field/method signatures. + + let mut blob = vec![0x6]; // FIELD + self.type_blob(ty, &mut blob); + + self.blobs.insert(&blob) + } + + fn insert_scope(&mut self, namespace: &'a str) -> u32 { + if let Some(scope) = self.scopes.get(namespace) { + *scope + } else { + let name = if namespace == "System" { "mscorlib" } else { namespace }; + let scope = ResolutionScope::AssemblyRef(self.tables.AssemblyRef.push2(tables::AssemblyRef { Name: self.strings.insert(name), ..Default::default() })).encode(); + self.scopes.insert(namespace, scope); + scope + } + } + + fn insert_type_ref(&mut self, namespace: &'a str, name: &'a str) -> u32 { + if let Some(reference) = self.references.get(&(namespace, name)) { + *reference + } else { + let scope = if self.module.contains_type(namespace, name) { self.module_scope } else { self.insert_scope(namespace) }; + + let reference = TypeDefOrRef::TypeRef(self.tables.TypeRef.push2(tables::TypeRef { TypeName: self.strings.insert(name), TypeNamespace: self.strings.insert(namespace), ResolutionScope: scope })).encode(); + self.references.insert((namespace, name), reference); + reference + } + } + + fn type_blob(&mut self, ty: &'a Type, blob: &mut Vec) { + match ty { + Type::Void => blob.push(ELEMENT_TYPE_VOID as _), + Type::Bool => blob.push(ELEMENT_TYPE_BOOLEAN as _), + Type::Char => blob.push(ELEMENT_TYPE_CHAR as _), + Type::I8 => blob.push(ELEMENT_TYPE_I1 as _), + Type::U8 => blob.push(ELEMENT_TYPE_U1 as _), + Type::I16 => blob.push(ELEMENT_TYPE_I2 as _), + Type::U16 => blob.push(ELEMENT_TYPE_U2 as _), + Type::I32 => blob.push(ELEMENT_TYPE_I4 as _), + Type::U32 => blob.push(ELEMENT_TYPE_U4 as _), + Type::I64 => blob.push(ELEMENT_TYPE_I8 as _), + Type::U64 => blob.push(ELEMENT_TYPE_U8 as _), + Type::F32 => blob.push(ELEMENT_TYPE_R4 as _), + Type::F64 => blob.push(ELEMENT_TYPE_R8 as _), + Type::ISize => blob.push(ELEMENT_TYPE_I as _), + Type::USize => blob.push(ELEMENT_TYPE_U as _), + Type::String => blob.push(ELEMENT_TYPE_STRING as _), + Type::IInspectable => blob.push(ELEMENT_TYPE_OBJECT as _), + Type::GUID => { + let code = self.insert_type_ref("System", "Guid"); + blob.push(ELEMENT_TYPE_VALUETYPE as _); + u32_blob(code, blob); + } + Type::HRESULT => { + let code = self.insert_type_ref("Windows.Foundation", "HResult"); + blob.push(ELEMENT_TYPE_VALUETYPE as _); + u32_blob(code, blob); + } + Type::TypeRef(ty) => { + let code = self.insert_type_ref(&ty.namespace, &ty.name); + blob.push(ELEMENT_TYPE_VALUETYPE as _); + u32_blob(code, blob); + } + Type::BSTR => { + let code = self.insert_type_ref("Windows.Win32.Foundation", "BSTR"); + blob.push(ELEMENT_TYPE_VALUETYPE as _); + u32_blob(code, blob); + } + Type::IUnknown => { + let code = self.insert_type_ref("Windows.Win32.Foundation", "IUnknown"); + blob.push(ELEMENT_TYPE_VALUETYPE as _); + u32_blob(code, blob); + } + Type::PCWSTR | Type::PWSTR => { + let code = self.insert_type_ref("Windows.Win32.Foundation", "PWSTR"); + blob.push(ELEMENT_TYPE_VALUETYPE as _); + u32_blob(code, blob); + } + Type::PCSTR | Type::PSTR => { + let code = self.insert_type_ref("Windows.Win32.Foundation", "PSTR"); + blob.push(ELEMENT_TYPE_VALUETYPE as _); + u32_blob(code, blob); + } + Type::ConstRef(ty) => { + u32_blob(ELEMENT_TYPE_CMOD_OPT as _, blob); + u32_blob(self.insert_type_ref("System.Runtime.CompilerServices", "IsConst"), blob); + u32_blob(ELEMENT_TYPE_BYREF as _, blob); + self.type_blob(ty, blob); + } + Type::WinrtArrayRef(ty) => { + u32_blob(ELEMENT_TYPE_BYREF as _, blob); + u32_blob(ELEMENT_TYPE_SZARRAY as _, blob); + self.type_blob(ty, blob); + } + Type::WinrtArray(ty) => { + u32_blob(ELEMENT_TYPE_SZARRAY as _, blob); + self.type_blob(ty, blob); + } + Type::Win32Array((ty, bounds)) => { + u32_blob(ELEMENT_TYPE_ARRAY as _, blob); + self.type_blob(ty, blob); + u32_blob(1, blob); // rank + u32_blob(1, blob); // count + u32_blob(*bounds as _, blob); + } + Type::TypeName => { + let code = self.insert_type_ref("System", "Type"); + blob.push(ELEMENT_TYPE_CLASS as _); + u32_blob(code, blob); + } + Type::MutPtr((ty, pointers)) | Type::ConstPtr((ty, pointers)) => { + for _ in 0..*pointers { + u32_blob(ELEMENT_TYPE_PTR as _, blob); + } + self.type_blob(ty, blob); + } + _ => todo!("{:?}", ty), + } + } +} + +fn round(size: usize, round: usize) -> usize { + let round = round - 1; + (size + round) & !round +} + +fn u32_blob(value: u32, blob: &mut Vec) { + if value < 0x80 { + blob.push(value as _); + } else if value < 0x4000 { + blob.push((0x40 | (value & 0xFF00)) as _); + blob.push((value | 0xFF) as _); + } else { + blob.push((0x60 | (value & 0xFF000000)) as _); + blob.push((value | 0xFF0000) as _); + blob.push((value | 0xFF00) as _); + blob.push((value | 0xFF) as _); + } +} diff --git a/crates/libs/metadata/src/writer/winmd/write/strings.rs b/crates/libs/metadata/src/writer/winmd/write/strings.rs new file mode 100644 index 0000000000..f473e8e762 --- /dev/null +++ b/crates/libs/metadata/src/writer/winmd/write/strings.rs @@ -0,0 +1,35 @@ +use super::Write; +use std::collections::hash_map::*; + +pub struct Strings<'a> { + map: HashMap<&'a str, u32>, + stream: Vec, +} + +impl<'a> Default for Strings<'a> { + fn default() -> Self { + Self { map: Default::default(), stream: vec![0] } + } +} + +impl<'a> Strings<'a> { + pub fn insert(&mut self, value: &'a str) -> u32 { + if value.is_empty() { + return 0; + } + + match self.map.entry(value) { + Entry::Vacant(entry) => { + let offset = *entry.insert(self.stream.len() as _); + self.stream.extend_from_slice(value.as_bytes()); + self.stream.push(0); + offset + } + Entry::Occupied(entry) => *entry.get(), + } + } + + pub fn into_stream(self) -> Vec { + self.stream.into_stream() + } +} diff --git a/crates/libs/metadata/src/writer/imp/tables.rs b/crates/libs/metadata/src/writer/winmd/write/tables.rs similarity index 98% rename from crates/libs/metadata/src/writer/imp/tables.rs rename to crates/libs/metadata/src/writer/winmd/write/tables.rs index 7b34507389..d87a2f4f1d 100644 --- a/crates/libs/metadata/src/writer/imp/tables.rs +++ b/crates/libs/metadata/src/writer/winmd/write/tables.rs @@ -1,6 +1,6 @@ #![allow(non_snake_case)] -use super::*; +use super::{coded_index_size, Write}; #[derive(Default)] pub struct Tables { @@ -161,7 +161,7 @@ pub struct TypeSpec { } impl Tables { - pub fn stream(self) -> Vec { + pub fn into_stream(self) -> Vec { let resolution_scope = coded_index_size(&[self.Module.len(), self.ModuleRef.len(), self.AssemblyRef.len(), self.TypeRef.len()]); let type_def_or_ref = coded_index_size(&[self.TypeDef.len(), self.TypeRef.len(), self.TypeSpec.len()]); let has_constant = coded_index_size(&[self.Field.len(), self.Param.len(), self.Property.len()]); @@ -281,7 +281,6 @@ impl Tables { buffer.write_u32(x.HashValue); } - buffer.resize(round(buffer.len(), 4), 0); - buffer + buffer.into_stream() } } diff --git a/crates/libs/metadata/src/writer/winmd/write/traits.rs b/crates/libs/metadata/src/writer/winmd/write/traits.rs new file mode 100644 index 0000000000..2001755c98 --- /dev/null +++ b/crates/libs/metadata/src/writer/winmd/write/traits.rs @@ -0,0 +1,66 @@ +use super::round; + +pub trait Write { + unsafe fn write_header(&mut self, value: &T); + fn write_u8(&mut self, value: u8); + fn write_u16(&mut self, value: u16); + fn write_u32(&mut self, value: u32); + fn write_u64(&mut self, value: u64); + fn write_code(&mut self, value: u32, size: usize); + fn write_index(&mut self, index: u32, len: usize); + fn into_stream(self) -> Self; +} + +impl Write for Vec { + unsafe fn write_header(&mut self, value: &T) { + self.extend_from_slice(std::slice::from_raw_parts(value as *const _ as _, std::mem::size_of::())); + } + + fn write_u8(&mut self, value: u8) { + self.extend_from_slice(&value.to_le_bytes()); + } + + fn write_u16(&mut self, value: u16) { + self.extend_from_slice(&value.to_le_bytes()); + } + + fn write_u32(&mut self, value: u32) { + self.extend_from_slice(&value.to_le_bytes()); + } + + fn write_u64(&mut self, value: u64) { + self.extend_from_slice(&value.to_le_bytes()); + } + + fn write_code(&mut self, value: u32, size: usize) { + if size == 2 { + self.write_u16(value as _); + } else { + self.write_u32(value); + } + } + + fn write_index(&mut self, index: u32, len: usize) { + if len < (1 << 16) { + self.write_u16(index as u16 + 1); + } else { + self.write_u32(index + 1); + } + } + + fn into_stream(mut self) -> Self { + self.resize(round(self.len(), 4), 0); + self + } +} + +pub trait Push2 { + fn push2(&mut self, value: T) -> u32; +} + +impl Push2 for Vec { + fn push2(&mut self, value: T) -> u32 { + self.push(value); + (self.len() - 1) as _ + } +} diff --git a/crates/libs/windows/src/Windows/AI/MachineLearning/impl.rs b/crates/libs/windows/src/Windows/AI/MachineLearning/impl.rs index 379d1cbdda..c7607c6de3 100644 --- a/crates/libs/windows/src/Windows/AI/MachineLearning/impl.rs +++ b/crates/libs/windows/src/Windows/AI/MachineLearning/impl.rs @@ -40,7 +40,6 @@ impl ILearningModelFeatureDescriptor_Vtbl { match this.Kind() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -52,7 +51,6 @@ impl ILearningModelFeatureDescriptor_Vtbl { match this.IsRequired() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -85,7 +83,6 @@ impl ILearningModelFeatureValue_Vtbl { match this.Kind() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -129,7 +126,6 @@ impl ITensor_Vtbl { match this.TensorKind() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/ApplicationModel/Activation/impl.rs b/crates/libs/windows/src/Windows/ApplicationModel/Activation/impl.rs index 70b6b27593..943a192c10 100644 --- a/crates/libs/windows/src/Windows/ApplicationModel/Activation/impl.rs +++ b/crates/libs/windows/src/Windows/ApplicationModel/Activation/impl.rs @@ -15,7 +15,6 @@ impl IActivatedEventArgs_Vtbl { match this.Kind() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -27,7 +26,6 @@ impl IActivatedEventArgs_Vtbl { match this.PreviousExecutionState() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -101,7 +99,6 @@ impl IApplicationViewActivatedEventArgs_Vtbl { match this.CurrentlyShownApplicationViewId() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -325,7 +322,6 @@ impl IAppointmentsProviderShowTimeFrameActivatedEventArgs_Vtbl { match this.TimeToShow() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -337,7 +333,6 @@ impl IAppointmentsProviderShowTimeFrameActivatedEventArgs_Vtbl { match this.Duration() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1583,7 +1578,6 @@ impl IPhoneCallActivatedEventArgs_Vtbl { match this.LineId() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1640,7 +1634,6 @@ impl IPrelaunchActivatedEventArgs_Vtbl { match this.PrelaunchActivated() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -2173,7 +2166,6 @@ impl IWalletActionActivatedEventArgs_Vtbl { match this.ActionKind() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/ApplicationModel/Background/impl.rs b/crates/libs/windows/src/Windows/ApplicationModel/Background/impl.rs index 2e13758498..5864e6b29f 100644 --- a/crates/libs/windows/src/Windows/ApplicationModel/Background/impl.rs +++ b/crates/libs/windows/src/Windows/ApplicationModel/Background/impl.rs @@ -57,7 +57,6 @@ impl IBackgroundTaskInstance_Vtbl { match this.InstanceId() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -81,7 +80,6 @@ impl IBackgroundTaskInstance_Vtbl { match this.Progress() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -110,7 +108,6 @@ impl IBackgroundTaskInstance_Vtbl { match this.Canceled(::windows_core::from_raw_borrowed(&cancelhandler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -127,7 +124,6 @@ impl IBackgroundTaskInstance_Vtbl { match this.SuspendedCount() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -180,7 +176,6 @@ impl IBackgroundTaskInstance2_Vtbl { match this.GetThrottleCount(counter) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -249,7 +244,6 @@ impl IBackgroundTaskRegistration_Vtbl { match this.TaskId() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -273,7 +267,6 @@ impl IBackgroundTaskRegistration_Vtbl { match this.Progress(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -290,7 +283,6 @@ impl IBackgroundTaskRegistration_Vtbl { match this.Completed(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/ApplicationModel/Chat/impl.rs b/crates/libs/windows/src/Windows/ApplicationModel/Chat/impl.rs index 6109fa6534..071741ed2b 100644 --- a/crates/libs/windows/src/Windows/ApplicationModel/Chat/impl.rs +++ b/crates/libs/windows/src/Windows/ApplicationModel/Chat/impl.rs @@ -13,7 +13,6 @@ impl IChatItem_Vtbl { match this.ItemKind() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/ApplicationModel/Contacts/impl.rs b/crates/libs/windows/src/Windows/ApplicationModel/Contacts/impl.rs index fd3d3e2577..abb7ac7f7b 100644 --- a/crates/libs/windows/src/Windows/ApplicationModel/Contacts/impl.rs +++ b/crates/libs/windows/src/Windows/ApplicationModel/Contacts/impl.rs @@ -16,7 +16,6 @@ impl IContactField_Vtbl { match this.Type() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -28,7 +27,6 @@ impl IContactField_Vtbl { match this.Category() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/ApplicationModel/Core/impl.rs b/crates/libs/windows/src/Windows/ApplicationModel/Core/impl.rs index 3b5a3f2aef..7806ed980f 100644 --- a/crates/libs/windows/src/Windows/ApplicationModel/Core/impl.rs +++ b/crates/libs/windows/src/Windows/ApplicationModel/Core/impl.rs @@ -17,7 +17,6 @@ impl ICoreApplicationUnhandledError_Vtbl { match this.UnhandledErrorDetected(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/ApplicationModel/UserDataAccounts/Provider/impl.rs b/crates/libs/windows/src/Windows/ApplicationModel/UserDataAccounts/Provider/impl.rs index 0afc5c6c03..f6cf090ebd 100644 --- a/crates/libs/windows/src/Windows/ApplicationModel/UserDataAccounts/Provider/impl.rs +++ b/crates/libs/windows/src/Windows/ApplicationModel/UserDataAccounts/Provider/impl.rs @@ -13,7 +13,6 @@ impl IUserDataAccountProviderOperation_Vtbl { match this.Kind() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/ApplicationModel/impl.rs b/crates/libs/windows/src/Windows/ApplicationModel/impl.rs index 1ad1e46e62..db088dba2b 100644 --- a/crates/libs/windows/src/Windows/ApplicationModel/impl.rs +++ b/crates/libs/windows/src/Windows/ApplicationModel/impl.rs @@ -175,7 +175,6 @@ impl ISuspendingOperation_Vtbl { match this.Deadline() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Data/Json/impl.rs b/crates/libs/windows/src/Windows/Data/Json/impl.rs index d3a326859a..624699842a 100644 --- a/crates/libs/windows/src/Windows/Data/Json/impl.rs +++ b/crates/libs/windows/src/Windows/Data/Json/impl.rs @@ -19,7 +19,6 @@ impl IJsonValue_Vtbl { match this.ValueType() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -55,7 +54,6 @@ impl IJsonValue_Vtbl { match this.GetNumber() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -67,7 +65,6 @@ impl IJsonValue_Vtbl { match this.GetBoolean() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Data/Xml/Dom/impl.rs b/crates/libs/windows/src/Windows/Data/Xml/Dom/impl.rs index 1b63825da7..99b0c63876 100644 --- a/crates/libs/windows/src/Windows/Data/Xml/Dom/impl.rs +++ b/crates/libs/windows/src/Windows/Data/Xml/Dom/impl.rs @@ -37,7 +37,6 @@ impl IXmlCharacterData_Vtbl { match this.Length() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -145,7 +144,6 @@ impl IXmlNode_Vtbl { match this.NodeType() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -253,7 +251,6 @@ impl IXmlNode_Vtbl { match this.HasChildNodes() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Devices/Adc/Provider/impl.rs b/crates/libs/windows/src/Windows/Devices/Adc/Provider/impl.rs index 71628d33f8..356fd4ec39 100644 --- a/crates/libs/windows/src/Windows/Devices/Adc/Provider/impl.rs +++ b/crates/libs/windows/src/Windows/Devices/Adc/Provider/impl.rs @@ -22,7 +22,6 @@ impl IAdcControllerProvider_Vtbl { match this.ChannelCount() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -34,7 +33,6 @@ impl IAdcControllerProvider_Vtbl { match this.ResolutionInBits() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -46,7 +44,6 @@ impl IAdcControllerProvider_Vtbl { match this.MinValue() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -58,7 +55,6 @@ impl IAdcControllerProvider_Vtbl { match this.MaxValue() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -70,7 +66,6 @@ impl IAdcControllerProvider_Vtbl { match this.ChannelMode() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -87,7 +82,6 @@ impl IAdcControllerProvider_Vtbl { match this.IsChannelModeSupported(channelmode) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -109,7 +103,6 @@ impl IAdcControllerProvider_Vtbl { match this.ReadValue(channelnumber) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Devices/Custom/impl.rs b/crates/libs/windows/src/Windows/Devices/Custom/impl.rs index 4a587b8eb6..203805add0 100644 --- a/crates/libs/windows/src/Windows/Devices/Custom/impl.rs +++ b/crates/libs/windows/src/Windows/Devices/Custom/impl.rs @@ -17,7 +17,6 @@ impl IIOControlCode_Vtbl { match this.AccessMode() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -29,7 +28,6 @@ impl IIOControlCode_Vtbl { match this.BufferingMethod() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -41,7 +39,6 @@ impl IIOControlCode_Vtbl { match this.Function() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -53,7 +50,6 @@ impl IIOControlCode_Vtbl { match this.DeviceType() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -65,7 +61,6 @@ impl IIOControlCode_Vtbl { match this.ControlCode() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Devices/Geolocation/impl.rs b/crates/libs/windows/src/Windows/Devices/Geolocation/impl.rs index e3642ca1eb..9bd273cbce 100644 --- a/crates/libs/windows/src/Windows/Devices/Geolocation/impl.rs +++ b/crates/libs/windows/src/Windows/Devices/Geolocation/impl.rs @@ -15,7 +15,6 @@ impl IGeoshape_Vtbl { match this.GeoshapeType() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -27,7 +26,6 @@ impl IGeoshape_Vtbl { match this.SpatialReferenceId() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -39,7 +37,6 @@ impl IGeoshape_Vtbl { match this.AltitudeReferenceSystem() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Devices/Gpio/Provider/impl.rs b/crates/libs/windows/src/Windows/Devices/Gpio/Provider/impl.rs index 435bf96d6e..1fb127d0fa 100644 --- a/crates/libs/windows/src/Windows/Devices/Gpio/Provider/impl.rs +++ b/crates/libs/windows/src/Windows/Devices/Gpio/Provider/impl.rs @@ -14,7 +14,6 @@ impl IGpioControllerProvider_Vtbl { match this.PinCount() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -70,7 +69,6 @@ impl IGpioPinProvider_Vtbl { match this.ValueChanged(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -87,7 +85,6 @@ impl IGpioPinProvider_Vtbl { match this.DebounceTimeout() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -104,7 +101,6 @@ impl IGpioPinProvider_Vtbl { match this.PinNumber() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -116,7 +112,6 @@ impl IGpioPinProvider_Vtbl { match this.SharingMode() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -128,7 +123,6 @@ impl IGpioPinProvider_Vtbl { match this.IsDriveModeSupported(drivemode) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -140,7 +134,6 @@ impl IGpioPinProvider_Vtbl { match this.GetDriveMode() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -162,7 +155,6 @@ impl IGpioPinProvider_Vtbl { match this.Read() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Devices/I2c/Provider/impl.rs b/crates/libs/windows/src/Windows/Devices/I2c/Provider/impl.rs index 981b893c21..17f0b53653 100644 --- a/crates/libs/windows/src/Windows/Devices/I2c/Provider/impl.rs +++ b/crates/libs/windows/src/Windows/Devices/I2c/Provider/impl.rs @@ -69,7 +69,6 @@ impl II2cDeviceProvider_Vtbl { match this.WritePartial(::core::slice::from_raw_parts(::core::mem::transmute_copy(&buffer), buffer_array_size as _)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -86,7 +85,6 @@ impl II2cDeviceProvider_Vtbl { match this.ReadPartial(::core::slice::from_raw_parts_mut(::core::mem::transmute_copy(&buffer), buffer_array_size as _)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -103,7 +101,6 @@ impl II2cDeviceProvider_Vtbl { match this.WriteReadPartial(::core::slice::from_raw_parts(::core::mem::transmute_copy(&writebuffer), writeBuffer_array_size as _), ::core::slice::from_raw_parts_mut(::core::mem::transmute_copy(&readbuffer), readBuffer_array_size as _)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Devices/Lights/Effects/impl.rs b/crates/libs/windows/src/Windows/Devices/Lights/Effects/impl.rs index c6d3f19c03..9f86661a20 100644 --- a/crates/libs/windows/src/Windows/Devices/Lights/Effects/impl.rs +++ b/crates/libs/windows/src/Windows/Devices/Lights/Effects/impl.rs @@ -14,7 +14,6 @@ impl ILampArrayEffect_Vtbl { match this.ZIndex() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Devices/Midi/impl.rs b/crates/libs/windows/src/Windows/Devices/Midi/impl.rs index 8b7bf8f500..d2978883a8 100644 --- a/crates/libs/windows/src/Windows/Devices/Midi/impl.rs +++ b/crates/libs/windows/src/Windows/Devices/Midi/impl.rs @@ -18,7 +18,6 @@ impl IMidiMessage_Vtbl { match this.Timestamp() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -42,7 +41,6 @@ impl IMidiMessage_Vtbl { match this.Type() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Devices/PointOfService/impl.rs b/crates/libs/windows/src/Windows/Devices/PointOfService/impl.rs index 6cbfd098ae..8b0c1935bb 100644 --- a/crates/libs/windows/src/Windows/Devices/PointOfService/impl.rs +++ b/crates/libs/windows/src/Windows/Devices/PointOfService/impl.rs @@ -66,7 +66,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.CharactersPerLine() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -83,7 +82,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.LineHeight() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -100,7 +98,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.LineSpacing() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -112,7 +109,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.LineWidth() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -129,7 +125,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.IsLetterQuality() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -141,7 +136,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.IsPaperNearEnd() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -158,7 +152,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.ColorCartridge() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -170,7 +163,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.IsCoverOpen() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -182,7 +174,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.IsCartridgeRemoved() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -194,7 +185,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.IsCartridgeEmpty() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -206,7 +196,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.IsHeadCleaning() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -218,7 +207,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.IsPaperEmpty() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -230,7 +218,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.IsReadyToPrint() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -242,7 +229,6 @@ impl ICommonClaimedPosPrinterStation_Vtbl { match this.ValidateData(::core::mem::transmute(&data)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -305,7 +291,6 @@ impl ICommonPosPrintStationCapabilities_Vtbl { match this.IsPrinterPresent() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -317,7 +302,6 @@ impl ICommonPosPrintStationCapabilities_Vtbl { match this.IsDualColorSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -329,7 +313,6 @@ impl ICommonPosPrintStationCapabilities_Vtbl { match this.ColorCartridgeCapabilities() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -341,7 +324,6 @@ impl ICommonPosPrintStationCapabilities_Vtbl { match this.CartridgeSensors() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -353,7 +335,6 @@ impl ICommonPosPrintStationCapabilities_Vtbl { match this.IsBoldSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -365,7 +346,6 @@ impl ICommonPosPrintStationCapabilities_Vtbl { match this.IsItalicSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -377,7 +357,6 @@ impl ICommonPosPrintStationCapabilities_Vtbl { match this.IsUnderlineSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -389,7 +368,6 @@ impl ICommonPosPrintStationCapabilities_Vtbl { match this.IsDoubleHighPrintSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -401,7 +379,6 @@ impl ICommonPosPrintStationCapabilities_Vtbl { match this.IsDoubleWidePrintSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -413,7 +390,6 @@ impl ICommonPosPrintStationCapabilities_Vtbl { match this.IsDoubleHighDoubleWidePrintSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -425,7 +401,6 @@ impl ICommonPosPrintStationCapabilities_Vtbl { match this.IsPaperEmptySensorSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -437,7 +412,6 @@ impl ICommonPosPrintStationCapabilities_Vtbl { match this.IsPaperNearEndSensorSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -502,7 +476,6 @@ impl ICommonReceiptSlipCapabilities_Vtbl { match this.IsBarcodeSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -514,7 +487,6 @@ impl ICommonReceiptSlipCapabilities_Vtbl { match this.IsBitmapSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -526,7 +498,6 @@ impl ICommonReceiptSlipCapabilities_Vtbl { match this.IsLeft90RotationSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -538,7 +509,6 @@ impl ICommonReceiptSlipCapabilities_Vtbl { match this.IsRight90RotationSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -550,7 +520,6 @@ impl ICommonReceiptSlipCapabilities_Vtbl { match this.Is180RotationSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -562,7 +531,6 @@ impl ICommonReceiptSlipCapabilities_Vtbl { match this.IsPrintAreaSupported() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -574,7 +542,6 @@ impl ICommonReceiptSlipCapabilities_Vtbl { match this.RuledLineCapabilities() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Devices/Pwm/Provider/impl.rs b/crates/libs/windows/src/Windows/Devices/Pwm/Provider/impl.rs index a9a91ae190..99e8dfe0e1 100644 --- a/crates/libs/windows/src/Windows/Devices/Pwm/Provider/impl.rs +++ b/crates/libs/windows/src/Windows/Devices/Pwm/Provider/impl.rs @@ -22,7 +22,6 @@ impl IPwmControllerProvider_Vtbl { match this.PinCount() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -34,7 +33,6 @@ impl IPwmControllerProvider_Vtbl { match this.ActualFrequency() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -46,7 +44,6 @@ impl IPwmControllerProvider_Vtbl { match this.SetDesiredFrequency(frequency) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -58,7 +55,6 @@ impl IPwmControllerProvider_Vtbl { match this.MaxFrequency() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -70,7 +66,6 @@ impl IPwmControllerProvider_Vtbl { match this.MinFrequency() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Devices/Scanners/impl.rs b/crates/libs/windows/src/Windows/Devices/Scanners/impl.rs index cd85cf493e..c005ae1c8e 100644 --- a/crates/libs/windows/src/Windows/Devices/Scanners/impl.rs +++ b/crates/libs/windows/src/Windows/Devices/Scanners/impl.rs @@ -16,7 +16,6 @@ impl IImageScannerFormatConfiguration_Vtbl { match this.DefaultFormat() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -28,7 +27,6 @@ impl IImageScannerFormatConfiguration_Vtbl { match this.Format() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -45,7 +43,6 @@ impl IImageScannerFormatConfiguration_Vtbl { match this.IsFormatSupported(value) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -109,7 +106,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.MinScanArea() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -121,7 +117,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.MaxScanArea() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -133,7 +128,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.SelectedScanRegion() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -150,7 +144,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.AutoCroppingMode() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -167,7 +160,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.IsAutoCroppingModeSupported(value) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -179,7 +171,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.MinResolution() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -191,7 +182,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.MaxResolution() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -203,7 +193,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.OpticalResolution() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -215,7 +204,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.DesiredResolution() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -232,7 +220,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.ActualResolution() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -244,7 +231,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.DefaultColorMode() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -256,7 +242,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.ColorMode() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -273,7 +258,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.IsColorModeSupported(value) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -285,7 +269,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.MinBrightness() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -297,7 +280,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.MaxBrightness() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -309,7 +291,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.BrightnessStep() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -321,7 +302,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.DefaultBrightness() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -333,7 +313,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.Brightness() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -350,7 +329,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.MinContrast() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -362,7 +340,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.MaxContrast() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -374,7 +351,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.ContrastStep() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -386,7 +362,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.DefaultContrast() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -398,7 +373,6 @@ impl IImageScannerSourceConfiguration_Vtbl { match this.Contrast() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Devices/Sms/impl.rs b/crates/libs/windows/src/Windows/Devices/Sms/impl.rs index 48fc9c7a03..f2c41bbfd2 100644 --- a/crates/libs/windows/src/Windows/Devices/Sms/impl.rs +++ b/crates/libs/windows/src/Windows/Devices/Sms/impl.rs @@ -19,7 +19,6 @@ impl ISmsBinaryMessage_Vtbl { match this.Format() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -99,7 +98,6 @@ impl ISmsDevice_Vtbl { match this.CalculateLength(::windows_core::from_raw_borrowed(&message)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -123,7 +121,6 @@ impl ISmsDevice_Vtbl { match this.CellularClass() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -147,7 +144,6 @@ impl ISmsDevice_Vtbl { match this.DeviceStatus() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -159,7 +155,6 @@ impl ISmsDevice_Vtbl { match this.SmsMessageReceived(::windows_core::from_raw_borrowed(&eventhandler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -176,7 +171,6 @@ impl ISmsDevice_Vtbl { match this.SmsDeviceStatusChanged(::windows_core::from_raw_borrowed(&eventhandler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -221,7 +215,6 @@ impl ISmsMessage_Vtbl { match this.Id() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -233,7 +226,6 @@ impl ISmsMessage_Vtbl { match this.MessageClass() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -268,7 +260,6 @@ impl ISmsMessageBase_Vtbl { match this.MessageType() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -292,7 +283,6 @@ impl ISmsMessageBase_Vtbl { match this.CellularClass() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -304,7 +294,6 @@ impl ISmsMessageBase_Vtbl { match this.MessageClass() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -365,7 +354,6 @@ impl ISmsTextMessage_Vtbl { match this.Timestamp() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -377,7 +365,6 @@ impl ISmsTextMessage_Vtbl { match this.PartReferenceId() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -389,7 +376,6 @@ impl ISmsTextMessage_Vtbl { match this.PartNumber() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -401,7 +387,6 @@ impl ISmsTextMessage_Vtbl { match this.PartCount() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -464,7 +449,6 @@ impl ISmsTextMessage_Vtbl { match this.Encoding() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Foundation/Collections/impl.rs b/crates/libs/windows/src/Windows/Foundation/Collections/impl.rs index 36e4947291..8c050f1b45 100644 --- a/crates/libs/windows/src/Windows/Foundation/Collections/impl.rs +++ b/crates/libs/windows/src/Windows/Foundation/Collections/impl.rs @@ -65,7 +65,6 @@ impl IIterator_Vtbl { match this.HasCurrent() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -77,7 +76,6 @@ impl IIterator_Vtbl { match this.MoveNext() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -89,7 +87,6 @@ impl IIterator_Vtbl { match this.GetMany(::core::slice::from_raw_parts_mut(::core::mem::transmute_copy(&items), items_array_size as _)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -195,7 +192,6 @@ impl { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -207,7 +203,6 @@ impl { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -231,7 +226,6 @@ impl { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -283,7 +277,6 @@ impl IMapChangedEventArgs_Vtbl { match this.CollectionChange() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -346,7 +339,6 @@ impl { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -358,7 +350,6 @@ impl { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -403,7 +394,6 @@ impl { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -445,7 +435,6 @@ impl IObservableVector_Vtbl { match this.VectorChanged(::windows_core::from_raw_borrowed(&vhnd)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -521,7 +510,6 @@ impl IVector_Vtbl { match this.Size() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -545,7 +533,6 @@ impl IVector_Vtbl { match this.IndexOf(::core::mem::transmute(&value), ::core::mem::transmute_copy(&index)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -587,7 +574,6 @@ impl IVector_Vtbl { match this.GetMany(startindex, ::core::slice::from_raw_parts_mut(::core::mem::transmute_copy(&items), items_array_size as _)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -635,7 +621,6 @@ impl IVectorChangedEventArgs_Vtbl { match this.CollectionChange() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -647,7 +632,6 @@ impl IVectorChangedEventArgs_Vtbl { match this.Index() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -696,7 +680,6 @@ impl IVectorView_Vtbl { match this.Size() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -708,7 +691,6 @@ impl IVectorView_Vtbl { match this.IndexOf(::core::mem::transmute(&value), ::core::mem::transmute_copy(&index)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -720,7 +702,6 @@ impl IVectorView_Vtbl { match this.GetMany(startindex, ::core::slice::from_raw_parts_mut(::core::mem::transmute_copy(&items), items_array_size as _)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Foundation/Diagnostics/impl.rs b/crates/libs/windows/src/Windows/Foundation/Diagnostics/impl.rs index 5a008e1089..44a6eab65b 100644 --- a/crates/libs/windows/src/Windows/Foundation/Diagnostics/impl.rs +++ b/crates/libs/windows/src/Windows/Foundation/Diagnostics/impl.rs @@ -19,7 +19,6 @@ impl IErrorReportingSettings_Vtbl { match this.GetErrorOptions() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -98,7 +97,6 @@ impl IFileLoggingSession_Vtbl { match this.LogFileGenerated(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -159,7 +157,6 @@ impl ILoggingChannel_Vtbl { match this.Enabled() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -171,7 +168,6 @@ impl ILoggingChannel_Vtbl { match this.Level() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -203,7 +199,6 @@ impl ILoggingChannel_Vtbl { match this.LoggingEnabled(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -324,7 +319,6 @@ impl ILoggingTarget_Vtbl { match this.IsEnabled() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -336,7 +330,6 @@ impl ILoggingTarget_Vtbl { match this.IsEnabledWithLevel(level) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -348,7 +341,6 @@ impl ILoggingTarget_Vtbl { match this.IsEnabledWithLevelAndKeywords(level, keywords) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Foundation/impl.rs b/crates/libs/windows/src/Windows/Foundation/impl.rs index 80de1ca6f2..9d327bc945 100644 --- a/crates/libs/windows/src/Windows/Foundation/impl.rs +++ b/crates/libs/windows/src/Windows/Foundation/impl.rs @@ -130,7 +130,6 @@ impl IAsyncInfo_Vtbl { match this.Id() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -142,7 +141,6 @@ impl IAsyncInfo_Vtbl { match this.Status() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -154,7 +152,6 @@ impl IAsyncInfo_Vtbl { match this.ErrorCode() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -410,7 +407,6 @@ impl IMemoryBufferReference_Vtbl { match this.Capacity() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -422,7 +418,6 @@ impl IMemoryBufferReference_Vtbl { match this.Closed(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -497,7 +492,6 @@ impl IPropertyValue_Vtbl { match this.Type() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -509,7 +503,6 @@ impl IPropertyValue_Vtbl { match this.IsNumericScalar() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -521,7 +514,6 @@ impl IPropertyValue_Vtbl { match this.GetUInt8() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -533,7 +525,6 @@ impl IPropertyValue_Vtbl { match this.GetInt16() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -545,7 +536,6 @@ impl IPropertyValue_Vtbl { match this.GetUInt16() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -557,7 +547,6 @@ impl IPropertyValue_Vtbl { match this.GetInt32() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -569,7 +558,6 @@ impl IPropertyValue_Vtbl { match this.GetUInt32() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -581,7 +569,6 @@ impl IPropertyValue_Vtbl { match this.GetInt64() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -593,7 +580,6 @@ impl IPropertyValue_Vtbl { match this.GetUInt64() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -605,7 +591,6 @@ impl IPropertyValue_Vtbl { match this.GetSingle() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -617,7 +602,6 @@ impl IPropertyValue_Vtbl { match this.GetDouble() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -629,7 +613,6 @@ impl IPropertyValue_Vtbl { match this.GetChar16() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -641,7 +624,6 @@ impl IPropertyValue_Vtbl { match this.GetBoolean() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -665,7 +647,6 @@ impl IPropertyValue_Vtbl { match this.GetGuid() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -677,7 +658,6 @@ impl IPropertyValue_Vtbl { match this.GetDateTime() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -689,7 +669,6 @@ impl IPropertyValue_Vtbl { match this.GetTimeSpan() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -701,7 +680,6 @@ impl IPropertyValue_Vtbl { match this.GetPoint() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -713,7 +691,6 @@ impl IPropertyValue_Vtbl { match this.GetSize() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -725,7 +702,6 @@ impl IPropertyValue_Vtbl { match this.GetRect() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Gaming/Input/Custom/impl.rs b/crates/libs/windows/src/Windows/Gaming/Input/Custom/impl.rs index 40b6fc2774..9e286a8a92 100644 --- a/crates/libs/windows/src/Windows/Gaming/Input/Custom/impl.rs +++ b/crates/libs/windows/src/Windows/Gaming/Input/Custom/impl.rs @@ -91,7 +91,6 @@ impl IGameControllerProvider_Vtbl { match this.FirmwareVersionInfo() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -103,7 +102,6 @@ impl IGameControllerProvider_Vtbl { match this.HardwareProductId() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -115,7 +113,6 @@ impl IGameControllerProvider_Vtbl { match this.HardwareVendorId() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -127,7 +124,6 @@ impl IGameControllerProvider_Vtbl { match this.HardwareVersionInfo() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -139,7 +135,6 @@ impl IGameControllerProvider_Vtbl { match this.IsConnected() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Gaming/Input/ForceFeedback/impl.rs b/crates/libs/windows/src/Windows/Gaming/Input/ForceFeedback/impl.rs index 7261c5a8c5..aa84f899a5 100644 --- a/crates/libs/windows/src/Windows/Gaming/Input/ForceFeedback/impl.rs +++ b/crates/libs/windows/src/Windows/Gaming/Input/ForceFeedback/impl.rs @@ -17,7 +17,6 @@ impl IForceFeedbackEffect_Vtbl { match this.Gain() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -34,7 +33,6 @@ impl IForceFeedbackEffect_Vtbl { match this.State() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Gaming/Input/impl.rs b/crates/libs/windows/src/Windows/Gaming/Input/impl.rs index 967d068dca..d3036476fc 100644 --- a/crates/libs/windows/src/Windows/Gaming/Input/impl.rs +++ b/crates/libs/windows/src/Windows/Gaming/Input/impl.rs @@ -24,7 +24,6 @@ impl IGameController_Vtbl { match this.HeadsetConnected(::windows_core::from_raw_borrowed(&value)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -41,7 +40,6 @@ impl IGameController_Vtbl { match this.HeadsetDisconnected(::windows_core::from_raw_borrowed(&value)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -58,7 +56,6 @@ impl IGameController_Vtbl { match this.UserChanged(::windows_core::from_raw_borrowed(&value)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -87,7 +84,6 @@ impl IGameController_Vtbl { match this.IsWireless() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Gaming/Preview/GamesEnumeration/impl.rs b/crates/libs/windows/src/Windows/Gaming/Preview/GamesEnumeration/impl.rs index dfd36501fc..95a8c6c7ed 100644 --- a/crates/libs/windows/src/Windows/Gaming/Preview/GamesEnumeration/impl.rs +++ b/crates/libs/windows/src/Windows/Gaming/Preview/GamesEnumeration/impl.rs @@ -44,7 +44,6 @@ impl IGameListEntry_Vtbl { match this.Category() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Globalization/NumberFormatting/impl.rs b/crates/libs/windows/src/Windows/Globalization/NumberFormatting/impl.rs index 7901ecd320..38be6826bc 100644 --- a/crates/libs/windows/src/Windows/Globalization/NumberFormatting/impl.rs +++ b/crates/libs/windows/src/Windows/Globalization/NumberFormatting/impl.rs @@ -169,7 +169,6 @@ impl INumberFormatterOptions_Vtbl { match this.IntegerDigits() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -186,7 +185,6 @@ impl INumberFormatterOptions_Vtbl { match this.FractionDigits() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -203,7 +201,6 @@ impl INumberFormatterOptions_Vtbl { match this.IsGrouped() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -220,7 +217,6 @@ impl INumberFormatterOptions_Vtbl { match this.IsDecimalPointAlwaysDisplayed() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -375,7 +371,6 @@ impl INumberRounder_Vtbl { match this.RoundInt32(value) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -387,7 +382,6 @@ impl INumberRounder_Vtbl { match this.RoundUInt32(value) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -399,7 +393,6 @@ impl INumberRounder_Vtbl { match this.RoundInt64(value) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -411,7 +404,6 @@ impl INumberRounder_Vtbl { match this.RoundUInt64(value) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -423,7 +415,6 @@ impl INumberRounder_Vtbl { match this.RoundSingle(value) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -435,7 +426,6 @@ impl INumberRounder_Vtbl { match this.RoundDouble(value) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -508,7 +498,6 @@ impl ISignedZeroOption_Vtbl { match this.IsZeroSigned() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -545,7 +534,6 @@ impl ISignificantDigitsOption_Vtbl { match this.SignificantDigits() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Graphics/DirectX/Direct3D11/impl.rs b/crates/libs/windows/src/Windows/Graphics/DirectX/Direct3D11/impl.rs index 0a50aacba7..c029441505 100644 --- a/crates/libs/windows/src/Windows/Graphics/DirectX/Direct3D11/impl.rs +++ b/crates/libs/windows/src/Windows/Graphics/DirectX/Direct3D11/impl.rs @@ -39,7 +39,6 @@ impl IDirect3DSurface_Vtbl { match this.Description() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Graphics/Imaging/impl.rs b/crates/libs/windows/src/Windows/Graphics/Imaging/impl.rs index 8f27f39a89..c3b6cbb43a 100644 --- a/crates/libs/windows/src/Windows/Graphics/Imaging/impl.rs +++ b/crates/libs/windows/src/Windows/Graphics/Imaging/impl.rs @@ -51,7 +51,6 @@ impl IBitmapFrame_Vtbl { match this.BitmapPixelFormat() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -63,7 +62,6 @@ impl IBitmapFrame_Vtbl { match this.BitmapAlphaMode() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -75,7 +73,6 @@ impl IBitmapFrame_Vtbl { match this.DpiX() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -87,7 +84,6 @@ impl IBitmapFrame_Vtbl { match this.DpiY() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -99,7 +95,6 @@ impl IBitmapFrame_Vtbl { match this.PixelWidth() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -111,7 +106,6 @@ impl IBitmapFrame_Vtbl { match this.PixelHeight() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -123,7 +117,6 @@ impl IBitmapFrame_Vtbl { match this.OrientedPixelWidth() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -135,7 +128,6 @@ impl IBitmapFrame_Vtbl { match this.OrientedPixelHeight() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Graphics/Printing/OptionDetails/impl.rs b/crates/libs/windows/src/Windows/Graphics/Printing/OptionDetails/impl.rs index 8e992f37a2..6e00aebd01 100644 --- a/crates/libs/windows/src/Windows/Graphics/Printing/OptionDetails/impl.rs +++ b/crates/libs/windows/src/Windows/Graphics/Printing/OptionDetails/impl.rs @@ -81,7 +81,6 @@ impl IPrintNumberOptionDetails_Vtbl { match this.MinValue() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -93,7 +92,6 @@ impl IPrintNumberOptionDetails_Vtbl { match this.MaxValue() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -143,7 +141,6 @@ impl IPrintOptionDetails_Vtbl { match this.OptionType() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -177,7 +174,6 @@ impl IPrintOptionDetails_Vtbl { match this.State() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -201,7 +197,6 @@ impl IPrintOptionDetails_Vtbl { match this.TrySetValue(::windows_core::from_raw_borrowed(&value)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -238,7 +233,6 @@ impl IPrintTextOptionDetails_Vtbl { match this.MaxCharacters() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Graphics/Printing/impl.rs b/crates/libs/windows/src/Windows/Graphics/Printing/impl.rs index 6299331474..ea5913f347 100644 --- a/crates/libs/windows/src/Windows/Graphics/Printing/impl.rs +++ b/crates/libs/windows/src/Windows/Graphics/Printing/impl.rs @@ -29,7 +29,6 @@ impl IPrintTaskOptionsCore_Vtbl { match this.GetPageDescription(jobpagenumber) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -87,7 +86,6 @@ impl IPrintTaskOptionsCoreProperties_Vtbl { match this.MediaSize() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -104,7 +102,6 @@ impl IPrintTaskOptionsCoreProperties_Vtbl { match this.MediaType() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -121,7 +118,6 @@ impl IPrintTaskOptionsCoreProperties_Vtbl { match this.Orientation() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -138,7 +134,6 @@ impl IPrintTaskOptionsCoreProperties_Vtbl { match this.PrintQuality() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -155,7 +150,6 @@ impl IPrintTaskOptionsCoreProperties_Vtbl { match this.ColorMode() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -172,7 +166,6 @@ impl IPrintTaskOptionsCoreProperties_Vtbl { match this.Duplex() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -189,7 +182,6 @@ impl IPrintTaskOptionsCoreProperties_Vtbl { match this.Collation() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -206,7 +198,6 @@ impl IPrintTaskOptionsCoreProperties_Vtbl { match this.Staple() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -223,7 +214,6 @@ impl IPrintTaskOptionsCoreProperties_Vtbl { match this.HolePunch() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -240,7 +230,6 @@ impl IPrintTaskOptionsCoreProperties_Vtbl { match this.Binding() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -252,7 +241,6 @@ impl IPrintTaskOptionsCoreProperties_Vtbl { match this.MinCopies() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -264,7 +252,6 @@ impl IPrintTaskOptionsCoreProperties_Vtbl { match this.MaxCopies() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -281,7 +268,6 @@ impl IPrintTaskOptionsCoreProperties_Vtbl { match this.NumberOfCopies() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Media/Audio/impl.rs b/crates/libs/windows/src/Windows/Media/Audio/impl.rs index 4f4a2ed8bc..842aea52d6 100644 --- a/crates/libs/windows/src/Windows/Media/Audio/impl.rs +++ b/crates/libs/windows/src/Windows/Media/Audio/impl.rs @@ -127,7 +127,6 @@ impl IAudioNode_Vtbl { match this.OutgoingGain() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -151,7 +150,6 @@ impl IAudioNode_Vtbl { match this.ConsumeInput() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Media/Core/impl.rs b/crates/libs/windows/src/Windows/Media/Core/impl.rs index 14ae64f494..a55bcc517d 100644 --- a/crates/libs/windows/src/Windows/Media/Core/impl.rs +++ b/crates/libs/windows/src/Windows/Media/Core/impl.rs @@ -26,7 +26,6 @@ impl IMediaCue_Vtbl { match this.StartTime() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -43,7 +42,6 @@ impl IMediaCue_Vtbl { match this.Duration() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -112,7 +110,6 @@ impl IMediaStreamDescriptor_Vtbl { match this.IsSelected() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -245,7 +242,6 @@ impl IMediaTrack_Vtbl { match this.TrackKind() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -302,7 +298,6 @@ impl ISingleSelectMediaTrackList_Vtbl { match this.SelectedIndexChanged(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -324,7 +319,6 @@ impl ISingleSelectMediaTrackList_Vtbl { match this.SelectedIndex() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Media/Devices/impl.rs b/crates/libs/windows/src/Windows/Media/Devices/impl.rs index 09b1e6dcd8..a65aad5c02 100644 --- a/crates/libs/windows/src/Windows/Media/Devices/impl.rs +++ b/crates/libs/windows/src/Windows/Media/Devices/impl.rs @@ -26,7 +26,6 @@ impl IDefaultAudioDeviceChangedEventArgs_Vtbl { match this.Role() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Media/Effects/impl.rs b/crates/libs/windows/src/Windows/Media/Effects/impl.rs index f845ee4e79..bdb93488b2 100644 --- a/crates/libs/windows/src/Windows/Media/Effects/impl.rs +++ b/crates/libs/windows/src/Windows/Media/Effects/impl.rs @@ -68,7 +68,6 @@ impl IBasicAudioEffect_Vtbl { match this.UseInputFrameForOutput() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -145,7 +144,6 @@ impl IBasicVideoEffect_Vtbl { match this.IsReadOnly() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -157,7 +155,6 @@ impl IBasicVideoEffect_Vtbl { match this.SupportedMemoryTypes() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -169,7 +166,6 @@ impl IBasicVideoEffect_Vtbl { match this.TimeIndependent() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -245,7 +241,6 @@ impl IVideoCompositor_Vtbl { match this.TimeIndependent() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Media/Protection/PlayReady/impl.rs b/crates/libs/windows/src/Windows/Media/Protection/PlayReady/impl.rs index 092d0fecdc..d5b3d48fff 100644 --- a/crates/libs/windows/src/Windows/Media/Protection/PlayReady/impl.rs +++ b/crates/libs/windows/src/Windows/Media/Protection/PlayReady/impl.rs @@ -18,7 +18,6 @@ impl INDClosedCaptionDataReceivedEventArgs_Vtbl { match this.ClosedCaptionDataFormat() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -30,7 +29,6 @@ impl INDClosedCaptionDataReceivedEventArgs_Vtbl { match this.PresentationTimestamp() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -160,7 +158,6 @@ impl INDDownloadEngine_Vtbl { match this.CanSeek() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -172,7 +169,6 @@ impl INDDownloadEngine_Vtbl { match this.BufferFullMinThresholdInSamples() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -184,7 +180,6 @@ impl INDDownloadEngine_Vtbl { match this.BufferFullMaxThresholdInSamples() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -334,7 +329,6 @@ impl INDLicenseFetchDescriptor_Vtbl { match this.ContentIDType() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -508,7 +502,6 @@ impl INDProximityDetectionCompletedEventArgs_Vtbl { match this.ProximityDetectionRetryCount() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -568,7 +561,6 @@ impl INDRegistrationCompletedEventArgs_Vtbl { match this.TransmitterCertificateAccepted() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -712,7 +704,6 @@ impl INDStreamParser_Vtbl { match this.GetStreamInformation(::windows_core::from_raw_borrowed(&descriptor), ::core::mem::transmute_copy(&streamtype)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -828,7 +819,6 @@ impl INDTransmitterProperties_Vtbl { match this.CertificateType() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -840,7 +830,6 @@ impl INDTransmitterProperties_Vtbl { match this.PlatformIdentifier() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -865,7 +854,6 @@ impl INDTransmitterProperties_Vtbl { match this.SecurityLevel() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -877,7 +865,6 @@ impl INDTransmitterProperties_Vtbl { match this.SecurityVersion() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -889,7 +876,6 @@ impl INDTransmitterProperties_Vtbl { match this.ExpirationDate() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -998,7 +984,6 @@ impl IPlayReadyDomain_Vtbl { match this.AccountId() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1010,7 +995,6 @@ impl IPlayReadyDomain_Vtbl { match this.ServiceId() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1022,7 +1006,6 @@ impl IPlayReadyDomain_Vtbl { match this.Revision() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1089,7 +1072,6 @@ impl IPlayReadyLicense_Vtbl { match this.FullyEvaluated() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1101,7 +1083,6 @@ impl IPlayReadyLicense_Vtbl { match this.UsableForPlay() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1125,7 +1106,6 @@ impl IPlayReadyLicense_Vtbl { match this.ExpireAfterFirstPlay() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1137,7 +1117,6 @@ impl IPlayReadyLicense_Vtbl { match this.DomainAccountID() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1149,7 +1128,6 @@ impl IPlayReadyLicense_Vtbl { match this.ChainDepth() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1161,7 +1139,6 @@ impl IPlayReadyLicense_Vtbl { match this.GetKIDAtChainDepth(chaindepth) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1220,7 +1197,6 @@ impl IPlayReadyLicenseAcquisitionServiceRequest_Vtbl { match this.DomainServiceId() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1335,7 +1311,6 @@ impl IPlayReadySecureStopServiceRequest_Vtbl { match this.SessionID() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1347,7 +1322,6 @@ impl IPlayReadySecureStopServiceRequest_Vtbl { match this.StartTime() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1359,7 +1333,6 @@ impl IPlayReadySecureStopServiceRequest_Vtbl { match this.UpdateTime() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1371,7 +1344,6 @@ impl IPlayReadySecureStopServiceRequest_Vtbl { match this.Stopped() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1511,7 +1483,6 @@ impl IPlayReadyServiceRequest_Vtbl { match this.ProcessManualEnablingResponse(::core::slice::from_raw_parts(::core::mem::transmute_copy(&responsebytes), responseBytes_array_size as _)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Media/Protection/impl.rs b/crates/libs/windows/src/Windows/Media/Protection/impl.rs index 3f6f5159c9..4084844b74 100644 --- a/crates/libs/windows/src/Windows/Media/Protection/impl.rs +++ b/crates/libs/windows/src/Windows/Media/Protection/impl.rs @@ -14,7 +14,6 @@ impl IMediaProtectionServiceRequest_Vtbl { match this.ProtectionSystem() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -26,7 +25,6 @@ impl IMediaProtectionServiceRequest_Vtbl { match this.Type() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Media/SpeechRecognition/impl.rs b/crates/libs/windows/src/Windows/Media/SpeechRecognition/impl.rs index f28cac7755..0a4b97d296 100644 --- a/crates/libs/windows/src/Windows/Media/SpeechRecognition/impl.rs +++ b/crates/libs/windows/src/Windows/Media/SpeechRecognition/impl.rs @@ -19,7 +19,6 @@ impl ISpeechRecognitionConstraint_Vtbl { match this.IsEnabled() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -53,7 +52,6 @@ impl ISpeechRecognitionConstraint_Vtbl { match this.Type() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -65,7 +63,6 @@ impl ISpeechRecognitionConstraint_Vtbl { match this.Probability() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Media/impl.rs b/crates/libs/windows/src/Windows/Media/impl.rs index 2e42c0df12..f071c1f5a7 100644 --- a/crates/libs/windows/src/Windows/Media/impl.rs +++ b/crates/libs/windows/src/Windows/Media/impl.rs @@ -61,7 +61,6 @@ impl IMediaFrame_Vtbl { match this.IsReadOnly() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -129,7 +128,6 @@ impl IMediaFrame_Vtbl { match this.IsDiscontinuous() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -186,7 +184,6 @@ impl IMediaMarker_Vtbl { match this.Time() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Networking/BackgroundTransfer/impl.rs b/crates/libs/windows/src/Windows/Networking/BackgroundTransfer/impl.rs index 0278c37bd8..d7131a793f 100644 --- a/crates/libs/windows/src/Windows/Networking/BackgroundTransfer/impl.rs +++ b/crates/libs/windows/src/Windows/Networking/BackgroundTransfer/impl.rs @@ -99,7 +99,6 @@ impl IBackgroundTransferBase_Vtbl { match this.CostPolicy() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -198,7 +197,6 @@ impl IBackgroundTransferOperation_Vtbl { match this.Guid() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -246,7 +244,6 @@ impl IBackgroundTransferOperation_Vtbl { match this.CostPolicy() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -313,7 +310,6 @@ impl IBackgroundTransferOperationPriority_Vtbl { match this.Priority() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Networking/Sockets/impl.rs b/crates/libs/windows/src/Windows/Networking/Sockets/impl.rs index 43e632e8f6..f2d8a3e237 100644 --- a/crates/libs/windows/src/Windows/Networking/Sockets/impl.rs +++ b/crates/libs/windows/src/Windows/Networking/Sockets/impl.rs @@ -45,7 +45,6 @@ impl IControlChannelTriggerResetEventDetails_Vtbl { match this.ResetReason() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -57,7 +56,6 @@ impl IControlChannelTriggerResetEventDetails_Vtbl { match this.HardwareSlotReset() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -69,7 +67,6 @@ impl IControlChannelTriggerResetEventDetails_Vtbl { match this.SoftwareSlotReset() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -138,7 +135,6 @@ impl IWebSocket_Vtbl { match this.Closed(::windows_core::from_raw_borrowed(&eventhandler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -192,7 +188,6 @@ impl IWebSocketControl_Vtbl { match this.OutboundBufferSizeInBytes() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -326,7 +321,6 @@ impl IWebSocketInformation_Vtbl { match this.BandwidthStatistics() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -388,7 +382,6 @@ impl IWebSocketInformation2_Vtbl { match this.ServerCertificateErrorSeverity() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Networking/Vpn/impl.rs b/crates/libs/windows/src/Windows/Networking/Vpn/impl.rs index 883b017fb7..4f17a26615 100644 --- a/crates/libs/windows/src/Windows/Networking/Vpn/impl.rs +++ b/crates/libs/windows/src/Windows/Networking/Vpn/impl.rs @@ -138,7 +138,6 @@ impl IVpnCustomPrompt_Vtbl { match this.Compulsory() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -155,7 +154,6 @@ impl IVpnCustomPrompt_Vtbl { match this.Bordered() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -217,7 +215,6 @@ impl IVpnCustomPromptElement_Vtbl { match this.Compulsory() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -234,7 +231,6 @@ impl IVpnCustomPromptElement_Vtbl { match this.Emphasized() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -523,7 +519,6 @@ impl IVpnProfile_Vtbl { match this.RememberCredentials() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -540,7 +535,6 @@ impl IVpnProfile_Vtbl { match this.AlwaysOn() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Phone/Notification/Management/impl.rs b/crates/libs/windows/src/Windows/Phone/Notification/Management/impl.rs index c046343bd0..44de0ee3ec 100644 --- a/crates/libs/windows/src/Windows/Phone/Notification/Management/impl.rs +++ b/crates/libs/windows/src/Windows/Phone/Notification/Management/impl.rs @@ -21,7 +21,6 @@ impl IAccessoryNotificationTriggerDetails_Vtbl { match this.TimeCreated() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -57,7 +56,6 @@ impl IAccessoryNotificationTriggerDetails_Vtbl { match this.AccessoryNotificationType() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -69,7 +67,6 @@ impl IAccessoryNotificationTriggerDetails_Vtbl { match this.StartedProcessing() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Phone/PersonalInformation/impl.rs b/crates/libs/windows/src/Windows/Phone/PersonalInformation/impl.rs index 7d6940acac..2c2d3b128b 100644 --- a/crates/libs/windows/src/Windows/Phone/PersonalInformation/impl.rs +++ b/crates/libs/windows/src/Windows/Phone/PersonalInformation/impl.rs @@ -225,7 +225,6 @@ impl IContactInformation2_Vtbl { match this.DisplayPictureDate() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Security/Authentication/Web/Provider/impl.rs b/crates/libs/windows/src/Windows/Security/Authentication/Web/Provider/impl.rs index 9b53238e6d..38c5a64389 100644 --- a/crates/libs/windows/src/Windows/Security/Authentication/Web/Provider/impl.rs +++ b/crates/libs/windows/src/Windows/Security/Authentication/Web/Provider/impl.rs @@ -46,7 +46,6 @@ impl IWebAccountProviderOperation_Vtbl { match this.Kind() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -201,7 +200,6 @@ impl IWebAccountProviderTokenOperation_Vtbl { match this.CacheExpirationTime() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Security/Credentials/impl.rs b/crates/libs/windows/src/Windows/Security/Credentials/impl.rs index 7ed0699979..4280b8c658 100644 --- a/crates/libs/windows/src/Windows/Security/Credentials/impl.rs +++ b/crates/libs/windows/src/Windows/Security/Credentials/impl.rs @@ -39,7 +39,6 @@ impl IWebAccount_Vtbl { match this.State() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Storage/AccessCache/impl.rs b/crates/libs/windows/src/Windows/Storage/AccessCache/impl.rs index a8e480b60f..26e2fee460 100644 --- a/crates/libs/windows/src/Windows/Storage/AccessCache/impl.rs +++ b/crates/libs/windows/src/Windows/Storage/AccessCache/impl.rs @@ -142,7 +142,6 @@ impl IStorageItemAccessList_Vtbl { match this.ContainsItem(::core::mem::transmute(&token)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -159,7 +158,6 @@ impl IStorageItemAccessList_Vtbl { match this.CheckAccess(::windows_core::from_raw_borrowed(&file)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -183,7 +181,6 @@ impl IStorageItemAccessList_Vtbl { match this.MaximumItemsAllowed() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Storage/BulkAccess/impl.rs b/crates/libs/windows/src/Windows/Storage/BulkAccess/impl.rs index 8da6acae06..c695d23350 100644 --- a/crates/libs/windows/src/Windows/Storage/BulkAccess/impl.rs +++ b/crates/libs/windows/src/Windows/Storage/BulkAccess/impl.rs @@ -97,7 +97,6 @@ impl IStorageItemInformation_Vtbl { match this.ThumbnailUpdated(::windows_core::from_raw_borrowed(&changedhandler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -114,7 +113,6 @@ impl IStorageItemInformation_Vtbl { match this.PropertiesUpdated(::windows_core::from_raw_borrowed(&changedhandler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Storage/Provider/impl.rs b/crates/libs/windows/src/Windows/Storage/Provider/impl.rs index f9561548ca..9e62af03ba 100644 --- a/crates/libs/windows/src/Windows/Storage/Provider/impl.rs +++ b/crates/libs/windows/src/Windows/Storage/Provider/impl.rs @@ -46,7 +46,6 @@ impl IStorageProviderPropertyCapabilities_Vtbl { match this.IsPropertySupported(::core::mem::transmute(&propertycanonicalname)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -93,7 +92,6 @@ impl IStorageProviderStatusUISource_Vtbl { match this.StatusUIChanged(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -203,7 +201,6 @@ impl IStorageProviderUICommand_Vtbl { match this.State() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Storage/Search/impl.rs b/crates/libs/windows/src/Windows/Storage/Search/impl.rs index 25a46a4b68..4dfb242901 100644 --- a/crates/libs/windows/src/Windows/Storage/Search/impl.rs +++ b/crates/libs/windows/src/Windows/Storage/Search/impl.rs @@ -296,7 +296,6 @@ impl IStorageFolderQueryOperations_Vtbl { match this.AreQueryOptionsSupported(::windows_core::from_raw_borrowed(&queryoptions)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -308,7 +307,6 @@ impl IStorageFolderQueryOperations_Vtbl { match this.IsCommonFolderQuerySupported(query) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -320,7 +318,6 @@ impl IStorageFolderQueryOperations_Vtbl { match this.IsCommonFileQuerySupported(query) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -401,7 +398,6 @@ impl IStorageQueryResultBase_Vtbl { match this.ContentsChanged(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -418,7 +414,6 @@ impl IStorageQueryResultBase_Vtbl { match this.OptionsChanged(::windows_core::from_raw_borrowed(&changedhandler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Storage/Streams/impl.rs b/crates/libs/windows/src/Windows/Storage/Streams/impl.rs index 2e22045ab9..bf4d498f8b 100644 --- a/crates/libs/windows/src/Windows/Storage/Streams/impl.rs +++ b/crates/libs/windows/src/Windows/Storage/Streams/impl.rs @@ -15,7 +15,6 @@ impl IBuffer_Vtbl { match this.Capacity() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -27,7 +26,6 @@ impl IBuffer_Vtbl { match this.Length() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -119,7 +117,6 @@ impl IDataReader_Vtbl { match this.UnconsumedBufferLength() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -131,7 +128,6 @@ impl IDataReader_Vtbl { match this.UnicodeEncoding() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -148,7 +144,6 @@ impl IDataReader_Vtbl { match this.ByteOrder() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -165,7 +160,6 @@ impl IDataReader_Vtbl { match this.InputStreamOptions() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -182,7 +176,6 @@ impl IDataReader_Vtbl { match this.ReadByte() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -211,7 +204,6 @@ impl IDataReader_Vtbl { match this.ReadBoolean() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -223,7 +215,6 @@ impl IDataReader_Vtbl { match this.ReadGuid() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -235,7 +226,6 @@ impl IDataReader_Vtbl { match this.ReadInt16() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -247,7 +237,6 @@ impl IDataReader_Vtbl { match this.ReadInt32() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -259,7 +248,6 @@ impl IDataReader_Vtbl { match this.ReadInt64() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -271,7 +259,6 @@ impl IDataReader_Vtbl { match this.ReadUInt16() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -283,7 +270,6 @@ impl IDataReader_Vtbl { match this.ReadUInt32() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -295,7 +281,6 @@ impl IDataReader_Vtbl { match this.ReadUInt64() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -307,7 +292,6 @@ impl IDataReader_Vtbl { match this.ReadSingle() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -319,7 +303,6 @@ impl IDataReader_Vtbl { match this.ReadDouble() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -343,7 +326,6 @@ impl IDataReader_Vtbl { match this.ReadDateTime() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -355,7 +337,6 @@ impl IDataReader_Vtbl { match this.ReadTimeSpan() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -475,7 +456,6 @@ impl IDataWriter_Vtbl { match this.UnstoredBufferLength() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -487,7 +467,6 @@ impl IDataWriter_Vtbl { match this.UnicodeEncoding() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -504,7 +483,6 @@ impl IDataWriter_Vtbl { match this.ByteOrder() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -601,7 +579,6 @@ impl IDataWriter_Vtbl { match this.WriteString(::core::mem::transmute(&value)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -613,7 +590,6 @@ impl IDataWriter_Vtbl { match this.MeasureString(::core::mem::transmute(&value)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -878,7 +854,6 @@ impl IRandomAccessStream_Vtbl { match this.Size() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -919,7 +894,6 @@ impl IRandomAccessStream_Vtbl { match this.Position() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -948,7 +922,6 @@ impl IRandomAccessStream_Vtbl { match this.CanRead() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -960,7 +933,6 @@ impl IRandomAccessStream_Vtbl { match this.CanWrite() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Storage/impl.rs b/crates/libs/windows/src/Windows/Storage/impl.rs index e5cde58d51..2061bce074 100644 --- a/crates/libs/windows/src/Windows/Storage/impl.rs +++ b/crates/libs/windows/src/Windows/Storage/impl.rs @@ -247,7 +247,6 @@ impl IStorageFilePropertiesWithAvailability_Vtbl { match this.IsAvailable() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -565,7 +564,6 @@ impl IStorageItem_Vtbl { match this.Attributes() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -577,7 +575,6 @@ impl IStorageItem_Vtbl { match this.DateCreated() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -589,7 +586,6 @@ impl IStorageItem_Vtbl { match this.IsOfType(r#type) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -644,7 +640,6 @@ impl IStorageItem2_Vtbl { match this.IsEqual(::windows_core::from_raw_borrowed(&item)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/System/Implementation/FileExplorer/impl.rs b/crates/libs/windows/src/Windows/System/Implementation/FileExplorer/impl.rs index 16762efb61..a9fbf2e199 100644 --- a/crates/libs/windows/src/Windows/System/Implementation/FileExplorer/impl.rs +++ b/crates/libs/windows/src/Windows/System/Implementation/FileExplorer/impl.rs @@ -17,7 +17,6 @@ impl ISysStorageProviderEventSource_Vtbl { match this.EventReceived(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/System/RemoteDesktop/Input/mod.rs b/crates/libs/windows/src/Windows/System/RemoteDesktop/Input/mod.rs index cb3a1088a9..a7906e7c8e 100644 --- a/crates/libs/windows/src/Windows/System/RemoteDesktop/Input/mod.rs +++ b/crates/libs/windows/src/Windows/System/RemoteDesktop/Input/mod.rs @@ -174,7 +174,6 @@ impl ::windows_core::Result + ::core::marker::Send + 's match ((*this).invoke)(::core::slice::from_raw_parts(::core::mem::transmute_copy(&pdudata), pduData_array_size as _)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/System/impl.rs b/crates/libs/windows/src/Windows/System/impl.rs index 1574318684..a434710e10 100644 --- a/crates/libs/windows/src/Windows/System/impl.rs +++ b/crates/libs/windows/src/Windows/System/impl.rs @@ -17,7 +17,6 @@ impl ILauncherViewOptions_Vtbl { match this.DesiredRemainingView() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/UI/Core/AnimationMetrics/impl.rs b/crates/libs/windows/src/Windows/UI/Core/AnimationMetrics/impl.rs index a3607cd99b..8adb66308e 100644 --- a/crates/libs/windows/src/Windows/UI/Core/AnimationMetrics/impl.rs +++ b/crates/libs/windows/src/Windows/UI/Core/AnimationMetrics/impl.rs @@ -20,7 +20,6 @@ impl IPropertyAnimation_Vtbl { match this.Type() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -32,7 +31,6 @@ impl IPropertyAnimation_Vtbl { match this.Delay() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -44,7 +42,6 @@ impl IPropertyAnimation_Vtbl { match this.Duration() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -56,7 +53,6 @@ impl IPropertyAnimation_Vtbl { match this.Control1() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -68,7 +64,6 @@ impl IPropertyAnimation_Vtbl { match this.Control2() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/UI/Core/impl.rs b/crates/libs/windows/src/Windows/UI/Core/impl.rs index 418a44ecd6..60fe869964 100644 --- a/crates/libs/windows/src/Windows/UI/Core/impl.rs +++ b/crates/libs/windows/src/Windows/UI/Core/impl.rs @@ -17,7 +17,6 @@ impl ICoreAcceleratorKeys_Vtbl { match this.AcceleratorKeyActivated(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -72,7 +71,6 @@ impl ICoreInputSourceBase_Vtbl { match this.IsInputEnabled() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -89,7 +87,6 @@ impl ICoreInputSourceBase_Vtbl { match this.InputEnabled(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -160,7 +157,6 @@ impl ICorePointerInputSource_Vtbl { match this.HasCapture() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -172,7 +168,6 @@ impl ICorePointerInputSource_Vtbl { match this.PointerPosition() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -201,7 +196,6 @@ impl ICorePointerInputSource_Vtbl { match this.PointerCaptureLost(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -218,7 +212,6 @@ impl ICorePointerInputSource_Vtbl { match this.PointerEntered(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -235,7 +228,6 @@ impl ICorePointerInputSource_Vtbl { match this.PointerExited(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -252,7 +244,6 @@ impl ICorePointerInputSource_Vtbl { match this.PointerMoved(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -269,7 +260,6 @@ impl ICorePointerInputSource_Vtbl { match this.PointerPressed(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -286,7 +276,6 @@ impl ICorePointerInputSource_Vtbl { match this.PointerReleased(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -303,7 +292,6 @@ impl ICorePointerInputSource_Vtbl { match this.PointerWheelChanged(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -398,7 +386,6 @@ impl ICorePointerRedirector_Vtbl { match this.PointerRoutedAway(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -415,7 +402,6 @@ impl ICorePointerRedirector_Vtbl { match this.PointerRoutedTo(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -432,7 +418,6 @@ impl ICorePointerRedirector_Vtbl { match this.PointerRoutedReleased(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -538,7 +523,6 @@ impl ICoreWindow_Vtbl { match this.Bounds() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -574,7 +558,6 @@ impl ICoreWindow_Vtbl { match this.FlowDirection() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -591,7 +574,6 @@ impl ICoreWindow_Vtbl { match this.IsInputEnabled() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -625,7 +607,6 @@ impl ICoreWindow_Vtbl { match this.PointerPosition() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -637,7 +618,6 @@ impl ICoreWindow_Vtbl { match this.Visible() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -659,7 +639,6 @@ impl ICoreWindow_Vtbl { match this.GetAsyncKeyState(virtualkey) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -671,7 +650,6 @@ impl ICoreWindow_Vtbl { match this.GetKeyState(virtualkey) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -693,7 +671,6 @@ impl ICoreWindow_Vtbl { match this.Activated(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -710,7 +687,6 @@ impl ICoreWindow_Vtbl { match this.AutomationProviderRequested(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -727,7 +703,6 @@ impl ICoreWindow_Vtbl { match this.CharacterReceived(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -744,7 +719,6 @@ impl ICoreWindow_Vtbl { match this.Closed(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -761,7 +735,6 @@ impl ICoreWindow_Vtbl { match this.InputEnabled(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -778,7 +751,6 @@ impl ICoreWindow_Vtbl { match this.KeyDown(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -795,7 +767,6 @@ impl ICoreWindow_Vtbl { match this.KeyUp(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -812,7 +783,6 @@ impl ICoreWindow_Vtbl { match this.PointerCaptureLost(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -829,7 +799,6 @@ impl ICoreWindow_Vtbl { match this.PointerEntered(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -846,7 +815,6 @@ impl ICoreWindow_Vtbl { match this.PointerExited(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -863,7 +831,6 @@ impl ICoreWindow_Vtbl { match this.PointerMoved(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -880,7 +847,6 @@ impl ICoreWindow_Vtbl { match this.PointerPressed(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -897,7 +863,6 @@ impl ICoreWindow_Vtbl { match this.PointerReleased(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -914,7 +879,6 @@ impl ICoreWindow_Vtbl { match this.TouchHitTesting(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -931,7 +895,6 @@ impl ICoreWindow_Vtbl { match this.PointerWheelChanged(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -948,7 +911,6 @@ impl ICoreWindow_Vtbl { match this.SizeChanged(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -965,7 +927,6 @@ impl ICoreWindow_Vtbl { match this.VisibilityChanged(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1052,7 +1013,6 @@ impl ICoreWindowEventArgs_Vtbl { match this.Handled() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/UI/Input/Inking/Analysis/impl.rs b/crates/libs/windows/src/Windows/UI/Input/Inking/Analysis/impl.rs index ca2baf1ae1..7a91abfeb9 100644 --- a/crates/libs/windows/src/Windows/UI/Input/Inking/Analysis/impl.rs +++ b/crates/libs/windows/src/Windows/UI/Input/Inking/Analysis/impl.rs @@ -22,7 +22,6 @@ impl IInkAnalysisNode_Vtbl { match this.Id() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -34,7 +33,6 @@ impl IInkAnalysisNode_Vtbl { match this.Kind() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -46,7 +44,6 @@ impl IInkAnalysisNode_Vtbl { match this.BoundingRect() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/UI/Input/Inking/impl.rs b/crates/libs/windows/src/Windows/UI/Input/Inking/impl.rs index bd8b76cc54..84849fea7e 100644 --- a/crates/libs/windows/src/Windows/UI/Input/Inking/impl.rs +++ b/crates/libs/windows/src/Windows/UI/Input/Inking/impl.rs @@ -81,7 +81,6 @@ impl IInkPresenterStencil_Vtbl { match this.Kind() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -93,7 +92,6 @@ impl IInkPresenterStencil_Vtbl { match this.IsVisible() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -110,7 +108,6 @@ impl IInkPresenterStencil_Vtbl { match this.BackgroundColor() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -127,7 +124,6 @@ impl IInkPresenterStencil_Vtbl { match this.ForegroundColor() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -144,7 +140,6 @@ impl IInkPresenterStencil_Vtbl { match this.Transform() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -257,7 +252,6 @@ impl IInkStrokeContainer_Vtbl { match this.BoundingRect() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -274,7 +268,6 @@ impl IInkStrokeContainer_Vtbl { match this.DeleteSelected() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -286,7 +279,6 @@ impl IInkStrokeContainer_Vtbl { match this.MoveSelected(::core::mem::transmute(&translation)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -298,7 +290,6 @@ impl IInkStrokeContainer_Vtbl { match this.SelectWithPolyLine(::windows_core::from_raw_borrowed(&polyline)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -310,7 +301,6 @@ impl IInkStrokeContainer_Vtbl { match this.SelectWithLine(::core::mem::transmute(&from), ::core::mem::transmute(&to)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -327,7 +317,6 @@ impl IInkStrokeContainer_Vtbl { match this.PasteFromClipboard(::core::mem::transmute(&position)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -339,7 +328,6 @@ impl IInkStrokeContainer_Vtbl { match this.CanPasteFromClipboard() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/UI/Input/impl.rs b/crates/libs/windows/src/Windows/UI/Input/impl.rs index 73712843a5..608bd8d811 100644 --- a/crates/libs/windows/src/Windows/UI/Input/impl.rs +++ b/crates/libs/windows/src/Windows/UI/Input/impl.rs @@ -30,7 +30,6 @@ impl IPointerPointTransform_Vtbl { match this.TryTransform(::core::mem::transmute(&inpoint), ::core::mem::transmute_copy(&outpoint)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -42,7 +41,6 @@ impl IPointerPointTransform_Vtbl { match this.TransformBounds(::core::mem::transmute(&rect)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/UI/Notifications/impl.rs b/crates/libs/windows/src/Windows/UI/Notifications/impl.rs index 8911b975f4..7be9706601 100644 --- a/crates/libs/windows/src/Windows/UI/Notifications/impl.rs +++ b/crates/libs/windows/src/Windows/UI/Notifications/impl.rs @@ -17,7 +17,6 @@ impl IAdaptiveNotificationContent_Vtbl { match this.Kind() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/UI/Text/impl.rs b/crates/libs/windows/src/Windows/UI/Text/impl.rs index a97c06a9d3..3597d0a456 100644 --- a/crates/libs/windows/src/Windows/UI/Text/impl.rs +++ b/crates/libs/windows/src/Windows/UI/Text/impl.rs @@ -62,7 +62,6 @@ impl ITextCharacterFormat_Vtbl { match this.AllCaps() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -79,7 +78,6 @@ impl ITextCharacterFormat_Vtbl { match this.BackgroundColor() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -96,7 +94,6 @@ impl ITextCharacterFormat_Vtbl { match this.Bold() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -113,7 +110,6 @@ impl ITextCharacterFormat_Vtbl { match this.FontStretch() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -130,7 +126,6 @@ impl ITextCharacterFormat_Vtbl { match this.FontStyle() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -147,7 +142,6 @@ impl ITextCharacterFormat_Vtbl { match this.ForegroundColor() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -164,7 +158,6 @@ impl ITextCharacterFormat_Vtbl { match this.Hidden() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -181,7 +174,6 @@ impl ITextCharacterFormat_Vtbl { match this.Italic() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -198,7 +190,6 @@ impl ITextCharacterFormat_Vtbl { match this.Kerning() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -232,7 +223,6 @@ impl ITextCharacterFormat_Vtbl { match this.LinkType() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -261,7 +251,6 @@ impl ITextCharacterFormat_Vtbl { match this.Outline() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -278,7 +267,6 @@ impl ITextCharacterFormat_Vtbl { match this.Position() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -295,7 +283,6 @@ impl ITextCharacterFormat_Vtbl { match this.ProtectedText() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -312,7 +299,6 @@ impl ITextCharacterFormat_Vtbl { match this.Size() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -329,7 +315,6 @@ impl ITextCharacterFormat_Vtbl { match this.SmallCaps() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -346,7 +331,6 @@ impl ITextCharacterFormat_Vtbl { match this.Spacing() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -363,7 +347,6 @@ impl ITextCharacterFormat_Vtbl { match this.Strikethrough() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -380,7 +363,6 @@ impl ITextCharacterFormat_Vtbl { match this.Subscript() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -397,7 +379,6 @@ impl ITextCharacterFormat_Vtbl { match this.Superscript() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -414,7 +395,6 @@ impl ITextCharacterFormat_Vtbl { match this.TextScript() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -431,7 +411,6 @@ impl ITextCharacterFormat_Vtbl { match this.Underline() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -448,7 +427,6 @@ impl ITextCharacterFormat_Vtbl { match this.Weight() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -482,7 +460,6 @@ impl ITextCharacterFormat_Vtbl { match this.IsEqual(::windows_core::from_raw_borrowed(&format)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -590,7 +567,6 @@ impl ITextDocument_Vtbl { match this.CaretType() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -607,7 +583,6 @@ impl ITextDocument_Vtbl { match this.DefaultTabStop() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -636,7 +611,6 @@ impl ITextDocument_Vtbl { match this.UndoLimit() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -653,7 +627,6 @@ impl ITextDocument_Vtbl { match this.CanCopy() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -665,7 +638,6 @@ impl ITextDocument_Vtbl { match this.CanPaste() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -677,7 +649,6 @@ impl ITextDocument_Vtbl { match this.CanRedo() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -689,7 +660,6 @@ impl ITextDocument_Vtbl { match this.CanUndo() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -701,7 +671,6 @@ impl ITextDocument_Vtbl { match this.ApplyDisplayUpdates() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -713,7 +682,6 @@ impl ITextDocument_Vtbl { match this.BatchDisplayUpdates() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -914,7 +882,6 @@ impl ITextParagraphFormat_Vtbl { match this.Alignment() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -931,7 +898,6 @@ impl ITextParagraphFormat_Vtbl { match this.FirstLineIndent() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -943,7 +909,6 @@ impl ITextParagraphFormat_Vtbl { match this.KeepTogether() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -960,7 +925,6 @@ impl ITextParagraphFormat_Vtbl { match this.KeepWithNext() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -977,7 +941,6 @@ impl ITextParagraphFormat_Vtbl { match this.LeftIndent() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -989,7 +952,6 @@ impl ITextParagraphFormat_Vtbl { match this.LineSpacing() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1001,7 +963,6 @@ impl ITextParagraphFormat_Vtbl { match this.LineSpacingRule() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1013,7 +974,6 @@ impl ITextParagraphFormat_Vtbl { match this.ListAlignment() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1030,7 +990,6 @@ impl ITextParagraphFormat_Vtbl { match this.ListLevelIndex() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1047,7 +1006,6 @@ impl ITextParagraphFormat_Vtbl { match this.ListStart() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1064,7 +1022,6 @@ impl ITextParagraphFormat_Vtbl { match this.ListStyle() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1081,7 +1038,6 @@ impl ITextParagraphFormat_Vtbl { match this.ListTab() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1098,7 +1054,6 @@ impl ITextParagraphFormat_Vtbl { match this.ListType() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1115,7 +1070,6 @@ impl ITextParagraphFormat_Vtbl { match this.NoLineNumber() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1132,7 +1086,6 @@ impl ITextParagraphFormat_Vtbl { match this.PageBreakBefore() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1149,7 +1102,6 @@ impl ITextParagraphFormat_Vtbl { match this.RightIndent() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1166,7 +1118,6 @@ impl ITextParagraphFormat_Vtbl { match this.RightToLeft() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1183,7 +1134,6 @@ impl ITextParagraphFormat_Vtbl { match this.Style() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1200,7 +1150,6 @@ impl ITextParagraphFormat_Vtbl { match this.SpaceAfter() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1217,7 +1166,6 @@ impl ITextParagraphFormat_Vtbl { match this.SpaceBefore() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1234,7 +1182,6 @@ impl ITextParagraphFormat_Vtbl { match this.WidowControl() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1251,7 +1198,6 @@ impl ITextParagraphFormat_Vtbl { match this.TabCount() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1295,7 +1241,6 @@ impl ITextParagraphFormat_Vtbl { match this.IsEqual(::windows_core::from_raw_borrowed(&format)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1441,7 +1386,6 @@ impl ITextRange_Vtbl { match this.Character() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1492,7 +1436,6 @@ impl ITextRange_Vtbl { match this.EndPosition() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1509,7 +1452,6 @@ impl ITextRange_Vtbl { match this.Gravity() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1526,7 +1468,6 @@ impl ITextRange_Vtbl { match this.Length() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1572,7 +1513,6 @@ impl ITextRange_Vtbl { match this.StartPosition() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1589,7 +1529,6 @@ impl ITextRange_Vtbl { match this.StoryLength() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1618,7 +1557,6 @@ impl ITextRange_Vtbl { match this.CanPaste(format) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1650,7 +1588,6 @@ impl ITextRange_Vtbl { match this.Delete(unit, count) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1662,7 +1599,6 @@ impl ITextRange_Vtbl { match this.EndOf(unit, extend) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1674,7 +1610,6 @@ impl ITextRange_Vtbl { match this.Expand(unit) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1686,7 +1621,6 @@ impl ITextRange_Vtbl { match this.FindText(::core::mem::transmute(&value), scanlength, options) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1715,7 +1649,6 @@ impl ITextRange_Vtbl { match this.GetIndex(unit) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1747,7 +1680,6 @@ impl ITextRange_Vtbl { match this.InRange(::windows_core::from_raw_borrowed(&range)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1764,7 +1696,6 @@ impl ITextRange_Vtbl { match this.InStory(::windows_core::from_raw_borrowed(&range)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1776,7 +1707,6 @@ impl ITextRange_Vtbl { match this.IsEqual(::windows_core::from_raw_borrowed(&range)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1788,7 +1718,6 @@ impl ITextRange_Vtbl { match this.Move(unit, count) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1800,7 +1729,6 @@ impl ITextRange_Vtbl { match this.MoveEnd(unit, count) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1812,7 +1740,6 @@ impl ITextRange_Vtbl { match this.MoveStart(unit, count) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1864,7 +1791,6 @@ impl ITextRange_Vtbl { match this.StartOf(unit, extend) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1957,7 +1883,6 @@ impl ITextSelection_Vtbl { match this.Options() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1974,7 +1899,6 @@ impl ITextSelection_Vtbl { match this.Type() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1986,7 +1910,6 @@ impl ITextSelection_Vtbl { match this.EndKey(unit, extend) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -1998,7 +1921,6 @@ impl ITextSelection_Vtbl { match this.HomeKey(unit, extend) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -2010,7 +1932,6 @@ impl ITextSelection_Vtbl { match this.MoveDown(unit, count, extend) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -2022,7 +1943,6 @@ impl ITextSelection_Vtbl { match this.MoveLeft(unit, count, extend) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -2034,7 +1954,6 @@ impl ITextSelection_Vtbl { match this.MoveRight(unit, count, extend) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -2046,7 +1965,6 @@ impl ITextSelection_Vtbl { match this.MoveUp(unit, count, extend) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/UI/UIAutomation/Core/impl.rs b/crates/libs/windows/src/Windows/UI/UIAutomation/Core/impl.rs index c7720ff789..32d9a08219 100644 --- a/crates/libs/windows/src/Windows/UI/UIAutomation/Core/impl.rs +++ b/crates/libs/windows/src/Windows/UI/UIAutomation/Core/impl.rs @@ -13,7 +13,6 @@ impl ICoreAutomationConnectionBoundObjectProvider_Vtbl { match this.IsComThreadingRequired() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -49,7 +48,6 @@ impl ICoreAutomationRemoteOperationExtensionProvider_Vtbl { match this.IsExtensionSupported(::core::mem::transmute(&extensionid)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/UI/WebUI/impl.rs b/crates/libs/windows/src/Windows/UI/WebUI/impl.rs index 5fab1c332c..a782d37267 100644 --- a/crates/libs/windows/src/Windows/UI/WebUI/impl.rs +++ b/crates/libs/windows/src/Windows/UI/WebUI/impl.rs @@ -44,7 +44,6 @@ impl IWebUIBackgroundTaskInstance_Vtbl { match this.Succeeded() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Web/Http/impl.rs b/crates/libs/windows/src/Windows/Web/Http/impl.rs index c7a2a3e892..bff49740a2 100644 --- a/crates/libs/windows/src/Windows/Web/Http/impl.rs +++ b/crates/libs/windows/src/Windows/Web/Http/impl.rs @@ -82,7 +82,6 @@ impl IHttpContent_Vtbl { match this.TryComputeLength(::core::mem::transmute_copy(&length)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Web/Syndication/impl.rs b/crates/libs/windows/src/Windows/Web/Syndication/impl.rs index 97a3d5a3a5..f827ea9eaf 100644 --- a/crates/libs/windows/src/Windows/Web/Syndication/impl.rs +++ b/crates/libs/windows/src/Windows/Web/Syndication/impl.rs @@ -61,7 +61,6 @@ impl ISyndicationClient_Vtbl { match this.MaxResponseBufferSize() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -78,7 +77,6 @@ impl ISyndicationClient_Vtbl { match this.Timeout() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -95,7 +93,6 @@ impl ISyndicationClient_Vtbl { match this.BypassCacheOnRetrieve() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/libs/windows/src/Windows/Web/UI/impl.rs b/crates/libs/windows/src/Windows/Web/UI/impl.rs index d1511b3a26..2206d4db68 100644 --- a/crates/libs/windows/src/Windows/Web/UI/impl.rs +++ b/crates/libs/windows/src/Windows/Web/UI/impl.rs @@ -101,7 +101,6 @@ impl IWebViewControl_Vtbl { match this.CanGoBack() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -113,7 +112,6 @@ impl IWebViewControl_Vtbl { match this.CanGoForward() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -130,7 +128,6 @@ impl IWebViewControl_Vtbl { match this.DefaultBackgroundColor() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -142,7 +139,6 @@ impl IWebViewControl_Vtbl { match this.ContainsFullScreenElement() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -271,7 +267,6 @@ impl IWebViewControl_Vtbl { match this.NavigationStarting(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -288,7 +283,6 @@ impl IWebViewControl_Vtbl { match this.ContentLoading(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -305,7 +299,6 @@ impl IWebViewControl_Vtbl { match this.DOMContentLoaded(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -322,7 +315,6 @@ impl IWebViewControl_Vtbl { match this.NavigationCompleted(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -339,7 +331,6 @@ impl IWebViewControl_Vtbl { match this.FrameNavigationStarting(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -356,7 +347,6 @@ impl IWebViewControl_Vtbl { match this.FrameContentLoading(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -373,7 +363,6 @@ impl IWebViewControl_Vtbl { match this.FrameDOMContentLoaded(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -390,7 +379,6 @@ impl IWebViewControl_Vtbl { match this.FrameNavigationCompleted(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -407,7 +395,6 @@ impl IWebViewControl_Vtbl { match this.ScriptNotify(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -424,7 +411,6 @@ impl IWebViewControl_Vtbl { match this.LongRunningScriptDetected(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -441,7 +427,6 @@ impl IWebViewControl_Vtbl { match this.UnsafeContentWarningDisplaying(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -458,7 +443,6 @@ impl IWebViewControl_Vtbl { match this.UnviewableContentIdentified(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -475,7 +459,6 @@ impl IWebViewControl_Vtbl { match this.PermissionRequested(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -492,7 +475,6 @@ impl IWebViewControl_Vtbl { match this.UnsupportedUriSchemeIdentified(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -509,7 +491,6 @@ impl IWebViewControl_Vtbl { match this.NewWindowRequested(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -526,7 +507,6 @@ impl IWebViewControl_Vtbl { match this.ContainsFullScreenElementChanged(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -543,7 +523,6 @@ impl IWebViewControl_Vtbl { match this.WebResourceRequested(::windows_core::from_raw_borrowed(&handler)) { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/tests/component/src/bindings.rs b/crates/tests/component/src/bindings.rs index 808a9203e1..c016ffd05d 100644 --- a/crates/tests/component/src/bindings.rs +++ b/crates/tests/component/src/bindings.rs @@ -325,7 +325,6 @@ impl IClass_Vtbl { match this.Property() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -356,7 +355,6 @@ impl IClass_Vtbl { match this.Flags() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/tests/component_client/src/bindings.rs b/crates/tests/component_client/src/bindings.rs index 808a9203e1..c016ffd05d 100644 --- a/crates/tests/component_client/src/bindings.rs +++ b/crates/tests/component_client/src/bindings.rs @@ -325,7 +325,6 @@ impl IClass_Vtbl { match this.Property() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), @@ -356,7 +355,6 @@ impl IClass_Vtbl { match this.Flags() { ::core::result::Result::Ok(ok__) => { ::core::ptr::write(result__, ::core::mem::transmute_copy(&ok__)); - ::core::mem::forget(ok__); ::windows_core::HRESULT(0) } ::core::result::Result::Err(err) => err.into(), diff --git a/crates/tools/metadata/Cargo.toml b/crates/tools/metadata/Cargo.toml new file mode 100644 index 0000000000..ad500b243d --- /dev/null +++ b/crates/tools/metadata/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "tool_metadata" +version = "0.0.0" +edition = "2018" +publish = false + +[dependencies.windows-bindgen] +path = "../../libs/bindgen" diff --git a/crates/tools/metadata/src/main.rs b/crates/tools/metadata/src/main.rs new file mode 100644 index 0000000000..47b481f92d --- /dev/null +++ b/crates/tools/metadata/src/main.rs @@ -0,0 +1,54 @@ +fn main() { + let bindings = [ + "Windows.Win32.System.Diagnostics.Debug.IMAGE_COR20_HEADER", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_DLLCHARACTERISTICS_NO_SEH", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_DLLCHARACTERISTICS_NX_COMPAT", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_FILE_32BIT_MACHINE", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_FILE_DLL", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_FILE_EXECUTABLE_IMAGE", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_FILE_HEADER", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_NT_OPTIONAL_HDR32_MAGIC", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_NT_OPTIONAL_HDR64_MAGIC", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_OPTIONAL_HEADER32", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_OPTIONAL_HEADER64", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_SECTION_HEADER", + "Windows.Win32.System.Diagnostics.Debug.IMAGE_SUBSYSTEM_WINDOWS_CUI", + "Windows.Win32.System.SystemInformation.IMAGE_FILE_MACHINE_I386", + "Windows.Win32.System.SystemServices.IMAGE_DOS_HEADER", + "Windows.Win32.System.SystemServices.IMAGE_DOS_SIGNATURE", + "Windows.Win32.System.SystemServices.IMAGE_NT_SIGNATURE", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_ARRAY", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_BOOLEAN", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_BYREF", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_CHAR", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_CLASS", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_CMOD_OPT", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_CMOD_REQD", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_GENERICINST", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_I", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_I1", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_I2", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_I4", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_I8", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_OBJECT", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_PTR", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_R4", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_R8", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_STRING", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_SZARRAY", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_U", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_U1", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_U2", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_U4", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_U8", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_VALUETYPE", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_VALUETYPE", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_VAR", + "Windows.Win32.System.WinRT.Metadata.ELEMENT_TYPE_VOID", + ]; + + let bindings = windows_bindgen::standalone_sys(&bindings); + std::fs::write("crates/libs/metadata/src/bindings.rs", bindings).unwrap(); +} diff --git a/crates/tools/riddle/src/main.rs b/crates/tools/riddle/src/main.rs index 86c0dab2b6..362848c4f8 100644 --- a/crates/tools/riddle/src/main.rs +++ b/crates/tools/riddle/src/main.rs @@ -1,102 +1,148 @@ -mod syntax; -use metadata::writer; -use std::io::Read; -use syn::*; -use syntax::*; +use metadata::*; + +enum ArgKind { + None, + Input, + Output, + Filter, +} fn main() { - if let Err(message) = run() { - eprintln!("error: {message}"); + if let Err(error) = run() { + eprintln!("{}", error); std::process::exit(1); } } -type ToolResult = std::result::Result<(), String>; +fn run() -> Result<()> { + let time = std::time::Instant::now(); + let args: Vec<_> = std::env::args().skip(1).collect(); + + if args.is_empty() { + println!( + r#"Usage: riddle.exe [options...] + +Options: + -in Path to files and directories containing .winmd and .idl files + -out Path to .winmd or .idl file to generate + -filter Namespaces to include or !exclude in output + -format Format .idl files only + -verbose Show detailed information +"# + ); + return Ok(()); + } -fn run() -> ToolResult { let mut kind = ArgKind::None; - let mut merge = Vec::::new(); - let mut input = Vec::::new(); - let mut reference = Vec::::new(); - let mut output = String::new(); - let mut winrt = true; + let mut output = None; + let mut input = Vec::<&str>::new(); + let mut include = Vec::<&str>::new(); + let mut exclude = Vec::<&str>::new(); + let mut format = false; + let mut verbose = false; - for arg in std::env::args().skip(1) { + for arg in &args { if arg.starts_with('-') { kind = ArgKind::None; } + match kind { ArgKind::None => match arg.as_str() { - "-merge" => kind = ArgKind::Merge, - "-input" => kind = ArgKind::Input, - "-ref" => kind = ArgKind::Reference, - "-output" => kind = ArgKind::Output, - "-win32" => { - winrt = false; - kind = ArgKind::None; - } - _ => print_help()?, + "-in" => kind = ArgKind::Input, + "-out" => kind = ArgKind::Output, + "-filter" => kind = ArgKind::Filter, + "-format" => format = true, + "-verbose" => verbose = true, + _ => return Err(Error::new(&format!("invalid option: `{arg}`"))), }, - ArgKind::Merge => merge.push(arg), - ArgKind::Input => input.push(arg), - ArgKind::Reference => reference.push(arg), ArgKind::Output => { - if output.is_empty() { - output = arg; + if output.is_none() { + output = Some(arg.as_str()); } else { - print_help()?; + return Err(Error::new("too many outputs")); } } + ArgKind::Input => input.push(arg.as_str()), + ArgKind::Filter => { + if let Some(rest) = arg.strip_prefix('!') { + exclude.push(rest); + } else { + include.push(arg.as_str()); + } + } + } + } + + if format { + if output.is_some() || !include.is_empty() || !exclude.is_empty() { + return Err(Error::new("-format cannot be combined with -output, -include, or -exclude")); + } + + let input = filter_input(input, &["idl"])?; + + if input.is_empty() { + return Err(Error::new("no .idl inputs")); } + + for path in &input { + let source = read_to_string(path)?; + write_to_file(path, writer::format_idl(&source).map_err(|error| error.with_path(path))?)?; + } + + return Ok(()); } - if merge.len() + input.len() == 0 || output.is_empty() { - print_help()?; + let input = filter_input(input, &["winmd", "idl"])?; + + if input.is_empty() { + return Err(Error::new("no inputs")); } - let mut items = Vec::new(); + let Some(output) = output else { + return Err(Error::new("no output")); + }; - // for merge in merge { - // // TODO: write the types in the winmd into `items` - // } + let filter = reader::Filter::new(&include, &exclude); + let module = writer::Module::read(&input, &filter)?; - for filename in &input { - let mut file = std::fs::File::open(filename).map_err(|_| format!("failed to open `{filename}`"))?; - let mut source = String::new(); - file.read_to_string(&mut source).map_err(|_| format!("failed to read `{filename}`"))?; + //dbg!(&module); - if let Err(error) = parse_str::(&source).and_then(|module| module.to_writer(module.name.to_string(), &mut items)) { - let start = error.span().start(); - let filename = std::fs::canonicalize(filename).map_err(|_| format!("failed to canonicalize `{filename}`"))?; - return Err(format!("{error}\n --> {}:{:?}:{:?} ", filename.to_string_lossy().trim_start_matches(r#"\\?\"#), start.line, start.column)); - } + module.write(output)?; + + if verbose { + println!(" Finished writing `{}` in {:.2}s", canonicalize(output)?, time.elapsed().as_secs_f32()); } - let buffer = writer::write("test", winrt, &items, &[]); - std::fs::write(&output, buffer).map_err(|_| format!("failed to write `{output}`")) + Ok(()) } -fn print_help() -> ToolResult { - Err(r#"riddle.exe [options...] +fn filter_input(input: Vec<&str>, filter: &[&str]) -> Result> { + fn try_push(path: &str, filter: &[&str], results: &mut Vec) -> Result<()> { + let path = canonicalize(path)?; -options: - -input Path to source file with type definitions to parse - -merge Path to file or directory containing .winmd files to merge - -ref Path to file or directory containing .winmd files to reference - -output Path to .winmd file to generate - -win32 Kind of .winmd to generate; default is WinRT + if filter.contains(&extension(&path).1) { + results.push(path); + } -examples: - riddle -input first.rs second.rs -output out.winmd -ref local - riddle -merge first.winmd second.winmd -output out.winmd -"# - .to_string()) -} + Ok(()) + } -enum ArgKind { - None, - Merge, - Input, - Reference, - Output, + let mut results = vec![]; + + for input in &input { + let path = std::path::Path::new(input); + + if path.is_dir() { + for entry in path.read_dir().map_err(|_| Error::new("failed to read directory").with_path(input))?.flatten() { + let path = entry.path(); + + if path.is_file() { + try_push(&path.to_string_lossy(), filter, &mut results)?; + } + } + } else { + try_push(&path.to_string_lossy(), filter, &mut results)?; + } + } + Ok(results) } diff --git a/crates/tools/riddle/src/syntax.rs b/crates/tools/riddle/src/syntax.rs deleted file mode 100644 index a773f58008..0000000000 --- a/crates/tools/riddle/src/syntax.rs +++ /dev/null @@ -1,184 +0,0 @@ -use metadata::writer; -use syn::{parse::*, spanned::*, *}; - -mod keywords { - syn::custom_keyword!(interface); -} - -pub trait ToWriter { - fn to_writer(&self, namespace: String, items: &mut Vec) -> Result<()>; -} - -pub struct Module { - pub name: Ident, - pub members: Vec, -} - -impl Parse for Module { - fn parse(input: ParseStream) -> Result { - input.parse::()?; - let name = input.parse::()?; - let content; - braced!(content in input); - let mut members = vec![]; - while !content.is_empty() { - members.push(content.parse::()?); - } - Ok(Self { name, members }) - } -} - -impl ToWriter for Module { - fn to_writer(&self, namespace: String, items: &mut Vec) -> Result<()> { - for member in &self.members { - match member { - ModuleMember::Module(member) => member.to_writer(format!("{namespace}.{}", member.name), items)?, - ModuleMember::Interface(member) => member.to_writer(namespace.clone(), items)?, - ModuleMember::Struct(member) => member.to_writer(namespace.clone(), items)?, - ModuleMember::Enum(member) => member.to_writer(namespace.clone(), items)?, - } - } - Ok(()) - } -} - -pub enum ModuleMember { - Module(Module), - Interface(Interface), - Struct(ItemStruct), - Enum(ItemEnum), -} - -impl Parse for ModuleMember { - fn parse(input: ParseStream) -> Result { - let lookahead = input.lookahead1(); - if lookahead.peek(Token![mod]) { - Ok(ModuleMember::Module(input.parse()?)) - } else if lookahead.peek(keywords::interface) { - Ok(ModuleMember::Interface(input.parse()?)) - } else if lookahead.peek(Token![struct]) { - Ok(ModuleMember::Struct(input.parse()?)) - } else if lookahead.peek(Token![enum]) { - Ok(ModuleMember::Enum(input.parse()?)) - } else { - Err(lookahead.error()) - } - } -} - -pub struct Interface { - pub name: Ident, - pub methods: Vec, -} - -impl Parse for Interface { - fn parse(input: ParseStream) -> Result { - input.parse::()?; - let name = input.parse::()?; - let content; - braced!(content in input); - let mut methods = vec![]; - while !content.is_empty() { - methods.push(content.parse::()?); - } - Ok(Self { name, methods }) - } -} - -impl ToWriter for Interface { - fn to_writer(&self, namespace: String, items: &mut Vec) -> Result<()> { - let mut methods = vec![]; - - for method in &self.methods { - methods.push(writer::Method { name: method.sig.ident.to_string(), return_type: writer::Type::Void, params: vec![] }); - } - - items.push(writer::Item::Interface(writer::Interface { namespace, name: self.name.to_string(), methods })); - Ok(()) - } -} - -impl ToWriter for ItemStruct { - fn to_writer(&self, namespace: String, items: &mut Vec) -> Result<()> { - let mut fields = vec![]; - - let Fields::Named(named) = &self.fields else { - return Err(Error::new(self.fields.span(), "expected named fields")); - }; - - for field in &named.named { - fields.push(writer::Field { name: field.ident.as_ref().unwrap().to_string(), ty: type_to_type(&field.ty)? }); - } - - items.push(writer::Item::Struct(writer::Struct { namespace, name: self.ident.to_string(), fields })); - Ok(()) - } -} - -impl ToWriter for ItemEnum { - fn to_writer(&self, namespace: String, items: &mut Vec) -> Result<()> { - let mut constants = vec![]; - let mut value = 0; - - // TODO: need to read the `#[repr(u8)]` attribute infer the underlying type - - for variant in &self.variants { - if let Some((_, discriminant)) = &variant.discriminant { - let Expr::Lit(discriminant) = discriminant else { - return Err(Error::new(discriminant.span(), "expected literal discriminant")); - }; - - let Lit::Int(discriminant) = &discriminant.lit else { - return Err(Error::new(discriminant.lit.span(), "expected integer discriminant")); - }; - - value = discriminant.base10_parse()?; - } - - constants.push(writer::Constant { name: variant.ident.to_string(), value: writer::Value::I32(value) }); - value += 1; - } - - items.push(writer::Item::Enum(writer::Enum { namespace, name: self.ident.to_string(), constants })); - Ok(()) - } -} - -fn type_to_type(ty: &Type) -> Result { - let Type::Path(path) = ty else { - return Err(Error::new(ty.span(), "expected type path")); - }; - - let mut name = String::new(); - - for segment in &path.path.segments { - if !name.is_empty() { - name.push('.'); - } - name.push_str(&segment.ident.to_string()); - } - - let ty = match name.as_str() { - "bool" => writer::Type::Bool, - "i8" => writer::Type::I8, - "u8" => writer::Type::U8, - "i16" => writer::Type::I16, - "u16" => writer::Type::U16, - "i32" => writer::Type::I32, - "u32" => writer::Type::U32, - "i64" => writer::Type::I64, - "u64" => writer::Type::U64, - "f32" => writer::Type::F32, - "f64" => writer::Type::F64, - "isize" => writer::Type::ISize, - "usize" => writer::Type::USize, - _ => { - let Some((namespace, name)) = name.rsplit_once('.') else { - return Err(Error::new(path.span(), "expected type")); - }; - writer::Type::Named((namespace.to_string(), name.to_string())) - } - }; - - Ok(ty) -} diff --git a/crates/tools/yml/Cargo.toml b/crates/tools/yml/Cargo.toml index 05822eca78..28cb439027 100644 --- a/crates/tools/yml/Cargo.toml +++ b/crates/tools/yml/Cargo.toml @@ -6,4 +6,4 @@ publish = false [dependencies] metadata = { package = "windows-metadata", path = "../../libs/metadata" } -regex = "1.7.0" +regex = "1.7"