Compare commits

...

2 commits

Author SHA1 Message Date
same mf who else
b4ebdb8ff8 fix some warnings
Some checks are pending
/ build (push) Waiting to run
2026-02-21 00:48:41 +02:00
same mf who else
7a8365c017 refactor: Namespace::resolve* -> Namespace::namespace* 2026-02-20 22:58:23 +02:00
4 changed files with 17 additions and 20 deletions

View file

@ -15,7 +15,7 @@ pub(crate) use std::ops::{Add, Sub, Mul, Div};
pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicUsize, Ordering::Relaxed}}; pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicUsize, Ordering::Relaxed}};
pub(crate) use std::marker::PhantomData; pub(crate) use std::marker::PhantomData;
pub(crate) use dizzle::*; pub(crate) use dizzle::*;
pub(crate) use quanta::Clock; //pub(crate) use quanta::Clock;
pub(crate) use atomic_float::AtomicF64; pub(crate) use atomic_float::AtomicF64;
// Define macros first, so that private macros are available in private modules: // Define macros first, so that private macros are available in private modules:
@ -189,12 +189,12 @@ pub fn evaluate_output_expression <'a, O: Out + 'a, S> (
match frags.next() { match frags.next() {
Some("when") => output.place(&When::new( Some("when") => output.place(&When::new(
state.resolve(arg0?)?.unwrap(), state.namespace(arg0?)?.unwrap(),
Thunk::new(move|output: &mut O|state.view(output, &arg1).unwrap()) Thunk::new(move|output: &mut O|state.view(output, &arg1).unwrap())
)), )),
Some("either") => output.place(&Either::new( Some("either") => output.place(&Either::new(
state.resolve(arg0?)?.unwrap(), state.namespace(arg0?)?.unwrap(),
Thunk::new(move|output: &mut O|state.view(output, &arg1).unwrap()), Thunk::new(move|output: &mut O|state.view(output, &arg1).unwrap()),
Thunk::new(move|output: &mut O|state.view(output, &arg2).unwrap()) Thunk::new(move|output: &mut O|state.view(output, &arg2).unwrap())
)), )),
@ -242,9 +242,9 @@ pub fn evaluate_output_expression <'a, O: Out + 'a, S> (
let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") }; let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") };
let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap()); let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap());
match axis { match axis {
Some("xy") | None => Fixed::XY(state.resolve(arg0?)?.unwrap(), state.resolve(arg1?)?.unwrap(), cb), Some("xy") | None => Fixed::XY(state.namespace(arg0?)?.unwrap(), state.namespace(arg1?)?.unwrap(), cb),
Some("x") => Fixed::X(state.resolve(arg0?)?.unwrap(), cb), Some("x") => Fixed::X(state.namespace(arg0?)?.unwrap(), cb),
Some("y") => Fixed::Y(state.resolve(arg0?)?.unwrap(), cb), Some("y") => Fixed::Y(state.namespace(arg0?)?.unwrap(), cb),
frag => unimplemented!("fixed/{frag:?} ({expr:?}) ({head:?}) ({:?})", frag => unimplemented!("fixed/{frag:?} ({expr:?}) ({head:?}) ({:?})",
head.src()?.unwrap_or_default().split("/").next()) head.src()?.unwrap_or_default().split("/").next())
} }
@ -255,9 +255,9 @@ pub fn evaluate_output_expression <'a, O: Out + 'a, S> (
let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") }; let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") };
let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap()); let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap());
match axis { match axis {
Some("xy") | None => Min::XY(state.resolve(arg0?)?.unwrap(), state.resolve(arg1?)?.unwrap(), cb), Some("xy") | None => Min::XY(state.namespace(arg0?)?.unwrap(), state.namespace(arg1?)?.unwrap(), cb),
Some("x") => Min::X(state.resolve(arg0?)?.unwrap(), cb), Some("x") => Min::X(state.namespace(arg0?)?.unwrap(), cb),
Some("y") => Min::Y(state.resolve(arg0?)?.unwrap(), cb), Some("y") => Min::Y(state.namespace(arg0?)?.unwrap(), cb),
frag => unimplemented!("min/{frag:?}") frag => unimplemented!("min/{frag:?}")
} }
}), }),
@ -267,9 +267,9 @@ pub fn evaluate_output_expression <'a, O: Out + 'a, S> (
let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") }; let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") };
let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap()); let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap());
match axis { match axis {
Some("xy") | None => Max::XY(state.resolve(arg0?)?.unwrap(), state.resolve(arg1?)?.unwrap(), cb), Some("xy") | None => Max::XY(state.namespace(arg0?)?.unwrap(), state.namespace(arg1?)?.unwrap(), cb),
Some("x") => Max::X(state.resolve(arg0?)?.unwrap(), cb), Some("x") => Max::X(state.namespace(arg0?)?.unwrap(), cb),
Some("y") => Max::Y(state.resolve(arg0?)?.unwrap(), cb), Some("y") => Max::Y(state.namespace(arg0?)?.unwrap(), cb),
frag => unimplemented!("max/{frag:?}") frag => unimplemented!("max/{frag:?}")
} }
}), }),
@ -279,9 +279,9 @@ pub fn evaluate_output_expression <'a, O: Out + 'a, S> (
let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") }; let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") };
let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap()); let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap());
match axis { match axis {
Some("xy") | None => Push::XY(state.resolve(arg0?)?.unwrap(), state.resolve(arg1?)?.unwrap(), cb), Some("xy") | None => Push::XY(state.namespace(arg0?)?.unwrap(), state.namespace(arg1?)?.unwrap(), cb),
Some("x") => Push::X(state.resolve(arg0?)?.unwrap(), cb), Some("x") => Push::X(state.namespace(arg0?)?.unwrap(), cb),
Some("y") => Push::Y(state.resolve(arg0?)?.unwrap(), cb), Some("y") => Push::Y(state.namespace(arg0?)?.unwrap(), cb),
frag => unimplemented!("push/{frag:?}") frag => unimplemented!("push/{frag:?}")
} }
}), }),

View file

@ -1,5 +1,4 @@
use crate::*; use crate::*;
use Direction::*;
use Alignment::*; use Alignment::*;
impl Coord for u16 { impl Coord for u16 {

View file

@ -76,8 +76,6 @@ pub trait View<O, U> {
Err(format!("View::view_word: no words defined: {word:?}").into()) Err(format!("View::view_word: no words defined: {word:?}").into())
} }
fn view <'a> (&'a self, output: &mut O, dsl: &'a impl Language) -> Usually<U> { fn view <'a> (&'a self, output: &mut O, dsl: &'a impl Language) -> Usually<U> {
let is_expr = dsl.expr();
let is_word = dsl.word();
match (dsl.expr(), dsl.word()) { match (dsl.expr(), dsl.word()) {
(Ok(Some(e)), _ ) => self.view_expr(output, &e), (Ok(Some(e)), _ ) => self.view_expr(output, &e),
(_, Ok(Some(w))) => self.view_word(output, &w), (_, Ok(Some(w))) => self.view_word(output, &w),

View file

@ -262,7 +262,7 @@ pub fn tui_input <T: Handle<TuiIn> + Send + Sync + 'static> (
Some("fg") => { Some("fg") => {
let arg0 = arg0?.expect("fg: expected arg 0 (color)"); let arg0 = arg0?.expect("fg: expected arg 0 (color)");
output.place(&Tui::fg( output.place(&Tui::fg(
Namespace::<Color>::resolve(state, arg0)?.unwrap_or_else(||panic!("fg: {arg0:?}: not a color")), Namespace::<Color>::namespace(state, arg0)?.unwrap_or_else(||panic!("fg: {arg0:?}: not a color")),
Thunk::new(move|output: &mut TuiOut|state.view(output, &arg1).unwrap()), Thunk::new(move|output: &mut TuiOut|state.view(output, &arg1).unwrap()),
)) ))
}, },
@ -270,7 +270,7 @@ pub fn tui_input <T: Handle<TuiIn> + Send + Sync + 'static> (
Some("bg") => { Some("bg") => {
let arg0 = arg0?.expect("bg: expected arg 0 (color)"); let arg0 = arg0?.expect("bg: expected arg 0 (color)");
output.place(&Tui::bg( output.place(&Tui::bg(
Namespace::<Color>::resolve(state, arg0)?.unwrap_or_else(||panic!("bg: {arg0:?}: not a color")), Namespace::<Color>::namespace(state, arg0)?.unwrap_or_else(||panic!("bg: {arg0:?}: not a color")),
Thunk::new(move|output: &mut TuiOut|state.view(output, &arg1).unwrap()), Thunk::new(move|output: &mut TuiOut|state.view(output, &arg1).unwrap()),
)) ))
}, },