fix(macros/generate/auxiliary/c/function): Also add inputs when no output
This commit is contained in:
parent
475dde282c
commit
3d35d395f3
|
@ -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! {
|
||||
|
|
Reference in New Issue