extern examples added

This commit is contained in:
Per Lindgren 2020-10-24 19:38:49 +02:00
parent d11b2ddd35
commit 0f8e173614
3 changed files with 32 additions and 27 deletions

View file

@ -22,5 +22,6 @@ proc-macro2 = "1"
proc-macro-error = "1" proc-macro-error = "1"
quote = "1" quote = "1"
syn = "1" syn = "1"
rtic-syntax = { git = "https://github.com/rtic-rs/rtic-syntax", branch = "master", version = "0.5.0-alpha.0" } #rtic-syntax = { git = "https://github.com/rtic-rs/rtic-syntax", branch = "master", version = "0.5.0-alpha.0" }
rtic-syntax = { git = "https://github.com/rtic-rs/rtic-syntax", branch = "extern_task", version = "0.5.0-alpha.0" }

View file

@ -95,19 +95,21 @@ pub fn codegen(
locals_pat = Some(pat); locals_pat = Some(pat);
} }
let attrs = &task.attrs; if !&task.is_extern {
let context = &task.context; let attrs = &task.attrs;
let stmts = &task.stmts; let context = &task.context;
let locals_pat = locals_pat.iter(); let stmts = &task.stmts;
user_tasks.push(quote!( let locals_pat = locals_pat.iter();
#(#attrs)* user_tasks.push(quote!(
#[allow(non_snake_case)] #(#attrs)*
fn #name(#(#locals_pat,)* #context: #name::Context) { #[allow(non_snake_case)]
use rtic::Mutex as _; fn #name(#(#locals_pat,)* #context: #name::Context) {
use rtic::Mutex as _;
#(#stmts)* #(#stmts)*
} }
)); ));
}
} }
(mod_app, root, user_tasks) (mod_app, root, user_tasks)

View file

@ -99,21 +99,23 @@ pub fn codegen(
root.push(struct_); root.push(struct_);
} }
let context = &task.context; if !&task.is_extern {
let attrs = &task.attrs; let context = &task.context;
let cfgs = &task.cfgs; let attrs = &task.attrs;
let stmts = &task.stmts; let cfgs = &task.cfgs;
let locals_pat = locals_pat.iter(); let stmts = &task.stmts;
user_tasks.push(quote!( let locals_pat = locals_pat.iter();
#(#attrs)* user_tasks.push(quote!(
#(#cfgs)* #(#attrs)*
#[allow(non_snake_case)] #(#cfgs)*
fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) { #[allow(non_snake_case)]
use rtic::Mutex as _; fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) {
use rtic::Mutex as _;
#(#stmts)* #(#stmts)*
} }
)); ));
}
root.push(module::codegen( root.push(module::codegen(
Context::SoftwareTask(name), Context::SoftwareTask(name),