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 --- ext/tls/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'ext/tls/lib.rs') diff --git a/ext/tls/lib.rs b/ext/tls/lib.rs index fb4e8759d..123d35acf 100644 --- a/ext/tls/lib.rs +++ b/ext/tls/lib.rs @@ -10,7 +10,6 @@ use deno_core::anyhow::anyhow; use deno_core::error::custom_error; use deno_core::error::AnyError; use deno_core::parking_lot::Mutex; -use deno_core::Extension; use rustls::client::HandshakeSignatureValid; use rustls::client::ServerCertVerified; @@ -35,10 +34,8 @@ use std::io::Cursor; use std::sync::Arc; use std::time::SystemTime; -/// This extension has no runtime apis, it only exports some shared native functions. -pub fn init_ops() -> Extension { - Extension::builder(env!("CARGO_PKG_NAME")).build() -} +// This extension has no runtime apis, it only exports some shared native functions. +deno_core::extension!(deno_tls); struct DefaultSignatureVerification; -- cgit v1.2.3