swc_css_codegen/
macros.rs

1macro_rules! emit {
2    ($g:expr,$n:expr) => {{
3        use crate::Emit;
4
5        $g.emit(&$n)?;
6    }};
7}
8
9macro_rules! write_raw {
10    ($g:expr,$span:expr,$n:expr) => {{
11        $g.wr.write_raw(Some($span), $n)?;
12    }};
13
14    ($g:expr,$n:expr) => {{
15        $g.wr.write_raw(None, $n)?;
16    }};
17}
18
19macro_rules! write_str {
20    ($g:expr,$span:expr,$n:expr) => {{
21        $g.wr.write_str($span, $n)?;
22    }};
23}
24
25macro_rules! formatting_newline {
26    ($g:expr) => {{
27        if !$g.config.minify {
28            $g.wr.write_newline()?;
29        }
30    }};
31}
32
33macro_rules! space {
34    ($g:expr) => {{
35        $g.wr.write_space()?;
36    }};
37}
38
39macro_rules! formatting_space {
40    ($g:expr) => {{
41        if !$g.config.minify {
42            $g.wr.write_space()?;
43        }
44    }};
45}
46
47macro_rules! semi {
48    ($g:expr) => {{
49        write_raw!($g, ";");
50    }};
51}
52
53macro_rules! formatting_semi {
54    ($g:expr) => {{
55        if !$g.config.minify {
56            write_raw!($g, ";");
57        }
58    }};
59}
60
61macro_rules! increase_indent {
62    ($g:expr) => {{
63        if !$g.config.minify {
64            $g.wr.increase_indent();
65        }
66    }};
67}
68
69macro_rules! decrease_indent {
70    ($g:expr) => {{
71        if !$g.config.minify {
72            $g.wr.decrease_indent();
73        }
74    }};
75}
76macro_rules! lo_span_offset {
77    ($s:expr,$o:expr) => {{
78        if $s.is_dummy() {
79            DUMMY_SP
80        } else {
81            Span::new($s.lo, $s.lo + BytePos($o))
82        }
83    }};
84}
85
86macro_rules! hi_span_offset {
87    ($s:expr,$o:expr) => {{
88        if $s.is_dummy() {
89            DUMMY_SP
90        } else {
91            Span::new($s.hi - BytePos($o), $s.hi)
92        }
93    }};
94}