diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-03-17 12:22:15 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-17 18:22:15 +0000 |
commit | e55b448730160a6e4df9815a268d4049ac89deab (patch) | |
tree | 35d80fd60f2f1d1d06903caff256484a7d703d76 /ext/web/benches/encoding.rs | |
parent | 0bc6bf5d33b8198253954d7f04558270de45c925 (diff) |
feat(core) deno_core::extension! macro to simplify extension registration (#18210)
This implements two macros to simplify extension registration and centralize a lot of the boilerplate as a base for future improvements:
* `deno_core::ops!` registers a block of `#[op]`s, optionally with type
parameters, useful for places where we share lists of ops
* `deno_core::extension!` is used to register an extension, and creates
two methods that can be used at runtime/snapshot generation time:
`init_ops` and `init_ops_and_esm`.
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/web/benches/encoding.rs')
-rw-r--r-- | ext/web/benches/encoding.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/web/benches/encoding.rs b/ext/web/benches/encoding.rs index feb309785..2deba07f3 100644 --- a/ext/web/benches/encoding.rs +++ b/ext/web/benches/encoding.rs @@ -10,6 +10,7 @@ use deno_core::ExtensionFileSourceCode; use deno_core::OpState; use deno_web::BlobStore; +#[derive(Clone)] struct Permissions; impl deno_web::TimersPermission for Permissions { @@ -23,10 +24,13 @@ impl deno_web::TimersPermission for Permissions { fn setup() -> Vec<Extension> { vec![ - deno_webidl::init_esm(), - deno_url::init_ops_and_esm(), - deno_console::init_esm(), - deno_web::init_ops_and_esm::<Permissions>(BlobStore::default(), None), + deno_webidl::deno_webidl::init_ops_and_esm(), + deno_url::deno_url::init_ops_and_esm(), + deno_console::deno_console::init_ops_and_esm(), + deno_web::deno_web::init_ops_and_esm::<Permissions>( + BlobStore::default(), + None, + ), Extension::builder("bench_setup") .esm(vec![ExtensionFileSource { specifier: "ext:setup".to_string(), |