From 34b35d08be8e4eb1b32de6ca64ae5b8e9e518c01 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Sat, 18 Jan 2025 00:14:46 +0100 Subject: [PATCH] remove edn_ prefix from a couple macros --- edn/src/token.rs | 6 +++--- midi/src/midi_edit.rs | 4 ++-- midi/src/midi_pool.rs | 12 ++++++------ output/src/view.rs | 4 ++-- sampler/src/sampler.rs | 14 +++++++------- tek/src/lib.rs | 4 ++-- time/src/clock.rs | 4 ++-- tui/examples/tui.rs | 2 +- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/edn/src/token.rs b/edn/src/token.rs index e860813b..be7088ed 100644 --- a/edn/src/token.rs +++ b/edn/src/token.rs @@ -301,7 +301,7 @@ impl<'a, T: Context<'a, U>, U> Context<'a, U> for Option { } } /// 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 ($type:ty:|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => { impl<'a> Context<'a, $type> for $State { @@ -324,7 +324,7 @@ impl<'a, T: Context<'a, U>, U> Context<'a, U> for Option { /// Implement `Context` for a context and numeric type. /// /// 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. ($type:ty:|$self:ident:<$T:ident:$Trait:path>|{ $($pat:pat => $expr:expr),* $(,)? }) => { 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 { /// Implement `Context` for a context and content type. /// /// 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),* $(,)? }) => { impl<'a, E: Output> Context<'a, Box + 'a>> for $State { fn get (&'a $self, edn: &'a impl Atom<'a>) -> Option + 'a>> { diff --git a/midi/src/midi_edit.rs b/midi/src/midi_edit.rs index 24a8da3b..f63aee05 100644 --- a/midi/src/midi_edit.rs +++ b/midi/src/midi_edit.rs @@ -49,13 +49,13 @@ from!(|clip: Option>>|MidiEditor = { model.redraw(); model }); -edn_provide!(bool: |self: MidiEditor| { +provide!(bool: |self: MidiEditor| { ":true" => true, ":false" => false, ":time-lock" => 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-pos" => self.note_pos(), diff --git a/midi/src/midi_pool.rs b/midi/src/midi_pool.rs index e1901714..3d49bddd 100644 --- a/midi/src/midi_pool.rs +++ b/midi/src/midi_pool.rs @@ -220,7 +220,7 @@ handle!(TuiIn: |self: MidiPool, input|{ None }) }); -edn_provide!(bool: |self: MidiPool| {}); +provide!(bool: |self: MidiPool| {}); impl MidiPool { pub fn new_clip (&self) -> MidiClip { MidiClip::new("Clip", true, 4 * PPQ, None, Some(ItemPalette::random())) @@ -242,19 +242,19 @@ impl MidiPool { (index, clip) } } -edn_provide!(MidiClip: |self: MidiPool| { +provide!(MidiClip: |self: MidiPool| { ":new-clip" => self.new_clip(), ":cloned-clip" => self.cloned_clip(), }); -edn_provide!(PathBuf: |self: MidiPool| {}); -edn_provide!(Arc: |self: MidiPool| {}); -edn_provide!(usize: |self: MidiPool| { +provide!(PathBuf: |self: MidiPool| {}); +provide!(Arc: |self: MidiPool| {}); +provide!(usize: |self: MidiPool| { ":current" => 0, ":after" => 0, ":previous" => 0, ":next" => 0 }); -edn_provide!(ItemColor: |self: MidiPool| { +provide!(ItemColor: |self: MidiPool| { ":random-color" => ItemColor::random() }); #[derive(Clone, PartialEq, Debug)] pub enum PoolCommand { diff --git a/output/src/view.rs b/output/src/view.rs index 5c255223..fd9c8a0e 100644 --- a/output/src/view.rs +++ b/output/src/view.rs @@ -5,7 +5,7 @@ use std::{sync::Arc, marker::PhantomData}; /// This consists of: /// * render callback (implementation of [Content]) /// * value providers (implementations of [Context]) -#[macro_export] macro_rules! edn_view { +#[macro_export] macro_rules! view { ($Output:ty: |$self:ident: $App:ty| $content:expr; { $( $type:ty { $($sym:literal => $value:expr),* } );* }) => { @@ -22,7 +22,7 @@ use std::{sync::Arc, marker::PhantomData}; } } /// 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),* $(,)? }) => { impl<'a, E: Output> Context<'a, Box + 'a>> for $State { fn get (&'a $self, edn: &'a impl Atom<'a>) -> Option + 'a>> { diff --git a/sampler/src/sampler.rs b/sampler/src/sampler.rs index ba4682e8..22823b02 100644 --- a/sampler/src/sampler.rs +++ b/sampler/src/sampler.rs @@ -674,9 +674,9 @@ edn_command!(SamplerTuiCommand: |state: SamplerTui| { return None }) }); -edn_provide!(usize: |self: SamplerTui| {}); -edn_provide!(PathBuf: |self: SamplerTui| {}); -edn_provide!(Arc: |self: SamplerTui| {}); +provide!(usize: |self: SamplerTui| {}); +provide!(PathBuf: |self: SamplerTui| {}); +provide!(Arc: |self: SamplerTui| {}); edn_command!(FileBrowserCommand: |state: SamplerTui| { ("begin" [] Self::Begin) ("cancel" [] Self::Cancel) @@ -713,10 +713,10 @@ edn_command!(SamplerCommand: |state: Sampler| { ("note/off" [p: u7] Self::NoteOff(p.expect("no pitch"))) }); -edn_provide!(u7: |self: Sampler| {}); -edn_provide!(Option>>: |self: Sampler| {}); -edn_provide!(usize: |self: Sampler| {}); -edn_provide!(f32: |self: Sampler| {}); +provide!(u7: |self: Sampler| {}); +provide!(Option>>: |self: Sampler| {}); +provide!(usize: |self: Sampler| {}); +provide!(f32: |self: Sampler| {}); input_to_command!(FileBrowserCommand: |state:SamplerTui, input: Event|match input { _ => return None }); command!(|self: FileBrowserCommand,state:SamplerTui|match self { _ => todo!() }); //input_to_command!(SamplerTuiCommand: |state: SamplerTui, input: Event|match state.mode{ diff --git a/tek/src/lib.rs b/tek/src/lib.rs index b1b907e2..45f3fdaf 100644 --- a/tek/src/lib.rs +++ b/tek/src/lib.rs @@ -161,14 +161,14 @@ has_editor!(|self: Tek|{ }; editor_h = 15; 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-next" => (self.selected.scene().unwrap_or(0) + 1).min(self.scenes.len()), ":scene-prev" => self.selected.scene().unwrap_or(0).saturating_sub(1), ":track" => self.selected.track().unwrap_or(0), ":track-next" => (self.selected.track().unwrap_or(0) + 1).min(self.tracks.len()), ":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 {}; isize {}; Color {}; diff --git a/time/src/clock.rs b/time/src/clock.rs index 772053d6..d6b55b10 100644 --- a/time/src/clock.rs +++ b/time/src/clock.rs @@ -22,8 +22,8 @@ pub enum ClockCommand { SetQuant(f64), SetSync(f64), } -edn_provide_num!(u32: |self: Clock| {}); -edn_provide!(f64: |self: Clock| {}); +provide_num!(u32: |self: Clock| {}); +provide!(f64: |self: Clock| {}); edn_command!(ClockCommand: |state: Clock| { ("play" [] Self::Play(None)) ("play" [t: u32] Self::Play(t)) diff --git a/tui/examples/tui.rs b/tui/examples/tui.rs index b341f06e..842366a8 100644 --- a/tui/examples/tui.rs +++ b/tui/examples/tui.rs @@ -45,7 +45,7 @@ const EXAMPLES: &'static [&'static str] = &[ include_str!("edn12.edn"), include_str!("edn13.edn"), ]; -edn_view!(TuiOut: |self: Example|{ +view!(TuiOut: |self: Example|{ 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())))); let code = Tui::bg(Color::Rgb(10,60,10),