mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-18 05:45:19 +01:00
refactor: remove minor code duplication
This commit is contained in:
parent
0593a7290b
commit
22ba6bac06
1 changed files with 12 additions and 24 deletions
|
|
@ -37,32 +37,20 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 {
|
||||||
let cfgs = &task.cfgs;
|
let cfgs = &task.cfgs;
|
||||||
let stmts = &task.stmts;
|
let stmts = &task.stmts;
|
||||||
let inputs = &task.inputs;
|
let inputs = &task.inputs;
|
||||||
|
let lifetime = if task.is_bottom { quote!('static) } else { quote!('a) };
|
||||||
|
let generics = if task.is_bottom { quote!() } else { quote!(<'a>) };
|
||||||
|
|
||||||
user_tasks.push(if task.is_bottom {
|
user_tasks.push(quote!(
|
||||||
quote!(
|
#(#attrs)*
|
||||||
#(#attrs)*
|
#(#cfgs)*
|
||||||
#(#cfgs)*
|
#[allow(non_snake_case)]
|
||||||
#[allow(non_snake_case)]
|
async fn #name#generics(#context: #name::Context<#lifetime> #(,#inputs)*) {
|
||||||
async fn #name(#context: #name::Context<'static> #(,#inputs)*) {
|
use rtic::Mutex as _;
|
||||||
use rtic::Mutex as _;
|
use rtic::mutex::prelude::*;
|
||||||
use rtic::mutex::prelude::*;
|
|
||||||
|
|
||||||
#(#stmts)*
|
#(#stmts)*
|
||||||
}
|
}
|
||||||
)
|
));
|
||||||
} else {
|
|
||||||
quote!(
|
|
||||||
#(#attrs)*
|
|
||||||
#(#cfgs)*
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
async fn #name<'a>(#context: #name::Context<'a> #(,#inputs)*) {
|
|
||||||
use rtic::Mutex as _;
|
|
||||||
use rtic::mutex::prelude::*;
|
|
||||||
|
|
||||||
#(#stmts)*
|
|
||||||
}
|
|
||||||
)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
root.push(module::codegen(Context::SoftwareTask(name), app, analysis));
|
root.push(module::codegen(Context::SoftwareTask(name), app, analysis));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue