summaryrefslogtreecommitdiff
path: root/core/ops_builtin.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-03-09 20:22:27 -0400
committerGitHub <noreply@github.com>2023-03-09 19:22:27 -0500
commitd1685b120bf7da5ba384806153f65d90ef156b77 (patch)
tree155c87f1beae810f52fb2a9ef9ab7526fa1af990 /core/ops_builtin.rs
parent78d430103a8f6931154ddbbe19d36f3b8630286d (diff)
refactor(core): remove RuntimeOptions::extensions_with_js (#18099)
This commit removes "deno_core::RuntimeOptions::extensions_with_js". Now it's embedders' responsibility to properly register extensions that will not contains JavaScript sources when running from an existing snapshot. Prerequisite for https://github.com/denoland/deno/pull/18080
Diffstat (limited to 'core/ops_builtin.rs')
-rw-r--r--core/ops_builtin.rs59
1 files changed, 36 insertions, 23 deletions
diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs
index d225b8624..7b66ffaa4 100644
--- a/core/ops_builtin.rs
+++ b/core/ops_builtin.rs
@@ -1,3 +1,4 @@
+use crate::ExtensionBuilder;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use crate::error::format_file_name;
use crate::error::type_error;
@@ -18,38 +19,50 @@ use std::io::stdout;
use std::io::Write;
use std::rc::Rc;
-pub(crate) fn init_builtins() -> Extension {
+fn ext() -> ExtensionBuilder {
Extension::builder("core")
+}
+
+fn ops(ext: &mut ExtensionBuilder) -> &mut ExtensionBuilder {
+ let mut ops = vec![
+ op_close::decl(),
+ op_try_close::decl(),
+ op_print::decl(),
+ op_resources::decl(),
+ op_wasm_streaming_feed::decl(),
+ op_wasm_streaming_set_url::decl(),
+ op_void_sync::decl(),
+ op_void_async::decl(),
+ op_add::decl(),
+ // // TODO(@AaronO): track IO metrics for builtin streams
+ op_read::decl(),
+ op_read_all::decl(),
+ op_write::decl(),
+ op_write_all::decl(),
+ op_shutdown::decl(),
+ op_metrics::decl(),
+ op_format_file_name::decl(),
+ op_is_proxy::decl(),
+ op_str_byte_length::decl(),
+ ];
+ ops.extend(crate::ops_builtin_v8::init_builtins_v8());
+ ext.ops(ops)
+}
+
+pub(crate) fn init_builtin_ops_and_esm() -> Extension {
+ ops(&mut ext())
.js(include_js_files!(
"00_primordials.js",
"01_core.js",
"02_error.js",
))
- .ops(vec![
- op_close::decl(),
- op_try_close::decl(),
- op_print::decl(),
- op_resources::decl(),
- op_wasm_streaming_feed::decl(),
- op_wasm_streaming_set_url::decl(),
- op_void_sync::decl(),
- op_void_async::decl(),
- op_add::decl(),
- // // TODO(@AaronO): track IO metrics for builtin streams
- op_read::decl(),
- op_read_all::decl(),
- op_write::decl(),
- op_write_all::decl(),
- op_shutdown::decl(),
- op_metrics::decl(),
- op_format_file_name::decl(),
- op_is_proxy::decl(),
- op_str_byte_length::decl(),
- ])
- .ops(crate::ops_builtin_v8::init_builtins_v8())
.build()
}
+pub(crate) fn init_builtin_ops() -> Extension {
+ ops(&mut ext()).build()
+}
+
/// Return map of resources with id as key
/// and string representation as value.
#[op]