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 {
let doc_comments: String = Attribute::to_auxiliary_c_merged(&self.attributes);
let ident = self.identifier.to_c_with_path(namespaces);
let inputs: Vec<TokenStream2> = self
.inputs
.iter()
.map(NamedType::to_auxiliary_c)
.collect();
let inputs: Vec<TokenStream2> = self.inputs.iter().map(NamedType::to_auxiliary_c).collect();
let function_output = if let Some(out) = &self.output {
let type_name = &out.to_auxiliary_c(true, None);
@ -76,20 +72,23 @@ impl Function {
(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() {
quote! { void }
} 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! {
#output_comma #(#inputs),*
#output_comma #(#initial_inputs),*
}
} else {
TokenStream2::default()
quote! {
#(#initial_inputs),*
}
};
quote! {