mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-19 06:15:45 +01:00
Merge #396
396: Fix namespaces r=AfoHT a=korken89 Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
This commit is contained in:
commit
9fb5a223cb
50 changed files with 199 additions and 269 deletions
|
|
@ -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::{
|
||||
|
|
@ -19,8 +19,6 @@ type CodegenResult = (
|
|||
Vec<TokenStream2>,
|
||||
// user_init -- the `#[init]` function written by the user
|
||||
Option<TokenStream2>,
|
||||
// user_init_imports -- the imports for `#[init]` functio written by the user
|
||||
Vec<TokenStream2>,
|
||||
// call_init -- the call to the user `#[init]` if there's one
|
||||
Option<TokenStream2>,
|
||||
);
|
||||
|
|
@ -50,7 +48,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult {
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mut user_init_imports = vec![];
|
||||
let late_resources = util::late_resources_ident(&name);
|
||||
|
||||
root_init.push(quote!(
|
||||
|
|
@ -61,12 +58,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult {
|
|||
}
|
||||
));
|
||||
|
||||
let name_late = format_ident!("{}LateResources", name);
|
||||
user_init_imports.push(quote!(
|
||||
#[allow(non_snake_case)]
|
||||
use super::#name_late;
|
||||
));
|
||||
|
||||
let mut locals_pat = None;
|
||||
let mut locals_new = None;
|
||||
if !init.locals.is_empty() {
|
||||
|
|
@ -88,11 +79,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult {
|
|||
#(#stmts)*
|
||||
}
|
||||
));
|
||||
user_init_imports.push(quote!(
|
||||
#(#attrs)*
|
||||
#[allow(non_snake_case)]
|
||||
use super::#name;
|
||||
));
|
||||
|
||||
let mut mod_app = None;
|
||||
if !init.args.resources.is_empty() {
|
||||
|
|
@ -101,17 +87,13 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult {
|
|||
|
||||
root_init.push(item);
|
||||
mod_app = Some(constructor);
|
||||
|
||||
let name_late = format_ident!("{}Resources", name);
|
||||
user_init_imports.push(quote!(
|
||||
#[allow(non_snake_case)]
|
||||
use super::#name_late;
|
||||
));
|
||||
}
|
||||
|
||||
let app_name = &app.name;
|
||||
let app_path = quote! {crate::#app_name};
|
||||
let locals_new = locals_new.iter();
|
||||
let call_init = Some(
|
||||
quote!(let late = crate::#name(#(#locals_new,)* #name::Context::new(core.into()));),
|
||||
quote!(let late = #app_path::#name(#(#locals_new,)* #name::Context::new(core.into()));),
|
||||
);
|
||||
|
||||
root_init.push(module::codegen(
|
||||
|
|
@ -122,8 +104,8 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult {
|
|||
extra,
|
||||
));
|
||||
|
||||
(mod_app, root_init, user_init, user_init_imports, call_init)
|
||||
(mod_app, root_init, user_init, call_init)
|
||||
} else {
|
||||
(None, vec![], None, vec![], None)
|
||||
(None, vec![], None, None)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue