rquickjs_extension/macros.rs
1#[macro_export]
2macro_rules! globals_only {
3 ($name:ident, |$globals:ident| { $($t:tt)* }) => {
4 impl Extension for $name {
5 type Implementation = GlobalsOnly;
6
7 fn globals(globals: &Object<'_>, _options: &()) -> Result<()> {
8 (|$globals: &Object<'_>| {
9 $($t)*
10 })(globals)
11 }
12
13 fn implementation() -> &'static Self::Implementation {
14 &GlobalsOnly
15 }
16
17 fn options(self) -> () {}
18 }
19 };
20}