summaryrefslogtreecommitdiff
path: root/src/library/mod.rs
blob: bd1feebb9edd04f2f3ea12193ece51f8b1084e85 (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
//! The standard library.

mod insert;
mod layout;
mod style;

pub use insert::*;
pub use layout::*;
pub use style::*;

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

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

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