mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-19 06:15:45 +01:00
Add rtic-timer (timerqueue + monotonic) and rtic-monotonics (systick-monotonic)
This commit is contained in:
parent
b8b881f446
commit
306aa47170
276 changed files with 607 additions and 713 deletions
55
rtic/macros/src/syntax/parse/resource.rs
Normal file
55
rtic/macros/src/syntax/parse/resource.rs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
use proc_macro2::Span;
|
||||
use syn::{parse, Field, Visibility};
|
||||
|
||||
use crate::syntax::parse::util::FilterAttrs;
|
||||
use crate::syntax::{
|
||||
ast::{LocalResource, SharedResource, SharedResourceProperties},
|
||||
parse::util,
|
||||
};
|
||||
|
||||
impl SharedResource {
|
||||
pub(crate) fn parse(item: &Field, span: Span) -> parse::Result<Self> {
|
||||
if item.vis != Visibility::Inherited {
|
||||
return Err(parse::Error::new(
|
||||
span,
|
||||
"this field must have inherited / private visibility",
|
||||
));
|
||||
}
|
||||
|
||||
let FilterAttrs {
|
||||
cfgs,
|
||||
mut attrs,
|
||||
docs,
|
||||
} = util::filter_attributes(item.attrs.clone());
|
||||
|
||||
let lock_free = util::extract_lock_free(&mut attrs)?;
|
||||
|
||||
Ok(SharedResource {
|
||||
cfgs,
|
||||
attrs,
|
||||
docs,
|
||||
ty: Box::new(item.ty.clone()),
|
||||
properties: SharedResourceProperties { lock_free },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl LocalResource {
|
||||
pub(crate) fn parse(item: &Field, span: Span) -> parse::Result<Self> {
|
||||
if item.vis != Visibility::Inherited {
|
||||
return Err(parse::Error::new(
|
||||
span,
|
||||
"this field must have inherited / private visibility",
|
||||
));
|
||||
}
|
||||
|
||||
let FilterAttrs { cfgs, attrs, docs } = util::filter_attributes(item.attrs.clone());
|
||||
|
||||
Ok(LocalResource {
|
||||
cfgs,
|
||||
attrs,
|
||||
docs,
|
||||
ty: Box::new(item.ty.clone()),
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue