diff options
author | 2020-10-22 16:48:56 +0000 | |
---|---|---|
committer | 2020-10-22 16:48:56 +0000 | |
commit | 9fb5a223cb8adb01381650b66eab28ea5abc98ed (patch) | |
tree | 357983fd15ba52ea221f20b5cb14b96783d07d51 /macros/src/codegen/software_tasks.rs | |
parent | 6de4f1a797c81aec6c24f47872e5d3968344684c (diff) | |
parent | 17e976ab495234f9f53f56e6693850af077cf701 (diff) | |
download | rtic-9fb5a223cb8adb01381650b66eab28ea5abc98ed.tar.gz rtic-9fb5a223cb8adb01381650b66eab28ea5abc98ed.tar.zst rtic-9fb5a223cb8adb01381650b66eab28ea5abc98ed.zip |
Merge #396
396: Fix namespaces r=AfoHT a=korken89
Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
Diffstat (limited to 'macros/src/codegen/software_tasks.rs')
-rw-r--r-- | macros/src/codegen/software_tasks.rs | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index 17d1e6da..18cecdf2 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -1,5 +1,5 @@ use proc_macro2::TokenStream as TokenStream2; -use quote::{format_ident, quote}; +use quote::quote; use rtic_syntax::{ast::App, Context}; use crate::{ @@ -22,13 +22,10 @@ pub fn codegen( Vec<TokenStream2>, // user_software_tasks -- the `#[task]` functions written by the user Vec<TokenStream2>, - // user_software_tasks_imports -- the imports for `#[task]` functions written by the user - Vec<TokenStream2>, ) { let mut mod_app = vec![]; let mut root = vec![]; let mut user_tasks = vec![]; - let mut software_tasks_imports = vec![]; for (name, task) in &app.software_tasks { let inputs = &task.inputs; @@ -53,7 +50,7 @@ pub fn codegen( mod_app.push(quote!( /// Queue version of a free-list that keeps track of empty slots in /// the following buffers - pub static mut #fq: #fq_ty = #fq_expr; + static mut #fq: #fq_ty = #fq_expr; )); let elems = &(0..cap) @@ -67,7 +64,7 @@ pub fn codegen( mod_app.push(quote!( #uninit /// Buffer that holds the instants associated to the inputs of a task - pub static mut #instants: + static mut #instants: [core::mem::MaybeUninit<<#m as rtic::Monotonic>::Instant>; #cap_lit] = [#(#elems,)*]; )); @@ -78,7 +75,7 @@ pub fn codegen( mod_app.push(quote!( #uninit /// Buffer that holds the inputs of a task - pub static mut #inputs_ident: [core::mem::MaybeUninit<#input_ty>; #cap_lit] = + static mut #inputs_ident: [core::mem::MaybeUninit<#input_ty>; #cap_lit] = [#(#elems,)*]; )); @@ -93,13 +90,6 @@ pub fn codegen( analysis, ); - // Add resources to imports - let name_res = format_ident!("{}Resources", name); - software_tasks_imports.push(quote!( - #[allow(non_snake_case)] - use super::#name_res; - )); - root.push(item); mod_app.push(constructor); @@ -123,17 +113,12 @@ pub fn codegen( #(#attrs)* #(#cfgs)* #[allow(non_snake_case)] - pub fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) { + fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) { use rtic::Mutex as _; #(#stmts)* } )); - software_tasks_imports.push(quote!( - #(#cfgs)* - #[allow(non_snake_case)] - use super::#name; - )); root.push(module::codegen( Context::SoftwareTask(name), @@ -144,5 +129,5 @@ pub fn codegen( )); } - (mod_app, root, user_tasks, software_tasks_imports) + (mod_app, root, user_tasks) } |