Fix println expand function
This is similar to the `function_like::log::expand` function now.
use defmt_parser::ParserMode;
use proc_macro::TokenStream;
+use proc_macro2::TokenStream as TokenStream2;
use proc_macro_error::abort;
use quote::quote;
use syn::parse_macro_input;
@@ -8,8 +9,10 @@ use crate::construct;
use crate::function_like::log::{Args, Codegen};
pub(crate) fn expand(args: TokenStream) -> TokenStream {
- let args = parse_macro_input!(args as Args);
+ expand_parsed(parse_macro_input!(args as Args)).into()
+}
+pub(crate) fn expand_parsed(args: Args) -> TokenStream2 {
let format_string = args.format_string.value();
let fragments = match defmt_parser::parse(&format_string, ParserMode::Strict) {
Ok(args) => args,
@@ -27,14 +30,15 @@ pub(crate) fn expand(args: TokenStream) -> TokenStream {
args.format_string.span(),
);
- let format_tag = construct::interned_string(&format_string, "println", false);
+ let header = construct::interned_string(&format_string, "println", false);
quote!({
match (#(&(#formatting_exprs)),*) {
(#(#patterns),*) => {
- defmt::export::istr(&#format_tag);
+ defmt::export::acquire();
+ defmt::export::header(&#header);
#(#exprs;)*
+ defmt::export::release()
}
}
})
- .into()
}
