fix(macros/generate/auxiliary/c/function): Also add inputs when no output

This commit is contained in:
Benedikt Peetz 2024-03-27 22:05:08 +01:00
parent 475dde282c
commit 3d35d395f3
Signed by: bpeetz
GPG Key ID: A5E94010C3A642AD
1 changed files with 12 additions and 13 deletions

View File

@ -29,11 +29,7 @@ impl Function {
pub fn to_auxiliary_c(&self, namespaces: &[&Identifier]) -> String { pub fn to_auxiliary_c(&self, namespaces: &[&Identifier]) -> String {
let doc_comments: String = Attribute::to_auxiliary_c_merged(&self.attributes); let doc_comments: String = Attribute::to_auxiliary_c_merged(&self.attributes);
let ident = self.identifier.to_c_with_path(namespaces); let ident = self.identifier.to_c_with_path(namespaces);
let inputs: Vec<TokenStream2> = self let inputs: Vec<TokenStream2> = self.inputs.iter().map(NamedType::to_auxiliary_c).collect();
.inputs
.iter()
.map(NamedType::to_auxiliary_c)
.collect();
let function_output = if let Some(out) = &self.output { let function_output = if let Some(out) = &self.output {
let type_name = &out.to_auxiliary_c(true, None); let type_name = &out.to_auxiliary_c(true, None);
@ -76,20 +72,23 @@ impl Function {
(TokenStream2::default(), TokenStream2::default()) (TokenStream2::default(), TokenStream2::default())
}; };
let initial_inputs: Vec<TokenStream2> = self
.inputs
.iter()
.map(|named_type| (&named_type.r#type, &named_type.name))
.map(|(r#type, name)| r#type.to_auxiliary_c(false, Some(name)))
.collect();
let inputs: TokenStream2 = if self.inputs.is_empty() && output.is_empty() { let inputs: TokenStream2 = if self.inputs.is_empty() && output.is_empty() {
quote! { void } quote! { void }
} else if !self.inputs.is_empty() && !output.is_empty() { } else if !self.inputs.is_empty() && !output.is_empty() {
let inputs: Vec<TokenStream2> = self
.inputs
.iter()
.map(|named_type| &named_type.r#type)
.map(|r#type| r#type.to_auxiliary_c(false, None))
.collect();
quote! { quote! {
#output_comma #(#inputs),* #output_comma #(#initial_inputs),*
} }
} else { } else {
TokenStream2::default() quote! {
#(#initial_inputs),*
}
}; };
quote! { quote! {