From 8eccef7d9cda8a60594b86d31b656a3680d1ca16 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 26 Feb 2019 23:25:16 +0100 Subject: refactor: make `binds` harder to misuse --- macros/src/codegen.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'macros/src/codegen.rs') diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs index 0e25e8a..1d201c0 100644 --- a/macros/src/codegen.rs +++ b/macros/src/codegen.rs @@ -468,12 +468,8 @@ fn post_init(ctxt: &Context, app: &App, analysis: &Analysis) -> proc_macro2::Tok // the device into compile errors let device = &app.args.device; let nvic_prio_bits = quote!(#device::NVIC_PRIO_BITS); - for (name, exception) in &app.exceptions { - let name = if let Some(ref binds) = exception.args.binds { - binds - } else { - name - }; + for (handler, exception) in &app.exceptions { + let name = exception.args.binds(handler); let priority = exception.args.priority; exprs.push(quote!(assert!(#priority <= (1 << #nvic_prio_bits)))); exprs.push(quote!(p.SCB.set_priority( @@ -1128,7 +1124,7 @@ fn exceptions(ctxt: &mut Context, app: &App, analysis: &Analysis) -> Vec proc_macro2::Toke // the device into compile errors let device = &app.args.device; let nvic_prio_bits = quote!(#device::NVIC_PRIO_BITS); - for (name, interrupt) in &app.interrupts { - let name = if let Some(ref binds) = interrupt.args.binds { - binds - } else { - name - }; + for (handler, interrupt) in &app.interrupts { + let name = interrupt.args.binds(handler); let priority = interrupt.args.priority; exprs.push(quote!(p.NVIC.enable(#device::Interrupt::#name);)); exprs.push(quote!(assert!(#priority <= (1 << #nvic_prio_bits));)); -- cgit v1.2.3