summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-02-04 19:22:23 +0100
committerLaurenz <laurmaedje@gmail.com>2020-02-04 19:22:23 +0100
commite63ce52ae0d929506a1fa238477f039d14d53813 (patch)
tree74dd8ce425dc368021c6495273acbdf2e736be68 /src/library
parent5c11aa72239ecbdd9577f027bdc7e9468d68414e (diff)
Merge `Parsed` and `Layouted` types into `Pass` with `Feedback` 🌝🎢🌚
Diffstat (limited to 'src/library')
-rw-r--r--src/library/font.rs32
-rw-r--r--src/library/layout.rs42
-rw-r--r--src/library/mod.rs4
-rw-r--r--src/library/page.rs24
-rw-r--r--src/library/spacing.rs18
5 files changed, 60 insertions, 60 deletions
diff --git a/src/library/font.rs b/src/library/font.rs
index 422a68f9..9c69e1dd 100644
--- a/src/library/font.rs
+++ b/src/library/font.rs
@@ -11,10 +11,10 @@ function! {
list: Vec<String>,
}
- parse(header, body, ctx, errors, decos) {
+ parse(header, body, ctx, f) {
FontFamilyFunc {
- body: body!(opt: body, ctx, errors, decos),
- list: header.args.pos.get_all::<StringLike>(errors)
+ body: body!(opt: body, ctx, f),
+ list: header.args.pos.get_all::<StringLike>(&mut f.errors)
.map(|s| s.0.to_lowercase())
.collect(),
}
@@ -37,11 +37,11 @@ function! {
style: Option<FontStyle>,
}
- parse(header, body, ctx, errors, decos) {
+ parse(header, body, ctx, f) {
FontStyleFunc {
- body: body!(opt: body, ctx, errors, decos),
- style: header.args.pos.get::<FontStyle>(errors)
- .or_missing(errors, header.name.span, "style"),
+ body: body!(opt: body, ctx, f),
+ style: header.args.pos.get::<FontStyle>(&mut f.errors)
+ .or_missing(&mut f.errors, header.name.span, "style"),
}
}
@@ -58,19 +58,19 @@ function! {
weight: Option<FontWeight>,
}
- parse(header, body, ctx, errors, decos) {
- let body = body!(opt: body, ctx, errors, decos);
- let weight = header.args.pos.get::<Spanned<(FontWeight, bool)>>(errors)
+ parse(header, body, ctx, f) {
+ let body = body!(opt: body, ctx, f);
+ let weight = header.args.pos.get::<Spanned<(FontWeight, bool)>>(&mut f.errors)
.map(|Spanned { v: (weight, is_clamped), span }| {
if is_clamped {
- errors.push(err!(@Warning: span;
+ f.errors.push(err!(@Warning: span;
"weight should be between \
100 and 900, clamped to {}", weight.0));
}
weight
})
- .or_missing(errors, header.name.span, "weight");
+ .or_missing(&mut f.errors, header.name.span, "weight");
FontWeightFunc { body, weight }
}
@@ -88,11 +88,11 @@ function! {
size: Option<FSize>,
}
- parse(header, body, ctx, errors, decos) {
+ parse(header, body, ctx, f) {
FontSizeFunc {
- body: body!(opt: body, ctx, errors, decos),
- size: header.args.pos.get::<FSize>(errors)
- .or_missing(errors, header.name.span, "size")
+ body: body!(opt: body, ctx, f),
+ size: header.args.pos.get::<FSize>(&mut f.errors)
+ .or_missing(&mut f.errors, header.name.span, "size")
}
}
diff --git a/src/library/layout.rs b/src/library/layout.rs
index 591ea2c0..da1652b0 100644
--- a/src/library/layout.rs
+++ b/src/library/layout.rs
@@ -10,17 +10,17 @@ function! {
map: PosAxisMap<AlignmentValue>,
}
- parse(header, body, ctx, errors, decos) {
+ parse(header, body, ctx, f) {
AlignFunc {
- body: body!(opt: body, ctx, errors, decos),
- map: PosAxisMap::parse::<AxisKey>(errors, &mut header.args),
+ body: body!(opt: body, ctx, f),
+ map: PosAxisMap::parse::<AxisKey>(&mut f.errors, &mut header.args),
}
}
- layout(self, ctx, errors) {
+ layout(self, ctx, f) {
ctx.base = ctx.spaces[0].dimensions;
- let map = self.map.dedup(errors, ctx.axes, |alignment| {
+ let map = self.map.dedup(&mut f.errors, ctx.axes, |alignment| {
alignment.axis().map(|s| s.to_generic(ctx.axes))
});
@@ -29,7 +29,7 @@ function! {
if let Some(generic) = alignment.to_generic(ctx.axes, axis) {
*ctx.alignment.get_mut(axis) = generic;
} else {
- errors.push(err!(span;
+ f.errors.push(err!(span;
"invalid alignment `{}` for {} axis", alignment, axis));
}
}
@@ -38,7 +38,7 @@ function! {
match &self.body {
Some(body) => {
let layouted = layout(body, ctx).await;
- errors.extend(layouted.errors);
+ f.extend(layouted.feedback);
vec![AddMultiple(layouted.output)]
}
None => vec![SetAlignment(ctx.alignment)],
@@ -55,18 +55,18 @@ function! {
map: PosAxisMap<Direction>,
}
- parse(header, body, ctx, errors, decos) {
+ parse(header, body, ctx, f) {
DirectionFunc {
name_span: header.name.span,
- body: body!(opt: body, ctx, errors, decos),
- map: PosAxisMap::parse::<AxisKey>(errors, &mut header.args),
+ body: body!(opt: body, ctx, f),
+ map: PosAxisMap::parse::<AxisKey>(&mut f.errors, &mut header.args),
}
}
- layout(self, ctx, errors) {
+ layout(self, ctx, f) {
ctx.base = ctx.spaces[0].dimensions;
- let map = self.map.dedup(errors, ctx.axes, |direction| {
+ let map = self.map.dedup(&mut f.errors, ctx.axes, |direction| {
Some(direction.axis().to_generic(ctx.axes))
});
@@ -76,7 +76,7 @@ function! {
map.with(Secondary, |&dir| axes.secondary = dir);
if axes.primary.axis() == axes.secondary.axis() {
- errors.push(err!(self.name_span;
+ f.errors.push(err!(self.name_span;
"invalid aligned primary and secondary axes: `{}`, `{}`",
ctx.axes.primary, ctx.axes.secondary));
} else {
@@ -86,7 +86,7 @@ function! {
match &self.body {
Some(body) => {
let layouted = layout(body, ctx).await;
- errors.extend(layouted.errors);
+ f.extend(layouted.feedback);
vec![AddMultiple(layouted.output)]
}
None => vec![SetAxes(ctx.axes)],
@@ -103,15 +103,15 @@ function! {
debug: Option<bool>,
}
- parse(header, body, ctx, errors, decos) {
+ parse(header, body, ctx, f) {
BoxFunc {
- body: body!(opt: body, ctx, errors, decos).unwrap_or(SyntaxModel::new()),
- extents: AxisMap::parse::<ExtentKey>(errors, &mut header.args.key),
- debug: header.args.key.get::<bool>(errors, "debug"),
+ body: body!(opt: body, ctx, f).unwrap_or(SyntaxModel::new()),
+ extents: AxisMap::parse::<ExtentKey>(&mut f.errors, &mut header.args.key),
+ debug: header.args.key.get::<bool>(&mut f.errors, "debug"),
}
}
- layout(self, ctx, errors) {
+ layout(self, ctx, f) {
ctx.repeat = false;
ctx.spaces.truncate(1);
@@ -119,7 +119,7 @@ function! {
ctx.debug = debug;
}
- let map = self.extents.dedup(errors, ctx.axes);
+ let map = self.extents.dedup(&mut f.errors, ctx.axes);
for &axis in &[Horizontal, Vertical] {
if let Some(psize) = map.get(axis) {
let size = psize.scaled(ctx.base.get(axis));
@@ -131,7 +131,7 @@ function! {
let layouted = layout(&self.body, ctx).await;
let layout = layouted.output.into_iter().next().unwrap();
- errors.extend(layouted.errors);
+ f.extend(layouted.feedback);
vec![Add(layout)]
}
diff --git a/src/library/mod.rs b/src/library/mod.rs
index f6666174..08dffdd7 100644
--- a/src/library/mod.rs
+++ b/src/library/mod.rs
@@ -53,8 +53,8 @@ function! {
body: Option<SyntaxModel>,
}
- parse(header, body, ctx, errors, decos) {
- ValFunc { body: body!(opt: body, ctx, errors, decos) }
+ parse(header, body, ctx, f) {
+ ValFunc { body: body!(opt: body, ctx, f) }
}
layout(self, ctx, errors) {
diff --git a/src/library/page.rs b/src/library/page.rs
index 084b3446..07e43026 100644
--- a/src/library/page.rs
+++ b/src/library/page.rs
@@ -12,16 +12,16 @@ function! {
flip: bool,
}
- parse(header, body, ctx, errors, decos) {
- body!(nope: body, errors);
+ parse(header, body, ctx, f) {
+ body!(nope: body, f);
PageSizeFunc {
- paper: header.args.pos.get::<Paper>(errors),
- extents: AxisMap::parse::<ExtentKey>(errors, &mut header.args.key),
- flip: header.args.key.get::<bool>(errors, "flip").unwrap_or(false),
+ paper: header.args.pos.get::<Paper>(&mut f.errors),
+ extents: AxisMap::parse::<ExtentKey>(&mut f.errors, &mut header.args.key),
+ flip: header.args.key.get::<bool>(&mut f.errors, "flip").unwrap_or(false),
}
}
- layout(self, ctx, errors) {
+ layout(self, ctx, f) {
let mut style = ctx.style.page;
if let Some(paper) = self.paper {
@@ -31,7 +31,7 @@ function! {
style.class = PaperClass::Custom;
}
- let map = self.extents.dedup(errors, ctx.axes);
+ let map = self.extents.dedup(&mut f.errors, ctx.axes);
map.with(Horizontal, |&width| style.dimensions.x = width);
map.with(Vertical, |&height| style.dimensions.y = height);
@@ -50,16 +50,16 @@ function! {
padding: PaddingMap,
}
- parse(header, body, ctx, errors, decos) {
- body!(nope: body, errors);
+ parse(header, body, ctx, f) {
+ body!(nope: body, f);
PageMarginsFunc {
- padding: PaddingMap::parse(errors, &mut header.args),
+ padding: PaddingMap::parse(&mut f.errors, &mut header.args),
}
}
- layout(self, ctx, errors) {
+ layout(self, ctx, f) {
let mut style = ctx.style.page;
- self.padding.apply(errors, ctx.axes, &mut style.margins);
+ self.padding.apply(&mut f.errors, ctx.axes, &mut style.margins);
vec![SetPageStyle(style)]
}
}
diff --git a/src/library/spacing.rs b/src/library/spacing.rs
index d77285c5..a6db162a 100644
--- a/src/library/spacing.rs
+++ b/src/library/spacing.rs
@@ -46,13 +46,13 @@ function! {
type Meta = ContentKind;
- parse(header, body, ctx, errors, decos, meta) {
+ parse(header, body, ctx, f, meta) {
ContentSpacingFunc {
- body: body!(opt: body, ctx, errors, decos),
+ body: body!(opt: body, ctx, f),
content: meta,
- spacing: header.args.pos.get::<f64>(errors)
+ spacing: header.args.pos.get::<f64>(&mut f.errors)
.map(|num| num as f32)
- .or_missing(errors, header.name.span, "spacing"),
+ .or_missing(&mut f.errors, header.name.span, "spacing"),
}
}
@@ -84,15 +84,15 @@ function! {
type Meta = Option<SpecificAxis>;
- parse(header, body, ctx, errors, decos, meta) {
- body!(nope: body, errors);
+ parse(header, body, ctx, f, meta) {
+ body!(nope: body, f);
SpacingFunc {
spacing: if let Some(axis) = meta {
- header.args.pos.get::<FSize>(errors)
+ header.args.pos.get::<FSize>(&mut f.errors)
.map(|s| (AxisKey::Specific(axis), s))
} else {
- header.args.key.get_with_key::<AxisKey, FSize>(errors)
- }.or_missing(errors, header.name.span, "spacing"),
+ header.args.key.get_with_key::<AxisKey, FSize>(&mut f.errors)
+ }.or_missing(&mut f.errors, header.name.span, "spacing"),
}
}