mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
load up to modes
the stacked modal music editor. lol
This commit is contained in:
parent
b991a49ad7
commit
4d4c470a81
7 changed files with 220 additions and 205 deletions
|
|
@ -1,8 +1,23 @@
|
|||
use crate::*;
|
||||
|
||||
/// Namespace. Currently linearly searched.
|
||||
pub struct DslNs<'t, T: 't>(pub &'t [(&'t str, T)]);
|
||||
|
||||
pub trait DslSymNs<'t, T: 't>: 't { const NS: DslNs<'t, fn (&'t Self)->T>; }
|
||||
/// Namespace where keys are symbols.
|
||||
pub trait DslSymNs<'t, T: 't>: 't {
|
||||
const NS: DslNs<'t, fn (&'t Self)->T>;
|
||||
fn from_sym <D: Dsl> (&'t self, dsl: D) -> Usually<T> {
|
||||
if let Some(dsl) = dsl.sym()? {
|
||||
for (sym, get) in Self::NS.0 {
|
||||
if dsl == *sym {
|
||||
return Ok(get(self))
|
||||
}
|
||||
}
|
||||
}
|
||||
return Err(format!("not found: sym: {dsl:?}").into())
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export] macro_rules! dsl_sym (
|
||||
(|$state:ident:$State:ty| -> $type:ty {$($lit:literal => $exp:expr),* $(,)?})=>{
|
||||
impl<'t> DslSymNs<'t, $type> for $State {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue