Skip to content

Commit 6d45cc6

Browse files
authored
Don't transform pointers to references (#2036)
1 parent c4a48b3 commit 6d45cc6

File tree

270 files changed

+31825
-30132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+31825
-30132
lines changed

crates/libs/bindgen/src/gen.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,13 @@ impl<'a> Gen<'a> {
911911
} else {
912912
quote! { ::core::mem::transmute_copy(#name), }
913913
}
914+
} else if param.ty.is_pointer() && self.reader.param_flags(param.def).optional() {
915+
let flags = self.reader.param_flags(param.def);
916+
if flags.output() {
917+
quote! { ::core::mem::transmute(#name.unwrap_or(::std::ptr::null_mut())), }
918+
} else {
919+
quote! { ::core::mem::transmute(#name.unwrap_or(::std::ptr::null())), }
920+
}
914921
} else {
915922
quote! { ::core::mem::transmute(#name), }
916923
}
@@ -997,25 +1004,11 @@ impl<'a> Gen<'a> {
9971004
continue;
9981005
}
9991006

1000-
if param.ty.is_pointer() && !param.ty.is_void() && param.array_info != ArrayInfo::Removed {
1001-
let param_flags = self.reader.param_flags(param.def);
1002-
let kind = self.type_default_name(&param.ty.deref());
1003-
let kind = if param_flags.output() {
1004-
quote! { &mut #kind }
1005-
} else {
1006-
quote! { &#kind }
1007-
};
1008-
if self.reader.param_flags(param.def).optional() {
1009-
tokens.combine(&quote! { #name: ::core::option::Option<#kind>, });
1010-
} else {
1011-
tokens.combine(&quote! { #name: #kind, });
1012-
}
1013-
continue;
1014-
}
1015-
10161007
let kind = self.type_default_name(&param.ty);
10171008

1018-
if self.reader.type_is_blittable(&param.ty) {
1009+
if param.ty.is_pointer() && self.reader.param_flags(param.def).optional() {
1010+
tokens.combine(&quote! { #name: ::core::option::Option<#kind>, });
1011+
} else if self.reader.type_is_blittable(&param.ty) {
10191012
tokens.combine(&quote! { #name: #kind, });
10201013
} else {
10211014
tokens.combine(&quote! { #name: &#kind, });

crates/libs/windows/src/Windows/Win32/AI/MachineLearning/DirectML/mod.rs

Lines changed: 57 additions & 57 deletions
Large diffs are not rendered by default.

crates/libs/windows/src/Windows/Win32/AI/MachineLearning/WinML/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ impl IMLOperatorKernelContext {
165165
let mut result__ = ::core::mem::MaybeUninit::zeroed();
166166
(::windows::core::Interface::vtable(self).AllocateTemporaryData)(::windows::core::Interface::as_raw(self), size, ::core::mem::transmute(result__.as_mut_ptr())).from_abi::<::windows::core::IUnknown>(result__)
167167
}
168-
pub unsafe fn GetExecutionInterface(&self, executionobject: ::core::option::Option<&mut ::core::option::Option<::windows::core::IUnknown>>) {
169-
(::windows::core::Interface::vtable(self).GetExecutionInterface)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(executionobject))
168+
pub unsafe fn GetExecutionInterface(&self, executionobject: ::core::option::Option<*mut ::core::option::Option<::windows::core::IUnknown>>) {
169+
(::windows::core::Interface::vtable(self).GetExecutionInterface)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(executionobject.unwrap_or(::std::ptr::null_mut())))
170170
}
171171
}
172172
impl ::core::convert::From<IMLOperatorKernelContext> for ::windows::core::IUnknown {
@@ -271,8 +271,8 @@ impl IMLOperatorKernelCreationContext {
271271
let mut result__ = ::core::mem::MaybeUninit::zeroed();
272272
(::windows::core::Interface::vtable(self).GetTensorShapeDescription)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(result__.as_mut_ptr())).from_abi::<IMLOperatorTensorShapeDescription>(result__)
273273
}
274-
pub unsafe fn GetExecutionInterface(&self, executionobject: ::core::option::Option<&mut ::core::option::Option<::windows::core::IUnknown>>) {
275-
(::windows::core::Interface::vtable(self).GetExecutionInterface)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(executionobject))
274+
pub unsafe fn GetExecutionInterface(&self, executionobject: ::core::option::Option<*mut ::core::option::Option<::windows::core::IUnknown>>) {
275+
(::windows::core::Interface::vtable(self).GetExecutionInterface)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(executionobject.unwrap_or(::std::ptr::null_mut())))
276276
}
277277
}
278278
impl ::core::convert::From<IMLOperatorKernelCreationContext> for ::windows::core::IUnknown {
@@ -396,14 +396,14 @@ pub struct IMLOperatorKernelFactory_Vtbl {
396396
#[repr(transparent)]
397397
pub struct IMLOperatorRegistry(::windows::core::IUnknown);
398398
impl IMLOperatorRegistry {
399-
pub unsafe fn RegisterOperatorSetSchema<'a, P0, P1>(&self, operatorsetid: &MLOperatorSetId, baselineversion: i32, schema: ::core::option::Option<&[*const MLOperatorSchemaDescription]>, typeinferrer: P0, shapeinferrer: P1) -> ::windows::core::Result<()>
399+
pub unsafe fn RegisterOperatorSetSchema<'a, P0, P1>(&self, operatorsetid: *const MLOperatorSetId, baselineversion: i32, schema: ::core::option::Option<&[*const MLOperatorSchemaDescription]>, typeinferrer: P0, shapeinferrer: P1) -> ::windows::core::Result<()>
400400
where
401401
P0: ::std::convert::Into<::windows::core::InParam<'a, IMLOperatorTypeInferrer>>,
402402
P1: ::std::convert::Into<::windows::core::InParam<'a, IMLOperatorShapeInferrer>>,
403403
{
404404
(::windows::core::Interface::vtable(self).RegisterOperatorSetSchema)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(operatorsetid), baselineversion, ::core::mem::transmute(schema.as_deref().map_or(::core::ptr::null(), |slice| slice.as_ptr())), schema.as_deref().map_or(0, |slice| slice.len() as _), typeinferrer.into().abi(), shapeinferrer.into().abi()).ok()
405405
}
406-
pub unsafe fn RegisterOperatorKernel<'a, P0, P1>(&self, operatorkernel: &MLOperatorKernelDescription, operatorkernelfactory: P0, shapeinferrer: P1) -> ::windows::core::Result<()>
406+
pub unsafe fn RegisterOperatorKernel<'a, P0, P1>(&self, operatorkernel: *const MLOperatorKernelDescription, operatorkernelfactory: P0, shapeinferrer: P1) -> ::windows::core::Result<()>
407407
where
408408
P0: ::std::convert::Into<::windows::core::InParam<'a, IMLOperatorKernelFactory>>,
409409
P1: ::std::convert::Into<::windows::core::InParam<'a, IMLOperatorShapeInferrer>>,
@@ -506,7 +506,7 @@ impl IMLOperatorShapeInferenceContext {
506506
pub unsafe fn GetInputTensorShape(&self, inputindex: u32, dimensions: &mut [u32]) -> ::windows::core::Result<()> {
507507
(::windows::core::Interface::vtable(self).GetInputTensorShape)(::windows::core::Interface::as_raw(self), inputindex, dimensions.len() as _, ::core::mem::transmute(dimensions.as_ptr())).ok()
508508
}
509-
pub unsafe fn SetOutputTensorShape(&self, outputindex: u32, dimensioncount: u32, dimensions: &u32) -> ::windows::core::Result<()> {
509+
pub unsafe fn SetOutputTensorShape(&self, outputindex: u32, dimensioncount: u32, dimensions: *const u32) -> ::windows::core::Result<()> {
510510
(::windows::core::Interface::vtable(self).SetOutputTensorShape)(::windows::core::Interface::as_raw(self), outputindex, dimensioncount, ::core::mem::transmute(dimensions)).ok()
511511
}
512512
}
@@ -647,8 +647,8 @@ impl IMLOperatorTensor {
647647
pub unsafe fn GetData(&self) -> *mut ::core::ffi::c_void {
648648
(::windows::core::Interface::vtable(self).GetData)(::windows::core::Interface::as_raw(self))
649649
}
650-
pub unsafe fn GetDataInterface(&self, datainterface: ::core::option::Option<&mut ::core::option::Option<::windows::core::IUnknown>>) {
651-
(::windows::core::Interface::vtable(self).GetDataInterface)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(datainterface))
650+
pub unsafe fn GetDataInterface(&self, datainterface: ::core::option::Option<*mut ::core::option::Option<::windows::core::IUnknown>>) {
651+
(::windows::core::Interface::vtable(self).GetDataInterface)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(datainterface.unwrap_or(::std::ptr::null_mut())))
652652
}
653653
}
654654
impl ::core::convert::From<IMLOperatorTensor> for ::windows::core::IUnknown {
@@ -811,7 +811,7 @@ impl IMLOperatorTypeInferenceContext {
811811
let mut result__ = ::core::mem::MaybeUninit::zeroed();
812812
(::windows::core::Interface::vtable(self).GetInputEdgeDescription)(::windows::core::Interface::as_raw(self), inputindex, ::core::mem::transmute(result__.as_mut_ptr())).from_abi::<MLOperatorEdgeDescription>(result__)
813813
}
814-
pub unsafe fn SetOutputEdgeDescription(&self, outputindex: u32, edgedescription: &MLOperatorEdgeDescription) -> ::windows::core::Result<()> {
814+
pub unsafe fn SetOutputEdgeDescription(&self, outputindex: u32, edgedescription: *const MLOperatorEdgeDescription) -> ::windows::core::Result<()> {
815815
(::windows::core::Interface::vtable(self).SetOutputEdgeDescription)(::windows::core::Interface::as_raw(self), outputindex, ::core::mem::transmute(edgedescription)).ok()
816816
}
817817
}
@@ -934,7 +934,7 @@ pub struct IWinMLEvaluationContext(::windows::core::IUnknown);
934934
impl IWinMLEvaluationContext {
935935
#[doc = "*Required features: `\"Win32_Graphics_Direct3D12\"`*"]
936936
#[cfg(feature = "Win32_Graphics_Direct3D12")]
937-
pub unsafe fn BindValue(&self, pdescriptor: &WINML_BINDING_DESC) -> ::windows::core::Result<()> {
937+
pub unsafe fn BindValue(&self, pdescriptor: *const WINML_BINDING_DESC) -> ::windows::core::Result<()> {
938938
(::windows::core::Interface::vtable(self).BindValue)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(pdescriptor)).ok()
939939
}
940940
#[doc = "*Required features: `\"Win32_Graphics_Direct3D12\"`*"]
@@ -1007,7 +1007,7 @@ impl IWinMLModel {
10071007
let mut result__ = ::core::mem::MaybeUninit::zeroed();
10081008
(::windows::core::Interface::vtable(self).GetDescription)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(result__.as_mut_ptr())).from_abi::<*mut WINML_MODEL_DESC>(result__)
10091009
}
1010-
pub unsafe fn EnumerateMetadata(&self, index: u32, pkey: &mut ::windows::core::PWSTR, pvalue: &mut ::windows::core::PWSTR) -> ::windows::core::Result<()> {
1010+
pub unsafe fn EnumerateMetadata(&self, index: u32, pkey: *mut ::windows::core::PWSTR, pvalue: *mut ::windows::core::PWSTR) -> ::windows::core::Result<()> {
10111011
(::windows::core::Interface::vtable(self).EnumerateMetadata)(::windows::core::Interface::as_raw(self), index, ::core::mem::transmute(pkey), ::core::mem::transmute(pvalue)).ok()
10121012
}
10131013
#[doc = "*Required features: `\"Win32_Foundation\"`*"]

0 commit comments

Comments
 (0)