From c010cbc17dcbb2f0d6005d21530143bf57cb5871 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 25 May 2022 13:50:33 +0200 Subject: Move route from context to VM --- src/library/layout/align.rs | 2 +- src/library/layout/columns.rs | 4 ++-- src/library/layout/container.rs | 4 ++-- src/library/layout/grid.rs | 2 +- src/library/layout/pad.rs | 2 +- src/library/layout/page.rs | 10 +++++----- src/library/layout/place.rs | 2 +- src/library/layout/spacing.rs | 4 ++-- src/library/layout/stack.rs | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/library/layout') diff --git a/src/library/layout/align.rs b/src/library/layout/align.rs index c050d2a4..c0a7d16c 100644 --- a/src/library/layout/align.rs +++ b/src/library/layout/align.rs @@ -12,7 +12,7 @@ pub struct AlignNode { #[node] impl AlignNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult { + fn construct(_: &mut Machine, args: &mut Args) -> TypResult { let aligns: Spec> = args.find()?.unwrap_or_default(); let body: Content = args.expect("body")?; Ok(match (body, aligns) { diff --git a/src/library/layout/columns.rs b/src/library/layout/columns.rs index 8e523694..4c842261 100644 --- a/src/library/layout/columns.rs +++ b/src/library/layout/columns.rs @@ -17,7 +17,7 @@ impl ColumnsNode { #[property(resolve)] pub const GUTTER: Relative = Ratio::new(0.04).into(); - fn construct(_: &mut Context, args: &mut Args) -> TypResult { + fn construct(_: &mut Machine, args: &mut Args) -> TypResult { Ok(Content::block(Self { columns: args.expect("column count")?, child: args.expect("body")?, @@ -106,7 +106,7 @@ pub struct ColbreakNode; #[node] impl ColbreakNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult { + fn construct(_: &mut Machine, args: &mut Args) -> TypResult { let weak = args.named("weak")?.unwrap_or(false); Ok(Content::Colbreak { weak }) } diff --git a/src/library/layout/container.rs b/src/library/layout/container.rs index 5264f258..df03ac91 100644 --- a/src/library/layout/container.rs +++ b/src/library/layout/container.rs @@ -5,7 +5,7 @@ pub struct BoxNode; #[node] impl BoxNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult { + fn construct(_: &mut Machine, args: &mut Args) -> TypResult { let width = args.named("width")?; let height = args.named("height")?; let body: LayoutNode = args.eat()?.unwrap_or_default(); @@ -18,7 +18,7 @@ pub struct BlockNode; #[node] impl BlockNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult { + fn construct(_: &mut Machine, args: &mut Args) -> TypResult { Ok(Content::Block(args.eat()?.unwrap_or_default())) } } diff --git a/src/library/layout/grid.rs b/src/library/layout/grid.rs index 8ecac636..5b621732 100644 --- a/src/library/layout/grid.rs +++ b/src/library/layout/grid.rs @@ -13,7 +13,7 @@ pub struct GridNode { #[node] impl GridNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult { + fn construct(_: &mut Machine, args: &mut Args) -> TypResult { let columns = args.named("columns")?.unwrap_or_default(); let rows = args.named("rows")?.unwrap_or_default(); let base_gutter: Vec = args.named("gutter")?.unwrap_or_default(); diff --git a/src/library/layout/pad.rs b/src/library/layout/pad.rs index aff0e8b0..97b760e1 100644 --- a/src/library/layout/pad.rs +++ b/src/library/layout/pad.rs @@ -11,7 +11,7 @@ pub struct PadNode { #[node] impl PadNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult { + fn construct(_: &mut Machine, args: &mut Args) -> TypResult { let all = args.named("rest")?.or(args.find()?); let x = args.named("x")?; let y = args.named("y")?; diff --git a/src/library/layout/page.rs b/src/library/layout/page.rs index 8db1329f..7d91aa6d 100644 --- a/src/library/layout/page.rs +++ b/src/library/layout/page.rs @@ -35,7 +35,7 @@ impl PageNode { #[property(referenced)] pub const FOOTER: Marginal = Marginal::None; - fn construct(_: &mut Context, args: &mut Args) -> TypResult { + fn construct(_: &mut Machine, args: &mut Args) -> TypResult { Ok(Content::Page(Self(args.expect("body")?))) } @@ -109,7 +109,7 @@ impl PageNode { let w = size.x - padding.left - padding.right; let area = Size::new(w, h); let pod = Regions::one(area, area, area.map(Length::is_finite)); - let sub = Layout::layout(&content, ctx, &pod, styles)?.remove(0); + let sub = content.layout(ctx, &pod, styles)?.remove(0); Arc::make_mut(frame).push_frame(pos, sub); } } @@ -134,7 +134,7 @@ pub struct PagebreakNode; #[node] impl PagebreakNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult { + fn construct(_: &mut Machine, args: &mut Args) -> TypResult { let weak = args.named("weak")?.unwrap_or(false); Ok(Content::Pagebreak { weak }) } @@ -158,8 +158,8 @@ impl Marginal { Self::None => None, Self::Content(content) => Some(content.clone()), Self::Func(func, span) => { - let args = Args::from_values(*span, [Value::Int(page as i64)]); - Some(func.call(ctx, args)?.display()) + let args = Args::new(*span, [Value::Int(page as i64)]); + Some(func.call_detached(ctx, args)?.display()) } }) } diff --git a/src/library/layout/place.rs b/src/library/layout/place.rs index e74776db..408ca129 100644 --- a/src/library/layout/place.rs +++ b/src/library/layout/place.rs @@ -7,7 +7,7 @@ pub struct PlaceNode(pub LayoutNode); #[node] impl PlaceNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult { + fn construct(_: &mut Machine, args: &mut Args) -> TypResult { let aligns = args.find()?.unwrap_or(Spec::with_x(Some(RawAlign::Start))); let dx = args.named("dx")?.unwrap_or_default(); let dy = args.named("dy")?.unwrap_or_default(); diff --git a/src/library/layout/spacing.rs b/src/library/layout/spacing.rs index 8a96e378..da4a96b6 100644 --- a/src/library/layout/spacing.rs +++ b/src/library/layout/spacing.rs @@ -8,7 +8,7 @@ pub struct HNode; #[node] impl HNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult { + fn construct(_: &mut Machine, args: &mut Args) -> TypResult { let amount = args.expect("spacing")?; let weak = args.named("weak")?.unwrap_or(false); Ok(Content::Horizontal { amount, weak }) @@ -20,7 +20,7 @@ pub struct VNode; #[node] impl VNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult { + fn construct(_: &mut Machine, args: &mut Args) -> TypResult { let amount = args.expect("spacing")?; let weak = args.named("weak")?.unwrap_or(false); Ok(Content::Vertical { amount, weak, generated: false }) diff --git a/src/library/layout/stack.rs b/src/library/layout/stack.rs index bbfeeab0..828ff8e3 100644 --- a/src/library/layout/stack.rs +++ b/src/library/layout/stack.rs @@ -15,7 +15,7 @@ pub struct StackNode { #[node] impl StackNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult { + fn construct(_: &mut Machine, args: &mut Args) -> TypResult { Ok(Content::block(Self { dir: args.named("dir")?.unwrap_or(Dir::TTB), spacing: args.named("spacing")?, -- cgit v1.2.3