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/hardware_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/hardware_tasks.rs')
-rw-r--r-- | macros/src/codegen/hardware_tasks.rs | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs index ebfa69b9..e6fa5ed1 100644 --- a/macros/src/codegen/hardware_tasks.rs +++ b/macros/src/codegen/hardware_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::{ @@ -23,13 +23,10 @@ pub fn codegen( Vec<TokenStream2>, // user_hardware_tasks -- the `#[task]` functions written by the user Vec<TokenStream2>, - // user_hardware_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 hardware_tasks_imports = vec![]; for (name, task) in &app.hardware_tasks { let (let_instant, instant) = if let Some(m) = extra.monotonic { @@ -50,6 +47,8 @@ pub fn codegen( let symbol = task.args.binds.clone(); let priority = task.args.priority; + let app_name = &app.name; + let app_path = quote! {crate::#app_name}; mod_app.push(quote!( #[allow(non_snake_case)] #[no_mangle] @@ -59,7 +58,7 @@ pub fn codegen( #let_instant rtic::export::run(PRIORITY, || { - crate::#name( + #app_path::#name( #locals_new #name::Context::new(&rtic::export::Priority::new(PRIORITY) #instant) ) @@ -79,13 +78,6 @@ pub fn codegen( analysis, ); - // Add resources to imports - let name_res = format_ident!("{}Resources", name); - hardware_tasks_imports.push(quote!( - #[allow(non_snake_case)] - use super::#name_res; - )); - root.push(item); mod_app.push(constructor); @@ -121,13 +113,7 @@ pub fn codegen( #(#stmts)* } )); - - hardware_tasks_imports.push(quote!( - #(#attrs)* - #[allow(non_snake_case)] - use super::#name; - )); } - (mod_app, root, user_tasks, hardware_tasks_imports) + (mod_app, root, user_tasks) } |