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 {
|
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! {
|
||||||
|
|
Reference in New Issue