Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Jan 17, 2025
1 parent 6204818 commit 0f57c44
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
7 changes: 3 additions & 4 deletions crates/libs/bindgen/src/types/cpp_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl CppFn {
}
ReturnHint::ResultValue => {
let where_clause = method.write_where(writer, false);
let return_type = signature.params[signature.params.len() - 1].ty.deref();
let return_type = signature.params[signature.params.len() - 1].deref();
let map = return_type.write_result_map();
let return_type = return_type.write_name(writer);

Expand Down Expand Up @@ -174,9 +174,8 @@ impl CppFn {
ReturnHint::ReturnValue => {
let where_clause = method.write_where(writer, false);

let return_type = method.signature.params[method.signature.params.len() - 1]
.ty
.deref();
let return_type =
method.signature.params[method.signature.params.len() - 1].deref();

if return_type.is_interface() {
let return_type = return_type.write_name(writer);
Expand Down
25 changes: 7 additions & 18 deletions crates/libs/bindgen/src/types/cpp_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl CppMethod {
// The len params must be input only.
if signature.params[relative].is_input()
&& position != relative
&& !signature.params[relative].ty.is_pointer()
&& !signature.params[relative].is_pointer()
{
param_hints[relative] = ParamHint::ArrayRelativePtr(position);
} else {
Expand Down Expand Up @@ -141,7 +141,7 @@ impl CppMethod {
// Remove any byte arrays that aren't byte-sized types.
for position in 0..param_hints.len() {
if let ParamHint::ArrayRelativeByteLen(relative) = param_hints[position] {
if !signature.params[position].ty.is_byte_size() {
if !signature.params[position].is_byte_size() {
param_hints[position] = ParamHint::None;
param_hints[relative] = ParamHint::None;
}
Expand Down Expand Up @@ -299,9 +299,7 @@ impl CppMethod {
ReturnHint::ResultValue => {
let where_clause = self.write_where(writer, false);

let return_type = self.signature.params[self.signature.params.len() - 1]
.ty
.deref();
let return_type = self.signature.params[self.signature.params.len() - 1].deref();

let map = return_type.write_result_map();
let return_type = return_type.write_name(writer);
Expand All @@ -327,9 +325,7 @@ impl CppMethod {
ReturnHint::ReturnValue => {
let where_clause = self.write_where(writer, false);

let return_type = self.signature.params[self.signature.params.len() - 1]
.ty
.deref();
let return_type = self.signature.params[self.signature.params.len() - 1].deref();

if return_type.is_interface() {
let return_type = return_type.write_name(writer);
Expand Down Expand Up @@ -397,12 +393,7 @@ impl CppMethod {
.iter()
.map(write_invoke_arg);

let result = to_ident(
&self.signature.params[self.signature.params.len() - 1]
.def
.name()
.to_lowercase(),
);
let result = self.signature.params[self.signature.params.len() - 1].write_ident();

quote! {
match #parent_impl::#name(this, #(#invoke_args,)*) {
Expand Down Expand Up @@ -457,9 +448,7 @@ impl CppMethod {
quote! { -> windows_core::Result<()> }
}
ReturnHint::ResultValue => {
let return_type = self.signature.params[self.signature.params.len() - 1]
.ty
.deref();
let return_type = self.signature.params[self.signature.params.len() - 1].deref();
let return_type = return_type.write_name(writer);

quote! { -> windows_core::Result<#return_type> }
Expand Down Expand Up @@ -642,7 +631,7 @@ impl CppMethod {
}
ParamHint::ArrayRelativePtr(relative) => {
let relative_param = &self.signature.params[relative];
let name = to_ident(&relative_param.def.name().to_lowercase());
let name = relative_param.write_ident();
if relative_param.is_optional() {
quote! { #name.as_deref().map_or(0, |slice|slice.len().try_into().unwrap()), }
} else {
Expand Down

0 comments on commit 0f57c44

Please sign in to comment.