Skip to content

Commit

Permalink
Prefer &T to *const T for Win32 input parameters (#1939)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Jul 25, 2022
1 parent 60c6ec5 commit 9aef1a2
Show file tree
Hide file tree
Showing 287 changed files with 24,153 additions and 24,135 deletions.
16 changes: 16 additions & 0 deletions crates/libs/bindgen/src/gen.rs
Expand Up @@ -1022,6 +1022,22 @@ impl<'a> Gen<'a> {
continue;
}

if param.ty.is_pointer() && !param.ty.is_void() {
let param_flags = self.reader.param_flags(param.def);
let kind = self.type_default_name(&param.ty.deref());
let kind = if param_flags.output() {
quote! { &mut #kind }
} else {
quote! { &#kind }
};
if self.reader.param_flags(param.def).optional() {
tokens.combine(&quote! { #name: ::core::option::Option<#kind>, });
} else {
tokens.combine(&quote! { #name: #kind, });
}
continue;
}

let kind = self.type_default_name(&param.ty);

if self.reader.type_is_blittable(&param.ty) {
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -145,7 +145,7 @@ impl IMLOperatorKernelContext {
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::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__)
}
pub unsafe fn GetExecutionInterface(&self, executionobject: *mut ::core::option::Option<::windows::core::IUnknown>) {
pub unsafe fn GetExecutionInterface(&self, executionobject: ::core::option::Option<&mut ::core::option::Option<::windows::core::IUnknown>>) {
(::windows::core::Interface::vtable(self).GetExecutionInterface)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(executionobject))
}
}
Expand Down Expand Up @@ -251,7 +251,7 @@ impl IMLOperatorKernelCreationContext {
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(self).GetTensorShapeDescription)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(result__.as_mut_ptr())).from_abi::<IMLOperatorTensorShapeDescription>(result__)
}
pub unsafe fn GetExecutionInterface(&self, executionobject: *mut ::core::option::Option<::windows::core::IUnknown>) {
pub unsafe fn GetExecutionInterface(&self, executionobject: ::core::option::Option<&mut ::core::option::Option<::windows::core::IUnknown>>) {
(::windows::core::Interface::vtable(self).GetExecutionInterface)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(executionobject))
}
}
Expand Down Expand Up @@ -376,14 +376,14 @@ pub struct IMLOperatorKernelFactory_Vtbl {
#[repr(transparent)]
pub struct IMLOperatorRegistry(::windows::core::IUnknown);
impl IMLOperatorRegistry {
pub unsafe fn RegisterOperatorSetSchema<'a, P0, P1>(&self, operatorsetid: *const MLOperatorSetId, baselineversion: i32, schema: &[*const MLOperatorSchemaDescription], typeinferrer: P0, shapeinferrer: P1) -> ::windows::core::Result<()>
pub unsafe fn RegisterOperatorSetSchema<'a, P0, P1>(&self, operatorsetid: &MLOperatorSetId, baselineversion: i32, schema: &[*const MLOperatorSchemaDescription], typeinferrer: P0, shapeinferrer: P1) -> ::windows::core::Result<()>
where
P0: ::std::convert::Into<::windows::core::InParam<'a, IMLOperatorTypeInferrer>>,
P1: ::std::convert::Into<::windows::core::InParam<'a, IMLOperatorShapeInferrer>>,
{
(::windows::core::Interface::vtable(self).RegisterOperatorSetSchema)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(operatorsetid), baselineversion, ::core::mem::transmute(::windows::core::as_ptr_or_null(schema)), schema.len() as _, typeinferrer.into().abi(), shapeinferrer.into().abi()).ok()
}
pub unsafe fn RegisterOperatorKernel<'a, P0, P1>(&self, operatorkernel: *const MLOperatorKernelDescription, operatorkernelfactory: P0, shapeinferrer: P1) -> ::windows::core::Result<()>
pub unsafe fn RegisterOperatorKernel<'a, P0, P1>(&self, operatorkernel: &MLOperatorKernelDescription, operatorkernelfactory: P0, shapeinferrer: P1) -> ::windows::core::Result<()>
where
P0: ::std::convert::Into<::windows::core::InParam<'a, IMLOperatorKernelFactory>>,
P1: ::std::convert::Into<::windows::core::InParam<'a, IMLOperatorShapeInferrer>>,
Expand Down Expand Up @@ -486,7 +486,7 @@ impl IMLOperatorShapeInferenceContext {
pub unsafe fn GetInputTensorShape(&self, inputindex: u32, dimensions: &mut [u32]) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).GetInputTensorShape)(::windows::core::Interface::as_raw(self), inputindex, dimensions.len() as _, ::core::mem::transmute(::windows::core::as_mut_ptr_or_null(dimensions))).ok()
}
pub unsafe fn SetOutputTensorShape(&self, outputindex: u32, dimensioncount: u32, dimensions: *const u32) -> ::windows::core::Result<()> {
pub unsafe fn SetOutputTensorShape(&self, outputindex: u32, dimensioncount: u32, dimensions: &u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).SetOutputTensorShape)(::windows::core::Interface::as_raw(self), outputindex, dimensioncount, ::core::mem::transmute(dimensions)).ok()
}
}
Expand Down Expand Up @@ -627,7 +627,7 @@ impl IMLOperatorTensor {
pub unsafe fn GetData(&self) -> *mut ::core::ffi::c_void {
(::windows::core::Interface::vtable(self).GetData)(::windows::core::Interface::as_raw(self))
}
pub unsafe fn GetDataInterface(&self, datainterface: *mut ::core::option::Option<::windows::core::IUnknown>) {
pub unsafe fn GetDataInterface(&self, datainterface: ::core::option::Option<&mut ::core::option::Option<::windows::core::IUnknown>>) {
(::windows::core::Interface::vtable(self).GetDataInterface)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(datainterface))
}
}
Expand Down Expand Up @@ -791,7 +791,7 @@ impl IMLOperatorTypeInferenceContext {
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::windows::core::Interface::vtable(self).GetInputEdgeDescription)(::windows::core::Interface::as_raw(self), inputindex, ::core::mem::transmute(result__.as_mut_ptr())).from_abi::<MLOperatorEdgeDescription>(result__)
}
pub unsafe fn SetOutputEdgeDescription(&self, outputindex: u32, edgedescription: *const MLOperatorEdgeDescription) -> ::windows::core::Result<()> {
pub unsafe fn SetOutputEdgeDescription(&self, outputindex: u32, edgedescription: &MLOperatorEdgeDescription) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).SetOutputEdgeDescription)(::windows::core::Interface::as_raw(self), outputindex, ::core::mem::transmute(edgedescription)).ok()
}
}
Expand Down Expand Up @@ -914,7 +914,7 @@ pub struct IWinMLEvaluationContext(::windows::core::IUnknown);
impl IWinMLEvaluationContext {
#[doc = "*Required features: `\"Win32_Graphics_Direct3D12\"`*"]
#[cfg(feature = "Win32_Graphics_Direct3D12")]
pub unsafe fn BindValue(&self, pdescriptor: *const WINML_BINDING_DESC) -> ::windows::core::Result<()> {
pub unsafe fn BindValue(&self, pdescriptor: &WINML_BINDING_DESC) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).BindValue)(::windows::core::Interface::as_raw(self), ::core::mem::transmute(pdescriptor)).ok()
}
#[doc = "*Required features: `\"Win32_Graphics_Direct3D12\"`*"]
Expand Down Expand Up @@ -987,7 +987,7 @@ impl IWinMLModel {
let mut result__ = ::core::mem::MaybeUninit::zeroed();
(::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__)
}
pub unsafe fn EnumerateMetadata(&self, index: u32, pkey: *mut ::windows::core::PWSTR, pvalue: *mut ::windows::core::PWSTR) -> ::windows::core::Result<()> {
pub unsafe fn EnumerateMetadata(&self, index: u32, pkey: &mut ::windows::core::PWSTR, pvalue: &mut ::windows::core::PWSTR) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).EnumerateMetadata)(::windows::core::Interface::as_raw(self), index, ::core::mem::transmute(pkey), ::core::mem::transmute(pvalue)).ok()
}
#[doc = "*Required features: `\"Win32_Foundation\"`*"]
Expand Down

0 comments on commit 9aef1a2

Please sign in to comment.