summaryrefslogtreecommitdiff
path: root/ext/webidl
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-03-17 12:22:15 -0600
committerGitHub <noreply@github.com>2023-03-17 18:22:15 +0000
commite55b448730160a6e4df9815a268d4049ac89deab (patch)
tree35d80fd60f2f1d1d06903caff256484a7d703d76 /ext/webidl
parent0bc6bf5d33b8198253954d7f04558270de45c925 (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/webidl')
-rw-r--r--ext/webidl/benches/dict.rs2
-rw-r--r--ext/webidl/lib.rs13
2 files changed, 2 insertions, 13 deletions
diff --git a/ext/webidl/benches/dict.rs b/ext/webidl/benches/dict.rs
index 2ed9adf78..89a83ddaa 100644
--- a/ext/webidl/benches/dict.rs
+++ b/ext/webidl/benches/dict.rs
@@ -11,7 +11,7 @@ use deno_core::ExtensionFileSourceCode;
fn setup() -> Vec<Extension> {
vec![
- deno_webidl::init_esm(),
+ deno_webidl::deno_webidl::init_ops_and_esm(),
Extension::builder("deno_webidl_bench")
.esm(vec![ExtensionFileSource {
specifier: "ext:setup".to_string(),
diff --git a/ext/webidl/lib.rs b/ext/webidl/lib.rs
index 42559e501..332bea815 100644
--- a/ext/webidl/lib.rs
+++ b/ext/webidl/lib.rs
@@ -1,14 +1,3 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-use deno_core::include_js_files;
-use deno_core::Extension;
-
-pub fn init() -> Extension {
- Extension::builder(env!("CARGO_PKG_NAME")).build()
-}
-
-pub fn init_esm() -> Extension {
- Extension::builder(env!("CARGO_PKG_NAME"))
- .esm(include_js_files!("00_webidl.js",))
- .build()
-}
+deno_core::extension!(deno_webidl, esm = ["00_webidl.js"],);