Skip to content

Commit

Permalink
Infer ABI type for method result type (#1909)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Jul 13, 2022
1 parent f2c7b49 commit 56f7799
Show file tree
Hide file tree
Showing 504 changed files with 54,156 additions and 54,151 deletions.
3 changes: 1 addition & 2 deletions crates/libs/bindgen/src/com_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,12 @@ pub fn gen(gen: &Gen, def: TypeDef, kind: InterfaceKind, method: MethodDef, meth
let params = gen.win32_params(leading_params, kind);
let return_type = signature.params[signature.params.len() - 1].ty.deref();
let return_type_tokens = gen.type_name(&return_type);
let abi_return_type_tokens = gen.type_abi_name(&return_type);

quote! {
#doc
#features
pub unsafe fn #name<#generics>(&self, #params) -> ::windows::core::Result<#return_type_tokens> #where_clause {
let mut result__ = ::core::mem::MaybeUninit::<#abi_return_type_tokens>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(self)#bases.#vname)(::windows::core::Interface::as_raw(self), #args ::core::mem::transmute(result__.as_mut_ptr()))
.from_abi::<#return_type_tokens>(result__ )
}
Expand Down
3 changes: 1 addition & 2 deletions crates/libs/bindgen/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ fn gen_win_function(gen: &Gen, def: MethodDef) -> TokenStream {
let params = gen.win32_params(leading_params, kind);
let return_type = signature.params[signature.params.len() - 1].ty.deref();
let return_type_tokens = gen.type_name(&return_type);
let abi_return_type_tokens = gen.type_abi_name(&return_type);

quote! {
#doc
Expand All @@ -123,7 +122,7 @@ fn gen_win_function(gen: &Gen, def: MethodDef) -> TokenStream {
extern "system" {
fn #name(#(#abi_params),*) #abi_return_type;
}
let mut result__ = ::core::mem::MaybeUninit::<#abi_return_type_tokens>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
#name(#args ::core::mem::transmute(result__.as_mut_ptr())).from_abi::<#return_type_tokens>(result__)
}
}
Expand Down
8 changes: 3 additions & 5 deletions crates/libs/bindgen/src/winrt_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,21 @@ pub fn gen(gen: &Gen, def: TypeDef, generic_types: &[Type], kind: InterfaceKind,
if return_type.is_winrt_array() {
(
quote! {
let mut result__ = ::core::mem::MaybeUninit::<#return_type_tokens>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).#vname)(::windows::core::Interface::as_raw(this), #args #composable_args #return_arg)
.and_then(|| result__.assume_init())
},
quote! {},
)
} else {
let abi_type_name = gen.type_abi_name(return_type);

(
quote! {
let mut result__ = ::core::mem::MaybeUninit::<#abi_type_name>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).#vname)(::windows::core::Interface::as_raw(this), #args #composable_args #return_arg)
.from_abi::<#return_type_tokens>(result__ )
},
quote! {
let mut result__ = ::core::mem::MaybeUninit::<#abi_type_name>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).#vname)(::windows::core::Interface::as_raw(this), #args ::core::ptr::null_mut(), &mut ::core::option::Option::<::windows::core::IInspectable>::None as *mut _ as _, #return_arg)
.from_abi::<#return_type_tokens>(result__ )
},
Expand Down
120 changes: 60 additions & 60 deletions crates/libs/windows/src/Windows/AI/MachineLearning/Preview/mod.rs

Large diffs are not rendered by default.

440 changes: 220 additions & 220 deletions crates/libs/windows/src/Windows/AI/MachineLearning/mod.rs

Large diffs are not rendered by default.

1,118 changes: 559 additions & 559 deletions crates/libs/windows/src/Windows/ApplicationModel/Activation/mod.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@ impl AppExtension {
pub fn Id(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).Id)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn DisplayName(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).DisplayName)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn Description(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).Description)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn Package(&self) -> ::windows::core::Result<super::Package> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).Package)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::Package>(result__)
}
}
pub fn AppInfo(&self) -> ::windows::core::Result<super::AppInfo> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).AppInfo)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::AppInfo>(result__)
}
}
Expand All @@ -42,7 +42,7 @@ impl AppExtension {
pub fn GetExtensionPropertiesAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<super::super::Foundation::Collections::IPropertySet>> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).GetExtensionPropertiesAsync)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::super::Foundation::IAsyncOperation<super::super::Foundation::Collections::IPropertySet>>(result__)
}
}
Expand All @@ -51,14 +51,14 @@ impl AppExtension {
pub fn GetPublicFolderAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<super::super::Storage::StorageFolder>> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).GetPublicFolderAsync)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::super::Foundation::IAsyncOperation<super::super::Storage::StorageFolder>>(result__)
}
}
pub fn AppUserModelId(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = &::windows::core::Interface::cast::<IAppExtension2>(self)?;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).AppUserModelId)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
Expand Down Expand Up @@ -134,7 +134,7 @@ impl AppExtensionCatalog {
pub fn FindAllAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<super::super::Foundation::Collections::IVectorView<AppExtension>>> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).FindAllAsync)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::super::Foundation::IAsyncOperation<super::super::Foundation::Collections::IVectorView<AppExtension>>>(result__)
}
}
Expand All @@ -146,7 +146,7 @@ impl AppExtensionCatalog {
{
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).RequestRemovePackageAsync)(::windows::core::Interface::as_raw(this), packagefullname.into().abi(), result__.as_mut_ptr()).from_abi::<super::super::Foundation::IAsyncOperation<bool>>(result__)
}
}
Expand All @@ -158,7 +158,7 @@ impl AppExtensionCatalog {
{
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<super::super::Foundation::EventRegistrationToken>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).PackageInstalled)(::windows::core::Interface::as_raw(this), handler.into().abi(), result__.as_mut_ptr()).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
Expand All @@ -176,7 +176,7 @@ impl AppExtensionCatalog {
{
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<super::super::Foundation::EventRegistrationToken>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).PackageUpdating)(::windows::core::Interface::as_raw(this), handler.into().abi(), result__.as_mut_ptr()).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
Expand All @@ -194,7 +194,7 @@ impl AppExtensionCatalog {
{
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<super::super::Foundation::EventRegistrationToken>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).PackageUpdated)(::windows::core::Interface::as_raw(this), handler.into().abi(), result__.as_mut_ptr()).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
Expand All @@ -212,7 +212,7 @@ impl AppExtensionCatalog {
{
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<super::super::Foundation::EventRegistrationToken>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).PackageUninstalling)(::windows::core::Interface::as_raw(this), handler.into().abi(), result__.as_mut_ptr()).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
Expand All @@ -230,7 +230,7 @@ impl AppExtensionCatalog {
{
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<super::super::Foundation::EventRegistrationToken>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).PackageStatusChanged)(::windows::core::Interface::as_raw(this), handler.into().abi(), result__.as_mut_ptr()).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
Expand All @@ -245,7 +245,7 @@ impl AppExtensionCatalog {
P0: ::std::convert::Into<::windows::core::InParam<'a, ::windows::core::HSTRING>>,
{
Self::IAppExtensionCatalogStatics(|this| unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).Open)(::windows::core::Interface::as_raw(this), appextensionname.into().abi(), result__.as_mut_ptr()).from_abi::<AppExtensionCatalog>(result__)
})
}
Expand Down Expand Up @@ -322,14 +322,14 @@ impl AppExtensionPackageInstalledEventArgs {
pub fn AppExtensionName(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).AppExtensionName)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn Package(&self) -> ::windows::core::Result<super::Package> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).Package)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::Package>(result__)
}
}
Expand All @@ -338,7 +338,7 @@ impl AppExtensionPackageInstalledEventArgs {
pub fn Extensions(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVectorView<AppExtension>> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).Extensions)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::super::Foundation::Collections::IVectorView<AppExtension>>(result__)
}
}
Expand Down Expand Up @@ -412,14 +412,14 @@ impl AppExtensionPackageStatusChangedEventArgs {
pub fn AppExtensionName(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).AppExtensionName)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn Package(&self) -> ::windows::core::Result<super::Package> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).Package)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::Package>(result__)
}
}
Expand Down Expand Up @@ -493,14 +493,14 @@ impl AppExtensionPackageUninstallingEventArgs {
pub fn AppExtensionName(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).AppExtensionName)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn Package(&self) -> ::windows::core::Result<super::Package> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).Package)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::Package>(result__)
}
}
Expand Down Expand Up @@ -574,14 +574,14 @@ impl AppExtensionPackageUpdatedEventArgs {
pub fn AppExtensionName(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).AppExtensionName)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn Package(&self) -> ::windows::core::Result<super::Package> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).Package)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::Package>(result__)
}
}
Expand All @@ -590,7 +590,7 @@ impl AppExtensionPackageUpdatedEventArgs {
pub fn Extensions(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVectorView<AppExtension>> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).Extensions)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::super::Foundation::Collections::IVectorView<AppExtension>>(result__)
}
}
Expand Down Expand Up @@ -664,14 +664,14 @@ impl AppExtensionPackageUpdatingEventArgs {
pub fn AppExtensionName(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).AppExtensionName)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn Package(&self) -> ::windows::core::Result<super::Package> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(this).Package)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::Package>(result__)
}
}
Expand Down
Loading

0 comments on commit 56f7799

Please sign in to comment.