summaryrefslogtreecommitdiff
path: root/runtime/ops/process.rs
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 /runtime/ops/process.rs
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 'runtime/ops/process.rs')
-rw-r--r--runtime/ops/process.rs24
1 files changed, 11 insertions, 13 deletions
diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs
index 20db96af9..a15b63f80 100644
--- a/runtime/ops/process.rs
+++ b/runtime/ops/process.rs
@@ -7,7 +7,6 @@ use deno_core::op;
use deno_core::serde_json;
use deno_core::AsyncMutFuture;
use deno_core::AsyncRefCell;
-use deno_core::Extension;
use deno_core::OpState;
use deno_core::RcRef;
use deno_core::Resource;
@@ -99,18 +98,17 @@ impl StdioOrRid {
}
}
-pub fn init_ops() -> Extension {
- Extension::builder("deno_process")
- .ops(vec![
- op_spawn_child::decl(),
- op_spawn_wait::decl(),
- op_spawn_sync::decl(),
- deprecated::op_run::decl(),
- deprecated::op_run_status::decl(),
- deprecated::op_kill::decl(),
- ])
- .build()
-}
+deno_core::extension!(
+ deno_process,
+ ops = [
+ op_spawn_child,
+ op_spawn_wait,
+ op_spawn_sync,
+ deprecated::op_run,
+ deprecated::op_run_status,
+ deprecated::op_kill,
+ ]
+);
struct ChildResource(tokio::process::Child);