|
|
@ -613,18 +613,39 @@ impl RawTracePoint {
|
|
|
|
|
|
|
|
|
|
|
|
pub struct Lsm {
|
|
|
|
pub struct Lsm {
|
|
|
|
item: ItemFn,
|
|
|
|
item: ItemFn,
|
|
|
|
name: String,
|
|
|
|
name: Option<String>,
|
|
|
|
|
|
|
|
sleepable: bool,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Lsm {
|
|
|
|
impl Lsm {
|
|
|
|
pub fn from_syn(mut args: Args, item: ItemFn) -> Result<Lsm> {
|
|
|
|
pub fn from_syn(mut args: Args, item: ItemFn) -> Result<Lsm> {
|
|
|
|
let name = name_arg(&mut args)?.unwrap_or_else(|| item.sig.ident.to_string());
|
|
|
|
let name = pop_arg(&mut args, "name");
|
|
|
|
|
|
|
|
let mut sleepable = false;
|
|
|
|
Ok(Lsm { item, name })
|
|
|
|
if let Some(s) = pop_arg(&mut args, "sleepable") {
|
|
|
|
|
|
|
|
if let Ok(m) = s.parse() {
|
|
|
|
|
|
|
|
sleepable = m
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return Err(Error::new_spanned(
|
|
|
|
|
|
|
|
"mutlibuffer",
|
|
|
|
|
|
|
|
"invalid value. should be 'true' or 'false'",
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
err_on_unknown_args(&args)?;
|
|
|
|
|
|
|
|
Ok(Lsm {
|
|
|
|
|
|
|
|
item,
|
|
|
|
|
|
|
|
name,
|
|
|
|
|
|
|
|
sleepable,
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn expand(&self) -> Result<TokenStream> {
|
|
|
|
pub fn expand(&self) -> Result<TokenStream> {
|
|
|
|
let section_name = format!("lsm/{}", self.name);
|
|
|
|
let section_prefix = if self.sleepable { "lsm.s" } else { "lsm" };
|
|
|
|
|
|
|
|
let section_name = if let Some(name) = &self.name {
|
|
|
|
|
|
|
|
format!("{section_prefix}/{name}")
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
section_prefix.to_string()
|
|
|
|
|
|
|
|
};
|
|
|
|
let fn_vis = &self.item.vis;
|
|
|
|
let fn_vis = &self.item.vis;
|
|
|
|
let fn_name = &self.item.sig.ident;
|
|
|
|
let fn_name = &self.item.sig.ident;
|
|
|
|
let item = &self.item;
|
|
|
|
let item = &self.item;
|
|
|
|