remove edn_ prefix from a couple macros

This commit is contained in:
🪞👃🪞 2025-01-18 00:14:46 +01:00
parent 798de37172
commit 34b35d08be
8 changed files with 25 additions and 25 deletions

View file

@ -301,7 +301,7 @@ impl<'a, T: Context<'a, U>, U> Context<'a, U> for Option<T> {
} }
} }
/// Implement `Context` for a context and type. /// Implement `Context` for a context and type.
#[macro_export] macro_rules! edn_provide { #[macro_export] macro_rules! provide {
// Provide a value to the EDN template // Provide a value to the EDN template
($type:ty:|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => { ($type:ty:|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => {
impl<'a> Context<'a, $type> for $State { impl<'a> Context<'a, $type> for $State {
@ -324,7 +324,7 @@ impl<'a, T: Context<'a, U>, U> Context<'a, U> for Option<T> {
/// Implement `Context` for a context and numeric type. /// Implement `Context` for a context and numeric type.
/// ///
/// This enables support for numeric literals. /// This enables support for numeric literals.
#[macro_export] macro_rules! edn_provide_num { #[macro_export] macro_rules! provide_num {
// Provide a value that may also be a numeric literal in the EDN, to a generic implementation. // Provide a value that may also be a numeric literal in the EDN, to a generic implementation.
($type:ty:|$self:ident:<$T:ident:$Trait:path>|{ $($pat:pat => $expr:expr),* $(,)? }) => { ($type:ty:|$self:ident:<$T:ident:$Trait:path>|{ $($pat:pat => $expr:expr),* $(,)? }) => {
impl<'a, $T: $Trait> Context<'a, $type> for $T { impl<'a, $T: $Trait> Context<'a, $type> for $T {
@ -347,7 +347,7 @@ impl<'a, T: Context<'a, U>, U> Context<'a, U> for Option<T> {
/// Implement `Context` for a context and content type. /// Implement `Context` for a context and content type.
/// ///
/// This enables support for layout expressions. /// This enables support for layout expressions.
#[macro_export] macro_rules! edn_provide_content { #[macro_export] macro_rules! provide_content {
(|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => { (|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => {
impl<'a, E: Output> Context<'a, Box<dyn Render<E> + 'a>> for $State { impl<'a, E: Output> Context<'a, Box<dyn Render<E> + 'a>> for $State {
fn get (&'a $self, edn: &'a impl Atom<'a>) -> Option<Box<dyn Render<E> + 'a>> { fn get (&'a $self, edn: &'a impl Atom<'a>) -> Option<Box<dyn Render<E> + 'a>> {

View file

@ -49,13 +49,13 @@ from!(|clip: Option<Arc<RwLock<MidiClip>>>|MidiEditor = {
model.redraw(); model.redraw();
model model
}); });
edn_provide!(bool: |self: MidiEditor| { provide!(bool: |self: MidiEditor| {
":true" => true, ":true" => true,
":false" => false, ":false" => false,
":time-lock" => self.time_lock().get(), ":time-lock" => self.time_lock().get(),
":time-lock-toggle" => !self.time_lock().get(), ":time-lock-toggle" => !self.time_lock().get(),
}); });
edn_provide!(usize: |self: MidiEditor| { provide!(usize: |self: MidiEditor| {
":note-length" => self.note_len(), ":note-length" => self.note_len(),
":note-pos" => self.note_pos(), ":note-pos" => self.note_pos(),

View file

@ -220,7 +220,7 @@ handle!(TuiIn: |self: MidiPool, input|{
None None
}) })
}); });
edn_provide!(bool: |self: MidiPool| {}); provide!(bool: |self: MidiPool| {});
impl MidiPool { impl MidiPool {
pub fn new_clip (&self) -> MidiClip { pub fn new_clip (&self) -> MidiClip {
MidiClip::new("Clip", true, 4 * PPQ, None, Some(ItemPalette::random())) MidiClip::new("Clip", true, 4 * PPQ, None, Some(ItemPalette::random()))
@ -242,19 +242,19 @@ impl MidiPool {
(index, clip) (index, clip)
} }
} }
edn_provide!(MidiClip: |self: MidiPool| { provide!(MidiClip: |self: MidiPool| {
":new-clip" => self.new_clip(), ":new-clip" => self.new_clip(),
":cloned-clip" => self.cloned_clip(), ":cloned-clip" => self.cloned_clip(),
}); });
edn_provide!(PathBuf: |self: MidiPool| {}); provide!(PathBuf: |self: MidiPool| {});
edn_provide!(Arc<str>: |self: MidiPool| {}); provide!(Arc<str>: |self: MidiPool| {});
edn_provide!(usize: |self: MidiPool| { provide!(usize: |self: MidiPool| {
":current" => 0, ":current" => 0,
":after" => 0, ":after" => 0,
":previous" => 0, ":previous" => 0,
":next" => 0 ":next" => 0
}); });
edn_provide!(ItemColor: |self: MidiPool| { provide!(ItemColor: |self: MidiPool| {
":random-color" => ItemColor::random() ":random-color" => ItemColor::random()
}); });
#[derive(Clone, PartialEq, Debug)] pub enum PoolCommand { #[derive(Clone, PartialEq, Debug)] pub enum PoolCommand {

View file

@ -5,7 +5,7 @@ use std::{sync::Arc, marker::PhantomData};
/// This consists of: /// This consists of:
/// * render callback (implementation of [Content]) /// * render callback (implementation of [Content])
/// * value providers (implementations of [Context]) /// * value providers (implementations of [Context])
#[macro_export] macro_rules! edn_view { #[macro_export] macro_rules! view {
($Output:ty: |$self:ident: $App:ty| $content:expr; { ($Output:ty: |$self:ident: $App:ty| $content:expr; {
$( $type:ty { $($sym:literal => $value:expr),* } );* $( $type:ty { $($sym:literal => $value:expr),* } );*
}) => { }) => {
@ -22,7 +22,7 @@ use std::{sync::Arc, marker::PhantomData};
} }
} }
/// Implements `Context` for content components and expressions /// Implements `Context` for content components and expressions
#[macro_export] macro_rules! edn_provide_content { #[macro_export] macro_rules! provide_content {
(|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => { (|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => {
impl<'a, E: Output> Context<'a, Box<dyn Render<E> + 'a>> for $State { impl<'a, E: Output> Context<'a, Box<dyn Render<E> + 'a>> for $State {
fn get (&'a $self, edn: &'a impl Atom<'a>) -> Option<Box<dyn Render<E> + 'a>> { fn get (&'a $self, edn: &'a impl Atom<'a>) -> Option<Box<dyn Render<E> + 'a>> {

View file

@ -674,9 +674,9 @@ edn_command!(SamplerTuiCommand: |state: SamplerTui| {
return None return None
}) })
}); });
edn_provide!(usize: |self: SamplerTui| {}); provide!(usize: |self: SamplerTui| {});
edn_provide!(PathBuf: |self: SamplerTui| {}); provide!(PathBuf: |self: SamplerTui| {});
edn_provide!(Arc<str>: |self: SamplerTui| {}); provide!(Arc<str>: |self: SamplerTui| {});
edn_command!(FileBrowserCommand: |state: SamplerTui| { edn_command!(FileBrowserCommand: |state: SamplerTui| {
("begin" [] Self::Begin) ("begin" [] Self::Begin)
("cancel" [] Self::Cancel) ("cancel" [] Self::Cancel)
@ -713,10 +713,10 @@ edn_command!(SamplerCommand: |state: Sampler| {
("note/off" [p: u7] ("note/off" [p: u7]
Self::NoteOff(p.expect("no pitch"))) Self::NoteOff(p.expect("no pitch")))
}); });
edn_provide!(u7: |self: Sampler| {}); provide!(u7: |self: Sampler| {});
edn_provide!(Option<Arc<RwLock<Sample>>>: |self: Sampler| {}); provide!(Option<Arc<RwLock<Sample>>>: |self: Sampler| {});
edn_provide!(usize: |self: Sampler| {}); provide!(usize: |self: Sampler| {});
edn_provide!(f32: |self: Sampler| {}); provide!(f32: |self: Sampler| {});
input_to_command!(FileBrowserCommand: |state:SamplerTui, input: Event|match input { _ => return None }); input_to_command!(FileBrowserCommand: |state:SamplerTui, input: Event|match input { _ => return None });
command!(|self: FileBrowserCommand,state:SamplerTui|match self { _ => todo!() }); command!(|self: FileBrowserCommand,state:SamplerTui|match self { _ => todo!() });
//input_to_command!(SamplerTuiCommand: |state: SamplerTui, input: Event|match state.mode{ //input_to_command!(SamplerTuiCommand: |state: SamplerTui, input: Event|match state.mode{

View file

@ -161,14 +161,14 @@ has_editor!(|self: Tek|{
}; };
editor_h = 15; editor_h = 15;
is_editing = self.editing.load(Relaxed); }); is_editing = self.editing.load(Relaxed); });
edn_provide_num!(usize: |self: Tek| { provide_num!(usize: |self: Tek| {
":scene" => self.selected.scene().unwrap_or(0), ":scene" => self.selected.scene().unwrap_or(0),
":scene-next" => (self.selected.scene().unwrap_or(0) + 1).min(self.scenes.len()), ":scene-next" => (self.selected.scene().unwrap_or(0) + 1).min(self.scenes.len()),
":scene-prev" => self.selected.scene().unwrap_or(0).saturating_sub(1), ":scene-prev" => self.selected.scene().unwrap_or(0).saturating_sub(1),
":track" => self.selected.track().unwrap_or(0), ":track" => self.selected.track().unwrap_or(0),
":track-next" => (self.selected.track().unwrap_or(0) + 1).min(self.tracks.len()), ":track-next" => (self.selected.track().unwrap_or(0) + 1).min(self.tracks.len()),
":track-prev" => self.selected.track().unwrap_or(0).saturating_sub(1) }); ":track-prev" => self.selected.track().unwrap_or(0).saturating_sub(1) });
edn_view!(TuiOut: |self: Tek| self.size.of(EdnView::from_source(self, self.edn.as_ref())); { view!(TuiOut: |self: Tek| self.size.of(EdnView::from_source(self, self.edn.as_ref())); {
bool {}; bool {};
isize {}; isize {};
Color {}; Color {};

View file

@ -22,8 +22,8 @@ pub enum ClockCommand {
SetQuant(f64), SetQuant(f64),
SetSync(f64), SetSync(f64),
} }
edn_provide_num!(u32: |self: Clock| {}); provide_num!(u32: |self: Clock| {});
edn_provide!(f64: |self: Clock| {}); provide!(f64: |self: Clock| {});
edn_command!(ClockCommand: |state: Clock| { edn_command!(ClockCommand: |state: Clock| {
("play" [] Self::Play(None)) ("play" [] Self::Play(None))
("play" [t: u32] Self::Play(t)) ("play" [t: u32] Self::Play(t))

View file

@ -45,7 +45,7 @@ const EXAMPLES: &'static [&'static str] = &[
include_str!("edn12.edn"), include_str!("edn12.edn"),
include_str!("edn13.edn"), include_str!("edn13.edn"),
]; ];
edn_view!(TuiOut: |self: Example|{ view!(TuiOut: |self: Example|{
let title = Tui::bg(Color::Rgb(60,10,10), let title = Tui::bg(Color::Rgb(60,10,10),
Push::y(1, Align::n(format!("Example {}/{} in {:?}", self.0 + 1, EXAMPLES.len(), &self.1.wh())))); Push::y(1, Align::n(format!("Example {}/{} in {:?}", self.0 + 1, EXAMPLES.len(), &self.1.wh()))));
let code = Tui::bg(Color::Rgb(10,60,10), let code = Tui::bg(Color::Rgb(10,60,10),