Skip to content

Commit

Permalink
ReturnHint::ReturnVoid is not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Dec 10, 2024
1 parent 2dffc99 commit dab0baf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
12 changes: 0 additions & 12 deletions crates/libs/bindgen/src/types/cpp_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,6 @@ impl CppFn {
}
}
}
ReturnHint::ReturnVoid => {
let where_clause = method.write_where(writer, false);

quote! {
#cfg
#[inline]
pub unsafe fn #name<#generics>(#params) #abi_return_type #where_clause {
#link
#name(#args)
}
}
}
};

quote! {
Expand Down
18 changes: 2 additions & 16 deletions crates/libs/bindgen/src/types/cpp_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub enum ReturnHint {
ResultVoid,
ReturnStruct,
ReturnValue,
ReturnVoid,
}

#[derive(Copy, Clone, PartialEq, Debug)]
Expand Down Expand Up @@ -187,12 +186,9 @@ impl CppMethod {
false
};

// TODO: ignore this attribute and just return HRESULT/BOOL/NTSTATUS/whatever and let the caller user `.ok()` if
// they want to treat it as a Result with a single success value.
if !def.has_attribute("CanReturnMultipleSuccessValuesAttribute") {
match &signature.return_type.0 {
Type::Void if is_retval => return_hint = ReturnHint::ReturnValue,
Type::Void => return_hint = ReturnHint::ReturnVoid,
Type::HRESULT => {
if is_retval {
return_hint = ReturnHint::ResultValue
Expand Down Expand Up @@ -283,6 +279,7 @@ impl CppMethod {
let args = self.write_args();
let params = self.write_params(writer);
let generics = self.write_generics();
let abi_return_type = self.write_return(writer);

match self.return_hint {
ReturnHint::Query(..) => {
Expand Down Expand Up @@ -386,24 +383,14 @@ impl CppMethod {
}
}
ReturnHint::None => {
let return_type = self.signature.return_type.0.write_default(writer);
let where_clause = self.write_where(writer, false);

quote! {
pub unsafe fn #name<#generics>(&self, #params) -> #return_type #where_clause {
pub unsafe fn #name<#generics>(&self, #params) #abi_return_type #where_clause {
(windows_core::Interface::vtable(self).#vname)(windows_core::Interface::as_raw(self), #args)
}
}
}
ReturnHint::ReturnVoid => {
let where_clause = self.write_where(writer, false);

quote! {
pub unsafe fn #name<#generics>(&self, #params) #where_clause {
(windows_core::Interface::vtable(self).#vname)(windows_core::Interface::as_raw(self),#args)
}
}
}
}
}

Expand Down Expand Up @@ -494,7 +481,6 @@ impl CppMethod {
}

let return_type = match self.return_hint {
ReturnHint::ReturnVoid => quote! {},
ReturnHint::Query(..) | ReturnHint::QueryOptional(..) | ReturnHint::ResultVoid => {
quote! { -> windows_core::Result<()> }
}
Expand Down

0 comments on commit dab0baf

Please sign in to comment.