summaryrefslogtreecommitdiff
path: root/src/library/mod.rs
blob: 191a3920ba0faa02d90d67fda5d9081d63997d61 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! The standard library.

mod align;
mod boxed;
mod color;
mod font;
mod page;
mod spacing;

pub use align::*;
pub use boxed::*;
pub use color::*;
pub use font::*;
pub use page::*;
pub use spacing::*;

use crate::eval::{Scope, ValueFunc};

macro_rules! std {
    ($($name:literal => $func:expr),* $(,)?) => {
        /// Create a scope with all standard library functions.
        pub fn _std() -> Scope {
            let mut std = Scope::new();
            $(std.set($name, ValueFunc::new(|args, ctx| Box::pin($func(args, ctx))));)*
            std
        }
    };
}

std! {
    "align" => align,
    "box" => boxed,
    "font" => font,
    "h" => h,
    "page" => page,
    "pagebreak" => pagebreak,
    "rgb" => rgb,
    "v" => v,
}