From e55b448730160a6e4df9815a268d4049ac89deab Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Fri, 17 Mar 2023 12:22:15 -0600 Subject: feat(core) deno_core::extension! macro to simplify extension registration (#18210) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- bench_util/benches/op_baseline.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'bench_util') diff --git a/bench_util/benches/op_baseline.rs b/bench_util/benches/op_baseline.rs index 8ed678b88..89fb3d2f3 100644 --- a/bench_util/benches/op_baseline.rs +++ b/bench_util/benches/op_baseline.rs @@ -9,14 +9,10 @@ use deno_bench_util::bencher::Bencher; use deno_core::op; use deno_core::Extension; +deno_core::extension!(bench_setup, ops = [op_pi_json, op_pi_async, op_nop]); + fn setup() -> Vec { - vec![Extension::builder("bench_setup") - .ops(vec![ - op_pi_json::decl(), - op_pi_async::decl(), - op_nop::decl(), - ]) - .build()] + vec![bench_setup::init_ops()] } #[op] -- cgit v1.2.3